@maveio/components 0.0.151 → 0.0.152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-XSVNMS3S.cjs → chunk-22UX4SY2.cjs} +1 -1
- package/dist/{chunk-BRZI5I43.cjs → chunk-2P6HF22Q.cjs} +3 -3
- package/dist/{chunk-S6WN4NLN.js → chunk-6QHPCMNQ.js} +1 -1
- package/dist/{chunk-FDSTNWZP.js → chunk-ALJZRKHQ.js} +1 -1
- package/dist/{chunk-ZXCHPIGV.js → chunk-HKHV3KLY.js} +3 -3
- package/dist/{chunk-LX6MMRGQ.js → chunk-JDU4LP6W.js} +1 -1
- package/dist/chunk-KJFAZKNJ.js +1807 -0
- package/dist/chunk-MB72HBHH.cjs +1 -0
- package/dist/chunk-NV7C4TBM.js +1 -0
- package/dist/{chunk-VGWLQHAV.cjs → chunk-OMKGLQZE.cjs} +2 -2
- package/dist/{chunk-SM4RPLYQ.cjs → chunk-WEZKG6QZ.cjs} +2 -2
- package/dist/chunk-ZXKSNEJF.cjs +1807 -0
- package/dist/components/list.cjs +1 -1
- package/dist/components/list.js +1 -1
- package/dist/components/player.cjs +1 -1
- package/dist/components/player.js +1 -1
- package/dist/components/pop.cjs +1 -1
- package/dist/components/pop.js +1 -1
- package/dist/components/upload.cjs +1 -1
- package/dist/components/upload.js +1 -1
- package/dist/embed/socket.cjs +1 -1
- package/dist/embed/socket.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist/themes/default.cjs +19 -47
- package/dist/themes/default.js +19 -47
- package/dist/themes/dolphin.cjs +29 -33
- package/dist/themes/dolphin.js +29 -33
- package/dist/themes/loader.cjs +1 -1
- package/dist/themes/loader.d.cts +4 -1
- package/dist/themes/loader.d.ts +4 -1
- package/dist/themes/loader.js +1 -1
- package/dist/themes/synthwave.cjs +22 -40
- package/dist/themes/synthwave.js +22 -40
- package/package.json +8 -8
- package/dist/chunk-AEGY4JNC.js +0 -1209
- package/dist/chunk-APKCPW3V.cjs +0 -1209
- package/dist/chunk-KTP5LV2E.cjs +0 -1
- package/dist/chunk-MAOTHFPC.js +0 -1
package/dist/chunk-AEGY4JNC.js
DELETED
|
@@ -1,1209 +0,0 @@
|
|
|
1
|
-
import {a as a$3}from'./chunk-MAOTHFPC.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-DH5I55F5.js';import {a as a$1}from'./chunk-3PLBZPRP.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 $={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"},Y={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},ei={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_PAUSED:"mediaPaused",MEDIA_HAS_PLAYED:"mediaHasPlayed",MEDIA_ENDED:"mediaEnded",MEDIA_MUTED:"mediaMuted",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_IS_PIP:"mediaIsPip",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_PREVIEW_CHAPTER:"mediaPreviewChapter",MEDIA_LOADING:"mediaLoading",MEDIA_BUFFERED:"mediaBuffered",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_CHAPTERS_CUES:"mediaChaptersCues"},Yd=Object.entries(ei),T=Yd.reduce((s,[e,t])=>(s[e]=`${t.toLowerCase()}`,s),{}),ti=Yd.reduce((s,[e,t])=>(s[e]=`${t.toLowerCase()}`,s),{USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"});Object.entries(ti).reduce((s,[e,t])=>{let i=T[e];return i&&(s[t]=i),s},{userinactivechange:"userinactive"});var qd=Object.entries(T).reduce((s,[e,t])=>{let i=ti[e];return i&&(s[t]=i),s},{userinactive:"userinactivechange"}),Et={SUBTITLES:"subtitles",CAPTIONS:"captions",CHAPTERS:"chapters",METADATA:"metadata"},ii={DISABLED:"disabled",SHOWING:"showing"};var fa={MOUSE:"mouse",TOUCH:"touch"},je={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},rt={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var Be={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:s=1}={})=>`current playback rate ${s}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading",SETTINGS:()=>"settings",AUDIO_TRACKS:()=>"audio tracks",QUALITY:()=>"quality"},le={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",ENTER_AIRPLAY:()=>"start airplay",EXIT_AIRPLAY:()=>"stop airplay",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:s=30}={})=>`seek forward ${s} seconds`,SEEK_BACK_N_SECS:({seekOffset:s=30}={})=>`seek back ${s} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"};function zd(s){return s?.map(nm).join(" ")}function nm(s){if(s){let{id:e,width:t,height:i}=s;return [e,t,i].filter(r=>r!=null).join(":")}}function Xd(s){return s?.map(am).join(" ")}function am(s){if(s){let{id:e,kind:t,language:i,label:r}=s;return [e,t,i,r].filter(n=>n!=null).join(":")}}function Qs(s,e=false){return s.split("_").map(function(t,i){return (i||e?t[0].toUpperCase():t[0].toLowerCase())+t.slice(1).toLowerCase()}).join("")}function jd(s){return typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s)}var Zs=s=>new Promise(e=>setTimeout(e,s));var Qd=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],om=(s,e)=>{let t=s===1?Qd[e].singular:Qd[e].plural;return `${s} ${t}`},si=s=>{if(!jd(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,l)=>o&&om(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function vt(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 Js=(s,e,t=".value")=>{let i=s.querySelector(t);i&&(i.textContent=e);},dm=(s,e)=>{let t=`slot[name="${e}"]`,i=s.shadowRoot.querySelector(t);return i?i.children:[]},er=(s,e)=>dm(s,e)[0],Vt=(s,e)=>!s||!e?false:s.contains(e)?true:Vt(s,e.getRootNode().host),Kt=(s,e)=>{if(!s)return null;let t=s.closest(e);return t||Kt(s.getRootNode().host,e)};function ga(s=document){var e;let t=s?.activeElement;return t?(e=ga(t.shadowRoot))!=null?e:t:null}function Zd(s){var e;let t=(e=s?.getRootNode)==null?void 0:e.call(s);return t instanceof ShadowRoot||t instanceof Document?t:null}function Jd(s,e=3){if(s.checkVisibility)return s.checkVisibility({checkOpacity:true,checkVisibilityCSS:true});let t=s;for(;t&&e>0;){let i=getComputedStyle(t);if(i.opacity==="0"||i.visibility==="hidden"||i.display==="none")return false;t=t.parentElement,e--;}return true}function ec(s,e,t,i){let r=ma(t,i),n=ma(t,{x:s,y:e}),a=ma(i,{x:s,y:e});return n>r||a>r?n>a?1:0:n/r}function ma(s,e){return Math.sqrt(Math.pow(e.x-s.x,2)+Math.pow(e.y-s.y,2))}function ce(s,e){let t=cm(s,i=>i===e);return t||pa(s,e)}function cm(s,e){var t;let i;for(i of s.querySelectorAll("style")){let r;try{r=(t=i.sheet)==null?void 0:t.cssRules;}catch{continue}for(let n of r??[])if(e(n.selectorText))return n}}function pa(s,e){var t,i;let r=(t=s.querySelectorAll("style"))!=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 oe(s,e,t=Number.NaN){let i=s.getAttribute(e);return i!=null?+i:t}function me(s,e,t){let i=+t;if(t==null||Number.isNaN(i)){s.hasAttribute(e)&&s.removeAttribute(e);return}oe(s,e,void 0)!==i&&s.setAttribute(e,`${i}`);}function re(s,e){return s.hasAttribute(e)}function ie(s,e,t){if(t==null){s.hasAttribute(e)&&s.removeAttribute(e);return}re(s,e)!=t&&s.toggleAttribute(e,t);}function Ae(s,e,t=null){var i;return (i=s.getAttribute(e))!=null?i:t}function ge(s,e,t){if(t==null){s.hasAttribute(e)&&s.removeAttribute(e);return}let i=`${t}`;Ae(s,e,void 0)!==i&&s.setAttribute(e,i);}var tr=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return true}},Ea=class{observe(){}unobserve(){}disconnect(){}},tc={createElement:function(){return new ir.HTMLElement},createElementNS:function(){return new ir.HTMLElement},addEventListener(){},removeEventListener(){}},ir={ResizeObserver:Ea,document:tc,HTMLElement:class extends tr{},DocumentFragment:class extends tr{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return ""}},matchMedia(s){return {matches:false,media:s}}},ic=typeof window>"u"||typeof window.customElements>"u",sc=Object.keys(ir).every(s=>s in globalThis),_=ic&&!sc?ir:globalThis,M=ic&&!sc?tc:globalThis.document;var hm=Object.defineProperty,um=(s,e,t)=>e in s?hm(s,e,{enumerable:true,configurable:true,writable:true,value:t}):s[e]=t,fm=(s,e,t)=>(um(s,e+"",t),t),rc=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},et=(s,e,t)=>(rc(s,e,"read from private field"),t?t.call(s):e.get(s)),sr=(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);},rr=(s,e,t,i)=>(rc(s,e,"write to private field"),e.set(s,t),t),Tt,nr,bi,ar,nc=M.createElement("template");nc.innerHTML=`
|
|
2
|
-
<style>
|
|
3
|
-
:host {
|
|
4
|
-
font: var(--media-font,
|
|
5
|
-
var(--media-font-weight, bold)
|
|
6
|
-
var(--media-font-size, 14px) /
|
|
7
|
-
var(--media-text-content-height, var(--media-control-height, 24px))
|
|
8
|
-
var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
|
|
9
|
-
color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
|
|
10
|
-
background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
|
|
11
|
-
padding: var(--media-button-padding, var(--media-control-padding, 10px));
|
|
12
|
-
justify-content: var(--media-button-justify-content, center);
|
|
13
|
-
display: inline-flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
vertical-align: middle;
|
|
16
|
-
box-sizing: border-box;
|
|
17
|
-
transition: background .15s linear;
|
|
18
|
-
pointer-events: auto;
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
-webkit-tap-highlight-color: transparent;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
:host(:focus-visible) {
|
|
25
|
-
box-shadow: inset 0 0 0 2px rgb(27 127 204 / .9);
|
|
26
|
-
outline: 0;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
:host(:where(:focus)) {
|
|
30
|
-
box-shadow: none;
|
|
31
|
-
outline: 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
:host(:hover) {
|
|
35
|
-
background: var(--media-control-hover-background, rgba(50 50 70 / .7));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
svg, img, ::slotted(svg), ::slotted(img) {
|
|
39
|
-
width: var(--media-button-icon-width);
|
|
40
|
-
height: var(--media-button-icon-height, var(--media-control-height, 24px));
|
|
41
|
-
transform: var(--media-button-icon-transform);
|
|
42
|
-
transition: var(--media-button-icon-transition);
|
|
43
|
-
fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
|
|
44
|
-
vertical-align: middle;
|
|
45
|
-
max-width: 100%;
|
|
46
|
-
max-height: 100%;
|
|
47
|
-
min-width: 100%;
|
|
48
|
-
}
|
|
49
|
-
</style>
|
|
50
|
-
`;var he=class extends _.HTMLElement{constructor(e={}){if(super(),sr(this,Tt,void 0),fm(this,"preventClick",false),sr(this,nr,t=>{this.preventClick||this.handleClick(t);}),sr(this,bi,t=>{let{key:i}=t;if(!this.keysUsed.includes(i)){this.removeEventListener("keyup",et(this,bi));return}this.preventClick||this.handleClick(t);}),sr(this,ar,t=>{let{metaKey:i,altKey:r,key:n}=t;if(i||r||!this.keysUsed.includes(n)){this.removeEventListener("keyup",et(this,bi));return}this.addEventListener("keyup",et(this,bi),{once:true});}),!this.shadowRoot){this.attachShadow({mode:"open"});let t=nc.content.cloneNode(true);this.nativeEl=t;let i=e.slotTemplate;i||(i=M.createElement("template"),i.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(i.content.cloneNode(true)),this.shadowRoot.appendChild(t);}}static get observedAttributes(){return ["disabled",Y.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",et(this,nr)),this.addEventListener("keydown",et(this,ar)),this.tabIndex=0;}disable(){this.removeEventListener("click",et(this,nr)),this.removeEventListener("keydown",et(this,ar)),this.removeEventListener("keyup",et(this,bi)),this.tabIndex=-1;}attributeChangedCallback(e,t,i){var r,n,a,o,l;e===Y.MEDIA_CONTROLLER?(t&&((n=(r=et(this,Tt))==null?void 0:r.unassociateElement)==null||n.call(r,this),rr(this,Tt,null)),i&&this.isConnected&&(rr(this,Tt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=et(this,Tt))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&i!==t&&(i==null?this.enable():this.disable());}connectedCallback(){var e,t,i;let{style:r}=ce(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");let n=this.getAttribute(Y.MEDIA_CONTROLLER);n&&(rr(this,Tt,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=et(this,Tt))==null?void 0:t.associateElement)==null||i.call(t,this));}disconnectedCallback(){var e,t;this.disable(),(t=(e=et(this,Tt))==null?void 0:e.unassociateElement)==null||t.call(e,this),rr(this,Tt,null);}get keysUsed(){return ["Enter"," "]}handleClick(e){}};Tt=new WeakMap;nr=new WeakMap;bi=new WeakMap;ar=new WeakMap;_.customElements.get("media-chrome-button")||_.customElements.define("media-chrome-button",he);var ac=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
51
|
-
<path d="M22.13 3H3.87a.87.87 0 0 0-.87.87v13.26a.87.87 0 0 0 .87.87h3.4L9 16H5V5h16v11h-4l1.72 2h3.4a.87.87 0 0 0 .87-.87V3.87a.87.87 0 0 0-.86-.87Zm-8.75 11.44a.5.5 0 0 0-.76 0l-4.91 5.73a.5.5 0 0 0 .38.83h9.82a.501.501 0 0 0 .38-.83l-4.91-5.73Z"/>
|
|
52
|
-
</svg>
|
|
53
|
-
`,lc=M.createElement("template");lc.innerHTML=`
|
|
54
|
-
<style>
|
|
55
|
-
:host([${T.MEDIA_IS_AIRPLAYING}]) slot:not([name=exit]):not([name=icon]) {
|
|
56
|
-
display: none !important;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
:host(:not([${T.MEDIA_IS_AIRPLAYING}])) slot:not([name=enter]):not([name=icon]) {
|
|
61
|
-
display: none !important;
|
|
62
|
-
}
|
|
63
|
-
</style>
|
|
64
|
-
|
|
65
|
-
<slot name="icon">
|
|
66
|
-
<slot name="enter">${ac}</slot>
|
|
67
|
-
<slot name="exit">${ac}</slot>
|
|
68
|
-
</slot>
|
|
69
|
-
`;var oc=s=>{let e=s.mediaIsAirplaying?le.EXIT_AIRPLAY():le.ENTER_AIRPLAY();s.setAttribute("aria-label",e);},va=class extends he{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_IS_AIRPLAYING,T.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:lc,...e});}connectedCallback(){super.connectedCallback(),oc(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_IS_AIRPLAYING&&oc(this);}get mediaIsAirplaying(){return re(this,T.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){ie(this,T.MEDIA_IS_AIRPLAYING,e);}get mediaAirplayUnavailable(){return Ae(this,T.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){ge(this,T.MEDIA_AIRPLAY_UNAVAILABLE,e);}handleClick(){let e=new _.CustomEvent($.MEDIA_AIRPLAY_REQUEST,{composed:true,bubbles:true});this.dispatchEvent(e);}};_.customElements.get("media-airplay-button")||_.customElements.define("media-airplay-button",va);var mm='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',gm='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',cc=M.createElement("template");cc.innerHTML=`
|
|
70
|
-
<style>
|
|
71
|
-
:host([${T.MEDIA_IS_CASTING}]) slot:not([name=exit]):not([name=icon]) {
|
|
72
|
-
display: none !important;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
:host(:not([${T.MEDIA_IS_CASTING}])) slot:not([name=enter]):not([name=icon]) {
|
|
77
|
-
display: none !important;
|
|
78
|
-
}
|
|
79
|
-
</style>
|
|
80
|
-
|
|
81
|
-
<slot name="icon">
|
|
82
|
-
<slot name="enter">${mm}</slot>
|
|
83
|
-
<slot name="exit">${gm}</slot>
|
|
84
|
-
</slot>
|
|
85
|
-
`;var dc=s=>{let e=s.mediaIsCasting?le.EXIT_CAST():le.ENTER_CAST();s.setAttribute("aria-label",e);},Ta=class extends he{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_IS_CASTING,T.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:cc,...e});}connectedCallback(){super.connectedCallback(),dc(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_IS_CASTING&&dc(this);}get mediaIsCasting(){return re(this,T.MEDIA_IS_CASTING)}set mediaIsCasting(e){ie(this,T.MEDIA_IS_CASTING,e);}get mediaCastUnavailable(){return Ae(this,T.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){ge(this,T.MEDIA_CAST_UNAVAILABLE,e);}handleClick(){let e=this.mediaIsCasting?$.MEDIA_EXIT_CAST_REQUEST:$.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new _.CustomEvent(e,{composed:true,bubbles:true}));}};_.customElements.get("media-cast-button")||_.customElements.define("media-cast-button",Ta);var hc=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Wt=(s,e,t)=>(hc(s,e,"read from private field"),t?t.call(s):e.get(s)),pm=(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);},or=(s,e,t,i)=>(hc(s,e,"write to private field"),e.set(s,t),t),Ke,uc=M.createElement("template");uc.innerHTML=`
|
|
86
|
-
<style>
|
|
87
|
-
:host {
|
|
88
|
-
display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
|
|
89
|
-
box-sizing: border-box;
|
|
90
|
-
}
|
|
91
|
-
</style>
|
|
92
|
-
`;var Aa=class extends _.HTMLElement{constructor(e={}){if(super(),pm(this,Ke,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),i=uc.content.cloneNode(true);this.nativeEl=i;let r=e.slotTemplate;r||(r=M.createElement("template"),r.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(r.content.cloneNode(true)),t.appendChild(i);}}static get observedAttributes(){return [Y.MEDIA_CONTROLLER,T.MEDIA_PAUSED]}attributeChangedCallback(e,t,i){var r,n,a,o,l;e===Y.MEDIA_CONTROLLER&&(t&&((n=(r=Wt(this,Ke))==null?void 0:r.unassociateElement)==null||n.call(r,this),or(this,Ke,null)),i&&this.isConnected&&(or(this,Ke,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=Wt(this,Ke))==null?void 0:o.associateElement)==null||l.call(o,this)));}connectedCallback(){var e,t,i,r;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),or(this,Ke,Em(this)),this.getAttribute(Y.MEDIA_CONTROLLER)&&((t=(e=Wt(this,Ke))==null?void 0:e.associateElement)==null||t.call(e,this)),(i=Wt(this,Ke))==null||i.addEventListener("pointerdown",this),(r=Wt(this,Ke))==null||r.addEventListener("click",this);}disconnectedCallback(){var e,t,i,r;this.getAttribute(Y.MEDIA_CONTROLLER)&&((t=(e=Wt(this,Ke))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(i=Wt(this,Ke))==null||i.removeEventListener("pointerdown",this),(r=Wt(this,Ke))==null||r.removeEventListener("click",this),or(this,Ke,null);}handleEvent(e){var t;let i=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(i?.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){let{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:c}=this.getBoundingClientRect(),h=n-o,u=a-l;if(h<0||u<0||h>d||u>c||d===0&&c===0)return;let{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===fa.TOUCH){this.handleTap(e);return}else if(f===fa.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return re(this,T.MEDIA_PAUSED)}set mediaPaused(e){ie(this,T.MEDIA_PAUSED,e);}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new _.CustomEvent(t,{composed:true,bubbles:true}));}};Ke=new WeakMap;function Em(s){var e;let t=s.getAttribute(Y.MEDIA_CONTROLLER);return t?(e=s.getRootNode())==null?void 0:e.getElementById(t):Kt(s,"media-controller")}_.customElements.get("media-gesture-receiver")||_.customElements.define("media-gesture-receiver",Aa);var fc=new WeakMap,ba=s=>{let e=fc.get(s);return e||fc.set(s,e=new Set),e},mc=new _.ResizeObserver(s=>{for(let e of s)for(let t of ba(e.target))t(e);});function ri(s,e){ba(s).add(e),mc.observe(s);}function ls(s,e){let t=ba(s);t.delete(e),t.size||mc.unobserve(s);}var vm=Object.defineProperty,Tm=(s,e,t)=>e in s?vm(s,e,{enumerable:true,configurable:true,writable:true,value:t}):s[e]=t,Am=(s,e,t)=>(Tm(s,e+"",t),t),Ia=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Sa=(s,e,t)=>(Ia(s,e,"read from private field"),e.get(s)),ni=(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);},ya=(s,e,t,i)=>(Ia(s,e,"write to private field"),e.set(s,t),t),nt=(s,e,t)=>(Ia(s,e,"access private method"),t),lr,yi,_a,gc,xa,pc,ds,cr,hr,La,Si,cs,te={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},Ec=M.createElement("template");Ec.innerHTML=`
|
|
93
|
-
<style>
|
|
94
|
-
|
|
95
|
-
:host([${T.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
|
|
96
|
-
outline: none;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
:host {
|
|
100
|
-
box-sizing: border-box;
|
|
101
|
-
position: relative;
|
|
102
|
-
display: inline-block;
|
|
103
|
-
line-height: 0;
|
|
104
|
-
background-color: var(--media-background-color, #000);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
:host(:not([${te.AUDIO}])) [part~=layer]:not([part~=media-layer]) {
|
|
108
|
-
position: absolute;
|
|
109
|
-
top: 0;
|
|
110
|
-
left: 0;
|
|
111
|
-
bottom: 0;
|
|
112
|
-
right: 0;
|
|
113
|
-
display: flex;
|
|
114
|
-
flex-flow: column nowrap;
|
|
115
|
-
align-items: start;
|
|
116
|
-
pointer-events: none;
|
|
117
|
-
background: none;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
slot[name=media] {
|
|
121
|
-
display: var(--media-slot-display, contents);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
:host([${te.AUDIO}]) slot[name=media] {
|
|
126
|
-
display: var(--media-slot-display, none);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
:host([${te.AUDIO}]) [part~=layer][part~=gesture-layer] {
|
|
131
|
-
height: 0;
|
|
132
|
-
display: block;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
:host(:not([${te.AUDIO}])[${te.GESTURES_DISABLED}]) ::slotted([slot=gestures-chrome]),
|
|
137
|
-
:host(:not([${te.AUDIO}])[${te.GESTURES_DISABLED}]) media-gesture-receiver[slot=gestures-chrome] {
|
|
138
|
-
display: none;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
::slotted(:not([slot=media]):not([slot=poster]):not(media-loading-indicator):not([hidden])) {
|
|
143
|
-
pointer-events: auto;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
:host(:not([${te.AUDIO}])) *[part~=layer][part~=centered-layer] {
|
|
147
|
-
align-items: center;
|
|
148
|
-
justify-content: center;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
:host(:not([${te.AUDIO}])) ::slotted(media-gesture-receiver[slot=gestures-chrome]),
|
|
152
|
-
:host(:not([${te.AUDIO}])) media-gesture-receiver[slot=gestures-chrome] {
|
|
153
|
-
align-self: stretch;
|
|
154
|
-
flex-grow: 1;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
slot[name=middle-chrome] {
|
|
158
|
-
display: inline;
|
|
159
|
-
flex-grow: 1;
|
|
160
|
-
pointer-events: none;
|
|
161
|
-
background: none;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
::slotted([slot=media]),
|
|
166
|
-
::slotted([slot=poster]) {
|
|
167
|
-
width: 100%;
|
|
168
|
-
height: 100%;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
:host(:not([${te.AUDIO}])) .spacer {
|
|
173
|
-
flex-grow: 1;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
:host(:-webkit-full-screen) {
|
|
178
|
-
|
|
179
|
-
width: 100% !important;
|
|
180
|
-
height: 100% !important;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
::slotted(:not([slot=media]):not([slot=poster]):not([${te.NO_AUTOHIDE}]):not([hidden])) {
|
|
185
|
-
opacity: 1;
|
|
186
|
-
transition: opacity 0.25s;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
:host([${te.USER_INACTIVE}]:not([${T.MEDIA_PAUSED}]):not([${T.MEDIA_IS_AIRPLAYING}]):not([${T.MEDIA_IS_CASTING}]):not([${te.AUDIO}])) ::slotted(:not([slot=media]):not([slot=poster]):not([${te.NO_AUTOHIDE}])) {
|
|
191
|
-
opacity: 0;
|
|
192
|
-
transition: opacity 1s;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
:host([${te.USER_INACTIVE}]:not([${T.MEDIA_PAUSED}]):not([${T.MEDIA_IS_CASTING}]):not([${te.AUDIO}])) ::slotted([slot=media]) {
|
|
196
|
-
cursor: none;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
::slotted(media-control-bar) {
|
|
200
|
-
align-self: stretch;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
:host(:not([${te.AUDIO}])[${T.MEDIA_HAS_PLAYED}]) slot[name=poster] {
|
|
205
|
-
display: none;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
::slotted([role="menu"]) {
|
|
209
|
-
align-self: end;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
::slotted([role="dialog"]) {
|
|
213
|
-
align-self: center;
|
|
214
|
-
}
|
|
215
|
-
</style>
|
|
216
|
-
|
|
217
|
-
<slot name="media" part="layer media-layer"></slot>
|
|
218
|
-
<slot name="poster" part="layer poster-layer"></slot>
|
|
219
|
-
<slot name="gestures-chrome" part="layer gesture-layer">
|
|
220
|
-
<media-gesture-receiver slot="gestures-chrome"></media-gesture-receiver>
|
|
221
|
-
</slot>
|
|
222
|
-
<span part="layer vertical-layer">
|
|
223
|
-
<slot name="top-chrome" part="top chrome"></slot>
|
|
224
|
-
<slot name="middle-chrome" part="middle chrome"></slot>
|
|
225
|
-
<slot name="centered-chrome" part="layer centered-layer center centered chrome"></slot>
|
|
226
|
-
|
|
227
|
-
<slot part="bottom chrome"></slot>
|
|
228
|
-
</span>
|
|
229
|
-
`;var bm=Object.values(T),ym="sm:384 md:576 lg:768 xl:960";function Sm(s){_m(s.target,s.contentRect.width);}function _m(s,e){var t;if(!s.isConnected)return;let i=(t=s.getAttribute(te.BREAKPOINTS))!=null?t:ym,r=xm(i),n=Im(r,e),a=false;if(Object.keys(r).forEach(o=>{if(n.includes(o)){s.hasAttribute(`breakpoint${o}`)||(s.setAttribute(`breakpoint${o}`,""),a=true);return}s.hasAttribute(`breakpoint${o}`)&&(s.removeAttribute(`breakpoint${o}`),a=true);}),a){let o=new CustomEvent(ti.BREAKPOINTS_CHANGE,{detail:n});s.dispatchEvent(o);}}function xm(s){let e=s.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function Im(s,e){return Object.keys(s).filter(t=>e>=s[t])}var dr=class extends _.HTMLElement{constructor(){super(),ni(this,_a),ni(this,xa),ni(this,ds),ni(this,hr),ni(this,Si),ni(this,lr,0),ni(this,yi,void 0),Am(this,"breakpointsComputed",false),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ec.content.cloneNode(true)));let e=a=>{let o=this.media;for(let l of a)l.type==="childList"&&(l.removedNodes.forEach(d=>{if(d.slot=="media"&&l.target==this){let c=l.previousSibling&&l.previousSibling.previousElementSibling;if(!c||!o)this.mediaUnsetCallback(d);else {let h=c.slot!=="media";for(;(c=c.previousSibling)!==null;)c.slot=="media"&&(h=false);h&&this.mediaUnsetCallback(d);}}}),o&&l.addedNodes.forEach(d=>{d===o&&this.handleMediaUpdated(o);}));};new MutationObserver(e).observe(this,{childList:true,subtree:true});let i=false;ri(this,a=>{i||(setTimeout(()=>{Sm(a),i=false,this.breakpointsComputed||(this.breakpointsComputed=true,this.dispatchEvent(new CustomEvent(ti.BREAKPOINTS_COMPUTED,{bubbles:true,composed:true})));},0),i=true);});let n=this.querySelector(":scope > slot[slot=media]");n&&n.addEventListener("slotchange",()=>{if(!n.assignedElements({flatten:true}).length){Sa(this,yi)&&this.mediaUnsetCallback(Sa(this,yi));return}this.handleMediaUpdated(this.media);});}static get observedAttributes(){return [te.AUTOHIDE,te.GESTURES_DISABLED].concat(bm).filter(e=>![T.MEDIA_RENDITION_LIST,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_CHAPTERS_CUES].includes(e))}attributeChangedCallback(e,t,i){e.toLowerCase()==te.AUTOHIDE&&(this.autohide=i);}get media(){let e=this.querySelector(":scope > [slot=media]");return e?.nodeName=="SLOT"&&(e=e.assignedElements({flatten:true})[0]),e}async handleMediaUpdated(e){e&&(ya(this,yi,e),e.localName.includes("-")&&await _.customElements.whenDefined(e.localName),this.mediaSetCallback(e));}connectedCallback(){var e;let i=this.getAttribute(te.AUDIO)!=null?Be.AUDIO_PLAYER():Be.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",i),this.handleMediaUpdated(this.media),this.setAttribute(te.USER_INACTIVE,""),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=_.window)==null||e.addEventListener("mouseup",this);}disconnectedCallback(){var e;this.media&&this.mediaUnsetCallback(this.media),(e=_.window)==null||e.removeEventListener("mouseup",this);}mediaSetCallback(e){}mediaUnsetCallback(e){ya(this,yi,null);}handleEvent(e){switch(e.type){case "pointerdown":ya(this,lr,e.timeStamp);break;case "pointermove":nt(this,_a,gc).call(this,e);break;case "pointerup":nt(this,xa,pc).call(this,e);break;case "mouseleave":nt(this,ds,cr).call(this);break;case "mouseup":this.removeAttribute(te.KEYBOARD_CONTROL);break;case "keyup":nt(this,Si,cs).call(this),this.setAttribute(te.KEYBOARD_CONTROL,"");break}}set autohide(e){e=Number(e),this._autohide=isNaN(e)?0:e;}get autohide(){return this._autohide===void 0?2:this._autohide}};lr=new WeakMap;yi=new WeakMap;_a=new WeakSet;gc=function(s){s.pointerType!=="mouse"&&s.timeStamp-Sa(this,lr)<250||(nt(this,hr,La).call(this),clearTimeout(this._inactiveTimeout),[this,this.media].includes(s.target)&&nt(this,Si,cs).call(this));};xa=new WeakSet;pc=function(s){if(s.pointerType==="touch"){let e=!this.hasAttribute(te.USER_INACTIVE);[this,this.media].includes(s.target)&&e?nt(this,ds,cr).call(this):nt(this,Si,cs).call(this);}else s.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e?.localName))&&nt(this,Si,cs).call(this);};ds=new WeakSet;cr=function(){if(this.autohide<0||this.hasAttribute(te.USER_INACTIVE))return;this.setAttribute(te.USER_INACTIVE,"");let s=new _.CustomEvent(ti.USER_INACTIVE,{composed:true,bubbles:true,detail:true});this.dispatchEvent(s);};hr=new WeakSet;La=function(){if(!this.hasAttribute(te.USER_INACTIVE))return;this.removeAttribute(te.USER_INACTIVE);let s=new _.CustomEvent(ti.USER_INACTIVE,{composed:true,bubbles:true,detail:false});this.dispatchEvent(s);};Si=new WeakSet;cs=function(){nt(this,hr,La).call(this),clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=setTimeout(()=>{nt(this,ds,cr).call(this);},this.autohide*1e3));};var vc=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},De=(s,e,t)=>(vc(s,e,"read from private field"),t?t.call(s):e.get(s)),hs=(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);},ur=(s,e,t,i)=>(vc(s,e,"write to private field"),e.set(s,t),t),_i,xi,fr,ai,Bt,Yt,Ii=class{constructor(e,t,{defaultValue:i}={defaultValue:void 0}){hs(this,Bt),hs(this,_i,void 0),hs(this,xi,void 0),hs(this,fr,void 0),hs(this,ai,new Set),ur(this,_i,e),ur(this,xi,t),ur(this,fr,new Set(i));}[Symbol.iterator](){return De(this,Bt,Yt).values()}get length(){return De(this,Bt,Yt).size}get value(){var e;return (e=[...De(this,Bt,Yt)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(ur(this,ai,new Set),this.add(...(t=e?.split(" "))!=null?t:[]));}toString(){return this.value}item(e){return [...De(this,Bt,Yt)][e]}values(){return De(this,Bt,Yt).values()}forEach(e){De(this,Bt,Yt).forEach(e);}add(...e){var t,i;e.forEach(r=>De(this,ai).add(r)),!(this.value===""&&!((t=De(this,_i))!=null&&t.hasAttribute(`${De(this,xi)}`)))&&((i=De(this,_i))==null||i.setAttribute(`${De(this,xi)}`,`${this.value}`));}remove(...e){var t;e.forEach(i=>De(this,ai).delete(i)),(t=De(this,_i))==null||t.setAttribute(`${De(this,xi)}`,`${this.value}`);}contains(e){return De(this,Bt,Yt).has(e)}toggle(e,t){return typeof t<"u"?t?(this.add(e),true):(this.remove(e),false):this.contains(e)?(this.remove(e),false):(this.add(e),true)}replace(e,t){return this.remove(e),this.add(t),e===t}};_i=new WeakMap;xi=new WeakMap;fr=new WeakMap;ai=new WeakMap;Bt=new WeakSet;Yt=function(){return De(this,ai).size?De(this,ai):De(this,fr)};var Lm=(s="")=>s.split(/\s+/),Tc=(s="")=>{let[e,t,i]=s.split(":"),r=i?decodeURIComponent(i):void 0;return e=e==="cc"?"captions":"subtitles",{kind:e,language:t,label:r}},us=(s="",e={})=>Lm(s).map(t=>{let i=Tc(t);return {...e,...i}}),Ra=s=>Array.isArray(s)?s.map(e=>typeof e=="string"?Tc(e):e):typeof s=="string"?us(s):[s],mr=({kind:s,label:e,language:t}={kind:"subtitles"})=>e?`${s==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,oi=(s=[])=>Array.prototype.map.call(s,mr).join(" "),Rm=(s,e)=>t=>t[s]===e,Ac=s=>{let e=Object.entries(s).map(([t,i])=>Rm(t,i));return t=>e.every(i=>i(t))},Li=(s,e=[],t=[])=>{let i=Ra(t).map(Ac),r=n=>i.some(a=>a(n));Array.from(e).filter(r).forEach(n=>{n.mode=s;});},Ri=(s,e=()=>true)=>{if(!s?.textTracks)return [];let t=typeof e=="function"?e:Ac(e);return Array.from(s.textTracks).filter(t)},bc=s=>!!s.getAttribute(T.MEDIA_SUBTITLES_SHOWING);var be={enter:"requestFullscreen",exit:"exitFullscreen",rootEvents:["fullscreenchange"],mediaEvents:[],element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};M.fullscreenElement===void 0&&(be.enter="webkitRequestFullScreen",be.exit=M.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",be.rootEvents=["webkitfullscreenchange"],be.mediaEvents=["webkitbeginfullscreen","webkitendfullscreen"],be.element="webkitFullscreenElement",be.error="webkitfullscreenerror",be.enabled="webkitFullscreenEnabled");var gr,Da=()=>{var s,e;return gr||(gr=(e=(s=M)==null?void 0:s.createElement)==null?void 0:e.call(s,"video"),gr)},yc=async(s=Da())=>{if(!s)return false;let e=s.volume;return s.volume=e/2+.1,await Zs(0),s.volume!==e},Dm=/.*Version\/.*Safari\/.*/.test(_.navigator.userAgent),Cm=(s=Da())=>_.matchMedia("(display-mode: standalone)").matches&&Dm?false:typeof s?.requestPictureInPicture=="function",km=(s=Da())=>{let e=M[be.enabled];return !e&&s&&(e="webkitSupportsFullscreen"in s),e},Ca=km(),Sc=Cm(),_c=!!_.WebKitPlaybackTargetAvailabilityEvent,xc=!!_.chrome;var Er,Ic=yc().then(s=>(Er=s,Er)),wm=Object.values(rt),pr=s=>Ri(s.media,e=>[Et.SUBTITLES,Et.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),Lc=s=>Ri(s.media,e=>e.mode===ii.SHOWING&&[Et.SUBTITLES,Et.CAPTIONS].includes(e.kind)),We={MEDIA_PAUSED:{get:function(s){let{media:e}=s;return e?e.paused:true},mediaEvents:["play","playing","pause","emptied"]},MEDIA_HAS_PLAYED:{get:function(s){let{media:e}=s;return e?!e.paused:false},mediaEvents:["playing","emptied"]},MEDIA_ENDED:{get:function(s){let{media:e}=s;return e?e.ended:false},mediaEvents:["seeked","ended","emptied"]},MEDIA_PLAYBACK_RATE:{get:function(s){let{media:e}=s;return !e||typeof e.playbackRate>"u"?1:e.playbackRate},mediaEvents:["ratechange","loadstart"]},MEDIA_MUTED:{get:function(s){let{media:e}=s;return !e||typeof e.muted>"u"?false:e.muted},mediaEvents:["volumechange"]},MEDIA_VOLUME:{get:function(s){let{media:e}=s;return !e||typeof e.volume>"u"?1:Number(e.volume)},mediaEvents:["volumechange"]},MEDIA_VOLUME_LEVEL:{get:function(s){let{media:e}=s,t="high";if(!e||typeof e.volume>"u")return t;let{muted:i,volume:r}=e;return r===0||i?t="off":r<.5?t="low":r<.75&&(t="medium"),t},mediaEvents:["volumechange"]},MEDIA_CURRENT_TIME:{get:function(s){let{media:e}=s;return !e||typeof e.currentTime>"u"?0:e.currentTime},mediaEvents:["playing","pause","timeupdate","loadedmetadata"]},MEDIA_DURATION:{get:function(s){let{media:e}=s;return s.hasAttribute("defaultduration")&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?+s.getAttribute("defaultduration"):!e||!Number.isFinite(e.duration)?Number.NaN:e.duration},mediaEvents:["durationchange","loadedmetadata","emptied"]},MEDIA_SEEKABLE:{get:function(s){var e;let{media:t}=s;if(!((e=t?.seekable)!=null&&e.length))return;let i=t.seekable.start(0),r=t.seekable.end(t.seekable.length-1);if(!(!i&&!r))return [Number(i.toFixed(3)),Number(r.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress"]},MEDIA_LOADING:{get:function(s){var e;return ((e=s.media)==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},MEDIA_BUFFERED:{get:function(s){var e,t,i;let r=(e=s.media)==null?void 0:e.buffered;return Array.from((i=(t=s.media)==null?void 0:t.buffered)!=null?i:[]).map((n,a)=>[Number(r.start(a)).toFixed(3),Number(r.end(a)).toFixed(3)])},mediaEvents:["progress","emptied"]},MEDIA_STREAM_TYPE:{get:function(s){let{media:e}=s;if(!e)return;let{streamType:t}=e;if(wm.includes(t)){if(t===rt.UNKNOWN){let r=s.getAttribute("defaultstreamtype");return [rt.LIVE,rt.ON_DEMAND].includes(r)?r:void 0}return t}let i=e.duration;if(i===1/0)return rt.LIVE;if(Number.isFinite(i))return rt.ON_DEMAND;{let r=s.getAttribute("defaultstreamtype");if([rt.LIVE,rt.ON_DEMAND].includes(r))return r}},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},MEDIA_TARGET_LIVE_WINDOW:{get:function(s){let{media:e}=s;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,i=We.MEDIA_STREAM_TYPE.get(s);return (t==null||Number.isNaN(t))&&i===rt.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},MEDIA_TIME_IS_LIVE:{get:function(s){let{media:e}=s;if(!e)return false;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?false:e.currentTime>=e.liveEdgeStart;if(!(We.MEDIA_STREAM_TYPE.get(s)==="live"))return false;let i=e.seekable;if(!i)return true;if(!i.length)return false;let r=s.hasAttribute("liveedgeoffset")?Number(s.getAttribute("liveedgeoffset")):10,n=i.end(i.length-1)-r;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},MEDIA_IS_FULLSCREEN:{get:function(s,e){var t,i;let r=s.media;if(r&&M[be.element]===void 0&&"webkitDisplayingFullscreen"in r)return r.webkitDisplayingFullscreen&&r.webkitPresentationMode==="fullscreen";let n;return e?n=M[be.element]?e.target:null:n=(i=(t=Zd(s))==null?void 0:t.fullscreenElement)!=null?i:M[be.element],Vt(s.fullscreenElement,n)},rootEvents:be.rootEvents,mediaEvents:be.mediaEvents},MEDIA_IS_PIP:{get:function(s,e){var t;let i=s.media;if(!i)return false;if(e)return e.type=="enterpictureinpicture";{let r=(t=s.getRootNode().pictureInPictureElement)!=null?t:M.pictureInPictureElement;return Vt(i,r)}},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},MEDIA_IS_AIRPLAYING:{get:function(s){var e;let{media:t}=s;return !t?.remote||((e=t.remote)==null?void 0:e.state)==="disconnected"?false:t.remote.state},remoteEvents:["playing","connect","connecting","disconnect"]},MEDIA_IS_CASTING:{get:function(s){var e;let{media:t}=s;return !t?.remote||((e=t.remote)==null?void 0:e.state)==="disconnected"?false:t.remote.state},remoteEvents:["connect","connecting","disconnect"]},MEDIA_AIRPLAY_UNAVAILABLE:{get:function(s,{availability:e=false}={}){if(!_c)return je.UNSUPPORTED;if(!(e==null||e===true))return je.UNAVAILABLE},mediaSetCallback(s,e){var t;s.disableRemotePlayback||s.hasAttribute("disableremoteplayback")||(t=s.remote)==null||t.watchAvailability(r=>e({availability:r})).catch(r=>{r.name==="NotSupportedError"?e({availability:null}):e({availability:false});});},mediaUnsetCallback(s){var e;s.disableRemotePlayback||s.hasAttribute("disableremoteplayback")||(e=s.remote)==null||e.cancelWatchAvailability();}},MEDIA_CAST_UNAVAILABLE:{get:function(s,{availability:e=false}={}){var t;let{media:i}=s;if(!xc||!((t=i?.remote)!=null&&t.state))return je.UNSUPPORTED;if(!(e==null||e===true))return je.UNAVAILABLE},mediaSetCallback(s,e){var t;s.disableRemotePlayback||s.hasAttribute("disableremoteplayback")||(t=s.remote)==null||t.watchAvailability(r=>e({availability:r})).catch(r=>{r.name==="NotSupportedError"?e({availability:null}):e({availability:false});});},mediaUnsetCallback(s){var e;s.disableRemotePlayback||s.hasAttribute("disableremoteplayback")||(e=s.remote)==null||e.cancelWatchAvailability();}},MEDIA_FULLSCREEN_UNAVAILABLE:{get:function(){return Ca?void 0:je.UNAVAILABLE}},MEDIA_PIP_UNAVAILABLE:{get:function(){return Sc?void 0:je.UNSUPPORTED}},MEDIA_RENDITION_UNAVAILABLE:{get:function(s){var e;let{media:t}=s;if(!t?.videoRenditions)return je.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return je.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},MEDIA_AUDIO_TRACK_UNAVAILABLE:{get:function(s){var e,t;let{media:i}=s;if(!i?.audioTracks)return je.UNSUPPORTED;if(((t=(e=i.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return je.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},MEDIA_VOLUME_UNAVAILABLE:{get:function(s){if(Er!==void 0&&!Er)return je.UNSUPPORTED;let{media:e}=s;if(e&&typeof e.volume>"u")return je.UNAVAILABLE},mediaEvents:["loadstart"]},MEDIA_SUBTITLES_LIST:{get:function(s){return pr(s).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},MEDIA_SUBTITLES_SHOWING:{get:function(s,e){var t;return s.hasAttribute("defaultsubtitles")&&["addtrack","removetrack"].includes(e?.type)&&[Et.CAPTIONS,Et.SUBTITLES].includes((t=e?.track)==null?void 0:t.kind)&&fs.MEDIA_TOGGLE_SUBTITLES_REQUEST(void 0,{detail:true},s),Lc(s).map(({kind:i,label:r,language:n})=>({kind:i,label:r,language:n}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"]},MEDIA_CHAPTERS_CUES:{get:function(s){var e;let{media:t}=s;if(!t)return [];let[i]=Ri(t,{kind:Et.CHAPTERS});return Array.from((e=i?.cues)!=null?e:[]).map(({text:r,startTime:n,endTime:a})=>({text:r,startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack"]},MEDIA_RENDITION_LIST:{get:function(s){var e;let{media:t}=s;return [...(e=t?.videoRenditions)!=null?e:[]]},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},MEDIA_RENDITION_SELECTED:{get:function(s){var e,t,i;let{media:r}=s;return (i=(t=r?.videoRenditions)==null?void 0:t[(e=r.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:i.id},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},MEDIA_AUDIO_TRACK_LIST:{get:function(s){var e;let{media:t}=s;return [...(e=t?.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},MEDIA_AUDIO_TRACK_ENABLED:{get:function(s){var e,t;let{media:i}=s;return (t=[...(e=i?.audioTracks)!=null?e:[]].find(r=>r.enabled))==null?void 0:t.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]}},fs={MEDIA_PLAY_REQUEST:(s,e,t)=>{var i;let r=We.MEDIA_STREAM_TYPE.get(t),n=t.getAttribute("noautoseektolive")===null;r==rt.LIVE&&n&&fs.MEDIA_SEEK_TO_LIVE_REQUEST(s),(i=s.play())==null||i.catch(()=>{});},MEDIA_PAUSE_REQUEST:s=>s.pause(),MEDIA_MUTE_REQUEST:s=>s.muted=true,MEDIA_UNMUTE_REQUEST:s=>{s.muted=false,s.volume===0&&(s.volume=.25);},MEDIA_VOLUME_REQUEST:(s,e,t)=>{let i=e.detail;if(s.volume=i,i>0&&s.muted&&(s.muted=false),!t.hasAttribute("novolumepref"))try{_.localStorage.setItem("media-chrome-pref-volume",i.toString());}catch{}},MEDIA_ENTER_FULLSCREEN_REQUEST:(s,e,t)=>{if(!Ca){console.warn("MediaChrome: Fullscreen support is unavailable; not entering fullscreen");return}M.pictureInPictureElement&&M.exitPictureInPicture(),t[be.enter]?t.fullscreenElement[be.enter]():s.webkitEnterFullscreen?s.webkitEnterFullscreen():s.requestFullscreen?s.requestFullscreen():console.warn("MediaChrome: Fullscreen not supported");},MEDIA_EXIT_FULLSCREEN_REQUEST:()=>{M[be.exit]();},MEDIA_ENTER_PIP_REQUEST:s=>{if(!M.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!s.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}M[be.element]&&M[be.exit]();let e=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.");};s.requestPictureInPicture().catch(t=>{if(t.code===11)if(s.readyState===0&&s.preload==="none"){let i=()=>{s.removeEventListener("loadedmetadata",r),s.preload="none";},r=()=>{s.requestPictureInPicture().catch(e),i();};s.addEventListener("loadedmetadata",r),s.preload="metadata",setTimeout(()=>{s.readyState===0&&e(),i();},1e3);}else throw t;else throw t});},MEDIA_EXIT_PIP_REQUEST:()=>{M.pictureInPictureElement&&M.exitPictureInPicture();},MEDIA_ENTER_CAST_REQUEST:async s=>{var e;if(((e=s.remote)==null?void 0:e.state)==="disconnected"){if(M[be.element]&&M[be.exit](),!s.remote.prompt){console.warn("MediaChrome: Casting is not supported in this environment");return}try{await s.remote.prompt();}catch{}}},MEDIA_EXIT_CAST_REQUEST:s=>{var e;((e=s.remote)==null?void 0:e.state)==="connected"&&s.remote.prompt();},MEDIA_SEEK_REQUEST:(s,e)=>{let t=e.detail;(s.readyState>0||s.readyState===void 0)&&(s.currentTime=t);},MEDIA_PLAYBACK_RATE_REQUEST:(s,e)=>{s.playbackRate=e.detail;},MEDIA_PREVIEW_REQUEST:(s,e,t)=>{var i,r,n,a,o,l;if(!s)return;let d=e.detail;if(d===null){t.propagateMediaState(T.MEDIA_PREVIEW_TIME,void 0),t.propagateMediaState(T.MEDIA_PREVIEW_IMAGE,void 0),t.propagateMediaState(T.MEDIA_PREVIEW_COORDS,void 0);return}t.propagateMediaState(T.MEDIA_PREVIEW_TIME,d);let[c]=Ri(s,{kind:Et.CHAPTERS}),h=Array.from((i=c?.cues)!=null?i:[]).find(v=>v.startTime<=d&&v.endTime>d);t.propagateMediaState(T.MEDIA_PREVIEW_CHAPTER,h?.text);let[u]=Ri(s,{kind:Et.METADATA,label:"thumbnails"}),f=Array.from((r=u?.cues)!=null?r:[]).find(v=>v.startTime>=d);if(!f)return;let m=/'^(?:[a-z]+:)?\/\//i.test((n=f?.text)!=null?n:"")||(a=s.querySelector('track[label="thumbnails"]'))==null?void 0:a.src,g=new URL((o=f?.text)!=null?o:"./",m),E=(l=new URLSearchParams(g.hash).get("#xywh"))!=null?l:"";t.propagateMediaState(T.MEDIA_PREVIEW_IMAGE,g.href),t.propagateMediaState(T.MEDIA_PREVIEW_COORDS,E.split(","));},MEDIA_SHOW_SUBTITLES_REQUEST:(s,e,t)=>{var i;let r=pr(t),{detail:n=[]}=e,a=Ra(n),o=(i=a[0])==null?void 0:i.language;o&&!t?.hasAttribute("nosubtitleslangpref")&&_.localStorage.setItem("media-chrome-pref-subtitles-lang",o),Li(ii.SHOWING,r,a);},MEDIA_DISABLE_SUBTITLES_REQUEST:(s,e,t)=>{let i=pr(t),{detail:r=[]}=e;Li(ii.DISABLED,i,r);},MEDIA_TOGGLE_SUBTITLES_REQUEST:(s,e,t)=>{let{detail:i}=e??{},r=pr(t),n=Lc(t),a=!!n.length;if(r.length){if(i===false||a&&i!==true)Li(ii.DISABLED,r,n);else if(i===true||!a&&i!==false){let o=r[0];if(!t?.hasAttribute("nosubtitleslangpref")){let h=_.localStorage.getItem("media-chrome-pref-subtitles-lang"),u=h?[h,..._.navigator.languages]:_.navigator.languages,f=r.filter(m=>u.some(g=>m.language.toLowerCase().startsWith(g.split("-")[0]))).sort((m,g)=>{let E=u.findIndex(A=>m.language.toLowerCase().startsWith(A.split("-")[0])),v=u.findIndex(A=>g.language.toLowerCase().startsWith(A.split("-")[0]));return E-v});f[0]&&(o=f[0]);}let{language:l,label:d,kind:c}=o;Li(ii.DISABLED,r,n),Li(ii.SHOWING,r,[{language:l,label:d,kind:c}]);}}},MEDIA_AIRPLAY_REQUEST:async s=>{if(s?.remote){if(!s.remote.prompt){console.warn("MediaChrome: AirPlay is not supported in this environment");return}try{await s.remote.prompt();}catch{}}},MEDIA_SEEK_TO_LIVE_REQUEST:s=>{let e=s.seekable;if(!e){console.warn("MediaChrome: Media element does not support seeking to live.");return}if(!e.length){console.warn("MediaChrome: Media is unable to seek to live.");return}s.currentTime=e.end(e.length-1);},MEDIA_RENDITION_REQUEST:(s,e)=>{if(!s?.videoRenditions){console.warn("MediaChrome: Rendition selection not supported by this media.");return}let t=e.detail,i=[...s.videoRenditions].findIndex(r=>r.id==t);s.videoRenditions.selectedIndex!=i&&(s.videoRenditions.selectedIndex=i);},MEDIA_AUDIO_TRACK_REQUEST:(s,e)=>{if(!s?.audioTracks){console.warn("MediaChrome: Audio track selection not supported by this media.");return}let t=e.detail;for(let i of s.audioTracks)i.enabled=t==i.id;}};var Oa=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},At=(s,e,t)=>(Oa(s,e,"read from private field"),t?t.call(s):e.get(s)),ms=(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);},ka=(s,e,t,i)=>(Oa(s,e,"write to private field"),e.set(s,t),t),Ci=(s,e,t)=>(Oa(s,e,"access private method"),t),qt,gs,Di,ki,ps,vr,wa,Mc=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],Mm=10,Rc=0,Ve={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",NO_HOTKEYS:"nohotkeys"},Ma=class extends dr{constructor(){super(),ms(this,ki),ms(this,vr),ms(this,qt,new Ii(this,Ve.HOTKEYS)),ms(this,gs,void 0),ms(this,Di,void 0),We.MEDIA_VOLUME_UNAVAILABLE.get(this)===void 0&&Ic.then(()=>{this.propagateMediaState(T.MEDIA_VOLUME_UNAVAILABLE,We.MEDIA_VOLUME_UNAVAILABLE.get(this));}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associateElement(this),Object.keys(fs).forEach(e=>{let t=`_handle${Qs(e,true)}`;this[t]=i=>{if(i.stopPropagation(),!this.media){console.warn("Media Chrome: No media available.");return}fs[e](this.media,i,this);},this.addEventListener($[e],this[t]);}),this._mediaStatePropagators={},Object.keys(We).forEach(e=>{this._mediaStatePropagators[e]=t=>{this.propagateMediaState(ei[e],We[e].get(this,t));};});}static get observedAttributes(){return super.observedAttributes.concat(Ve.NO_HOTKEYS,Ve.HOTKEYS,Ve.DEFAULT_STREAM_TYPE,Ve.DEFAULT_SUBTITLES,Ve.DEFAULT_DURATION)}get fullscreenElement(){var e;return (e=At(this,gs))!=null?e:this}set fullscreenElement(e){this.hasAttribute(Ve.FULLSCREEN_ELEMENT)&&this.removeAttribute(Ve.FULLSCREEN_ELEMENT),ka(this,gs,e);}attributeChangedCallback(e,t,i){var r;if(super.attributeChangedCallback(e,t,i),e===Ve.NO_HOTKEYS)i!==t&&i===""?(this.hasAttribute(Ve.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):i!==t&&i===null&&this.enableHotkeys();else if(e===Ve.HOTKEYS)At(this,qt).value=i;else if(e===Ve.DEFAULT_SUBTITLES&&i!==t&&i==="")this.dispatchEvent(new _.CustomEvent($.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:true,bubbles:true,detail:true}));else if(e===Ve.DEFAULT_STREAM_TYPE)this.propagateMediaState(ei.MEDIA_STREAM_TYPE);else if(e===Ve.FULLSCREEN_ELEMENT){let n=i?(r=At(this,Di))==null?void 0:r.getElementById(i):void 0;ka(this,gs,n);}}connectedCallback(){ka(this,Di,this.getRootNode()),super.connectedCallback(),this.enableHotkeys();}disconnectedCallback(){super.disconnectedCallback(),this.disableHotkeys(),this.dispatchEvent(new _.CustomEvent($.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:true,bubbles:true,detail:false}));}mediaSetCallback(e){if(super.mediaSetCallback(e),e.hasAttribute("tabindex")||(e.tabIndex=-1),Object.keys(We).forEach(t=>{let{mediaSetCallback:i,mediaEvents:r,rootEvents:n,textTracksEvents:a,videoRenditionsEvents:o,audioTracksEvents:l,remoteEvents:d}=We[t],c=this._mediaStatePropagators[t];i&&(i(e,c),c()),r?.forEach(h=>{e.addEventListener(h,c),c();}),n?.forEach(h=>{var u;(u=At(this,Di))==null||u.addEventListener(h,c),c();}),a?.forEach(h=>{var u;(u=e.textTracks)==null||u.addEventListener(h,c),c();}),o?.forEach(h=>{var u;(u=e.videoRenditions)==null||u.addEventListener(h,c),c();}),l?.forEach(h=>{var u;(u=e.audioTracks)==null||u.addEventListener(h,c),c();}),d?.forEach(h=>{var u;(u=e.remote)==null||u.addEventListener(h,c),c();});}),!this.hasAttribute("novolumepref"))try{let t=_.localStorage.getItem("media-chrome-pref-volume");t!==null&&(e.volume=t);}catch(t){console.debug("Media Chrome: Error getting volume pref",t);}}mediaUnsetCallback(e){super.mediaUnsetCallback(e),Object.keys(We).forEach(t=>{let{mediaUnsetCallback:i,mediaEvents:r,rootEvents:n,textTracksEvents:a,videoRenditionsEvents:o,audioTracksEvents:l,remoteEvents:d}=We[t],c=this._mediaStatePropagators[t];r?.forEach(h=>{e.removeEventListener(h,c);}),n?.forEach(h=>{var u;(u=At(this,Di))==null||u.removeEventListener(h,c);}),a?.forEach(h=>{var u;(u=e.textTracks)==null||u.removeEventListener(h,c);}),o?.forEach(h=>{var u;(u=e.videoRenditions)==null||u.removeEventListener(h,c),c();}),l?.forEach(h=>{var u;(u=e.audioTracks)==null||u.removeEventListener(h,c),c();}),d?.forEach(h=>{var u;(u=e.remote)==null||u.removeEventListener(h,c),c();}),i&&(i(e,c),c());}),this.propagateMediaState(ei.MEDIA_PAUSED,true);}propagateMediaState(e,t){let i=wc(this.mediaStateReceivers,e);if(kc(this.mediaStateReceivers,e,t),i===wc(this.mediaStateReceivers,e))return;let r=e.toLowerCase(),n=new _.CustomEvent(qd[r],{composed:true,bubbles:true,detail:t});this.dispatchEvent(n);}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let i=this.registerMediaStateReceiver.bind(this),r=this.unregisterMediaStateReceiver.bind(this),n=Bm(e,i,r);Object.keys($).forEach(a=>{e.addEventListener($[a],this[`_handle${Qs(a,true)}`]);}),t.set(e,n);}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.keys($).forEach(r=>{e.removeEventListener($[r],this[`_handle${Qs(r,true)}`]);});}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),Object.keys(We).forEach(r=>{let n=We[r];kc([e],ei[r],n.get(this));}));}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,i=t.indexOf(e);i<0||t.splice(i,1);}enableHotkeys(){this.addEventListener("keydown",Ci(this,vr,wa));}disableHotkeys(){this.removeEventListener("keydown",Ci(this,vr,wa)),this.removeEventListener("keyup",Ci(this,ki,ps));}get hotkeys(){return At(this,qt)}keyboardShortcutHandler(e){var t,i,r,n;if(((n=(r=(t=e.target.getAttribute(Ve.KEYS_USED))==null?void 0:t.split(" "))!=null?r:(i=e.target)==null?void 0:i.keysUsed)!=null?n:[]).map(f=>f==="Space"?" ":f).filter(Boolean).includes(e.key))return;let o,l,d,c,h,u=Mm;if(!At(this,qt).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&At(this,qt).contains("nospace")))switch(e.key){case " ":case "k":o=this.getAttribute(T.MEDIA_PAUSED)!=null?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new _.CustomEvent(o,{composed:true,bubbles:true}));break;case "m":o=this.getAttribute(T.MEDIA_VOLUME_LEVEL)==="off"?$.MEDIA_UNMUTE_REQUEST:$.MEDIA_MUTE_REQUEST,this.dispatchEvent(new _.CustomEvent(o,{composed:true,bubbles:true}));break;case "f":o=this.getAttribute(T.MEDIA_IS_FULLSCREEN)!=null?$.MEDIA_EXIT_FULLSCREEN_REQUEST:$.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new _.CustomEvent(o,{composed:true,bubbles:true}));break;case "c":this.dispatchEvent(new _.CustomEvent($.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:true,bubbles:true}));break;case "ArrowLeft":l=this.getAttribute(T.MEDIA_CURRENT_TIME),d=l&&!Number.isNaN(+l)?+l:Rc,c=Math.max(d-u,0),h=new _.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:c}),this.dispatchEvent(h);break;case "ArrowRight":l=this.getAttribute(T.MEDIA_CURRENT_TIME),d=l&&!Number.isNaN(+l)?+l:Rc,c=Math.max(d+u,0),h=new _.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:c}),this.dispatchEvent(h);break;}}};qt=new WeakMap;gs=new WeakMap;Di=new WeakMap;ki=new WeakSet;ps=function(s){let{key:e}=s;if(!Mc.includes(e)){this.removeEventListener("keyup",Ci(this,ki,ps));return}this.keyboardShortcutHandler(s);};vr=new WeakSet;wa=function(s){let{metaKey:e,altKey:t,key:i}=s;if(e||t||!Mc.includes(i)){this.removeEventListener("keyup",Ci(this,ki,ps));return}[" ","ArrowLeft","ArrowRight"].includes(i)&&!(At(this,qt).contains(`no${i.toLowerCase()}`)||i===" "&&At(this,qt).contains("nospace"))&&s.preventDefault(),this.addEventListener("keyup",Ci(this,ki,ps),{once:true});};var Pm=Object.values(T),Om=Object.values(ei),Na=s=>{var e,t,i,r;let{observedAttributes:n}=s.constructor;!n&&((e=s.nodeName)!=null&&e.includes("-"))&&(_.customElements.upgrade(s),{observedAttributes:n}=s.constructor);let a=(r=(i=(t=s?.getAttribute)==null?void 0:t.call(s,Y.MEDIA_CHROME_ATTRIBUTES))==null?void 0:i.split)==null?void 0:r.call(i,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>Pm.includes(o)):[]},Nm=s=>{var e,t;return (e=s.nodeName)!=null&&e.includes("-")&&_.customElements.get((t=s.nodeName)==null?void 0:t.toLowerCase())&&!(s instanceof _.customElements.get(s.nodeName.toLowerCase()))&&_.customElements.upgrade(s),Om.some(i=>i in s)},Pa=s=>Nm(s)||!!Na(s).length,Dc=s=>{var e;return (e=s?.join)==null?void 0:e.call(s,":")},Cc={[T.MEDIA_SUBTITLES_LIST]:oi,[T.MEDIA_SUBTITLES_SHOWING]:oi,[T.MEDIA_SEEKABLE]:Dc,[T.MEDIA_BUFFERED]:s=>s?.map(Dc).join(" "),[T.MEDIA_PREVIEW_COORDS]:s=>s?.join(" "),[T.MEDIA_RENDITION_LIST]:zd,[T.MEDIA_AUDIO_TRACK_LIST]:Xd},Fm=async(s,e,t)=>{var i,r;if(s.isConnected||await Zs(0),typeof t=="boolean"||t==null)return ie(s,e,t);if(typeof t=="number")return me(s,e,t);if(typeof t=="string")return ge(s,e,t);if(Array.isArray(t)&&!t.length)return s.removeAttribute(e);let n=(r=(i=Cc[e])==null?void 0:i.call(Cc,t))!=null?r:t;return s.setAttribute(e,n)},Um=s=>{var e;return !!((e=s.closest)!=null&&e.call(s,'*[slot="media"]'))},li=(s,e)=>{if(Um(s))return;let t=(r,n)=>{var a,o;Pa(r)&&n(r);let{children:l=[]}=r??{},d=(o=(a=r?.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(h=>li(h,n));},i=s?.nodeName.toLowerCase();if(i.includes("-")&&!Pa(s)){_.customElements.whenDefined(i).then(()=>{t(s,e);});return}t(s,e);},kc=(s,e,t)=>{s.forEach(i=>{if(e in i){i[e]=t;return}let r=Na(i),n=e.toLowerCase();r.includes(n)&&Fm(i,n,t);});},wc=(s,e)=>{for(let t of s){if(e in t)return t[e];let i=Na(t),r=e.toLowerCase();if(i.includes(r))return t.getAttribute(r)}},Bm=(s,e,t)=>{li(s,e);let i=c=>{var h;let u=(h=c?.composedPath()[0])!=null?h:c.target;e(u);},r=c=>{var h;let u=(h=c?.composedPath()[0])!=null?h:c.target;t(u);};s.addEventListener($.REGISTER_MEDIA_STATE_RECEIVER,i),s.addEventListener($.UNREGISTER_MEDIA_STATE_RECEIVER,r);let n=c=>{c.forEach(h=>{let{addedNodes:u=[],removedNodes:f=[],type:m,target:g,attributeName:E}=h;m==="childList"?(Array.prototype.forEach.call(u,v=>li(v,e)),Array.prototype.forEach.call(f,v=>li(v,t))):m==="attributes"&&E===Y.MEDIA_CHROME_ATTRIBUTES&&(Pa(g)?e(g):t(g));});},a=[],o=c=>{let h=c.target;h.name!=="media"&&(a.forEach(u=>li(u,t)),a=[...h.assignedElements({flatten:true})],a.forEach(u=>li(u,e)));};s.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(s,{childList:true,attributes:true,subtree:true}),()=>{li(s,t),s.removeEventListener("slotchange",o),l.disconnect(),s.removeEventListener($.REGISTER_MEDIA_STATE_RECEIVER,i),s.removeEventListener($.UNREGISTER_MEDIA_STATE_RECEIVER,r);}};_.customElements.get("media-controller")||_.customElements.define("media-controller",Ma);var Va=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},pe=(s,e,t)=>(Va(s,e,"read from private field"),t?t.call(s):e.get(s)),Fe=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},zt=(s,e,t,i)=>(Va(s,e,"write to private field"),e.set(s,t),t),at=(s,e,t)=>(Va(s,e,"access private method"),t),bt,Rr,Tr,Ar,ot,Ir,br,yr,Sr,Ka,Pc,_r,Fa,xr,Ua,Lr,Wa,Ba,Oc,$a,Nc,Ga,Fc,Ha,Uc,Bc=M.createElement("template");Bc.innerHTML=`
|
|
230
|
-
<style>
|
|
231
|
-
:host {
|
|
232
|
-
--_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
|
|
233
|
-
--_media-range-padding: var(--media-range-padding, var(--media-control-padding, 10px));
|
|
234
|
-
|
|
235
|
-
box-shadow: var(--_focus-visible-box-shadow, none);
|
|
236
|
-
background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
|
|
237
|
-
height: calc(var(--media-control-height, 24px) + 2 * var(--_media-range-padding));
|
|
238
|
-
display: inline-flex;
|
|
239
|
-
align-items: center;
|
|
240
|
-
|
|
241
|
-
vertical-align: middle;
|
|
242
|
-
box-sizing: border-box;
|
|
243
|
-
position: relative;
|
|
244
|
-
width: 100px;
|
|
245
|
-
transition: background .15s linear;
|
|
246
|
-
cursor: pointer;
|
|
247
|
-
pointer-events: auto;
|
|
248
|
-
touch-action: none;
|
|
249
|
-
z-index: 1;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
input[type=range]:focus {
|
|
254
|
-
outline: 0;
|
|
255
|
-
}
|
|
256
|
-
input[type=range]:focus::-webkit-slider-runnable-track {
|
|
257
|
-
outline: 0;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
:host(:hover) {
|
|
261
|
-
background: var(--media-control-hover-background, rgb(50 50 70 / .7));
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
#leftgap {
|
|
265
|
-
padding-left: var(--media-range-padding-left, var(--_media-range-padding));
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
#rightgap {
|
|
269
|
-
padding-right: var(--media-range-padding-right, var(--_media-range-padding));
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
#startpoint,
|
|
273
|
-
#endpoint {
|
|
274
|
-
position: absolute;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
#endpoint {
|
|
278
|
-
right: 0;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
#container {
|
|
282
|
-
|
|
283
|
-
width: var(--media-range-track-width, 100%);
|
|
284
|
-
transform: translate(var(--media-range-track-translate-x, 0px), var(--media-range-track-translate-y, 0px));
|
|
285
|
-
position: relative;
|
|
286
|
-
height: 100%;
|
|
287
|
-
display: flex;
|
|
288
|
-
align-items: center;
|
|
289
|
-
min-width: 40px;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
#range {
|
|
293
|
-
|
|
294
|
-
display: var(--media-time-range-hover-display, block);
|
|
295
|
-
bottom: var(--media-time-range-hover-bottom, -7px);
|
|
296
|
-
height: var(--media-time-range-hover-height, max(100% + 7px, 25px));
|
|
297
|
-
width: 100%;
|
|
298
|
-
position: absolute;
|
|
299
|
-
cursor: pointer;
|
|
300
|
-
|
|
301
|
-
-webkit-appearance: none;
|
|
302
|
-
-webkit-tap-highlight-color: transparent;
|
|
303
|
-
background: transparent;
|
|
304
|
-
margin: 0;
|
|
305
|
-
z-index: 1;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
@media (hover: hover) {
|
|
309
|
-
#range {
|
|
310
|
-
bottom: var(--media-time-range-hover-bottom, -5px);
|
|
311
|
-
height: var(--media-time-range-hover-height, max(100% + 5px, 20px));
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
#range::-webkit-slider-thumb {
|
|
318
|
-
-webkit-appearance: none;
|
|
319
|
-
background: transparent;
|
|
320
|
-
width: .1px;
|
|
321
|
-
height: .1px;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
#range::-moz-range-thumb {
|
|
326
|
-
background: transparent;
|
|
327
|
-
border: transparent;
|
|
328
|
-
width: .1px;
|
|
329
|
-
height: .1px;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
#appearance {
|
|
333
|
-
height: var(--media-range-track-height, 4px);
|
|
334
|
-
display: flex;
|
|
335
|
-
flex-direction: column;
|
|
336
|
-
justify-content: center;
|
|
337
|
-
width: 100%;
|
|
338
|
-
position: absolute;
|
|
339
|
-
|
|
340
|
-
will-change: transform;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
#background,
|
|
344
|
-
#track {
|
|
345
|
-
border-radius: var(--media-range-track-border-radius, 1px);
|
|
346
|
-
position: absolute;
|
|
347
|
-
width: 100%;
|
|
348
|
-
height: 100%;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
#background {
|
|
352
|
-
background: var(--media-range-track-background, rgb(255 255 255 / .2));
|
|
353
|
-
backdrop-filter: var(--media-range-track-background-backdrop-filter);
|
|
354
|
-
-webkit-backdrop-filter: var(--media-range-track-background-backdrop-filter);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
#track {
|
|
358
|
-
border: var(--media-range-track-border, none);
|
|
359
|
-
outline: var(--media-range-track-outline);
|
|
360
|
-
outline-offset: var(--media-range-track-outline-offset);
|
|
361
|
-
backdrop-filter: var(--media-range-track-backdrop-filter);
|
|
362
|
-
-webkit-backdrop-filter: var(--media-range-track-backdrop-filter);
|
|
363
|
-
box-shadow: var(--media-range-track-box-shadow, none);
|
|
364
|
-
overflow: hidden;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
#progress,
|
|
368
|
-
#highlight,
|
|
369
|
-
#pointer {
|
|
370
|
-
position: absolute;
|
|
371
|
-
height: 100%;
|
|
372
|
-
will-change: width;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
#progress {
|
|
376
|
-
background: var(--media-range-bar-color, var(--media-primary-color, rgb(238 238 238)));
|
|
377
|
-
transition: var(--media-range-track-transition);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
#pointer {
|
|
381
|
-
background: var(--media-range-track-pointer-background);
|
|
382
|
-
border-right: var(--media-range-track-pointer-border-right);
|
|
383
|
-
transition: visibility .25s, opacity .25s;
|
|
384
|
-
visibility: hidden;
|
|
385
|
-
opacity: 0;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
@media (hover: hover) {
|
|
389
|
-
:host(:hover) #pointer {
|
|
390
|
-
transition: visibility .5s, opacity .5s;
|
|
391
|
-
visibility: visible;
|
|
392
|
-
opacity: 1;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
#thumb {
|
|
397
|
-
width: var(--media-range-thumb-width, 10px);
|
|
398
|
-
height: var(--media-range-thumb-height, 10px);
|
|
399
|
-
margin-left: calc(var(--media-range-thumb-width, 10px) / -2);
|
|
400
|
-
border: var(--media-range-thumb-border, none);
|
|
401
|
-
border-radius: var(--media-range-thumb-border-radius, 10px);
|
|
402
|
-
background: var(--media-range-thumb-background, var(--media-primary-color, rgb(238 238 238)));
|
|
403
|
-
box-shadow: var(--media-range-thumb-box-shadow, 1px 1px 1px transparent);
|
|
404
|
-
transition: var(--media-range-thumb-transition);
|
|
405
|
-
transform: var(--media-range-thumb-transform, none);
|
|
406
|
-
opacity: var(--media-range-thumb-opacity, 1);
|
|
407
|
-
position: absolute;
|
|
408
|
-
left: 0;
|
|
409
|
-
cursor: pointer;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
:host([disabled]) #thumb {
|
|
413
|
-
background-color: #777;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
.segments #appearance {
|
|
417
|
-
height: var(--media-range-segment-hover-height, 7px);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
#background,
|
|
421
|
-
#track {
|
|
422
|
-
clip-path: url(#segments-clipping);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
#segments {
|
|
426
|
-
--segments-gap: var(--media-range-segments-gap, 2px);
|
|
427
|
-
position: absolute;
|
|
428
|
-
width: 100%;
|
|
429
|
-
height: 100%;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
#segments-clipping {
|
|
433
|
-
transform: translateX(calc(var(--segments-gap) / 2));
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
#segments-clipping:empty {
|
|
437
|
-
display: none;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
#segments-clipping rect {
|
|
441
|
-
height: var(--media-range-track-height, 4px);
|
|
442
|
-
y: calc((var(--media-range-segment-hover-height, 7px) - var(--media-range-track-height, 4px)) / 2);
|
|
443
|
-
transition: var(--media-range-segment-transition, transform .1s ease-in-out);
|
|
444
|
-
transform: var(--media-range-segment-transform, scaleY(1));
|
|
445
|
-
transform-origin: center;
|
|
446
|
-
}
|
|
447
|
-
</style>
|
|
448
|
-
<div id="leftgap"></div>
|
|
449
|
-
<div id="container">
|
|
450
|
-
<div id="startpoint"></div>
|
|
451
|
-
<div id="endpoint"></div>
|
|
452
|
-
<div id="appearance" part="appearance">
|
|
453
|
-
<div id="background"></div>
|
|
454
|
-
<div id="track">
|
|
455
|
-
<div id="highlight"></div>
|
|
456
|
-
<div id="pointer"></div>
|
|
457
|
-
<div id="progress"></div>
|
|
458
|
-
</div>
|
|
459
|
-
<div id="thumb"></div>
|
|
460
|
-
<svg id="segments"><clipPath id="segments-clipping"></clipPath></svg>
|
|
461
|
-
</div>
|
|
462
|
-
<input id="range" type="range" min="0" max="1" step="any" value="0">
|
|
463
|
-
</div>
|
|
464
|
-
<div id="rightgap"></div>
|
|
465
|
-
`;var di=class extends _.HTMLElement{constructor(){super(),Fe(this,Ka),Fe(this,_r),Fe(this,xr),Fe(this,Lr),Fe(this,Ba),Fe(this,$a),Fe(this,Ga),Fe(this,Ha),Fe(this,bt,void 0),Fe(this,Rr,void 0),Fe(this,Tr,void 0),Fe(this,Ar,void 0),Fe(this,ot,{}),Fe(this,Ir,[]),Fe(this,br,()=>{if(this.range.matches(":focus-visible")){let{style:e}=ce(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)");}}),Fe(this,yr,()=>{let{style:e}=ce(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow");}),Fe(this,Sr,()=>{let e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e);}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Bc.content.cloneNode(true))),this.container=this.shadowRoot.querySelector("#container"),zt(this,Tr,this.shadowRoot.querySelector("#startpoint")),zt(this,Ar,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance");}static get observedAttributes(){return ["disabled","aria-disabled",Y.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,n,a,o,l;e===Y.MEDIA_CONTROLLER?(t&&((n=(r=pe(this,bt))==null?void 0:r.unassociateElement)==null||n.call(r,this),zt(this,bt,null)),i&&this.isConnected&&(zt(this,bt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=pe(this,bt))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==i)&&(i==null?(this.range.removeAttribute(e),at(this,_r,Fa).call(this)):(this.range.setAttribute(e,i),at(this,xr,Ua).call(this)));}connectedCallback(){var e,t,i;let{style:r}=ce(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),pe(this,ot).pointer=ce(this.shadowRoot,"#pointer"),pe(this,ot).progress=ce(this.shadowRoot,"#progress"),pe(this,ot).thumb=ce(this.shadowRoot,"#thumb");let n=this.getAttribute(Y.MEDIA_CONTROLLER);n&&(zt(this,bt,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=pe(this,bt))==null?void 0:t.associateElement)==null||i.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",pe(this,br)),this.shadowRoot.addEventListener("focusout",pe(this,yr)),at(this,_r,Fa).call(this),ri(this.container,pe(this,Sr));}disconnectedCallback(){var e,t;at(this,xr,Ua).call(this),(t=(e=pe(this,bt))==null?void 0:e.unassociateElement)==null||t.call(e,this),zt(this,bt,null),this.shadowRoot.removeEventListener("focusin",pe(this,br)),this.shadowRoot.removeEventListener("focusout",pe(this,yr)),ls(this.container,pe(this,Sr));}updatePointerBar(e){var t;(t=pe(this,ot).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`);}updateBar(){var e,t;let i=this.range.valueAsNumber*100;(e=pe(this,ot).progress)==null||e.style.setProperty("width",`${i}%`),(t=pe(this,ot).thumb)==null||t.style.setProperty("left",`${i}%`);}updateSegments(e){let t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",!e?.length)return;pe(this,ot).activeSegment=pa(this.shadowRoot,"#segments-clipping rect:nth-child(0)"),this.container.classList.toggle("segments",!!e.length);let i=[...new Set([+this.range.min,...e.flatMap(n=>[n.start,n.end]),+this.range.max])];zt(this,Ir,[...i]);let r=i.pop();for(let[n,a]of i.entries()){let[o,l]=[n===0,n===i.length-1],d=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,h=`calc(${((l?r:i[n+1])-a)*100}%${o||l?"":" - var(--segments-gap)"})`,u=M.createElementNS("http://www.w3.org/2000/svg","rect"),f=ce(this.shadowRoot,`#segments-clipping rect:nth-child(${n+1})`);f.style.setProperty("x",d),f.style.setProperty("width",h),t.append(u);}}getPointerRatio(e){let t=ec(e.clientX,e.clientY,pe(this,Tr).getBoundingClientRect(),pe(this,Ar).getBoundingClientRect());return Math.max(0,Math.min(1,t))}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case "pointermove":at(this,Ha,Uc).call(this,e);break;case "input":this.updateBar();break;case "pointerenter":at(this,Ba,Oc).call(this,e);break;case "pointerdown":at(this,Lr,Wa).call(this,e);break;case "pointerup":at(this,$a,Nc).call(this);break;case "pointerleave":at(this,Ga,Fc).call(this);break}}get keysUsed(){return ["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};bt=new WeakMap;Rr=new WeakMap;Tr=new WeakMap;Ar=new WeakMap;ot=new WeakMap;Ir=new WeakMap;br=new WeakMap;yr=new WeakMap;Sr=new WeakMap;Ka=new WeakSet;Pc=function(s){let e=pe(this,ot).activeSegment;if(!e)return;let t=this.getPointerRatio(s),r=`#segments-clipping rect:nth-child(${pe(this,Ir).findIndex((n,a,o)=>{let l=o[a+1];return l!=null&&t>=n&&t<=l})+1})`;(e.selectorText!=r||!e.style.transform)&&(e.selectorText=r,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"));};_r=new WeakSet;Fa=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this));};xr=new WeakSet;Ua=function(){var s,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(s=_.window)==null||s.removeEventListener("pointerup",this),(e=_.window)==null||e.removeEventListener("pointermove",this);};Lr=new WeakSet;Wa=function(s){var e;zt(this,Rr,s.composedPath().includes(this.range)),(e=_.window)==null||e.addEventListener("pointerup",this);};Ba=new WeakSet;Oc=function(s){var e;s.pointerType!=="mouse"&&at(this,Lr,Wa).call(this,s),this.addEventListener("pointerleave",this),(e=_.window)==null||e.addEventListener("pointermove",this);};$a=new WeakSet;Nc=function(){var s;(s=_.window)==null||s.removeEventListener("pointerup",this),this.toggleAttribute("dragging",false),this.range.disabled=this.hasAttribute("disabled");};Ga=new WeakSet;Fc=function(){var s,e;this.removeEventListener("pointerleave",this),(s=_.window)==null||s.removeEventListener("pointermove",this),this.toggleAttribute("dragging",false),this.range.disabled=this.hasAttribute("disabled"),(e=pe(this,ot).activeSegment)==null||e.style.removeProperty("transform");};Ha=new WeakSet;Uc=function(s){this.toggleAttribute("dragging",s.buttons===1||s.pointerType!=="mouse"),this.updatePointerBar(s),at(this,Ka,Pc).call(this,s),this.dragging&&(s.pointerType!=="mouse"||!pe(this,Rr))&&(this.range.disabled=true,this.range.valueAsNumber=this.getPointerRatio(s),this.range.dispatchEvent(new Event("input",{bubbles:true,composed:true})));};_.customElements.get("media-chrome-range")||_.customElements.define("media-chrome-range",di);var $c=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Dr=(s,e,t)=>($c(s,e,"read from private field"),t?t.call(s):e.get(s)),$m=(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);},Cr=(s,e,t,i)=>($c(s,e,"write to private field"),e.set(s,t),t),yt,Gc=M.createElement("template");Gc.innerHTML=`
|
|
466
|
-
<style>
|
|
467
|
-
:host {
|
|
468
|
-
|
|
469
|
-
box-sizing: border-box;
|
|
470
|
-
display: var(--media-control-display, var(--media-control-bar-display, inline-flex));
|
|
471
|
-
color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
|
|
472
|
-
--media-loading-indicator-icon-height: 44px;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
::slotted(media-time-range),
|
|
476
|
-
::slotted(media-volume-range) {
|
|
477
|
-
min-height: 100%;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
::slotted(media-time-range),
|
|
481
|
-
::slotted(media-clip-selector) {
|
|
482
|
-
flex-grow: 1;
|
|
483
|
-
}
|
|
484
|
-
</style>
|
|
485
|
-
|
|
486
|
-
<slot></slot>
|
|
487
|
-
`;var Ya=class extends _.HTMLElement{constructor(){super(),$m(this,yt,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Gc.content.cloneNode(true)));}static get observedAttributes(){return [Y.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,n,a,o,l;e===Y.MEDIA_CONTROLLER&&(t&&((n=(r=Dr(this,yt))==null?void 0:r.unassociateElement)==null||n.call(r,this),Cr(this,yt,null)),i&&this.isConnected&&(Cr(this,yt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=Dr(this,yt))==null?void 0:o.associateElement)==null||l.call(o,this)));}connectedCallback(){var e,t,i;let r=this.getAttribute(Y.MEDIA_CONTROLLER);r&&(Cr(this,yt,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=Dr(this,yt))==null?void 0:t.associateElement)==null||i.call(t,this));}disconnectedCallback(){var e,t;(t=(e=Dr(this,yt))==null?void 0:e.unassociateElement)==null||t.call(e,this),Cr(this,yt,null);}};yt=new WeakMap;_.customElements.get("media-control-bar")||_.customElements.define("media-control-bar",Ya);var Hc=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},kr=(s,e,t)=>(Hc(s,e,"read from private field"),t?t.call(s):e.get(s)),Gm=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},wr=(s,e,t,i)=>(Hc(s,e,"write to private field"),e.set(s,t),t),St,Vc=M.createElement("template");Vc.innerHTML=`
|
|
488
|
-
<style>
|
|
489
|
-
:host {
|
|
490
|
-
font: var(--media-font,
|
|
491
|
-
var(--media-font-weight, normal)
|
|
492
|
-
var(--media-font-size, 14px) /
|
|
493
|
-
var(--media-text-content-height, var(--media-control-height, 24px))
|
|
494
|
-
var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
|
|
495
|
-
color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
|
|
496
|
-
background: var(--media-text-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7))));
|
|
497
|
-
padding: var(--media-control-padding, 10px);
|
|
498
|
-
display: inline-flex;
|
|
499
|
-
justify-content: center;
|
|
500
|
-
align-items: center;
|
|
501
|
-
vertical-align: middle;
|
|
502
|
-
box-sizing: border-box;
|
|
503
|
-
text-align: center;
|
|
504
|
-
pointer-events: auto;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
:host(:focus-visible) {
|
|
509
|
-
box-shadow: inset 0 0 0 2px rgb(27 127 204 / .9);
|
|
510
|
-
outline: 0;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
:host(:where(:focus)) {
|
|
515
|
-
box-shadow: none;
|
|
516
|
-
outline: 0;
|
|
517
|
-
}
|
|
518
|
-
</style>
|
|
519
|
-
<slot></slot>
|
|
520
|
-
`;var _t=class extends _.HTMLElement{constructor(){super(),Gm(this,St,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Vc.content.cloneNode(true)));}static get observedAttributes(){return [Y.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,n,a,o,l;e===Y.MEDIA_CONTROLLER&&(t&&((n=(r=kr(this,St))==null?void 0:r.unassociateElement)==null||n.call(r,this),wr(this,St,null)),i&&this.isConnected&&(wr(this,St,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=kr(this,St))==null?void 0:o.associateElement)==null||l.call(o,this)));}connectedCallback(){var e,t,i;let{style:r}=ce(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let n=this.getAttribute(Y.MEDIA_CONTROLLER);n&&(wr(this,St,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=kr(this,St))==null?void 0:t.associateElement)==null||i.call(t,this));}disconnectedCallback(){var e,t;(t=(e=kr(this,St))==null?void 0:e.unassociateElement)==null||t.call(e,this),wr(this,St,null);}};St=new WeakMap;_.customElements.get("media-text-display")||_.customElements.define("media-text-display",_t);var Kc=_t;var Yc=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Wc=(s,e,t)=>(Yc(s,e,"read from private field"),t?t.call(s):e.get(s)),Hm=(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);},Vm=(s,e,t,i)=>(Yc(s,e,"write to private field"),e.set(s,t),t),Es,qa=class extends _t{constructor(){super(),Hm(this,Es,void 0),Vm(this,Es,this.shadowRoot.querySelector("slot")),Wc(this,Es).textContent=vt(0);}static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_DURATION]}attributeChangedCallback(e,t,i){e===T.MEDIA_DURATION&&(Wc(this,Es).textContent=vt(i)),super.attributeChangedCallback(e,t,i);}get mediaDuration(){return oe(this,T.MEDIA_DURATION)}set mediaDuration(e){me(this,T.MEDIA_DURATION,e);}};Es=new WeakMap;_.customElements.get("media-duration-display")||_.customElements.define("media-duration-display",qa);var jc=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},za=(s,e,t)=>(jc(s,e,"read from private field"),t?t.call(s):e.get(s)),Km=(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);},Wm=(s,e,t,i)=>(jc(s,e,"write to private field"),e.set(s,t),t),wi,lt={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},qc=[...Object.values(lt),T.MEDIA_CURRENT_TIME,T.MEDIA_DURATION,T.MEDIA_SEEKABLE],zc=["Enter"," "],Ym=" / ",Xc=(s,{timesSep:e=Ym}={})=>{var t,i,r,n;let a=s.hasAttribute(lt.REMAINING),o=s.hasAttribute(lt.SHOW_DURATION),l=(t=s.mediaCurrentTime)!=null?t:0,[,d]=(i=s.mediaSeekable)!=null?i:[],c=(n=(r=s.mediaDuration)!=null?r:d)!=null?n:0,h=a?vt(0-(c-l)):vt(l);return o?`${h}${e}${vt(c)}`:h},qm="video not loaded, unknown time.",zm=s=>{var e;let t=s.mediaCurrentTime,[,i]=(e=s.mediaSeekable)!=null?e:[],r=s.mediaDuration||i;if(t==null||r==null){s.setAttribute("aria-valuetext",qm);return}let n=s.hasAttribute(lt.REMAINING),a=s.hasAttribute(lt.SHOW_DURATION),o=n?si(0-(r-t)):si(t);if(!a){s.setAttribute("aria-valuetext",o);return}let l=si(r),d=`${o} of ${l}`;s.setAttribute("aria-valuetext",d);},Xa=class extends _t{constructor(){super(),Km(this,wi,void 0),Wm(this,wi,this.shadowRoot.querySelector("slot")),za(this,wi).innerHTML=`${Xc(this)}`;}static get observedAttributes(){return [...super.observedAttributes,...qc,"disabled"]}connectedCallback(){let{style:e}=ce(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","pointer"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",Be.PLAYBACK_TIME());let t=i=>{let{key:r}=i;if(!zc.includes(r)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay();};this.addEventListener("keydown",i=>{let{metaKey:r,altKey:n,key:a}=i;if(r||n||!zc.includes(a)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t);}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback();}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""));}disconnectedCallback(){this.disable(),super.disconnectedCallback();}attributeChangedCallback(e,t,i){qc.includes(e)?this.update():e==="disabled"&&i!==t&&(i==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,i);}enable(){this.tabIndex=0;}disable(){this.tabIndex=-1;}get remaining(){return re(this,lt.REMAINING)}set remaining(e){ie(this,lt.REMAINING,e);}get showDuration(){return re(this,lt.SHOW_DURATION)}set showDuration(e){ie(this,lt.SHOW_DURATION,e);}get noToggle(){return re(this,lt.NO_TOGGLE)}set noToggle(e){ie(this,lt.NO_TOGGLE,e);}get mediaDuration(){return oe(this,T.MEDIA_DURATION)}set mediaDuration(e){me(this,T.MEDIA_DURATION,e);}get mediaCurrentTime(){return oe(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){me(this,T.MEDIA_CURRENT_TIME,e);}get mediaSeekable(){let e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.MEDIA_SEEKABLE,e.join(":"));}update(){let e=Xc(this);zm(this),e!==za(this,wi).innerHTML&&(za(this,wi).innerHTML=e);}};wi=new WeakMap;_.customElements.get("media-time-display")||_.customElements.define("media-time-display",Xa);var Xm=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
521
|
-
<path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
|
|
522
|
-
</svg>`,jm=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
523
|
-
<path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/>
|
|
524
|
-
</svg>`,eh=M.createElement("template");eh.innerHTML=`
|
|
525
|
-
<style>
|
|
526
|
-
:host([aria-checked="true"]) slot[name=off] {
|
|
527
|
-
display: none !important;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
:host(:not([aria-checked="true"])) slot[name=on] {
|
|
532
|
-
display: none !important;
|
|
533
|
-
}
|
|
534
|
-
</style>
|
|
535
|
-
|
|
536
|
-
<slot name="icon">
|
|
537
|
-
<slot name="on">${Xm}</slot>
|
|
538
|
-
<slot name="off">${jm}</slot>
|
|
539
|
-
</slot>
|
|
540
|
-
`;var Qc=s=>{s.setAttribute("aria-checked",bc(s));},ja=class extends he{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:eh,...e}),this._captionsReady=false;}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",Be.CLOSED_CAPTIONS()),Qc(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_SUBTITLES_SHOWING&&Qc(this);}get mediaSubtitlesList(){return Zc(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Jc(this,T.MEDIA_SUBTITLES_LIST,e);}get mediaSubtitlesShowing(){return Zc(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Jc(this,T.MEDIA_SUBTITLES_SHOWING,e);}handleClick(){this.dispatchEvent(new _.CustomEvent($.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:true,bubbles:true}));}},Zc=(s,e)=>{let t=s.getAttribute(e);return t?us(t):[]},Jc=(s,e,t)=>{if(!t?.length){s.removeAttribute(e);return}let i=oi(t);s.getAttribute(e)!==i&&s.setAttribute(e,i);};_.customElements.get("media-captions-button")||_.customElements.define("media-captions-button",ja);var Mi={SEEK_OFFSET:"seekoffset"},Mr=30,Qm=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${Mr}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`,th=M.createElement("template");th.innerHTML=`
|
|
541
|
-
<slot name="icon">${Qm}</slot>
|
|
542
|
-
`;var Zm=0,Qa=class extends he{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_CURRENT_TIME,Mi.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:th,...e});}connectedCallback(){this.seekOffset=oe(this,Mi.SEEK_OFFSET,Mr),super.connectedCallback();}attributeChangedCallback(e,t,i){e===Mi.SEEK_OFFSET&&(this.seekOffset=oe(this,Mi.SEEK_OFFSET,Mr)),super.attributeChangedCallback(e,t,i);}get seekOffset(){return oe(this,Mi.SEEK_OFFSET,Mr)}set seekOffset(e){me(this,Mi.SEEK_OFFSET,e),this.setAttribute("aria-label",le.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),Js(er(this,"icon"),this.seekOffset);}get mediaCurrentTime(){return oe(this,T.MEDIA_CURRENT_TIME,Zm)}set mediaCurrentTime(e){me(this,T.MEDIA_CURRENT_TIME,e);}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new _.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:e});this.dispatchEvent(t);}};_.customElements.get("media-seek-forward-button")||_.customElements.define("media-seek-forward-button",Qa);var Jm=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
543
|
-
<path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
|
|
544
|
-
</svg>`,eg=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
545
|
-
<path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
|
|
546
|
-
</svg>`,sh=M.createElement("template");sh.innerHTML=`
|
|
547
|
-
<style>
|
|
548
|
-
:host([${T.MEDIA_IS_FULLSCREEN}]) slot:not([name=exit]):not([name=icon]) {
|
|
549
|
-
display: none !important;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
:host(:not([${T.MEDIA_IS_FULLSCREEN}])) slot:not([name=enter]):not([name=icon]) {
|
|
554
|
-
display: none !important;
|
|
555
|
-
}
|
|
556
|
-
</style>
|
|
557
|
-
|
|
558
|
-
<slot name="icon">
|
|
559
|
-
<slot name="enter">${Jm}</slot>
|
|
560
|
-
<slot name="exit">${eg}</slot>
|
|
561
|
-
</slot>
|
|
562
|
-
`;var ih=s=>{let e=s.mediaIsFullscreen?le.EXIT_FULLSCREEN():le.ENTER_FULLSCREEN();s.setAttribute("aria-label",e);},Za=class extends he{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_IS_FULLSCREEN,T.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:sh,...e});}connectedCallback(){ih(this),super.connectedCallback();}attributeChangedCallback(e,t,i){e===T.MEDIA_IS_FULLSCREEN&&ih(this),super.attributeChangedCallback(e,t,i);}get mediaFullscreenUnavailable(){return Ae(this,T.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){ge(this,T.MEDIA_FULLSCREEN_UNAVAILABLE,e);}get mediaIsFullscreen(){return re(this,T.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){ie(this,T.MEDIA_IS_FULLSCREEN,e);}handleClick(){let e=this.mediaIsFullscreen?$.MEDIA_EXIT_FULLSCREEN_REQUEST:$.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new _.CustomEvent(e,{composed:true,bubbles:true}));}};_.customElements.get("media-fullscreen-button")||_.customElements.define("media-fullscreen-button",Za);var{MEDIA_TIME_IS_LIVE:Pr,MEDIA_PAUSED:vs}=T,{MEDIA_SEEK_TO_LIVE_REQUEST:tg,MEDIA_PLAY_REQUEST:ig}=$,sg='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',nh=M.createElement("template");nh.innerHTML=`
|
|
563
|
-
<style>
|
|
564
|
-
|
|
565
|
-
slot[name=indicator] > *,
|
|
566
|
-
:host ::slotted([slot=indicator]) {
|
|
567
|
-
|
|
568
|
-
min-width: auto;
|
|
569
|
-
fill: var(--media-live-button-icon-color, rgb(140, 140, 140));
|
|
570
|
-
color: var(--media-live-button-icon-color, rgb(140, 140, 140));
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
:host([${Pr}]:not([${vs}])) slot[name=indicator] > *,
|
|
574
|
-
:host([${Pr}]:not([${vs}])) ::slotted([slot=indicator]) {
|
|
575
|
-
fill: var(--media-live-button-indicator-color, rgb(255, 0, 0));
|
|
576
|
-
color: var(--media-live-button-indicator-color, rgb(255, 0, 0));
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
:host([${Pr}]:not([${vs}])) {
|
|
580
|
-
cursor: not-allowed;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
</style>
|
|
584
|
-
|
|
585
|
-
<slot name="indicator">${sg}</slot>
|
|
586
|
-
|
|
587
|
-
<slot name="spacer"> </slot><slot name="text">LIVE</slot>
|
|
588
|
-
`;var rh=s=>{let e=s.mediaPaused||!s.mediaTimeIsLive,t=e?le.SEEK_LIVE():le.PLAYING_LIVE();s.setAttribute("aria-label",t),e?s.removeAttribute("aria-disabled"):s.setAttribute("aria-disabled","true");},Ja=class extends he{static get observedAttributes(){return [...super.observedAttributes,vs,Pr]}constructor(e={}){super({slotTemplate:nh,...e});}connectedCallback(){rh(this),super.connectedCallback();}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),rh(this);}get mediaPaused(){return re(this,T.MEDIA_PAUSED)}set mediaPaused(e){ie(this,T.MEDIA_PAUSED,e);}get mediaTimeIsLive(){return re(this,T.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){ie(this,T.MEDIA_TIME_IS_LIVE,e);}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new _.CustomEvent(tg,{composed:true,bubbles:true})),this.hasAttribute(vs)&&this.dispatchEvent(new _.CustomEvent(ig,{composed:true,bubbles:true})));}};_.customElements.get("media-live-button")||_.customElements.define("media-live-button",Ja);var{MEDIA_VOLUME_LEVEL:Ts}=T,rg=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
589
|
-
<path d="M16.5 12A4.5 4.5 0 0 0 14 8v2.18l2.45 2.45a4.22 4.22 0 0 0 .05-.63Zm2.5 0a6.84 6.84 0 0 1-.54 2.64L20 16.15A8.8 8.8 0 0 0 21 12a9 9 0 0 0-7-8.77v2.06A7 7 0 0 1 19 12ZM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25A6.92 6.92 0 0 1 14 18.7v2.06A9 9 0 0 0 17.69 19l2 2.05L21 19.73l-9-9L4.27 3ZM12 4 9.91 6.09 12 8.18V4Z"/>
|
|
590
|
-
</svg>`,ah=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
591
|
-
<path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4Z"/>
|
|
592
|
-
</svg>`,ng=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
593
|
-
<path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4ZM14 3.23v2.06a7 7 0 0 1 0 13.42v2.06a9 9 0 0 0 0-17.54Z"/>
|
|
594
|
-
</svg>`,lh=M.createElement("template");lh.innerHTML=`
|
|
595
|
-
<style>
|
|
596
|
-
|
|
597
|
-
:host(:not([${Ts}])) slot:not([name=high]):not([name=icon]),
|
|
598
|
-
:host([${Ts}=high]) slot:not([name=high]):not([name=icon]) {
|
|
599
|
-
display: none !important;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
:host([${Ts}=off]) slot:not([name=off]):not([name=icon]) {
|
|
603
|
-
display: none !important;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
:host([${Ts}=low]) slot:not([name=low]):not([name=icon]) {
|
|
607
|
-
display: none !important;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
:host([${Ts}=medium]) slot:not([name=medium]):not([name=icon]) {
|
|
611
|
-
display: none !important;
|
|
612
|
-
}
|
|
613
|
-
</style>
|
|
614
|
-
|
|
615
|
-
<slot name="icon">
|
|
616
|
-
<slot name="off">${rg}</slot>
|
|
617
|
-
<slot name="low">${ah}</slot>
|
|
618
|
-
<slot name="medium">${ah}</slot>
|
|
619
|
-
<slot name="high">${ng}</slot>
|
|
620
|
-
</slot>
|
|
621
|
-
`;var oh=s=>{let t=s.mediaVolumeLevel==="off"?le.UNMUTE():le.MUTE();s.setAttribute("aria-label",t);},eo=class extends he{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:lh,...e});}connectedCallback(){oh(this),super.connectedCallback();}attributeChangedCallback(e,t,i){e===T.MEDIA_VOLUME_LEVEL&&oh(this),super.attributeChangedCallback(e,t,i);}get mediaVolumeLevel(){return Ae(this,T.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){ge(this,T.MEDIA_VOLUME_LEVEL,e);}handleClick(){let e=this.mediaVolumeLevel==="off"?$.MEDIA_UNMUTE_REQUEST:$.MEDIA_MUTE_REQUEST;this.dispatchEvent(new _.CustomEvent(e,{composed:true,bubbles:true}));}};_.customElements.get("media-mute-button")||_.customElements.define("media-mute-button",eo);var dh=`<svg aria-hidden="true" viewBox="0 0 28 24">
|
|
622
|
-
<path d="M24 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h20a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Zm-1 16H5V5h18v14Zm-3-8h-7v5h7v-5Z"/>
|
|
623
|
-
</svg>`,hh=M.createElement("template");hh.innerHTML=`
|
|
624
|
-
<style>
|
|
625
|
-
:host([${T.MEDIA_IS_PIP}]) slot:not([name=exit]):not([name=icon]) {
|
|
626
|
-
display: none !important;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
:host(:not([${T.MEDIA_IS_PIP}])) slot:not([name=enter]):not([name=icon]) {
|
|
631
|
-
display: none !important;
|
|
632
|
-
}
|
|
633
|
-
</style>
|
|
634
|
-
|
|
635
|
-
<slot name="icon">
|
|
636
|
-
<slot name="enter">${dh}</slot>
|
|
637
|
-
<slot name="exit">${dh}</slot>
|
|
638
|
-
</slot>
|
|
639
|
-
`;var ch=s=>{let e=s.mediaIsPip?le.EXIT_PIP():le.ENTER_PIP();s.setAttribute("aria-label",e);},to=class extends he{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_IS_PIP,T.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:hh,...e});}connectedCallback(){ch(this),super.connectedCallback();}attributeChangedCallback(e,t,i){e===T.MEDIA_IS_PIP&&ch(this),super.attributeChangedCallback(e,t,i);}get mediaPipUnavailable(){return Ae(this,T.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){ge(this,T.MEDIA_PIP_UNAVAILABLE,e);}get mediaIsPip(){return re(this,T.MEDIA_IS_PIP)}set mediaIsPip(e){ie(this,T.MEDIA_IS_PIP,e);}handleClick(){let e=this.mediaIsPip?$.MEDIA_EXIT_PIP_REQUEST:$.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new _.CustomEvent(e,{composed:true,bubbles:true}));}};_.customElements.get("media-pip-button")||_.customElements.define("media-pip-button",to);var ag=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
640
|
-
<path d="m6 21 15-9L6 3v18Z"/>
|
|
641
|
-
</svg>`,og=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
642
|
-
<path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
|
|
643
|
-
</svg>`,fh=M.createElement("template");fh.innerHTML=`
|
|
644
|
-
<style>
|
|
645
|
-
:host([${T.MEDIA_PAUSED}]) slot[name=pause] {
|
|
646
|
-
display: none !important;
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
:host(:not([${T.MEDIA_PAUSED}])) slot[name=play] {
|
|
650
|
-
display: none !important;
|
|
651
|
-
}
|
|
652
|
-
</style>
|
|
653
|
-
|
|
654
|
-
<slot name="icon">
|
|
655
|
-
<slot name="play">${ag}</slot>
|
|
656
|
-
<slot name="pause">${og}</slot>
|
|
657
|
-
</slot>
|
|
658
|
-
`;var uh=s=>{let e=s.mediaPaused?le.PLAY():le.PAUSE();s.setAttribute("aria-label",e);},io=class extends he{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_PAUSED,T.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:fh,...e});}connectedCallback(){uh(this),super.connectedCallback();}attributeChangedCallback(e,t,i){e===T.MEDIA_PAUSED&&uh(this),super.attributeChangedCallback(e,t,i);}get mediaPaused(){return re(this,T.MEDIA_PAUSED)}set mediaPaused(e){ie(this,T.MEDIA_PAUSED,e);}handleClick(){let e=this.mediaPaused?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new _.CustomEvent(e,{composed:true,bubbles:true}));}};_.customElements.get("media-play-button")||_.customElements.define("media-play-button",io);var lg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Or=(s,e,t)=>(lg(s,e,"read from private field"),t?t.call(s):e.get(s)),dg=(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);},Pi,so={RATES:"rates"},cg=[1,1.2,1.5,1.7,2],Nr=1,mh=M.createElement("template");mh.innerHTML=`
|
|
659
|
-
<style>
|
|
660
|
-
:host {
|
|
661
|
-
min-width: 5ch;
|
|
662
|
-
padding: var(--media-button-padding, var(--media-control-padding, 10px 5px));
|
|
663
|
-
}
|
|
664
|
-
</style>
|
|
665
|
-
<slot name="icon"></slot>
|
|
666
|
-
`;var ro=class extends he{constructor(e={}){super({slotTemplate:mh,...e}),dg(this,Pi,new Ii(this,so.RATES,{defaultValue:cg})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${Nr}x`;}static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,so.RATES]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===so.RATES&&(Or(this,Pi).value=i),e===T.MEDIA_PLAYBACK_RATE){let r=i?+i:Number.NaN,n=Number.isNaN(r)?Nr:r;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Be.PLAYBACK_RATE({playbackRate:n}));}}get rates(){return Or(this,Pi)}set rates(e){e?Array.isArray(e)&&(Or(this,Pi).value=e.join(" ")):Or(this,Pi).value="";}get mediaPlaybackRate(){return oe(this,T.MEDIA_PLAYBACK_RATE,Nr)}set mediaPlaybackRate(e){me(this,T.MEDIA_PLAYBACK_RATE,e);}handleClick(){var e,t;let i=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),r=(t=(e=i.find(a=>a>this.mediaPlaybackRate))!=null?e:i[0])!=null?t:Nr,n=new _.CustomEvent($.MEDIA_PLAYBACK_RATE_REQUEST,{composed:true,bubbles:true,detail:r});this.dispatchEvent(n);}};Pi=new WeakMap;_.customElements.get("media-playback-rate-button")||_.customElements.define("media-playback-rate-button",ro);var xt={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},gh=M.createElement("template");gh.innerHTML=`
|
|
667
|
-
<style>
|
|
668
|
-
:host {
|
|
669
|
-
pointer-events: none;
|
|
670
|
-
display: var(--media-poster-image-display, inline-block);
|
|
671
|
-
box-sizing: border-box;
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
img {
|
|
675
|
-
max-width: 100%;
|
|
676
|
-
max-height: 100%;
|
|
677
|
-
min-width: 100%;
|
|
678
|
-
min-height: 100%;
|
|
679
|
-
background-repeat: no-repeat;
|
|
680
|
-
background-position: var(--media-poster-image-background-position, var(--media-object-position, center));
|
|
681
|
-
background-size: var(--media-poster-image-background-size, var(--media-object-fit, contain));
|
|
682
|
-
object-fit: var(--media-object-fit, contain);
|
|
683
|
-
object-position: var(--media-object-position, center);
|
|
684
|
-
}
|
|
685
|
-
</style>
|
|
686
|
-
|
|
687
|
-
<img part="poster img" aria-hidden="true" id="image"/>
|
|
688
|
-
`;var hg=s=>{s.style.removeProperty("background-image");},ug=(s,e)=>{s.style["background-image"]=`url('${e}')`;},no=class extends _.HTMLElement{static get observedAttributes(){return [xt.PLACEHOLDER_SRC,xt.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(gh.content.cloneNode(true))),this.image=this.shadowRoot.querySelector("#image");}attributeChangedCallback(e,t,i){e===xt.SRC&&(i==null?this.image.removeAttribute(xt.SRC):this.image.setAttribute(xt.SRC,i)),e===xt.PLACEHOLDER_SRC&&(i==null?hg(this.image):ug(this.image,i));}get placeholderSrc(){return Ae(this,xt.PLACEHOLDER_SRC)}set placeholderSrc(e){ge(this,xt.SRC,e);}get src(){return Ae(this,xt.SRC)}set src(e){ge(this,xt.SRC,e);}};_.customElements.get("media-poster-image")||_.customElements.define("media-poster-image",no);var Oi={SEEK_OFFSET:"seekoffset"},Fr=30,fg=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${Fr}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`,ph=M.createElement("template");ph.innerHTML=`
|
|
689
|
-
<slot name="icon">${fg}</slot>
|
|
690
|
-
`;var mg=0,ao=class extends he{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_CURRENT_TIME,Oi.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:ph,...e});}connectedCallback(){this.seekOffset=oe(this,Oi.SEEK_OFFSET,Fr),super.connectedCallback();}attributeChangedCallback(e,t,i){e===Oi.SEEK_OFFSET&&(this.seekOffset=oe(this,Oi.SEEK_OFFSET,Fr)),super.attributeChangedCallback(e,t,i);}get seekOffset(){return oe(this,Oi.SEEK_OFFSET,Fr)}set seekOffset(e){me(this,Oi.SEEK_OFFSET,e),this.setAttribute("aria-label",le.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),Js(er(this,"icon"),this.seekOffset);}get mediaCurrentTime(){return oe(this,T.MEDIA_CURRENT_TIME,mg)}set mediaCurrentTime(e){me(this,T.MEDIA_CURRENT_TIME,e);}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new _.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:e});this.dispatchEvent(t);}};_.customElements.get("media-seek-backward-button")||_.customElements.define("media-seek-backward-button",ao);var vh=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Eh=(s,e,t)=>(vh(s,e,"read from private field"),t?t.call(s):e.get(s)),gg=(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);},pg=(s,e,t,i)=>(vh(s,e,"write to private field"),e.set(s,t),t),As,oo=class extends _t{constructor(){super(),gg(this,As,void 0),pg(this,As,this.shadowRoot.querySelector("slot")),Eh(this,As).textContent=vt(0);}static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_PREVIEW_TIME&&i!=null&&(Eh(this,As).textContent=vt(i));}get mediaPreviewTime(){return oe(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){me(this,T.MEDIA_PREVIEW_TIME,e);}};As=new WeakMap;_.customElements.get("media-preview-time-display")||_.customElements.define("media-preview-time-display",oo);var Th=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Ur=(s,e,t)=>(Th(s,e,"read from private field"),t?t.call(s):e.get(s)),Eg=(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);},Br=(s,e,t,i)=>(Th(s,e,"write to private field"),e.set(s,t),t),It,Ah=M.createElement("template");Ah.innerHTML=`
|
|
691
|
-
<style>
|
|
692
|
-
:host {
|
|
693
|
-
box-sizing: border-box;
|
|
694
|
-
display: var(--media-control-display, var(--media-preview-thumbnail-display, inline-block));
|
|
695
|
-
overflow: hidden;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
img {
|
|
699
|
-
display: none;
|
|
700
|
-
position: relative;
|
|
701
|
-
}
|
|
702
|
-
</style>
|
|
703
|
-
<img crossorigin loading="eager" decoding="async">
|
|
704
|
-
`;var lo=class extends _.HTMLElement{constructor(){super(),Eg(this,It,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ah.content.cloneNode(true)));}static get observedAttributes(){return [Y.MEDIA_CONTROLLER,T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,i;let r=this.getAttribute(Y.MEDIA_CONTROLLER);r&&(Br(this,It,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=Ur(this,It))==null?void 0:t.associateElement)==null||i.call(t,this));}disconnectedCallback(){var e,t;(t=(e=Ur(this,It))==null?void 0:e.unassociateElement)==null||t.call(e,this),Br(this,It,null);}attributeChangedCallback(e,t,i){var r,n,a,o,l;[T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===Y.MEDIA_CONTROLLER&&(t&&((n=(r=Ur(this,It))==null?void 0:r.unassociateElement)==null||n.call(r,this),Br(this,It,null)),i&&this.isConnected&&(Br(this,It,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=Ur(this,It))==null?void 0:o.associateElement)==null||l.call(o,this)));}get mediaPreviewImage(){return Ae(this,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ge(this,T.MEDIA_PREVIEW_IMAGE,e);}get mediaPreviewCoords(){let e=this.getAttribute(T.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(T.MEDIA_PREVIEW_COORDS);return}this.setAttribute(T.MEDIA_PREVIEW_COORDS,e.join(" "));}update(){let e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;let[i,r,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:c,minWidth:h,minHeight:u}=l,f=Math.min(parseInt(d)/n,parseInt(c)/a),m=Math.max(parseInt(h)/n,parseInt(u)/a),g=f<1,E=g?f:m>1?m:1,{style:v}=ce(this.shadowRoot,":host"),A=ce(this.shadowRoot,"img").style,b=this.shadowRoot.querySelector("img"),L=g?"min":"max";v.setProperty(`${L}-width`,"initial","important"),v.setProperty(`${L}-height`,"initial","important"),v.width=`${n*E}px`,v.height=`${a*E}px`;let y=()=>{A.width=`${this.imgWidth*E}px`,A.height=`${this.imgHeight*E}px`,A.display="block";};b.src!==o&&(b.onload=()=>{this.imgWidth=b.naturalWidth,this.imgHeight=b.naturalHeight,y();},b.src=o,y()),y(),A.transform=`translate(-${i*E}px, -${r*E}px)`;}};It=new WeakMap;_.customElements.get("media-preview-thumbnail")||_.customElements.define("media-preview-thumbnail",lo);var yh=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},bh=(s,e,t)=>(yh(s,e,"read from private field"),t?t.call(s):e.get(s)),vg=(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);},Tg=(s,e,t,i)=>(yh(s,e,"write to private field"),e.set(s,t),t),bs,co=class extends Kc{constructor(){super(),vg(this,bs,void 0),Tg(this,bs,this.shadowRoot.querySelector("slot"));}static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_PREVIEW_CHAPTER]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===T.MEDIA_PREVIEW_CHAPTER&&i!==t){if(i==null){bh(this,bs).textContent="",this.removeAttribute("aria-valuetext");return}bh(this,bs).textContent=i,this.setAttribute("aria-valuetext",`chapter: ${i}`);}}get mediaPreviewChapter(){return Ae(this,T.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){ge(this,T.MEDIA_PREVIEW_CHAPTER,e);}};bs=new WeakMap;_.customElements.get("media-preview-chapter-display")||_.customElements.define("media-preview-chapter-display",co);var Sh=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Ce=(s,e,t)=>(Sh(s,e,"read from private field"),e.get(s)),Lt=(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);},Qe=(s,e,t,i)=>(Sh(s,e,"write to private field"),e.set(s,t),t),Ag=(s,e,t,i)=>({set _(r){Qe(s,e,r);},get _(){return Ce(s,e)}}),Ni,$r,Fi,ys,Gr,Hr,Vr,Ui,ci,Kr,Wr=class{constructor(e,t,i){Lt(this,Ni,void 0),Lt(this,$r,void 0),Lt(this,Fi,void 0),Lt(this,ys,void 0),Lt(this,Gr,void 0),Lt(this,Hr,void 0),Lt(this,Vr,void 0),Lt(this,Ui,void 0),Lt(this,ci,0),Lt(this,Kr,(r=performance.now())=>{Qe(this,ci,requestAnimationFrame(Ce(this,Kr))),Qe(this,ys,performance.now()-Ce(this,Fi));let n=1e3/this.fps;if(Ce(this,ys)>n){Qe(this,Fi,r-Ce(this,ys)%n);let a=1e3/((r-Ce(this,$r))/++Ag(this,Gr)._),o=(r-Ce(this,Hr))/1e3/this.duration,l=Ce(this,Vr)+o*this.playbackRate;l-Ce(this,Ni).valueAsNumber>0?Qe(this,Ui,this.playbackRate/this.duration/a):(Qe(this,Ui,.995*Ce(this,Ui)),l=Ce(this,Ni).valueAsNumber+Ce(this,Ui)),this.callback(l);}}),Qe(this,Ni,e),this.callback=t,this.fps=i;}start(){Ce(this,ci)===0&&(Qe(this,Fi,performance.now()),Qe(this,$r,Ce(this,Fi)),Qe(this,Gr,0),Ce(this,Kr).call(this));}stop(){Ce(this,ci)!==0&&(cancelAnimationFrame(Ce(this,ci)),Qe(this,ci,0));}update({start:e,duration:t,playbackRate:i}){let r=e-Ce(this,Ni).valueAsNumber;(r>0||r<-0.03)&&this.callback(e),Qe(this,Vr,e),Qe(this,Hr,performance.now()),this.duration=t,this.playbackRate=i;}};Ni=new WeakMap;$r=new WeakMap;Fi=new WeakMap;ys=new WeakMap;Gr=new WeakMap;Hr=new WeakMap;Vr=new WeakMap;Ui=new WeakMap;ci=new WeakMap;Kr=new WeakMap;var go=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ke=(s,e,t)=>(go(s,e,"read from private field"),t?t.call(s):e.get(s)),$e=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Rt=(s,e,t,i)=>(go(s,e,"write to private field"),e.set(s,t),t),tt=(s,e,t)=>(go(s,e,"access private method"),t),Bi,hi,qr,xs,zr,Ss,Xr,jr,$i,Gi,_s,po,_h,ho,Qr,Eo,uo,xh,Is,Zr,fo,Ih,bg="video not loaded, unknown time.",yg=s=>{let e=s.range,t=si(+Rh(s)),i=si(+s.mediaSeekableEnd),r=t&&i?`${t} of ${i}`:bg;e.setAttribute("aria-valuetext",r);},Lh=M.createElement("template");Lh.innerHTML=`
|
|
705
|
-
<style>
|
|
706
|
-
:host {
|
|
707
|
-
--media-preview-border-radius: 3px;
|
|
708
|
-
--media-box-padding-left: 10px;
|
|
709
|
-
--media-box-padding-right: 10px;
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
#highlight {
|
|
713
|
-
background: var(--media-time-range-buffered-color, rgb(255 255 255 / .4));
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
#preview-rail,
|
|
717
|
-
#current-rail {
|
|
718
|
-
|
|
719
|
-
width: 1%;
|
|
720
|
-
position: absolute;
|
|
721
|
-
left: 0;
|
|
722
|
-
bottom: 100%;
|
|
723
|
-
pointer-events: none;
|
|
724
|
-
will-change: transform;
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
[part~="box"] {
|
|
728
|
-
|
|
729
|
-
position: absolute;
|
|
730
|
-
bottom: 100%;
|
|
731
|
-
display: flex;
|
|
732
|
-
flex-direction: column;
|
|
733
|
-
align-items: center;
|
|
734
|
-
transform: translateX(-50%);
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
[part~="preview-box"] {
|
|
738
|
-
transition-property: var(--media-preview-transition-property, visibility, opacity);
|
|
739
|
-
transition-duration: var(--media-preview-transition-duration-out, .25s);
|
|
740
|
-
transition-delay: var(--media-preview-transition-delay-out, 0s);
|
|
741
|
-
visibility: hidden;
|
|
742
|
-
opacity: 0;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
:host(:is([${T.MEDIA_PREVIEW_IMAGE}], [${T.MEDIA_PREVIEW_TIME}])[dragging]) [part~="preview-box"] {
|
|
746
|
-
transition-duration: var(--media-preview-transition-duration-in, .5s);
|
|
747
|
-
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
748
|
-
visibility: visible;
|
|
749
|
-
opacity: 1;
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
@media (hover: hover) {
|
|
753
|
-
:host(:is([${T.MEDIA_PREVIEW_IMAGE}], [${T.MEDIA_PREVIEW_TIME}]):hover) [part~="preview-box"] {
|
|
754
|
-
transition-duration: var(--media-preview-transition-duration-in, .5s);
|
|
755
|
-
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
756
|
-
visibility: visible;
|
|
757
|
-
opacity: 1;
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
media-preview-thumbnail,
|
|
762
|
-
::slotted(media-preview-thumbnail) {
|
|
763
|
-
visibility: hidden;
|
|
764
|
-
|
|
765
|
-
transition: visibility 0s .25s;
|
|
766
|
-
transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
|
|
767
|
-
background: var(--media-preview-thumbnail-background, var(--media-preview-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)))));
|
|
768
|
-
box-shadow: var(--media-preview-thumbnail-box-shadow, 0 0 4px rgb(0 0 0 / .2));
|
|
769
|
-
max-width: var(--media-preview-thumbnail-max-width, 180px);
|
|
770
|
-
max-height: var(--media-preview-thumbnail-max-height, 160px);
|
|
771
|
-
min-width: var(--media-preview-thumbnail-min-width, 120px);
|
|
772
|
-
min-height: var(--media-preview-thumbnail-min-height, 80px);
|
|
773
|
-
border: var(--media-preview-thumbnail-border);
|
|
774
|
-
border-radius: var(--media-preview-thumbnail-border-radius,
|
|
775
|
-
var(--media-preview-border-radius) var(--media-preview-border-radius) 0 0);
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}][dragging]) media-preview-thumbnail,
|
|
779
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}][dragging]) ::slotted(media-preview-thumbnail) {
|
|
780
|
-
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
781
|
-
visibility: visible;
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
@media (hover: hover) {
|
|
785
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}]:hover) media-preview-thumbnail,
|
|
786
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}]:hover) ::slotted(media-preview-thumbnail) {
|
|
787
|
-
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
788
|
-
visibility: visible;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
:host([${T.MEDIA_PREVIEW_TIME}]:hover) {
|
|
792
|
-
--media-time-range-hover-display: block;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
media-preview-chapter-display,
|
|
797
|
-
::slotted(media-preview-chapter-display) {
|
|
798
|
-
display: none;
|
|
799
|
-
line-height: 1.3;
|
|
800
|
-
min-width: 0;
|
|
801
|
-
|
|
802
|
-
transition: min-width 0s, border-radius 0s, margin 0s, padding 0s;
|
|
803
|
-
transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
|
|
804
|
-
background: var(--media-preview-chapter-background, var(--media-preview-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)))));
|
|
805
|
-
border-radius: var(--media-preview-chapter-border-radius,
|
|
806
|
-
var(--media-preview-border-radius) var(--media-preview-border-radius)
|
|
807
|
-
var(--media-preview-border-radius) var(--media-preview-border-radius));
|
|
808
|
-
padding: var(--media-preview-chapter-padding, 4px 10px);
|
|
809
|
-
margin: var(--media-preview-chapter-margin, 0 0 5px);
|
|
810
|
-
text-shadow: var(--media-preview-chapter-text-shadow, 0 0 4px rgb(0 0 0 / .75));
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}]) media-preview-chapter-display,
|
|
814
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-chapter-display) {
|
|
815
|
-
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
816
|
-
border-radius: var(--media-preview-chapter-border-radius, 0);
|
|
817
|
-
padding: var(--media-preview-chapter-padding, 4px 10px 0);
|
|
818
|
-
margin: var(--media-preview-chapter-margin, 0);
|
|
819
|
-
min-width: 100%;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
media-preview-chapter-display[${T.MEDIA_PREVIEW_CHAPTER}]:not([${T.MEDIA_PREVIEW_CHAPTER}=""]),
|
|
823
|
-
::slotted(media-preview-chapter-display[${T.MEDIA_PREVIEW_CHAPTER}]:not([${T.MEDIA_PREVIEW_CHAPTER}=""])) {
|
|
824
|
-
display: initial;
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
media-preview-time-display,
|
|
828
|
-
::slotted(media-preview-time-display) {
|
|
829
|
-
line-height: 1.3;
|
|
830
|
-
min-width: 0;
|
|
831
|
-
|
|
832
|
-
transition: min-width 0s, border-radius 0s;
|
|
833
|
-
transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
|
|
834
|
-
background: var(--media-preview-time-background, var(--media-preview-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)))));
|
|
835
|
-
border-radius: var(--media-preview-time-border-radius,
|
|
836
|
-
var(--media-preview-border-radius) var(--media-preview-border-radius)
|
|
837
|
-
var(--media-preview-border-radius) var(--media-preview-border-radius));
|
|
838
|
-
padding: var(--media-preview-time-padding, 4px 10px);
|
|
839
|
-
margin: var(--media-preview-time-margin, 0 0 10px);
|
|
840
|
-
text-shadow: var(--media-preview-time-text-shadow, 0 0 4px rgb(0 0 0 / .75));
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}]) media-preview-time-display,
|
|
844
|
-
:host([${T.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-time-display) {
|
|
845
|
-
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
846
|
-
border-radius: var(--media-preview-time-border-radius,
|
|
847
|
-
0 0 var(--media-preview-border-radius) var(--media-preview-border-radius));
|
|
848
|
-
min-width: 100%;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
:host([${T.MEDIA_PREVIEW_TIME}]:hover) {
|
|
852
|
-
--media-time-range-hover-display: block;
|
|
853
|
-
}
|
|
854
|
-
</style>
|
|
855
|
-
<div id="preview-rail">
|
|
856
|
-
<slot name="preview" part="box preview-box">
|
|
857
|
-
<media-preview-thumbnail></media-preview-thumbnail>
|
|
858
|
-
<media-preview-chapter-display></media-preview-chapter-display>
|
|
859
|
-
<media-preview-time-display></media-preview-time-display>
|
|
860
|
-
</slot>
|
|
861
|
-
</div>
|
|
862
|
-
<div id="current-rail">
|
|
863
|
-
<slot name="current" part="box current-box">
|
|
864
|
-
|
|
865
|
-
</slot>
|
|
866
|
-
</div>
|
|
867
|
-
`;var Yr=(s,e=s.mediaCurrentTime)=>{if(Number.isNaN(s.mediaSeekableEnd))return 0;let t=(e-s.mediaSeekableStart)/(s.mediaSeekableEnd-s.mediaSeekableStart);return Math.max(0,Math.min(t,1))},Rh=(s,e=s.range.valueAsNumber)=>Number.isNaN(s.mediaSeekableEnd)?0:e*(s.mediaSeekableEnd-s.mediaSeekableStart)+s.mediaSeekableStart,mo=class extends di{constructor(){super(),$e(this,Gi),$e(this,po),$e(this,Qr),$e(this,uo),$e(this,Is),$e(this,fo),$e(this,Bi,void 0),$e(this,hi,void 0),$e(this,qr,void 0),$e(this,xs,void 0),$e(this,zr,void 0),$e(this,Ss,void 0),$e(this,Xr,void 0),$e(this,jr,void 0),$e(this,$i,void 0),$e(this,ho,t=>{this.dragging||(this.range.valueAsNumber=t,this.updateBar());}),this.container.appendChild(Lh.content.cloneNode(true)),Rt(this,qr,this.shadowRoot.querySelectorAll('[part~="box"]')),Rt(this,zr,this.shadowRoot.querySelector('[part~="preview-box"]')),Rt(this,Ss,this.shadowRoot.querySelector('[part~="current-box"]'));let e=getComputedStyle(this);Rt(this,Xr,parseInt(e.getPropertyValue("--media-box-padding-left"))),Rt(this,jr,parseInt(e.getPropertyValue("--media-box-padding-right"))),Rt(this,hi,new Wr(this.range,ke(this,ho),60));}static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_PAUSED,T.MEDIA_DURATION,T.MEDIA_SEEKABLE,T.MEDIA_CURRENT_TIME,T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_TIME,T.MEDIA_PREVIEW_CHAPTER,T.MEDIA_BUFFERED,T.MEDIA_PLAYBACK_RATE,T.MEDIA_LOADING,T.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",Be.SEEK()),tt(this,Gi,_s).call(this),Rt(this,Bi,this.getRootNode()),(e=ke(this,Bi))==null||e.addEventListener("transitionstart",this);}disconnectedCallback(){var e;super.disconnectedCallback(),tt(this,Gi,_s).call(this),(e=ke(this,Bi))==null||e.removeEventListener("transitionstart",this),Rt(this,Bi,null);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),t!=i&&(e===T.MEDIA_CURRENT_TIME||e===T.MEDIA_PAUSED||e===T.MEDIA_ENDED||e===T.MEDIA_LOADING||e===T.MEDIA_DURATION||e===T.MEDIA_SEEKABLE?(ke(this,hi).update({start:Yr(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),tt(this,Gi,_s).call(this),yg(this)):e===T.MEDIA_BUFFERED&&this.updateBufferedBar(),e===T.MEDIA_DURATION&&(this.mediaChaptersCues=ke(this,$i)));}get mediaChaptersCues(){return ke(this,$i)}set mediaChaptersCues(e){var t;Rt(this,$i,e),this.updateSegments((t=ke(this,$i))==null?void 0:t.map(i=>({start:Yr(this,i.startTime),end:Yr(this,i.endTime)})));}get mediaPaused(){return re(this,T.MEDIA_PAUSED)}set mediaPaused(e){ie(this,T.MEDIA_PAUSED,e);}get mediaLoading(){return re(this,T.MEDIA_LOADING)}set mediaLoading(e){ie(this,T.MEDIA_LOADING,e);}get mediaDuration(){return oe(this,T.MEDIA_DURATION)}set mediaDuration(e){me(this,T.MEDIA_DURATION,e);}get mediaCurrentTime(){return oe(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){me(this,T.MEDIA_CURRENT_TIME,e);}get mediaPlaybackRate(){return oe(this,T.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){me(this,T.MEDIA_PLAYBACK_RATE,e);}get mediaBuffered(){let e=this.getAttribute(T.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(i=>+i)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(T.MEDIA_BUFFERED);return}let t=e.map(i=>i.join(":")).join(" ");this.setAttribute(T.MEDIA_BUFFERED,t);}get mediaSeekable(){let e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.MEDIA_SEEKABLE,e.join(":"));}get mediaSeekableEnd(){var e;let[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return Ae(this,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ge(this,T.MEDIA_PREVIEW_IMAGE,e);}get mediaPreviewTime(){return oe(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){me(this,T.MEDIA_PREVIEW_TIME,e);}get mediaEnded(){return re(this,T.MEDIA_ENDED)}set mediaEnded(e){ie(this,T.MEDIA_ENDED,e);}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox();}updateBufferedBar(){var e;let t=this.mediaBuffered;if(!t.length)return;let i;if(this.mediaEnded)i=1;else {let n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];i=Yr(this,a);}let{style:r}=ce(this.shadowRoot,"#highlight");r.setProperty("width",`${i*100}%`);}updateCurrentBox(){if(!ke(this,Ss).assignedElements().length)return;let e=tt(this,Qr,Eo).call(this,ke(this,Ss),this.range.valueAsNumber),{style:t}=ce(this.shadowRoot,"#current-rail");t.transform=`translateX(${e})`;}handleEvent(e){switch(super.handleEvent(e),e.type){case "input":tt(this,fo,Ih).call(this);break;case "pointermove":tt(this,uo,xh).call(this,e);break;case "pointerup":case "pointerleave":tt(this,Is,Zr).call(this,null);break;case "transitionstart":Vt(e.target,this)&&setTimeout(()=>tt(this,Gi,_s).call(this),0);break}}};Bi=new WeakMap;hi=new WeakMap;qr=new WeakMap;xs=new WeakMap;zr=new WeakMap;Ss=new WeakMap;Xr=new WeakMap;jr=new WeakMap;$i=new WeakMap;Gi=new WeakSet;_s=function(){tt(this,po,_h).call(this)?ke(this,hi).start():ke(this,hi).stop();};po=new WeakSet;_h=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaDuration>0&&Jd(this)};ho=new WeakMap;Qr=new WeakSet;Eo=function(s,e){var t;let i=`${e*100*100}%`,r=s.offsetWidth;if(!r)return i;let n=(t=this.getAttribute("bounds")?Kt(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?t:this,a=this.range.getBoundingClientRect(),o=n.getBoundingClientRect(),l=(ke(this,Xr)-(a.left-o.left-r/2))/a.width*100,d=(o.right-a.left-r/2-ke(this,jr))/a.width*100;return Number.isNaN(l)||(i=`max(${l*100}%, ${i})`),Number.isNaN(d)||(i=`min(${i}, ${d*100}%)`),i};uo=new WeakSet;xh=function(s){let e=[...ke(this,qr)].some(l=>s.composedPath().includes(l));if(!this.dragging&&(e||!s.composedPath().includes(this))){tt(this,Is,Zr).call(this,null);return}let t=this.mediaDuration;if(!t)return;let i=this.range.getBoundingClientRect(),r=(s.clientX-i.left)/i.width;r=Math.max(0,Math.min(1,r));let n=tt(this,Qr,Eo).call(this,ke(this,zr),r),{style:a}=ce(this.shadowRoot,"#preview-rail");a.transform=`translateX(${n})`;let o=Math.round(ke(this,xs))-Math.round(r*t);Math.abs(o)<1||(Rt(this,xs,r*t),tt(this,Is,Zr).call(this,ke(this,xs)));};Is=new WeakSet;Zr=function(s){this.dispatchEvent(new _.CustomEvent($.MEDIA_PREVIEW_REQUEST,{composed:true,bubbles:true,detail:s}));};fo=new WeakSet;Ih=function(){ke(this,hi).stop();let s=Rh(this);this.dispatchEvent(new _.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:s}));};_.customElements.get("media-time-range")||_.customElements.define("media-time-range",mo);var kh=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Ls=(s,e,t)=>(kh(s,e,"read from private field"),t?t.call(s):e.get(s)),Dh=(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);},Rs=(s,e,t,i)=>(kh(s,e,"write to private field"),e.set(s,t),t),Dt,Jr,Ch={LOADING_DELAY:"loadingdelay"},wh=500,Mh=M.createElement("template"),Sg=`
|
|
868
|
-
<svg aria-hidden="true" viewBox="0 0 100 100">
|
|
869
|
-
<path d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">
|
|
870
|
-
<animateTransform
|
|
871
|
-
attributeName="transform"
|
|
872
|
-
attributeType="XML"
|
|
873
|
-
type="rotate"
|
|
874
|
-
dur="1s"
|
|
875
|
-
from="0 50 50"
|
|
876
|
-
to="360 50 50"
|
|
877
|
-
repeatCount="indefinite" />
|
|
878
|
-
</path>
|
|
879
|
-
</svg>
|
|
880
|
-
`;Mh.innerHTML=`
|
|
881
|
-
<style>
|
|
882
|
-
:host {
|
|
883
|
-
display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));
|
|
884
|
-
vertical-align: middle;
|
|
885
|
-
box-sizing: border-box;
|
|
886
|
-
--_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${wh}ms);
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
#status {
|
|
890
|
-
color: rgba(0,0,0,0);
|
|
891
|
-
width: 0px;
|
|
892
|
-
height: 0px;
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
:host slot[name=icon] > *,
|
|
896
|
-
:host ::slotted([slot=icon]) {
|
|
897
|
-
opacity: var(--media-loading-indicator-opacity, 0);
|
|
898
|
-
transition: opacity 0.15s;
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
:host([${T.MEDIA_LOADING}]:not([${T.MEDIA_PAUSED}])) slot[name=icon] > *,
|
|
902
|
-
:host([${T.MEDIA_LOADING}]:not([${T.MEDIA_PAUSED}])) ::slotted([slot=icon]) {
|
|
903
|
-
opacity: var(--media-loading-indicator-opacity, 1);
|
|
904
|
-
transition: opacity 0.15s var(--_loading-indicator-delay);
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
:host #status {
|
|
908
|
-
visibility: var(--media-loading-indicator-opacity, hidden);
|
|
909
|
-
transition: visibility 0.15s;
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
:host([${T.MEDIA_LOADING}]:not([${T.MEDIA_PAUSED}])) #status {
|
|
913
|
-
visibility: var(--media-loading-indicator-opacity, visible);
|
|
914
|
-
transition: visibility 0.15s var(--_loading-indicator-delay);
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
svg, img, ::slotted(svg), ::slotted(img) {
|
|
918
|
-
width: var(--media-loading-indicator-icon-width);
|
|
919
|
-
height: var(--media-loading-indicator-icon-height, 100px);
|
|
920
|
-
fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
|
|
921
|
-
vertical-align: middle;
|
|
922
|
-
}
|
|
923
|
-
</style>
|
|
924
|
-
|
|
925
|
-
<slot name="icon">${Sg}</slot>
|
|
926
|
-
<div id="status" role="status" aria-live="polite">${Be.MEDIA_LOADING()}</div>
|
|
927
|
-
`;var vo=class extends _.HTMLElement{constructor(){if(super(),Dh(this,Dt,void 0),Dh(this,Jr,wh),!this.shadowRoot){let e=this.attachShadow({mode:"open"}),t=Mh.content.cloneNode(true);e.appendChild(t);}}static get observedAttributes(){return [Y.MEDIA_CONTROLLER,T.MEDIA_PAUSED,T.MEDIA_LOADING,Ch.LOADING_DELAY]}attributeChangedCallback(e,t,i){var r,n,a,o,l;e===Ch.LOADING_DELAY&&t!==i?this.loadingDelay=Number(i):e===Y.MEDIA_CONTROLLER&&(t&&((n=(r=Ls(this,Dt))==null?void 0:r.unassociateElement)==null||n.call(r,this),Rs(this,Dt,null)),i&&this.isConnected&&(Rs(this,Dt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=Ls(this,Dt))==null?void 0:o.associateElement)==null||l.call(o,this)));}connectedCallback(){var e,t,i;let r=this.getAttribute(Y.MEDIA_CONTROLLER);r&&(Rs(this,Dt,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=Ls(this,Dt))==null?void 0:t.associateElement)==null||i.call(t,this));}disconnectedCallback(){var e,t;(t=(e=Ls(this,Dt))==null?void 0:e.unassociateElement)==null||t.call(e,this),Rs(this,Dt,null);}get loadingDelay(){return Ls(this,Jr)}set loadingDelay(e){Rs(this,Jr,e);let{style:t}=ce(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`);}get mediaPaused(){return re(this,T.MEDIA_PAUSED)}set mediaPaused(e){ie(this,T.MEDIA_PAUSED,e);}get mediaLoading(){return re(this,T.MEDIA_LOADING)}set mediaLoading(e){ie(this,T.MEDIA_LOADING,e);}};Dt=new WeakMap;Jr=new WeakMap;_.customElements.get("media-loading-indicator")||_.customElements.define("media-loading-indicator",vo);var _g=1,xg=s=>s.mediaMuted?0:s.mediaVolume,Ig=({value:s})=>`${Math.round(s*100)}%`,To=class extends di{static get observedAttributes(){return [...super.observedAttributes,T.MEDIA_VOLUME,T.MEDIA_MUTED,T.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{let e=this.range.value,t=new _.CustomEvent($.MEDIA_VOLUME_REQUEST,{composed:true,bubbles:true,detail:e});this.dispatchEvent(t);});}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",Be.VOLUME());}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),(e===T.MEDIA_VOLUME||e===T.MEDIA_MUTED)&&(this.range.valueAsNumber=xg(this),this.range.setAttribute("aria-valuetext",Ig(this.range)),this.updateBar());}get mediaVolume(){return oe(this,T.MEDIA_VOLUME,_g)}set mediaVolume(e){me(this,T.MEDIA_VOLUME,e);}get mediaMuted(){return re(this,T.MEDIA_MUTED)}set mediaMuted(e){ie(this,T.MEDIA_MUTED,e);}get mediaVolumeUnavailable(){return Ae(this,T.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){ge(this,T.MEDIA_VOLUME_UNAVAILABLE,e);}};_.customElements.get("media-volume-range")||_.customElements.define("media-volume-range",To);var xo=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Ue=(s,e,t)=>(xo(s,e,"read from private field"),t?t.call(s):e.get(s)),Ze=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},ct=(s,e,t,i)=>(xo(s,e,"write to private field"),e.set(s,t),t),dt=(s,e,t)=>(xo(s,e,"access private method"),t),Ct,Xt,Vi,Ds,en,tn,Ao,Hi,bo,sn,yo,Cs,rn,nn,So,_o,Ph,Io,Oh,Lg=`
|
|
928
|
-
<svg aria-hidden="true" viewBox="0 1 24 24" part="select-indicator indicator">
|
|
929
|
-
<path d="m10 15.17 9.193-9.191 1.414 1.414-10.606 10.606-6.364-6.364 1.414-1.414 4.95 4.95Z"/>
|
|
930
|
-
</svg>`;function Lo(s,e,t){let i=M.createElement("media-chrome-option");i.part.add("option"),i.value=e,i.selected=t;let r=M.createElement("span");return r.textContent=s,i.append(r),i}function an(s,e){let t=s.querySelector(`:scope > [slot="${e}"]`);return t?.nodeName=="SLOT"&&(t=t.assignedElements({flatten:true})[0]),t?(t=t.cloneNode(true),t.removeAttribute("slot"),t):s.shadowRoot.querySelector(`[name="${e}"] > svg`).cloneNode(true)}var Nh=M.createElement("template");Nh.innerHTML=`
|
|
931
|
-
<style>
|
|
932
|
-
:host {
|
|
933
|
-
font: var(--media-font,
|
|
934
|
-
var(--media-font-weight, normal)
|
|
935
|
-
var(--media-font-size, 15px) /
|
|
936
|
-
var(--media-text-content-height, var(--media-control-height, 24px))
|
|
937
|
-
var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
|
|
938
|
-
color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
|
|
939
|
-
background: var(--media-listbox-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .8))));
|
|
940
|
-
border-radius: var(--media-listbox-border-radius);
|
|
941
|
-
display: inline-flex;
|
|
942
|
-
flex-direction: column;
|
|
943
|
-
position: relative;
|
|
944
|
-
box-sizing: border-box;
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
::slotted([slot="header"]) {
|
|
948
|
-
padding: .4em 1.4em;
|
|
949
|
-
border-bottom: 1px solid rgb(255 255 255 / .25);
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
#container {
|
|
953
|
-
gap: var(--media-listbox-gap);
|
|
954
|
-
display: flex;
|
|
955
|
-
flex-direction: var(--media-listbox-flex-direction, column);
|
|
956
|
-
overflow: hidden auto;
|
|
957
|
-
padding-block: .5em;
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
media-chrome-option {
|
|
961
|
-
padding-inline: .7em 1.4em;
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
media-chrome-option > span {
|
|
965
|
-
margin-inline: .5ch;
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
[part~="indicator"] {
|
|
969
|
-
fill: var(--media-option-indicator-fill, var(--media-icon-color, var(--media-primary-color, rgb(238 238 238))));
|
|
970
|
-
height: var(--media-option-indicator-height, 1.25em);
|
|
971
|
-
vertical-align: var(--media-option-indicator-vertical-align, text-top);
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
[part~="select-indicator"] {
|
|
975
|
-
display: var(--media-option-select-indicator-display);
|
|
976
|
-
visibility: hidden;
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
[aria-selected="true"] > [part~="select-indicator"] {
|
|
980
|
-
visibility: visible;
|
|
981
|
-
}
|
|
982
|
-
</style>
|
|
983
|
-
<style id="layout-row" media="width:0">
|
|
984
|
-
|
|
985
|
-
::slotted([slot="header"]) {
|
|
986
|
-
padding: .4em .5em;
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
#container {
|
|
990
|
-
gap: var(--media-listbox-gap, .25em);
|
|
991
|
-
flex-direction: var(--media-listbox-flex-direction, row);
|
|
992
|
-
padding-inline: .5em;
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
media-chrome-option {
|
|
996
|
-
padding: .3em .24em;
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
media-chrome-option[aria-selected="true"] {
|
|
1000
|
-
background: var(--media-option-selected-background, rgb(255 255 255 / .2));
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
[part~="select-indicator"] {
|
|
1004
|
-
display: var(--media-option-select-indicator-display, none);
|
|
1005
|
-
}
|
|
1006
|
-
</style>
|
|
1007
|
-
<slot name="header"></slot>
|
|
1008
|
-
<slot id="container"></slot>
|
|
1009
|
-
<slot name="select-indicator" hidden>${Lg}</slot>
|
|
1010
|
-
`;var ks=class extends _.HTMLElement{constructor(e={}){super(),Ze(this,tn),Ze(this,sn),Ze(this,Cs),Ze(this,nn),Ze(this,_o),Ze(this,Io),Ze(this,Ct,void 0),Ze(this,Xt,""),Ze(this,Vi,null),Ze(this,Ds,false),Ze(this,en,t=>{this.handleClick(t);}),Ze(this,Hi,t=>{let{key:i}=t;if(i==="Escape"){this.removeEventListener("keyup",Ue(this,Hi));return}if(i==="Meta"){ct(this,Ds,false);return}dt(this,tn,Ao).call(this,t);}),Ze(this,bo,t=>{let{key:i,altKey:r}=t;if(r){this.removeEventListener("keyup",Ue(this,Hi));return}if(i==="Meta"){ct(this,Ds,true);return}if(this.keysUsed.includes(i)&&t.preventDefault(),Ue(this,Ds)&&this.keysUsed.includes(i)){dt(this,tn,Ao).call(this,t);return}this.addEventListener("keyup",Ue(this,Hi),{once:true});}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=Nh.content.cloneNode(true),e.slotTemplate&&this.nativeEl.append(e.slotTemplate.content.cloneNode(true)),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.container.addEventListener("slotchange",t=>{for(let i of t.target.assignedNodes({flatten:true}))i.nodeType===3&&i.textContent.trim()===""&&i.remove();});}static get observedAttributes(){return ["disabled","style",Y.MEDIA_CONTROLLER]}static formatOptionText(e){return e}formatOptionText(e,t){return this.constructor.formatOptionText(e,t)}get options(){var e;let t=this.querySelectorAll("media-chrome-option");return t.length||(t=(e=this.container)==null?void 0:e.querySelectorAll("media-chrome-option")),Array.from(t)}get selectedOptions(){return this.options.filter(e=>e.selected)}get value(){var e,t;return (t=(e=this.selectedOptions[0])==null?void 0:e.value)!=null?t:""}set value(e){let t=this.options.find(i=>i.value===e);t&&dt(this,nn,So).call(this,t);}focus(){var e;(e=this.selectedOptions[0])==null||e.focus();}enable(){this.addEventListener("click",Ue(this,en)),this.addEventListener("keydown",Ue(this,bo));}disable(){this.removeEventListener("click",Ue(this,en)),this.removeEventListener("keyup",Ue(this,Hi));}attributeChangedCallback(e,t,i){var r,n,a,o,l;e==="style"&&i!==t?dt(this,sn,yo).call(this):e===Y.MEDIA_CONTROLLER?(t&&((n=(r=Ue(this,Ct))==null?void 0:r.unassociateElement)==null||n.call(r,this),ct(this,Ct,null)),i&&this.isConnected&&(ct(this,Ct,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=Ue(this,Ct))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&i!==t&&(i==null?this.enable():this.disable());}connectedCallback(){var e,t,i;dt(this,sn,yo).call(this),this.hasAttribute("disabled")||this.enable(),this.hasAttribute("role")||this.setAttribute("role","listbox");let r=this.getAttribute(Y.MEDIA_CONTROLLER);r&&(ct(this,Ct,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=Ue(this,Ct))==null?void 0:t.associateElement)==null||i.call(t,this));}disconnectedCallback(){var e,t;this.disable(),(t=(e=Ue(this,Ct))==null?void 0:e.unassociateElement)==null||t.call(e,this),ct(this,Ct,null);}get keysUsed(){return ["Enter"," ","ArrowDown","ArrowUp","Home","End"]}handleSelection(e,t){let i=dt(this,Cs,rn).call(this,e);i&&dt(this,nn,So).call(this,i,t);}handleMovement(e){let{key:t}=e,i=this.options,r=dt(this,Cs,rn).call(this,e);r||(r=i.filter(a=>a.getAttribute("tabindex")==="0")[0]);let n;switch(t){case "ArrowDown":n=r.nextElementSibling,n?.hasAttribute("disabled")&&(n=n.nextElementSibling);break;case "ArrowUp":n=r.previousElementSibling,n?.hasAttribute("disabled")&&(n=n.previousElementSibling);break;case "Home":n=i[0];break;case "End":n=i[i.length-1];break;default:n=dt(this,_o,Ph).call(this,t);break}n&&(i.forEach(a=>a.setAttribute("tabindex","-1")),n.setAttribute("tabindex","0"),n.focus());}handleClick(e){let t=dt(this,Cs,rn).call(this,e);!t||t.hasAttribute("disabled")||(this.options.forEach(i=>i.setAttribute("tabindex","-1")),t.setAttribute("tabindex","0"),this.handleSelection(e,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"));}};Ct=new WeakMap;Xt=new WeakMap;Vi=new WeakMap;Ds=new WeakMap;en=new WeakMap;tn=new WeakSet;Ao=function(s){let{key:e}=s;e==="Enter"||e===" "?this.handleSelection(s,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"):this.handleMovement(s);};Hi=new WeakMap;bo=new WeakMap;sn=new WeakSet;yo=function(){var s;let e=this.shadowRoot.querySelector("#layout-row"),t=((s=getComputedStyle(this).getPropertyValue("--media-listbox-layout"))==null?void 0:s.trim())==="row";e.setAttribute("media",t?"":"width:0");};Cs=new WeakSet;rn=function(s){let e=s.composedPath(),t=e.findIndex(i=>i.nodeName==="MEDIA-CHROME-OPTION");return e[t]};nn=new WeakSet;So=function(s,e){let t=[...this.selectedOptions];(!this.hasAttribute("aria-multiselectable")||this.getAttribute("aria-multiselectable")!=="true")&&this.options.forEach(i=>i.selected=false),e?s.selected=!s.selected:s.selected=true,this.selectedOptions.some((i,r)=>i!=t[r])&&this.dispatchEvent(new Event("change",{bubbles:true,composed:true}));};_o=new WeakSet;Ph=function(s){dt(this,Io,Oh).call(this);let e=this.options,t=e.findIndex(d=>d.getAttribute("tabindex")==="0");ct(this,Xt,Ue(this,Xt)+s);let i=Ue(this,Xt).split("").every(d=>d===s),r=e.slice(t+(i?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(Ue(this,Xt))),n=e.slice(0,t-(i?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(Ue(this,Xt))),a=[],o=[];return i&&(a=e.slice(t+(i?1:0)).filter(d=>d.textContent.startsWith(s)),o=e.slice(0,t-(i?1:0)).filter(d=>d.textContent.startsWith(s))),[...r,...n,...a,...o][0]};Io=new WeakSet;Oh=function(){clearTimeout(Ue(this,Vi)),ct(this,Vi,null),ct(this,Vi,setTimeout(()=>{ct(this,Xt,""),ct(this,Vi,null);},500));};_.customElements.get("media-chrome-listbox")||_.customElements.define("media-chrome-listbox",ks);var Do=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},B=(s,e,t)=>(Do(s,e,"read from private field"),t?t.call(s):e.get(s)),Ye=(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);},kt=(s,e,t,i)=>(Do(s,e,"write to private field"),e.set(s,t),t),ui=(s,e,t)=>(Do(s,e,"access private method"),t),wt,Ge,ws,ye,ht,Ki,on,ln,dn,cn,hn,Ro,Co,Fh,Wi,Ms,fi,Uh=M.createElement("template");Uh.innerHTML=`
|
|
1011
|
-
<style>
|
|
1012
|
-
:host {
|
|
1013
|
-
font: var(--media-font,
|
|
1014
|
-
var(--media-font-weight, normal)
|
|
1015
|
-
var(--media-font-size, 15px) /
|
|
1016
|
-
var(--media-text-content-height, var(--media-control-height, 24px))
|
|
1017
|
-
var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
|
|
1018
|
-
color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
|
|
1019
|
-
display: inline-flex;
|
|
1020
|
-
position: relative;
|
|
1021
|
-
flex-shrink: .5;
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
[name=listbox]::slotted(*),
|
|
1025
|
-
[part=listbox] {
|
|
1026
|
-
position: absolute;
|
|
1027
|
-
bottom: 100%;
|
|
1028
|
-
max-height: 300px;
|
|
1029
|
-
transition: var(--media-selectmenu-transition-in,
|
|
1030
|
-
visibility 0s, transform .15s ease-out, opacity .15s ease-out);
|
|
1031
|
-
transform: var(--media-listbox-transform-in, translateY(0) scale(1));
|
|
1032
|
-
visibility: visible;
|
|
1033
|
-
opacity: 1;
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
[name=listbox][hidden]::slotted(*),
|
|
1037
|
-
[hidden] [part=listbox] {
|
|
1038
|
-
transition: var(--media-selectmenu-transition-out,
|
|
1039
|
-
visibility .15s ease-out, transform .15s ease-out, opacity .15s ease-out);
|
|
1040
|
-
transform: var(--media-listbox-transform-out, translateY(2px) scale(.99));
|
|
1041
|
-
visibility: hidden;
|
|
1042
|
-
opacity: 0;
|
|
1043
|
-
pointer-events: none;
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
slot[name=listbox][hidden] {
|
|
1047
|
-
display: block;
|
|
1048
|
-
}
|
|
1049
|
-
</style>
|
|
1050
|
-
|
|
1051
|
-
<slot name="button">
|
|
1052
|
-
<media-chrome-button aria-haspopup="listbox" part="button">
|
|
1053
|
-
<slot name="button-content"></slot>
|
|
1054
|
-
</media-chrome-button>
|
|
1055
|
-
</slot>
|
|
1056
|
-
<slot name="listbox" hidden>
|
|
1057
|
-
<media-chrome-listbox id="listbox" part="listbox">
|
|
1058
|
-
<slot></slot>
|
|
1059
|
-
</media-chrome-listbox>
|
|
1060
|
-
</slot>
|
|
1061
|
-
`;var Os=class extends _.HTMLElement{constructor(){var e;super(),Ye(this,hn),Ye(this,Co),Ye(this,Wi),Ye(this,wt,void 0),Ye(this,Ge,void 0),Ye(this,ws,void 0),Ye(this,ye,void 0),Ye(this,ht,void 0),Ye(this,Ki,t=>{let{key:i}=t;if(!this.keysUsed.includes(i)){this.removeEventListener("keyup",B(this,Ki));return}t.composedPath().includes(B(this,Ge))&&(i==="Enter"||i===" ")?ui(this,hn,Ro).call(this):i==="Escape"&&ui(this,Wi,Ms).call(this);}),Ye(this,on,t=>{let{metaKey:i,altKey:r,key:n}=t;if(i||r||!this.keysUsed.includes(n)){this.removeEventListener("keyup",B(this,Ki));return}t.preventDefault(),this.addEventListener("keyup",B(this,Ki),{once:true});}),Ye(this,ln,t=>{t.composedPath().includes(this)||ui(this,Wi,Ms).call(this);}),Ye(this,dn,t=>{t.composedPath().includes(B(this,Ge))&&ui(this,hn,Ro).call(this);}),Ye(this,cn,()=>{ui(this,Wi,Ms).call(this);}),Ye(this,fi,()=>{if(B(this,ye).offsetWidth===0)return;let t=B(this,ye).offsetWidth,i=B(this,Ge).getBoundingClientRect();if(this.hasAttribute("mediacontroller")||B(this,Ge).hasAttribute("mediacontroller")||B(this,ye).hasAttribute("mediacontroller")){B(this,ye).style.zIndex="1",B(this,ye).style.bottom="unset",B(this,ye).style.right=null,B(this,ye).style.left="0",B(this,ye).style.top=`${i.height}px`;return}let n=Ps(this).getBoundingClientRect(),a=i.x+t,o=Math.max(i.right-a,i.right-n.right);B(this,ye).style.left=null,B(this,ye).style.right=`${o}px`,B(this,ye).style.maxHeight=`${n.height-i.height}px`;}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Uh.content.cloneNode(true))),(e=this.init)==null||e.call(this),kt(this,Ge,this.shadowRoot.querySelector("[part=button]")),kt(this,ye,this.shadowRoot.querySelector("[part=listbox]")),kt(this,ws,this.shadowRoot.querySelector("slot[name=button]")),B(this,ws).addEventListener("slotchange",()=>{let t=B(this,ws).assignedElements()[0];if(!t)return;kt(this,Ge,t),B(this,Ge).preventClick=true,this.hasAttribute("disabled")||B(this,Ge).hasAttribute("disabled")?this.disable():(this.enable(),B(this,Ge).setAttribute("aria-haspopup","listbox"));}),kt(this,ht,this.shadowRoot.querySelector("slot[name=listbox]")),B(this,ht).addEventListener("slotchange",()=>{kt(this,ye,B(this,ht).assignedElements()[0]||B(this,ye));});}static get observedAttributes(){return ["disabled",Y.MEDIA_CONTROLLER]}enable(){B(this,Ge).toggleAttribute("disabled",false),this.addEventListener("change",B(this,cn)),this.addEventListener("keydown",B(this,on)),this.addEventListener("click",B(this,dn)),M.addEventListener("click",B(this,ln));}disable(){B(this,Ge).toggleAttribute("disabled",true),this.removeEventListener("change",B(this,cn)),this.removeEventListener("keydown",B(this,on)),this.removeEventListener("keyup",B(this,Ki)),this.removeEventListener("click",B(this,dn)),M.removeEventListener("click",B(this,ln));}attributeChangedCallback(e,t,i){var r,n,a,o,l;e===Y.MEDIA_CONTROLLER?(t&&((n=(r=B(this,wt))==null?void 0:r.unassociateElement)==null||n.call(r,this),kt(this,wt,null),B(this,ye).removeAttribute(Y.MEDIA_CONTROLLER)),i&&this.isConnected&&(kt(this,wt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=B(this,wt))==null?void 0:o.associateElement)==null||l.call(o,this),B(this,ye).setAttribute(Y.MEDIA_CONTROLLER,i))):e==="disabled"&&i!==t&&(i==null?this.enable():this.disable());}connectedCallback(){var e,t,i;let{style:r}=ce(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let n=this.getAttribute(Y.MEDIA_CONTROLLER);n&&(kt(this,wt,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=B(this,wt))==null?void 0:t.associateElement)==null||i.call(t,this),B(this,ye).setAttribute(Y.MEDIA_CONTROLLER,n)),this.hasAttribute("disabled")||this.enable(),B(this,ht).hidden||ri(Ps(this),B(this,fi));}disconnectedCallback(){var e,t;ls(Ps(this),B(this,fi)),this.disable(),(t=(e=B(this,wt))==null?void 0:e.unassociateElement)==null||t.call(e,this),kt(this,wt,null),B(this,ye).removeAttribute(Y.MEDIA_CONTROLLER);}get keysUsed(){return ["Enter","Escape"," ","ArrowUp","ArrowDown","f","c","k","m"]}};wt=new WeakMap;Ge=new WeakMap;ws=new WeakMap;ye=new WeakMap;ht=new WeakMap;Ki=new WeakMap;on=new WeakMap;ln=new WeakMap;dn=new WeakMap;cn=new WeakMap;hn=new WeakSet;Ro=function(){B(this,ht).hidden?ui(this,Co,Fh).call(this):ui(this,Wi,Ms).call(this);};Co=new WeakSet;Fh=function(){B(this,ht).hidden&&(B(this,ht).hidden=false,B(this,Ge).setAttribute("aria-expanded","true"),B(this,fi).call(this),B(this,ye).focus(),ri(Ps(this),B(this,fi)));};Wi=new WeakSet;Ms=function(){if(B(this,ht).hidden)return;ls(Ps(this),B(this,fi));let s=ga();B(this,ht).hidden=true,B(this,Ge).setAttribute("aria-expanded","false"),Vt(B(this,ye),s)&&B(this,Ge).focus();};fi=new WeakMap;function Ps(s){var e;return (e=s.getAttribute("bounds")?Kt(s,`#${s.getAttribute("bounds")}`):Rg(s)||s.parentElement)!=null?e:s}function Rg(s){var e;let t=s.getAttribute(Y.MEDIA_CONTROLLER);return t?(e=s.getRootNode())==null?void 0:e.getElementById(t):Kt(s,"media-controller")}_.customElements.get("media-chrome-selectmenu")||_.customElements.define("media-chrome-selectmenu",Os);var Fo=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Mo=(s,e,t)=>(Fo(s,e,"read from private field"),e.get(s)),ko=(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);},wo=(s,e,t,i)=>(Fo(s,e,"write to private field"),e.set(s,t),t),Bh=(s,e,t)=>(Fo(s,e,"access private method"),t),un,Yi,fn,Po,$h=M.createElement("template");$h.innerHTML=`
|
|
1062
|
-
<style>
|
|
1063
|
-
:host {
|
|
1064
|
-
cursor: pointer;
|
|
1065
|
-
display: block;
|
|
1066
|
-
line-height: revert;
|
|
1067
|
-
white-space: nowrap;
|
|
1068
|
-
white-space-collapse: collapse;
|
|
1069
|
-
text-wrap: nowrap;
|
|
1070
|
-
padding: .4em .5em;
|
|
1071
|
-
transition: var(--media-option-transition);
|
|
1072
|
-
outline: var(--media-option-outline, 0);
|
|
1073
|
-
outline-offset: var(--media-option-outline-offset, -1px);
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
:host(:focus-visible) {
|
|
1077
|
-
box-shadow: var(--media-option-focus-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
|
|
1078
|
-
outline: var(--media-option-hover-outline, 0);
|
|
1079
|
-
outline-offset: var(--media-option-hover-outline-offset, var(--media-option-outline-offset, -1px));
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
:host(:hover) {
|
|
1083
|
-
cursor: pointer;
|
|
1084
|
-
background: var(--media-option-hover-background, rgb(82 82 122 / .8));
|
|
1085
|
-
outline: var(--media-option-hover-outline);
|
|
1086
|
-
outline-offset: var(--media-option-hover-outline-offset, var(--media-option-outline-offset, -1px));
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
:host([aria-selected="true"]) {
|
|
1090
|
-
background: var(--media-option-selected-background);
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
:host([disabled]) {
|
|
1094
|
-
pointer-events: none;
|
|
1095
|
-
color: rgba(255, 255, 255, .3);
|
|
1096
|
-
}
|
|
1097
|
-
</style>
|
|
1098
|
-
<slot></slot>
|
|
1099
|
-
`;var jt={VALUE:"value",SELECTED:"selected",DISABLED:"disabled"},Oo=class extends _.HTMLElement{constructor(){super(),ko(this,fn),ko(this,un,false),ko(this,Yi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild($h.content.cloneNode(true)));}static get observedAttributes(){return [jt.DISABLED,jt.SELECTED,jt.VALUE]}get value(){var e;return (e=this.getAttribute(jt.VALUE))!=null?e:this.text}set value(e){this.setAttribute(jt.VALUE,e);}get text(){var e;return ((e=this.textContent)!=null?e:"").trim()}get selected(){return this.getAttribute("aria-selected")==="true"}set selected(e){wo(this,un,true),this.setAttribute("aria-selected",e?"true":"false"),e?this.part.add("option-selected"):this.part.remove("option-selected");}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex",-1),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false");}disable(){this.removeAttribute("tabindex");}attributeChangedCallback(e,t,i){e===jt.SELECTED&&!Mo(this,un)?this.setAttribute("aria-selected",i!=null?"true":"false"):e===jt.DISABLED&&i!==t&&(i==null?this.enable():this.disable());}connectedCallback(){this.hasAttribute(jt.DISABLED)||this.enable(),this.setAttribute("role","option"),wo(this,Yi,No(this,this.parentNode)),Bh(this,fn,Po).call(this);}disconnectedCallback(){this.disable(),Bh(this,fn,Po).call(this),wo(this,Yi,null);}handleClick(){}};un=new WeakMap;Yi=new WeakMap;fn=new WeakSet;Po=function(){var s;let e=(s=Mo(this,Yi))==null?void 0:s.options;if(!e)return;let t=e.filter(i=>i.getAttribute("aria-selected")==="true").pop();t||(t=e[0]),Mo(this,Yi).getAttribute("aria-multiselectable")!=="true"&&e.forEach(i=>{i.setAttribute("tabindex","-1"),i.setAttribute("aria-selected","false");}),t?.setAttribute("tabindex","0"),t?.setAttribute("aria-selected","true");};function No(s,e){if(!s)return null;let{host:t}=s.getRootNode();return !e&&t?No(s,t):e?.options?e:No(e,e?.parentNode)}_.customElements.get("media-chrome-option")||_.customElements.define("media-chrome-option",Oo);var Vo=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Dg=(s,e,t)=>(Vo(s,e,"read from private field"),e.get(s)),Uo=(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);},Cg=(s,e,t,i)=>(Vo(s,e,"write to private field"),e.set(s,t),t),Bo=(s,e,t)=>(Vo(s,e,"access private method"),t),gn,$o,Vh,mn,Go,kg=`
|
|
1100
|
-
<svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">
|
|
1101
|
-
<path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
|
|
1102
|
-
</svg>`,Kh=M.createElement("template");Kh.innerHTML=`
|
|
1103
|
-
<slot name="captions-indicator" hidden>${kg}</slot>
|
|
1104
|
-
`;var Ho=class extends ks{constructor(){super({slotTemplate:Kh}),Uo(this,$o),Uo(this,mn),Uo(this,gn,void 0);}static get observedAttributes(){return [...super.observedAttributes,"aria-multiselectable",T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===T.MEDIA_SUBTITLES_LIST&&t!==i?Bo(this,$o,Vh).call(this):e===T.MEDIA_SUBTITLES_SHOWING&&t!==i?this.value=i:e==="aria-multiselectable"&&(this.removeAttribute("aria-multiselectable"),console.warn("Captions List doesn't currently support multiple selections. You can enable multiple items via the media.textTracks API."));}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Bo(this,mn,Go));}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Bo(this,mn,Go));}get mediaSubtitlesList(){return Gh(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Hh(this,T.MEDIA_SUBTITLES_LIST,e);}get mediaSubtitlesShowing(){return Gh(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Hh(this,T.MEDIA_SUBTITLES_SHOWING,e);}};gn=new WeakMap;$o=new WeakSet;Vh=function(){var s;if(Dg(this,gn)===JSON.stringify(this.mediaSubtitlesList))return;Cg(this,gn,JSON.stringify(this.mediaSubtitlesList));let e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.value,i=Lo(this.formatOptionText("Off"),"off",t);i.prepend(an(this,"select-indicator")),e.append(i);let r=this.mediaSubtitlesList;for(let n of r){let a=Lo(this.formatOptionText(n.label,n),mr(n),this.value==mr(n));a.prepend(an(this,"select-indicator")),((s=n.kind)!=null?s:"subs")==="captions"&&a.append(an(this,"captions-indicator")),e.append(a);}};mn=new WeakSet;Go=function(){let s=this.mediaSubtitlesShowing,e=this.getAttribute(T.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(s?.length&&t&&this.dispatchEvent(new _.CustomEvent($.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:true,bubbles:true,detail:s})),!this.value||!t)return;let i=new _.CustomEvent($.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:true,bubbles:true,detail:this.value});this.dispatchEvent(i);};var Gh=(s,e)=>{let t=s.getAttribute(e);return t?us(t):[]},Hh=(s,e,t)=>{if(!t?.length){s.removeAttribute(e);return}let i=oi(t);s.getAttribute(e)!==i&&s.setAttribute(e,i);};_.customElements.get("media-captions-listbox")||_.customElements.define("media-captions-listbox",Ho);var Ko=class extends Os{init(){let e=M.createElement("media-captions-button");e.part.add("button"),e.preventClick=true;let t=M.createElement("media-captions-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let i=this.shadowRoot.querySelector("slot[name=button]"),r=this.shadowRoot.querySelector("slot[name=listbox]");i.textContent="",r.textContent="",i.append(e),r.append(t);}};_.customElements.get("media-captions-selectmenu")||_.customElements.define("media-captions-selectmenu",Ko);var js=b(b$1(),1);function wg(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var $u={exports:{}};(function(s,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,c){if(c=c||{},l=l.trim(),d=d.trim(),!d){if(!c.alwaysNormalize)return l;var h=o.parseURL(l);if(!h)throw new Error("Error trying to parse base URL.");return h.path=o.normalizePath(h.path),o.buildURLFromParts(h)}var u=o.parseURL(d);if(!u)throw new Error("Error trying to parse relative URL.");if(u.scheme)return c.alwaysNormalize?(u.path=o.normalizePath(u.path),o.buildURLFromParts(u)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=r.exec(f.path);f.netLoc=m[1],f.path=m[2];}f.netLoc&&!f.path&&(f.path="/");var g={scheme:f.scheme,netLoc:u.netLoc,path:null,params:u.params,query:u.query,fragment:u.fragment};if(!u.netLoc&&(g.netLoc=f.netLoc,u.path[0]!=="/"))if(!u.path)g.path=f.path,u.params||(g.params=f.params,u.query||(g.query=f.query));else {var E=f.path,v=E.substring(0,E.lastIndexOf("/")+1)+u.path;g.path=o.normalizePath(v);}return g.path===null&&(g.path=c.alwaysNormalize?o.normalizePath(u.path):u.path),o.buildURLFromParts(g)},parseURL:function(l){var d=i.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};s.exports=o;})();})($u);var Td=$u.exports;function Wh(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),t.push.apply(t,i);}return t}function Oe(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Wh(Object(t),true).forEach(function(i){Og(s,i,t[i]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Wh(Object(t)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(t,i));});}return s}function Mg(s,e){if(typeof s!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var i=t.call(s,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return (e==="string"?String:Number)(s)}function Pg(s){var e=Mg(s,"string");return typeof e=="symbol"?e:String(e)}function Og(s,e,t){return e=Pg(e),e in s?Object.defineProperty(s,e,{value:t,enumerable:true,configurable:true,writable:true}):s[e]=t,s}function _e(){return _e=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(s[i]=t[i]);}return s},_e.apply(this,arguments)}var F=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},Ng=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=Fg},Fg=Number.MAX_SAFE_INTEGER||9007199254740991,p=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",s}({}),K=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),x=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.UNKNOWN="unknown",s}({}),gi=function(){},cl={trace:gi,debug:gi,log:gi,warn:gi,info:gi,error:gi},Us=cl;function Ug(s){let e=self.console[s];return e?e.bind(self.console,`[${s}] >`):gi}function Bg(s,...e){e.forEach(function(t){Us[t]=s[t]?s[t].bind(s):Ug(t);});}function $g(s,e){if(typeof console=="object"&&s===true||typeof s=="object"){Bg(s,"debug","log","info","warn","error");try{Us.log(`Debug logs enabled for "${e}" in hls.js version 1.5.15`);}catch{Us=cl;}}else Us=cl;}var S=Us,Gg=/^(\d+)x(\d+)$/,Yh=/(.+?)=(".*?"|.*?)(?:,|$)/g,Ee=class s{constructor(e){typeof e=="string"&&(e=s.parseAttrList(e)),_e(this,e);}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;let i=new Uint8Array(t.length/2);for(let r=0;r<t.length/2;r++)i[r]=parseInt(t.slice(r*2,r*2+2),16);return i}else return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){let t=Gg.exec(this[e]);if(t!==null)return {width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,i={},r='"';for(Yh.lastIndex=0;(t=Yh.exec(e))!==null;){let n=t[2];n.indexOf(r)===0&&n.lastIndexOf(r)===n.length-1&&(n=n.slice(1,-1));let a=t[1].trim();i[a]=n;}return i}};function Hg(s){return s!=="ID"&&s!=="CLASS"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function Vg(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}var Mn=class{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let i=t.attr;for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==i[r]){S.warn(`DATERANGE tag attribute: "${r}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=r;break}e=_e(new Ee({}),i,e);}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let i=new Date(this.attr["END-DATE"]);F(i.getTime())&&(this._endDate=i);}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;let e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(F(e))return e}else if(this._endDate)return (this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return "PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return !!this.id&&!this._badValueForSameId&&F(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}},ts=class{constructor(){this.aborted=false,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0};}},ne={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},Pn=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[ne.AUDIO]:null,[ne.VIDEO]:null,[ne.AUDIOVIDEO]:null},this.baseurl=e;}setByteRange(e,t){let i=e.split("@",2),r;i.length===1?r=t?.byteRangeEndOffset||0:r=parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r];}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return !this._url&&this.baseurl&&this.relurl&&(this._url=Td.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:true})),this._url||""}set url(e){this._url=e;}},Bs=class extends Pn{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new ts,this.data=void 0,this.bitrateTest=false,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e;}get decryptdata(){let{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){let t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else {let i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!F(this.programDateTime))return null;let e=F(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return true;if(this.levelkeys){let t=Object.keys(this.levelkeys),i=t.length;if(i>1||i===1&&this.levelkeys[t[0]].encrypted)return true}return false}setKeyFormat(e){if(this.levelkeys){let t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn));}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort();}setElementaryStreamInfo(e,t,i,r,n,a=false){let{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:i,startDTS:r,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,r),l.endDTS=Math.max(l.endDTS,n);}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[ne.AUDIO]=null,e[ne.VIDEO]=null,e[ne.AUDIOVIDEO]=null;}},hl=class extends Pn{constructor(e,t,i,r,n){super(i),this.fragOffset=0,this.duration=0,this.gap=false,this.independent=false,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new ts,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=r;let a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration);}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return !!(e.audio||e.video||e.audiovideo)}},Kg=10,ul=class{constructor(e){this.PTSKnown=false,this.alignedSliding=false,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=true,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=true,this.advanced=true,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=false,this.canSkipUntil=0,this.canSkipDateRanges=false,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=false,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e;}reloaded(e){if(!e){this.advanced=true,this.updated=true;return}let t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay;}get hasProgramDateTime(){return this.fragments.length?F(this.fragments[this.fragments.length-1].programDateTime):false}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Kg}get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return (e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return (e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return (e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return (e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}};function Ad(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0))}function Wg(s){let e=fl(s).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function Yg(s){let e=function(i,r,n){let a=i[r];i[r]=i[n],i[n]=a;};e(s,0,3),e(s,1,2),e(s,4,5),e(s,6,7);}function qg(s){let e=s.split(":"),t=null;if(e[0]==="data"&&e.length===2){let i=e[1].split(";"),r=i[i.length-1].split(",");if(r.length===2){let n=r[0]==="base64",a=r[1];n?(i.splice(-1,1),t=Ad(a)):t=Wg(a);}}return t}function fl(s){return Uint8Array.from(unescape(encodeURIComponent(s)),e=>e.charCodeAt(0))}var is=typeof self<"u"?self:void 0,de={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Xe={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function qh(s){switch(s){case Xe.FAIRPLAY:return de.FAIRPLAY;case Xe.PLAYREADY:return de.PLAYREADY;case Xe.WIDEVINE:return de.WIDEVINE;case Xe.CLEARKEY:return de.CLEARKEY}}var Fs={CENC:"1077efecc0b24d02ace33c1e52e2fb4b",CLEARKEY:"e2719d58a985b3c9781ab030af78d30e",PLAYREADY:"9a04f07998404286ab92e65be0885f95",WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function zh(s){if(s===Fs.WIDEVINE)return de.WIDEVINE;if(s===Fs.PLAYREADY)return de.PLAYREADY;if(s===Fs.CENC||s===Fs.CLEARKEY)return de.CLEARKEY}function Xh(s){switch(s){case de.FAIRPLAY:return Xe.FAIRPLAY;case de.PLAYREADY:return Xe.PLAYREADY;case de.WIDEVINE:return Xe.WIDEVINE;case de.CLEARKEY:return Xe.CLEARKEY}}function Wo(s){let{drmSystems:e,widevineLicenseUrl:t}=s,i=e?[de.FAIRPLAY,de.WIDEVINE,de.PLAYREADY,de.CLEARKEY].filter(r=>!!e[r]):[];return !i[de.WIDEVINE]&&t&&i.push(de.WIDEVINE),i}var Gu=function(s){return is!=null&&(s=is.navigator)!=null&&s.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function zg(s,e,t,i){let r;switch(s){case de.FAIRPLAY:r=["cenc","sinf"];break;case de.WIDEVINE:case de.PLAYREADY:r=["cenc"];break;case de.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return Xg(r,e,t,i)}function Xg(s,e,t,i){return [{initDataTypes:s,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function vi(s,e,t){return Uint8Array.prototype.slice?s.slice(e,t):new Uint8Array(Array.prototype.slice.call(s,e,t))}var bd=(s,e)=>e+10<=s.length&&s[e]===73&&s[e+1]===68&&s[e+2]===51&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128,Hu=(s,e)=>e+10<=s.length&&s[e]===51&&s[e+1]===68&&s[e+2]===73&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128,Gs=(s,e)=>{let t=e,i=0;for(;bd(s,e);){i+=10;let r=aa(s,e+6);i+=r,Hu(s,e+10)&&(i+=10),e+=i;}if(i>0)return s.subarray(t,t+i)},aa=(s,e)=>{let t=0;return t=(s[e]&127)<<21,t|=(s[e+1]&127)<<14,t|=(s[e+2]&127)<<7,t|=s[e+3]&127,t},jg=(s,e)=>bd(s,e)&&aa(s,e+6)+10<=s.length-e,yd=s=>{let e=Ku(s);for(let t=0;t<e.length;t++){let i=e[t];if(Vu(i))return ip(i)}},Vu=s=>s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp",Qg=s=>{let e=String.fromCharCode(s[0],s[1],s[2],s[3]),t=aa(s,4),i=10;return {type:e,size:t,data:s.subarray(i,i+t)}},Ku=s=>{let e=0,t=[];for(;bd(s,e);){let i=aa(s,e+6);e+=10;let r=e+i;for(;e+8<r;){let n=Qg(s.subarray(e)),a=Zg(n);a&&t.push(a),e+=n.size+10;}Hu(s,e)&&(e+=10);}return t},Zg=s=>s.type==="PRIV"?Jg(s):s.type[0]==="W"?tp(s):ep(s),Jg=s=>{if(s.size<2)return;let e=Ft(s.data,true),t=new Uint8Array(s.data.subarray(e.length+1));return {key:s.type,info:e,data:t.buffer}},ep=s=>{if(s.size<2)return;if(s.type==="TXXX"){let t=1,i=Ft(s.data.subarray(t),true);t+=i.length+1;let r=Ft(s.data.subarray(t));return {key:s.type,info:i,data:r}}let e=Ft(s.data.subarray(1));return {key:s.type,data:e}},tp=s=>{if(s.type==="WXXX"){if(s.size<2)return;let t=1,i=Ft(s.data.subarray(t),true);t+=i.length+1;let r=Ft(s.data.subarray(t));return {key:s.type,info:i,data:r}}let e=Ft(s.data);return {key:s.type,data:e}},ip=s=>{if(s.data.byteLength===8){let e=new Uint8Array(s.data),t=e[3]&1,i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}},Ft=(s,e=false)=>{let t=sp();if(t){let d=t.decode(s);if(e){let c=d.indexOf("\0");return c!==-1?d.substring(0,c):d}return d.replace(/\0/g,"")}let i=s.length,r,n,a,o="",l=0;for(;l<i;){if(r=s[l++],r===0&&e)return o;if(r===0||r===3)continue;switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(r);break;case 12:case 13:n=s[l++],o+=String.fromCharCode((r&31)<<6|n&63);break;case 14:n=s[l++],a=s[l++],o+=String.fromCharCode((r&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o},Yo;function sp(){if(!navigator.userAgent.includes("PlayStation 4"))return !Yo&&typeof self.TextDecoder<"u"&&(Yo=new self.TextDecoder("utf-8")),Yo}var Pt={hexDump:function(s){let e="";for(let t=0;t<s.length;t++){let i=s[t].toString(16);i.length<2&&(i="0"+i),e+=i;}return e}},On=Math.pow(2,32)-1,rp=[].push,Wu={video:1,audio:2,id3:3,text:4};function xe(s){return String.fromCharCode.apply(null,s)}function Yu(s,e){let t=s[e]<<8|s[e+1];return t<0?65536+t:t}function G(s,e){let t=qu(s,e);return t<0?4294967296+t:t}function jh(s,e){let t=G(s,e);return t*=Math.pow(2,32),t+=G(s,e+4),t}function qu(s,e){return s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3]}function qo(s,e,t){s[e]=t>>24,s[e+1]=t>>16&255,s[e+2]=t>>8&255,s[e+3]=t&255;}function np(s){let e=s.byteLength;for(let t=0;t<e;){let i=G(s,t);if(i>8&&s[t+4]===109&&s[t+5]===111&&s[t+6]===111&&s[t+7]===102)return true;t=i>1?t+i:e;}return false}function j(s,e){let t=[];if(!e.length)return t;let i=s.byteLength;for(let r=0;r<i;){let n=G(s,r),a=xe(s.subarray(r+4,r+8)),o=n>1?r+n:i;if(a===e[0])if(e.length===1)t.push(s.subarray(r+8,o));else {let l=j(s.subarray(r+8,o),e.slice(1));l.length&&rp.apply(t,l);}r=o;}return t}function ap(s){let e=[],t=s[0],i=8,r=G(s,i);i+=4;let n=0,a=0;t===0?(n=G(s,i),a=G(s,i+4),i+=8):(n=jh(s,i),a=jh(s,i+8),i+=16),i+=2;let o=s.length+a,l=Yu(s,i);i+=2;for(let d=0;d<l;d++){let c=i,h=G(s,c);c+=4;let u=h&2147483647;if((h&2147483648)>>>31===1)return S.warn("SIDX has hierarchical references (not supported)"),null;let m=G(s,c);c+=4,e.push({referenceSize:u,subsegmentDuration:m,info:{duration:m/r,start:o,end:o+u-1}}),o+=u,c+=4,i=c;}return {earliestPresentationTime:n,timescale:r,version:t,referencesCount:l,references:e}}function zu(s){let e=[],t=j(s,["moov","trak"]);for(let r=0;r<t.length;r++){let n=t[r],a=j(n,["tkhd"])[0];if(a){let o=a[0],l=G(a,o===0?12:20),d=j(n,["mdia","mdhd"])[0];if(d){o=d[0];let c=G(d,o===0?12:20),h=j(n,["mdia","hdlr"])[0];if(h){let u=xe(h.subarray(8,12)),f={soun:ne.AUDIO,vide:ne.VIDEO}[u];if(f){let m=j(n,["mdia","minf","stbl","stsd"])[0],g=op(m);e[l]={timescale:c,type:f},e[f]=Oe({timescale:c,id:l},g);}}}}}return j(s,["moov","mvex","trex"]).forEach(r=>{let n=G(r,4),a=e[n];a&&(a.default={duration:G(r,12),flags:G(r,20)});}),e}function op(s){let e=s.subarray(8),t=e.subarray(86),i=xe(e.subarray(4,8)),r=i,n=i==="enca"||i==="encv";if(n){let o=j(e,[i])[0].subarray(i==="enca"?28:78);j(o,["sinf"]).forEach(d=>{let c=j(d,["schm"])[0];if(c){let h=xe(c.subarray(4,8));if(h==="cbcs"||h==="cenc"){let u=j(d,["frma"])[0];u&&(r=xe(u));}}});}switch(r){case "avc1":case "avc2":case "avc3":case "avc4":{let a=j(t,["avcC"])[0];r+="."+pn(a[1])+pn(a[2])+pn(a[3]);break}case "mp4a":{let a=j(e,[i])[0],o=j(a.subarray(28),["esds"])[0];if(o&&o.length>12){let l=4;if(o[l++]!==3)break;l=zo(o,l),l+=2;let d=o[l++];if(d&128&&(l+=2),d&64&&(l+=o[l++]),o[l++]!==4)break;l=zo(o,l);let c=o[l++];if(c===64)r+="."+pn(c);else break;if(l+=12,o[l++]!==5)break;l=zo(o,l);let h=o[l++],u=(h&248)>>3;u===31&&(u+=1+((h&7)<<3)+((o[l]&224)>>5)),r+="."+u;}break}case "hvc1":case "hev1":{let a=j(t,["hvcC"])[0],o=a[1],l=["","A","B","C"][o>>6],d=o&31,c=G(a,2),h=(o&32)>>5?"H":"L",u=a[12],f=a.subarray(6,12);r+="."+l+d,r+="."+c.toString(16).toUpperCase(),r+="."+h+u;let m="";for(let g=f.length;g--;){let E=f[g];(E||m)&&(m="."+E.toString(16).toUpperCase()+m);}r+=m;break}case "dvh1":case "dvhe":{let a=j(t,["dvcC"])[0],o=a[2]>>1&127,l=a[2]<<5&32|a[3]>>3&31;r+="."+Mt(o)+"."+Mt(l);break}case "vp09":{let a=j(t,["vpcC"])[0],o=a[4],l=a[5],d=a[6]>>4&15;r+="."+Mt(o)+"."+Mt(l)+"."+Mt(d);break}case "av01":{let a=j(t,["av1C"])[0],o=a[1]>>>5,l=a[1]&31,d=a[2]>>>7?"H":"M",c=(a[2]&64)>>6,h=(a[2]&32)>>5,u=o===2&&c?h?12:10:c?10:8,f=(a[2]&16)>>4,m=(a[2]&8)>>3,g=(a[2]&4)>>2,E=a[2]&3;r+="."+o+"."+Mt(l)+d+"."+Mt(u)+"."+f+"."+m+g+E+"."+Mt(1)+"."+Mt(1)+"."+Mt(1)+"."+0;break}}return {codec:r,encrypted:n}}function zo(s,e){let t=e+5;for(;s[e++]&128&&e<t;);return e}function pn(s){return ("0"+s.toString(16).toUpperCase()).slice(-2)}function Mt(s){return (s<10?"0":"")+s}function lp(s,e){if(!s||!e)return s;let t=e.keyId;return t&&e.isCommonEncryption&&j(s,["moov","trak"]).forEach(r=>{let a=j(r,["mdia","minf","stbl","stsd"])[0].subarray(8),o=j(a,["enca"]),l=o.length>0;l||(o=j(a,["encv"])),o.forEach(d=>{let c=l?d.subarray(28):d.subarray(78);j(c,["sinf"]).forEach(u=>{let f=Xu(u);if(f){let m=f.subarray(8,24);m.some(g=>g!==0)||(S.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Pt.hexDump(m)} -> ${Pt.hexDump(t)}`),f.set(t,8));}});});}),s}function Xu(s){let e=j(s,["schm"])[0];if(e){let t=xe(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return j(s,["schi","tenc"])[0]}return null}function dp(s,e){return j(e,["moof","traf"]).reduce((t,i)=>{let r=j(i,["tfdt"])[0],n=r[0],a=j(i,["tfhd"]).reduce((o,l)=>{let d=G(l,4),c=s[d];if(c){let h=G(r,4);if(n===1){if(h===On)return S.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;h*=On+1,h+=G(r,8);}let u=c.timescale||9e4,f=h/u;if(F(f)&&(o===null||f<o))return f}return o},null);return a!==null&&F(a)&&(t===null||a<t)?a:t},null)}function cp(s,e){let t=0,i=0,r=0,n=j(s,["moof","traf"]);for(let a=0;a<n.length;a++){let o=n[a],l=j(o,["tfhd"])[0],d=G(l,4),c=e[d];if(!c)continue;let h=c.default,u=G(l,0)|h?.flags,f=h?.duration;u&8&&(u&2?f=G(l,12):f=G(l,8));let m=c.timescale||9e4,g=j(o,["trun"]);for(let E=0;E<g.length;E++){if(t=hp(g[E]),!t&&f){let v=G(g[E],4);t=f*v;}c.type===ne.VIDEO?i+=t/m:c.type===ne.AUDIO&&(r+=t/m);}}if(i===0&&r===0){let a=1/0,o=0,l=0,d=j(s,["sidx"]);for(let c=0;c<d.length;c++){let h=ap(d[c]);if(h!=null&&h.references){a=Math.min(a,h.earliestPresentationTime/h.timescale);let u=h.references.reduce((f,m)=>f+m.info.duration||0,0);o=Math.max(o,u+h.earliestPresentationTime/h.timescale),l=o-a;}}if(l&&F(l))return l}return i||r}function hp(s){let e=G(s,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let i=0,r=G(s,4);for(let n=0;n<r;n++){if(e&256){let a=G(s,t);i+=a,t+=4;}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4);}return i}function up(s,e,t){j(e,["moof","traf"]).forEach(i=>{j(i,["tfhd"]).forEach(r=>{let n=G(r,4),a=s[n];if(!a)return;let o=a.timescale||9e4;j(i,["tfdt"]).forEach(l=>{let d=l[0],c=t*o;if(c){let h=G(l,4);if(d===0)h-=c,h=Math.max(h,0),qo(l,4,h);else {h*=Math.pow(2,32),h+=G(l,8),h-=c,h=Math.max(h,0);let u=Math.floor(h/(On+1)),f=Math.floor(h%(On+1));qo(l,4,u),qo(l,8,f);}}});});});}function fp(s){let e={valid:null,remainder:null},t=j(s,["moof"]);if(t.length<2)return e.remainder=s,e;let i=t[t.length-1];return e.valid=vi(s,0,i.byteOffset-8),e.remainder=vi(s,i.byteOffset-8),e}function st(s,e){let t=new Uint8Array(s.length+e.length);return t.set(s),t.set(e,s.length),t}function Qh(s,e){let t=[],i=e.samples,r=e.timescale,n=e.id,a=false;return j(i,["moof"]).map(l=>{let d=l.byteOffset-8;j(l,["traf"]).map(h=>{let u=j(h,["tfdt"]).map(f=>{let m=f[0],g=G(f,4);return m===1&&(g*=Math.pow(2,32),g+=G(f,8)),g/r})[0];return u!==void 0&&(s=u),j(h,["tfhd"]).map(f=>{let m=G(f,4),g=G(f,0)&16777215,E=(g&1)!==0,v=(g&2)!==0,A=(g&8)!==0,b=0,L=(g&16)!==0,y=0,D=(g&32)!==0,I=8;m===n&&(E&&(I+=8),v&&(I+=4),A&&(b=G(f,I),I+=4),L&&(y=G(f,I),I+=4),D&&(I+=4),e.type==="video"&&(a=mp(e.codec)),j(h,["trun"]).map(k=>{let P=k[0],R=G(k,0)&16777215,w=(R&1)!==0,X=0,O=(R&4)!==0,z=(R&256)!==0,q=0,V=(R&512)!==0,J=0,ae=(R&1024)!==0,U=(R&2048)!==0,N=0,ee=G(k,4),Q=8;w&&(X=G(k,Q),Q+=4),O&&(Q+=4);let se=X+d;for(let Se=0;Se<ee;Se++){if(z?(q=G(k,Q),Q+=4):q=b,V?(J=G(k,Q),Q+=4):J=y,ae&&(Q+=4),U&&(P===0?N=G(k,Q):N=qu(k,Q),Q+=4),e.type===ne.VIDEO){let Le=0;for(;Le<J;){let Ne=G(i,se);if(se+=4,gp(a,i[se])){let Je=i.subarray(se,se+Ne);ju(Je,a?2:1,s+N/r,t);}se+=Ne,Le+=Ne+4;}}s+=q/r;}}));})});}),t}function mp(s){if(!s)return false;let e=s.indexOf("."),t=e<0?s:s.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function gp(s,e){if(s){let t=e>>1&63;return t===39||t===40}else return (e&31)===6}function ju(s,e,t,i){let r=Qu(s),n=0;n+=e;let a=0,o=0,l=0;for(;n<r.length;){a=0;do{if(n>=r.length)break;l=r[n++],a+=l;}while(l===255);o=0;do{if(n>=r.length)break;l=r[n++],o+=l;}while(l===255);let d=r.length-n,c=n;if(o<d)n+=o;else if(o>d){S.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(r[c++]===181){let u=Yu(r,c);if(c+=2,u===49){let f=G(r,c);if(c+=4,f===1195456820){let m=r[c++];if(m===3){let g=r[c++],E=31&g,v=64&g,A=v?2+E*3:0,b=new Uint8Array(A);if(v){b[0]=g;for(let L=1;L<A;L++)b[L]=r[c++];}i.push({type:m,payloadType:a,pts:t,bytes:b});}}}}}else if(a===5&&o>16){let h=[];for(let m=0;m<16;m++){let g=r[c++].toString(16);h.push(g.length==1?"0"+g:g),(m===3||m===5||m===7||m===9)&&h.push("-");}let u=o-16,f=new Uint8Array(u);for(let m=0;m<u;m++)f[m]=r[c++];i.push({payloadType:a,pts:t,uuid:h.join(""),userData:Ft(f),userDataBytes:f});}}}function Qu(s){let e=s.byteLength,t=[],i=1;for(;i<e-2;)s[i]===0&&s[i+1]===0&&s[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return s;let r=e-t.length,n=new Uint8Array(r),a=0;for(i=0;i<r;a++,i++)a===t[0]&&(a++,t.shift()),n[i]=s[a];return n}function pp(s){let e=s[0],t="",i="",r=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;xe(s.subarray(d,d+1))!=="\0";)t+=xe(s.subarray(d,d+1)),d+=1;for(t+=xe(s.subarray(d,d+1)),d+=1;xe(s.subarray(d,d+1))!=="\0";)i+=xe(s.subarray(d,d+1)),d+=1;i+=xe(s.subarray(d,d+1)),d+=1,r=G(s,12),n=G(s,16),o=G(s,20),l=G(s,24),d=28;}else if(e===1){d+=4,r=G(s,d),d+=4;let h=G(s,d);d+=4;let u=G(s,d);for(d+=4,a=2**32*h+u,Ng(a)||(a=Number.MAX_SAFE_INTEGER,S.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=G(s,d),d+=4,l=G(s,d),d+=4;xe(s.subarray(d,d+1))!=="\0";)t+=xe(s.subarray(d,d+1)),d+=1;for(t+=xe(s.subarray(d,d+1)),d+=1;xe(s.subarray(d,d+1))!=="\0";)i+=xe(s.subarray(d,d+1)),d+=1;i+=xe(s.subarray(d,d+1)),d+=1;}let c=s.subarray(d,s.byteLength);return {schemeIdUri:t,value:i,timeScale:r,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:c}}function Ep(s,...e){let t=e.length,i=8,r=t;for(;r--;)i+=e[r].byteLength;let n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=i&255,n.set(s,4),r=0,i=8;r<t;r++)n.set(e[r],i),i+=e[r].byteLength;return n}function vp(s,e,t){if(s.byteLength!==16)throw new RangeError("Invalid system id");let i,r;i=0,r=new Uint8Array;let n;i>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,false)):n=new Uint8Array;let a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,false),Ep([112,115,115,104],new Uint8Array([i,0,0,0]),s,n,r,a,t||new Uint8Array)}function Tp(s){let e=[];if(s instanceof ArrayBuffer){let t=s.byteLength,i=0;for(;i+32<t;){let r=new DataView(s,i),n=Ap(r);e.push(n),i+=n.size;}}return e}function Ap(s){let e=s.getUint32(0),t=s.byteOffset,i=s.byteLength;if(i<e)return {offset:t,size:i};if(s.getUint32(4)!==1886614376)return {offset:t,size:e};let n=s.getUint32(8)>>>24;if(n!==0&&n!==1)return {offset:t,size:e};let a=s.buffer,o=Pt.hexDump(new Uint8Array(a,t+12,16)),l=s.getUint32(28),d=null,c=null;if(n===0){if(e-32<l||l<22)return {offset:t,size:e};c=new Uint8Array(a,t+32,l);}else if(n===1){if(!l||i<t+32+l*16+16)return {offset:t,size:e};d=[];for(let h=0;h<l;h++)d.push(new Uint8Array(a,t+32+h*16,16));}return {version:n,systemId:o,kids:d,data:c,offset:t,size:e}}var En={},Hs=class s{static clearKeyUriToKeyIdMap(){En={};}constructor(e,t,i,r=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=r,this.iv=n,this.encrypted=e?e!=="NONE":false,this.isCommonEncryption=this.encrypted&&e!=="AES-128";}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return true;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Xe.FAIRPLAY:case Xe.WIDEVINE:case Xe.PLAYREADY:case Xe.CLEARKEY:return ["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return false}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&S.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let i=bp(e);return new s(this.method,this.uri,"identity",this.keyFormatVersions,i)}let t=qg(this.uri);if(t)switch(this.keyFormat){case Xe.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Xe.PLAYREADY:{let i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=vp(i,null,t);let r=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),n=String.fromCharCode.apply(null,Array.from(r)),a=n.substring(n.indexOf("<"),n.length),d=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(d){let c=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(c){let h=Ad(c).subarray(0,16);Yg(h),this.keyId=h;}}break}default:{let i=t.subarray(0,16);if(i.length!==16){let r=new Uint8Array(16);r.set(i,16-i.length),i=r;}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=En[this.uri];if(!i){let r=Object.keys(En).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,r),En[this.uri]=i;}this.keyId=i;}return this}};function bp(s){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=s>>8*(15-t)&255;return e}var Zu=/\{\$([a-zA-Z0-9-_]+)\}/g;function Zh(s){return Zu.test(s)}function qe(s,e,t){if(s.variableList!==null||s.hasVariableRefs)for(let i=t.length;i--;){let r=t[i],n=e[r];n&&(e[r]=ml(s,n));}}function ml(s,e){if(s.variableList!==null||s.hasVariableRefs){let t=s.variableList;return e.replace(Zu,i=>{let r=i.substring(2,i.length-1),n=t?.[r];return n===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),i):n})}return e}function Jh(s,e,t){let i=s.variableList;i||(s.variableList=i={});let r,n;if("QUERYPARAM"in e){r=e.QUERYPARAM;try{let a=new self.URL(t).searchParams;if(a.has(r))n=a.get(r);else throw new Error(`"${r}" does not match any query parameter in URI: "${t}"`)}catch(a){s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`));}}else r=e.NAME,n=e.VALUE;r in i?s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):i[r]=n||"";}function yp(s,e,t){let i=e.IMPORT;if(t&&i in t){let r=s.variableList;r||(s.variableList=r={}),r[i]=t[i];}else s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`));}function Ti(s=true){return typeof self>"u"?void 0:(s||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function Sp(s){return typeof self<"u"&&s===self.ManagedMediaSource}var Nn={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function _p(s,e){let t=Nn[e];return !!t&&!!t[s.slice(0,4)]}function Xo(s,e,t=true){return !s.split(",").some(i=>!Ju(i,e,t))}function Ju(s,e,t=true){var i;let r=Ti(t);return (i=r?.isTypeSupported(Vs(s,e)))!=null?i:false}function Vs(s,e){return `${e}/mp4;codecs="${s}"`}function eu(s){if(s){let e=s.substring(0,4);return Nn.video[e]}return 2}function Fn(s){return s.split(",").reduce((e,t)=>{let i=Nn.video[t];return i?(i*2+e)/(e?3:2):(Nn.audio[t]+e)/(e?2:1)},0)}var jo={};function xp(s,e=true){if(jo[s])return jo[s];let t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[s];for(let i=0;i<t.length;i++)if(Ju(t[i],"audio",e))return jo[s]=t[i],t[i];return s}var Ip=/flac|opus/i;function Un(s,e=true){return s.replace(Ip,t=>xp(t.toLowerCase(),e))}function tu(s,e){return s&&s!=="mp4a"?s:e&&e.split(",")[0]}function Lp(s){let e=s.split(",");for(let t=0;t<e.length;t++){let i=e[t].split(".");if(i.length>2){let r=i.shift()+".";r+=parseInt(i.shift()).toString(16),r+=("000"+parseInt(i.shift()).toString(16)).slice(-4),e[t]=r;}}return e.join(",")}var iu=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,su=/#EXT-X-MEDIA:(.*)/g,Rp=/^#EXT(?:INF|-X-TARGETDURATION):/m,ru=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Dp=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),pi=class s{static findGroup(e,t){for(let i=0;i<e.length;i++){let r=e[i];if(r.id===t)return r}}static resolve(e,t){return Td.buildAbsoluteURL(t,e,{alwaysNormalize:true})}static isMediaPlaylist(e){return Rp.test(e)}static parseMasterPlaylist(e,t){let i=Zh(e),r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];iu.lastIndex=0;let a;for(;(a=iu.exec(e))!=null;)if(a[1]){var o;let d=new Ee(a[1]);qe(r,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let c=ml(r,a[2]),h={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:s.resolve(c,t)},u=d.decimalResolution("RESOLUTION");u&&(h.width=u.width,h.height=u.height),Cp(d.CODECS,h),(o=h.unknownCodecs)!=null&&o.length||n.push(h),r.levels.push(h);}else if(a[3]){let d=a[3],c=a[4];switch(d){case "SESSION-DATA":{let h=new Ee(c);qe(r,h,["DATA-ID","LANGUAGE","VALUE","URI"]);let u=h["DATA-ID"];u&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[u]=h);break}case "SESSION-KEY":{let h=nu(c,t,r);h.encrypted&&h.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(h)):S.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${c}"`);break}case "DEFINE":{{let h=new Ee(c);qe(r,h,["NAME","VALUE","QUERYPARAM"]),Jh(r,h,t);}break}case "CONTENT-STEERING":{let h=new Ee(c);qe(r,h,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:s.resolve(h["SERVER-URI"],t),pathwayId:h["PATHWAY-ID"]||"."};break}case "START":{r.startTimeOffset=au(c);break}}}let l=n.length>0&&n.length<r.levels.length;return r.levels=l?n:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,i){let r,n={},a=i.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(su.lastIndex=0;(r=su.exec(e))!==null;){let d=new Ee(r[1]),c=d.TYPE;if(c){let h=o[c],u=n[c]||[];n[c]=u,qe(i,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);let f=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],g=d.CHANNELS,E=d.CHARACTERISTICS,v=d["INSTREAM-ID"],A={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||f||"",type:c,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:f,url:d.URI?s.resolve(d.URI,t):""};if(m&&(A.assocLang=m),g&&(A.channels=g),E&&(A.characteristics=E),v&&(A.instreamId=v),h!=null&&h.length){let b=s.findGroup(h,A.groupId)||h[0];ou(A,b,"audioCodec"),ou(A,b,"textCodec");}u.push(A);}}return n}static parseLevelPlaylist(e,t,i,r,n,a){let o=new ul(t),l=o.fragments,d=null,c=0,h=0,u=0,f=0,m=null,g=new Bs(r,t),E,v,A,b=-1,L=false,y=null;for(ru.lastIndex=0,o.m3u8=e,o.hasVariableRefs=Zh(e);(E=ru.exec(e))!==null;){L&&(L=false,g=new Bs(r,t),g.start=u,g.sn=c,g.cc=f,g.level=i,d&&(g.initSegment=d,g.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,y&&(g.setByteRange(y),y=null)));let P=E[1];if(P){g.duration=parseFloat(P);let R=(" "+E[2]).slice(1);g.title=R||null,g.tagList.push(R?["INF",P,R]:["INF",P]);}else if(E[3]){if(F(g.duration)){g.start=u,A&&cu(g,A,o),g.sn=c,g.level=i,g.cc=f,l.push(g);let R=(" "+E[3]).slice(1);g.relurl=ml(o,R),lu(g,m),m=g,u+=g.duration,c++,h=0,L=true;}}else if(E[4]){let R=(" "+E[4]).slice(1);m?g.setByteRange(R,m):g.setByteRange(R);}else if(E[5])g.rawProgramDateTime=(" "+E[5]).slice(1),g.tagList.push(["PROGRAM-DATE-TIME",g.rawProgramDateTime]),b===-1&&(b=l.length);else {if(E=E[0].match(Dp),!E){S.warn("No matches on slow regex match for level playlist!");continue}for(v=1;v<E.length&&!(typeof E[v]<"u");v++);let R=(" "+E[v]).slice(1),w=(" "+E[v+1]).slice(1),X=E[v+2]?(" "+E[v+2]).slice(1):"";switch(R){case "PLAYLIST-TYPE":o.type=w.toUpperCase();break;case "MEDIA-SEQUENCE":c=o.startSN=parseInt(w);break;case "SKIP":{let O=new Ee(w);qe(o,O,["RECENTLY-REMOVED-DATERANGES"]);let z=O.decimalInteger("SKIPPED-SEGMENTS");if(F(z)){o.skippedSegments=z;for(let V=z;V--;)l.unshift(null);c+=z;}let q=O.enumeratedString("RECENTLY-REMOVED-DATERANGES");q&&(o.recentlyRemovedDateranges=q.split(" "));break}case "TARGETDURATION":o.targetduration=Math.max(parseInt(w),1);break;case "VERSION":o.version=parseInt(w);break;case "INDEPENDENT-SEGMENTS":case "EXTM3U":break;case "ENDLIST":o.live=false;break;case "#":(w||X)&&g.tagList.push(X?[w,X]:[w]);break;case "DISCONTINUITY":f++,g.tagList.push(["DIS"]);break;case "GAP":g.gap=true,g.tagList.push([R]);break;case "BITRATE":g.tagList.push([R,w]);break;case "DATERANGE":{let O=new Ee(w);qe(o,O,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),qe(o,O,O.clientAttrs);let z=new Mn(O,o.dateRanges[O.ID]);z.isValid||o.skippedSegments?o.dateRanges[z.id]=z:S.warn(`Ignoring invalid DATERANGE tag: "${w}"`),g.tagList.push(["EXT-X-DATERANGE",w]);break}case "DEFINE":{{let O=new Ee(w);qe(o,O,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in O?yp(o,O,a):Jh(o,O,t);}break}case "DISCONTINUITY-SEQUENCE":f=parseInt(w);break;case "KEY":{let O=nu(w,t,o);if(O.isSupported()){if(O.method==="NONE"){A=void 0;break}A||(A={}),A[O.keyFormat]&&(A=_e({},A)),A[O.keyFormat]=O;}else S.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${w}"`);break}case "START":o.startTimeOffset=au(w);break;case "MAP":{let O=new Ee(w);if(qe(o,O,["BYTERANGE","URI"]),g.duration){let z=new Bs(r,t);du(z,O,i,A),d=z,g.initSegment=d,d.rawProgramDateTime&&!g.rawProgramDateTime&&(g.rawProgramDateTime=d.rawProgramDateTime);}else {let z=g.byteRangeEndOffset;if(z){let q=g.byteRangeStartOffset;y=`${z-q}@${q}`;}else y=null;du(g,O,i,A),d=g,L=true;}break}case "SERVER-CONTROL":{let O=new Ee(w);o.canBlockReload=O.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=O.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&O.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=O.optionalFloat("PART-HOLD-BACK",0),o.holdBack=O.optionalFloat("HOLD-BACK",0);break}case "PART-INF":{let O=new Ee(w);o.partTarget=O.decimalFloatingPoint("PART-TARGET");break}case "PART":{let O=o.partList;O||(O=o.partList=[]);let z=h>0?O[O.length-1]:void 0,q=h++,V=new Ee(w);qe(o,V,["BYTERANGE","URI"]);let J=new hl(V,g,t,q,z);O.push(J),g.duration+=J.duration;break}case "PRELOAD-HINT":{let O=new Ee(w);qe(o,O,["URI"]),o.preloadHint=O;break}case "RENDITION-REPORT":{let O=new Ee(w);qe(o,O,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(O);break}default:S.warn(`line parsed but not handled: ${E}`);break}}}m&&!m.relurl?(l.pop(),u-=m.duration,o.partList&&(o.fragmentHint=m)):o.partList&&(lu(g,m),g.cc=f,o.fragmentHint=g,A&&cu(g,A,o));let D=l.length,I=l[0],k=l[D-1];if(u+=o.skippedSegments*o.targetduration,u>0&&D&&k){o.averagetargetduration=u/D;let P=k.sn;o.endSN=P!=="initSegment"?P:0,o.live||(k.endList=true),I&&(o.startCC=I.cc);}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(u+=o.fragmentHint.duration),o.totalduration=u,o.endCC=f,b>0&&kp(l,b),o}};function nu(s,e,t){var i,r;let n=new Ee(s);qe(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let a=(i=n.METHOD)!=null?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,c=(r=n.KEYFORMAT)!=null?r:"identity";o&&n.IV&&!l&&S.error(`Invalid IV: ${n.IV}`);let h=o?pi.resolve(o,e):"",u=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Hs(a,h,c,u,l)}function au(s){let t=new Ee(s).decimalFloatingPoint("TIME-OFFSET");return F(t)?t:null}function Cp(s,e){let t=(s||"").split(/[ ,]+/).filter(i=>i);["video","audio","text"].forEach(i=>{let r=t.filter(n=>_p(n,i));r.length&&(e[`${i}Codec`]=r.join(","),t=t.filter(n=>r.indexOf(n)===-1));}),e.unknownCodecs=t;}function ou(s,e,t){let i=e[t];i&&(s[t]=i);}function kp(s,e){let t=s[e];for(let i=e;i--;){let r=s[i];if(!r)return;r.programDateTime=t.programDateTime-r.duration*1e3,t=r;}}function lu(s,e){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):e!=null&&e.programDateTime&&(s.programDateTime=e.endProgramDateTime),F(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null);}function du(s,e,t,i){s.relurl=e.URI,e.BYTERANGE&&s.setByteRange(e.BYTERANGE),s.level=t,s.sn="initSegment",i&&(s.levelkeys=i),s.initSegment=null;}function cu(s,e,t){s.levelkeys=e;let{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(r=>e[r].isCommonEncryption)&&i.push(s);}var Z={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},H={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function hu(s){let{type:e}=s;switch(e){case Z.AUDIO_TRACK:return H.AUDIO;case Z.SUBTITLE_TRACK:return H.SUBTITLE;default:return H.MAIN}}function Qo(s,e){let t=s.url;return (t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var gl=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners();}startLoad(e){}stopLoad(){this.destroyInternalLoaders();}registerListeners(){let{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(p.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this);}unregisterListeners(){let{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(p.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,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:Z.MANIFEST,url:i,deliveryDirectives:null});}onLevelLoading(e,t){let{id:i,level:r,pathwayId:n,url:a,deliveryDirectives:o}=t;this.load({id:i,level:r,pathwayId:n,responseType:"text",type:Z.LEVEL,url:a,deliveryDirectives:o});}onAudioTrackLoading(e,t){let{id:i,groupId:r,url:n,deliveryDirectives:a}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:Z.AUDIO_TRACK,url:n,deliveryDirectives:a});}onSubtitleTrackLoading(e,t){let{id:i,groupId:r,url:n,deliveryDirectives:a}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:Z.SUBTITLE_TRACK,url:n,deliveryDirectives:a});}load(e){var t;let i=this.hls.config,r=this.getInternalLoader(e);if(r){let d=r.context;if(d&&d.url===e.url&&d.level===e.level){S.trace("[playlist-loader]: playlist request ongoing");return}S.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort();}let n;if(e.type===Z.MANIFEST?n=i.manifestLoadPolicy.default:n=_e({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),F((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===Z.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Z.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Z.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){let c=d.partTarget,h=d.targetduration;if(c&&h){let u=Math.max(c*3,h*.8)*1e3;n=_e({},n,{maxTimeToFirstByteMs:Math.min(u,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(u,n.maxTimeToFirstByteMs)});}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,c,h,u)=>{let f=this.getInternalLoader(h);this.resetInternalLoader(h.type);let m=d.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,h,new Error("no EXTM3U delimiter"),u||null,c);return}c.parsing.start=performance.now(),pi.isMediaPlaylist(m)?this.handleTrackOrLevelPlaylist(d,c,h,u||null,f):this.handleMasterPlaylist(d,c,h,u);},onError:(d,c,h,u)=>{this.handleNetworkError(c,h,false,d,u);},onTimeout:(d,c,h)=>{this.handleNetworkError(c,h,true,void 0,d);}};r.load(e,o,l);}handleMasterPlaylist(e,t,i,r){let n=this.hls,a=e.data,o=Qo(e,i),l=pi.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,i,l.playlistParsingError,r,t);return}let{contentSteering:d,levels:c,sessionData:h,sessionKeys:u,startTimeOffset:f,variableList:m}=l;this.variableList=m;let{AUDIO:g=[],SUBTITLES:E,"CLOSED-CAPTIONS":v}=pi.parseMasterPlaylistMedia(a,o,l);g.length&&!g.some(b=>!b.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(S.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:false,autoselect:false,forced:false,id:-1,attrs:new Ee({}),bitrate:0,url:""})),n.trigger(p.MANIFEST_LOADED,{levels:c,audioTracks:g,subtitles:E,captions:v,contentSteering:d,url:o,stats:t,networkDetails:r,sessionData:h,sessionKeys:u,startTimeOffset:f,variableList:m});}handleTrackOrLevelPlaylist(e,t,i,r,n){let a=this.hls,{id:o,level:l,type:d}=i,c=Qo(e,i),h=0,u=F(l)?l:F(o)?o:0,f=hu(i),m=pi.parseLevelPlaylist(e.data,c,u,f,h,this.variableList);if(d===Z.MANIFEST){let g={attrs:new Ee({}),bitrate:0,details:m,name:"",url:c};a.trigger(p.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:c,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null});}t.parsing.end=performance.now(),i.levelDetails=m,this.handlePlaylistLoaded(m,e,t,i,r,n);}handleManifestParsingError(e,t,i,r,n){this.hls.trigger(p.ERROR,{type:K.NETWORK_ERROR,details:x.MANIFEST_PARSING_ERROR,fatal:t.type===Z.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===Z.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Z.AUDIO_TRACK||e.type===Z.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);S.warn(`[playlist-loader]: ${a}`);let l=x.UNKNOWN,d=false,c=this.getInternalLoader(e);switch(e.type){case Z.MANIFEST:l=i?x.MANIFEST_LOAD_TIMEOUT:x.MANIFEST_LOAD_ERROR,d=true;break;case Z.LEVEL:l=i?x.LEVEL_LOAD_TIMEOUT:x.LEVEL_LOAD_ERROR,d=false;break;case Z.AUDIO_TRACK:l=i?x.AUDIO_TRACK_LOAD_TIMEOUT:x.AUDIO_TRACK_LOAD_ERROR,d=false;break;case Z.SUBTITLE_TRACK:l=i?x.SUBTITLE_TRACK_LOAD_TIMEOUT:x.SUBTITLE_LOAD_ERROR,d=false;break}c&&this.resetInternalLoader(e.type);let h={type:K.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(r){let u=t?.url||e.url;h.response=Oe({url:u,data:void 0},r);}this.hls.trigger(p.ERROR,h);}handlePlaylistLoaded(e,t,i,r,n,a){let o=this.hls,{type:l,level:d,id:c,groupId:h,deliveryDirectives:u}=r,f=Qo(t,r),m=hu(r),g=typeof r.level=="number"&&m===H.MAIN?d:void 0;if(!e.fragments.length){let v=new Error("No Segments found in Playlist");o.trigger(p.ERROR,{type:K.NETWORK_ERROR,details:x.LEVEL_EMPTY_ERROR,fatal:false,url:f,error:v,reason:v.message,response:t,context:r,level:g,parent:m,networkDetails:n,stats:i});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let E=e.playlistParsingError;if(E){o.trigger(p.ERROR,{type:K.NETWORK_ERROR,details:x.LEVEL_PARSING_ERROR,fatal:false,url:f,error:E,reason:E.message,response:t,context:r,level:g,parent:m,networkDetails:n,stats:i});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case Z.MANIFEST:case Z.LEVEL:o.trigger(p.LEVEL_LOADED,{details:e,level:g||0,id:c||0,stats:i,networkDetails:n,deliveryDirectives:u});break;case Z.AUDIO_TRACK:o.trigger(p.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:u});break;case Z.SUBTITLE_TRACK:o.trigger(p.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:u});break}}};function ef(s,e){let t;try{t=new Event("addtrack");}catch{t=document.createEvent("Event"),t.initEvent("addtrack",false,false);}t.track=s,e.dispatchEvent(t);}function tf(s,e){let t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(e.id))try{if(s.addCue(e),!s.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){S.debug(`[texttrack-utils]: ${i}`);try{let r=new self.TextTrackCue(e.startTime,e.endTime,e.text);r.id=e.id,s.addCue(r);}catch(r){S.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${r}`);}}t==="disabled"&&(s.mode=t);}function Qi(s){let e=s.mode;if(e==="disabled"&&(s.mode="hidden"),s.cues)for(let t=s.cues.length;t--;)s.removeCue(s.cues[t]);e==="disabled"&&(s.mode=e);}function pl(s,e,t,i){let r=s.mode;if(r==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){let n=Mp(s.cues,e,t);for(let a=0;a<n.length;a++)(!i||i(n[a]))&&s.removeCue(n[a]);}r==="disabled"&&(s.mode=r);}function wp(s,e){if(e<s[0].startTime)return 0;let t=s.length-1;if(e>s[t].endTime)return -1;let i=0,r=t;for(;i<=r;){let n=Math.floor((r+i)/2);if(e<s[n].startTime)r=n-1;else if(e>s[n].startTime&&i<t)i=n+1;else return n}return s[i].startTime-e<e-s[r].startTime?i:r}function Mp(s,e,t){let i=[],r=wp(s,e);if(r>-1)for(let n=r,a=s.length;n<a;n++){let o=s[n];if(o.startTime>=e&&o.endTime<=t)i.push(o);else if(o.startTime>t)return i}return i}function In(s){let e=[];for(let t=0;t<s.length;t++){let i=s[t];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&e.push(s[t]);}return e}var gt={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},Pp=.25;function El(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function uu(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,JSON.stringify(r?Oe({type:r},i):i));}return n}var vn=(()=>{let s=El();try{s&&new s(0,Number.POSITIVE_INFINITY,"");}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Zo(s,e){return s.getTime()/1e3-e}function Op(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var vl=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners();}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null;}_registerListeners(){let{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this);}_unregisterListeners(){let{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this);}onMediaAttached(e,t){this.media=t.media;}onMediaDetaching(){this.id3Track&&(Qi(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={});}onManifestLoading(){this.dateRangeCuesAppended={};}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let i=e[t];if(i.kind==="metadata"&&i.label==="id3")return ef(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=El();if(a)for(let o=0;o<n.length;o++){let l=n[o].type;if(l===gt.emsg&&!i||!r)continue;let d=Ku(n[o].data);if(d){let c=n[o].pts,h=c+n[o].duration;h>vn&&(h=vn),h-c<=0&&(h=c+Pp);for(let f=0;f<d.length;f++){let m=d[f];if(!Vu(m)){this.updateId3CueEnds(c,l);let g=uu(a,c,h,m,l);g&&this.id3Track.addCue(g);}}}}}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===vn&&(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:l}}=a;if(n&&(o||l)){let d;r==="audio"?d=c=>c.type===gt.audioId3&&l:r==="video"?d=c=>c.type===gt.emsg&&o:d=c=>c.type===gt.audioId3&&l||c.type===gt.emsg&&o,pl(n,t,i,d);}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:i,id3Track:r}=this,{dateRanges:n}=t,a=Object.keys(n);if(r){let c=Object.keys(i).filter(h=>!a.includes(h));for(let h=c.length;h--;){let u=c[h];Object.keys(i[u].cues).forEach(f=>{r.removeCue(i[u].cues[f]);}),delete i[u];}}let o=t.fragments[t.fragments.length-1];if(a.length===0||!F(o?.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));let l=o.programDateTime/1e3-o.start,d=El();for(let c=0;c<a.length;c++){let h=a[c],u=n[h],f=Zo(u.startDate,l),m=i[h],g=m?.cues||{},E=m?.durationKnown||false,v=vn,A=u.endDate;if(A)v=Zo(A,l),E=true;else if(u.endOnNext&&!E){let L=a.reduce((y,D)=>{if(D!==u.id){let I=n[D];if(I.class===u.class&&I.startDate>u.startDate&&(!y||u.startDate<y.startDate))return I}return y},null);L&&(v=Zo(L.startDate,l),E=true);}let b=Object.keys(u.attr);for(let L=0;L<b.length;L++){let y=b[L];if(!Hg(y))continue;let D=g[y];if(D)E&&!m.durationKnown&&(D.endTime=v);else if(d){let I=u.attr[y];Vg(y)&&(I=Op(I));let k=uu(d,f,v,{key:y,data:I},gt.dateRange);k&&(k.id=h,this.id3Track.addCue(k),g[y]=k);}}i[h]={cues:g,dateRange:u,durationKnown:E};}}},Tl=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners();}get latency(){return this._latency||0}get maxLatency(){let{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let{levelDetails:e}=this;if(e===null)return null;let{holdBack:t,partHoldBack:i,targetduration:r}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig,d=o&&i||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*r);let c=r;return d+Math.min(this.stallCount*1,c)}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency,i=this.levelDetails;if(e===null||t===null||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{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){let{levelDetails:e}=this;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e,levelDetails:t}=this;if(!e||!t)return 0;let i=e.buffered.length;return (i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null;}registerListeners(){this.hls.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(p.ERROR,this.onError,this);}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(p.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(p.ERROR,this.onError,this);}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler);}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null);}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0;}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler);}onError(e,t){var i;t.details===x.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&S.warn("[playback-rate-controller]: Stall detected, adjusting target latency"));}timeupdate(){let{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;let i=this.computeLatency();if(i===null)return;this._latency=i;let{lowLatencyMode:r,maxLiveSyncPlaybackRate:n}=this.config;if(!r||n===1||!t.live)return;let a=this.targetLatency;if(a===null)return;let o=i-a,l=Math.min(this.maxLatency,a+t.targetduration);if(o<l&&o>.05&&this.forwardBufferLength>1){let c=Math.min(2,Math.max(1,n)),h=Math.round(2/(1+Math.exp(-0.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,h));}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1);}estimateLiveEdge(){let{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},Al=["NONE","TYPE-0","TYPE-1",null];function Np(s){return Al.indexOf(s)>-1}var Bn=["SDR","PQ","HLG"];function Fp(s){return !!s&&Bn.indexOf(s)>-1}var Ln={No:"",Yes:"YES",v2:"v2"};function fu(s){let{canSkipUntil:e,canSkipDateRanges:t,age:i}=s,r=i<e/2;return e&&r?t?Ln.v2:Ln.Yes:Ln.No}var $n=class{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i;}addDirectives(e){let t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}},Jt=class{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>!!t).map(t=>t.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES);}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return mu(this._audioGroups,e)}hasSubtitleGroup(e){return mu(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let i=this._audioGroups;i||(i=this._audioGroups=[]),i.indexOf(t)===-1&&i.push(t);}else if(e==="text"){let i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(t)===-1&&i.push(t);}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return (e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return (e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}};function mu(s,e){return !e||!s?false:s.indexOf(e)!==-1}function Jo(s,e){let t=e.startPTS;if(F(t)){let i=0,r;e.sn>s.sn?(i=t-s.start,r=s):(i=s.start-t,r=e),r.duration!==i&&(r.duration=i);}else e.sn>s.sn?s.cc===e.cc&&s.minEndPTS?e.start=s.start+(s.minEndPTS-s.start):e.start=s.start+s.duration:e.start=Math.max(s.start-e.duration,0);}function sf(s,e,t,i,r,n){i-t<=0&&(S.warn("Fragment should have a positive duration",e),i=t+e.duration,n=r+e.duration);let o=t,l=i,d=e.startPTS,c=e.endPTS;if(F(d)){let E=Math.abs(d-t);F(e.deltaPTS)?e.deltaPTS=Math.max(E,e.deltaPTS):e.deltaPTS=E,o=Math.max(t,d),t=Math.min(t,d),r=Math.min(r,e.startDTS),l=Math.min(i,c),i=Math.max(i,c),n=Math.max(n,e.endDTS);}let h=t-e.start;e.start!==0&&(e.start=t),e.duration=i-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=r,e.endPTS=i,e.minEndPTS=l,e.endDTS=n;let u=e.sn;if(!s||u<s.startSN||u>s.endSN)return 0;let f,m=u-s.startSN,g=s.fragments;for(g[m]=e,f=m;f>0;f--)Jo(g[f],g[f-1]);for(f=m;f<g.length-1;f++)Jo(g[f],g[f+1]);return s.fragmentHint&&Jo(g[g.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=true,h}function Up(s,e){let t=null,i=s.fragments;for(let l=i.length-1;l>=0;l--){let d=i[l].initSegment;if(d){t=d;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let r=0,n;if(Gp(s,e,(l,d)=>{l.relurl&&(r=l.cc-d.cc),F(l.startPTS)&&F(l.endPTS)&&(d.start=d.startPTS=l.startPTS,d.startDTS=l.startDTS,d.maxStartPTS=l.maxStartPTS,d.endPTS=l.endPTS,d.endDTS=l.endDTS,d.minEndPTS=l.minEndPTS,d.duration=l.endPTS-l.startPTS,d.duration&&(n=d),e.PTSKnown=e.alignedSliding=true),d.elementaryStreams=l.elementaryStreams,d.loader=l.loader,d.stats=l.stats,l.initSegment&&(d.initSegment=l.initSegment,t=l.initSegment);}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(d=>{var c;d&&(!d.initSegment||d.initSegment.relurl===((c=t)==null?void 0:c.relurl))&&(d.initSegment=t);}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){S.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc;}else e.canSkipDateRanges&&(e.dateRanges=Bp(s.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));let a=e.fragments;if(r){S.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=r;}e.skippedSegments&&(e.startCC=e.fragments[0].cc),$p(s.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats;}),n?sf(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):rf(s,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=s.driftStartTime,e.driftStart=s.driftStart;let o=e.advancedDateTime;if(e.advanced&&o){let l=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=l),e.driftEndTime=o,e.driftEnd=l;}else e.driftEndTime=s.driftEndTime,e.driftEnd=s.driftEnd,e.advancedDateTime=s.advancedDateTime;}function Bp(s,e,t){let i=_e({},s);return t&&t.forEach(r=>{delete i[r];}),Object.keys(e).forEach(r=>{let n=new Mn(e[r].attr,i[r]);n.isValid?i[r]=n:S.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[r].attr)}"`);}),i}function $p(s,e,t){if(s&&e){let i=0;for(let r=0,n=s.length;r<=n;r++){let a=s[r],o=e[r+i];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):i--;}}}function Gp(s,e,t){let i=e.skippedSegments,r=Math.max(s.startSN,e.startSN)-e.startSN,n=(s.fragmentHint?1:0)+(i?e.endSN:Math.min(s.endSN,e.endSN))-e.startSN,a=e.startSN-s.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments;for(let d=r;d<=n;d++){let c=l[a+d],h=o[d];i&&!h&&d<i&&(h=e.fragments[d]=c),c&&h&&t(c,h);}}function rf(s,e){let t=e.startSN+e.skippedSegments-s.startSN,i=s.fragments;t<0||t>=i.length||bl(e,i[t].start);}function bl(s,e){if(e){let t=s.fragments;for(let i=s.skippedSegments;i<t.length;i++)t[i].start+=e;s.fragmentHint&&(s.fragmentHint.start+=e);}}function Hp(s,e=1/0){let t=1e3*s.targetduration;if(s.updated){let i=s.fragments;if(i.length&&t*4>e){let n=i[i.length-1].duration*1e3;n<t&&(t=n);}}else t/=2;return Math.round(t)}function Vp(s,e,t){if(!(s!=null&&s.details))return null;let i=s.details,r=i.fragments[e-i.startSN];return r||(r=i.fragmentHint,r&&r.sn===e)?r:e<i.startSN&&t&&t.sn===e?t:null}function gu(s,e,t){var i;return s!=null&&s.details?nf((i=s.details)==null?void 0:i.partList,e,t):null}function nf(s,e,t){if(s)for(let i=s.length;i--;){let r=s[i];if(r.index===t&&r.fragment.sn===e)return r}return null}function af(s){s.forEach((e,t)=>{let{details:i}=e;i!=null&&i.fragments&&i.fragments.forEach(r=>{r.level=t;});});}function Gn(s){switch(s.details){case x.FRAG_LOAD_TIMEOUT:case x.KEY_LOAD_TIMEOUT:case x.LEVEL_LOAD_TIMEOUT:case x.MANIFEST_LOAD_TIMEOUT:return true}return false}function pu(s,e){let t=Gn(e);return s.default[`${t?"timeout":"error"}Retry`]}function Sd(s,e){let t=s.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*s.retryDelayMs,s.maxRetryDelayMs)}function Eu(s){return Oe(Oe({},s),{errorRetry:null,timeoutRetry:null})}function Hn(s,e,t,i){if(!s)return false;let r=i?.code,n=e<s.maxNumRetry&&(Kp(r)||!!t);return s.shouldRetry?s.shouldRetry(s,e,t,i,n):n}function Kp(s){return s===0&&navigator.onLine===false||!!s&&(s<400||s>499)}var of={search:function(s,e){let t=0,i=s.length-1,r=null,n=null;for(;t<=i;){r=(t+i)/2|0,n=s[r];let a=e(n);if(a>0)t=r+1;else if(a<0)i=r-1;else return n}return null}};function Wp(s,e,t){if(e===null||!Array.isArray(s)||!s.length||!F(e))return null;let i=s[0].programDateTime;if(e<(i||0))return null;let r=s[s.length-1].endProgramDateTime;if(e>=(r||0))return null;t=t||0;for(let n=0;n<s.length;++n){let a=s[n];if(qp(e,t,a))return a}return null}function Vn(s,e,t=0,i=0,r=.005){let n=null;if(s){n=e[s.sn-e[0].sn+1]||null;let o=s.endDTS-t;o>0&&o<15e-7&&(t+=15e-7);}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!s||s.level===n.level)&&yl(t,i,n)===0||Yp(n,s,Math.min(r,i))))return n;let a=of.search(e,yl.bind(null,t,i));return a&&(a!==s||!n)?a:n}function Yp(s,e,t){if(e&&e.start===0&&e.level<s.level&&(e.endPTS||0)>0){let i=e.tagList.reduce((r,n)=>(n[0]==="INF"&&(r+=parseFloat(n[1])),r),t);return s.start<=i}return false}function yl(s=0,e=0,t){if(t.start<=s&&t.start+t.duration>s)return 0;let i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=s?1:t.start-i>s&&t.start?-1:0}function qp(s,e,t){let i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return (t.endProgramDateTime||0)-i>s}function zp(s,e){return of.search(s,t=>t.cc<e?1:t.cc>e?-1:0)}var Me={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},ut={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2},Sl=class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=S.log.bind(S,"[info]:"),this.warn=S.warn.bind(S,"[warning]:"),this.error=S.error.bind(S,"[error]:"),this.registerListeners();}registerListeners(){let e=this.hls;e.on(p.ERROR,this.onError,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this);}unregisterListeners(){let e=this.hls;e&&(e.off(p.ERROR,this.onError,this),e.off(p.ERROR,this.onErrorOut,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this));}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={};}startLoad(e){}stopLoad(){this.playlistError=0;}getVariantLevelIndex(e){return e?.type===H.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={};}onLevelUpdated(){this.playlistError=0;}onError(e,t){var i,r;if(t.fatal)return;let n=this.hls,a=t.context;switch(t.details){case x.FRAG_LOAD_ERROR:case x.FRAG_LOAD_TIMEOUT:case x.KEY_LOAD_ERROR:case x.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case x.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction={action:Me.DoNothing,flags:ut.None};return}case x.FRAG_GAP:case x.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Me.SendAlternateToPenaltyBox;return}case x.LEVEL_EMPTY_ERROR:case x.LEVEL_PARSING_ERROR:{var o,l;let d=t.parent===H.MAIN?t.level:n.loadLevel;t.details===x.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=false,t.errorAction=this.getLevelSwitchAction(t,d));}return;case x.LEVEL_LOAD_ERROR:case x.LEVEL_LOAD_TIMEOUT:typeof a?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case x.AUDIO_TRACK_LOAD_ERROR:case x.AUDIO_TRACK_LOAD_TIMEOUT:case x.SUBTITLE_LOAD_ERROR:case x.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){let d=n.levels[n.loadLevel];if(d&&(a.type===Z.AUDIO_TRACK&&d.hasAudioGroup(a.groupId)||a.type===Z.SUBTITLE_TRACK&&d.hasSubtitleGroup(a.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=Me.SendAlternateToPenaltyBox,t.errorAction.flags=ut.MoveAllAlternatesMatchingHost;return}}return;case x.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let d=n.levels[n.loadLevel],c=d?.attrs["HDCP-LEVEL"];c?t.errorAction={action:Me.SendAlternateToPenaltyBox,flags:ut.MoveAllAlternatesMatchingHDCP,hdcpLevel:c}:this.keySystemError(t);}return;case x.BUFFER_ADD_CODEC_ERROR:case x.REMUX_ALLOC_ERROR:case x.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(r=t.level)!=null?r:n.loadLevel);return;case x.INTERNAL_EXCEPTION:case x.BUFFER_APPENDING_ERROR:case x.BUFFER_FULL_ERROR:case x.LEVEL_SWITCH_ERROR:case x.BUFFER_STALLED_ERROR:case x.BUFFER_SEEK_OVER_HOLE:case x.BUFFER_NUDGE_ON_STALL:t.errorAction={action:Me.DoNothing,flags:ut.None};return}t.type===K.KEY_SYSTEM_ERROR&&this.keySystemError(t);}keySystemError(e){let t=this.getVariantLevelIndex(e.frag);e.levelRetry=false,e.errorAction=this.getLevelSwitchAction(e,t);}getPlaylistRetryOrSwitchAction(e,t){let i=this.hls,r=pu(i.config.playlistLoadPolicy,e),n=this.playlistError++;if(Hn(r,n,Gn(e),e.response))return {action:Me.RetryRequest,flags:ut.None,retryConfig:r,retryCount:n};let o=this.getLevelSwitchAction(e,t);return r&&(o.retryConfig=r,o.retryCount=n),o}getFragRetryOrSwitchAction(e){let t=this.hls,i=this.getVariantLevelIndex(e.frag),r=t.levels[i],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=pu(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((c,h)=>c+h.fragmentError,0);if(r&&(e.details!==x.FRAG_GAP&&r.fragmentError++,Hn(o,l,Gn(e),e.response)))return {action:Me.RetryRequest,flags:ut.None,retryConfig:o,retryCount:l};let d=this.getLevelSwitchAction(e,i);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(e,t){let i=this.hls;t==null&&(t=i.loadLevel);let r=this.hls.levels[t];if(r){var n,a;let d=e.details;r.loadError++,d===x.BUFFER_APPEND_ERROR&&r.fragmentError++;let c=-1,{levels:h,loadLevel:u,minAutoLevel:f,maxAutoLevel:m}=i;i.autoLevelEnabled||(i.loadLevel=-1);let g=(n=e.frag)==null?void 0:n.type,v=(g===H.AUDIO&&d===x.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===x.BUFFER_ADD_CODEC_ERROR||d===x.BUFFER_APPEND_ERROR))&&h.some(({audioCodec:D})=>r.audioCodec!==D),b=e.sourceBufferName==="video"&&(d===x.BUFFER_ADD_CODEC_ERROR||d===x.BUFFER_APPEND_ERROR)&&h.some(({codecSet:D,audioCodec:I})=>r.codecSet!==D&&r.audioCodec===I),{type:L,groupId:y}=(a=e.context)!=null?a:{};for(let D=h.length;D--;){let I=(D+u)%h.length;if(I!==u&&I>=f&&I<=m&&h[I].loadError===0){var o,l;let k=h[I];if(d===x.FRAG_GAP&&g===H.MAIN&&e.frag){let P=h[I].details;if(P){let R=Vn(e.frag,P.fragments,e.frag.start);if(R!=null&&R.gap)continue}}else {if(L===Z.AUDIO_TRACK&&k.hasAudioGroup(y)||L===Z.SUBTITLE_TRACK&&k.hasSubtitleGroup(y))continue;if(g===H.AUDIO&&(o=r.audioGroups)!=null&&o.some(P=>k.hasAudioGroup(P))||g===H.SUBTITLE&&(l=r.subtitleGroups)!=null&&l.some(P=>k.hasSubtitleGroup(P))||v&&r.audioCodec===k.audioCodec||!v&&r.audioCodec!==k.audioCodec||b&&r.codecSet===k.codecSet)continue}c=I;break}}if(c>-1&&i.loadLevel!==c)return e.levelRetry=true,this.playlistError=0,{action:Me.SendAlternateToPenaltyBox,flags:ut.None,nextAutoLevel:c}}return {action:Me.SendAlternateToPenaltyBox,flags:ut.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case Me.DoNothing:break;case Me.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==x.FRAG_GAP?t.fatal=true:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break;}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){let t=this.hls,i=e.errorAction;if(!i)return;let{flags:r,hdcpLevel:n,nextAutoLevel:a}=i;switch(r){case ut.None:this.switchLevel(e,a);break;case ut.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=Al[Al.indexOf(n)-1],i.resolved=true),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(e,a);}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=true,this.hls.nextLoadLevel=this.hls.nextAutoLevel);}},Ks=class{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=false,this.log=void 0,this.warn=void 0,this.log=S.log.bind(S,`${t}:`),this.warn=S.warn.bind(S,`${t}:`),this.hls=e;}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null;}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1);}startLoad(){this.canLoad=true,this.requestScheduled=-1,this.loadPlaylist();}stopLoad(){this.canLoad=false,this.clearTimer();}switchParams(e,t,i){let r=t?.renditionReports;if(r){let n=-1;for(let a=0;a<r.length;a++){let o=r[a],l;try{l=new self.URL(o.URI,t.url).href;}catch(d){S.warn(`Could not construct new URL for Rendition Report: ${d}`),l=o.URI||"";}if(l===e){n=a;break}else l===e.substring(0,l.length)&&(n=a);}if(n!==-1){let a=r[n],o=parseInt(a["LAST-MSN"])||t?.lastPartSn,l=parseInt(a["LAST-PART"])||t?.lastPartIndex;if(this.hls.config.lowLatencyMode){let c=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&c>t.partTarget&&(l+=1);}let d=i&&fu(i);return new $n(o,l>=0?l:void 0,d)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now());}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,i){let{details:r,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(r.advancedDateTime=Date.now()-o,r.live||i!=null&&i.live){if(r.reloaded(i),i&&this.log(`live playlist ${e} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),i&&r.fragments.length>0&&Up(i,r),!this.canLoad||!r.live)return;let l,d,c;if(r.canBlockReload&&r.endSN&&r.advanced){let E=this.hls.config.lowLatencyMode,v=r.lastPartSn,A=r.endSN,b=r.lastPartIndex,L=b!==-1,y=v===A,D=E?0:b;L?(d=y?A+1:v,c=y?D:b+1):d=A+1;let I=r.age,k=I+r.ageHeader,P=Math.min(k-r.partTarget,r.targetduration*1.5);if(P>0){if(i&&P>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${P} with playlist age: ${r.age}`),P=0;else {let R=Math.floor(P/r.targetduration);if(d+=R,c!==void 0){let w=Math.round(P%r.targetduration/r.partTarget);c+=w;}this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${I.toFixed(2)}s goal: ${P} skip sn ${R} to part ${c}`);}r.tuneInGoal=P;}if(l=this.getDeliveryDirectives(r,t.deliveryDirectives,d,c),E||!y){this.loadPlaylist(l);return}}else (r.canBlockReload||r.canSkipUntil)&&(l=this.getDeliveryDirectives(r,t.deliveryDirectives,d,c));let h=this.hls.mainForwardBufferInfo,u=h?h.end-h.len:0,f=(r.edge-u)*1e3,m=Hp(r,f);r.updated&&a>this.requestScheduled+m&&(this.requestScheduled=n.loading.start),d!==void 0&&r.canBlockReload?this.requestScheduled=n.loading.first+m-(r.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+m<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=m);let g=this.requestScheduled-a;g=Math.max(0,g),this.log(`reload live playlist ${e} in ${Math.round(g)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),g);}else this.clearTimer();}getDeliveryDirectives(e,t,i,r){let n=fu(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,r=t.part,n=Ln.No),new $n(i,r,n)}checkRetry(e){let t=e.details,i=Gn(e),r=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=r||{},l=!!r&&!!o&&(n===Me.RetryRequest||!r.resolved&&n===Me.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return false;if(i&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else {let c=Sd(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${c}ms`);}e.levelRetry=true,r.resolved=true;}return l}},Zt=class{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i;}sample(e,t){let i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e;}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}},_l=class{constructor(e,t,i,r=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Zt(e),this.fast_=new Zt(t),this.defaultTTFB_=r,this.ttfb_=new Zt(e);}update(e,t){let{slow_:i,fast_:r,ttfb_:n}=this;i.halfLife!==e&&(this.slow_=new Zt(e,i.getEstimate(),i.getTotalWeight())),r.halfLife!==t&&(this.fast_=new Zt(t,r.getEstimate(),r.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Zt(e,n.getEstimate(),n.getTotalWeight()));}sample(e,t){e=Math.max(e,this.minDelayMs_);let i=8*t,r=e/1e3,n=i/r;this.fast_.sample(r,n),this.slow_.sample(r,n);}sampleTTFB(e){let t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5));}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}},lf={supported:true,configurations:[],decodingInfoResults:[{supported:true,powerEfficient:true,smooth:true}]},vu={};function Xp(s,e,t,i,r,n){let a=s.audioCodec?s.audioGroups:null,o=n?.audioCodec,l=n?.channels,d=l?parseInt(l):o?1/0:2,c=null;if(a!=null&&a.length)try{a.length===1&&a[0]?c=e.groups[a[0]].channels:c=a.reduce((h,u)=>{if(u){let f=e.groups[u];if(!f)throw new Error(`Audio track group ${u} not found`);Object.keys(f.channels).forEach(m=>{h[m]=(h[m]||0)+f.channels[m];});}return h},{2:0});}catch{return true}return s.videoCodec!==void 0&&(s.width>1920&&s.height>1088||s.height>1920&&s.width>1088||s.frameRate>Math.max(i,30)||s.videoRange!=="SDR"&&s.videoRange!==t||s.bitrate>Math.max(r,8e6))||!!c&&F(d)&&Object.keys(c).some(h=>parseInt(h)>d)}function jp(s,e,t){let i=s.videoCodec,r=s.audioCodec;if(!i||!r||!t)return Promise.resolve(lf);let n={width:s.width,height:s.height,bitrate:Math.ceil(Math.max(s.bitrate*.9,s.averageBitrate)),framerate:s.frameRate||30},a=s.videoRange;a!=="SDR"&&(n.transferFunction=a.toLowerCase());let o=i.split(",").map(l=>({type:"media-source",video:Oe(Oe({},n),{},{contentType:Vs(l,"video")})}));return r&&s.audioGroups&&s.audioGroups.forEach(l=>{var d;l&&((d=e.groups[l])==null||d.tracks.forEach(c=>{if(c.groupId===l){let h=c.channels||"",u=parseFloat(h);F(u)&&u>2&&o.push.apply(o,r.split(",").map(f=>({type:"media-source",audio:{contentType:Vs(f,"audio"),channels:""+u}})));}}));}),Promise.all(o.map(l=>{let d=Qp(l);return vu[d]||(vu[d]=t.decodingInfo(l))})).then(l=>({supported:!l.some(d=>!d.supported),configurations:o,decodingInfoResults:l})).catch(l=>({supported:false,configurations:o,decodingInfoResults:[],error:l}))}function Qp(s){let{audio:e,video:t}=s,i=t||e;if(i){let r=i.contentType.split('"')[1];if(t)return `r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${r}_${Math.ceil(t.bitrate/1e5)}`;if(e)return `c${e.channels}${e.spatialRendering?"s":"n"}_${r}`}return ""}function Zp(){if(typeof matchMedia=="function"){let s=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(s.media!==e.media)return s.matches===true}return false}function Jp(s,e){let t=false,i=[];return s&&(t=s!=="SDR",i=[s]),e&&(i=e.allowedVideoRanges||Bn.slice(0),t=e.preferHDR!==void 0?e.preferHDR:Zp(),t?i=i.filter(r=>r!=="SDR"):i=["SDR"]),{preferHDR:t,allowedVideoRanges:i}}function e0(s,e,t,i,r){let n=Object.keys(s),a=i?.channels,o=i?.audioCodec,l=a&&parseInt(a)===2,d=true,c=false,h=1/0,u=1/0,f=1/0,m=0,g=[],{preferHDR:E,allowedVideoRanges:v}=Jp(e,r);for(let y=n.length;y--;){let D=s[n[y]];d=D.channels[2]>0,h=Math.min(h,D.minHeight),u=Math.min(u,D.minFramerate),f=Math.min(f,D.minBitrate);let I=v.filter(k=>D.videoRanges[k]>0);I.length>0&&(c=true,g=I);}h=F(h)?h:0,u=F(u)?u:0;let A=Math.max(1080,h),b=Math.max(30,u);return f=F(f)?f:t,t=Math.max(f,t),c||(e=void 0,g=[]),{codecSet:n.reduce((y,D)=>{let I=s[D];if(D===y)return y;if(I.minBitrate>t)return $t(D,`min bitrate of ${I.minBitrate} > current estimate of ${t}`),y;if(!I.hasDefaultAudio)return $t(D,"no renditions with default or auto-select sound found"),y;if(o&&D.indexOf(o.substring(0,4))%5!==0)return $t(D,`audio codec preference "${o}" not found`),y;if(a&&!l){if(!I.channels[a])return $t(D,`no renditions with ${a} channel sound found (channels options: ${Object.keys(I.channels)})`),y}else if((!o||l)&&d&&I.channels[2]===0)return $t(D,"no renditions with stereo sound found"),y;return I.minHeight>A?($t(D,`min resolution of ${I.minHeight} > maximum of ${A}`),y):I.minFramerate>b?($t(D,`min framerate of ${I.minFramerate} > maximum of ${b}`),y):g.some(k=>I.videoRanges[k]>0)?I.maxScore<m?($t(D,`max score of ${I.maxScore} < selected max of ${m}`),y):y&&(Fn(D)>=Fn(y)||I.fragmentError>s[y].fragmentError)?y:(m=I.maxScore,D):($t(D,`no variants with VIDEO-RANGE of ${JSON.stringify(g)} found`),y)},void 0),videoRanges:g,preferHDR:E,minFramerate:u,minBitrate:f}}function $t(s,e){S.log(`[abr] start candidates with "${s}" ignored because ${e}`);}function t0(s){return s.reduce((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:false,hasAutoSelect:false}),i.tracks.push(t);let r=t.channels||"2";return i.channels[r]=(i.channels[r]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=true),i.hasAutoSelect&&(e.hasAutoSelectAudio=true),e},{hasDefaultAudio:false,hasAutoSelectAudio:false,groups:{}})}function i0(s,e,t,i){return s.slice(t,i+1).reduce((r,n)=>{if(!n.codecSet)return r;let a=n.audioGroups,o=r[n.codecSet];o||(r[n.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,n.bitrate);let l=Math.min(n.height,n.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,n.frameRate),o.maxScore=Math.max(o.maxScore,n.score),o.fragmentError+=n.fragmentError,o.videoRanges[n.videoRange]=(o.videoRanges[n.videoRange]||0)+1,a&&a.forEach(d=>{if(!d)return;let c=e.groups[d];c&&(o.hasDefaultAudio=o.hasDefaultAudio||e.hasDefaultAudio?c.hasDefault:c.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(c.channels).forEach(h=>{o.channels[h]=(o.channels[h]||0)+c.channels[h];}));}),r},{})}function Nt(s,e,t){if("attrs"in s){let i=e.indexOf(s);if(i!==-1)return i}for(let i=0;i<e.length;i++){let r=e[i];if(Ji(s,r,t))return i}return -1}function Ji(s,e,t){let{groupId:i,name:r,lang:n,assocLang:a,characteristics:o,default:l}=s,d=s.forced;return (i===void 0||e.groupId===i)&&(r===void 0||e.name===r)&&(n===void 0||e.lang===n)&&(n===void 0||e.assocLang===a)&&(l===void 0||e.default===l)&&(d===void 0||e.forced===d)&&(o===void 0||s0(o,e.characteristics))&&(t===void 0||t(s,e))}function s0(s,e=""){let t=s.split(","),i=e.split(",");return t.length===i.length&&!t.some(r=>i.indexOf(r)===-1)}function qi(s,e){let{audioCodec:t,channels:i}=s;return (t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(i===void 0||i===(e.channels||"2"))}function r0(s,e,t,i,r){let n=e[i],o=e.reduce((u,f,m)=>{let g=f.uri;return (u[g]||(u[g]=[])).push(m),u},{})[n.uri];o.length>1&&(i=Math.max.apply(Math,o));let l=n.videoRange,d=n.frameRate,c=n.codecSet.substring(0,4),h=Tu(e,i,u=>{if(u.videoRange!==l||u.frameRate!==d||u.codecSet.substring(0,4)!==c)return false;let f=u.audioGroups,m=t.filter(g=>!f||f.indexOf(g.groupId)!==-1);return Nt(s,m,r)>-1});return h>-1?h:Tu(e,i,u=>{let f=u.audioGroups,m=t.filter(g=>!f||f.indexOf(g.groupId)!==-1);return Nt(s,m,r)>-1})}function Tu(s,e,t){for(let i=e;i;i--)if(t(s[i]))return i;for(let i=e+1;i<s.length;i++)if(t(s[i]))return i;return -1}var xl=class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{let{fragCurrent:t,partCurrent:i,hls:r}=this,{autoLevelEnabled:n,media:a}=r;if(!t||!a)return;let o=performance.now(),l=i?i.stats:t.stats,d=i?i.duration:t.duration,c=o-l.loading.start,h=r.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=h){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||a.paused||!a.playbackRate||!a.readyState)return;let u=r.mainForwardBufferInfo;if(u===null)return;let f=this.bwEstimator.getEstimateTTFB(),m=Math.abs(a.playbackRate);if(c<=Math.max(f,1e3*(d/(m*2))))return;let g=u.len/m,E=l.loading.first?l.loading.first-l.loading.start:-1,v=l.loaded&&E>-1,A=this.getBwEstimate(),b=r.levels,L=b[t.level],y=l.total||Math.max(l.loaded,Math.round(d*L.averageBitrate/8)),D=v?c-E:c;D<1&&v&&(D=Math.min(c,l.loaded*8/A));let I=v?l.loaded*1e3/D:0,k=I?(y-l.loaded)/I:y*8/A+f/1e3;if(k<=g)return;let P=I?I*8:A,R=Number.POSITIVE_INFINITY,w;for(w=t.level-1;w>h;w--){let O=b[w].maxBitrate;if(R=this.getTimeToLoadFrag(f/1e3,P,d*O,!b[w].details),R<g)break}if(R>=k||R>d*10)return;r.nextLoadLevel=r.nextAutoLevel=w,v?this.bwEstimator.sample(c-Math.min(f,E),l.loaded):this.bwEstimator.sampleTTFB(c);let X=b[w].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>X&&this.resetEstimator(X),this.clearTimer(),S.warn(`[abr] Fragment ${t.sn}${i?" part "+i.index:""} of level ${t.level} is loading too slowly;
|
|
1105
|
-
Time to underbuffer: ${g.toFixed(3)} s
|
|
1106
|
-
Estimated load time for current fragment: ${k.toFixed(3)} s
|
|
1107
|
-
Estimated load time for down switch fragment: ${R.toFixed(3)} s
|
|
1108
|
-
TTFB estimate: ${E|0} ms
|
|
1109
|
-
Current BW estimate: ${F(A)?A|0:"Unknown"} bps
|
|
1110
|
-
New BW estimate: ${this.getBwEstimate()|0} bps
|
|
1111
|
-
Switching to level ${w} @ ${X|0} bps`),r.trigger(p.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:i,stats:l});},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners();}resetEstimator(e){e&&(S.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator();}initEstimator(){let e=this.hls.config;return new _l(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){let{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.FRAG_LOADING,this.onFragLoading,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(p.ERROR,this.onError,this);}unregisterListeners(){let{hls:e}=this;e&&(e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.FRAG_LOADING,this.onFragLoading,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(p.ERROR,this.onError,this));}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null;}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer();}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null;}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey="";}onFragLoading(e,t){let i=t.frag;if(!this.ignoreFragment(i)){if(!i.bitrateTest){var r;this.fragCurrent=i,this.partCurrent=(r=t.part)!=null?r:null;}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100);}}onLevelSwitching(e,t){this.clearTimer();}onError(e,t){if(!t.fatal)switch(t.details){case x.BUFFER_ADD_CODEC_ERROR:case x.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case x.FRAG_LOAD_TIMEOUT:{let i=t.frag,{fragCurrent:r,partCurrent:n}=this;if(i&&r&&i.sn===r.sn&&i.level===r.level){let a=performance.now(),o=n?n.stats:i.stats,l=a-o.loading.start,d=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&d>-1){let h=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(h,d),o.loaded);}else this.bwEstimator.sampleTTFB(l);}break}}}getTimeToLoadFrag(e,t,i,r){let n=e+i/t,a=r?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let i=this.hls.config,{loading:r}=t.stats,n=r.end-r.start;F(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD);}onFragLoaded(e,{frag:t,part:i}){let r=i?i.stats:t.stats;if(t.type===H.MAIN&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){let n=i?i.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+r.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l);}if(t.bitrateTest){let n={stats:r,frag:t,part:i,id:t.type};this.onFragBuffered(p.FRAG_BUFFERED,n),t.bitrateTest=false;}else this.lastLoadedFragLevel=t.level;}}onFragBuffered(e,t){let{frag:i,part:r}=t,n=r!=null&&r.stats.loaded?r.stats:i.stats;if(n.aborted||this.ignoreFragment(i))return;let a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0;}ignoreFragment(e){return e.type!==H.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1);}get firstAutoLevel(){let{maxAutoLevel:e,minAutoLevel:t}=this.hls,i=this.getBwEstimate(),r=this.hls.config.maxStarvationDelay,n=this.findBestLevel(i,t,e,0,r,1,1);if(n>-1)return n;let a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return S.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){let e=this.forcedAutoLevel,i=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(e!==-1&&(!i||!r||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;let n=i&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){let a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return `${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:i}=this,{maxAutoLevel:r,config:n,minAutoLevel:a}=i,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),d=this.getStarvationDelay(),c=n.abrBandWidthFactor,h=n.abrBandWidthUpFactor;if(d){let E=this.findBestLevel(l,a,r,d,0,c,h);if(E>=0)return E}let u=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!d){let E=this.bitrateTestDelay;E&&(u=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-E,S.info(`[abr] bitrate test took ${Math.round(1e3*E)}ms, set first fragment max fetchDuration to ${Math.round(1e3*u)} ms`),c=h=1);}let f=this.findBestLevel(l,a,r,d,u,c,h);if(S.info(`[abr] ${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`),f>-1)return f;let m=i.levels[a],g=i.levels[i.loadLevel];return m?.bitrate<g?.bitrate?a:i.loadLevel}getStarvationDelay(){let e=this.hls,t=e.media;if(!t)return 1/0;let i=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,r=e.mainForwardBufferInfo;return (r?r.len:0)/i}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,i,r,n,a,o){var l;let d=r+n,c=this.lastLoadedFragLevel,h=c===-1?this.hls.firstLevel:c,{fragCurrent:u,partCurrent:f}=this,{levels:m,allAudioTracks:g,loadLevel:E,config:v}=this.hls;if(m.length===1)return 0;let A=m[h],b=!!(A!=null&&(l=A.details)!=null&&l.live),L=E===-1||c===-1,y,D="SDR",I=A?.frameRate||0,{audioPreference:k,videoPreference:P}=v,R=this.audioTracksByGroup||(this.audioTracksByGroup=t0(g));if(L){if(this.firstSelection!==-1)return this.firstSelection;let q=this.codecTiers||(this.codecTiers=i0(m,R,t,i)),V=e0(q,D,e,k,P),{codecSet:J,videoRanges:ae,minFramerate:U,minBitrate:N,preferHDR:ee}=V;y=J,D=ee?ae[ae.length-1]:ae[0],I=U,e=Math.max(e,N),S.log(`[abr] picked start tier ${JSON.stringify(V)}`);}else y=A?.codecSet,D=A?.videoRange;let w=f?f.duration:u?u.duration:0,X=this.bwEstimator.getEstimateTTFB()/1e3,O=[];for(let q=i;q>=t;q--){var z;let V=m[q],J=q>h;if(!V)continue;if(v.useMediaCapabilities&&!V.supportedResult&&!V.supportedPromise){let Se=navigator.mediaCapabilities;typeof Se?.decodingInfo=="function"&&Xp(V,R,D,I,e,k)?(V.supportedPromise=jp(V,R,Se),V.supportedPromise.then(Le=>{if(!this.hls)return;V.supportedResult=Le;let Ne=this.hls.levels,Je=Ne.indexOf(V);Le.error?S.warn(`[abr] MediaCapabilities decodingInfo error: "${Le.error}" for level ${Je} ${JSON.stringify(Le)}`):Le.supported||(S.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${Je} ${JSON.stringify(Le)}`),Je>-1&&Ne.length>1&&(S.log(`[abr] Removing unsupported level ${Je}`),this.hls.removeLevel(Je)));})):V.supportedResult=lf;}if(y&&V.codecSet!==y||D&&V.videoRange!==D||J&&I>V.frameRate||!J&&I>0&&I<V.frameRate||V.supportedResult&&!((z=V.supportedResult.decodingInfoResults)!=null&&z[0].smooth)){O.push(q);continue}let ae=V.details,U=(f?ae?.partTarget:ae?.averagetargetduration)||w,N;J?N=o*e:N=a*e;let ee=w&&r>=w*2&&n===0?m[q].averageBitrate:m[q].maxBitrate,Q=this.getTimeToLoadFrag(X,N,ee*U,ae===void 0);if(N>=ee&&(q===c||V.loadError===0&&V.fragmentError===0)&&(Q<=X||!F(Q)||b&&!this.bitrateTestDelay||Q<d)){let Se=this.forcedAutoLevel;return q!==E&&(Se===-1||Se!==E)&&(O.length&&S.trace(`[abr] Skipped level(s) ${O.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${m[O[0]].codecs}" ${m[O[0]].videoRange}; not compatible with "${A.codecs}" ${D}`),S.info(`[abr] switch candidate:${h}->${q} adjustedbw(${Math.round(N)})-bitrate=${Math.round(N-ee)} ttfb:${X.toFixed(1)} avgDuration:${U.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${Q.toFixed(1)} firstSelection:${L} codecSet:${y} videoRange:${D} hls.loadLevel:${E}`)),L&&(this.firstSelection=q),q}}return -1}set nextAutoLevel(e){let{maxAutoLevel:t,minAutoLevel:i}=this.hls,r=Math.min(Math.max(e,i),t);this._nextAutoLevel!==r&&(this.nextAutoLevelKey="",this._nextAutoLevel=r);}},Il=class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this);}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed();}onHandlerDestroying(){this.clearNextTick(),this.clearInterval();}onHandlerDestroyed(){}hasInterval(){return !!this._tickInterval}hasNextTick(){return !!this._tickTimer}setInterval(e){return this._tickInterval?false:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),true)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,true):false}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,true):false}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0);}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0);}doTick(){}},Pe={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Ll=class{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=false,this.hls=e,this._registerListeners();}_registerListeners(){let{hls:e}=this;e.on(p.BUFFER_APPENDED,this.onBufferAppended,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this);}_unregisterListeners(){let{hls:e}=this;e.off(p.BUFFER_APPENDED,this.onBufferAppended,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this);}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null;}getAppendedFrag(e,t){let i=this.activePartLists[t];if(i)for(let r=i.length;r--;){let n=i[r];if(!n)break;let a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){let{fragments:i}=this,r=Object.keys(i);for(let n=r.length;n--;){let a=i[r[n]];if(a?.body.type===t&&a.buffered){let o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,i,r){this.timeRanges&&(this.timeRanges[e]=t);let n=r?.fragment.sn||-1;Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===i&&this.removeFragment(o.body);return}let l=o.range[e];l&&l.time.some(d=>{let c=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return c&&this.removeFragment(o.body),c});});}detectPartialFragments(e){let t=this.timeRanges,{frag:i,part:r}=e;if(!t||i.sn==="initSegment")return;let n=zi(i),a=this.fragments[n];if(!a||a.buffered&&i.gap)return;let o=!i.relurl;Object.keys(t).forEach(l=>{let d=i.elementaryStreams[l];if(!d)return;let c=t[l],h=o||d.partial===true;a.range[l]=this.getBufferedTimes(i,r,h,c);}),a.loaded=null,Object.keys(a.range).length?(a.buffered=true,(a.body.endList=i.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),Tn(a)||this.removeParts(i.sn-1,i.type)):this.removeFragment(a.body);}removeParts(e,t){let i=this.activePartLists[t];i&&(this.activePartLists[t]=i.filter(r=>r.fragment.sn>=e));}fragBuffered(e,t){let i=zi(e),r=this.fragments[i];!r&&t&&(r=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:false,range:Object.create(null)},e.gap&&(this.hasGaps=true)),r&&(r.loaded=null,r.buffered=true);}getBufferedTimes(e,t,i,r){let n={time:[],partial:i},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let c=0;c<r.length;c++){let h=r.start(c)-this.bufferPadding,u=r.end(c)+this.bufferPadding;if(d>=h&&l<=u){n.time.push({startPTS:Math.max(a,r.start(c)),endPTS:Math.min(o,r.end(c))});break}else if(a<u&&o>h){let f=Math.max(a,r.start(c)),m=Math.min(o,r.end(c));m>f&&(n.partial=true,n.time.push({startPTS:f,endPTS:m}));}else if(o<=h)break}return n}getPartialFragment(e){let t=null,i,r,n,a=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{let c=l[d];c&&Tn(c)&&(r=c.body.start-o,n=c.body.end+o,e>=r&&e<=n&&(i=Math.min(e-r,n-e),a<=i&&(t=c.body,a=i)));}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||Tn(t))}getState(e){let t=zi(e),i=this.fragments[t];return i?i.buffered?Tn(i)?Pe.PARTIAL:Pe.OK:Pe.APPENDING:Pe.NOT_LOADED}isTimeBuffered(e,t,i){let r,n;for(let a=0;a<i.length;a++){if(r=i.start(a)-this.bufferPadding,n=i.end(a)+this.bufferPadding,e>=r&&t<=n)return true;if(t<=r)return false}return false}onFragLoaded(e,t){let{frag:i,part:r}=t;if(i.sn==="initSegment"||i.bitrateTest)return;let n=r?null:t,a=zi(i);this.fragments[a]={body:i,appendedPTS:null,loaded:n,buffered:false,range:Object.create(null)};}onBufferAppended(e,t){let{frag:i,part:r,timeRanges:n}=t;if(i.sn==="initSegment")return;let a=i.type;if(r){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(r);}this.timeRanges=n,Object.keys(n).forEach(o=>{let l=n[o];this.detectEvictedFragments(o,l,a,r);});}onFragBuffered(e,t){this.detectPartialFragments(t);}hasFragment(e){let t=zi(e);return !!this.fragments[t]}hasParts(e){var t;return !!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,r,n){r&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o)return;let l=o.body;l.type!==i||r&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l);});}removeFragment(e){let t=zi(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let i=this.activePartLists[e.type];if(i){let r=e.sn;this.activePartLists[e.type]=i.filter(n=>n.fragment.sn!==r);}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type];}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=false;}};function Tn(s){var e,t,i;return s.buffered&&(s.body.gap||((e=s.range.video)==null?void 0:e.partial)||((t=s.range.audio)==null?void 0:t.partial)||((i=s.range.audiovideo)==null?void 0:i.partial))}function zi(s){return `${s.type}_${s.level}_${s.sn}`}var n0={length:0,start:()=>0,end:()=>0},ue=class s{static isBuffered(e,t){try{if(e){let i=s.getBuffered(e);for(let r=0;r<i.length;r++)if(t>=i.start(r)&&t<=i.end(r))return !0}}catch{}return false}static bufferInfo(e,t,i){try{if(e){let r=s.getBuffered(e),n=[],a;for(a=0;a<r.length;a++)n.push({start:r.start(a),end:r.end(a)});return this.bufferedInfo(n,t,i)}}catch{}return {len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.sort(function(d,c){let h=d.start-c.start;return h||c.end-d.end});let r=[];if(i)for(let d=0;d<e.length;d++){let c=r.length;if(c){let h=r[c-1].end;e[d].start-h<i?e[d].end>h&&(r[c-1].end=e[d].end):r.push(e[d]);}else r.push(e[d]);}else r=e;let n=0,a,o=t,l=t;for(let d=0;d<r.length;d++){let c=r[d].start,h=r[d].end;if(t+i>=c&&t<h)o=c,l=h,n=l-t;else if(t+i<c){a=c;break}}return {len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return S.log("failed to get media.buffered",t),n0}}},Ws=class{constructor(e,t,i,r=0,n=-1,a=false){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=An(),this.buffering={audio:An(),video:An(),audiovideo:An()},this.level=e,this.sn=t,this.id=i,this.size=r,this.part=n,this.partial=a;}};function An(){return {start:0,executeStart:0,executeEnd:0,end:0}}function Rn(s,e){for(let i=0,r=s.length;i<r;i++){var t;if(((t=s[i])==null?void 0:t.cc)===e)return s[i]}return null}function a0(s,e,t){return !!(e&&(t.endCC>t.startCC||s&&s.cc<t.startCC))}function o0(s,e){let t=s.fragments,i=e.fragments;if(!i.length||!t.length){S.log("No fragments to align");return}let r=Rn(t,i[0].cc);if(!r||r&&!r.startPTS){S.log("No frag in previous level to align on");return}return r}function Au(s,e){if(s){let t=s.start+e;s.start=s.startPTS=t,s.endPTS=t+s.duration;}}function df(s,e){let t=e.fragments;for(let i=0,r=t.length;i<r;i++)Au(t[i],s);e.fragmentHint&&Au(e.fragmentHint,s),e.alignedSliding=true;}function l0(s,e,t){e&&(d0(s,t,e),!t.alignedSliding&&e&&Kn(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&rf(e,t));}function d0(s,e,t){if(a0(s,t,e)){let i=o0(t,e);i&&F(i.start)&&(S.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),df(i.start,e));}}function Kn(s,e){if(!s.hasProgramDateTime||!e.hasProgramDateTime)return;let t=s.fragments,i=e.fragments;if(!t.length||!i.length)return;let r,n,a=Math.min(e.endCC,s.endCC);e.startCC<a&&s.startCC<a&&(r=Rn(i,a),n=Rn(t,a)),(!r||!n)&&(r=i[Math.floor(i.length/2)],n=Rn(t,r.cc)||t[Math.floor(t.length/2)]);let o=r.programDateTime,l=n.programDateTime;if(!o||!l)return;let d=(l-o)/1e3-(n.start-r.start);df(d,s);}var bu=Math.pow(2,17),Rl=class{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e;}destroy(){this.loader&&(this.loader.destroy(),this.loader=null);}abort(){this.loader&&this.loader.abort();}load(e,t){let i=e.url;if(!i)return Promise.reject(new mt({type:K.NETWORK_ERROR,details:x.FRAG_LOAD_ERROR,fatal:false,frag:e,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();let r=this.config,n=r.fLoader,a=r.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(Su(e));return}else e.gap=false;let d=this.loader=e.loader=n?new n(r):new a(r),c=yu(e),h=Eu(r.fragLoadPolicy.default),u={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:bu};e.stats=d.stats,d.load(c,u,{onSuccess:(f,m,g,E)=>{this.resetLoader(e,d);let v=f.data;g.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(v.slice(0,16)),v=v.slice(16)),o({frag:e,part:null,payload:v,networkDetails:E});},onError:(f,m,g,E)=>{this.resetLoader(e,d),l(new mt({type:K.NETWORK_ERROR,details:x.FRAG_LOAD_ERROR,fatal:false,frag:e,response:Oe({url:i,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:g,stats:E}));},onAbort:(f,m,g)=>{this.resetLoader(e,d),l(new mt({type:K.NETWORK_ERROR,details:x.INTERNAL_ABORTED,fatal:false,frag:e,error:new Error("Aborted"),networkDetails:g,stats:f}));},onTimeout:(f,m,g)=>{this.resetLoader(e,d),l(new mt({type:K.NETWORK_ERROR,details:x.FRAG_LOAD_TIMEOUT,fatal:false,frag:e,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:g,stats:f}));},onProgress:(f,m,g,E)=>{t&&t({frag:e,part:null,payload:g,networkDetails:E});}});})}loadPart(e,t,i){this.abort();let r=this.config,n=r.fLoader,a=r.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(Su(e,t));return}let d=this.loader=e.loader=n?new n(r):new a(r),c=yu(e,t),h=Eu(r.fragLoadPolicy.default),u={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:bu};t.stats=d.stats,d.load(c,u,{onSuccess:(f,m,g,E)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);let v={frag:e,part:t,payload:f.data,networkDetails:E};i(v),o(v);},onError:(f,m,g,E)=>{this.resetLoader(e,d),l(new mt({type:K.NETWORK_ERROR,details:x.FRAG_LOAD_ERROR,fatal:false,frag:e,part:t,response:Oe({url:c.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:g,stats:E}));},onAbort:(f,m,g)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new mt({type:K.NETWORK_ERROR,details:x.INTERNAL_ABORTED,fatal:false,frag:e,part:t,error:new Error("Aborted"),networkDetails:g,stats:f}));},onTimeout:(f,m,g)=>{this.resetLoader(e,d),l(new mt({type:K.NETWORK_ERROR,details:x.FRAG_LOAD_TIMEOUT,fatal:false,frag:e,part:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:g,stats:f}));}});})}updateStatsFromPart(e,t){let i=e.stats,r=t.stats,n=r.total;if(i.loaded+=r.loaded,n){let l=Math.round(e.duration/t.duration),d=Math.min(Math.round(i.loaded/n),l),h=(l-d)*Math.round(i.loaded/d);i.total=i.loaded+h;}else i.total=Math.max(i.loaded,i.total);let a=i.loading,o=r.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end;}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy();}};function yu(s,e=null){let t=e||s,i={frag:s,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},r=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(F(r)&&F(n)){var a;let o=r,l=n;if(s.sn==="initSegment"&&((a=s.decryptdata)==null?void 0:a.method)==="AES-128"){let d=n-r;d%16&&(l=n+(16-d%16)),r!==0&&(i.resetIV=true,o=r-16);}i.rangeStart=o,i.rangeEnd=l;}return i}function Su(s,e){let t=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:K.MEDIA_ERROR,details:x.FRAG_GAP,fatal:false,frag:s,error:t,networkDetails:null};return e&&(i.part=e),(e||s).stats.aborted=true,new mt(i)}var mt=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e;}},Dl=class{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t;}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}},Cl=class{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t;}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},false,["encrypt","decrypt"])}};function c0(s){let e=s.byteLength,t=e&&new DataView(s.buffer).getUint8(e-1);return t?vi(s,0,e-t):s}var kl=class{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable();}uint8ArrayToUint32Array_(e){let t=new DataView(e),i=new Uint32Array(4);for(let r=0;r<4;r++)i[r]=t.getUint32(r*4);return i}initTable(){let e=this.sBox,t=this.invSBox,i=this.subMix,r=i[0],n=i[1],a=i[2],o=i[3],l=this.invSubMix,d=l[0],c=l[1],h=l[2],u=l[3],f=new Uint32Array(256),m=0,g=0,E=0;for(E=0;E<256;E++)E<128?f[E]=E<<1:f[E]=E<<1^283;for(E=0;E<256;E++){let v=g^g<<1^g<<2^g<<3^g<<4;v=v>>>8^v&255^99,e[m]=v,t[v]=m;let A=f[m],b=f[A],L=f[b],y=f[v]*257^v*16843008;r[m]=y<<24|y>>>8,n[m]=y<<16|y>>>16,a[m]=y<<8|y>>>24,o[m]=y,y=L*16843009^b*65537^A*257^m*16843008,d[v]=y<<24|y>>>8,c[v]=y<<16|y>>>16,h[v]=y<<8|y>>>24,u[v]=y,m?(m=A^f[f[f[L^A]]],g^=f[f[g]]):m=g=1;}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),i=true,r=0;for(;r<t.length&&i;)i=t[r]===this.key[r],r++;if(i)return;this.key=t;let n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);let a=this.ksRows=(n+6+1)*4,o,l,d=this.keySchedule=new Uint32Array(a),c=this.invKeySchedule=new Uint32Array(a),h=this.sBox,u=this.rcon,f=this.invSubMix,m=f[0],g=f[1],E=f[2],v=f[3],A,b;for(o=0;o<a;o++){if(o<n){A=d[o]=t[o];continue}b=A,o%n===0?(b=b<<8|b>>>24,b=h[b>>>24]<<24|h[b>>>16&255]<<16|h[b>>>8&255]<<8|h[b&255],b^=u[o/n|0]<<24):n>6&&o%n===4&&(b=h[b>>>24]<<24|h[b>>>16&255]<<16|h[b>>>8&255]<<8|h[b&255]),d[o]=A=(d[o-n]^b)>>>0;}for(l=0;l<a;l++)o=a-l,l&3?b=d[o]:b=d[o-4],l<4||o<=4?c[l]=b:c[l]=m[h[b>>>24]]^g[h[b>>>16&255]]^E[h[b>>>8&255]]^v[h[b&255]],c[l]=c[l]>>>0;}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){let r=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],c=o[2],h=o[3],u=this.uint8ArrayToUint32Array_(i),f=u[0],m=u[1],g=u[2],E=u[3],v=new Int32Array(e),A=new Int32Array(v.length),b,L,y,D,I,k,P,R,w,X,O,z,q,V,J=this.networkToHostOrderSwap;for(;t<v.length;){for(w=J(v[t]),X=J(v[t+1]),O=J(v[t+2]),z=J(v[t+3]),I=w^n[0],k=z^n[1],P=O^n[2],R=X^n[3],q=4,V=1;V<r;V++)b=l[I>>>24]^d[k>>16&255]^c[P>>8&255]^h[R&255]^n[q],L=l[k>>>24]^d[P>>16&255]^c[R>>8&255]^h[I&255]^n[q+1],y=l[P>>>24]^d[R>>16&255]^c[I>>8&255]^h[k&255]^n[q+2],D=l[R>>>24]^d[I>>16&255]^c[k>>8&255]^h[P&255]^n[q+3],I=b,k=L,P=y,R=D,q=q+4;b=a[I>>>24]<<24^a[k>>16&255]<<16^a[P>>8&255]<<8^a[R&255]^n[q],L=a[k>>>24]<<24^a[P>>16&255]<<16^a[R>>8&255]<<8^a[I&255]^n[q+1],y=a[P>>>24]<<24^a[R>>16&255]<<16^a[I>>8&255]<<8^a[k&255]^n[q+2],D=a[R>>>24]<<24^a[I>>16&255]<<16^a[k>>8&255]<<8^a[P&255]^n[q+3],A[t]=J(b^f),A[t+1]=J(D^m),A[t+2]=J(y^g),A[t+3]=J(L^E),f=w,m=X,g=O,E=z,t=t+4;}return A.buffer}},h0=16,Ys=class{constructor(e,{removePKCS7Padding:t=true}={}){if(this.logEnabled=true,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{let i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle);}catch{}this.useSoftware=!this.subtle;}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null;}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?c0(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null);}decrypt(e,t,i){return this.useSoftware?new Promise((r,n)=>{this.softwareDecrypt(new Uint8Array(e),t,i);let a=this.flush();a?r(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"));}):this.webCryptoDecrypt(new Uint8Array(e),t,i)}softwareDecrypt(e,t,i){let{currentIV:r,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=st(a,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;r&&(i=r);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new kl),l.expandKey(t);let d=n;return this.currentResult=l.decrypt(o.buffer,0,i),this.currentIV=vi(o,-16).buffer,d||null}webCryptoDecrypt(e,t,i){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i));this.key=t,this.fastAesKey=new Cl(this.subtle,t);}return this.fastAesKey.expandKey().then(r=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new Dl(this.subtle,new Uint8Array(i)).decrypt(e.buffer,r)):Promise.reject(new Error("web crypto not initialized"))).catch(r=>(S.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(e,t,i)))}onWebCryptoError(e,t,i){this.useSoftware=true,this.logEnabled=true,this.softwareDecrypt(e,t,i);let r=this.flush();if(r)return r.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,i=e.length-e.length%h0;return i!==e.length&&(t=vi(e,0,i),this.remainderData=vi(e,i)),t}logOnce(e){this.logEnabled&&(S.log(`[decrypter]: ${e}`),this.logEnabled=false);}},u0={toString:function(s){let e="",t=s.length;for(let i=0;i<t;i++)e+=`[${s.start(i).toFixed(3)}-${s.end(i).toFixed(3)}]`;return e}},C={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},qs=class extends Il{constructor(e,t,i,r,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=C.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=false,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=false,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=false,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=r,this.log=S.log.bind(S,`${r}:`),this.warn=S.warn.bind(S,`${r}:`),this.hls=e,this.fragmentLoader=new Rl(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Ys(e.config),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this);}doTick(){this.onTickEnd();}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=C.STOPPED;}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return false;let i=t.partList;if(i!=null&&i.length){let n=i[i.length-1];return ue.isBuffered(this.media,n.start+n.duration/2)}let r=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(r)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return (e=this.levelLastLoaded)==null?void 0:e.details}}onMediaAttached(e,t){let i=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);let r=this.config;this.levels&&r.autoStartLoad&&this.state===C.STOPPED&&this.startLoad(r.startPosition);}onMediaDetaching(){let e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=false,this.fragmentTracker.removeAllFragments(),this.stopLoad();}onMediaSeeking(){let{config:e,fragCurrent:t,media:i,mediaBuffer:r,state:n}=this,a=i?i.currentTime:0,o=ue.bufferInfo(r||i,a,e.maxBufferHole);if(this.log(`media seeking to ${F(a)?a.toFixed(3):a}, state: ${n}`),this.state===C.ENDED)this.resetLoadingState();else if(t){let l=e.maxFragLookUpTolerance,d=t.start-l,c=t.start+t.duration+l;if(!o.len||c<o.start||d>o.end){let h=a>c;(a<d||h)&&(h&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null);}}i&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,true),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate();}onMediaEnded(){this.startPosition=this.lastCurrentTime=0;}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[];}onHandlerDestroying(){this.hls.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null;}onHandlerDestroyed(){this.state=C.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed();}loadFragment(e,t,i){this._loadFragForPlayback(e,t,i);}_loadFragForPlayback(e,t,i){let r=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n);};this._doFragLoad(e,t,i,r).then(n=>{if(!n)return;let a=this.state;if(this.fragContextChanged(e)){(a===C.FRAG_LOADING||!this.fragCurrent&&a===C.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=C.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(p.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n);}).catch(n=>{this.state===C.STOPPED||this.state===C.ERROR||(this.warn(`Frag error: ${n?.message||n}`),this.resetFragmentLoading(e));});}clearTrackerIfNeeded(e){var t;let{fragmentTracker:i}=this;if(i.getState(e)===Pe.APPENDING){let n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),l=this.backtrackFragment;((l?e.sn-l.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&i.removeFragment(e);}else ((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===Pe.PARTIAL&&i.removeFragment(e));}checkLiveUpdate(e){if(e.updated&&!e.live){let t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type});}e.fragments[0]||(e.deltaUpdateFailed=true);}flushMainBuffer(e,t,i=null){if(!(e-t))return;let r={startOffset:e,endOffset:t,type:i};this.hls.trigger(p.BUFFER_FLUSHING,r);}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{if(!i||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{let{hls:r}=this,{payload:n}=i,a=e.decryptdata;if(n&&n.byteLength>0&&a!=null&&a.key&&a.iv&&a.method==="AES-128"){let o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw r.trigger(p.ERROR,{type:K.MEDIA_ERROR,details:x.FRAG_DECRYPT_ERROR,fatal:false,error:l,reason:l.message,frag:e}),l}).then(l=>{let d=self.performance.now();return r.trigger(p.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),i.payload=l,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)}).catch(i=>{this.state===C.STOPPED||this.state===C.ERROR||(this.warn(i),this.resetFragmentLoading(e));});}completeInitSegmentLoad(e){let{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");let i=e.frag.stats;this.state=C.IDLE,e.frag.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),this.tick();}fragContextChanged(e){let{fragCurrent:t}=this;return !e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var i,r,n,a;let o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===H.MAIN?"level":"track"} ${e.level} (frag:[${((i=e.startPTS)!=null?i:NaN).toFixed(3)}-${((r=e.endPTS)!=null?r:NaN).toFixed(3)}] > buffer:${o?u0.toString(ue.getBuffered(o)):"(detached)"})`),e.sn!=="initSegment"){var l;if(e.type!==H.SUBTITLE){let c=e.elementaryStreams;if(!Object.keys(c).some(h=>!!c[h])){this.state=C.IDLE;return}}let d=(l=this.levels)==null?void 0:l[e.level];d!=null&&d.fragmentError&&(this.log(`Resetting level fragment error count of ${d.fragmentError} on frag buffered`),d.fragmentError=0);}this.state=C.IDLE,o&&(!this.loadedmetadata&&e.type==H.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=true,this.seekToStartPos()),this.tick());}seekToStartPos(){}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:i,part:r,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new Ws(i.level,i.sn,i.stats.chunkCount+1,0,r?r.index:-1,!a);t.flush(o);}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,r){var n;let a=t?.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=C.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(c=>{if(!this.fragContextChanged(c.frag))return this.hls.trigger(p.KEY_LOADED,c),this.state===C.KEY_LOADING&&(this.state=C.IDLE),c}),this.hls.trigger(p.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),i=Math.max(e.start,i||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){let c=a.partList;if(c&&r){i>e.end&&a.fragmentHint&&(e=a.fragmentHint);let h=this.getNextPart(c,e,i);if(h>-1){let u=c[h];this.log(`Loading part sn: ${e.sn} p: ${u.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${h}-${c.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=u.start+u.duration,this.state=C.FRAG_LOADING;let f;return o?f=o.then(m=>!m||this.fragContextChanged(m.frag)?null:this.doFragPartsLoad(e,u,t,r)).catch(m=>this.handleFragLoadError(m)):f=this.doFragPartsLoad(e,u,t,r).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(p.FRAG_LOADING,{frag:e,part:u,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(c,i))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),F(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=C.FRAG_LOADING;let l=this.config.progressive,d;return l&&o?d=o.then(c=>!c||this.fragContextChanged(c?.frag)?null:this.fragmentLoader.load(e,r)).catch(c=>this.handleFragLoadError(c)):d=Promise.all([this.fragmentLoader.load(e,l?r:void 0),o]).then(([c])=>(!l&&c&&r&&r(c),c)).catch(c=>this.handleFragLoadError(c)),this.hls.trigger(p.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,i,r){return new Promise((n,a)=>{var o;let l=[],d=(o=i.details)==null?void 0:o.partList,c=h=>{this.fragmentLoader.loadPart(e,h,r).then(u=>{l[h.index]=u;let f=u.part;this.hls.trigger(p.FRAG_LOADED,u);let m=gu(i,e.sn,h.index+1)||nf(d,e.sn,h.index+1);if(m)c(m);else return n({frag:e,part:f,partsLoaded:l})}).catch(a);};c(t);})}handleFragLoadError(e){if("data"in e){let t=e.data;e.data&&t.details===x.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(p.ERROR,t);}else this.hls.trigger(p.ERROR,{type:K.OTHER_ERROR,details:x.INTERNAL_EXCEPTION,err:e,error:e,fatal:true});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==C.PARSING){!this.fragCurrent&&this.state!==C.STOPPED&&this.state!==C.ERROR&&(this.state=C.IDLE);return}let{frag:i,part:r,level:n}=t,a=self.performance.now();i.stats.parsing.end=a,r&&(r.stats.parsing.end=a),this.updateLevelTiming(i,r,n,e.partial);}getCurrentContext(e){let{levels:t,fragCurrent:i}=this,{level:r,sn:n,part:a}=e;if(!(t!=null&&t[r]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${r}. The current chunk will not be buffered.`),null;let o=t[r],l=a>-1?gu(o,n,a):null,d=l?l.fragment:Vp(o,n,i);return d?(i&&i!==d&&(d.stats=i.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,i,r,n){var a;if(!e||this.state!==C.PARSING)return;let{data1:o,data2:l}=e,d=o;if(o&&l&&(d=st(o,l)),!((a=d)!=null&&a.length))return;let c={type:e.type,frag:t,part:i,chunkMeta:r,parent:t.type,data:d};if(this.hls.trigger(p.BUFFER_APPENDING,c),e.dropped&&e.independent&&!i){if(n)return;this.flushBufferGap(t);}}flushBufferGap(e){let t=this.media;if(!t)return;if(!ue.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let i=t.currentTime,r=ue.bufferInfo(t,i,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,r.end-a),i+a);e.start-o>a&&this.flushMainBuffer(o,e.start);}getFwdBufferInfo(e,t){let i=this.getLoadPosition();return F(i)?this.getFwdBufferInfoAtPos(e,i,t):null}getFwdBufferInfoAtPos(e,t,i){let{config:{maxBufferHole:r}}=this,n=ue.bufferInfo(e,t,r);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&n.nextStart<a.end)return ue.bufferInfo(e,t,Math.max(n.nextStart,r))}return n}getMaxBufferLength(e){let{config:t}=this,i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){let i=this.config,r=Math.max(Math.min(e-t,i.maxBufferLength),t),n=Math.max(e-t*3,i.maxMaxBufferLength/2,r);return n>=r?(i.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),true):false}getAppendedFrag(e,t=H.MAIN){let i=this.fragmentTracker.getAppendedFrag(e,H.MAIN);return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){let i=t.fragments,r=i.length;if(!r)return null;let{config:n}=this,a=i[0].start,o;if(t.live){let l=n.initialLiveManifestSize;if(r<l)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${l})`),null;(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a)&&(o=this.getInitialLiveFragment(t,i),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e);}else e<=a&&(o=i[0]);if(!o){let l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t);}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){let i=this.fragmentTracker.getState(e);return (i===Pe.OK||i===Pe.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,r,n){let a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&i.nextStart){let l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,r);if(l!==null&&i.len+l.len>=n)return this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,i){let r=-1,n=false,a=true;for(let o=0,l=e.length;o<l;o++){let d=e[o];if(a=a&&!d.independent,r>-1&&i<d.start)break;let c=d.loaded;c?r=-1:(n||d.independent||a)&&d.fragment===t&&(r=o),n=c;}return r}loadedEndOfParts(e,t){let i=e[e.length-1];return i&&t>i.start&&i.loaded}getInitialLiveFragment(e,t){let i=this.fragPrevious,r=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),r=Wp(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){let n=i.sn+1;if(n>=e.startSN&&n<=e.endSN){let a=t[n-e.startSN];i.cc===a.cc&&(r=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`));}r||(r=zp(t,i.cc),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`));}}else {let n=this.hls.liveSyncPosition;n!==null&&(r=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e));}return r}getFragmentAtPosition(e,t,i){let{config:r}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=i,{fragmentHint:l}=i,{maxFragLookUpTolerance:d}=r,c=i.partList,h=!!(r.lowLatencyMode&&c!=null&&c.length&&l);h&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let u;if(e<t){let f=e>t-d?0:d;u=Vn(n,a,e,f);}else u=a[a.length-1];if(u){let f=u.sn-i.startSN,m=this.fragmentTracker.getState(u);if((m===Pe.OK||m===Pe.PARTIAL&&u.gap)&&(n=u),n&&u.sn===n.sn&&(!h||c[0].fragment.sn>u.sn)&&n&&u.level===n.level){let E=a[f+1];u.sn<o&&this.fragmentTracker.getState(E)!==Pe.OK?u=E:u=null;}}return u}synchronizeToLiveEdge(e){let{config:t,media:i}=this;if(!i)return;let r=this.hls.liveSyncPosition,n=i.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(r!==null&&i.duration>r&&(n<r||!l)){let d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&i.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=r),i.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${r.toFixed(3)}`),i.currentTime=r));}}alignPlaylists(e,t,i){let r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;let n=e.fragments[0].start,a=!t,o=e.alignedSliding&&F(n);if(a||!o&&!n){let{fragPrevious:l}=this;l0(l,i,e);let d=e.fragments[0].start;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${l?l.sn:"na"} fragments: ${r}`),d}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;if(i<t&&(i=-1),i===-1||this.lastCurrentTime===-1){let r=this.startTimeOffset!==null,n=r?this.startTimeOffset:e.startTimeOffset;n!==null&&F(n)?(i=t+n,n<0&&(i+=e.totalduration),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Start time offset ${n} found in ${r?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):e.live?i=this.hls.liveSyncPosition||t:this.startPosition=i=0,this.lastCurrentTime=i;}this.nextLoadPosition=i;}getLoadPosition(){let{media:e}=this,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e));}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==C.FRAG_LOADING_WAITING_RETRY)&&(this.state=C.IDLE);}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let c=this.getCurrentContext(t.chunkMeta);c&&(t.frag=c.frag);}let i=t.frag;if(!i||i.type!==e||!this.levels)return;if(this.fragContextChanged(i)){var r;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(r=this.fragCurrent)==null?void 0:r.url}`);return}let n=t.details===x.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,true);let a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===Me.RetryRequest&&d){this.resetStartWhenNotLoaded(this.levelLastLoaded);let c=Sd(d,l);this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${c}ms`),a.resolved=true,this.retryDate=self.performance.now()+c,this.state=C.FRAG_LOADING_WAITING_RETRY;}else if(d&&a)if(this.resetFragmentErrors(e),l<d.maxNumRetry)!n&&o!==Me.RemoveAlternatePermanently&&(a.resolved=true);else {S.warn(`${t.details} reached or exceeded max retry (${l})`);return}else a?.action===Me.SendAlternateToPenaltyBox?this.state=C.WAITING_LEVEL:this.state=C.ERROR;this.tickImmediate();}reduceLengthAndFlushBuffer(e){if(this.state===C.PARSING||this.state===C.PARSED){let t=e.frag,i=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,i),n=r&&r.len>.5;n&&this.reduceMaxBufferLength(r.len,t?.duration||10);let a=!n;return a&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return false}resetFragmentErrors(e){e===H.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=false),this.state!==C.STOPPED&&(this.state=C.IDLE);}afterBufferFlushed(e,t,i){if(!e)return;let r=ue.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,i),this.state===C.ENDED&&this.resetLoadingState();}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=C.IDLE;}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=false;let t=e?e.details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition;}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState();}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,false,true);}updateLevelTiming(e,t,i,r){var n;let a=i.details;if(!a){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,d)=>{let c=e.elementaryStreams[d];if(c){let h=c.endPTS-c.startPTS;if(h<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${h})`),l||false;let u=r?0:sf(a,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS);return this.hls.trigger(p.LEVEL_PTS_UPDATED,{details:a,level:i,drift:u,type:d,frag:e,start:c.startPTS,end:c.endPTS}),true}return l},false)&&((n=this.transmuxer)==null?void 0:n.error)===null){let l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(i.fragmentError===0&&(i.fragmentError++,e.gap=true,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,true)),this.warn(l.message),this.hls.trigger(p.ERROR,{type:K.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:false,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer();}this.state=C.PARSED,this.hls.trigger(p.FRAG_PARSED,{frag:e,part:t});}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null);}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState());}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`));}get state(){return this._state}},Wn=class{constructor(){this.chunks=[],this.dataLength=0;}push(e){this.chunks.push(e),this.dataLength+=e.length;}flush(){let{chunks:e,dataLength:t}=this,i;if(e.length)e.length===1?i=e[0]:i=f0(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0;}};function f0(s,e){let t=new Uint8Array(e),i=0;for(let r=0;r<s.length;r++){let n=s[r];t.set(n,i),i+=n.length;}return t}function m0(){return typeof __HLS_WORKER_BUNDLE__=="function"}function g0(){let s=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(s);return {worker:new self.Worker(e),objectURL:e}}function p0(s){let e=new self.URL(s,self.location.href).href;return {worker:new self.Worker(e),scriptURL:e}}function Ot(s="",e=9e4){return {type:s,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var zs=class{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null;}resetInitSegment(e,t,i,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0};}resetTimeStamp(e){this.initPTS=e,this.resetContiguity();}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0;}canParse(e,t){return false}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=st(this.cachedData,e),this.cachedData=null);let i=Gs(e,0),r=i?i.length:0,n,a=this._audioTrack,o=this._id3Track,l=i?yd(i):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&F(l))&&(this.basePTS=E0(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:gt.audioId3,duration:Number.POSITIVE_INFINITY});r<d;){if(this.canParse(e,r)){let c=this.appendFrame(a,e,r);c?(this.frameIndex++,this.lastPTS=c.sample.pts,r+=c.length,n=r):r=d;}else jg(e,r)?(i=Gs(e,r),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:gt.audioId3,duration:Number.POSITIVE_INFINITY}),r+=i.length,n=r):r++;if(r===d&&n!==d){let c=vi(e,n);this.cachedData?this.cachedData=st(this.cachedData,c):this.cachedData=c;}}return {audioTrack:a,videoTrack:Ot(),id3Track:o,textTrack:Ot()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Ot(),id3Track:this._id3Track,textTrack:Ot()}}destroy(){}},E0=(s,e,t)=>{if(F(s))return s*90;let i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};function v0(s,e,t,i){let r,n,a,o,l=navigator.userAgent.toLowerCase(),d=i,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((e[t+2]&192)>>>6)+1;let h=(e[t+2]&60)>>>2;if(h>c.length-1){let u=new Error(`invalid ADTS sampling index:${h}`);s.emit(p.ERROR,p.ERROR,{type:K.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:true,error:u,reason:u.message});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,S.log(`manifest codec:${i}, ADTS type:${r}, samplingIndex:${h}`),/firefox/i.test(l)?h>=6?(r=5,o=new Array(4),n=h-3):(r=2,o=new Array(2),n=h):l.indexOf("android")!==-1?(r=2,o=new Array(2),n=h):(r=5,o=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&h>=6?n=h-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(h>=6&&a===1||/vivaldi/i.test(l))||!i&&a===1)&&(r=2,o=new Array(2)),n=h)),o[0]=r<<3,o[0]|=(h&14)>>1,o[1]|=(h&1)<<7,o[1]|=a<<3,r===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:c[h],channelCount:a,codec:"mp4a.40."+r,manifestCodec:d}}function cf(s,e){return s[e]===255&&(s[e+1]&246)===240}function hf(s,e){return s[e+1]&1?7:9}function _d(s,e){return (s[e+3]&3)<<11|s[e+4]<<3|(s[e+5]&224)>>>5}function T0(s,e){return e+5<s.length}function Yn(s,e){return e+1<s.length&&cf(s,e)}function A0(s,e){return T0(s,e)&&cf(s,e)&&_d(s,e)<=s.length-e}function b0(s,e){if(Yn(s,e)){let t=hf(s,e);if(e+t>=s.length)return false;let i=_d(s,e);if(i<=t)return false;let r=e+i;return r===s.length||Yn(s,r)}return false}function uf(s,e,t,i,r){if(!s.samplerate){let n=v0(e,t,i,r);if(!n)return;s.config=n.config,s.samplerate=n.samplerate,s.channelCount=n.channelCount,s.codec=n.codec,s.manifestCodec=n.manifestCodec,S.log(`parsed codec:${s.codec}, rate:${n.samplerate}, channels:${n.channelCount}`);}}function ff(s){return 1024*9e4/s}function y0(s,e){let t=hf(s,e);if(e+t<=s.length){let i=_d(s,e)-t;if(i>0)return {headerLength:t,frameLength:i}}}function mf(s,e,t,i,r){let n=ff(s.samplerate),a=i+r*n,o=y0(e,t),l;if(o){let{frameLength:h,headerLength:u}=o,f=u+h,m=Math.max(0,t+f-e.length);m?(l=new Uint8Array(f-u),l.set(e.subarray(t+u,e.length),0)):l=e.subarray(t+u,t+f);let g={unit:l,pts:a};return m||s.samples.push(g),{sample:g,length:f,missing:m}}let d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}var bn=null,S0=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],_0=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],x0=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],I0=[0,1,1,4];function gf(s,e,t,i,r){if(t+24>e.length)return;let n=pf(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=i+r*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return s.config=[],s.channelCount=n.channelCount,s.samplerate=n.sampleRate,s.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function pf(s,e){let t=s[e+1]>>3&3,i=s[e+1]>>1&3,r=s[e+2]>>4&15,n=s[e+2]>>2&3;if(t!==1&&r!==0&&r!==15&&n!==3){let a=s[e+2]>>1&1,o=s[e+3]>>6,l=t===3?3-i:i===3?3:4,d=S0[l*14+r-1]*1e3,h=_0[(t===3?0:t===2?1:2)*3+n],u=o===3?1:2,f=x0[t][i],m=I0[i],g=f*8*m,E=Math.floor(f*d/h+a)*m;if(bn===null){let b=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);bn=b?parseInt(b[1]):0;}return !!bn&&bn<=87&&i===2&&d>=224e3&&o===0&&(s[e+3]=s[e+3]|128),{sampleRate:h,channelCount:u,frameLength:E,samplesPerFrame:g}}}function xd(s,e){return s[e]===255&&(s[e+1]&224)===224&&(s[e+1]&6)!==0}function Ef(s,e){return e+1<s.length&&xd(s,e)}function L0(s,e){return xd(s,e)&&4<=s.length-e}function vf(s,e){if(e+1<s.length&&xd(s,e)){let i=pf(s,e),r=4;i!=null&&i.frameLength&&(r=i.frameLength);let n=e+r;return n===s.length||Ef(s,n)}return false}var wl=class extends zs{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t;}resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0};}static probe(e){if(!e)return false;let t=Gs(e,0),i=t?.length||0;if(vf(e,i))return false;for(let r=e.length;i<r;i++)if(b0(e,i))return S.log("ADTS sync word found !"),true;return false}canParse(e,t){return A0(e,t)}appendFrame(e,t,i){uf(e,this.observer,t,i,e.manifestCodec);let r=mf(e,t,i,this.basePTS,this.frameIndex);if(r&&r.missing===0)return r}},R0=/\/emsg[-/]ID3/i,Ml=class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t;}resetTimeStamp(){}resetInitSegment(e,t,i,r){let n=this.videoTrack=Ot("video",1),a=this.audioTrack=Ot("audio",1),o=this.txtTrack=Ot("text",1);if(this.id3Track=Ot("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=zu(e);if(l.video){let{id:d,timescale:c,codec:h}=l.video;n.id=d,n.timescale=o.timescale=c,n.codec=h;}if(l.audio){let{id:d,timescale:c,codec:h}=l.audio;a.id=d,a.timescale=c,a.codec=h;}o.id=Wu.text,n.sampleDuration=0,n.duration=a.duration=r;}resetContiguity(){this.remainderData=null;}static probe(e){return np(e)}demux(e,t){this.timeOffset=t;let i=e,r=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=st(this.remainderData,e));let o=fp(i);this.remainderData=o.remainder,r.samples=o.valid||new Uint8Array;}else r.samples=i;let a=this.extractID3Track(r,t);return n.samples=Qh(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let r=this.extractID3Track(t,this.timeOffset);return i.samples=Qh(e,t),{videoTrack:t,audioTrack:Ot(),id3Track:r,textTrack:Ot()}}extractID3Track(e,t){let i=this.id3Track;if(e.samples.length){let r=j(e.samples,["emsg"]);r&&r.forEach(n=>{let a=pp(n);if(R0.test(a.schemeIdUri)){let o=F(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale,l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);let d=a.payload;i.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:gt.emsg,duration:l});}});}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},Tf=(s,e)=>{let t=0,i=5;e+=i;let r=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=s[e];let o=Math.min(i,8),l=8-o;n[0]=4278190080>>>24+l<<l,r[0]=(a[0]&n[0])>>l,t=t?t<<o|r[0]:r[0],e+=1,i-=o;}return t},Pl=class extends zs{constructor(e){super(),this.observer=void 0,this.observer=e;}resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0};}canParse(e,t){return t+64<e.length}appendFrame(e,t,i){let r=Af(e,t,i,this.basePTS,this.frameIndex);if(r!==-1)return {sample:e.samples[e.samples.length-1],length:r,missing:0}}static probe(e){if(!e)return false;let t=Gs(e,0);if(!t)return false;let i=t.length;return e[i]===11&&e[i+1]===119&&yd(t)!==void 0&&Tf(e,i)<16}};function Af(s,e,t,i,r){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return -1;let n=e[t+4]>>6;if(n>=3)return -1;let o=[48e3,44100,32e3][n],l=e[t+4]&63,c=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][l*3+n]*2;if(t+c>e.length)return -1;let h=e[t+6]>>5,u=0;h===2?u+=2:(h&1&&h!==1&&(u+=2),h&4&&(u+=2));let f=(e[t+6]<<8|e[t+7])>>12-u&1,g=[2,1,2,3,3,4,4,5][h]+f,E=e[t+5]>>3,v=e[t+5]&7,A=new Uint8Array([n<<6|E<<1|v>>2,(v&3)<<6|h<<3|f<<2|l>>4,l<<4&224]),b=1536/o*9e4,L=i+r*b,y=e.subarray(t,t+c);return s.config=A,s.channelCount=g,s.samplerate=o,s.samples.push({unit:y,pts:L}),c}var Ol=class{constructor(){this.VideoSample=null;}createVideoSample(e,t,i,r){return {key:e,frame:false,pts:t,dts:i,units:[],debug:r,length:0}}getLastNalUnit(e){var t;let i=this.VideoSample,r;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){let n=i.units;r=n[n.length-1];}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){let i=t.samples,r=i.length;if(r){let n=i[r-1];e.pts=n.pts,e.dts=n.dts;}else {t.dropped++;return}}t.samples.push(e);}e.debug.length&&S.log(e.pts+"/"+e.dts+":"+e.debug);}},qn=class{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0;}loadWord(){let e=this.data,t=this.bytesAvailable,i=e.byteLength-t,r=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");r.set(e.subarray(i,i+n)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n;}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e);}readBits(e){let t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(e>32&&S.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!==0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ());}skipEG(){this.skipBits(1+this.skipLZ());}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,i=8,r;for(let n=0;n<e;n++)i!==0&&(r=this.readEG(),i=(t+r+256)%256),t=i===0?t:i;}readSPS(){let e=0,t=0,i=0,r=0,n,a,o,l=this.readUByte.bind(this),d=this.readBits.bind(this),c=this.readUEG.bind(this),h=this.readBoolean.bind(this),u=this.skipBits.bind(this),f=this.skipEG.bind(this),m=this.skipUEG.bind(this),g=this.skipScalingList.bind(this);l();let E=l();if(d(5),u(3),l(),m(),E===100||E===110||E===122||E===244||E===44||E===83||E===86||E===118||E===128){let D=c();if(D===3&&u(1),m(),m(),u(1),h())for(a=D!==3?8:12,o=0;o<a;o++)h()&&(o<6?g(16):g(64));}m();let v=c();if(v===0)c();else if(v===1)for(u(1),f(),f(),n=c(),o=0;o<n;o++)f();m(),u(1);let A=c(),b=c(),L=d(1);L===0&&u(1),u(1),h()&&(e=c(),t=c(),i=c(),r=c());let y=[1,1];if(h()&&h())switch(l()){case 1:y=[1,1];break;case 2:y=[12,11];break;case 3:y=[10,11];break;case 4:y=[16,11];break;case 5:y=[40,33];break;case 6:y=[24,11];break;case 7:y=[20,11];break;case 8:y=[32,11];break;case 9:y=[80,33];break;case 10:y=[18,11];break;case 11:y=[15,11];break;case 12:y=[64,33];break;case 13:y=[160,99];break;case 14:y=[4,3];break;case 15:y=[3,2];break;case 16:y=[2,1];break;case 255:{y=[l()<<8|l(),l()<<8|l()];break}}return {width:Math.ceil((A+1)*16-e*2-t*2),height:(2-L)*(b+1)*16-(L?2:4)*(i+r),pixelRatio:y}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},Nl=class extends Ol{parseAVCPES(e,t,i,r,n){let a=this.parseAVCNALu(e,i.data),o=this.VideoSample,l,d=false;i.data=null,o&&a.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(false,i.pts,i.dts,"")),a.forEach(c=>{var h;switch(c.type){case 1:{let g=false;l=true;let E=c.data;if(d&&E.length>4){let v=new qn(E).readSliceType();(v===2||v===4||v===7||v===9)&&(g=true);}if(g){var u;(u=o)!=null&&u.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null);}o||(o=this.VideoSample=this.createVideoSample(true,i.pts,i.dts,"")),o.frame=true,o.key=g;break}case 5:l=true,(h=o)!=null&&h.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(true,i.pts,i.dts,"")),o.key=true,o.frame=true;break;case 6:{l=true,ju(c.data,1,i.pts,t.samples);break}case 7:{var f,m;l=true,d=true;let g=c.data,v=new qn(g).readSPS();if(!e.sps||e.width!==v.width||e.height!==v.height||((f=e.pixelRatio)==null?void 0:f[0])!==v.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==v.pixelRatio[1]){e.width=v.width,e.height=v.height,e.pixelRatio=v.pixelRatio,e.sps=[g],e.duration=n;let A=g.subarray(1,4),b="avc1.";for(let L=0;L<3;L++){let y=A[L].toString(16);y.length<2&&(y="0"+y),b+=y;}e.codec=b;}break}case 8:l=true,e.pps=[c.data];break;case 9:l=true,e.audFound=true,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(false,i.pts,i.dts,"");break;case 12:l=true;break;default:l=false,o&&(o.debug+="unknown NAL "+c.type+" ");break}o&&l&&o.units.push(c);}),r&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null);}parseAVCNALu(e,t){let i=t.byteLength,r=e.naluState||0,n=r,a=[],o=0,l,d,c,h=-1,u=0;for(r===-1&&(h=0,u=t[0]&31,r=0,o=1);o<i;){if(l=t[o++],!r){r=l?0:1;continue}if(r===1){r=l?0:2;continue}if(!l)r=3;else if(l===1){if(d=o-r-1,h>=0){let f={data:t.subarray(h,d),type:u};a.push(f);}else {let f=this.getLastNalUnit(e.samples);f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d>0&&(f.data=st(f.data,t.subarray(0,d)),f.state=0));}o<i?(c=t[o]&31,h=o,u=c,r=0):r=-1;}else r=0;}if(h>=0&&r>=0){let f={data:t.subarray(h,i),type:u,state:r};a.push(f);}if(a.length===0){let f=this.getLastNalUnit(e.samples);f&&(f.data=st(f.data,t));}return e.naluState=r,a}},Fl=class{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Ys(t,{removePKCS7Padding:false});}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,i){let r=e[t].unit;if(r.length<=16)return;let n=r.subarray(16,r.length-r.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{let l=new Uint8Array(o);r.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i);});}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t),r=0;for(let n=32;n<e.length-16;n+=160,r+=16)i.set(e.subarray(n,n+16),r);return i}getAvcDecryptedUnit(e,t){let i=new Uint8Array(t),r=0;for(let n=32;n<e.length-16;n+=160,r+=16)e.set(i.subarray(r,r+16),n);return e}decryptAvcSample(e,t,i,r,n){let a=Qu(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,r);});}decryptAvcSamples(e,t,i,r){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){r();return}let n=e[t].units;for(;!(i>=n.length);i++){let a=n[i];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,i,r,a),!this.decrypter.isSync()))return}}}},we=188,Ul=class s{constructor(e,t,i){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=false,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.videoParser=new Nl;}static probe(e){let t=s.syncOffset(e);return t>0&&S.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){let t=e.length,i=Math.min(we*5,t-we)+1,r=0;for(;r<i;){let n=false,a=-1,o=0;for(let l=r;l<t;l+=we)if(e[l]===71&&(t-l===we||e[l+we]===71)){if(o++,a===-1&&(a=l,a!==0&&(i=Math.min(a+we*99,e.length-we)+1)),n||(n=Bl(e,l)===0),n&&o>1&&(a===0&&o>2||l+we>i))return a}else {if(o)return -1;break}r++;}return -1}static createTrack(e,t){return {container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Wu[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,r){this.pmtParsed=false,this._pmtId=-1,this._videoTrack=s.createTrack("video"),this._audioTrack=s.createTrack("audio",r),this._id3Track=s.createTrack("id3"),this._txtTrack=s.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,this._duration=r;}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null;}demux(e,t,i=false,r=false){i||(this.sampleAes=null);let n,a=this._videoTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack,c=a.pid,h=a.pesData,u=o.pid,f=l.pid,m=o.pesData,g=l.pesData,E=null,v=this.pmtParsed,A=this._pmtId,b=e.length;if(this.remainderData&&(e=st(this.remainderData,e),b=e.length,this.remainderData=null),b<we&&!r)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let L=Math.max(0,s.syncOffset(e));b-=(b-L)%we,b<e.byteLength&&!r&&(this.remainderData=new Uint8Array(e.buffer,b,e.buffer.byteLength-b));let y=0;for(let I=L;I<b;I+=we)if(e[I]===71){let k=!!(e[I+1]&64),P=Bl(e,I),R=(e[I+3]&48)>>4,w;if(R>1){if(w=I+5+e[I+4],w===I+we)continue}else w=I+4;switch(P){case c:k&&(h&&(n=Xi(h))&&this.videoParser.parseAVCPES(a,d,n,false,this._duration),h={data:[],size:0}),h&&(h.data.push(e.subarray(w,I+we)),h.size+=I+we-w);break;case u:if(k){if(m&&(n=Xi(m)))switch(o.segmentCodec){case "aac":this.parseAACPES(o,n);break;case "mp3":this.parseMPEGPES(o,n);break;case "ac3":this.parseAC3PES(o,n);break}m={data:[],size:0};}m&&(m.data.push(e.subarray(w,I+we)),m.size+=I+we-w);break;case f:k&&(g&&(n=Xi(g))&&this.parseID3PES(l,n),g={data:[],size:0}),g&&(g.data.push(e.subarray(w,I+we)),g.size+=I+we-w);break;case 0:k&&(w+=e[w]+1),A=this._pmtId=D0(e,w);break;case A:{k&&(w+=e[w]+1);let X=C0(e,w,this.typeSupported,i,this.observer);c=X.videoPid,c>0&&(a.pid=c,a.segmentCodec=X.segmentVideoCodec),u=X.audioPid,u>0&&(o.pid=u,o.segmentCodec=X.segmentAudioCodec),f=X.id3Pid,f>0&&(l.pid=f),E!==null&&!v&&(S.warn(`MPEG-TS PMT found at ${I} after unknown PID '${E}'. Backtracking to sync byte @${L} to parse all TS packets.`),E=null,I=L-188),v=this.pmtParsed=true;break}case 17:case 8191:break;default:E=P;break}}else y++;y>0&&zn(this.observer,new Error(`Found ${y} TS packet/s that do not start with 0x47`)),a.pesData=h,o.pesData=m,l.pesData=g;let D={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return r&&this.extractRemainingSamples(D),D}flush(){let{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,false,true):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){let{audioTrack:t,videoTrack:i,id3Track:r,textTrack:n}=e,a=i.pesData,o=t.pesData,l=r.pesData,d;if(a&&(d=Xi(a))?(this.videoParser.parseAVCPES(i,n,d,true,this._duration),i.pesData=null):i.pesData=a,o&&(d=Xi(o))){switch(t.segmentCodec){case "aac":this.parseAACPES(t,d);break;case "mp3":this.parseMPEGPES(t,d);break;case "ac3":this.parseAC3PES(t,d);break}t.pesData=null;}else o!=null&&o.size&&S.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=Xi(l))?(this.parseID3PES(r,d),r.pesData=null):r.pesData=l;}demuxSampleAes(e,t,i){let r=this.demux(e,i,true,!this.config.progressive),n=this.sampleAes=new Fl(this.observer,this.config,t);return this.decrypt(r,n)}decrypt(e,t){return new Promise(i=>{let{audioTrack:r,videoTrack:n}=e;r.samples&&r.segmentCodec==="aac"?t.decryptAacSamples(r.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{i(e);}):i(e);}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{i(e);});})}destroy(){this._duration=0;}parseAACPES(e,t){let i=0,r=this.aacOverFlow,n=t.data;if(r){this.aacOverFlow=null;let h=r.missing,u=r.sample.unit.byteLength;if(h===-1)n=st(r.sample.unit,n);else {let f=u-h;r.sample.unit.set(n.subarray(0,h),f),e.samples.push(r.sample),i=r.missing;}}let a,o;for(a=i,o=n.length;a<o-1&&!Yn(n,a);a++);if(a!==i){let h,u=a<o-1;if(u?h=`AAC PES did not start with ADTS header,offset:${a}`:h="No ADTS header found in AAC PES",zn(this.observer,new Error(h),u),!u)return}uf(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(r){let h=ff(e.samplerate);l=r.sample.pts+h;}else {S.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,c;for(;a<o;)if(c=mf(e,n,a,l,d),a+=c.length,c.missing){this.aacOverFlow=c;break}else for(d++;a<o-1&&!Yn(n,a);a++);}parseMPEGPES(e,t){let i=t.data,r=i.length,n=0,a=0,o=t.pts;if(o===void 0){S.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<r;)if(Ef(i,a)){let l=gf(e,i,a,o,n);if(l)a+=l.length,n++;else break}else a++;}parseAC3PES(e,t){{let i=t.data,r=t.pts;if(r===void 0){S.warn("[tsdemuxer]: AC3 PES unknown PTS");return}let n=i.length,a=0,o=0,l;for(;o<n&&(l=Af(e,i,o,r,a++))>0;)o+=l;}}parseID3PES(e,t){if(t.pts===void 0){S.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let i=_e({},t,{type:this._videoTrack?gt.emsg:gt.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i);}};function Bl(s,e){return ((s[e+1]&31)<<8)+s[e+2]}function D0(s,e){return (s[e+10]&31)<<8|s[e+11]}function C0(s,e,t,i,r){let n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=(s[e+1]&15)<<8|s[e+2],o=e+3+a-4,l=(s[e+10]&15)<<8|s[e+11];for(e+=12+l;e<o;){let d=Bl(s,e),c=(s[e+3]&15)<<8|s[e+4];switch(s[e]){case 207:if(!i){el("ADTS AAC");break}case 15:n.audioPid===-1&&(n.audioPid=d);break;case 21:n.id3Pid===-1&&(n.id3Pid=d);break;case 219:if(!i){el("H.264");break}case 27:n.videoPid===-1&&(n.videoPid=d,n.segmentVideoCodec="avc");break;case 3:case 4:!t.mpeg&&!t.mp3?S.log("MPEG audio found, not supported in this browser"):n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="mp3");break;case 193:if(!i){el("AC-3");break}case 129:t.ac3?n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="ac3"):S.log("AC-3 audio found, not supported in this browser");break;case 6:if(n.audioPid===-1&&c>0){let h=e+5,u=c;for(;u>2;){switch(s[h]){case 106:t.ac3!==true?S.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=d,n.segmentAudioCodec="ac3");break}let m=s[h+1]+2;h+=m,u-=m;}}break;case 194:case 135:return zn(r,new Error("Unsupported EC-3 in M2TS found")),n;case 36:return zn(r,new Error("Unsupported HEVC in M2TS found")),n}e+=c+5;}return n}function zn(s,e,t){S.warn(`parsing error: ${e.message}`),s.emit(p.ERROR,p.ERROR,{type:K.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:false,levelRetry:t,error:e,reason:e.message});}function el(s){S.log(`${s} with AES-128-CBC encryption found in unencrypted stream`);}function Xi(s){let e=0,t,i,r,n,a,o=s.data;if(!s||s.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=st(o[0],o[1]),o.splice(1,1);if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(i=(t[4]<<8)+t[5],i&&i>s.size-6)return null;let d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(S.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),r=t[8];let c=r+9;if(s.size<=c)return null;s.size-=c;let h=new Uint8Array(s.size);for(let u=0,f=o.length;u<f;u++){t=o[u];let m=t.byteLength;if(c)if(c>m){c-=m;continue}else t=t.subarray(c),m-=c,c=0;h.set(t,e),e+=m;}return i&&(i-=r+3),{data:h,pts:n,dts:a,len:i}}return null}var $l=class extends zs{resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0};}static probe(e){if(!e)return false;let t=Gs(e,0),i=t?.length||0;if(t&&e[i]===11&&e[i+1]===119&&yd(t)!==void 0&&Tf(e,i)<=16)return false;for(let r=e.length;i<r;i++)if(vf(e,i))return S.log("MPEG Audio sync word found !"),true;return false}canParse(e,t){return L0(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return gf(e,t,i,this.basePTS,this.frameIndex)}},Xn=class{static getSilentFrame(e,t){switch(e){case "mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}},Qt=Math.pow(2,32)-1,Ie=class s{static init(){s.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in s.types)s.types.hasOwnProperty(e)&&(s.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);s.HDLR_TYPES={video:t,audio:i};let r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);s.STTS=s.STSC=s.STCO=n,s.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),s.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),s.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),s.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);s.FTYP=s.box(s.types.ftyp,a,l,a,o),s.DINF=s.box(s.types.dinf,s.box(s.types.dref,r));}static box(e,...t){let i=8,r=t.length,n=r;for(;r--;)i+=t[r].byteLength;let a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=i&255,a.set(e,4),r=0,i=8;r<n;r++)a.set(t[r],i),i+=t[r].byteLength;return a}static hdlr(e){return s.box(s.types.hdlr,s.HDLR_TYPES[e])}static mdat(e){return s.box(s.types.mdat,e)}static mdhd(e,t){t*=e;let i=Math.floor(t/(Qt+1)),r=Math.floor(t%(Qt+1));return s.box(s.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))}static mdia(e){return s.box(s.types.mdia,s.mdhd(e.timescale,e.duration),s.hdlr(e.type),s.minf(e))}static mfhd(e){return s.box(s.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?s.box(s.types.minf,s.box(s.types.smhd,s.SMHD),s.DINF,s.stbl(e)):s.box(s.types.minf,s.box(s.types.vmhd,s.VMHD),s.DINF,s.stbl(e))}static moof(e,t,i){return s.box(s.types.moof,s.mfhd(e),s.traf(i,t))}static moov(e){let t=e.length,i=[];for(;t--;)i[t]=s.trak(e[t]);return s.box.apply(null,[s.types.moov,s.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(s.mvex(e)))}static mvex(e){let t=e.length,i=[];for(;t--;)i[t]=s.trex(e[t]);return s.box.apply(null,[s.types.mvex,...i])}static mvhd(e,t){t*=e;let i=Math.floor(t/(Qt+1)),r=Math.floor(t%(Qt+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,r>>24,r>>16&255,r>>8&255,r&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return s.box(s.types.mvhd,n)}static sdtp(e){let t=e.samples||[],i=new Uint8Array(4+t.length),r,n;for(r=0;r<t.length;r++)n=t[r].flags,i[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return s.box(s.types.sdtp,i)}static stbl(e){return s.box(s.types.stbl,s.stsd(e),s.box(s.types.stts,s.STTS),s.box(s.types.stsc,s.STSC),s.box(s.types.stsz,s.STSZ),s.box(s.types.stco,s.STCO))}static avc1(e){let t=[],i=[],r,n,a;for(r=0;r<e.sps.length;r++)n=e.sps[r],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(r=0;r<e.pps.length;r++)n=e.pps[r],a=n.byteLength,i.push(a>>>8&255),i.push(a&255),i=i.concat(Array.prototype.slice.call(n));let o=s.box(s.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),l=e.width,d=e.height,c=e.pixelRatio[0],h=e.pixelRatio[1];return s.box(s.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,l&255,d>>8&255,d&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,c&255,h>>24,h>>16&255,h>>8&255,h&255])))}static esds(e){let t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){let t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return s.box(s.types.mp4a,s.audioStsd(e),s.box(s.types.esds,s.esds(e)))}static mp3(e){return s.box(s.types[".mp3"],s.audioStsd(e))}static ac3(e){return s.box(s.types["ac-3"],s.audioStsd(e),s.box(s.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?s.box(s.types.stsd,s.STSD,s.mp3(e)):e.segmentCodec==="ac3"?s.box(s.types.stsd,s.STSD,s.ac3(e)):s.box(s.types.stsd,s.STSD,s.mp4a(e)):s.box(s.types.stsd,s.STSD,s.avc1(e))}static tkhd(e){let t=e.id,i=e.duration*e.timescale,r=e.width,n=e.height,a=Math.floor(i/(Qt+1)),o=Math.floor(i%(Qt+1));return s.box(s.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,r&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){let i=s.sdtp(e),r=e.id,n=Math.floor(t/(Qt+1)),a=Math.floor(t%(Qt+1));return s.box(s.types.traf,s.box(s.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),s.box(s.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),s.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,s.box(s.types.trak,s.tkhd(e),s.mdia(e))}static trex(e){let t=e.id;return s.box(s.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let i=e.samples||[],r=i.length,n=12+16*r,a=new Uint8Array(n),o,l,d,c,h,u;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<r;o++)l=i[o],d=l.duration,c=l.size,h=l.flags,u=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,h.degradPrio&61440,h.degradPrio&15,u>>>24&255,u>>>16&255,u>>>8&255,u&255],12+16*o);return s.box(s.types.trun,a)}static initSegment(e){s.types||s.init();let t=s.moov(e);return st(s.FTYP,t)}};Ie.types=void 0;Ie.HDLR_TYPES=void 0;Ie.STTS=void 0;Ie.STSC=void 0;Ie.STCO=void 0;Ie.STSZ=void 0;Ie.VMHD=void 0;Ie.SMHD=void 0;Ie.STSD=void 0;Ie.FTYP=void 0;Ie.DINF=void 0;var bf=9e4;function Id(s,e,t=1,i=false){let r=s*e*t;return i?Math.round(r):r}function k0(s,e,t=1,i=false){return Id(s,e,1/t,i)}function Ns(s,e=false){return Id(s,1e3,1/bf,e)}function w0(s,e=1){return Id(s,bf,1/e)}var M0=10*1e3,_u=1024,P0=1152,O0=1536,ji=null,tl=null,es=class{constructor(e,t,i,r=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=false,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=false,this.isVideoContiguous=false,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=false,ji===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ji=a?parseInt(a[1]):0;}if(tl===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);tl=n?parseInt(n[1]):0;}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null;}resetTimeStamp(e){S.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e;}resetNextTimestamp(){S.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=false,this.isAudioContiguous=false;}resetInitSegment(){S.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=false,this.videoTrackConfig=void 0;}getVideoStartPts(e){let t=false,i=e.reduce((r,n)=>{let a=n.pts-r;return a<-4294967296?(t=true,it(r,n.pts)):a>0?r:n.pts},e[0].pts);return t&&S.debug("PTS rollover detected"),i}remux(e,t,i,r,n,a,o,l){let d,c,h,u,f,m,g=n,E=n,v=e.pid>-1,A=t.pid>-1,b=t.samples.length,L=e.samples.length>0,y=o&&b>0||b>1;if((!v||L)&&(!A||y)||this.ISGenerated||o){if(this.ISGenerated){var I,k,P,R;let z=this.videoTrackConfig;z&&(t.width!==z.width||t.height!==z.height||((I=t.pixelRatio)==null?void 0:I[0])!==((k=z.pixelRatio)==null?void 0:k[0])||((P=t.pixelRatio)==null?void 0:P[1])!==((R=z.pixelRatio)==null?void 0:R[1]))&&this.resetInitSegment();}else h=this.generateIS(e,t,n,a);let w=this.isVideoContiguous,X=-1,O;if(y&&(X=N0(t.samples),!w&&this.config.forceKeyFrameOnDiscontinuity))if(m=true,X>0){S.warn(`[mp4-remuxer]: Dropped ${X} out of ${b} video samples due to a missing keyframe`);let z=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(X),t.dropped+=X,E+=(t.samples[0].pts-z)/t.inputTimeScale,O=E;}else X===-1&&(S.warn(`[mp4-remuxer]: No keyframe found out of ${b} video samples`),m=false);if(this.ISGenerated){if(L&&y){let z=this.getVideoStartPts(t.samples),V=(it(e.samples[0].pts,z)-z)/t.inputTimeScale;g+=Math.max(0,V),E+=Math.max(0,-V);}if(L){if(e.samplerate||(S.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(e,t,n,a)),c=this.remuxAudio(e,g,this.isAudioContiguous,a,A||y||l===H.AUDIO?E:void 0),y){let z=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(S.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,E,w,z);}}else y&&(d=this.remuxVideo(t,E,w,0));d&&(d.firstKeyFrame=X,d.independent=X!==-1,d.firstKeyFramePTS=O);}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(f=yf(i,n,this._initPTS,this._initDTS)),r.samples.length&&(u=Sf(r,n,this._initPTS))),{audio:c,video:d,initSegment:h,independent:m,text:u,id3:f}}generateIS(e,t,i,r){let n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS,c=!d||r,h="audio/mp4",u,f,m;if(c&&(u=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case "mp3":o.mpeg?(h="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case "ac3":e.codec="ac-3";break}l.audio={id:"audio",container:h,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):Ie.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(m=e.inputTimeScale,!d||m!==d.timescale?u=f=n[0].pts-Math.round(m*i):c=false);}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Ie.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(m=t.inputTimeScale,!d||m!==d.timescale){let g=this.getVideoStartPts(a),E=Math.round(m*i);f=Math.min(f,it(a[0].dts,g)-E),u=Math.min(u,g-E);}else c=false;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio};}if(Object.keys(l).length)return this.ISGenerated=true,c?(this._initPTS={baseTime:u,timescale:m},this._initDTS={baseTime:f,timescale:m}):u=m=void 0,{tracks:l,initPTS:u,timescale:m}}remuxVideo(e,t,i,r){let n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS,c=this.nextAvcDts,h=8,u=this.videoSampleDuration,f,m,g=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY,v=false;if(!i||c===null){let U=t*n,N=a[0].pts-it(a[0].dts,a[0].pts);ji&&c!==null&&Math.abs(U-N-c)<15e3?i=true:c=U-N;}let A=d.baseTime*n/d.timescale;for(let U=0;U<l;U++){let N=a[U];N.pts=it(N.pts-A,c),N.dts=it(N.dts-A,c),N.dts<a[U>0?U-1:U].dts&&(v=true);}v&&a.sort(function(U,N){let ee=U.dts-N.dts,Q=U.pts-N.pts;return ee||Q}),f=a[0].dts,m=a[a.length-1].dts;let b=m-f,L=b?Math.round(b/(l-1)):u||e.inputTimeScale/30;if(i){let U=f-c,N=U>L,ee=U<-1;if((N||ee)&&(N?S.warn(`AVC: ${Ns(U,true)} ms (${U}dts) hole between fragments detected at ${t.toFixed(3)}`):S.warn(`AVC: ${Ns(-U,true)} ms (${U}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!ee||c>=a[0].pts||ji)){f=c;let Q=a[0].pts-U;if(N)a[0].dts=f,a[0].pts=Q;else for(let se=0;se<a.length&&!(a[se].dts>Q);se++)a[se].dts-=U,a[se].pts-=U;S.log(`Video: Initial PTS/DTS adjusted: ${Ns(Q,true)}/${Ns(f,true)}, delta: ${Ns(U,true)} ms`);}}f=Math.max(0,f);let y=0,D=0,I=f;for(let U=0;U<l;U++){let N=a[U],ee=N.units,Q=ee.length,se=0;for(let Se=0;Se<Q;Se++)se+=ee[Se].data.length;D+=se,y+=Q,N.length=se,N.dts<I?(N.dts=I,I+=L/4|0||1):I=N.dts,g=Math.min(N.pts,g),E=Math.max(N.pts,E);}m=a[l-1].dts;let k=D+4*y+8,P;try{P=new Uint8Array(k);}catch(U){this.observer.emit(p.ERROR,p.ERROR,{type:K.MUX_ERROR,details:x.REMUX_ALLOC_ERROR,fatal:false,error:U,bytes:k,reason:`fail allocating video mdat ${k}`});return}let R=new DataView(P.buffer);R.setUint32(0,k),P.set(Ie.types.mdat,4);let w=false,X=Number.POSITIVE_INFINITY,O=Number.POSITIVE_INFINITY,z=Number.NEGATIVE_INFINITY,q=Number.NEGATIVE_INFINITY;for(let U=0;U<l;U++){let N=a[U],ee=N.units,Q=0;for(let Le=0,Ne=ee.length;Le<Ne;Le++){let Je=ee[Le],as=Je.data,da=Je.data.byteLength;R.setUint32(h,da),h+=4,P.set(as,h),h+=da,Q+=4+da;}let se;if(U<l-1)u=a[U+1].dts-N.dts,se=a[U+1].pts-N.pts;else {let Le=this.config,Ne=U>0?N.dts-a[U-1].dts:L;if(se=U>0?N.pts-a[U-1].pts:L,Le.stretchShortVideoTrack&&this.nextAudioPts!==null){let Je=Math.floor(Le.maxBufferHole*n),as=(r?g+r*n:this.nextAudioPts)-N.pts;as>Je?(u=as-Ne,u<0?u=Ne:w=true,S.log(`[mp4-remuxer]: It is approximately ${as/90} ms to the next segment; using duration ${u/90} ms for the last video frame.`)):u=Ne;}else u=Ne;}let Se=Math.round(N.pts-N.dts);X=Math.min(X,u),z=Math.max(z,u),O=Math.min(O,se),q=Math.max(q,se),o.push(new jn(N.key,u,Q,Se));}if(o.length){if(ji){if(ji<70){let U=o[0].flags;U.dependsOn=2,U.isNonSync=0;}}else if(tl&&q-O<z-X&&L/z<.025&&o[0].cts===0){S.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let U=f;for(let N=0,ee=o.length;N<ee;N++){let Q=U+o[N].duration,se=U+o[N].cts;if(N<ee-1){let Se=Q+o[N+1].cts;o[N].duration=Se-se;}else o[N].duration=N?o[N-1].duration:L;o[N].cts=0,U=Q;}}}u=w||!u?L:u,this.nextAvcDts=c=m+u,this.videoSampleDuration=u,this.isVideoContiguous=true;let ae={data1:Ie.moof(e.sequenceNumber++,f,_e({},e,{samples:o})),data2:P,startPTS:g/n,endPTS:(E+u)/n,startDTS:f/n,endDTS:c/n,type:"video",hasAudio:false,hasVideo:true,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ae}getSamplesPerFrame(e){switch(e.segmentCodec){case "mp3":return P0;case "ac3":return O0;default:return _u}}remuxAudio(e,t,i,r,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=this.getSamplesPerFrame(e),c=d*l,h=this._initPTS,u=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=n!==void 0,g=e.samples,E=u?0:8,v=this.nextAudioPts||-1,A=t*a,b=h.baseTime*a/h.timescale;if(this.isAudioContiguous=i=i||g.length&&v>0&&(r&&Math.abs(A-v)<9e3||Math.abs(it(g[0].pts-b,A)-v)<20*c),g.forEach(function(V){V.pts=it(V.pts-b,A);}),!i||v<0){if(g=g.filter(V=>V.pts>=0),!g.length)return;n===0?v=0:r&&!m?v=Math.max(0,A):v=g[0].pts;}if(e.segmentCodec==="aac"){let V=this.config.maxAudioFramesDrift;for(let J=0,ae=v;J<g.length;J++){let U=g[J],N=U.pts,ee=N-ae,Q=Math.abs(1e3*ee/a);if(ee<=-V*c&&m)J===0&&(S.warn(`Audio frame @ ${(N/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*ee/a)} ms.`),this.nextAudioPts=v=ae=N);else if(ee>=V*c&&Q<M0&&m){let se=Math.round(ee/c);ae=N-se*c,ae<0&&(se--,ae+=c),J===0&&(this.nextAudioPts=v=ae),S.warn(`[mp4-remuxer]: Injecting ${se} audio frame @ ${(ae/a).toFixed(3)}s due to ${Math.round(1e3*ee/a)} ms gap.`);for(let Se=0;Se<se;Se++){let Le=Math.max(ae,0),Ne=Xn.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Ne||(S.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Ne=U.unit.subarray()),g.splice(J,0,{unit:Ne,pts:Le}),ae+=c,J++;}}U.pts=ae,ae+=c;}}let L=null,y=null,D,I=0,k=g.length;for(;k--;)I+=g[k].unit.byteLength;for(let V=0,J=g.length;V<J;V++){let ae=g[V],U=ae.unit,N=ae.pts;if(y!==null){let Q=f[V-1];Q.duration=Math.round((N-y)/l);}else if(i&&e.segmentCodec==="aac"&&(N=v),L=N,I>0){I+=E;try{D=new Uint8Array(I);}catch(Q){this.observer.emit(p.ERROR,p.ERROR,{type:K.MUX_ERROR,details:x.REMUX_ALLOC_ERROR,fatal:false,error:Q,bytes:I,reason:`fail allocating audio mdat ${I}`});return}u||(new DataView(D.buffer).setUint32(0,I),D.set(Ie.types.mdat,4));}else return;D.set(U,E);let ee=U.byteLength;E+=ee,f.push(new jn(true,d,ee,0)),y=N;}let P=f.length;if(!P)return;let R=f[f.length-1];this.nextAudioPts=v=y+l*R.duration;let w=u?new Uint8Array(0):Ie.moof(e.sequenceNumber++,L/l,_e({},e,{samples:f}));e.samples=[];let X=L/a,O=v/a,q={data1:w,data2:D,startPTS:X,endPTS:O,startDTS:X,endDTS:O,type:"audio",hasAudio:true,hasVideo:false,nb:P};return this.isAudioContiguous=true,q}remuxEmptyAudio(e,t,i,r){let n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,c=d.baseTime*9e4/d.timescale,h=(l!==null?l:r.startDTS*n)+c,u=r.endDTS*n+c,f=o*_u,m=Math.ceil((u-h)/f),g=Xn.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(S.warn("[mp4-remuxer]: remux empty Audio"),!g){S.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}let E=[];for(let v=0;v<m;v++){let A=h+v*f;E.push({unit:g,pts:A,dts:A});}return e.samples=E,this.remuxAudio(e,t,i,false)}};function it(s,e){let t;if(e===null)return s;for(e<s?t=-8589934592:t=8589934592;Math.abs(s-e)>4294967296;)s+=t;return s}function N0(s){for(let e=0;e<s.length;e++)if(s[e].key)return e;return -1}function yf(s,e,t,i){let r=s.samples.length;if(!r)return;let n=s.inputTimeScale;for(let o=0;o<r;o++){let l=s.samples[o];l.pts=it(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=it(l.dts-i.baseTime*n/i.timescale,e*n)/n;}let a=s.samples;return s.samples=[],{samples:a}}function Sf(s,e,t){let i=s.samples.length;if(!i)return;let r=s.inputTimeScale;for(let a=0;a<i;a++){let o=s.samples[a];o.pts=it(o.pts-t.baseTime*r/t.timescale,e*r)/r;}s.samples.sort((a,o)=>a.pts-o.pts);let n=s.samples;return s.samples=[],{samples:n}}var jn=class{constructor(e,t,i,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=i,this.cts=r,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1};}},Gl=class{constructor(){this.emitInitSegment=false,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null;}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null;}resetNextTimestamp(){this.lastEndTime=null;}resetInitSegment(e,t,i,r){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(lp(e,r)),this.emitInitSegment=true;}generateInitSegment(e){let{audioCodec:t,videoCodec:i}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let r=this.initData=zu(e);r.audio&&(t=xu(r.audio,ne.AUDIO)),r.video&&(i=xu(r.video,ne.VIDEO));let n={};r.audio&&r.video?n.audiovideo={container:"video/mp4",codec:t+","+i,initSegment:e,id:"main"}:r.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:r.video?n.video={container:"video/mp4",codec:i,initSegment:e,id:"main"}:S.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n;}remux(e,t,i,r,n,a){var o,l;let{initPTS:d,lastEndTime:c}=this,h={audio:void 0,video:void 0,text:r,id3:i,initSegment:void 0};F(c)||(c=this.lastEndTime=n||0);let u=t.samples;if(!(u!=null&&u.length))return h;let f={initPTS:void 0,timescale:1},m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(u),m=this.initData),!((l=m)!=null&&l.length))return S.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=false);let g=cp(u,m),E=dp(m,u),v=E===null?n:E;(F0(d,v,n,g)||f.timescale!==d.timescale&&a)&&(f.initPTS=v-n,d&&d.timescale===1&&S.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});let A=e?v-d.baseTime/d.timescale:c,b=A+g;up(m,u,d.baseTime/d.timescale),g>0?this.lastEndTime=b:(S.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let L=!!m.audio,y=!!m.video,D="";L&&(D+="audio"),y&&(D+="video");let I={data1:u,startPTS:A,startDTS:A,endPTS:b,endDTS:b,type:D,hasAudio:L,hasVideo:y,nb:1,dropped:0};return h.audio=I.type==="audio"?I:void 0,h.video=I.type!=="audio"?I:void 0,h.initSegment=f,h.id3=yf(i,n,d,d),r.samples.length&&(h.text=Sf(r,n,d)),h}};function F0(s,e,t,i){if(s===null)return true;let r=Math.max(i,1),n=e-s.baseTime/s.timescale;return Math.abs(n-t)>r}function xu(s,e){let t=s?.codec;if(t&&t.length>4)return t;if(e===ne.AUDIO){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return Un(t,false);let i="mp4a.40.5";return S.info(`Parsed audio codec "${t}" or audio object type not handled. Using "${i}"`),i}return S.warn(`Unhandled video codec "${t}"`),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}var Ht;try{Ht=self.performance.now.bind(self.performance);}catch{S.debug("Unable to use Performance API on this environment"),Ht=is?.Date.now;}var Dn=[{demux:Ml,remux:Gl},{demux:Ul,remux:es},{demux:wl,remux:es},{demux:$l,remux:es}];Dn.splice(2,0,{demux:Pl,remux:es});var Qn=class{constructor(e,t,i,r,n){this.async=false,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.vendor=r,this.id=n;}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset();}push(e,t,i,r){let n=i.transmuxing;n.executeStart=Ht();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;r&&(this.currentTransmuxState=r);let{contiguous:d,discontinuity:c,trackSwitch:h,accurateTimeOffset:u,timeOffset:f,initSegmentChange:m}=r||o,{audioCodec:g,videoCodec:E,defaultInitPts:v,duration:A,initSegmentData:b}=l,L=U0(a,t);if(L&&L.method==="AES-128"){let k=this.getDecrypter();if(k.isSync()){let P=k.softwareDecrypt(a,L.key.buffer,L.iv.buffer);if(i.part>-1&&(P=k.flush()),!P)return n.executeEnd=Ht(),il(i);a=new Uint8Array(P);}else return this.decryptionPromise=k.webCryptoDecrypt(a,L.key.buffer,L.iv.buffer).then(P=>{let R=this.push(P,null,i);return this.decryptionPromise=null,R}),this.decryptionPromise}let y=this.needsProbing(c,h);if(y){let k=this.configureTransmuxer(a);if(k)return S.warn(`[transmuxer] ${k.message}`),this.observer.emit(p.ERROR,p.ERROR,{type:K.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:false,error:k,reason:k.message}),n.executeEnd=Ht(),il(i)}(c||h||m||y)&&this.resetInitSegment(b,g,E,A,t),(c||m||y)&&this.resetInitialTimestamp(v),d||this.resetContiguity();let D=this.transmux(a,L,f,u,i),I=this.currentTransmuxState;return I.contiguous=true,I.discontinuity=false,I.trackSwitch=false,n.executeEnd=Ht(),D}flush(e){let t=e.transmuxing;t.executeStart=Ht();let{decrypter:i,currentTransmuxState:r,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));let a=[],{timeOffset:o}=r;if(i){let h=i.flush();h&&a.push(this.push(h,null,e));}let{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=Ht(),[il(e)];let c=l.flush(o);return Cn(c)?c.then(h=>(this.flushRemux(a,h,e),a)):(this.flushRemux(a,c,e),a)}flushRemux(e,t,i){let{audioTrack:r,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;S.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);let c=this.remuxer.remux(r,n,a,o,d,l,true,this.id);e.push({remuxResult:c,chunkMeta:i}),i.transmuxing.executeEnd=Ht();}resetInitialTimestamp(e){let{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e));}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp());}resetInitSegment(e,t,i,r,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,i,r),o.resetInitSegment(e,t,i,n));}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0);}transmux(e,t,i,r,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,i,r,n):a=this.transmuxUnencrypted(e,i,r,n),a}transmuxUnencrypted(e,t,i,r){let{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,false,!this.config.progressive);return {remuxResult:this.remuxer.remux(n,a,o,l,t,i,false,this.id),chunkMeta:r}}transmuxSampleAes(e,t,i,r,n){return this.demuxer.demuxSampleAes(e,t,i).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,i,r,false,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:i,typeSupported:r,vendor:n}=this,a;for(let u=0,f=Dn.length;u<f;u++){var o;if((o=Dn[u].demux)!=null&&o.probe(e)){a=Dn[u];break}}if(!a)return new Error("Failed to find demuxer by probing fragment data");let l=this.demuxer,d=this.remuxer,c=a.remux,h=a.demux;(!d||!(d instanceof c))&&(this.remuxer=new c(i,t,r,n)),(!l||!(l instanceof h))&&(this.demuxer=new h(i,t,r),this.probe=h.probe);}needsProbing(e,t){return !this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Ys(this.config)),e}};function U0(s,e){let t=null;return s.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var il=s=>({remuxResult:{},chunkMeta:s});function Cn(s){return "then"in s&&s.then instanceof Function}var Hl=class{constructor(e,t,i,r,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=r,this.defaultInitPts=n||null;}},Vl=class{constructor(e,t,i,r,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=r,this.timeOffset=n,this.initSegmentChange=a;}},_f={exports:{}};(function(s){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=false));function r(l,d,c){this.fn=l,this.context=d,this.once=c||false;}function n(l,d,c,h,u){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new r(c,h||l,u),m=t?t+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new i:delete l._events[d];}function o(){this._events=new i,this._eventsCount=0;}o.prototype.eventNames=function(){var d=[],c,h;if(this._eventsCount===0)return d;for(h in c=this._events)e.call(c,h)&&d.push(t?h.slice(1):h);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},o.prototype.listeners=function(d){var c=t?t+d:d,h=this._events[c];if(!h)return [];if(h.fn)return [h.fn];for(var u=0,f=h.length,m=new Array(f);u<f;u++)m[u]=h[u].fn;return m},o.prototype.listenerCount=function(d){var c=t?t+d:d,h=this._events[c];return h?h.fn?1:h.length:0},o.prototype.emit=function(d,c,h,u,f,m){var g=t?t+d:d;if(!this._events[g])return false;var E=this._events[g],v=arguments.length,A,b;if(E.fn){switch(E.once&&this.removeListener(d,E.fn,void 0,true),v){case 1:return E.fn.call(E.context),true;case 2:return E.fn.call(E.context,c),true;case 3:return E.fn.call(E.context,c,h),true;case 4:return E.fn.call(E.context,c,h,u),true;case 5:return E.fn.call(E.context,c,h,u,f),true;case 6:return E.fn.call(E.context,c,h,u,f,m),true}for(b=1,A=new Array(v-1);b<v;b++)A[b-1]=arguments[b];E.fn.apply(E.context,A);}else {var L=E.length,y;for(b=0;b<L;b++)switch(E[b].once&&this.removeListener(d,E[b].fn,void 0,true),v){case 1:E[b].fn.call(E[b].context);break;case 2:E[b].fn.call(E[b].context,c);break;case 3:E[b].fn.call(E[b].context,c,h);break;case 4:E[b].fn.call(E[b].context,c,h,u);break;default:if(!A)for(y=1,A=new Array(v-1);y<v;y++)A[y-1]=arguments[y];E[b].fn.apply(E[b].context,A);}}return true},o.prototype.on=function(d,c,h){return n(this,d,c,h,false)},o.prototype.once=function(d,c,h){return n(this,d,c,h,true)},o.prototype.removeListener=function(d,c,h,u){var f=t?t+d:d;if(!this._events[f])return this;if(!c)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===c&&(!u||m.once)&&(!h||m.context===h)&&a(this,f);else {for(var g=0,E=[],v=m.length;g<v;g++)(m[g].fn!==c||u&&!m[g].once||h&&m[g].context!==h)&&E.push(m[g]);E.length?this._events[f]=E.length===1?E[0]:E:a(this,f);}return this},o.prototype.removeAllListeners=function(d){var c;return d?(c=t?t+d:d,this._events[c]&&a(this,c)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,s.exports=o;})(_f);var B0=_f.exports,Ld=wg(B0),Zn=class{constructor(e,t,i,r){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;let n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=i,this.onFlush=r;let a=(d,c)=>{c=c||{},c.frag=this.frag,c.id=this.id,d===p.ERROR&&(this.error=c.error),this.hls.trigger(d,c);};this.observer=new Ld,this.observer.on(p.FRAG_DECRYPTED,a),this.observer.on(p.ERROR,a);let o=Ti(n.preferManagedMediaSource)||{isTypeSupported:()=>false},l={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:o.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&typeof Worker<"u"&&(n.workerPath||m0())){try{n.workerPath?(S.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=p0(n.workerPath)):(S.log(`injecting Web Worker for "${t}"`),this.workerContext=g0()),this.onwmsg=h=>this.onWorkerMessage(h);let{worker:c}=this.workerContext;c.addEventListener("message",this.onwmsg),c.onerror=h=>{let u=new Error(`${h.message} (${h.filename}:${h.lineno})`);n.enableWorker=!1,S.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(p.ERROR,{type:K.OTHER_ERROR,details:x.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:u});},c.postMessage({cmd:"init",typeSupported:l,vendor:"",id:t,config:JSON.stringify(n)});}catch(c){S.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.resetWorker(),this.error=null,this.transmuxer=new Qn(this.observer,l,n,"",t);}return}this.transmuxer=new Qn(this.observer,l,n,"",t);}resetWorker(){if(this.workerContext){let{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null;}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else {let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null);}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null;}push(e,t,i,r,n,a,o,l,d,c){var h,u;d.transmuxing.start=self.performance.now();let{transmuxer:f}=this,m=a?a.start:n.start,g=n.decryptdata,E=this.frag,v=!(E&&n.cc===E.cc),A=!(E&&d.level===E.level),b=E?d.sn-E.sn:-1,L=this.part?d.part-this.part.index:-1,y=b===0&&d.id>1&&d.id===E?.stats.chunkCount,D=!A&&(b===1||b===0&&(L===1||y&&L<=0)),I=self.performance.now();(A||b||n.stats.parsing.start===0)&&(n.stats.parsing.start=I),a&&(L||!D)&&(a.stats.parsing.start=I);let k=!(E&&((h=n.initSegment)==null?void 0:h.url)===((u=E.initSegment)==null?void 0:u.url)),P=new Vl(v,D,l,A,m,k);if(!D||v||k){S.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
|
|
1112
|
-
discontinuity: ${v}
|
|
1113
|
-
trackSwitch: ${A}
|
|
1114
|
-
contiguous: ${D}
|
|
1115
|
-
accurateTimeOffset: ${l}
|
|
1116
|
-
timeOffset: ${m}
|
|
1117
|
-
initSegmentChange: ${k}`);let R=new Hl(i,r,t,o,c);this.configureTransmuxer(R);}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:g,chunkMeta:d,state:P},e instanceof ArrayBuffer?[e]:[]);else if(f){let R=f.push(e,g,d,P);Cn(R)?(f.async=true,R.then(w=>{this.handleTransmuxComplete(w);}).catch(w=>{this.transmuxerError(w,d,"transmuxer-interface push error");})):(f.async=false,this.handleTransmuxComplete(R));}}flush(e){e.transmuxing.start=self.performance.now();let{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let i=t.flush(e);Cn(i)||t.async?(Cn(i)||(i=Promise.resolve(i)),i.then(n=>{this.handleFlushResult(n,e);}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error");})):this.handleFlushResult(i,e);}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(p.ERROR,{type:K.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:false,error:e,err:e,reason:i}));}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i);}),this.onFlush(t);}onWorkerMessage(e){let t=e.data;if(!(t!=null&&t.event)){S.warn(`worker message received with no ${t?"event name":"data"}`);return}let i=this.hls;if(this.hls)switch(t.event){case "init":{var r;let n=(r=this.workerContext)==null?void 0:r.objectURL;n&&self.URL.revokeObjectURL(n);break}case "transmuxComplete":{this.handleTransmuxComplete(t.data);break}case "flush":{this.onFlush(t.data);break}case "workerLog":S[t.data.logType]&&S[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,i.trigger(t.event,t.data);break}}}configureTransmuxer(e){let{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e);}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e);}};function xf(s,e){if(s.length!==e.length)return false;for(let t=0;t<s.length;t++)if(!ss(s[t].attrs,e[t].attrs))return false;return true}function ss(s,e,t){let i=s["STABLE-RENDITION-ID"];return i&&!t?i===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(r=>s[r]!==e[r])}function Kl(s,e){return e.label.toLowerCase()===s.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(s.lang||"").toLowerCase())}var Iu=100,Wl=class extends qs{constructor(e,t,i){super(e,t,i,"[audio-stream-controller]",H.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=false,this.bufferFlushed=false,this.cachedTrackLoadedData=null,this._registerListeners();}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null;}_registerListeners(){let{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(p.ERROR,this.onError,this),e.on(p.BUFFER_RESET,this.onBufferReset,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this);}_unregisterListeners(){let{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(p.ERROR,this.onError,this),e.off(p.BUFFER_RESET,this.onBufferReset,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this);}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:n}){if(i==="main"){let a=t.cc;this.initPTS[t.cc]={baseTime:r,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${r}`),this.videoTrackCC=a,this.state===C.WAITING_INIT_PTS&&this.tick();}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=C.STOPPED;return}let t=this.lastCurrentTime;this.stopLoad(),this.setInterval(Iu),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=C.IDLE):(this.loadedmetadata=false,this.state=C.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick();}doTick(){switch(this.state){case C.IDLE:this.doTickIdle();break;case C.WAITING_TRACK:{var e;let{levels:i,trackId:r}=this,n=i==null||(e=i[r])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=C.WAITING_INIT_PTS;}break}case C.FRAG_LOADING_WAITING_RETRY:{var t;let i=performance.now(),r=this.retryDate;if(!r||i>=r||(t=this.media)!=null&&t.seeking){let{levels:n,trackId:a}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(n?.[a]||null),this.state=C.IDLE;}break}case C.WAITING_INIT_PTS:{let i=this.waitingData;if(i){let{frag:r,part:n,cache:a,complete:o}=i;if(this.initPTS[r.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=C.FRAG_LOADING;let l=a.flush(),d={frag:r,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d);}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${r.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else {let l=this.getLoadPosition(),d=ue.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);yl(d.end,this.config.maxFragLookUpTolerance,r)<0&&(this.log(`Waiting fragment cc (${r.cc}) @ ${r.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment());}}else this.state=C.IDLE;}}this.onTickEnd();}clearWaitingFragment(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=C.IDLE);}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState();}onTickEnd(){let{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime);}doTickIdle(){let{hls:e,levels:t,media:i,trackId:r}=this,n=e.config;if(!i&&(this.startFragRequested||!n.startFragPrefetch)||!(t!=null&&t[r]))return;let a=t[r],o=a.details;if(!o||o.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(o)){this.state=C.WAITING_TRACK;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=false,this.afterBufferFlushed(l,ne.AUDIO,H.AUDIO));let d=this.getFwdBufferInfo(l,H.AUDIO);if(d===null)return;let{bufferedTrack:c,switchingTrack:h}=this;if(!h&&this._streamEnded(d,o)){e.trigger(p.BUFFER_EOS,{type:"audio"}),this.state=C.ENDED;return}let u=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,H.MAIN),f=d.len,m=this.getMaxBufferLength(u?.len),g=o.fragments,E=g[0].start,v=this.flushing?this.getLoadPosition():d.end;if(h&&i){let y=this.getLoadPosition();c&&!ss(h.attrs,c.attrs)&&(v=y),o.PTSKnown&&y<E&&(d.end>E||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=E+.05);}if(f>=m&&!h&&v<g[g.length-1].start)return;let A=this.getNextFragment(v,o),b=false;if(A&&this.isLoopLoading(A,v)&&(b=!!A.gap,A=this.getNextFragmentLoopLoading(A,o,d,H.MAIN,m)),!A){this.bufferFlushed=true;return}let L=u&&A.start>u.end+o.targetduration;if(L||!(u!=null&&u.len)&&d.len){let y=this.getAppendedFrag(A.start,H.MAIN);if(y===null||(b||(b=!!y.gap||!!L&&u.len===0),L&&!b||b&&d.nextStart&&d.nextStart<y.end))return}this.loadFragment(A,a,v);}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=false,super.onMediaDetaching();}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new Jt(i));}onAudioTrackSwitching(e,t){let i=!!t.url;this.trackId=t.id;let{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),i?this.setInterval(Iu):this.resetTransmuxer(),i?(this.switchingTrack=t,this.state=C.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=C.STOPPED),this.tick();}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=false,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=false,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1;}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(p.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null);}onAudioTrackLoaded(e,t){var i;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}let{levels:r}=this,{details:n,id:a}=t;if(!r){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Audio track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);let o=r[a],l=0;if(n.live||(i=o.details)!=null&&i.live){this.checkLiveUpdate(n);let c=this.mainDetails;if(n.deltaUpdateFailed||!c)return;if(!o.details&&n.hasProgramDateTime&&c.hasProgramDateTime)Kn(n,c),l=n.fragments[0].start;else {var d;l=this.alignPlaylists(n,o.details,(d=this.levelLastLoaded)==null?void 0:d.details);}}o.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(this.mainDetails||n,l),this.state===C.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=C.IDLE),this.tick();}_handleFragmentLoadProgress(e){var t;let{frag:i,part:r,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}let d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}let c=d.details;if(!c){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}let h=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",u=this.transmuxer;u||(u=this.transmuxer=new Zn(this.hls,H.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let f=this.initPTS[i.cc],m=(t=i.initSegment)==null?void 0:t.data;if(f!==void 0){let E=r?r.index:-1,v=E!==-1,A=new Ws(i.level,i.sn,i.stats.chunkCount,n.byteLength,E,v);u.push(n,m,h,"",i,r,c.totalduration,false,A,f);}else {this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);let{cache:g}=this.waitingData=this.waitingData||{frag:i,part:r,cache:new Wn,complete:false};g.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=C.WAITING_INIT_PTS;}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=true;return}super._handleFragmentLoadComplete(e);}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=false;}onBufferCreated(e,t){let i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null);}onFragBuffered(e,t){let{frag:i,part:r}=t;if(i.type!==H.AUDIO){if(!this.loadedmetadata&&i.type===H.MAIN){let n=this.videoBuffer||this.media;n&&ue.getBuffered(n).length&&(this.loadedmetadata=true);}return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(i.sn!=="initSegment"){this.fragPrevious=i;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(p.AUDIO_TRACK_SWITCHED,Oe({},n)));}this.fragBufferedComplete(i,r);}onError(e,t){var i;if(t.fatal){this.state=C.ERROR;return}switch(t.details){case x.FRAG_GAP:case x.FRAG_PARSING_ERROR:case x.FRAG_DECRYPT_ERROR:case x.FRAG_LOAD_ERROR:case x.FRAG_LOAD_TIMEOUT:case x.KEY_LOAD_ERROR:case x.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(H.AUDIO,t);break;case x.AUDIO_TRACK_LOAD_ERROR:case x.AUDIO_TRACK_LOAD_TIMEOUT:case x.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===C.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===Z.AUDIO_TRACK&&(this.state=C.IDLE);break;case x.BUFFER_APPEND_ERROR:case x.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;if(t.details===x.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case x.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==ne.VIDEO&&(this.flushing=true);}onBufferFlushed(e,{type:t}){if(t!==ne.VIDEO){this.flushing=false,this.bufferFlushed=true,this.state===C.ENDED&&(this.state=C.IDLE);let i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,H.AUDIO),this.tick());}}_handleTransmuxComplete(e){var t;let i="audio",{hls:r}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:c}=o,{details:h}=c,{audio:u,text:f,id3:m,initSegment:g}=n;if(this.fragContextChanged(l)||!h){this.fragmentTracker.removeFragment(l);return}if(this.state=C.PARSING,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),g!=null&&g.tracks){let E=l.initSegment||l;this._bufferInitSegment(c,g.tracks,E,a),r.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:E,id:i,tracks:g.tracks});}if(u){let{startPTS:E,endPTS:v,startDTS:A,endDTS:b}=u;d&&(d.elementaryStreams[ne.AUDIO]={startPTS:E,endPTS:v,startDTS:A,endDTS:b}),l.setElementaryStreamInfo(ne.AUDIO,E,v,A,b),this.bufferFragmentData(u,l,d,a);}if(m!=null&&(t=m.samples)!=null&&t.length){let E=_e({id:i,frag:l,details:h},m);r.trigger(p.FRAG_PARSING_METADATA,E);}if(f){let E=_e({id:i,frag:l,details:h},f);r.trigger(p.FRAG_PARSING_USERDATA,E);}}_bufferInitSegment(e,t,i,r){if(this.state!==C.PARSING)return;t.video&&delete t.video;let n=t.audio;if(!n)return;n.id="audio";let a=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${a}/${n.codec}]`),a&&a.split(",").length===1&&(n.levelCodec=a),this.hls.trigger(p.BUFFER_CODECS,t);let o=n.initSegment;if(o!=null&&o.byteLength){let l={type:"audio",frag:i,part:null,chunkMeta:r,parent:i.type,data:o};this.hls.trigger(p.BUFFER_APPENDING,l);}this.tickImmediate();}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||r===Pe.NOT_LOADED||r===Pe.PARTIAL){var n;if(e.sn==="initSegment")this._loadInitSegment(e,t);else if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=C.WAITING_INIT_PTS;let a=this.mainDetails;a&&a.fragments[0].start!==t.details.fragments[0].start&&Kn(t.details,a);}else this.startFragRequested=true,super.loadFragment(e,t,i);}else this.clearTrackerIfNeeded(e);}flushAudioIfNeeded(e){let{media:t,bufferedTrack:i}=this,r=i?.attrs,n=e.attrs;t&&r&&(r.CHANNELS!==n.CHANNELS||i.name!==e.name||i.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null);}completeAudioSwitch(e){let{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(p.AUDIO_TRACK_SWITCHED,Oe({},e));}},Yl=class extends Ks{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=true,this.registerListeners();}registerListeners(){let{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(p.ERROR,this.onError,this);}unregisterListeners(){let{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(p.ERROR,this.onError,this);}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy();}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=true;}onManifestParsed(e,t){this.tracks=t.audioTracks||[];}onAudioTrackLoaded(e,t){let{id:i,groupId:r,details:n}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==r){this.warn(`Audio track with id:${i} and group:${r} not found in active group ${a?.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Audio track ${i} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o);}onLevelLoading(e,t){this.switchLevel(t.level);}onLevelSwitching(e,t){this.switchLevel(t.level);}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let i=t.audioGroups||null,r=this.groupIds,n=this.currentTrack;if(!i||r?.length!==i?.length||i!=null&&i.some(o=>r?.indexOf(o)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;let o=this.tracks.filter(u=>!i||i.indexOf(u.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(u=>u.default)&&(this.selectDefaultTrack=false),o.forEach((u,f)=>{u.id=f;});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;let l=this.hls.config.audioPreference;if(!n&&l){let u=Nt(l,o,qi);if(u>-1)n=o[u];else {let f=Nt(l,this.tracks);n=this.tracks[f];}}let d=this.findTrackId(n);d===-1&&n&&(d=this.findTrackId(null));let c={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${i?.join(",")}`),this.hls.trigger(p.AUDIO_TRACKS_UPDATED,c);let h=this.trackId;if(d!==-1&&h===-1)this.setAudioTrack(d);else if(o.length&&h===-1){var a;let u=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(u.message),this.hls.trigger(p.ERROR,{type:K.MEDIA_ERROR,details:x.AUDIO_TRACK_LOAD_ERROR,fatal:true,error:u});}}else this.shouldReloadPlaylist(n)&&this.setAudioTrack(this.trackId);}onError(e,t){t.fatal||!t.context||t.context.type===Z.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&(this.requestScheduled=-1,this.checkRetry(t));}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=false,this.setAudioTrack(e);}setAudioOption(e){let t=this.hls;if(t.config.audioPreference=e,e){let i=this.allAudioTracks;if(this.selectDefaultTrack=false,i.length){let r=this.currentTrack;if(r&&Ji(e,r,qi))return r;let n=Nt(e,this.tracksInGroup,qi);if(n>-1){let a=this.tracksInGroup[n];return this.setAudioTrack(n),a}else if(r){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);let o=r0(e,t.levels,i,a,qi);if(o===-1)return null;t.nextLoadLevel=o;}if(e.channels||e.audioCodec){let a=Nt(e,i);if(a>-1)return i[a]}}}return null}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=false;let i=this.currentTrack,r=t[e],n=r.details&&!r.details.live;if(e===this.trackId&&r===i&&n||(this.log(`Switching to audio-track ${e} "${r.name}" lang:${r.lang} group:${r.groupId} channels:${r.channels}`),this.trackId=e,this.currentTrack=r,this.hls.trigger(p.AUDIO_TRACK_SWITCHING,Oe({},r)),n))return;let a=this.switchParams(r.url,i?.details,r.details);this.loadPlaylist(a);}findTrackId(e){let t=this.tracksInGroup;for(let i=0;i<t.length;i++){let r=t[i];if(!(this.selectDefaultTrack&&!r.default)&&(!e||Ji(e,r,qi)))return i}if(e){let{name:i,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:l}=e;for(let d=0;d<t.length;d++){let c=t[d];if(Ji({name:i,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:l},c,qi))return d}for(let d=0;d<t.length;d++){let c=t[d];if(ss(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){let c=t[d];if(ss(e.attrs,c.attrs,["LANGUAGE"]))return d}}return -1}loadPlaylist(e){let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();let i=t.id,r=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n);}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`);}this.log(`loading audio-track playlist ${i} "${t.name}" lang:${t.lang} group:${r}`),this.clearTimer(),this.hls.trigger(p.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:e||null});}}},Lu=500,ql=class extends qs{constructor(e,t,i){super(e,t,i,"[subtitle-stream-controller]",H.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners();}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null;}_registerListeners(){let{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.ERROR,this.onError,this),e.on(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(p.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(p.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this);}_unregisterListeners(){let{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.ERROR,this.onError,this),e.off(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(p.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(p.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this);}startLoad(e){this.stopLoad(),this.state=C.IDLE,this.setInterval(Lu),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick();}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments();}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching();}onLevelLoaded(e,t){this.mainDetails=t.details;}onSubtitleFragProcessed(e,t){let{frag:i,success:r}=t;if(this.fragPrevious=i,this.state=C.IDLE,!r)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=i.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}let l=i.start+i.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null);}onBufferFlushing(e,t){let{startOffset:i,endOffset:r}=t;if(i===0&&r!==Number.POSITIVE_INFINITY){let n=r-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++;}}),this.fragmentTracker.removeFragmentsInRange(i,n,H.SUBTITLE);}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===H.MAIN){var i;(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=true);}}onError(e,t){let i=t.frag;i?.type===H.SUBTITLE&&(t.details===x.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,true),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==C.STOPPED&&(this.state=C.IDLE));}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&xf(this.levels,t)){this.levels=t.map(i=>new Jt(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{let r=new Jt(i);return this.tracksBuffered[r.id]=[],r}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,H.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null;}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,!((i=this.levels)!=null&&i.length)||this.currentTrackId===-1){this.clearInterval();return}let r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(Lu);}onSubtitleTrackLoaded(e,t){var i;let{currentTrackId:r,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}let l=n[o];if(o>=n.length||!l)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(a.live||(i=l.details)!=null&&i.live){let h=this.mainDetails;if(a.deltaUpdateFailed||!h)return;let u=h.fragments[0];if(!l.details)a.hasProgramDateTime&&h.hasProgramDateTime?(Kn(a,h),d=a.fragments[0].start):u&&(d=u.start,bl(a,d));else {var c;d=this.alignPlaylists(a,l.details,(c=this.levelLastLoaded)==null?void 0:c.details),d===0&&u&&(d=u.start,bl(a,d));}}l.details=a,this.levelLastLoaded=l,o===r&&(!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(this.mainDetails||a,d),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===C.IDLE&&(Vn(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0)));}_handleFragmentLoadComplete(e){let{frag:t,payload:i}=e,r=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&r!=null&&r.key&&r.iv&&r.method==="AES-128"){let a=performance.now();this.decrypter.decrypt(new Uint8Array(i),r.key.buffer,r.iv.buffer).catch(o=>{throw n.trigger(p.ERROR,{type:K.MEDIA_ERROR,details:x.FRAG_DECRYPT_ERROR,fatal:false,error:o,reason:o.message,frag:t}),o}).then(o=>{let l=performance.now();n.trigger(p.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}});}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=C.IDLE;});}}doTick(){if(!this.media){this.state=C.IDLE;return}if(this.state===C.IDLE){let{currentTrackId:e,levels:t}=this,i=t?.[e];if(!i||!t.length||!i.details)return;let{config:r}=this,n=this.getLoadPosition(),a=ue.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,r.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,H.MAIN),c=i.details,h=this.getMaxBufferLength(d?.len)+c.levelTargetDuration;if(l>h)return;let u=c.fragments,f=u.length,m=c.edge,g=null,E=this.fragPrevious;if(o<m){let v=r.maxFragLookUpTolerance,A=o>m-v?0:v;g=Vn(E,u,Math.max(u[0].start,o),A),!g&&E&&E.start<u[0].start&&(g=u[0]);}else g=u[f-1];if(!g)return;if(g=this.mapToInitFragWhenRequired(g),g.sn!=="initSegment"){let v=g.sn-c.startSN,A=u[v-1];A&&A.cc===g.cc&&this.fragmentTracker.getState(A)===Pe.NOT_LOADED&&(g=A);}this.fragmentTracker.getState(g)===Pe.NOT_LOADED&&this.loadFragment(g,i,o);}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,i){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=true,super.loadFragment(e,t,i));}get mediaBufferTimeRanges(){return new zl(this.tracksBuffered[this.currentTrackId]||[])}},zl=class{constructor(e){this.buffered=void 0;let t=(i,r,n)=>{if(r=r>>>0,r>n-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${n})`);return e[r][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}};}},Xl=class extends Ks{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=true,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=false,this.subtitlePollingInterval=-1,this._subtitleDisplay=true,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null,i=In(this.media.textTracks);for(let n=0;n<i.length;n++)if(i[n].mode==="hidden")t=i[n];else if(i[n].mode==="showing"){t=i[n];break}let r=this.findTrackForTextTrack(t);this.subtitleTrack!==r&&this.setSubtitleTrack(r);},this.registerListeners();}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy();}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes();}registerListeners(){let{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(p.ERROR,this.onError,this);}unregisterListeners(){let{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(p.ERROR,this.onError,this);}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange));}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e);}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),In(this.media.textTracks).forEach(t=>{Qi(t);}),this.subtitleTrack=-1,this.media=null;}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=true;}onManifestParsed(e,t){this.tracks=t.subtitleTracks;}onSubtitleTrackLoaded(e,t){let{id:i,groupId:r,details:n}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==r){this.warn(`Subtitle track with id:${i} and group:${r} not found in active group ${a?.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Subtitle track ${i} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o);}onLevelLoading(e,t){this.switchLevel(t.level);}onLevelSwitching(e,t){this.switchLevel(t.level);}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let i=t.subtitleGroups||null,r=this.groupIds,n=this.currentTrack;if(!i||r?.length!==i?.length||i!=null&&i.some(a=>r?.indexOf(a)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;let a=this.tracks.filter(c=>!i||i.indexOf(c.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(c=>c.default)&&(this.selectDefaultTrack=false),a.forEach((c,h)=>{c.id=h;});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;let o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=false;let c=Nt(o,a);if(c>-1)n=a[c];else {let h=Nt(o,this.tracks);n=this.tracks[h];}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));let d={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${i?.join(",")}" group-id`),this.hls.trigger(p.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.trackId===-1&&this.setSubtitleTrack(l);}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId);}findTrackId(e){let t=this.tracksInGroup,i=this.selectDefaultTrack;for(let r=0;r<t.length;r++){let n=t[r];if(!(i&&!n.default||!i&&!e)&&(!e||Ji(n,e)))return r}if(e){for(let r=0;r<t.length;r++){let n=t[r];if(ss(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){let n=t[r];if(ss(e.attrs,n.attrs,["LANGUAGE"]))return r}}return -1}findTrackForTextTrack(e){if(e){let t=this.tracksInGroup;for(let i=0;i<t.length;i++){let r=t[i];if(Kl(r,e))return i}}return -1}onError(e,t){t.fatal||!t.context||t.context.type===Z.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t);}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=false,this.setSubtitleTrack(e);}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){let t=this.allSubtitleTracks;if(this.selectDefaultTrack=false,t.length){let i=this.currentTrack;if(i&&Ji(e,i))return i;let r=Nt(e,this.tracksInGroup);if(r>-1){let n=this.tracksInGroup[r];return this.setSubtitleTrack(r),n}else {if(i)return null;{let n=Nt(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){let i=t.id,r=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n);}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`);}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(p.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:e||null});}}toggleTrackModes(){let{media:e}=this;if(!e)return;let t=In(e.textTracks),i=this.currentTrack,r;if(i&&(r=t.filter(n=>Kl(i,n))[0],r||this.warn(`Unable to find subtitle TextTrack with name "${i.name}" and language "${i.lang}"`)),[].slice.call(t).forEach(n=>{n.mode!=="disabled"&&n!==r&&(n.mode="disabled");}),r){let n=this.subtitleDisplay?"showing":"hidden";r.mode!==n&&(r.mode=n);}}setSubtitleTrack(e){let t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!F(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=false;let i=this.currentTrack,r=t[e]||null;if(this.trackId=e,this.currentTrack=r,this.toggleTrackModes(),!r){this.hls.trigger(p.SUBTITLE_TRACK_SWITCH,{id:e});return}let n=!!r.details&&!r.details.live;if(e===this.trackId&&r===i&&n)return;this.log(`Switching to subtitle-track ${e}`+(r?` "${r.name}" lang:${r.lang} group:${r.groupId}`:""));let{id:a,groupId:o="",name:l,type:d,url:c}=r;this.hls.trigger(p.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:c});let h=this.switchParams(r.url,i?.details,r.details);this.loadPlaylist(h);}},jl=class{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e;}append(e,t,i){let r=this.queues[t];r.push(e),r.length===1&&!i&&this.executeNext(t);}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t);}appendBlocker(e){let t,i=new Promise(n=>{t=n;}),r={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(r,e),i}executeNext(e){let t=this.queues[e];if(t.length){let i=t[0];try{i.execute();}catch(r){S.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${r}`),i.onError(r);let n=this.buffers[e];n!=null&&n.updating||this.shiftAndExecuteNext(e);}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e);}current(e){return this.queues[e][0]}},Ru=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Ql=class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=i=>{this.hls&&this.hls.pauseBuffering();},this._onStartStreaming=i=>{this.hls&&this.hls.resumeBuffering();},this._onMediaSourceOpen=()=>{let{media:i,mediaSource:r}=this;this.log("Media source opened"),i&&(i.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(p.MEDIA_ATTACHED,{media:i,mediaSource:r})),r&&r.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks();},this._onMediaSourceClose=()=>{this.log("Media source closed");},this._onMediaSourceEnded=()=>{this.log("Media source ended");},this._onMediaEmptied=()=>{let{mediaSrc:i,_objectUrl:r}=this;i!==r&&S.error(`Media element src was set while attaching MediaSource (${r} > ${i})`);},this.hls=e;let t="[buffer-controller]";this.appendSource=Sp(Ti(e.config.preferManagedMediaSource)),this.log=S.log.bind(S,t),this.warn=S.warn.bind(S,t),this.error=S.error.bind(S,t),this._initSourceBuffer(),this.registerListeners();}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null;}registerListeners(){let{hls:e}=this;e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.BUFFER_RESET,this.onBufferReset,this),e.on(p.BUFFER_APPENDING,this.onBufferAppending,this),e.on(p.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.BUFFER_EOS,this.onBufferEos,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.FRAG_PARSED,this.onFragParsed,this),e.on(p.FRAG_CHANGED,this.onFragChanged,this);}unregisterListeners(){let{hls:e}=this;e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.BUFFER_RESET,this.onBufferReset,this),e.off(p.BUFFER_APPENDING,this.onBufferAppending,this),e.off(p.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.BUFFER_EOS,this.onBufferEos,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.FRAG_PARSED,this.onFragParsed,this),e.off(p.FRAG_CHANGED,this.onFragChanged,this);}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new jl(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null;}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null;}onManifestParsed(e,t){let i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`);}onMediaAttaching(e,t){let i=this.media=t.media,r=Ti(this.appendSource);if(i&&r){var n;let a=this.mediaSource=new r;this.log(`created media source: ${(n=a.constructor)==null?void 0:n.name}`),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));let o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{i.removeAttribute("src");let l=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||l&&a instanceof l,Du(i),$0(i,o),i.load();}catch{i.src=o;}else i.src=o;i.addEventListener("emptied",this._onMediaEmptied);}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:i}=this;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream();}catch(r){this.warn(`onMediaDetaching: ${r.message} while calling endOfStream`);}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),i&&self.URL.revokeObjectURL(i),this.mediaSrc===i?(e.removeAttribute("src"),this.appendSource&&Du(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={};}this.hls.trigger(p.MEDIA_DETACHED,void 0);}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e);}),this._initSourceBuffer();}resetBuffer(e){let t=this.sourceBuffer[e];try{if(t){var i;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(i=this.mediaSource)!=null&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t);}}catch(r){this.warn(`onBufferReset ${e}`,r);}}onBufferCodecs(e,t){let i=this.getSourceBufferTypes().length,r=Object.keys(t);if(r.forEach(a=>{if(i){let l=this.tracks[a];if(l&&typeof l.buffer.changeType=="function"){var o;let{id:d,codec:c,levelCodec:h,container:u,metadata:f}=t[a],m=tu(l.codec,l.levelCodec),g=m?.replace(Ru,"$1"),E=tu(c,h),v=(o=E)==null?void 0:o.replace(Ru,"$1");if(E&&g!==v){a.slice(0,5)==="audio"&&(E=Un(E,this.appendSource));let A=`${u};codecs=${E}`;this.appendChangeType(a,A),this.log(`switching codec ${m} to ${E}`),this.tracks[a]={buffer:l.buffer,codec:c,container:u,levelCodec:h,metadata:f,id:d};}}}else this.pendingTracks[a]=t[a];}),i)return;let n=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==n&&(this.log(`${n} bufferCodec event(s) expected ${r.join(",")}`),this.bufferCodecEventsExpected=n),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks();}appendChangeType(e,t){let{operationQueue:i}=this,r={execute:()=>{let n=this.sourceBuffer[e];n&&(this.log(`changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),i.shiftAndExecuteNext(e);},onStart:()=>{},onComplete:()=>{},onError:n=>{this.warn(`Failed to change ${e} SourceBuffer type`,n);}};i.append(r,e,!!this.pendingTracks[e]);}onBufferAppending(e,t){let{hls:i,operationQueue:r,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:c}=t,h=c.buffering[o],u=self.performance.now();h.start=u;let f=l.stats.buffering,m=d?d.stats.buffering:null;f.start===0&&(f.start=u),m&&m.start===0&&(m.start=u);let g=n.audio,E=false;o==="audio"&&g?.container==="audio/mpeg"&&(E=!this.lastMpegAudioChunk||c.id===1||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);let v=l.start,A={execute:()=>{if(h.executeStart=self.performance.now(),E){let b=this.sourceBuffer[o];if(b){let L=v-b.timestampOffset;Math.abs(L)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${v} (delta: ${L}) sn: ${l.sn})`),b.timestampOffset=v);}}this.appendExecutor(a,o);},onStart:()=>{},onComplete:()=>{let b=self.performance.now();h.executeEnd=h.end=b,f.first===0&&(f.first=b),m&&m.first===0&&(m.first=b);let{sourceBuffer:L}=this,y={};for(let D in L)y[D]=ue.getBuffered(L[D]);this.appendErrors[o]=0,o==="audio"||o==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(p.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:c,parent:l.type,timeRanges:y});},onError:b=>{let L={type:K.MEDIA_ERROR,parent:l.type,details:x.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:d,chunkMeta:c,error:b,err:b,fatal:false};if(b.code===DOMException.QUOTA_EXCEEDED_ERR)L.details=x.BUFFER_FULL_ERROR;else {let y=++this.appendErrors[o];L.details=x.BUFFER_APPEND_ERROR,this.warn(`Failed ${y}/${i.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),y>=i.config.appendErrorMaxRetry&&(L.fatal=true);}i.trigger(p.ERROR,L);}};r.append(A,o,!!this.pendingTracks[o]);}onBufferFlushing(e,t){let{operationQueue:i}=this,r=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(p.BUFFER_FLUSHED,{type:n});},onError:a=>{this.warn(`Failed to remove from ${n} SourceBuffer`,a);}});t.type?i.append(r(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{i.append(r(n),n);});}onFragParsed(e,t){let{frag:i,part:r}=t,n=[],a=r?r.elementaryStreams:i.elementaryStreams;a[ne.AUDIOVIDEO]?n.push("audiovideo"):(a[ne.AUDIO]&&n.push("audio"),a[ne.VIDEO]&&n.push("video"));let o=()=>{let l=self.performance.now();i.stats.buffering.end=l,r&&(r.stats.buffering.end=l);let d=r?r.stats:i.stats;this.hls.trigger(p.FRAG_BUFFERED,{frag:i,part:r,stats:d,id:i.type});};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(o,n);}onFragChanged(e,t){this.trimBuffers();}onBufferEos(e,t){this.getSourceBufferTypes().reduce((r,n)=>{let a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=true,a.ended||(a.ended=true,this.log(`${n} sourceBuffer now EOS`))),r&&!!(!a||a.ended)},true)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{let a=this.sourceBuffer[n];a&&(a.ending=false);});let{mediaSource:r}=this;if(!r||r.readyState!=="open"){r&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${r.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),r.endOfStream();}));}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration());}trimBuffers(){let{hls:e,details:t,media:i}=this;if(!i||t===null||!this.getSourceBufferTypes().length)return;let n=e.config,a=i.currentTime,o=t.levelTargetDuration,l=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(F(l)&&l>0){let d=Math.max(l,o),c=Math.floor(a/o)*o-d;this.flushBackBuffer(a,o,c);}if(F(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){let d=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),c=Math.max(d,o),h=Math.floor(a/o)*o+c;this.flushFrontBuffer(a,o,h);}}flushBackBuffer(e,t,i){let{details:r,sourceBuffer:n}=this;this.getSourceBufferTypes().forEach(o=>{let l=n[o];if(l){let d=ue.getBuffered(l);if(d.length>0&&i>d.start(0)){if(this.hls.trigger(p.BACK_BUFFER_REACHED,{bufferEnd:i}),r!=null&&r.live)this.hls.trigger(p.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(l.ended&&d.end(d.length-1)-e<t*2){this.log(`Cannot flush ${o} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:o});}}});}flushFrontBuffer(e,t,i){let{sourceBuffer:r}=this;this.getSourceBufferTypes().forEach(a=>{let o=r[a];if(o){let l=ue.getBuffered(o),d=l.length;if(d<2)return;let c=l.start(d-1),h=l.end(d-1);if(i>c||e>=c&&e<=h)return;if(o.ended&&e-h<2*t){this.log(`Cannot flush ${a} front buffer while SourceBuffer is in ended state`);return}this.hls.trigger(p.BUFFER_FLUSHING,{startOffset:c,endOffset:1/0,type:a});}});}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;let{details:e,hls:t,media:i,mediaSource:r}=this,n=e.fragments[0].start+e.totalduration,a=i.duration,o=F(r.duration)?r.duration:0;e.live&&t.config.liveDurationInfinity?(r.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!F(a))&&(this.log(`Updating Media Source duration to ${n.toFixed(3)}`),r.duration=n);}updateSeekableRange(e){let t=this.mediaSource,i=e.fragments;if(i.length&&e.live&&t!=null&&t.setLiveSeekableRange){let n=Math.max(0,i[0].start),a=Math.max(n,n+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${n}-${a}.`),t.setLiveSeekableRange(n,a);}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:i}=this,r=Object.keys(i).length;if(r&&(!e||r===2||"audiovideo"in i)){this.createSourceBuffers(i),this.pendingTracks={};let n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(p.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a);});else {let a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(p.ERROR,{type:K.MEDIA_ERROR,details:x.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:true,error:a,reason:a.message});}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(let n in e)if(!t[n]){var r;let a=e[n];if(!a)throw Error(`source buffer exists for track ${n}, however track does not`);let o=((r=a.levelCodec)==null?void 0:r.indexOf(","))===-1?a.levelCodec:a.codec;o&&n.slice(0,5)==="audio"&&(o=Un(o,this.appendSource));let l=`${a.container};codecs=${o}`;this.log(`creating sourceBuffer(${l})`);try{let d=t[n]=i.addSourceBuffer(l),c=n;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(c,"bufferedchange",(h,u)=>{let f=u.removedRanges;f!=null&&f.length&&this.hls.trigger(p.BUFFER_FLUSHED,{type:n});}),this.tracks[n]={buffer:d,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id};}catch(d){this.error(`error while trying to add sourceBuffer: ${d.message}`),this.hls.trigger(p.ERROR,{type:K.MEDIA_ERROR,details:x.BUFFER_ADD_CODEC_ERROR,fatal:false,error:d,sourceBufferName:n,mimeType:l});}}}get mediaSrc(){var e,t;let i=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return i?.src}_onSBUpdateStart(e){let{operationQueue:t}=this;t.current(e).onStart();}_onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}let{operationQueue:i}=this;i.current(e).onComplete(),i.shiftAndExecuteNext(e);}_onSBUpdateError(e,t){var i;let r=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(i=this.mediaSource)==null?void 0:i.readyState}`);this.error(`${r}`,t),this.hls.trigger(p.ERROR,{type:K.MEDIA_ERROR,details:x.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:r,fatal:false});let n=this.operationQueue.current(e);n&&n.onError(r);}removeExecutor(e,t,i){let{media:r,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!r||!n||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}let d=F(r.duration)?r.duration:1/0,c=F(n.duration)?n.duration:1/0,h=Math.max(0,t),u=Math.min(i,d,c);u>h&&(!l.ending||l.ended)?(l.ended=false,this.log(`Removing [${h},${u}] from the ${e} SourceBuffer`),l.remove(h,u)):a.shiftAndExecuteNext(e);}appendExecutor(e,t){let i=this.sourceBuffer[t];if(!i){if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}i.ended=false,i.appendBuffer(e);}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}let{operationQueue:i}=this,r=t.map(n=>i.appendBlocker(n));Promise.all(r).then(()=>{e(),t.forEach(n=>{let a=this.sourceBuffer[n];a!=null&&a.updating||i.shiftAndExecuteNext(n);});});}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,i){let r=this.sourceBuffer[e];if(!r)return;let n=i.bind(this,e);this.listeners[e].push({event:t,listener:n}),r.addEventListener(t,n);}removeBufferListeners(e){let t=this.sourceBuffer[e];t&&this.listeners[e].forEach(i=>{t.removeEventListener(i.event,i.listener);});}};function Du(s){let e=s.querySelectorAll("source");[].slice.call(e).forEach(t=>{s.removeChild(t);});}function $0(s,e){let t=self.document.createElement("source");t.type="video/mp4",t.src=e,s.appendChild(t);}var G0={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},If=s=>String.fromCharCode(G0[s]||s),ft=15,Gt=100,H0={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},V0={17:2,18:4,21:6,22:8,23:10,19:13,20:15},K0={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},W0={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Y0=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],Zl=class{constructor(){this.time=null,this.verboseLevel=0;}log(e,t){if(this.verboseLevel>=e){let i=typeof t=="function"?t():t;S.log(`${this.time} [${e}] ${i}`);}}},mi=function(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t},Jn=class{constructor(){this.foreground="white",this.underline=false,this.italics=false,this.background="black",this.flash=false;}reset(){this.foreground="white",this.underline=false,this.italics=false,this.background="black",this.flash=false;}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let i=0;i<t.length;i++){let r=t[i];e.hasOwnProperty(r)&&(this[r]=e[r]);}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash;}toString(){return "color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}},Jl=class{constructor(){this.uchar=" ",this.penState=new Jn;}reset(){this.uchar=" ",this.penState.reset();}setChar(e,t){this.uchar=e,this.penState.copy(t);}setPenState(e){this.penState.copy(e);}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState);}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}},ed=class{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Jn,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Gt;t++)this.chars.push(new Jl);this.logger=e;}equals(e){for(let t=0;t<Gt;t++)if(!this.chars[t].equals(e.chars[t]))return false;return true}copy(e){for(let t=0;t<Gt;t++)this.chars[t].copy(e.chars[t]);}isEmpty(){let e=true;for(let t=0;t<Gt;t++)if(!this.chars[t].isEmpty()){e=false;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Gt&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Gt);}moveCursor(e){let t=this.pos+e;if(e>1)for(let i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t);}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState);}insertChar(e){e>=144&&this.backSpace();let t=If(e);if(this.pos>=Gt){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1);}clearFromPos(e){let t;for(t=e;t<Gt;t++)this.chars[t].reset();}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset();}clearToEndOfRow(){this.clearFromPos(this.pos);}getTextString(){let e=[],t=true;for(let i=0;i<Gt;i++){let r=this.chars[i].uchar;r!==" "&&(t=false),e.push(r);}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState);}},$s=class{constructor(e){this.rows=[],this.currRow=ft-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<ft;t++)this.rows.push(new ed(e));this.logger=e;}reset(){for(let e=0;e<ft;e++)this.rows[e].clear();this.currRow=ft-1;}equals(e){let t=true;for(let i=0;i<ft;i++)if(!this.rows[i].equals(e.rows[i])){t=false;break}return t}copy(e){for(let t=0;t<ft;t++)this.rows[t].copy(e.rows[t]);}isEmpty(){let e=true;for(let t=0;t<ft;t++)if(!this.rows[t].isEmpty()){e=false;break}return e}backSpace(){this.rows[this.currRow].backSpace();}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow();}insertChar(e){this.rows[this.currRow].insertChar(e);}setPen(e){this.rows[this.currRow].setPenStyles(e);}moveCursor(e){this.rows[this.currRow].moveCursor(e);}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e);}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<ft;o++)this.rows[o].clear();let n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){let o=a.rows[n].cueStartTime,l=this.logger.time;if(o!==null&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d]);}}this.currRow=t;let i=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);i.setCursor(e.indent),e.color=i.chars[a].penState.foreground;}let r={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:false};this.setPen(r);}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32);}setRollUpRows(e){this.nrRollUpRows=e;}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up");}getDisplayText(e){e=e||false;let t=[],i="",r=-1;for(let n=0;n<ft;n++){let a=this.rows[n].getTextString();a&&(r=n+1,e?t.push("Row "+r+": '"+a+"'"):t.push(a.trim()));}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(`
|
|
1118
|
-
`)),i}getTextAndFormat(){return this.rows}},ea=class{constructor(e,t,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new $s(i),this.nonDisplayedMemory=new $s(i),this.lastOutputScreen=new $s(i),this.currRollUpRow=this.displayedMemory.rows[ft-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i;}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[ft-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null;}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e;}setPAC(e){this.writeScreen.setPAC(e);}setBkgData(e){this.writeScreen.setBkgData(e);}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e);}insertChars(e){for(let i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(true)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(true)),this.outputDataUpdate());}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON");}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate());}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate();}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e);}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:true});}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON");}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT");}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT");}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(true);}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(true);}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset();}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText());}this.outputDataUpdate(true);}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e);}ccMIDROW(e){let t={flash:false};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else {let i=Math.floor(e/2)-16,r=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=r[i];}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t);}outputDataUpdate(e=false){let t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory));}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e));}},ta=class{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=z0(),this.logger=void 0;let r=this.logger=new Zl;this.channels=[null,new ea(e,t,r),new ea(e+1,i,r)];}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t);}addData(e,t){this.logger.time=e;for(let i=0;i<t.length;i+=2){let r=t[i]&127,n=t[i+1]&127,a=false,o=null;if(r===0&&n===0)continue;this.logger.log(3,()=>"["+mi([t[i],t[i+1]])+"] -> ("+mi([r,n])+")");let l=this.cmdHistory;if(r>=16&&r<=31){if(q0(r,n,l)){yn(null,null,l),this.logger.log(3,()=>"Repeated command ("+mi([r,n])+") is dropped");continue}yn(r,n,this.cmdHistory),a=this.parseCmd(r,n),a||(a=this.parseMidrow(r,n)),a||(a=this.parsePAC(r,n)),a||(a=this.parseBackgroundAttributes(r,n));}else yn(null,null,l);if(!a&&(o=this.parseChars(r,n),o)){let c=this.currentChannel;c&&c>0?this.channels[c].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?");}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+mi([r,n])+" orig: "+mi([t[i],t[i+1]]));}}parseCmd(e,t){let i=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=33&&t<=35;if(!(i||r))return false;let n=e===20||e===21||e===23?1:2,a=this.channels[n];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),this.currentChannel=n,true}parseMidrow(e,t){let i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),false;let r=this.channels[i];return r?(r.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+mi([e,t])+")"),true):false}return false}parsePAC(e,t){let i,r=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(r||n))return false;let a=e<=23?1:2;t>=64&&t<=95?i=a===1?H0[e]:K0[e]:i=a===1?V0[e]:W0[e];let o=this.channels[a];return o?(o.setPAC(this.interpretPAC(i,t)),this.currentChannel=a,true):false}interpretPAC(e,t){let i,r={color:null,italics:false,indent:null,underline:false,row:e};return t>95?i=t-96:i=t-64,r.underline=(i&1)===1,i<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(r.italics=true,r.color="white"):r.indent=Math.floor((i-16)/2)*4,r}parseChars(e,t){let i,r=null,n=null;if(e>=25?(i=2,n=e-8):(i=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+If(a)+"' in channel "+i),r=[a];}else e>=32&&e<=127&&(r=t===0?[e]:[e,t]);return r&&this.logger.log(3,()=>"Char codes = "+mi(r).join(",")),r}parseBackgroundAttributes(e,t){let i=(e===16||e===24)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=45&&t<=47;if(!(i||r))return false;let n,a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=Y0[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=true));let o=e<=23?1:2;return this.channels[o].setBkgData(a),true}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset();}yn(null,null,this.cmdHistory);}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let i=this.channels[t];i&&i.cueSplitAtTime(e);}}};function yn(s,e,t){t.a=s,t.b=e;}function q0(s,e,t){return t.a===s&&t.b===e}function z0(){return {a:null,b:null}}var Zi=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;}},Rd=function(){if(is!=null&&is.VTTCue)return self.VTTCue;let s=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return false;let d=l.toLowerCase();return ~o.indexOf(d)?d:false}function i(o){return t(s,o)}function r(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){let c=arguments[d];for(let h in c)o[h]=c[h];}return o}function a(o,l,d){let c=this,h={enumerable:true};c.hasBeenReset=false;let u="",f=false,m=o,g=l,E=d,v=null,A="",b=true,L="auto",y="start",D=50,I="middle",k=50,P="middle";Object.defineProperty(c,"id",n({},h,{get:function(){return u},set:function(R){u=""+R;}})),Object.defineProperty(c,"pauseOnExit",n({},h,{get:function(){return f},set:function(R){f=!!R;}})),Object.defineProperty(c,"startTime",n({},h,{get:function(){return m},set:function(R){if(typeof R!="number")throw new TypeError("Start time must be set to a number.");m=R,this.hasBeenReset=true;}})),Object.defineProperty(c,"endTime",n({},h,{get:function(){return g},set:function(R){if(typeof R!="number")throw new TypeError("End time must be set to a number.");g=R,this.hasBeenReset=true;}})),Object.defineProperty(c,"text",n({},h,{get:function(){return E},set:function(R){E=""+R,this.hasBeenReset=true;}})),Object.defineProperty(c,"region",n({},h,{get:function(){return v},set:function(R){v=R,this.hasBeenReset=true;}})),Object.defineProperty(c,"vertical",n({},h,{get:function(){return A},set:function(R){let w=i(R);if(w===false)throw new SyntaxError("An invalid or illegal string was specified.");A=w,this.hasBeenReset=true;}})),Object.defineProperty(c,"snapToLines",n({},h,{get:function(){return b},set:function(R){b=!!R,this.hasBeenReset=true;}})),Object.defineProperty(c,"line",n({},h,{get:function(){return L},set:function(R){if(typeof R!="number"&&R!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");L=R,this.hasBeenReset=true;}})),Object.defineProperty(c,"lineAlign",n({},h,{get:function(){return y},set:function(R){let w=r(R);if(!w)throw new SyntaxError("An invalid or illegal string was specified.");y=w,this.hasBeenReset=true;}})),Object.defineProperty(c,"position",n({},h,{get:function(){return D},set:function(R){if(R<0||R>100)throw new Error("Position must be between 0 and 100.");D=R,this.hasBeenReset=true;}})),Object.defineProperty(c,"positionAlign",n({},h,{get:function(){return I},set:function(R){let w=r(R);if(!w)throw new SyntaxError("An invalid or illegal string was specified.");I=w,this.hasBeenReset=true;}})),Object.defineProperty(c,"size",n({},h,{get:function(){return k},set:function(R){if(R<0||R>100)throw new Error("Size must be between 0 and 100.");k=R,this.hasBeenReset=true;}})),Object.defineProperty(c,"align",n({},h,{get:function(){return P},set:function(R){let w=r(R);if(!w)throw new SyntaxError("An invalid or illegal string was specified.");P=w,this.hasBeenReset=true;}})),c.displayState=void 0;}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),td=class{decode(e,t){if(!e)return "";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function Lf(s){function e(i,r,n,a){return (i|0)*3600+(r|0)*60+(n|0)+parseFloat(a||0)}let t=s.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}var id=class{constructor(){this.values=Object.create(null);}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t);}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let r=0;r<i.length;++r)if(t===i[r]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10));}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),true}return false}};function Rf(s,e,t,i){let r=i?s.split(i):[s];for(let n in r){if(typeof r[n]!="string")continue;let a=r[n].split(t);if(a.length!==2)continue;let o=a[0],l=a[1];e(o,l);}}var sd=new Rd(0,0,""),Sn=sd.align==="middle"?"middle":"center";function X0(s,e,t){let i=s;function r(){let o=Lf(s);if(o===null)throw new Error("Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){let d=new id;Rf(o,function(u,f){let m;switch(u){case "region":for(let g=t.length-1;g>=0;g--)if(t[g].id===f){d.set(u,t[g].region);break}break;case "vertical":d.alt(u,f,["rl","lr"]);break;case "line":m=f.split(","),d.integer(u,m[0]),d.percent(u,m[0])&&d.set("snapToLines",false),d.alt(u,m[0],["auto"]),m.length===2&&d.alt("lineAlign",m[1],["start",Sn,"end"]);break;case "position":m=f.split(","),d.percent(u,m[0]),m.length===2&&d.alt("positionAlign",m[1],["start",Sn,"end","line-left","line-right","auto"]);break;case "size":d.percent(u,f);break;case "align":d.alt(u,f,["start",Sn,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let c=d.get("line","auto");c==="auto"&&sd.line===-1&&(c=-1),l.line=c,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",true),l.size=d.get("size",100),l.align=d.get("align",Sn);let h=d.get("position","auto");h==="auto"&&sd.position===50&&(h=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=h;}function a(){s=s.replace(/^\s+/,"");}if(a(),e.startTime=r(),a(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.slice(3),a(),e.endTime=r(),a(),n(s,e);}function Df(s){return s.replace(/<br(?: \/)?>/gi,`
|
|
1119
|
-
`)}var rd=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new td,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0;}parse(e){let t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:true}));function i(){let n=t.buffer,a=0;for(n=Df(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
|
|
1120
|
-
`;)++a;let o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
|
|
1121
|
-
`&&++a,t.buffer=n.slice(a),o}function r(n){Rf(n,function(a,o){},/:/);}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=i();let o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER";}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=i(),t.state){case "HEADER":/:/.test(n)?r(n):n||(t.state="ID");continue;case "NOTE":n||(t.state="ID");continue;case "ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new Rd(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case "CUE":if(!t.cue){t.state="BADCUE";continue}try{X0(n,t.cue,t.regionList);}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case "CUETEXT":{let o=n.indexOf("-->")!==-1;if(!n||o&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
|
|
1122
|
-
`),t.cue.text+=n;}continue;case "BADCUE":n||(t.state="ID");}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE";}return this}flush(){let e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
|
|
1123
|
-
|
|
1124
|
-
`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t);}return e.onflush&&e.onflush(),this}},j0=/\r\n|\n\r|\n|\r/g,sl=function(e,t,i=0){return e.slice(i,i+t.length)===t},Q0=function(e){let t=parseInt(e.slice(-3)),i=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!F(t)||!F(i)||!F(r)||!F(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*r,t+=60*60*1e3*n,t},rl=function(e){let t=5381,i=e.length;for(;i;)t=t*33^e.charCodeAt(--i);return (t>>>0).toString()};function Dd(s,e,t){return rl(s.toString())+rl(e.toString())+rl(t)}var Z0=function(e,t,i){let r=e[t],n=e[r.prevCC];if(!n||!n.new&&r.new){e.ccOffset=e.presentationOffset=r.start,r.new=false;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=r.start-n.start,r.new=false,r=n,n=e[r.prevCC];}e.presentationOffset=i;};function J0(s,e,t,i,r,n,a){let o=new rd,l=Ft(new Uint8Array(s)).trim().replace(j0,`
|
|
1125
|
-
`).split(`
|
|
1126
|
-
`),d=[],c=e?w0(e.baseTime,e.timescale):0,h="00:00.000",u=0,f=0,m,g=true;o.oncue=function(E){let v=t[i],A=t.ccOffset,b=(u-c)/9e4;if(v!=null&&v.new&&(f!==void 0?A=t.ccOffset=v.start:Z0(t,i,b)),b){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}A=b-t.presentationOffset;}let L=E.endTime-E.startTime,y=it((E.startTime+A-f)*9e4,r*9e4)/9e4;E.startTime=Math.max(y,0),E.endTime=Math.max(y+L,0);let D=E.text.trim();E.text=decodeURIComponent(encodeURIComponent(D)),E.id||(E.id=Dd(E.startTime,E.endTime,D)),E.endTime>0&&d.push(E);},o.onparsingerror=function(E){m=E;},o.onflush=function(){if(m){a(m);return}n(d);},l.forEach(E=>{if(g)if(sl(E,"X-TIMESTAMP-MAP=")){g=false,E.slice(16).split(",").forEach(v=>{sl(v,"LOCAL:")?h=v.slice(6):sl(v,"MPEGTS:")&&(u=parseInt(v.slice(7)));});try{f=Q0(h)/1e3;}catch(v){m=v;}return}else E===""&&(g=false);o.parse(E+`
|
|
1127
|
-
`);}),o.flush();}var nl="stpp.ttml.im1t",Cf=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,kf=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,eE={left:"start",center:"center",right:"end",start:"start",end:"end"};function Cu(s,e,t,i){let r=j(new Uint8Array(s),["mdat"]);if(r.length===0){i(new Error("Could not parse IMSC1 mdat"));return}let n=r.map(o=>Ft(o)),a=k0(e.baseTime,1,e.timescale);try{n.forEach(o=>t(tE(o,a)));}catch(o){i(o);}}function tE(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((h,u)=>(h[u]=r.getAttribute(`ttp:${u}`)||n[u],h),{}),o=r.getAttribute("xml:space")!=="preserve",l=ku(al(r,"styling","style")),d=ku(al(r,"layout","region")),c=al(r,"body","[begin]");return [].map.call(c,h=>{let u=wf(h,o);if(!u||!h.hasAttribute("begin"))return null;let f=ll(h.getAttribute("begin"),a),m=ll(h.getAttribute("dur"),a),g=ll(h.getAttribute("end"),a);if(f===null)throw wu(h);if(g===null){if(m===null)throw wu(h);g=f+m;}let E=new Rd(f-e,g-e,u);E.id=Dd(E.startTime,E.endTime,E.text);let v=d[h.getAttribute("region")],A=l[h.getAttribute("style")],b=iE(v,A,l),{textAlign:L}=b;if(L){let y=eE[L];y&&(E.lineAlign=y),E.align=L;}return _e(E,b),E}).filter(h=>h!==null)}function al(s,e,t){let i=s.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function ku(s){return s.reduce((e,t)=>{let i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function wf(s,e){return [].slice.call(s.childNodes).reduce((t,i,r)=>{var n;return i.nodeName==="br"&&r?t+`
|
|
1128
|
-
`:(n=i.childNodes)!=null&&n.length?wf(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function iE(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,l)=>{let d=ol(e,i,l)||ol(s,i,l)||ol(r,i,l);return d&&(o[l]=d),o},{})}function ol(s,e,t){return s&&s.hasAttributeNS(e,t)?s.getAttributeNS(e,t):null}function wu(s){return new Error(`Could not parse ttml timestamp ${s}`)}function ll(s,e){if(!s)return null;let t=Lf(s);return t===null&&(Cf.test(s)?t=sE(s,e):kf.test(s)&&(t=rE(s,e))),t}function sE(s,e){let t=Cf.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 rE(s,e){let t=kf.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 nd=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=Pu(),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(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(p.FRAG_LOADING,this.onFragLoading,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this),e.on(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(p.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this);}destroy(){let{hls:e}=this;e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(p.FRAG_LOADING,this.onFragLoading,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this),e.off(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(p.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0;}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){let e=new Zi(this,"textTrack1"),t=new Zi(this,"textTrack2"),i=new Zi(this,"textTrack3"),r=new Zi(this,"textTrack4");this.cea608Parser1=new ta(1,e,t),this.cea608Parser2=new ta(3,i,r);}}addCues(e,t,i,r,n){let a=false;for(let o=n.length;o--;){let l=n[o],d=nE(l[0],l[1],t,i);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],i),a=true,d/(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(p.CUES_PARSED,{type:"captions",cues:o,track:e});}}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:n}){let{unparsedVttFrags:a}=this;i==="main"&&(this.initPTS[t.cc]={baseTime:r,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(p.FRAG_LOADED,o);}));}getExistingTrack(e,t){let{media:i}=this;if(i)for(let r=0;r<i.textTracks.length;r++){let n=i.textTracks[r];if(Mu(n,{name:e,lang:t}))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,Qi(i[e]),ef(i[e],r);else {let l=this.createTextTrack("captions",n,a);l&&(l[e]=true,i[e]=l);}}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(p.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,this._cleanTracks();}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{Qi(e[t]),delete e[t];}),this.nonNativeCaptionsTracks={};}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Pu(),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++)Qi(t[i]);}onSubtitleTracksUpdated(e,t){let i=t.subtitleTracks||[],r=i.some(n=>n.textCodec===nl);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(xf(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){let a=this.media,o=a?In(a.textTracks):null;if(this.tracks.forEach((l,d)=>{let c;if(o){let h=null;for(let u=0;u<o.length;u++)if(o[u]&&Mu(o[u],l)){h=o[u],o[u]=null;break}h&&(c=h);}if(c)Qi(c);else {let h=Mf(l);c=this.createTextTrack(h,l.name,l.lang),c&&(c.mode="disabled");}c&&this.textTracks.push(c);}),o!=null&&o.length){let l=o.filter(d=>d!==null).map(d=>d.label);l.length&&S.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`);}}else if(this.tracks.length){let a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(p.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===H.MAIN){var i,r;let{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:l,sn:d}=t.frag,c=(i=(r=t.part)==null?void 0:r.index)!=null?i:-1;n&&a&&(d!==o+1||d===o&&c!==this.lastPartIndex+1||l!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=l,this.lastSn=d,this.lastPartIndex=c;}}onFragLoaded(e,t){let{frag:i,payload:r}=t;if(i.type===H.SUBTITLE)if(r.byteLength){let n=i.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[i.level],l=this.vttCCs;l[i.cc]||(l[i.cc]={start:i.start,prevCC:this.prevCC,new:true},this.prevCC=i.cc),o&&o.textCodec===nl?this._parseIMSC1(i,r):this._parseVTTs(t);}}else this.hls.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:false,frag:i,error:new Error("Empty subtitle payload")});}_parseIMSC1(e,t){let i=this.hls;Cu(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),i.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:true,frag:e});},r=>{S.log(`Failed to parse IMSC1: ${r}`),i.trigger(p.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 l=this.hls,d=(t=i.initSegment)!=null&&t.data?st(i.initSegment.data,new Uint8Array(r)):r;J0(d,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,c=>{this._appendCues(c,i.level),l.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:true,frag:i});},c=>{let h=c.message==="Missing initPTS for VTT MPEGTS";h?a.push(e):this._fallbackToIMSC1(i,r),S.log(`Failed to parse VTT cue: ${c}`),!(h&&o>i.cc)&&l.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:false,frag:i,error:c});});}_fallbackToIMSC1(e,t){let i=this.tracks[e.level];i.textCodec||Cu(t,this.initPTS[e.cc],()=>{i.textCodec=nl,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=>tf(r,n));}else {let r=this.tracks[t];if(!r)return;let n=r.default?"default":"subtitles"+t;i.trigger(p.CUES_PARSED,{type:"subtitles",cues:e,track:n});}}onFragDecrypted(e,t){let{frag:i}=t;i.type===H.SUBTITLE&&this.onFragLoaded(p.FRAG_LOADED,t);}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={};}onFragParsingUserdata(e,t){this.initCea608Parsers();let{cea608Parser1:i,cea608Parser2:r}=this;if(!this.enabled||!i||!r)return;let{frag:n,samples:a}=t;if(!(n.type===H.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){let l=a[o].bytes;if(l){let d=this.extractCea608Data(l);i.addData(a[o].pts,d[0]),r.addData(a[o].pts,d[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(l=>pl(o[l],t,i));}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>pl(o[l],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++],l=127&e[r++];if(o===0&&l===0)continue;if((4&a)!==0){let c=3&a;(c===0||c===1)&&(t[c].push(o),t[c].push(l));}}return t}};function Mf(s){return s.characteristics&&/transcribes-spoken-dialog/gi.test(s.characteristics)&&/describes-music-and-sound/gi.test(s.characteristics)?"captions":"subtitles"}function Mu(s,e){return !!s&&s.kind===Mf(e)&&Kl(e,s)}function nE(s,e,t,i){return Math.min(e,i)-Math.max(s,t)}function Pu(){return {ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:true}}}var ad=class s{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners();}setStreamController(e){this.streamController=e;}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null;}registerListeners(){let{hls:e}=this;e.on(p.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this);}unregisterListener(){let{hls:e}=this;e.off(p.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this);}onFpsDropLevelCapping(e,t){let i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width});}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize();}onManifestParsed(e,t){let i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping();}onLevelsUpdated(e,t){this.timer&&F(this.autoLevelCapping)&&this.detectPlayerSize();}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping();}onMediaDetaching(){this.stopCapping();}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}let e=this.hls.levels;if(e.length){let t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&S.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping;}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return -1;let i=t.filter((r,n)=>this.isLevelAllowed(r)&&n<=e);return this.clientRect=null,s.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize());}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0);}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0);}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio;}catch{}return e}isLevelAllowed(e){return !this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return -1;let r=(o,l)=>l?o.width!==l.width||o.height!==l.height:true,n=e.length-1,a=Math.max(t,i);for(let o=0;o<e.length;o+=1){let l=e[o];if((l.width>=a||l.height>=a)&&r(l,e[o+1])){n=o;break}}return n}},od=class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=false,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners();}setStreamController(e){this.streamController=e;}registerListeners(){this.hls.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this);}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this);}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=false,this.media=null;}onMediaAttaching(e,t){let i=this.hls.config;if(i.capLevelOnFPSDrop){let r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=true),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod);}}checkFPS(e,t,i){let r=performance.now();if(t){if(this.lastTime){let n=r-this.lastTime,a=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(p.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:i}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let c=d.currentLevel;S.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=c)&&(c=c-1,d.trigger(p.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:d.currentLevel}),d.autoLevelCapping=c,this.streamController.nextLevelSwitch());}}this.lastTime=r,this.lastDroppedFrames=i,this.lastDecodedFrames=t;}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames);}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount);}},_n="[eme]",ia=class s{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=s.CDMCleanupPromise?[s.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=S.debug.bind(S,_n),this.log=S.log.bind(S,_n),this.warn=S.warn.bind(S,_n),this.error=S.error.bind(S,_n),this.hls=e,this.config=e.config,this.registerListeners();}destroy(){this.unregisterListeners(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null;}registerListeners(){this.hls.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.MANIFEST_LOADED,this.onManifestLoaded,this);}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(p.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(p.MANIFEST_LOADED,this.onManifestLoaded,this);}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:i}=this.config,r=t[e];if(r)return r.licenseUrl;if(e===de.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){let{drmSystems:t}=this.config,i=t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`);}attemptKeySystemAccess(e){let t=this.hls.levels,i=(a,o,l)=>!!a&&l.indexOf(a)===o,r=t.map(a=>a.audioCodec).filter(i),n=t.map(a=>a.videoCodec).filter(i);return r.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{let l=d=>{let c=d.shift();this.getMediaKeysPromise(c,r,n).then(h=>a({keySystem:c,mediaKeys:h})).catch(h=>{d.length?l(d):h instanceof ze?o(h):o(new ze({type:K.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_ACCESS,error:h,fatal:true},h.message));});};l(e);})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let r=`Configured requestMediaKeySystemAccess is not a function ${i}`;return Gu===null&&self.location.protocol==="http:"&&(r=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(r))}return i(e,t)}getMediaKeysPromise(e,t,i){let r=zg(e,t,i,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e],a=n?.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(r)}`),a=this.requestMediaKeySystemAccess(e,r);let o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`);}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);let d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(c=>(this.log(`Media-keys created for "${e}"`),d.then(h=>h?this.setMediaKeysServerCertificate(c,e,h):c))),o.mediaKeys.catch(c=>{this.error(`Failed to create media-keys for "${e}"}: ${c}`);}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${Pt.hexDump(e.keyId||[])}`);let r=i.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let i=this.createMediaKeySessionContext(e),r=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(i,n,t.pssh,"expired");}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e);}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Pt.hexDump(e.keyId)}updateKeySession(e,t){var i;let r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyID ${Pt.hexDump(((i=e.decryptdata)==null?void 0:i.keyId)||[])}
|
|
1129
|
-
} (data length: ${t&&t.byteLength})`),r.update(t)}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,i)=>{let r=Wo(this.config),n=e.map(qh).filter(a=>!!a&&r.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=Xh(a);o?t(o):i(new Error(`Unable to find format for key-system "${a}"`));}).catch(i)})}loadKey(e){let t=e.keyInfo.decryptdata,i=this.getKeyIdString(t),r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);let n=this.keyIdToKeySessionPromise[i];return n||(n=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();let l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t});return this.generateRequestWithPreferredKeySession(l,"cenc",t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof ze?this.hls.trigger(p.ERROR,e.data):this.hls.trigger(p.ERROR,{type:K.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_KEYS,error:e,fatal:true}));}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){let r=qh(e.keyFormat),n=r?[r]:Wo(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=Wo(this.config)),e.length===0)throw new ze({type:K.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:true},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){let{initDataType:t,initData:i}=e,r=`"${e.type}" event: init data type: "${t}"`;if(this.debug(r),i===null)return;let n,a;if(t==="sinf"&&this.config.drmSystems[de.FAIRPLAY]){let h=xe(new Uint8Array(i));try{let u=Ad(JSON.parse(h).sinf),f=Xu(new Uint8Array(u));if(!f)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");n=f.subarray(8,24),a=de.FAIRPLAY;}catch(u){this.warn(`${r} Failed to parse sinf: ${u}`);return}}else {let h=Tp(i),u=h.filter(f=>f.systemId===Fs.WIDEVINE)[0];if(!u){h.length===0||h.some(f=>!f.systemId)?this.warn(`${r} contains incomplete or invalid pssh data`):this.log(`ignoring ${r} for ${h.map(f=>zh(f.systemId)).join(",")} pssh data in favor of playlist keys`);return}if(a=zh(u.systemId),u.version===0&&u.data){let f=u.data.length-22;n=u.data.subarray(f,f+16);}}if(!a||!n)return;let o=Pt.hexDump(n),{keyIdToKeySessionPromise:l,mediaKeySessions:d}=this,c=l[o];for(let h=0;h<d.length;h++){let u=d[h],f=u.decryptdata;if(!f.keyId)continue;let m=Pt.hexDump(f.keyId);if(o===m||f.uri.replace(/-/g,"").indexOf(o)!==-1){if(c=l[m],f.pssh)break;delete l[m],f.pssh=new Uint8Array(i),f.keyId=n,c=l[o]=c.then(()=>this.generateRequestWithPreferredKeySession(u,t,i,"encrypted-event-key-match"));break}}c||(c=l[o]=this.getKeySystemSelectionPromise([a]).then(({keySystem:h,mediaKeys:u})=>{var f;this.throwIfDestroyed();let m=new Hs("ISO-23001-7",o,(f=Xh(h))!=null?f:"");return m.pssh=new Uint8Array(i),m.keyId=n,this.attemptSetMediaKeys(h,u).then(()=>{this.throwIfDestroyed();let g=this.createMediaKeySessionContext({decryptdata:m,keySystem:h,mediaKeys:u});return this.generateRequestWithPreferredKeySession(g,t,i,"encrypted-event-no-match")})})),c.catch(h=>this.handleError(h));}_onWaitingForKey(e){this.log(`"${e.type}" event`);}attemptSetMediaKeys(e,t){let i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let r=Promise.all(i).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>i.indexOf(n)===-1);})}generateRequestWithPreferredKeySession(e,t,i,r){var n,a;let o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{let m=o.call(this.hls,t,i,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,i=e.decryptdata.pssh=m.initData?new Uint8Array(m.initData):null;}catch(m){var l;if(this.warn(m.message),(l=this.hls)!=null&&l.config.debug)throw m}if(i===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);let d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${r}": ${d} (init data type: ${t} length: ${i?i.byteLength:null})`);let c=new Ld,h=e._onmessage=m=>{let g=e.mediaKeysSession;if(!g){c.emit("error",new Error("invalid state"));return}let{messageType:E,message:v}=m;this.log(`"${E}" message event for session "${g.sessionId}" message size: ${v.byteLength}`),E==="license-request"||E==="license-renewal"?this.renewLicense(e,v).catch(A=>{this.handleError(A),c.emit("error",A);}):E==="license-release"?e.keySystem===de.FAIRPLAY&&(this.updateKeySession(e,fl("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${E}"`);},u=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){c.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);let E=e.keyStatus;c.emit("keyStatus",E),E==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e));};e.mediaKeysSession.addEventListener("message",h),e.mediaKeysSession.addEventListener("keystatuseschange",u);let f=new Promise((m,g)=>{c.on("error",g),c.on("keyStatus",E=>{E.startsWith("usable")?m():E==="output-restricted"?g(new ze({type:K.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:false},"HDCP level output restricted")):E==="internal-error"?g(new ze({type:K.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:true},`key status changed to "${E}"`)):E==="expired"?g(new Error("key expired while generating request")):this.warn(`unhandled key status change "${E}"`);});});return e.mediaKeysSession.generateRequest(t,i).then(()=>{var m;this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${d}`);}).catch(m=>{throw new ze({type:K.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_SESSION,error:m,fatal:false},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>{throw c.removeAllListeners(),this.removeSession(e),m}).then(()=>(c.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,i)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Pt.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Pt.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t;});}fetchServerCertificate(e){let t=this.config,i=t.loader,r=new i(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{let l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(u,f,m,g)=>{a(u.data);},onError:(u,f,m,g)=>{o(new ze({type:K.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:true,networkDetails:m,response:Oe({url:l.url,data:void 0},u)},`"${e}" certificate request failed (${n}). Status: ${u.code} (${u.text})`));},onTimeout:(u,f,m)=>{o(new ze({type:K.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:true,networkDetails:m,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`));},onAbort:(u,f,m)=>{o(new Error("aborted"));}};r.load(l,c,h);})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((r,n)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i?.byteLength}) on "${t}"`),r(e);}).catch(a=>{n(new ze({type:K.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:true},a.message));});})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(r=>{throw new ze({type:K.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:r,fatal:true},r.message)}))}unpackPlayReadyKeyMessage(e,t){let i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;let r=new DOMParser().parseFromString(i,"application/xml"),n=r.querySelectorAll("HttpHeader");if(n.length>0){let c;for(let h=0,u=n.length;h<u;h++){var a,o;c=n[h];let f=(a=c.querySelector("name"))==null?void 0:a.textContent,m=(o=c.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m);}}let l=r.querySelector("Challenge"),d=l?.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return fl(atob(d))}setupLicenseXHR(e,t,i,r){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,i,r)}).catch(a=>{if(!i.decryptdata)throw a;return e.open("POST",t,true),n.call(this.hls,e,t,i,r)}).then(a=>(e.readyState||e.open("POST",t,true),{xhr:e,licenseChallenge:a||r})):(e.open("POST",t,true),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){let i=this.config.keyLoadPolicy.default;return new Promise((r,n)=>{let a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);let o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);let d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e);}catch(c){this.error(c);}r(l);}else {let l=i.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new ze({type:K.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:true,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else {let c=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${c} attempts left`),this.requestLicense(e,t).then(r,n);}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{e.keySystem==de.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(l,d)),l.send(d);});})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey);}onMediaDetached(){let e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Hs.clearKeyUriToKeyIdMap();let i=t.length;s.CDMCleanupPromise=Promise.all(t.map(r=>this.removeSession(r)).concat(e?.setMediaKeys(null).catch(r=>{this.log(`Could not clear media keys: ${r}`);}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),t.length=0);}).catch(r=>{this.log(`Could not close sessions and clear media keys: ${r}`);});}onManifestLoading(){this.keyFormatPromise=null;}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){let i=t.reduce((r,n)=>(r.indexOf(n.keyFormat)===-1&&r.push(n.keyFormat),r),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i);}}removeSession(e){let{mediaKeysSession:t,licenseXhr:i}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let r=this.mediaKeySessions.indexOf(e);return r>-1&&this.mediaKeySessions.splice(r,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`);}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`);})}}};ia.CDMCleanupPromise=void 0;var ze=class extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error;}},He;(function(s){s.MANIFEST="m",s.AUDIO="a",s.VIDEO="v",s.MUXED="av",s.INIT="i",s.CAPTION="c",s.TIMED_TEXT="tt",s.KEY="k",s.OTHER="o";})(He||(He={}));var ld;(function(s){s.DASH="d",s.HLS="h",s.SMOOTH="s",s.OTHER="o";})(ld||(ld={}));var Ei;(function(s){s.OBJECT="CMCD-Object",s.REQUEST="CMCD-Request",s.SESSION="CMCD-Session",s.STATUS="CMCD-Status";})(Ei||(Ei={}));var aE={[Ei.OBJECT]:["br","d","ot","tb"],[Ei.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[Ei.SESSION]:["cid","pr","sf","sid","st","v"],[Ei.STATUS]:["bs","rtp"]},Xs=class s{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(i=>i instanceof s?i:new s(i))),this.value=e,this.params=t;}},sa=class{constructor(e){this.description=void 0,this.description=e;}},oE="Dict";function lE(s){return Array.isArray(s)?JSON.stringify(s):s instanceof Map?"Map{}":s instanceof Set?"Set{}":typeof s=="object"?JSON.stringify(s):String(s)}function dE(s,e,t,i){return new Error(`failed to ${s} "${lE(e)}" as ${t}`,{cause:i})}var Ou="Bare Item",cE="Boolean",hE="Byte Sequence",uE="Decimal",fE="Integer";function mE(s){return s<-999999999999999||999999999999999<s}var gE=/[\x00-\x1f\x7f]+/,pE="Token",EE="Key";function Ut(s,e,t){return dE("serialize",s,e,t)}function vE(s){if(typeof s!="boolean")throw Ut(s,cE);return s?"?1":"?0"}function TE(s){return btoa(String.fromCharCode(...s))}function AE(s){if(ArrayBuffer.isView(s)===false)throw Ut(s,hE);return `:${TE(s)}:`}function Pf(s){if(mE(s))throw Ut(s,fE);return s.toString()}function bE(s){return `@${Pf(s.getTime()/1e3)}`}function Of(s,e){if(s<0)return -Of(-s,e);let t=Math.pow(10,e);if(Math.abs(s*t%1-.5)<Number.EPSILON){let r=Math.floor(s*t);return (r%2===0?r:r+1)/t}else return Math.round(s*t)/t}function yE(s){let e=Of(s,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Ut(s,uE);let t=e.toString();return t.includes(".")?t:`${t}.0`}var SE="String";function _E(s){if(gE.test(s))throw Ut(s,SE);return `"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function xE(s){return s.description||s.toString().slice(7,-1)}function Nu(s){let e=xE(s);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===false)throw Ut(e,pE);return e}function dd(s){switch(typeof s){case "number":if(!F(s))throw Ut(s,Ou);return Number.isInteger(s)?Pf(s):yE(s);case "string":return _E(s);case "symbol":return Nu(s);case "boolean":return vE(s);case "object":if(s instanceof Date)return bE(s);if(s instanceof Uint8Array)return AE(s);if(s instanceof sa)return Nu(s);default:throw Ut(s,Ou)}}function cd(s){if(/^[a-z*][a-z0-9\-_.*]*$/.test(s)===false)throw Ut(s,EE);return s}function Cd(s){return s==null?"":Object.entries(s).map(([e,t])=>t===true?`;${cd(e)}`:`;${cd(e)}=${dd(t)}`).join("")}function Nf(s){return s instanceof Xs?`${dd(s.value)}${Cd(s.params)}`:dd(s)}function IE(s){return `(${s.value.map(Nf).join(" ")})${Cd(s.params)}`}function LE(s,e={whitespace:true}){if(typeof s!="object")throw Ut(s,oE);let t=s instanceof Map?s.entries():Object.entries(s),i=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([r,n])=>{n instanceof Xs||(n=new Xs(n));let a=cd(r);return n.value===true?a+=Cd(n.params):(a+="=",Array.isArray(n.value)?a+=IE(n):a+=Nf(n)),a}).join(`,${i}`)}function RE(s,e){return LE(s,e)}var DE=s=>s==="ot"||s==="sf"||s==="st",CE=s=>typeof s=="number"?F(s):s!=null&&s!==""&&s!==false;function kE(s,e){let t=new URL(s),i=new URL(e);if(t.origin!==i.origin)return s;let r=t.pathname.split("/").slice(1),n=i.pathname.split("/").slice(1,-1);for(;r[0]===n[0];)r.shift(),n.shift();for(;n.length;)n.shift(),r.unshift("..");return r.join("/")}function wE(){try{return crypto.randomUUID()}catch{try{let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(r=="x"?n:n&3|8).toString(16)})}}}var kn=s=>Math.round(s),ME=(s,e)=>(e!=null&&e.baseUrl&&(s=kE(s,e.baseUrl)),encodeURIComponent(s)),xn=s=>kn(s/100)*100,PE={br:kn,d:kn,bl:xn,dl:xn,mtp:xn,nor:ME,rtp:xn,tb:kn};function OE(s,e){let t={};if(s==null||typeof s!="object")return t;let i=Object.keys(s).sort(),r=_e({},PE,e?.formatters),n=e?.filter;return i.forEach(a=>{if(n!=null&&n(a))return;let o=s[a],l=r[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||CE(o)&&(DE(a)&&typeof o=="string"&&(o=new sa(o)),t[a]=o));}),t}function Ff(s,e={}){return s?RE(OE(s,e),_e({whitespace:false},e)):""}function NE(s,e={}){if(!s)return {};let t=Object.entries(s),i=Object.entries(aE).concat(Object.entries(e?.customHeaderMap||{})),r=t.reduce((n,a)=>{var o;let[d,c]=a,h=((o=i.find(u=>u[1].includes(d)))==null?void 0:o[0])||Ei.REQUEST;return (n[h])!=null||(n[h]={}),n[h][d]=c,n},{});return Object.entries(r).reduce((n,[a,o])=>(n[a]=Ff(o,e),n),{})}function FE(s,e,t){return _e(s,NE(e,t))}var UE="CMCD";function BE(s,e={}){if(!s)return "";let t=Ff(s,e);return `${UE}=${encodeURIComponent(t)}`}var Fu=/CMCD=[^&#]+/;function $E(s,e,t){let i=BE(e,t);if(!i)return s;if(Fu.test(s))return s.replace(Fu,i);let r=s.includes("?")?"&":"?";return `${s}${r}${i}`}var hd=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=false,this.includeKeys=void 0,this.initialized=false,this.starved=false,this.buffering=true,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=true),this.buffering=true;},this.onPlaying=()=>{this.initialized||(this.initialized=true),this.buffering=false;},this.applyPlaylistData=r=>{try{this.apply(r,{ot:He.MANIFEST,su:!this.initialized});}catch(n){S.warn("Could not generate manifest CMCD data.",n);}},this.applyFragmentData=r=>{try{let n=r.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===He.VIDEO||o===He.AUDIO||o==He.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(r,l);}catch(n){S.warn("Could not generate segment CMCD data.",n);}},this.hls=e;let t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||wE(),this.cid=i.contentId,this.useHeaders=i.useHeaders===true,this.includeKeys=i.includeKeys,this.registerListeners());}registerListeners(){let e=this.hls;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHED,this.onMediaDetached,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this);}unregisterListeners(){let e=this.hls;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHED,this.onMediaDetached,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this);}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null;}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying);}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null);}onBufferCreated(e,t){var i,r;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer;}createData(){var e;return {v:1,sf:ld.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){_e(t,this.createData());let i=t.ot===He.INIT||t.ot===He.VIDEO||t.ot===He.MUXED;this.starved&&i&&(t.bs=true,t.su=true,this.starved=false),t.su==null&&(t.su=this.buffering);let{includeKeys:r}=this;r&&(t=Object.keys(t).reduce((n,a)=>(r.includes(a)&&(n[a]=t[a]),n),{})),this.useHeaders?(e.headers||(e.headers={}),FE(e.headers,t)):e.url=$E(e.url,t);}getObjectType(e){let{type:t}=e;if(t==="subtitle")return He.TIMED_TEXT;if(e.sn==="initSegment")return He.INIT;if(t==="audio")return He.AUDIO;if(t==="main")return this.hls.audioTracks.length?He.VIDEO:He.MUXED}getTopBandwidth(e){let t=0,i,r=this.hls;if(e===He.AUDIO)i=r.audioTracks;else {let n=r.maxAutoLevel,a=n>-1?n+1:r.levels.length;i=r.levels.slice(0,a);}for(let n of i)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){let t=this.hls.media,i=e===He.AUDIO?this.audioBuffer:this.videoBuffer;return !i||!t?NaN:ue.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n);}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy();}abort(){this.loader.abort();}load(n,a,o){t(n),this.loader.load(n,a,o);}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n);}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy();}abort(){this.loader.abort();}load(n,a,o){t(n),this.loader.load(n,a,o);}}}},GE=3e5,ud=class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=false,this.enabled=true,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=S.log.bind(S,"[content-steering]:"),this.registerListeners();}registerListeners(){let e=this.hls;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.ERROR,this.onError,this);}unregisterListeners(){let e=this.hls;e&&(e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.ERROR,this.onError,this));}startLoad(){if(this.started=true,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){let e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri);}}stopLoad(){this.started=false,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout();}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1);}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null;}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(i=>i!==e));}onManifestLoading(){this.stopLoad(),this.enabled=true,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null;}onManifestLoaded(e,t){let{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad());}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks;}onError(e,t){let{errorAction:i}=t;if(i?.action===Me.SendAlternateToPenaltyBox&&i.flags===ut.MoveAllAlternatesMatchingHost){let r=this.levels,n=this.pathwayPriority,a=this.pathwayId;if(t.context){let{groupId:o,pathwayId:l,type:d}=t.context;o&&r?a=this.getPathwayForGroupId(o,d,a):l&&(a=l);}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&r&&(n=r.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),n&&n.length>1&&(this.updatePathwayPriority(n),i.resolved=this.pathwayId!==a),i.resolved||S.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${r&&r.length} priorities: ${JSON.stringify(n)} penalized: ${JSON.stringify(this.penalizedPathways)}`);}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i;}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t,i=this.penalizedPathways,r=performance.now();Object.keys(i).forEach(n=>{r-i[n]>GE&&delete i[n];});for(let n=0;n<e.length;n++){let a=e[n];if(a in i)continue;if(a===this.pathwayId)return;let o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,af(t),this.hls.trigger(p.LEVELS_UPDATED,{levels:t});let d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,i){let r=this.getLevelsForPathway(i).concat(this.levels||[]);for(let n=0;n<r.length;n++)if(t===Z.AUDIO_TRACK&&r[n].hasAudioGroup(e)||t===Z.SUBTITLE_TRACK&&r[n].hasSubtitleGroup(e))return r[n].pathwayId;return i}clonePathways(e){let t=this.levels;if(!t)return;let i={},r={};e.forEach(n=>{let{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(c=>c.pathwayId===a))return;let d=this.getLevelsForPathway(o).map(c=>{let h=new Ee(c.attrs);h["PATHWAY-ID"]=a;let u=h.AUDIO&&`${h.AUDIO}_clone_${a}`,f=h.SUBTITLES&&`${h.SUBTITLES}_clone_${a}`;u&&(i[h.AUDIO]=u,h.AUDIO=u),f&&(r[h.SUBTITLES]=f,h.SUBTITLES=f);let m=Uf(c.uri,h["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),g=new Jt({attrs:h,audioCodec:c.audioCodec,bitrate:c.bitrate,height:c.height,name:c.name,url:m,videoCodec:c.videoCodec,width:c.width});if(c.audioGroups)for(let E=1;E<c.audioGroups.length;E++)g.addGroupId("audio",`${c.audioGroups[E]}_clone_${a}`);if(c.subtitleGroups)for(let E=1;E<c.subtitleGroups.length;E++)g.addGroupId("text",`${c.subtitleGroups[E]}_clone_${a}`);return g});t.push(...d),Uu(this.audioTracks,i,l,a),Uu(this.subtitleTracks,r,l,a);});}loadSteeringManifest(e){let t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let r;try{r=new self.URL(e);}catch{this.enabled=false,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){let c=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+c);}let n={responseType:"json",url:r.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(c,h,u,f)=>{this.log(`Loaded steering manifest: "${r}"`);let m=c.data;if(m.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;let{"RELOAD-URI":g,"PATHWAY-CLONES":E,"PATHWAY-PRIORITY":v}=m;if(g)try{this.uri=new self.URL(g,r).href;}catch{this.enabled=false,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${g}`);return}this.scheduleRefresh(this.uri||u.url),E&&this.clonePathways(E);let A={steeringManifest:m,url:r.toString()};this.hls.trigger(p.STEERING_MANIFEST_LOADED,A),v&&this.updatePathwayPriority(v);},onError:(c,h,u,f)=>{if(this.log(`Error loading steering manifest: ${c.code} ${c.text} (${h.url})`),this.stopLoad(),c.code===410){this.enabled=false,this.log(`Steering manifest ${h.url} no longer available`);return}let m=this.timeToLoad*1e3;if(c.code===429){let g=this.loader;if(typeof g?.getResponseHeader=="function"){let E=g.getResponseHeader("Retry-After");E&&(m=parseFloat(E)*1e3);}this.log(`Steering manifest ${h.url} rate limited`);return}this.scheduleRefresh(this.uri||h.url,m);},onTimeout:(c,h,u)=>{this.log(`Timeout loading steering manifest (${h.url})`),this.scheduleRefresh(this.uri||h.url);}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(n,l,d);}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var i;let r=(i=this.hls)==null?void 0:i.media;if(r&&!r.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3);},t);}};function Uu(s,e,t,i){s&&Object.keys(e).forEach(r=>{let n=s.filter(a=>a.groupId===r).map(a=>{let o=_e({},a);return o.details=void 0,o.attrs=new Ee(o.attrs),o.url=o.attrs.URI=Uf(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[r],o.attrs["PATHWAY-ID"]=i,o});s.push(...n);});}function Uf(s,e,t,i){let{HOST:r,PARAMS:n,[t]:a}=i,o;e&&(o=a?.[e],o&&(s=o));let l=new self.URL(s);return r&&!o&&(l.host=r),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d]);}),l.href}var HE=/^age:\s*[\d.]+\s*$/im,ra=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 ts,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=>{this.callbacks.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&&F(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 a=t.status,o=t.responseType!=="text";if(a>=200&&a<300&&(o&&t.response||t.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);let l=o?t.response:t.responseText,d=t.responseType==="arraybuffer"?l.byteLength:l.length;if(i.loaded=i.total=d,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;let c=this.callbacks.onProgress;if(c&&c(i,e,l,t),!this.callbacks)return;let h={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(h,i,e,t);}else {let l=n.loadPolicy.errorRetry,d=i.retry,c={url:e.url,data:void 0,code:a};Hn(l,d,false,c)?this.retry(l):(S.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,i));}}}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Hn(e,t,true))this.retry(e);else {var i;S.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=Sd(e,i.retry),i.retry++,S.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&&HE.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null;}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}};function VE(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return false}var KE=/(\d+)-(\d+)\/(\d+)/,na=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||zE,this.controller=new self.AbortController,this.stats=new ts;}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=WE(e,this.controller.signal),a=i.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:c}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&F(d)?d:c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(r,e,this.response);},t.timeout),self.fetch(this.request).then(h=>{this.response=this.loader=h;let u=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(r,e,this.response);},c-(u-r.loading.start)),!h.ok){let{status:f,statusText:m}=h;throw new fd(m||"fetch, bad network response",f,h)}return r.loading.first=u,r.total=qE(h.headers)||r.total,a&&F(t.highWaterMark)?this.loadProgressively(h,r,e,t.highWaterMark,a):o?h.arrayBuffer():e.responseType==="json"?h.json():h.text()}).then(h=>{let u=this.response;if(!u)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);let f=h[l];f&&(r.loaded=r.total=f);let m={url:u.url,data:h,code:u.status};a&&!F(t.highWaterMark)&&a(r,e,h,u),i.onSuccess(m,r,e,u);}).catch(h=>{if(self.clearTimeout(this.requestTimeout),r.aborted)return;let u=h&&h.code||0,f=h?h.message:null;i.onError({code:u,text:f},e,h?h.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 Wn,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,i,a.flush(),e),Promise.resolve(new ArrayBuffer(0));let c=d.value,h=c.length;return t.loaded+=h,h<r||a.dataLength?(a.push(c),a.dataLength>=r&&n(t,i,a.flush(),e)):n(t,i,c,e),l()}).catch(()=>Promise.reject());return l()}};function WE(s,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(_e({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function YE(s){let e=KE.exec(s);if(e)return parseInt(e[2])-parseInt(e[1])+1}function qE(s){let e=s.get("Content-Range");if(e){let i=YE(e);if(F(i))return i}let t=s.get("Content-Length");if(t)return parseInt(t)}function zE(s,e){return new self.Request(s.url,e)}var fd=class extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i;}},XE=/\s/,jE={newCue(s,e,t,i){let r=[],n,a,o,l,d,c=self.VTTCue||self.TextTrackCue;for(let u=0;u<i.rows.length;u++)if(n=i.rows[u],o=true,l=0,d="",!n.isEmpty()){var h;for(let g=0;g<n.chars.length;g++)XE.test(n.chars[g].uchar)&&o?l++:(d+=n.chars[g].uchar,o=false);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;let f=Df(d.trim()),m=Dd(e,t,f);s!=null&&(h=s.cues)!=null&&h.getCueById(m)||(a=new c(e,t,f),a.id=m,a.line=u+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),r.push(a));}return s&&r.length&&(r.sort((u,f)=>u.line==="auto"||f.line==="auto"?0:u.line>8&&f.line>8?f.line-u.line:u.line-f.line),r.forEach(u=>tf(s,u))),r}},QE={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Bf=Oe(Oe({autoStartLoad:true,startPosition:-1,defaultAudioCodec:void 0,debug:false,capLevelOnFPSDrop:false,capLevelToPlayerSize:false,ignoreDevicePixelRatio:false,preferManagedMediaSource:true,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:false,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:true,workerPath:null,enableSoftwareAES:true,startLevel:void 0,startFragPrefetch:false,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:ra,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:xl,bufferController:Ql,capLevelController:ad,errorController:Sl,fpsController:od,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:Gu,testBandwidth:true,progressive:false,lowLatencyMode:true,cmcd:void 0,enableDateRangeMetadataCues:true,enableEmsgMetadataCues:true,enableID3MetadataCues:true,useMediaCapabilities:true,certLoadPolicy:{default:QE},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},ZE()),{},{subtitleStreamController:ql,subtitleTrackController:Xl,timelineController:nd,audioStreamController:Wl,audioTrackController:Yl,emeController:ia,cmcdController:hd,contentSteeringController:ud});function ZE(){return {cueHandler:jE,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 JE(s,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let t=md(s),i=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(n=>{let a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];r.forEach(d=>{let c=`${n}Loading${d}`,h=e[c];if(h!==void 0&&o){l.push(c);let u=t[a].default;switch(e[a]={default:u},d){case "TimeOut":u.maxLoadTimeMs=h,u.maxTimeToFirstByteMs=h;break;case "MaxRetry":u.errorRetry.maxNumRetry=h,u.timeoutRetry.maxNumRetry=h;break;case "RetryDelay":u.errorRetry.retryDelayMs=h,u.timeoutRetry.retryDelayMs=h;break;case "MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=h,u.timeoutRetry.maxRetryDelayMs=h;break}}}),l.length&&S.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`);}),Oe(Oe({},t),e)}function md(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(md):Object.keys(s).reduce((e,t)=>(e[t]=md(s[t]),e),{}):s}function ev(s){let e=s.loader;e!==na&&e!==ra?(S.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=false):VE()&&(s.loader=na,s.progressive=true,s.enableSoftwareAES=true,S.log("[config]: Progressive streaming enabled, using FetchLoader"));}var dl,gd=class extends Ks{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(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.ERROR,this.onError,this);}_unregisterListeners(){let{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.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,l=false,d=false;t.levels.forEach(c=>{var h,u;let f=c.attrs,{audioCodec:m,videoCodec:g}=c;((h=m)==null?void 0:h.indexOf("mp4a.40.34"))!==-1&&(dl||(dl=/chrome|firefox/i.test(navigator.userAgent)),dl&&(c.audioCodec=m=void 0)),m&&(c.audioCodec=m=Un(m,i)),((u=g)==null?void 0:u.indexOf("avc1"))===0&&(g=c.videoCodec=Lp(g));let{width:E,height:v,unknownCodecs:A}=c;if(o||(o=!!(E&&v)),l||(l=!!g),d||(d=!!m),A!=null&&A.length||m&&!Xo(m,"audio",i)||g&&!Xo(g,"video",i))return;let{CODECS:b,"FRAME-RATE":L,"HDCP-LEVEL":y,"PATHWAY-ID":D,RESOLUTION:I,"VIDEO-RANGE":k}=f,R=`${`${D||"."}-`}${c.bitrate}-${I}-${L}-${b}-${k}-${y}`;if(n[R])if(n[R].uri!==c.url&&!c.attrs["PATHWAY-ID"]){let w=a[R]+=1;c.attrs["PATHWAY-ID"]=new Array(w+1).join(".");let X=new Jt(c);n[R]=X,r.push(X);}else n[R].addGroupId("audio",f.AUDIO),n[R].addGroupId("text",f.SUBTITLES);else {let w=new Jt(c);n[R]=w,a[R]=1,r.push(w);}}),this.filterAndSortMediaOptions(r,t,o,l,d);}filterAndSortMediaOptions(e,t,i,r,n){let a=[],o=[],l=e;if((i||r)&&n&&(l=l.filter(({videoCodec:m,videoRange:g,width:E,height:v})=>(!!m||!!(E&&v))&&Fp(g))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);let m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(p.ERROR,{type:K.MEDIA_ERROR,details:x.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:true,url:t.url,error:m,reason:m.message});}});return}if(t.audioTracks){let{preferManagedMediaSource:m}=this.hls.config;a=t.audioTracks.filter(g=>!g.audioCodec||Xo(g.audioCodec,"audio",m)),Bu(a);}t.subtitles&&(o=t.subtitles,Bu(o));let d=l.slice(0);l.sort((m,g)=>{if(m.attrs["HDCP-LEVEL"]!==g.attrs["HDCP-LEVEL"])return (m.attrs["HDCP-LEVEL"]||"")>(g.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&m.height!==g.height)return m.height-g.height;if(m.frameRate!==g.frameRate)return m.frameRate-g.frameRate;if(m.videoRange!==g.videoRange)return Bn.indexOf(m.videoRange)-Bn.indexOf(g.videoRange);if(m.videoCodec!==g.videoCodec){let E=eu(m.videoCodec),v=eu(g.videoCodec);if(E!==v)return v-E}if(m.uri===g.uri&&m.codecSet!==g.codecSet){let E=Fn(m.codecSet),v=Fn(g.codecSet);if(E!==v)return v-E}return m.averageBitrate!==g.averageBitrate?m.averageBitrate-g.averageBitrate:0});let c=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let m=0;m<d.length;m++)if(d[m].pathwayId===l[0].pathwayId){c=d[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===c){var h;this._firstLevel=m;let g=c.bitrate,E=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${g}`),((h=this.hls.userConfig)==null?void 0:h.abrEwmaDefaultEstimate)===void 0){let v=Math.min(g,this.hls.config.abrEwmaDefaultEstimateMax);v>E&&E===Bf.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=v);}break}let u=n&&!r,f={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:r,altAudio:!u&&a.some(m=>!!m.url)};this.hls.trigger(p.MANIFEST_PARSED,f),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition);}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let c=new Error("invalid level idx"),h=e<0;if(this.hls.trigger(p.ERROR,{type:K.OTHER_ERROR,details:x.LEVEL_SWITCH_ERROR,level:e,fatal:h,error:c,reason:c.message}),h)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&&a.details&&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 l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(p.LEVEL_SWITCHING,l);let d=a.details;if(!d||d.live){let c=this.switchParams(a.uri,r?.details,d);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;}onError(e,t){t.fatal||!t.context||t.context.type===Z.LEVEL&&t.context.level===this.level&&this.checkRetry(t);}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===H.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=this._levels[r];if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=true);return}r===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(r,t,a.details)):(i=t.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=true);}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){let r=i.uri;if(e)try{r=e.addDirectives(r);}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`);}let n=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${e?.msn!==void 0?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} ${r}`),this.clearTimer(),this.hls.trigger(p.LEVEL_LOADING,{url:r,level:t,pathwayId:i.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null});}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e);}removeLevel(e){var t;let i=this._levels.filter((r,n)=>n!==e?true:(this.steering&&this.steering.removeLevel(r),r===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,r.details&&r.details.fragments.forEach(a=>a.level=-1)),false));af(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(p.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(p.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}));}};function Bu(s){let e={};s.forEach(t=>{let i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++;});}var pd=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=x.KEY_LOAD_ERROR,i,r,n){return new mt({type:K.NETWORK_ERROR,details:t,fatal:false,frag:e,response:n,error:i,networkDetails:r})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:i,cc:r}=e;for(let n=0;n<t.length;n++){let a=t[n];if(r<=a.cc&&(i==="initSegment"||a.sn==="initSegment"||i<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o);});break}}}}load(e){return !e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,r;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,x.KEY_LOAD_ERROR,d))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,x.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 l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case "status-pending":case "usable":case "usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case "ISO-23001-7":case "SAMPLE-AES":case "SAMPLE-AES-CENC":case "SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case "AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,x.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 l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=i.keyLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(u,f,m,g)=>{let{frag:E,keyInfo:v,url:A}=m;if(!E.decryptdata||v!==this.keyUriToKeyInfo[A])return o(this.createKeyLoadError(E,x.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),g));v.decryptdata.key=E.decryptdata.key=new Uint8Array(u.data),E.keyLoader=null,v.loader=null,a({frag:E,keyInfo:v});},onError:(u,f,m,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.KEY_LOAD_ERROR,new Error(`HTTP Error ${u.code} loading key ${u.text}`),m,Oe({url:l.url,data:void 0},u)));},onTimeout:(u,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m));},onAbort:(u,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.INTERNAL_ABORTED,new Error("key loading aborted"),m));}};n.load(l,c,h);})}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 $f(){return self.SourceBuffer||self.WebKitSourceBuffer}function Gf(){if(!Ti())return false;let e=$f();return !e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function tv(){if(!Gf())return false;let s=Ti();return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>s.isTypeSupported(Vs(e,"video")))||["mp4a.40.2","fLaC"].some(e=>s.isTypeSupported(Vs(e,"audio"))))}function iv(){var s;let e=$f();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}var sv=250,wn=2,rv=.1,nv=.05,Ed=class{constructor(e,t,i,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=false,this.stalled=null,this.moved=false,this.seeking=false,this.config=e,this.media=t,this.fragmentTracker=i,this.hls=r;}destroy(){this.media=null,this.hls=this.fragmentTracker=null;}poll(e,t){let{config:i,media:r,stalled:n}=this;if(r===null)return;let{currentTime:a,seeking:o}=r,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=true,o||(this.nudgeRetry=0),n!==null){if(this.stallReported){let E=self.performance.now()-n;S.warn(`playback not stuck anymore @${a}, after ${Math.round(E)}ms`),this.stallReported=false;}this.stalled=null;}return}if(d||l){this.stalled=null;return}if(r.paused&&!o||r.ended||r.playbackRate===0||!ue.getBuffered(r).length){this.nudgeRetry=0;return}let c=ue.bufferInfo(r,a,0),h=c.nextStart||0;if(o){let E=c.len>wn,v=!h||t&&t.start<=a||h-a>wn&&!this.fragmentTracker.getPartialFragment(a);if(E||v)return;this.moved=false;}if(!this.moved&&this.stalled!==null){var u;if(!(c.len>0)&&!h)return;let v=Math.max(h,c.start||0)-a,A=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,L=(A==null||(u=A.details)==null?void 0:u.live)?A.details.targetduration*2:wn,y=this.fragmentTracker.getPartialFragment(a);if(v>0&&(v<=L||y)){r.paused||this._trySkipBufferHole(y);return}}let f=self.performance.now();if(n===null){this.stalled=f;return}let m=f-n;if(!o&&m>=sv&&(this._reportStall(c),!this.media))return;let g=ue.bufferInfo(r,a,i.maxBufferHole);this._tryFixBufferStall(g,m);}_tryFixBufferStall(e,t){let{config:i,fragmentTracker:r,media:n}=this;if(n===null)return;let a=n.currentTime,o=r.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>i.maxBufferHole||e.nextStart&&e.nextStart-a<i.maxBufferHole)&&t>i.highBufferWatchdogPeriod*1e3&&(S.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer());}_reportStall(e){let{hls:t,media:i,stallReported:r}=this;if(!r&&i){this.stallReported=true;let n=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(e)})`);S.warn(n.message),t.trigger(p.ERROR,{type:K.MEDIA_ERROR,details:x.BUFFER_STALLED_ERROR,fatal:false,error:n,buffer:e.len});}}_trySkipBufferHole(e){let{config:t,hls:i,media:r}=this;if(r===null)return 0;let n=r.currentTime,a=ue.bufferInfo(r,n,0),o=n<a.start?a.start:a.nextStart;if(o){let l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&r.readyState<3,c=o-n;if(c>0&&(l||d)){if(c>t.maxBufferHole){let{fragmentTracker:u}=this,f=false;if(n===0){let m=u.getAppendedFrag(0,H.MAIN);m&&o<m.end&&(f=true);}if(!f){let m=e||u.getAppendedFrag(n,H.MAIN);if(m){let g=false,E=m.end;for(;E<o;){let v=u.getPartialFragment(E);if(v)E+=v.duration;else {g=true;break}}if(g)return 0}}}let h=Math.max(o+nv,n+rv);if(S.warn(`skipping hole, adjusting currentTime from ${n} to ${h}`),this.moved=true,this.stalled=null,r.currentTime=h,e&&!e.gap){let u=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${h}`);i.trigger(p.ERROR,{type:K.MEDIA_ERROR,details:x.BUFFER_SEEK_OVER_HOLE,fatal:false,error:u,reason:u.message,frag:e});}return h}}return 0}_tryNudgeBuffer(){let{config:e,hls:t,media:i,nudgeRetry:r}=this;if(i===null)return;let n=i.currentTime;if(this.nudgeRetry++,r<e.nudgeMaxRetry){let a=n+(r+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);S.warn(o.message),i.currentTime=a,t.trigger(p.ERROR,{type:K.MEDIA_ERROR,details:x.BUFFER_NUDGE_ON_STALL,error:o,fatal:false});}else {let a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);S.error(a.message),t.trigger(p.ERROR,{type:K.MEDIA_ERROR,details:x.BUFFER_STALLED_ERROR,error:a,fatal:true});}}},av=100,vd=class extends qs{constructor(e,t,i){super(e,t,i,"[stream-controller]",H.MAIN),this.audioCodecSwap=false,this.gapController=null,this.level=-1,this._forceStartLoad=false,this.altAudio=false,this.audioOnly=false,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=false,this.backtrackFragment=null,this.audioCodecSwitch=false,this.videoBuffer=null,this._registerListeners();}_registerListeners(){let{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(p.ERROR,this.onError,this),e.on(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this),e.on(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this);}_unregisterListeners(){let{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(p.ERROR,this.onError,this),e.off(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this),e.off(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this);}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying();}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:i}=this;if(this.stopLoad(),this.setInterval(av),this.level=-1,!this.startFragRequested){let r=i.startLevel;r===-1&&(i.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=true):r=i.firstAutoLevel),i.nextLoadLevel=r,this.level=i.loadLevel,this.loadedmetadata=false;}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=C.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=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)){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(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged();}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:i,media:r}=this;if(t===null||!r&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;let n=e.nextLoadLevel;if(!(i!=null&&i[n]))return;let a=i[n],o=this.getMainFwdBufferInfo();if(o===null)return;let l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){let g={};this.altAudio&&(g.type="video"),this.hls.trigger(p.BUFFER_EOS,g),this.state=C.ENDED;return}e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;let d=a.details;if(!d||this.state===C.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a){this.level=n,this.state=C.WAITING_LEVEL;return}let c=o.len,h=this.getMaxBufferLength(a.maxBitrate);if(c>=h)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);let u=this.backtrackFragment?this.backtrackFragment.start:o.end,f=this.getNextFragment(u,d);if(this.couldBacktrack&&!this.fragPrevious&&f&&f.sn!=="initSegment"&&this.fragmentTracker.getState(f)!==Pe.OK){var m;let E=((m=this.backtrackFragment)!=null?m:f).sn-d.startSN,v=d.fragments[E-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,u)){if(!f.gap){let E=this.audioOnly&&!this.altAudio?ne.AUDIO:ne.VIDEO,v=(E===ne.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,E,H.MAIN);}f=this.getNextFragmentLoopLoading(f,d,o,H.MAIN,h);}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,u));}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);this.fragCurrent=e,r===Pe.NOT_LOADED||r===Pe.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=true,super.loadFragment(e,t,i)):this.clearTrackerIfNeeded(e);}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,H.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,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?i=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+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 l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,c=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(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?"video":null);}onMediaAttached(e,t){super.onMediaAttached(e,t);let i=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new Ed(this.config,i,this.fragmentTracker,this.hls);}onMediaDetaching(){let{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching();}onMediaPlaying(){this.tick();}onMediaSeeked(){let e=this.media,t=e?e.currentTime:null;F(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);let i=this.getMainFwdBufferInfo();if(i===null||i.len===0){this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`);return}this.tick();}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=false,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=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&&!iv(),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=i[t.level];(!r.details||r.details.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(r.details))&&(this.state=C.WAITING_LEVEL);}onLevelLoaded(e,t){var i;let{levels:r}=this,n=t.level,a=t.details,o=a.totalduration;if(!r){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);let l=r[n],d=this.fragCurrent;d&&(this.state===C.FRAG_LOADING||this.state===C.FRAG_LOADING_WAITING_RETRY)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let c=0;if(a.live||(i=l.details)!=null&&i.live){var h;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;c=this.alignPlaylists(a,l.details,(h=this.levelLastLoaded)==null?void 0:h.details);}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(p.LEVEL_UPDATED,{details:a,level:n}),this.state===C.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=C.IDLE;}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,c),this.tick();}_handleFragmentLoadProgress(e){var t;let{frag:i,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],l=o.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}let d=o.videoCodec,c=l.PTSKnown||!l.live,h=(t=i.initSegment)==null?void 0:t.data,u=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new Zn(this.hls,H.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=r?r.index:-1,g=m!==-1,E=new Ws(i.level,i.sn,i.stats.chunkCount,n.byteLength,m,g),v=this.initPTS[i.cc];f.push(n,h,u,d,i,r,l.totalduration,c,E,v);}onAudioTrackSwitching(e,t){let i=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState();}else this.audioOnly&&this.resetTransmuxer();let n=this.hls;i&&(n.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(p.AUDIO_TRACK_SWITCHED,t);}}onAudioTrackSwitched(e,t){let i=t.id,r=!!this.hls.audioTracks[i].url;if(r){let n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n);}this.altAudio=r,this.tick();}onBufferCreated(e,t){let i=t.tracks,r,n,a=false;for(let o in i){let l=i[o];if(l.id==="main"){if(n=o,r=l,o==="video"){let d=i[o];d&&(this.videoBuffer=d.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;if(i&&i.type!==H.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===C.PARSED&&(this.state=C.IDLE);return}let n=r?r.stats:i.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,r);}onError(e,t){var i;if(t.fatal){this.state=C.ERROR;return}switch(t.details){case x.FRAG_GAP:case x.FRAG_PARSING_ERROR:case x.FRAG_DECRYPT_ERROR:case x.FRAG_LOAD_ERROR:case x.FRAG_LOAD_TIMEOUT:case x.KEY_LOAD_ERROR:case x.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(H.MAIN,t);break;case x.LEVEL_LOAD_ERROR:case x.LEVEL_LOAD_TIMEOUT:case x.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===C.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===Z.LEVEL&&(this.state=C.IDLE);break;case x.BUFFER_APPEND_ERROR:case x.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===x.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case x.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){let{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!ue.getBuffered(e).length){let i=this.state!==C.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,i);}this.lastCurrentTime=e.currentTime;}}onFragLoadEmergencyAborted(){this.state=C.IDLE,this.loadedmetadata||(this.startFragRequested=false,this.nextLoadPosition=this.startPosition),this.tickImmediate();}onBufferFlushed(e,{type:t}){if(t!==ne.AUDIO||this.audioOnly&&!this.altAudio){let i=(t===ne.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,t,H.MAIN),this.tick();}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels;}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap;}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,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=ue.getBuffered(e),a=(r.length?r.start(0):0)-i;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),i+=a,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${t}`),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;if(!i||this.fragContextChanged(e))return;t.fragmentError=0,this.state=C.IDLE,this.startFragRequested=false,this.bitrateTest=false;let n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),r.trigger(p.FRAG_LOADED,i),e.bitrateTest=false;});}_handleTransmuxComplete(e){var t;let i="main",{hls:r}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:c}=o,{video:h,text:u,id3:f,initSegment:m}=n,{details:g}=c,E=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=C.PARSING,m){if(m!=null&&m.tracks){let b=l.initSegment||l;this._bufferInitSegment(c,m.tracks,b,a),r.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:i,tracks:m.tracks});}let v=m.initPTS,A=m.timescale;F(v)&&(this.initPTS[l.cc]={baseTime:v,timescale:A},r.trigger(p.INIT_PTS_FOUND,{frag:l,id:i,initPTS:v,timescale:A}));}if(h&&g&&l.sn!=="initSegment"){let v=g.fragments[l.sn-1-g.startSN],A=l.sn===g.startSN,b=!v||l.cc>v.cc;if(n.independent!==false){let{startPTS:L,endPTS:y,startDTS:D,endDTS:I}=h;if(d)d.elementaryStreams[h.type]={startPTS:L,endPTS:y,startDTS:D,endDTS:I};else if(h.firstKeyFrame&&h.independent&&a.id===1&&!b&&(this.couldBacktrack=true),h.dropped&&h.independent){let k=this.getMainFwdBufferInfo(),P=(k?k.end:this.getLoadPosition())+this.config.maxBufferHole,R=h.firstKeyFramePTS?h.firstKeyFramePTS:L;if(!A&&P<R-this.config.maxBufferHole&&!b){this.backtrack(l);return}else b&&(l.gap=true);l.setElementaryStreamInfo(h.type,l.start,y,l.start,I,true);}else A&&L>wn&&(l.gap=true);l.setElementaryStreamInfo(h.type,L,y,D,I),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(h,l,d,a,A||b);}else if(A||b)l.gap=true;else {this.backtrack(l);return}}if(E){let{startPTS:v,endPTS:A,startDTS:b,endDTS:L}=E;d&&(d.elementaryStreams[ne.AUDIO]={startPTS:v,endPTS:A,startDTS:b,endDTS:L}),l.setElementaryStreamInfo(ne.AUDIO,v,A,b,L),this.bufferFragmentData(E,l,d,a);}if(g&&f!=null&&(t=f.samples)!=null&&t.length){let v={id:i,frag:l,details:g,samples:f.samples};r.trigger(p.FRAG_PARSING_METADATA,v);}if(g&&u){let v={id:i,frag:l,details:g,samples:u.samples};r.trigger(p.FRAG_PARSING_USERDATA,v);}}_bufferInitSegment(e,t,i,r){if(this.state!==C.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,d=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5");let c=n.metadata;c&&"channelCount"in c&&(c.channelCount||1)!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5");}l&&l.indexOf("mp4a.40.5")!==-1&&d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`);}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(p.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{let c=t[l].initSegment;c!=null&&c.byteLength&&this.hls.trigger(p.BUFFER_APPENDING,{type:l,data:c,frag:i,part:null,chunkMeta:r,parent:i.type});}),this.tickImmediate();}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,H.MAIN)}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(ue.isBuffered(e,i)?t=this.getAppendedFrag(i):ue.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(p.FRAG_CHANGED,{frag:t}),(!r||r.level!==n)&&this.hls.trigger(p.LEVEL_SWITCHED,{level:n}));}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){let e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){let e=this.media;if(e){let t=e.currentTime,i=this.currentFrag;if(i&&F(t)&&F(i.programDateTime)){let r=i.programDateTime+(t-i.start)*1e3;return new Date(r)}}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}},rs=class s{static get version(){return "1.5.15"}static isMSESupported(){return Gf()}static isSupported(){return tv()}static getMediaSource(){return Ti()}static get Events(){return p}static get ErrorTypes(){return K}static get ErrorDetails(){return x}static get DefaultConfig(){return s.defaultConfig?s.defaultConfig:Bf}static set DefaultConfig(e){s.defaultConfig=e;}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=false,this._emitter=new Ld,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,$g(e.debug||false,"Hls instance");let t=this.config=JE(s.DefaultConfig,e);this.userConfig=e,t.progressive&&ev(t);let{abrController:i,bufferController:r,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new i(this),c=this.bufferController=new r(this),h=this.capLevelController=new n(this),u=new o(this),f=new gl(this),m=new vl(this),g=t.contentSteeringController,E=g?new g(this):null,v=this.levelController=new gd(this,E),A=new Ll(this),b=new pd(this.config),L=this.streamController=new vd(this,A,b);h.setStreamController(L),u.setStreamController(L);let y=[f,v,L];E&&y.splice(1,0,E),this.networkControllers=y;let D=[d,c,h,u,m,A];this.audioTrackController=this.createController(t.audioTrackController,y);let I=t.audioStreamController;I&&y.push(new I(this,A,b)),this.subtitleTrackController=this.createController(t.subtitleTrackController,y);let k=t.subtitleStreamController;k&&y.push(new k(this,A,b)),this.createController(t.timelineController,D),b.emeController=this.emeController=this.createController(t.emeController,D),this.cmcdController=this.createController(t.cmcdController,D),this.latencyController=this.createController(Tl,D),this.coreComponents=D,y.push(l);let P=l.onErrorOut;typeof P=="function"&&this.on(p.ERROR,P,l);}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(S.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===p.ERROR;this.trigger(p.ERROR,{type:K.OTHER_ERROR,details:x.INTERNAL_EXCEPTION,fatal:r,event:e,error:i}),this.triggeringException=false;}}return false}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){S.log("destroy"),this.trigger(p.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){S.log("attachMedia"),this._media=e,this.trigger(p.MEDIA_ATTACHING,{media:e});}detachMedia(){S.log("detachMedia"),this.trigger(p.MEDIA_DETACHING,void 0),this._media=null;}loadSource(e){this.stopLoad();let t=this.media,i=this.url,r=this.url=Td.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:true});this._autoLevelCapping=-1,this._maxHdcpLevel=null,S.log(`loadSource:${r}`),t&&i&&(i!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(p.MANIFEST_LOADING,{url:e});}startLoad(e=-1){S.log(`startLoad(${e})`),this.started=true,this.networkControllers.forEach(t=>{t.startLoad(e);});}stopLoad(){S.log("stopLoad"),this.started=false,this.networkControllers.forEach(e=>{e.stopLoad();});}resumeBuffering(){this.started&&this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.startLoad(-1);});}pauseBuffering(){this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.stopLoad();});}swapAudioCodec(){S.log("swapAudioCodec"),this.streamController.swapAudioCodec();}recoverMediaError(){S.log("recoverMediaError");let e=this._media;this.detachMedia(),e&&this.attachMedia(e);}removeLevel(e){this.levelController.removeLevel(e);}get levels(){let e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){S.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch();}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){S.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch();}get loadLevel(){return this.levelController.level}set loadLevel(e){S.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){S.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){S.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e;}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t);}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e);}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(S.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated());}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){Np(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()}setAudioOption(e){var t;return (t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return (t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null}get allAudioTracks(){let e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e);}get allSubtitleTracks(){let e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e);}get subtitleDisplay(){let e=this.subtitleTrackController;return e?e.subtitleDisplay: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}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}};rs.defaultConfig=void 0;var Vf=Symbol.for(""),ov=s=>{if(s?.r===Vf)return s?._$litStatic$},kd=s=>({_$litStatic$:s,r:Vf});var Hf=new Map,Kf=s=>(e,...t)=>{let i=t.length,r,n,a=[],o=[],l,d=0,c=false;for(;d<i;){for(l=e[d];d<i&&(n=t[d],(r=ov(n))!==void 0);)l+=r+e[++d],c=true;d!==i&&o.push(n),a.push(l),d++;}if(d===i&&a.push(e[i]),c){let h=a.join("$$lit$$");(e=Hf.get(h))===void 0&&(a.raw=a,Hf.set(h,e=a)),t=o;}return s(e,...t)},Wf=Kf(c$3);var W,Yf,qf,oa,zf,Xf,jf,Qf,wd,Md,Pd,la,Zf,Od,ns,Nd,Jf,em,fe=class extends a$1{constructor(){super(...arguments);e(this,W);this._controls=["play","time","seek","volume","fullscreen","subtitles"];this.popped=false;this._startedPlaying=false;this._intersectionObserver=new a$2(this,{callback:f(this,W,jf).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,W,oa).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,W,oa).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,W,oa).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,W,la).call(this):this._queue.push(()=>f(this,W,la).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(),f(this,W,qf).call(this);}disconnectedCallback(){super.disconnectedCallback(),this._metricsInstance?.demonitor();}loadTheme(){this.embed&&this._themeLoaded!=this.theme&&(a$3.get(this.theme,`${this.embedController.cdnRoot}/themes/player`),this._themeLoaded=this.theme);}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["--captions-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["--captions-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-volume-display"]="none":t["--media-volume-display"]="inline-flex",a$4(t)}render(){if(!this.embed)return;let t=this.querySelector('[slot="start-screen"]');return c$3`
|
|
1130
|
-
<slot
|
|
1131
|
-
name="video"
|
|
1132
|
-
style=${a$4({display:t&&!this._startedPlaying?"none":"block"})}
|
|
1133
|
-
>
|
|
1134
|
-
${this.embedController.render({complete:i=>{if(this._embed||(this._embedObj=i,this.updateEmbed(this._embedObj)),!!i)return Wf`<theme-${kd(this.theme)} style=${this.styles}>
|
|
1135
|
-
<video
|
|
1136
|
-
@click=${f(this,W,la)}
|
|
1137
|
-
playsinline
|
|
1138
|
-
?loop=${this.loop||this._embedObj.settings.loop}
|
|
1139
|
-
poster=${this.poster}
|
|
1140
|
-
${c$2(f(this,W,Xf))}
|
|
1141
|
-
slot="media"
|
|
1142
|
-
crossorigin="anonymous"
|
|
1143
|
-
>
|
|
1144
|
-
${d(this,W,em)}
|
|
1145
|
-
${d(this,W,Jf)}
|
|
1146
|
-
</video>
|
|
1147
|
-
</theme-${kd(this.theme)}>`}})}
|
|
1148
|
-
</slot>
|
|
1149
|
-
<slot name="start-screen"></slot>
|
|
1150
|
-
<slot name="end-screen"></slot>
|
|
1151
|
-
<slot name="hover-screen"></slot>
|
|
1152
|
-
`}};W=new WeakSet,Yf=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());},qf=function(){navigator.userAgent.includes("Mobi")||(this.style.setProperty("--subtitle-transform","translateY(100em)"),this.style.setProperty("--subtitle-display","none"),this.style.setProperty("--subtitle-opacity","0"),this._videoElement?.style.setProperty("--subtitle-transform","translateY(100em)"),this._videoElement?.style.setProperty("--subtitle-display","none"),this._videoElement?.style.setProperty("--subtitle-opacity","0")),this._videoElement?.addEventListener("webkitbeginfullscreen",()=>{this.style.setProperty("--subtitle-transform","translateY(-1em)");}),this._videoElement?.addEventListener("webkitendfullscreen",()=>{this.style.setProperty("--subtitle-transform","translateY(100em)");});},oa=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`},zf=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},Xf=function(t){if(t&&t.tagName=="VIDEO"&&(d(this,W,ns)||d(this,W,Nd))){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,W,Qf).call(this),n=="ended"&&f(this,W,wd).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,W,wd).call(this);let l=this.querySelector("[name='mave-time-remaining']");if(l){let c=Math.floor(this._videoElement.duration-this._videoElement.currentTime);l.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(h=>h.containsEmbed(this.embed));if(c){let h=c.getNextForEmbed(this.embed);h&&this.emit(this.EVENT_TYPES.CLICK,{embedId:h.id});}}let d=this.querySelector("[name='mave-list-next-image']");if(d){let c=[...document.querySelectorAll("mave-list")].find(h=>h.containsEmbed(this.embed));if(c){let h=c.getNextForEmbed(this.embed);if(h){let u=document.createElement("mave-img");u.setAttribute("embed",h.id),u.addEventListener("click",()=>{this.emit(this.EVENT_TYPES.CLICK,{embedId:h.id}),d.innerHTML="";}),d.appendChild(u);}else d.innerHTML="";}}}}this.dispatchEvent(new CustomEvent(n,{detail:a,bubbles:true,composed:true}));});}),js.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);rs.isSupported()&&d(this,W,ns)&&!r?(this.hls=new rs({startLevel:f(this,W,zf).call(this),capLevelToPlayerSize:true,xhrSetup:f(this,W,Yf).bind(this),maxBufferLength:20,maxBufferSize:20,backBufferLength:60}),this.hls?.loadSource(d(this,W,ns)),this.hls?.attachMedia(this._videoElement),a$6.metrics.enabled&&(this._metricsInstance=new js.Metrics(this.hls,this.embed,i))):this._videoElement.canPlayType("application/vnd.apple.mpegurl")&&d(this,W,ns)?(this._videoElement.src=d(this,W,ns),a$6.metrics.enabled&&(this._metricsInstance=new js.Metrics(this._videoElement,this.embed,i))):(this._videoElement.src=d(this,W,Nd),a$6.metrics.enabled&&(this._metricsInstance=new js.Metrics(this._videoElement,this.embed,i))),this._queue.length&&(this._queue.forEach(n=>n()),this._queue=[]),f(this,W,Pd).call(this),f(this,W,Md).call(this);}},jf=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,W,Pd).call(this));},Qf=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,W,Md).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");},wd=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";}},Md=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);},Pd=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());},la=function(){this._videoElement?.paused?(this._metricsInstance?.monitor(),this._videoElement?.play()):this._videoElement?.pause();},Zf=function(t){let i=t.target.track,r=i.activeCues;if(i.mode=="showing"&&(this._currentTrackLanguage=i.language),!navigator.userAgent.includes("Mobi")){if(!this._subtitlesText){let n=this.shadowRoot?.querySelector(`theme-${this.theme}`)?.shadowRoot?.querySelector("#subtitles_text");n&&(this._subtitlesText=n);}if(this._currentTrackLanguage!=i.language)return;if(r.length){let n=r[0];this._subtitlesText.style.opacity="1",this._subtitlesText.innerHTML=n.text;}else this._subtitlesText.style.opacity="0";}},Od=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)},ns=function(){let t=f(this,W,Od).call(this,"hls");if(t){let i=new URLSearchParams;return i.append("quality",t.size),this.embedController.embedFile("playlist.m3u8",i)}},Nd=function(){let t=f(this,W,Od).call(this,"mp4");return t?this.embedController.embedFile(`h264_${t?.size}.mp4`):this._embedObj.video.original},Jf=function(){if(this._embedObj.subtitles.length>0){let t=this.shadowRoot?.querySelector(`theme-${this.theme}`)?.shadowRoot?.querySelector("media-captions-selectmenu")?.shadowRoot?.querySelector("media-captions-listbox")?.shadowRoot?.querySelector('media-chrome-option[part="option option-selected"]');return t&&new MutationObserver(r=>{r.forEach(()=>{this._subtitlesText&&t.getAttribute("value")==="off"&&(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`
|
|
1153
|
-
<track mode="hidden" @cuechange=${f(this,W,Zf)} label=${i.label} kind="subtitles" srclang=${i.language} src=${i.path}></track>
|
|
1154
|
-
`})}},em=function(){return c$3`<track
|
|
1155
|
-
label="thumbnails"
|
|
1156
|
-
default
|
|
1157
|
-
kind="metadata"
|
|
1158
|
-
src=${this.embedController.embedFile("storyboard.vtt")}></track>`},fe.styles=h`
|
|
1159
|
-
:host {
|
|
1160
|
-
display: block;
|
|
1161
|
-
position: relative;
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
video::cue {
|
|
1165
|
-
font-family: Inter, Roboto, 'Helvetica Neue', 'Arial Nova', 'Nimbus Sans', Arial,
|
|
1166
|
-
sans-serif;
|
|
1167
|
-
font-weight: 500;
|
|
1168
|
-
display: var(--subtitle-display, initial);
|
|
1169
|
-
opacity: var(--subtitle-opacity, 1);
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
video::-webkit-media-text-track-display {
|
|
1173
|
-
transform: var(--subtitle-transform, initial);
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
video:focus-visible {
|
|
1177
|
-
outline: 0;
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
:host,
|
|
1181
|
-
media-controller,
|
|
1182
|
-
theme-default,
|
|
1183
|
-
video {
|
|
1184
|
-
width: 100%;
|
|
1185
|
-
max-height: 100vh;
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
slot[name='start-screen'],
|
|
1189
|
-
slot[name='end-screen'] {
|
|
1190
|
-
position: absolute;
|
|
1191
|
-
width: 100%;
|
|
1192
|
-
height: 100%;
|
|
1193
|
-
z-index: 99;
|
|
1194
|
-
top: 0;
|
|
1195
|
-
left: 0;
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
slot[name='end-screen'] {
|
|
1199
|
-
display: none;
|
|
1200
|
-
}
|
|
1201
|
-
`,c([a()],fe.prototype,"embed",1),c([a()],fe.prototype,"token",1),c([a({attribute:"aspect-ratio"})],fe.prototype,"aspect_ratio",2),c([a()],fe.prototype,"width",2),c([a()],fe.prototype,"subtitles",2),c([a({attribute:"active-subtitle"})],fe.prototype,"active_subtitle",2),c([a()],fe.prototype,"height",2),c([a()],fe.prototype,"autoplay",2),c([a()],fe.prototype,"color",2),c([a()],fe.prototype,"opacity",2),c([a()],fe.prototype,"loop",1),c([a()],fe.prototype,"controls",1),c([a()],fe.prototype,"cache",1),c([a()],fe.prototype,"quality",1),c([a()],fe.prototype,"theme",1),c([a()],fe.prototype,"poster",1),c([b$2()],fe.prototype,"popped",2),c([c$1("slot[name='end-screen']")],fe.prototype,"endScreenElement",2),c([c$1("slot[name='start-screen']")],fe.prototype,"startScreenElement",2),c([b$2()],fe.prototype,"_embedObj",2),c([a()],fe.prototype,"muted",1);window&&window.customElements&&(window.customElements.get("mave-player")||window.customElements.define("mave-player",fe));/*! Bundled license information:
|
|
1202
|
-
|
|
1203
|
-
lit-html/static.js:
|
|
1204
|
-
(**
|
|
1205
|
-
* @license
|
|
1206
|
-
* Copyright 2020 Google LLC
|
|
1207
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
1208
|
-
*)
|
|
1209
|
-
*/export{fe as a};
|