@maveio/components 0.0.169 → 0.0.170
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-3BAQWQNY.cjs +25 -0
- package/dist/chunk-3UQNIS3L.js +194 -0
- package/dist/chunk-474VILDO.cjs +194 -0
- package/dist/chunk-CZUMF7SR.cjs +1 -0
- package/dist/{chunk-OVZCXWUJ.js → chunk-EA4QYQHD.js} +141 -165
- package/dist/{chunk-KLJGACPT.js → chunk-GRBSIFM2.js} +1 -1
- package/dist/chunk-HMVS6DJE.js +186 -0
- package/dist/{chunk-BL2IUHCP.cjs → chunk-ITC5FANW.cjs} +203 -227
- package/dist/chunk-KO3CETGD.js +25 -0
- package/dist/chunk-LVGLIRQU.cjs +186 -0
- package/dist/{chunk-P5OWX4UR.js → chunk-NDPOBFNC.js} +1 -1
- package/dist/{chunk-IMY6Z3YA.cjs → chunk-OFBA5VRE.cjs} +2 -2
- package/dist/chunk-RWRHU74Q.js +1 -0
- package/dist/{chunk-MU4WLTQR.cjs → chunk-TJ5F2FGY.cjs} +1 -1
- package/dist/{chunk-L667KKJP.cjs → chunk-YWYZKUFB.cjs} +1 -1
- package/dist/{chunk-GHE5KR7E.js → chunk-ZWLZE25P.js} +1 -1
- package/dist/components/audio-track-menu.cjs +1 -1
- package/dist/components/audio-track-menu.js +1 -1
- package/dist/components/captions-menu-button.cjs +1 -0
- package/dist/components/captions-menu-button.d.cts +10 -0
- package/dist/components/captions-menu-button.d.ts +10 -0
- package/dist/components/captions-menu-button.js +1 -0
- package/dist/components/clip.cjs +1 -1
- package/dist/components/clip.js +1 -1
- package/dist/components/files.cjs +1 -1
- package/dist/components/files.js +1 -1
- package/dist/components/list.cjs +1 -1
- package/dist/components/list.js +1 -1
- package/dist/components/player.cjs +1 -1
- package/dist/components/player.d.cts +4 -0
- package/dist/components/player.d.ts +4 -0
- package/dist/components/player.js +1 -1
- package/dist/components/pop.cjs +1 -1
- package/dist/components/pop.js +1 -1
- package/dist/components/text.cjs +1 -1
- package/dist/components/text.js +1 -1
- package/dist/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 +204 -28
- package/dist/themes/default.js +204 -28
- package/dist/themes/dolphin.cjs +192 -16
- package/dist/themes/dolphin.js +192 -16
- package/dist/themes/loader.cjs +1 -1
- package/dist/themes/loader.js +1 -1
- package/dist/themes/synthwave.cjs +192 -19
- package/dist/themes/synthwave.js +192 -19
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2EIQ3VMA.cjs +0 -1
- package/dist/chunk-C3CI3U2Z.js +0 -379
- package/dist/chunk-V54NMMTT.cjs +0 -379
- package/dist/chunk-WTS6WHUH.js +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkCZUMF7SR_cjs=require('./chunk-CZUMF7SR.cjs'),chunk5QLIDHRT_cjs=require('./chunk-5QLIDHRT.cjs'),chunkQQDH35OW_cjs=require('./chunk-QQDH35OW.cjs'),chunkLVGLIRQU_cjs=require('./chunk-LVGLIRQU.cjs'),chunk3BAQWQNY_cjs=require('./chunk-3BAQWQNY.cjs'),chunk474VILDO_cjs=require('./chunk-474VILDO.cjs'),chunkBTCK3T4L_cjs=require('./chunk-BTCK3T4L.cjs'),chunkSDKTBB4N_cjs=require('./chunk-SDKTBB4N.cjs'),chunkTKJYRGEU_cjs=require('./chunk-TKJYRGEU.cjs'),chunkRQN3DXJB_cjs=require('./chunk-RQN3DXJB.cjs'),chunkDL4BV5IH_cjs=require('./chunk-DL4BV5IH.cjs'),chunk2E5GLLOS_cjs=require('./chunk-2E5GLLOS.cjs'),chunkNPP5B5PV_cjs=require('./chunk-NPP5B5PV.cjs'),chunkEVKPEPYP_cjs=require('./chunk-EVKPEPYP.cjs'),chunkJHSFSCC2_cjs=require('./chunk-JHSFSCC2.cjs');function Vh(s){return s?.map(B0).join(" ")}function Wh(s){return s?.split(/\s+/).map(G0)}function B0(s){if(s){let{id:e,width:t,height:i}=s;return [e,t,i].filter(r=>r!=null).join(":")}}function G0(s){if(s){let[e,t,i]=s.split(":");return {id:e,width:+t,height:+i}}}function Yh(s){return s?.map(H0).join(" ")}function qh(s){return s?.split(/\s+/).map(K0)}function H0(s){if(s){let{id:e,kind:t,language:i,label:r}=s;return [e,t,i,r].filter(n=>n!=null).join(":")}}function K0(s){if(s){let[e,t,i,r]=s.split(":");return {id:e,kind:t,language:i,label:r}}}function vs(s){return typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s)}var Zn=s=>new Promise(e=>setTimeout(e,s));var jh=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],V0=(s,e)=>{let t=s===1?jh[e].singular:jh[e].plural;return `${s} ${t}`},Wi=s=>{if(!vs(s))return "";let e=Math.abs(s),t=e!==s,i=new Date(0,0,0,0,0,e,0);return `${[i.getHours(),i.getMinutes(),i.getSeconds()].map((o,d)=>o&&V0(o,d)).filter(o=>o).join(", ")}${t?" remaining":""}`};function Nt(s,e){let t=false;s<0&&(t=true,s=0-s),s=s<0?0:s;let i=Math.floor(s%60),r=Math.floor(s/60%60),n=Math.floor(s/3600),a=Math.floor(e/60%60),o=Math.floor(e/3600);return (isNaN(s)||s===1/0)&&(n=r=i="0"),n=n>0||o>0?n+":":"",r=((n||a>=10)&&r<10?"0"+r:r)+":",i=i<10?"0"+i:i,(t?"-":"")+n+r+i}var zh=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},xi=(s,e,t)=>(zh(s,e,"read from private field"),t?t.call(s):e.get(s)),Y0=(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);},Jn=(s,e,t,i)=>(zh(s,e,"write to private field"),e.set(s,t),t),lt;function q0(s){return `
|
|
2
2
|
<style>
|
|
3
3
|
:host {
|
|
4
4
|
display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
|
|
5
5
|
box-sizing: border-box;
|
|
6
6
|
}
|
|
7
7
|
</style>
|
|
8
|
-
`}var
|
|
8
|
+
`}var Ts=class extends chunk474VILDO_cjs.o.HTMLElement{constructor(){if(super(),Y0(this,lt,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=chunk474VILDO_cjs.q(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}}static get observedAttributes(){return [chunk474VILDO_cjs.b.MEDIA_CONTROLLER,chunk474VILDO_cjs.d.MEDIA_PAUSED]}attributeChangedCallback(e,t,i){var r,n,a,o,d;e===chunk474VILDO_cjs.b.MEDIA_CONTROLLER&&(t&&((n=(r=xi(this,lt))==null?void 0:r.unassociateElement)==null||n.call(r,this),Jn(this,lt,null)),i&&this.isConnected&&(Jn(this,lt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=xi(this,lt))==null?void 0:o.associateElement)==null||d.call(o,this)));}connectedCallback(){var e,t,i,r;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),Jn(this,lt,j0(this)),this.getAttribute(chunk474VILDO_cjs.b.MEDIA_CONTROLLER)&&((t=(e=xi(this,lt))==null?void 0:e.associateElement)==null||t.call(e,this)),(i=xi(this,lt))==null||i.addEventListener("pointerdown",this),(r=xi(this,lt))==null||r.addEventListener("click",this);}disconnectedCallback(){var e,t,i,r;this.getAttribute(chunk474VILDO_cjs.b.MEDIA_CONTROLLER)&&((t=(e=xi(this,lt))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(i=xi(this,lt))==null||i.removeEventListener("pointerdown",this),(r=xi(this,lt))==null||r.removeEventListener("click",this),Jn(this,lt,null);}handleEvent(e){var t;let i=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(i?.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){let{clientX:n,clientY:a}=e,{left:o,top:d,width:l,height:c}=this.getBoundingClientRect(),u=n-o,h=a-d;if(u<0||h<0||u>l||h>c||l===0&&c===0)return;let f=this._pointerType||"mouse";if(this._pointerType=void 0,f===chunk474VILDO_cjs.i.TOUCH){this.handleTap(e);return}else if(f===chunk474VILDO_cjs.i.MOUSE||f===chunk474VILDO_cjs.i.PEN){this.handleMouseClick(e);return}}}}get mediaPaused(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_PAUSED)}set mediaPaused(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_PAUSED,e);}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?chunk474VILDO_cjs.a.MEDIA_PLAY_REQUEST:chunk474VILDO_cjs.a.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(t,{composed:true,bubbles:true}));}};lt=new WeakMap;Ts.shadowRootOptions={mode:"open"};Ts.getTemplateHTML=q0;function j0(s){var e;let t=s.getAttribute(chunk474VILDO_cjs.b.MEDIA_CONTROLLER);return t?(e=s.getRootNode())==null?void 0:e.getElementById(t):chunk474VILDO_cjs.w(s,"media-controller")}chunk474VILDO_cjs.o.customElements.get("media-gesture-receiver")||chunk474VILDO_cjs.o.customElements.define("media-gesture-receiver",Ts);var ea=Ts;var Bl=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Et=(s,e,t)=>(Bl(s,e,"read from private field"),t?t.call(s):e.get(s)),pt=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Yi=(s,e,t,i)=>(Bl(s,e,"write to private field"),e.set(s,t),t),It=(s,e,t)=>(Bl(s,e,"access private method"),t),sa,ys,Ar,Ss,ta,Nl,Qh,br,ia,Ul,Xh,$l,Zh,_r,ra,na,Gl,bs,Ir,J={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive",AUTOHIDE_OVER_CONTROLS:"autohideovercontrols"};function z0(s){return `
|
|
9
9
|
<style>
|
|
10
10
|
|
|
11
|
-
:host([${
|
|
11
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
|
|
12
12
|
outline: none;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -104,16 +104,16 @@
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
|
|
107
|
-
:host([${J.USER_INACTIVE}]:not([${
|
|
107
|
+
:host([${J.USER_INACTIVE}]:not([${chunk474VILDO_cjs.d.MEDIA_PAUSED}]):not([${chunk474VILDO_cjs.d.MEDIA_IS_AIRPLAYING}]):not([${chunk474VILDO_cjs.d.MEDIA_IS_CASTING}]):not([${J.AUDIO}])) ::slotted(:not([slot=media]):not([slot=poster]):not([${J.NO_AUTOHIDE}]):not([role=dialog])) {
|
|
108
108
|
opacity: 0;
|
|
109
109
|
transition: var(--media-control-transition-out, opacity 1s);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
:host([${J.USER_INACTIVE}]:not([${J.NO_AUTOHIDE}]):not([${
|
|
112
|
+
:host([${J.USER_INACTIVE}]:not([${J.NO_AUTOHIDE}]):not([${chunk474VILDO_cjs.d.MEDIA_PAUSED}]):not([${chunk474VILDO_cjs.d.MEDIA_IS_CASTING}]):not([${J.AUDIO}])) ::slotted([slot=media]) {
|
|
113
113
|
cursor: none;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
:host([${J.USER_INACTIVE}][${J.AUTOHIDE_OVER_CONTROLS}]:not([${J.NO_AUTOHIDE}]):not([${
|
|
116
|
+
:host([${J.USER_INACTIVE}][${J.AUTOHIDE_OVER_CONTROLS}]:not([${J.NO_AUTOHIDE}]):not([${chunk474VILDO_cjs.d.MEDIA_PAUSED}]):not([${chunk474VILDO_cjs.d.MEDIA_IS_CASTING}]):not([${J.AUDIO}])) * {
|
|
117
117
|
--media-cursor: none;
|
|
118
118
|
cursor: none;
|
|
119
119
|
}
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
|
|
127
|
-
:host(:not([${J.AUDIO}])[${
|
|
127
|
+
:host(:not([${J.AUDIO}])[${chunk474VILDO_cjs.d.MEDIA_HAS_PLAYED}]) slot[name=poster] {
|
|
128
128
|
display: none;
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -143,8 +143,8 @@
|
|
|
143
143
|
<slot name="poster" part="layer poster-layer"></slot>
|
|
144
144
|
<slot name="gestures-chrome" part="layer gesture-layer">
|
|
145
145
|
<media-gesture-receiver slot="gestures-chrome">
|
|
146
|
-
<template shadowrootmode="${
|
|
147
|
-
${
|
|
146
|
+
<template shadowrootmode="${ea.shadowRootOptions.mode}">
|
|
147
|
+
${ea.getTemplateHTML({})}
|
|
148
148
|
</template>
|
|
149
149
|
</media-gesture-receiver>
|
|
150
150
|
</slot>
|
|
@@ -156,38 +156,38 @@
|
|
|
156
156
|
<slot part="bottom chrome"></slot>
|
|
157
157
|
</span>
|
|
158
158
|
<slot name="dialog" part="layer dialog-layer"></slot>
|
|
159
|
-
`}var Q0=Object.values(chunkV54NMMTT_cjs.d),X0="sm:384 md:576 lg:768 xl:960";function Z0(s){Zh(s.target,s.contentRect.width);}function Zh(s,e){var t;if(!s.isConnected)return;let i=(t=s.getAttribute(J.BREAKPOINTS))!=null?t:X0,r=J0(i),n=eE(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(chunkV54NMMTT_cjs.e.BREAKPOINTS_CHANGE,{detail:n});s.dispatchEvent(o);}s.breakpointsComputed||(s.breakpointsComputed=true,s.dispatchEvent(new CustomEvent(chunkV54NMMTT_cjs.e.BREAKPOINTS_COMPUTED,{bubbles:true,composed:true})));}function J0(s){let e=s.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function eE(s,e){return Object.keys(s).filter(t=>e>=parseInt(s[t]))}var Wi=class extends chunkV54NMMTT_cjs.o.HTMLElement{constructor(){if(super(),Et(this,Nl),Et(this,Bl),Et(this,$l),Et(this,Lr),Et(this,aa),Et(this,As),Et(this,ra,0),Et(this,Ss,null),Et(this,Ir,null),Et(this,bs,void 0),this.breakpointsComputed=false,Et(this,ia,new MutationObserver(Lt(this,Nl,zh).bind(this))),Et(this,_r,false),Et(this,sa,t=>{vt(this,_r)||(setTimeout(()=>{Z0(t),Vi(this,_r,false);},0),Vi(this,_r,true));}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let t=chunkV54NMMTT_cjs.s(this.attributes),i=this.constructor.getTemplateHTML(t);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(i):this.shadowRoot.innerHTML=i;}let e=this.querySelector(":scope > slot[slot=media]");e&&e.addEventListener("slotchange",()=>{if(!e.assignedElements({flatten:true}).length){vt(this,Ss)&&this.mediaUnsetCallback(vt(this,Ss));return}this.handleMediaUpdated(this.media);});}static get observedAttributes(){return [J.AUTOHIDE,J.GESTURES_DISABLED].concat(Q0).filter(e=>![chunkV54NMMTT_cjs.d.MEDIA_RENDITION_LIST,chunkV54NMMTT_cjs.d.MEDIA_AUDIO_TRACK_LIST,chunkV54NMMTT_cjs.d.MEDIA_CHAPTERS_CUES,chunkV54NMMTT_cjs.d.MEDIA_WIDTH,chunkV54NMMTT_cjs.d.MEDIA_HEIGHT,chunkV54NMMTT_cjs.d.MEDIA_ERROR,chunkV54NMMTT_cjs.d.MEDIA_ERROR_MESSAGE].includes(e))}attributeChangedCallback(e,t,i){e.toLowerCase()==J.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&&(Vi(this,Ss,e),e.localName.includes("-")&&await chunkV54NMMTT_cjs.o.customElements.whenDefined(e.localName),this.mediaSetCallback(e));}connectedCallback(){var e;vt(this,ia).observe(this,{childList:true,subtree:true}),chunkV54NMMTT_cjs.q(this,vt(this,sa));let i=this.getAttribute(J.AUDIO)!=null?chunkV54NMMTT_cjs.n("audio player"):chunkV54NMMTT_cjs.n("video player");this.setAttribute("role","region"),this.setAttribute("aria-label",i),this.handleMediaUpdated(this.media),this.setAttribute(J.USER_INACTIVE,""),Zh(this,this.getBoundingClientRect().width),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=chunkV54NMMTT_cjs.o.window)==null||e.addEventListener("mouseup",this);}disconnectedCallback(){var e;vt(this,ia).disconnect(),chunkV54NMMTT_cjs.r(this,vt(this,sa)),this.media&&this.mediaUnsetCallback(this.media),(e=chunkV54NMMTT_cjs.o.window)==null||e.removeEventListener("mouseup",this);}mediaSetCallback(e){}mediaUnsetCallback(e){Vi(this,Ss,null);}handleEvent(e){switch(e.type){case "pointerdown":Vi(this,ra,e.timeStamp);break;case "pointermove":Lt(this,Bl,Qh).call(this,e);break;case "pointerup":Lt(this,$l,Xh).call(this,e);break;case "mouseleave":Lt(this,Lr,na).call(this);break;case "mouseup":this.removeAttribute(J.KEYBOARD_CONTROL);break;case "keyup":Lt(this,As,xr).call(this),this.setAttribute(J.KEYBOARD_CONTROL,"");break}}set autohide(e){let t=Number(e);Vi(this,bs,isNaN(t)?0:t);}get autohide(){return (vt(this,bs)===void 0?2:vt(this,bs)).toString()}get breakpoints(){return chunkV54NMMTT_cjs.I(this,J.BREAKPOINTS)}set breakpoints(e){chunkV54NMMTT_cjs.J(this,J.BREAKPOINTS,e);}get audio(){return chunkV54NMMTT_cjs.G(this,J.AUDIO)}set audio(e){chunkV54NMMTT_cjs.H(this,J.AUDIO,e);}get gesturesDisabled(){return chunkV54NMMTT_cjs.G(this,J.GESTURES_DISABLED)}set gesturesDisabled(e){chunkV54NMMTT_cjs.H(this,J.GESTURES_DISABLED,e);}get keyboardControl(){return chunkV54NMMTT_cjs.G(this,J.KEYBOARD_CONTROL)}set keyboardControl(e){chunkV54NMMTT_cjs.H(this,J.KEYBOARD_CONTROL,e);}get noAutohide(){return chunkV54NMMTT_cjs.G(this,J.NO_AUTOHIDE)}set noAutohide(e){chunkV54NMMTT_cjs.H(this,J.NO_AUTOHIDE,e);}get autohideOverControls(){return chunkV54NMMTT_cjs.G(this,J.AUTOHIDE_OVER_CONTROLS)}set autohideOverControls(e){chunkV54NMMTT_cjs.H(this,J.AUTOHIDE_OVER_CONTROLS,e);}get userInteractive(){return chunkV54NMMTT_cjs.G(this,J.USER_INACTIVE)}set userInteractive(e){chunkV54NMMTT_cjs.H(this,J.USER_INACTIVE,e);}};ra=new WeakMap;Ss=new WeakMap;Ir=new WeakMap;bs=new WeakMap;ia=new WeakMap;Nl=new WeakSet;zh=function(s){let e=this.media;for(let t of s){if(t.type!=="childList")continue;let i=t.removedNodes;for(let r of i){if(r.slot!="media"||t.target!=this)continue;let n=t.previousSibling&&t.previousSibling.previousElementSibling;if(!n||!e)this.mediaUnsetCallback(r);else {let a=n.slot!=="media";for(;(n=n.previousSibling)!==null;)n.slot=="media"&&(a=false);a&&this.mediaUnsetCallback(r);}}if(e)for(let r of t.addedNodes)r===e&&this.handleMediaUpdated(e);}};_r=new WeakMap;sa=new WeakMap;Bl=new WeakSet;Qh=function(s){if(s.pointerType!=="mouse"&&s.timeStamp-vt(this,ra)<250)return;Lt(this,aa,Hl).call(this),clearTimeout(vt(this,Ir));let e=this.hasAttribute(J.AUTOHIDE_OVER_CONTROLS);([this,this.media].includes(s.target)||e)&&Lt(this,As,xr).call(this);};$l=new WeakSet;Xh=function(s){if(s.pointerType==="touch"){let e=!this.hasAttribute(J.USER_INACTIVE);[this,this.media].includes(s.target)&&e?Lt(this,Lr,na).call(this):Lt(this,As,xr).call(this);}else s.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e?.localName))&&Lt(this,As,xr).call(this);};Lr=new WeakSet;na=function(){if(vt(this,bs)<0||this.hasAttribute(J.USER_INACTIVE))return;this.setAttribute(J.USER_INACTIVE,"");let s=new chunkV54NMMTT_cjs.o.CustomEvent(chunkV54NMMTT_cjs.e.USER_INACTIVE_CHANGE,{composed:true,bubbles:true,detail:true});this.dispatchEvent(s);};aa=new WeakSet;Hl=function(){if(!this.hasAttribute(J.USER_INACTIVE))return;this.removeAttribute(J.USER_INACTIVE);let s=new chunkV54NMMTT_cjs.o.CustomEvent(chunkV54NMMTT_cjs.e.USER_INACTIVE_CHANGE,{composed:true,bubbles:true,detail:false});this.dispatchEvent(s);};As=new WeakSet;xr=function(){Lt(this,aa,Hl).call(this),clearTimeout(vt(this,Ir));let s=parseInt(this.autohide);s<0||Vi(this,Ir,setTimeout(()=>{Lt(this,Lr,na).call(this);},s*1e3));};Wi.shadowRootOptions={mode:"open"};Wi.getTemplateHTML=z0;chunkV54NMMTT_cjs.o.customElements.get("media-container")||chunkV54NMMTT_cjs.o.customElements.define("media-container",Wi);var Jh=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},qe=(s,e,t)=>(Jh(s,e,"read from private field"),t?t.call(s):e.get(s)),Rr=(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);},oa=(s,e,t,i)=>(Jh(s,e,"write to private field"),e.set(s,t),t),_s,Is,la,Yi,Ei,ki,Di=class{constructor(e,t,{defaultValue:i}={defaultValue:void 0}){Rr(this,Ei),Rr(this,_s,void 0),Rr(this,Is,void 0),Rr(this,la,void 0),Rr(this,Yi,new Set),oa(this,_s,e),oa(this,Is,t),oa(this,la,new Set(i));}[Symbol.iterator](){return qe(this,Ei,ki).values()}get length(){return qe(this,Ei,ki).size}get value(){var e;return (e=[...qe(this,Ei,ki)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(oa(this,Yi,new Set),this.add(...(t=e?.split(" "))!=null?t:[]));}toString(){return this.value}item(e){return [...qe(this,Ei,ki)][e]}values(){return qe(this,Ei,ki).values()}forEach(e,t){qe(this,Ei,ki).forEach(e,t);}add(...e){var t,i;e.forEach(r=>qe(this,Yi).add(r)),!(this.value===""&&!((t=qe(this,_s))!=null&&t.hasAttribute(`${qe(this,Is)}`)))&&((i=qe(this,_s))==null||i.setAttribute(`${qe(this,Is)}`,`${this.value}`));}remove(...e){var t;e.forEach(i=>qe(this,Yi).delete(i)),(t=qe(this,_s))==null||t.setAttribute(`${qe(this,Is)}`,`${this.value}`);}contains(e){return qe(this,Ei,ki).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}};_s=new WeakMap;Is=new WeakMap;la=new WeakMap;Yi=new WeakMap;Ei=new WeakSet;ki=function(){return qe(this,Yi).size?qe(this,Yi):qe(this,la)};var tE=(s="")=>s.split(/\s+/),ef=(s="")=>{let[e,t,i]=s.split(":"),r=i?decodeURIComponent(i):void 0;return {kind:e==="cc"?chunkV54NMMTT_cjs.g.CAPTIONS:chunkV54NMMTT_cjs.g.SUBTITLES,language:t,label:r}},qi=(s="",e={})=>tE(s).map(t=>{let i=ef(t);return {...e,...i}}),Kl=s=>s?Array.isArray(s)?s.map(e=>typeof e=="string"?ef(e):e):typeof s=="string"?qi(s):[s]:[],da=({kind:s,label:e,language:t}={kind:"subtitles"})=>e?`${s==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,vi=(s=[])=>Array.prototype.map.call(s,da).join(" "),iE=(s,e)=>t=>t[s]===e,tf=s=>{let e=Object.entries(s).map(([t,i])=>iE(t,i));return t=>e.every(i=>i(t))},ji=(s,e=[],t=[])=>{let i=Kl(t).map(tf),r=n=>i.some(a=>a(n));Array.from(e).filter(r).forEach(n=>{n.mode=s;});},zi=(s,e=()=>true)=>{if(!s?.textTracks)return [];let t=typeof e=="function"?e:tf(e);return Array.from(s.textTracks).filter(t)},ca=s=>{var e;return !!((e=s.mediaSubtitlesShowing)!=null&&e.length)||s.hasAttribute(chunkV54NMMTT_cjs.d.MEDIA_SUBTITLES_SHOWING)};var rf=s=>{var e;let{media:t,fullscreenElement:i}=s;try{let r=i&&"requestFullscreen"in i?"requestFullscreen":i&&"webkitRequestFullScreen"in i?"webkitRequestFullScreen":void 0;if(r){let n=(e=i[r])==null?void 0:e.call(i);if(n instanceof Promise)return n.catch(()=>{})}else t?.webkitEnterFullscreen?t.webkitEnterFullscreen():t?.requestFullscreen&&t.requestFullscreen();}catch(r){console.error(r);}},sf="exitFullscreen"in chunkV54NMMTT_cjs.p?"exitFullscreen":"webkitExitFullscreen"in chunkV54NMMTT_cjs.p?"webkitExitFullscreen":"webkitCancelFullScreen"in chunkV54NMMTT_cjs.p?"webkitCancelFullScreen":void 0,nf=s=>{var e;let{documentElement:t}=s;if(sf){let i=(e=t?.[sf])==null?void 0:e.call(t);if(i instanceof Promise)return i.catch(()=>{})}},kr="fullscreenElement"in chunkV54NMMTT_cjs.p?"fullscreenElement":"webkitFullscreenElement"in chunkV54NMMTT_cjs.p?"webkitFullscreenElement":void 0,sE=s=>{let{documentElement:e,media:t}=s,i=e?.[kr];return !i&&"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t&&t.webkitDisplayingFullscreen&&t.webkitPresentationMode===chunkV54NMMTT_cjs.l.FULLSCREEN?t:i},af=s=>{var e;let{media:t,documentElement:i,fullscreenElement:r=t}=s;if(!t||!i)return false;let n=sE(s);if(!n)return false;if(n===r||n===t)return true;if(n.localName.includes("-")){let a=n.shadowRoot;if(!(kr in a))return chunkV54NMMTT_cjs.w(n,r);for(;a?.[kr];){if(a[kr]===r)return true;a=(e=a[kr])==null?void 0:e.shadowRoot;}}return false},rE="fullscreenEnabled"in chunkV54NMMTT_cjs.p?"fullscreenEnabled":"webkitFullscreenEnabled"in chunkV54NMMTT_cjs.p?"webkitFullscreenEnabled":void 0,of=s=>{let{documentElement:e,media:t}=s;return !!e?.[rE]||t&&"webkitSupportsFullscreen"in t};var ua,Vl=()=>{var s,e;return ua||(ua=(e=(s=chunkV54NMMTT_cjs.p)==null?void 0:s.createElement)==null?void 0:e.call(s,"video"),ua)},lf=async(s=Vl())=>{if(!s)return false;let e=s.volume;s.volume=e/2+.1;let t=new AbortController,i=await Promise.race([nE(s,t.signal),aE(s,e)]);return t.abort(),i},nE=(s,e)=>new Promise(t=>{s.addEventListener("volumechange",()=>t(true),{signal:e});}),aE=async(s,e)=>{for(let t=0;t<10;t++){if(s.volume===e)return false;await Jn(10);}return s.volume!==e},oE=/.*Version\/.*Safari\/.*/.test(chunkV54NMMTT_cjs.o.navigator.userAgent),Wl=(s=Vl())=>chunkV54NMMTT_cjs.o.matchMedia("(display-mode: standalone)").matches&&oE?false:typeof s?.requestPictureInPicture=="function",Yl=(s=Vl())=>of({documentElement:chunkV54NMMTT_cjs.p,media:s}),df=Yl(),cf=Wl(),uf=!!chunkV54NMMTT_cjs.o.WebKitPlaybackTargetAvailabilityEvent,hf=!!chunkV54NMMTT_cjs.o.chrome;var Ls=s=>zi(s.media,e=>[chunkV54NMMTT_cjs.g.SUBTITLES,chunkV54NMMTT_cjs.g.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),ql=s=>zi(s.media,e=>e.mode===chunkV54NMMTT_cjs.h.SHOWING&&[chunkV54NMMTT_cjs.g.SUBTITLES,chunkV54NMMTT_cjs.g.CAPTIONS].includes(e.kind)),ha=(s,e)=>{let t=Ls(s),i=ql(s),r=!!i.length;if(t.length){if(e===false||r&&e!==true)ji(chunkV54NMMTT_cjs.h.DISABLED,t,i);else if(e===true||!r&&e!==false){let n=t[0],{options:a}=s;if(!a?.noSubtitlesLangPref){let c=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),u=c?[c,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>u.some(m=>f.language.toLowerCase().startsWith(m.split("-")[0]))).sort((f,m)=>{let g=u.findIndex(v=>f.language.toLowerCase().startsWith(v.split("-")[0])),E=u.findIndex(v=>m.language.toLowerCase().startsWith(v.split("-")[0]));return g-E});h[0]&&(n=h[0]);}let{language:o,label:l,kind:d}=n;ji(chunkV54NMMTT_cjs.h.DISABLED,t,i),ji(chunkV54NMMTT_cjs.h.SHOWING,t,[{language:o,label:l,kind:d}]);}}},fa=(s,e)=>s===e?true:s==null||e==null||typeof s!=typeof e?false:typeof s=="number"&&Number.isNaN(s)&&Number.isNaN(e)?true:typeof s!="object"?false:Array.isArray(s)?lE(s,e):Object.entries(s).every(([t,i])=>t in e&&fa(i,e[t])),lE=(s,e)=>{let t=Array.isArray(s),i=Array.isArray(e);return t!==i?false:t||i?s.length!==e.length?false:s.every((r,n)=>fa(r,e[n])):true};var dE=Object.values(chunkV54NMMTT_cjs.k),ma,cE=lf().then(s=>(ma=s,ma)),ff=async(...s)=>{await Promise.all(s.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof chunkV54NMMTT_cjs.o.HTMLElement))return;let t=e.localName;if(!t.includes("-"))return;let i=chunkV54NMMTT_cjs.o.customElements.get(t);i&&e instanceof i||(await chunkV54NMMTT_cjs.o.customElements.whenDefined(t),chunkV54NMMTT_cjs.o.customElements.upgrade(e));}));},uE=new chunkV54NMMTT_cjs.o.DOMParser,hE=s=>s&&(uE.parseFromString(s,"text/html").body.textContent||s),xs={mediaError:{get(s,e){let{media:t}=s;if(e?.type!=="playing")return t?.error},mediaEvents:["emptied","error","playing"]},mediaErrorCode:{get(s,e){var t;let{media:i}=s;if(e?.type!=="playing")return (t=i?.error)==null?void 0:t.code},mediaEvents:["emptied","error","playing"]},mediaErrorMessage:{get(s,e){var t,i;let{media:r}=s;if(e?.type!=="playing")return (i=(t=r?.error)==null?void 0:t.message)!=null?i:""},mediaEvents:["emptied","error","playing"]},mediaWidth:{get(s){var e;let{media:t}=s;return (e=t?.videoWidth)!=null?e:0},mediaEvents:["resize"]},mediaHeight:{get(s){var e;let{media:t}=s;return (e=t?.videoHeight)!=null?e:0},mediaEvents:["resize"]},mediaPaused:{get(s){var e;let{media:t}=s;return (e=t?.paused)!=null?e:true},set(s,e){var t;let{media:i}=e;i&&(s?i.pause():(t=i.play())==null||t.catch(()=>{}));},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(s,e){let{media:t}=s;return t?e?e.type==="playing":!t.paused:false},mediaEvents:["playing","emptied"]},mediaEnded:{get(s){var e;let{media:t}=s;return (e=t?.ended)!=null?e:false},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(s){var e;let{media:t}=s;return (e=t?.playbackRate)!=null?e:1},set(s,e){let{media:t}=e;t&&Number.isFinite(+s)&&(t.playbackRate=+s);},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(s){var e;let{media:t}=s;return (e=t?.muted)!=null?e:false},set(s,e){let{media:t,options:{noMutedPref:i}={}}=e;if(t){t.muted=s;try{let r=chunkV54NMMTT_cjs.o.localStorage.getItem("media-chrome-pref-muted")!==null,n=t.hasAttribute("muted");if(i){r&&chunkV54NMMTT_cjs.o.localStorage.removeItem("media-chrome-pref-muted");return}if(n&&!r)return;chunkV54NMMTT_cjs.o.localStorage.setItem("media-chrome-pref-muted",s?"true":"false");}catch(r){console.debug("Error setting muted pref",r);}}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(s,e)=>{let{options:{noMutedPref:t}}=e,{media:i}=e;if(!(!i||i.muted||t))try{let r=chunkV54NMMTT_cjs.o.localStorage.getItem("media-chrome-pref-muted")==="true";xs.mediaMuted.set(r,e),s(r);}catch(r){console.debug("Error getting muted pref",r);}}]},mediaLoop:{get(s){let{media:e}=s;return e?.loop},set(s,e){let{media:t}=e;t&&(t.loop=s);},mediaEvents:["medialooprequest"]},mediaVolume:{get(s){var e;let{media:t}=s;return (e=t?.volume)!=null?e:1},set(s,e){let{media:t,options:{noVolumePref:i}={}}=e;if(t){try{s==null?chunkV54NMMTT_cjs.o.localStorage.removeItem("media-chrome-pref-volume"):!t.hasAttribute("muted")&&!i&&chunkV54NMMTT_cjs.o.localStorage.setItem("media-chrome-pref-volume",s.toString());}catch(r){console.debug("Error setting volume pref",r);}Number.isFinite(+s)&&(t.volume=+s);}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(s,e)=>{let{options:{noVolumePref:t}}=e;if(!t)try{let{media:i}=e;if(!i)return;let r=chunkV54NMMTT_cjs.o.localStorage.getItem("media-chrome-pref-volume");if(r==null)return;xs.mediaVolume.set(+r,e),s(+r);}catch(i){console.debug("Error getting volume pref",i);}}]},mediaVolumeLevel:{get(s){let{media:e}=s;return typeof e?.volume>"u"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(s){var e;let{media:t}=s;return (e=t?.currentTime)!=null?e:0},set(s,e){let{media:t}=e;!t||!Ts(s)||(t.currentTime=s);},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(s){let{media:e,options:{defaultDuration:t}={}}=s;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e?.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(s){let{media:e}=s;return e?.readyState<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(s){var e;let{media:t}=s;if(!((e=t?.seekable)!=null&&e.length))return;let i=t.seekable.start(0),r=t.seekable.end(t.seekable.length-1);if(!(!i&&!r))return [Number(i.toFixed(3)),Number(r.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(s){var e;let{media:t}=s,i=(e=t?.buffered)!=null?e:[];return Array.from(i).map((r,n)=>[Number(i.start(n).toFixed(3)),Number(i.end(n).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(s){let{media:e,options:{defaultStreamType:t}={}}=s,i=[chunkV54NMMTT_cjs.k.LIVE,chunkV54NMMTT_cjs.k.ON_DEMAND].includes(t)?t:void 0;if(!e)return i;let{streamType:r}=e;if(dE.includes(r))return r===chunkV54NMMTT_cjs.k.UNKNOWN?i:r;let n=e.duration;return n===1/0?chunkV54NMMTT_cjs.k.LIVE:Number.isFinite(n)?chunkV54NMMTT_cjs.k.ON_DEMAND:i},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(s){let{media:e}=s;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,i=xs.mediaStreamType.get(s);return (t==null||Number.isNaN(t))&&i===chunkV54NMMTT_cjs.k.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(s){let{media:e,options:{liveEdgeOffset:t=10}={}}=s;if(!e)return false;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?false:e.currentTime>=e.liveEdgeStart;if(!(xs.mediaStreamType.get(s)===chunkV54NMMTT_cjs.k.LIVE))return false;let r=e.seekable;if(!r)return true;if(!r.length)return false;let n=r.end(r.length-1)-t;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(s){return Ls(s).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(s){return ql(s).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(s,e)=>{var t,i;let{media:r,options:n}=e;if(!r)return;let a=o=>{var l;!n.defaultSubtitles||o&&![chunkV54NMMTT_cjs.g.CAPTIONS,chunkV54NMMTT_cjs.g.SUBTITLES].includes((l=o?.track)==null?void 0:l.kind)||ha(e,true);};return r.addEventListener("loadstart",a),(t=r.textTracks)==null||t.addEventListener("addtrack",a),(i=r.textTracks)==null||i.addEventListener("removetrack",a),()=>{var o,l;r.removeEventListener("loadstart",a),(o=r.textTracks)==null||o.removeEventListener("addtrack",a),(l=r.textTracks)==null||l.removeEventListener("removetrack",a);}}]},mediaChaptersCues:{get(s){var e;let{media:t}=s;if(!t)return [];let[i]=zi(t,{kind:chunkV54NMMTT_cjs.g.CHAPTERS});return Array.from((e=i?.cues)!=null?e:[]).map(({text:r,startTime:n,endTime:a})=>({text:hE(r),startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(s,e)=>{var t;let{media:i}=e;if(!i)return;let r=i.querySelector('track[kind="chapters"][default][src]'),n=(t=i.shadowRoot)==null?void 0:t.querySelector(':is(video,audio) > track[kind="chapters"][default][src]');return r?.addEventListener("load",s),n?.addEventListener("load",s),()=>{r?.removeEventListener("load",s),n?.removeEventListener("load",s);}}]},mediaIsPip:{get(s){var e,t;let{media:i,documentElement:r}=s;if(!i||!r||!r.pictureInPictureElement)return false;if(r.pictureInPictureElement===i)return true;if(r.pictureInPictureElement instanceof HTMLMediaElement)return (e=i.localName)!=null&&e.includes("-")?chunkV54NMMTT_cjs.w(i,r.pictureInPictureElement):false;if(r.pictureInPictureElement.localName.includes("-")){let n=r.pictureInPictureElement.shadowRoot;for(;n?.pictureInPictureElement;){if(n.pictureInPictureElement===i)return true;n=(t=n.pictureInPictureElement)==null?void 0:t.shadowRoot;}}return false},set(s,e){let{media:t}=e;if(t)if(s){if(!chunkV54NMMTT_cjs.p.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!t.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}let i=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.");};t.requestPictureInPicture().catch(r=>{if(r.code===11){if(!t.src){console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");return}if(t.readyState===0&&t.preload==="none"){let n=()=>{t.removeEventListener("loadedmetadata",a),t.preload="none";},a=()=>{t.requestPictureInPicture().catch(i),n();};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&i(),n();},1e3);}else throw r}else throw r});}else chunkV54NMMTT_cjs.p.pictureInPictureElement&&chunkV54NMMTT_cjs.p.exitPictureInPicture();},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(s){var e;let{media:t}=s;return [...(e=t?.videoRenditions)!=null?e:[]].map(i=>({...i}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(s){var e,t,i;let{media:r}=s;return (i=(t=r?.videoRenditions)==null?void 0:t[(e=r.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:i.id},set(s,e){let{media:t}=e;if(!t?.videoRenditions){console.warn("MediaController: Rendition selection not supported by this media.");return}let i=s,r=Array.prototype.findIndex.call(t.videoRenditions,n=>n.id==i);t.videoRenditions.selectedIndex!=r&&(t.videoRenditions.selectedIndex=r);},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(s){var e;let{media:t}=s;return [...(e=t?.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(s){var e,t;let{media:i}=s;return (t=[...(e=i?.audioTracks)!=null?e:[]].find(r=>r.enabled))==null?void 0:t.id},set(s,e){let{media:t}=e;if(!t?.audioTracks){console.warn("MediaChrome: Audio track selection not supported by this media.");return}let i=s;for(let r of t.audioTracks)r.enabled=i==r.id;},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(s){return af(s)},set(s,e,t){var i;s?(rf(e),t.detail&&((i=e.media)==null||i.focus())):nf(e);},rootEvents:["fullscreenchange","webkitfullscreenchange"],mediaEvents:["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"]},mediaIsCasting:{get(s){var e;let{media:t}=s;return !t?.remote||((e=t.remote)==null?void 0:e.state)==="disconnected"?false:!!t.remote.state},set(s,e){var t,i;let{media:r}=e;if(r&&!(s&&((t=r.remote)==null?void 0:t.state)!=="disconnected")&&!(!s&&((i=r.remote)==null?void 0:i.state)!=="connected")){if(typeof r.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}r.remote.prompt().catch(()=>{});}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return false},set(s,e){let{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&chunkV54NMMTT_cjs.o.WebKitPlaybackTargetAvailabilityEvent)){console.error("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker();}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(s){let{media:e}=s;if(!df||!Yl(e))return chunkV54NMMTT_cjs.j.UNSUPPORTED}},mediaPipUnavailable:{get(s){let{media:e}=s;if(!cf||!Wl(e))return chunkV54NMMTT_cjs.j.UNSUPPORTED;if(e?.disablePictureInPicture)return chunkV54NMMTT_cjs.j.UNAVAILABLE}},mediaVolumeUnavailable:{get(s){let{media:e}=s;if(ma===false||e?.volume==null)return chunkV54NMMTT_cjs.j.UNSUPPORTED},stateOwnersUpdateHandlers:[s=>{ma==null&&cE.then(e=>s(e?void 0:chunkV54NMMTT_cjs.j.UNSUPPORTED));}]},mediaCastUnavailable:{get(s,{availability:e="not-available"}={}){var t;let{media:i}=s;if(!hf||!((t=i?.remote)!=null&&t.state))return chunkV54NMMTT_cjs.j.UNSUPPORTED;if(!(e==null||e==="available"))return chunkV54NMMTT_cjs.j.UNAVAILABLE},stateOwnersUpdateHandlers:[(s,e)=>{var t;let{media:i}=e;return i?(i.disableRemotePlayback||i.hasAttribute("disableremoteplayback")||(t=i?.remote)==null||t.watchAvailability(n=>{s({availability:n?"available":"not-available"});}).catch(n=>{n.name==="NotSupportedError"?s({availability:null}):s({availability:"not-available"});}),()=>{var n;(n=i?.remote)==null||n.cancelWatchAvailability().catch(()=>{});}):void 0}]},mediaAirplayUnavailable:{get(s,e){if(!uf)return chunkV54NMMTT_cjs.j.UNSUPPORTED;if(e?.availability==="not-available")return chunkV54NMMTT_cjs.j.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(s,e)=>{var t;let{media:i}=e;return i?(i.disableRemotePlayback||i.hasAttribute("disableremoteplayback")||(t=i?.remote)==null||t.watchAvailability(n=>{s({availability:n?"available":"not-available"});}).catch(n=>{n.name==="NotSupportedError"?s({availability:null}):s({availability:"not-available"});}),()=>{var n;(n=i?.remote)==null||n.cancelWatchAvailability().catch(()=>{});}):void 0}]},mediaRenditionUnavailable:{get(s){var e;let{media:t}=s;if(!t?.videoRenditions)return chunkV54NMMTT_cjs.j.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return chunkV54NMMTT_cjs.j.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(s){var e,t;let{media:i}=s;if(!i?.audioTracks)return chunkV54NMMTT_cjs.j.UNSUPPORTED;if(((t=(e=i.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return chunkV54NMMTT_cjs.j.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaLang:{get(s){let{options:{mediaLang:e}={}}=s;return e??"en"}}};var mf={[chunkV54NMMTT_cjs.a.MEDIA_PREVIEW_REQUEST](s,e,{detail:t}){var i,r,n;let{media:a}=e,o=t??void 0,l,d;if(a&&o!=null){let[f]=zi(a,{kind:chunkV54NMMTT_cjs.g.METADATA,label:"thumbnails"}),m=Array.prototype.find.call((i=f?.cues)!=null?i:[],(g,E,v)=>E===0?g.endTime>o:E===v.length-1?g.startTime<=o:g.startTime<=o&&g.endTime>o);if(m){let g=/'^(?:[a-z]+:)?\/\//i.test(m.text)||(r=a?.querySelector('track[label="thumbnails"]'))==null?void 0:r.src,E=new URL(m.text,g);d=new URLSearchParams(E.hash).get("#xywh").split(",").map(y=>+y),l=E.href;}}let c=s.mediaDuration.get(e),h=(n=s.mediaChaptersCues.get(e).find((f,m,g)=>m===g.length-1&&c===f.endTime?f.startTime<=o&&f.endTime>=o:f.startTime<=o&&f.endTime>o))==null?void 0:n.text;return t!=null&&h==null&&(h=""),{mediaPreviewTime:o,mediaPreviewImage:l,mediaPreviewCoords:d,mediaPreviewChapter:h}},[chunkV54NMMTT_cjs.a.MEDIA_PAUSE_REQUEST](s,e){s["mediaPaused"].set(true,e);},[chunkV54NMMTT_cjs.a.MEDIA_PLAY_REQUEST](s,e){var t,i,r,n;let a="mediaPaused",l=s.mediaStreamType.get(e)===chunkV54NMMTT_cjs.k.LIVE,d=!((t=e.options)!=null&&t.noAutoSeekToLive),c=s.mediaTargetLiveWindow.get(e)>0;if(l&&d&&!c){let u=(i=s.mediaSeekable.get(e))==null?void 0:i[1];if(u){let h=(n=(r=e.options)==null?void 0:r.seekToLiveOffset)!=null?n:0,f=u-h;s.mediaCurrentTime.set(f,e);}}s[a].set(false,e);},[chunkV54NMMTT_cjs.a.MEDIA_PLAYBACK_RATE_REQUEST](s,e,{detail:t}){let i="mediaPlaybackRate",r=t;s[i].set(r,e);},[chunkV54NMMTT_cjs.a.MEDIA_MUTE_REQUEST](s,e){s["mediaMuted"].set(true,e);},[chunkV54NMMTT_cjs.a.MEDIA_UNMUTE_REQUEST](s,e){let t="mediaMuted";s.mediaVolume.get(e)||s.mediaVolume.set(.25,e),s[t].set(false,e);},[chunkV54NMMTT_cjs.a.MEDIA_LOOP_REQUEST](s,e,{detail:t}){let i="mediaLoop",r=!!t;return s[i].set(r,e),{mediaLoop:r}},[chunkV54NMMTT_cjs.a.MEDIA_VOLUME_REQUEST](s,e,{detail:t}){let i="mediaVolume",r=t;r&&s.mediaMuted.get(e)&&s.mediaMuted.set(false,e),s[i].set(r,e);},[chunkV54NMMTT_cjs.a.MEDIA_SEEK_REQUEST](s,e,{detail:t}){let i="mediaCurrentTime",r=t;s[i].set(r,e);},[chunkV54NMMTT_cjs.a.MEDIA_SEEK_TO_LIVE_REQUEST](s,e){var t,i,r;let n="mediaCurrentTime",a=(t=s.mediaSeekable.get(e))==null?void 0:t[1];if(Number.isNaN(Number(a)))return;let o=(r=(i=e.options)==null?void 0:i.seekToLiveOffset)!=null?r:0,l=a-o;s[n].set(l,e);},[chunkV54NMMTT_cjs.a.MEDIA_SHOW_SUBTITLES_REQUEST](s,e,{detail:t}){var i;let{options:r}=e,n=Ls(e),a=Kl(t),o=(i=a[0])==null?void 0:i.language;o&&!r.noSubtitlesLangPref&&chunkV54NMMTT_cjs.o.localStorage.setItem("media-chrome-pref-subtitles-lang",o),ji(chunkV54NMMTT_cjs.h.SHOWING,n,a);},[chunkV54NMMTT_cjs.a.MEDIA_DISABLE_SUBTITLES_REQUEST](s,e,{detail:t}){let i=Ls(e),r=t??[];ji(chunkV54NMMTT_cjs.h.DISABLED,i,r);},[chunkV54NMMTT_cjs.a.MEDIA_TOGGLE_SUBTITLES_REQUEST](s,e,{detail:t}){ha(e,t);},[chunkV54NMMTT_cjs.a.MEDIA_RENDITION_REQUEST](s,e,{detail:t}){let i="mediaRenditionSelected",r=t;s[i].set(r,e);},[chunkV54NMMTT_cjs.a.MEDIA_AUDIO_TRACK_REQUEST](s,e,{detail:t}){let i="mediaAudioTrackEnabled",r=t;s[i].set(r,e);},[chunkV54NMMTT_cjs.a.MEDIA_ENTER_PIP_REQUEST](s,e){let t="mediaIsPip";s.mediaIsFullscreen.get(e)&&s.mediaIsFullscreen.set(false,e),s[t].set(true,e);},[chunkV54NMMTT_cjs.a.MEDIA_EXIT_PIP_REQUEST](s,e){s["mediaIsPip"].set(false,e);},[chunkV54NMMTT_cjs.a.MEDIA_ENTER_FULLSCREEN_REQUEST](s,e,t){let i="mediaIsFullscreen";s.mediaIsPip.get(e)&&s.mediaIsPip.set(false,e),s[i].set(true,e,t);},[chunkV54NMMTT_cjs.a.MEDIA_EXIT_FULLSCREEN_REQUEST](s,e){s["mediaIsFullscreen"].set(false,e);},[chunkV54NMMTT_cjs.a.MEDIA_ENTER_CAST_REQUEST](s,e){let t="mediaIsCasting";s.mediaIsFullscreen.get(e)&&s.mediaIsFullscreen.set(false,e),s[t].set(true,e);},[chunkV54NMMTT_cjs.a.MEDIA_EXIT_CAST_REQUEST](s,e){s["mediaIsCasting"].set(false,e);},[chunkV54NMMTT_cjs.a.MEDIA_AIRPLAY_REQUEST](s,e){s["mediaIsAirplaying"].set(true,e);}};var gf=({media:s,fullscreenElement:e,documentElement:t,stateMediator:i=xs,requestMap:r=mf,options:n={},monitorStateOwnersOnlyWithSubscriptions:a=true})=>{let o=[],l={options:{...n}},d=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0}),c=g=>{g!=null&&(fa(g,d)||(d=Object.freeze({...d,...g}),o.forEach(E=>E(d))));},u=()=>{let g=Object.entries(i).reduce((E,[v,{get:y}])=>(E[v]=y(l),E),{});c(g);},h={},f,m=async(g,E)=>{var v,y,S,b,_,D,I,k,R,L,M,$,K,j,V,F;let Y=!!f;if(f={...l,...f??{},...g},Y)return;await ff(...Object.values(g));let G=o.length>0&&E===0&&a,q=l.media!==f.media,X=((v=l.media)==null?void 0:v.textTracks)!==((y=f.media)==null?void 0:y.textTracks),N=((S=l.media)==null?void 0:S.videoRenditions)!==((b=f.media)==null?void 0:b.videoRenditions),B=((_=l.media)==null?void 0:_.audioTracks)!==((D=f.media)==null?void 0:D.audioTracks),se=((I=l.media)==null?void 0:I.remote)!==((k=f.media)==null?void 0:k.remote),Ee=l.documentElement!==f.documentElement,re=!!l.media&&(q||G),ce=!!((R=l.media)!=null&&R.textTracks)&&(X||G),Ge=!!((L=l.media)!=null&&L.videoRenditions)&&(N||G),Ue=!!((M=l.media)!=null&&M.audioTracks)&&(B||G),st=!!(($=l.media)!=null&&$.remote)&&(se||G),mt=!!l.documentElement&&(Ee||G),Mt=re||ce||Ge||Ue||st||mt,Ii=o.length===0&&E===1&&a,ps=!!f.media&&(q||Ii),Es=!!((K=f.media)!=null&&K.textTracks)&&(X||Ii),Ol=!!((j=f.media)!=null&&j.videoRenditions)&&(N||Ii),fe=!!((V=f.media)!=null&&V.audioTracks)&&(B||Ii),He=!!((F=f.media)!=null&&F.remote)&&(se||Ii),rt=!!f.documentElement&&(Ee||Ii),Wt=ps||Es||Ol||fe||He||rt;if(!(Mt||Wt)){Object.entries(f).forEach(([me,gt])=>{l[me]=gt;}),u(),f=void 0;return}Object.entries(i).forEach(([me,{get:gt,mediaEvents:$n=[],textTracksEvents:vs=[],videoRenditionsEvents:Gn=[],audioTracksEvents:Hi=[],remoteEvents:Hn=[],rootEvents:Fl=[],stateOwnersUpdateHandlers:Kn=[]}])=>{h[me]||(h[me]={});let et=xe=>{let Ne=gt(l,xe);c({[me]:Ne});},Le;Le=h[me].mediaEvents,$n.forEach(xe=>{Le&&re&&(l.media.removeEventListener(xe,Le),h[me].mediaEvents=void 0),ps&&(f.media.addEventListener(xe,et),h[me].mediaEvents=et);}),Le=h[me].textTracksEvents,vs.forEach(xe=>{var Ne,wt;Le&&ce&&((Ne=l.media.textTracks)==null||Ne.removeEventListener(xe,Le),h[me].textTracksEvents=void 0),Es&&((wt=f.media.textTracks)==null||wt.addEventListener(xe,et),h[me].textTracksEvents=et);}),Le=h[me].videoRenditionsEvents,Gn.forEach(xe=>{var Ne,wt;Le&&Ge&&((Ne=l.media.videoRenditions)==null||Ne.removeEventListener(xe,Le),h[me].videoRenditionsEvents=void 0),Ol&&((wt=f.media.videoRenditions)==null||wt.addEventListener(xe,et),h[me].videoRenditionsEvents=et);}),Le=h[me].audioTracksEvents,Hi.forEach(xe=>{var Ne,wt;Le&&Ue&&((Ne=l.media.audioTracks)==null||Ne.removeEventListener(xe,Le),h[me].audioTracksEvents=void 0),fe&&((wt=f.media.audioTracks)==null||wt.addEventListener(xe,et),h[me].audioTracksEvents=et);}),Le=h[me].remoteEvents,Hn.forEach(xe=>{var Ne,wt;Le&&st&&((Ne=l.media.remote)==null||Ne.removeEventListener(xe,Le),h[me].remoteEvents=void 0),He&&((wt=f.media.remote)==null||wt.addEventListener(xe,et),h[me].remoteEvents=et);}),Le=h[me].rootEvents,Fl.forEach(xe=>{Le&&mt&&(l.documentElement.removeEventListener(xe,Le),h[me].rootEvents=void 0),rt&&(f.documentElement.addEventListener(xe,et),h[me].rootEvents=et);});let Vn=h[me].stateOwnersUpdateHandlers;if(Vn&&Mt&&(Array.isArray(Vn)?Vn:[Vn]).forEach(Ne=>{typeof Ne=="function"&&Ne();}),Wt){let xe=Kn.map(Ne=>Ne(et,f)).filter(Ne=>typeof Ne=="function");h[me].stateOwnersUpdateHandlers=xe.length===1?xe[0]:xe;}else Mt&&(h[me].stateOwnersUpdateHandlers=void 0);}),Object.entries(f).forEach(([me,gt])=>{l[me]=gt;}),u(),f=void 0;};return m({media:s,fullscreenElement:e,documentElement:t,options:n}),{dispatch(g){let{type:E,detail:v}=g;if(r[E]&&d.mediaErrorCode==null){c(r[E](i,l,g));return}E==="mediaelementchangerequest"?m({media:v}):E==="fullscreenelementchangerequest"?m({fullscreenElement:v}):E==="documentelementchangerequest"?m({documentElement:v}):E==="optionschangerequest"&&(Object.entries(v??{}).forEach(([y,S])=>{l.options[y]=S;}),u());},getState(){return d},subscribe(g){return m({},o.length+1),o.push(g),g(d),()=>{let E=o.indexOf(g);E>=0&&(m({},o.length-1),o.splice(E,1));}}}};var Jl=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Z=(s,e,t)=>(Jl(s,e,"read from private field"),t?t.call(s):e.get(s)),xt=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},jt=(s,e,t,i)=>(Jl(s,e,"write to private field"),e.set(s,t),t),Qt=(s,e,t)=>(Jl(s,e,"access private method"),t),Ci,Dr,pe,Xi,Cr,zt,ga,Mr,pa,jl,Zi,Rs,Ea,zl,Ql,bf,Af=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Enter"," ","f","m","k","c","l","j",">","<","p"],pf=10,Ef=.025,vf=.25,fE=.25,mE=2,U={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYBOARD_BACKWARD_SEEK_OFFSET:"keyboardbackwardseekoffset",KEYBOARD_FORWARD_SEEK_OFFSET:"keyboardforwardseekoffset",KEYBOARD_DOWN_VOLUME_STEP:"keyboarddownvolumestep",KEYBOARD_UP_VOLUME_STEP:"keyboardupvolumestep",KEYS_USED:"keysused",LANG:"lang",LOOP:"loop",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_DEFAULT_STORE:"nodefaultstore",NO_HOTKEYS:"nohotkeys",NO_MUTED_PREF:"nomutedpref",NO_SUBTITLES_LANG_PREF:"nosubtitleslangpref",NO_VOLUME_PREF:"novolumepref",SEEK_TO_LIVE_OFFSET:"seektoliveoffset"},Xl=class extends Wi{constructor(){super(),xt(this,pa),xt(this,Zi),xt(this,Ea),xt(this,Ql),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,xt(this,Ci,new Di(this,U.HOTKEYS)),xt(this,Dr,void 0),xt(this,pe,void 0),xt(this,Xi,null),xt(this,Cr,void 0),xt(this,zt,void 0),xt(this,ga,t=>{var i;(i=Z(this,pe))==null||i.dispatch(t);}),xt(this,Mr,void 0),this.associateElement(this);let e={};jt(this,Cr,t=>{Object.entries(t).forEach(([i,r])=>{if(i in e&&e[i]===r)return;this.propagateMediaState(i,r);let n=i.toLowerCase(),a=new chunkV54NMMTT_cjs.o.CustomEvent(chunkV54NMMTT_cjs.f[n],{composed:true,detail:r});this.dispatchEvent(a);}),e=t;}),this.hasAttribute(U.NO_HOTKEYS)?this.disableHotkeys():this.enableHotkeys();}static get observedAttributes(){return super.observedAttributes.concat(U.NO_HOTKEYS,U.HOTKEYS,U.DEFAULT_STREAM_TYPE,U.DEFAULT_SUBTITLES,U.DEFAULT_DURATION,U.NO_MUTED_PREF,U.NO_VOLUME_PREF,U.LANG,U.LOOP)}get mediaStore(){return Z(this,pe)}set mediaStore(e){var t,i;if(Z(this,pe)&&((t=Z(this,zt))==null||t.call(this),jt(this,zt,void 0)),jt(this,pe,e),!Z(this,pe)&&!this.hasAttribute(U.NO_DEFAULT_STORE)){Qt(this,pa,jl).call(this);return}jt(this,zt,(i=Z(this,pe))==null?void 0:i.subscribe(Z(this,Cr)));}get fullscreenElement(){var e;return (e=Z(this,Dr))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(U.FULLSCREEN_ELEMENT)&&this.removeAttribute(U.FULLSCREEN_ELEMENT),jt(this,Dr,e),(t=Z(this,pe))==null||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement});}get defaultSubtitles(){return chunkV54NMMTT_cjs.G(this,U.DEFAULT_SUBTITLES)}set defaultSubtitles(e){chunkV54NMMTT_cjs.H(this,U.DEFAULT_SUBTITLES,e);}get defaultStreamType(){return chunkV54NMMTT_cjs.I(this,U.DEFAULT_STREAM_TYPE)}set defaultStreamType(e){chunkV54NMMTT_cjs.J(this,U.DEFAULT_STREAM_TYPE,e);}get defaultDuration(){return chunkV54NMMTT_cjs.E(this,U.DEFAULT_DURATION)}set defaultDuration(e){chunkV54NMMTT_cjs.F(this,U.DEFAULT_DURATION,e);}get noHotkeys(){return chunkV54NMMTT_cjs.G(this,U.NO_HOTKEYS)}set noHotkeys(e){chunkV54NMMTT_cjs.H(this,U.NO_HOTKEYS,e);}get keysUsed(){return chunkV54NMMTT_cjs.I(this,U.KEYS_USED)}set keysUsed(e){chunkV54NMMTT_cjs.J(this,U.KEYS_USED,e);}get liveEdgeOffset(){return chunkV54NMMTT_cjs.E(this,U.LIVE_EDGE_OFFSET)}set liveEdgeOffset(e){chunkV54NMMTT_cjs.F(this,U.LIVE_EDGE_OFFSET,e);}get noAutoSeekToLive(){return chunkV54NMMTT_cjs.G(this,U.NO_AUTO_SEEK_TO_LIVE)}set noAutoSeekToLive(e){chunkV54NMMTT_cjs.H(this,U.NO_AUTO_SEEK_TO_LIVE,e);}get noVolumePref(){return chunkV54NMMTT_cjs.G(this,U.NO_VOLUME_PREF)}set noVolumePref(e){chunkV54NMMTT_cjs.H(this,U.NO_VOLUME_PREF,e);}get noMutedPref(){return chunkV54NMMTT_cjs.G(this,U.NO_MUTED_PREF)}set noMutedPref(e){chunkV54NMMTT_cjs.H(this,U.NO_MUTED_PREF,e);}get noSubtitlesLangPref(){return chunkV54NMMTT_cjs.G(this,U.NO_SUBTITLES_LANG_PREF)}set noSubtitlesLangPref(e){chunkV54NMMTT_cjs.H(this,U.NO_SUBTITLES_LANG_PREF,e);}get noDefaultStore(){return chunkV54NMMTT_cjs.G(this,U.NO_DEFAULT_STORE)}set noDefaultStore(e){chunkV54NMMTT_cjs.H(this,U.NO_DEFAULT_STORE,e);}attributeChangedCallback(e,t,i){var r,n,a,o,l,d,c,u,h,f,m,g;if(super.attributeChangedCallback(e,t,i),e===U.NO_HOTKEYS)i!==t&&i===""?(this.hasAttribute(U.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===U.HOTKEYS)Z(this,Ci).value=i;else if(e===U.DEFAULT_SUBTITLES&&i!==t)(r=Z(this,pe))==null||r.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(U.DEFAULT_SUBTITLES)}});else if(e===U.DEFAULT_STREAM_TYPE)(a=Z(this,pe))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(n=this.getAttribute(U.DEFAULT_STREAM_TYPE))!=null?n:void 0}});else if(e===U.LIVE_EDGE_OFFSET)(o=Z(this,pe))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(U.LIVE_EDGE_OFFSET)?+this.getAttribute(U.LIVE_EDGE_OFFSET):void 0,seekToLiveOffset:this.hasAttribute(U.SEEK_TO_LIVE_OFFSET)?void 0:+this.getAttribute(U.LIVE_EDGE_OFFSET)}});else if(e===U.SEEK_TO_LIVE_OFFSET)(l=Z(this,pe))==null||l.dispatch({type:"optionschangerequest",detail:{seekToLiveOffset:this.hasAttribute(U.SEEK_TO_LIVE_OFFSET)?+this.getAttribute(U.SEEK_TO_LIVE_OFFSET):void 0}});else if(e===U.NO_AUTO_SEEK_TO_LIVE)(d=Z(this,pe))==null||d.dispatch({type:"optionschangerequest",detail:{noAutoSeekToLive:this.hasAttribute(U.NO_AUTO_SEEK_TO_LIVE)}});else if(e===U.FULLSCREEN_ELEMENT){let E=i?(c=this.getRootNode())==null?void 0:c.getElementById(i):void 0;jt(this,Dr,E),(u=Z(this,pe))==null||u.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement});}else e===U.LANG&&i!==t?(chunkV54NMMTT_cjs.m(i),(h=Z(this,pe))==null||h.dispatch({type:"optionschangerequest",detail:{mediaLang:i}})):e===U.LOOP&&i!==t?(f=Z(this,pe))==null||f.dispatch({type:chunkV54NMMTT_cjs.a.MEDIA_LOOP_REQUEST,detail:i!=null}):e===U.NO_VOLUME_PREF&&i!==t?(m=Z(this,pe))==null||m.dispatch({type:"optionschangerequest",detail:{noVolumePref:this.hasAttribute(U.NO_VOLUME_PREF)}}):e===U.NO_MUTED_PREF&&i!==t&&((g=Z(this,pe))==null||g.dispatch({type:"optionschangerequest",detail:{noMutedPref:this.hasAttribute(U.NO_MUTED_PREF)}}));}connectedCallback(){var e,t;!Z(this,pe)&&!this.hasAttribute(U.NO_DEFAULT_STORE)&&Qt(this,pa,jl).call(this),(e=Z(this,pe))==null||e.dispatch({type:"documentelementchangerequest",detail:chunkV54NMMTT_cjs.p}),super.connectedCallback(),Z(this,pe)&&!Z(this,zt)&&jt(this,zt,(t=Z(this,pe))==null?void 0:t.subscribe(Z(this,Cr))),Z(this,Mr)!==void 0&&Z(this,pe)&&this.media&&setTimeout(()=>{var i,r,n;(r=(i=this.media)==null?void 0:i.textTracks)!=null&&r.length&&((n=Z(this,pe))==null||n.dispatch({type:chunkV54NMMTT_cjs.a.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:Z(this,Mr)}));},0),this.hasAttribute(U.NO_HOTKEYS)?this.disableHotkeys():this.enableHotkeys();}disconnectedCallback(){var e,t,i,r,n;if((e=super.disconnectedCallback)==null||e.call(this),Z(this,pe)){let a=Z(this,pe).getState();jt(this,Mr,!!((t=a.mediaSubtitlesShowing)!=null&&t.length)),(i=Z(this,pe))==null||i.dispatch({type:"documentelementchangerequest",detail:void 0}),(r=Z(this,pe))==null||r.dispatch({type:chunkV54NMMTT_cjs.a.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:false});}Z(this,zt)&&((n=Z(this,zt))==null||n.call(this),jt(this,zt,void 0));}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=Z(this,pe))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1);}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=Z(this,pe))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0});}propagateMediaState(e,t){Sf(this.mediaStateReceivers,e,t);}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let i=this.registerMediaStateReceiver.bind(this),r=this.unregisterMediaStateReceiver.bind(this),n=yE(e,i,r);Object.values(chunkV54NMMTT_cjs.a).forEach(a=>{e.addEventListener(a,Z(this,ga));}),t.set(e,n);}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.values(chunkV54NMMTT_cjs.a).forEach(r=>{e.removeEventListener(r,Z(this,ga));});}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),Z(this,pe)&&Object.entries(Z(this,pe).getState()).forEach(([r,n])=>{Sf([e],r,n);}));}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,i=t.indexOf(e);i<0||t.splice(i,1);}enableHotkeys(){this.addEventListener("keydown",Qt(this,Ea,zl));}disableHotkeys(){this.removeEventListener("keydown",Qt(this,Ea,zl)),this.removeEventListener("keyup",Qt(this,Zi,Rs));}get hotkeys(){return chunkV54NMMTT_cjs.I(this,U.HOTKEYS)}set hotkeys(e){chunkV54NMMTT_cjs.J(this,U.HOTKEYS,e);}keyboardShortcutHandler(e){var t,i,r,n,a,o,l,d,c;let u=e.target;if(((r=(i=(t=u.getAttribute(U.KEYS_USED))==null?void 0:t.split(" "))!=null?i:u?.keysUsed)!=null?r:[]).map(v=>v==="Space"?" ":v).filter(Boolean).includes(e.key))return;let f,m,g;if(!(Z(this,Ci).contains(`no${e.key.toLowerCase()}`)||e.key===" "&&Z(this,Ci).contains("nospace")||e.shiftKey&&(e.key==="/"||e.key==="?")&&Z(this,Ci).contains("noshift+/")))switch(e.key){case " ":case "k":f=Z(this,pe).getState().mediaPaused?chunkV54NMMTT_cjs.a.MEDIA_PLAY_REQUEST:chunkV54NMMTT_cjs.a.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new chunkV54NMMTT_cjs.o.CustomEvent(f,{composed:true,bubbles:true}));break;case "m":f=this.mediaStore.getState().mediaVolumeLevel==="off"?chunkV54NMMTT_cjs.a.MEDIA_UNMUTE_REQUEST:chunkV54NMMTT_cjs.a.MEDIA_MUTE_REQUEST,this.dispatchEvent(new chunkV54NMMTT_cjs.o.CustomEvent(f,{composed:true,bubbles:true}));break;case "f":f=this.mediaStore.getState().mediaIsFullscreen?chunkV54NMMTT_cjs.a.MEDIA_EXIT_FULLSCREEN_REQUEST:chunkV54NMMTT_cjs.a.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new chunkV54NMMTT_cjs.o.CustomEvent(f,{composed:true,bubbles:true}));break;case "c":this.dispatchEvent(new chunkV54NMMTT_cjs.o.CustomEvent(chunkV54NMMTT_cjs.a.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:true,bubbles:true}));break;case "ArrowLeft":case "j":{let v=this.hasAttribute(U.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(U.KEYBOARD_BACKWARD_SEEK_OFFSET):pf;m=Math.max(((n=this.mediaStore.getState().mediaCurrentTime)!=null?n:0)-v,0),g=new chunkV54NMMTT_cjs.o.CustomEvent(chunkV54NMMTT_cjs.a.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:m}),this.dispatchEvent(g);break}case "ArrowRight":case "l":{let v=this.hasAttribute(U.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(U.KEYBOARD_FORWARD_SEEK_OFFSET):pf;m=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)+v,0),g=new chunkV54NMMTT_cjs.o.CustomEvent(chunkV54NMMTT_cjs.a.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:m}),this.dispatchEvent(g);break}case "ArrowUp":{let v=this.hasAttribute(U.KEYBOARD_UP_VOLUME_STEP)?+this.getAttribute(U.KEYBOARD_UP_VOLUME_STEP):Ef;m=Math.min(((o=this.mediaStore.getState().mediaVolume)!=null?o:1)+v,1),g=new chunkV54NMMTT_cjs.o.CustomEvent(chunkV54NMMTT_cjs.a.MEDIA_VOLUME_REQUEST,{composed:true,bubbles:true,detail:m}),this.dispatchEvent(g);break}case "ArrowDown":{let v=this.hasAttribute(U.KEYBOARD_DOWN_VOLUME_STEP)?+this.getAttribute(U.KEYBOARD_DOWN_VOLUME_STEP):Ef;m=Math.max(((l=this.mediaStore.getState().mediaVolume)!=null?l:1)-v,0),g=new chunkV54NMMTT_cjs.o.CustomEvent(chunkV54NMMTT_cjs.a.MEDIA_VOLUME_REQUEST,{composed:true,bubbles:true,detail:m}),this.dispatchEvent(g);break}case "<":{let v=(d=this.mediaStore.getState().mediaPlaybackRate)!=null?d:1;m=Math.max(v-vf,fE).toFixed(2),g=new chunkV54NMMTT_cjs.o.CustomEvent(chunkV54NMMTT_cjs.a.MEDIA_PLAYBACK_RATE_REQUEST,{composed:true,bubbles:true,detail:m}),this.dispatchEvent(g);break}case ">":{let v=(c=this.mediaStore.getState().mediaPlaybackRate)!=null?c:1;m=Math.min(v+vf,mE).toFixed(2),g=new chunkV54NMMTT_cjs.o.CustomEvent(chunkV54NMMTT_cjs.a.MEDIA_PLAYBACK_RATE_REQUEST,{composed:true,bubbles:true,detail:m}),this.dispatchEvent(g);break}case "/":case "?":{e.shiftKey&&Qt(this,Ql,bf).call(this);break}case "p":{f=this.mediaStore.getState().mediaIsPip?chunkV54NMMTT_cjs.a.MEDIA_EXIT_PIP_REQUEST:chunkV54NMMTT_cjs.a.MEDIA_ENTER_PIP_REQUEST,g=new chunkV54NMMTT_cjs.o.CustomEvent(f,{composed:true,bubbles:true}),this.dispatchEvent(g);break}}}};Ci=new WeakMap;Dr=new WeakMap;pe=new WeakMap;Xi=new WeakMap;Cr=new WeakMap;zt=new WeakMap;ga=new WeakMap;Mr=new WeakMap;pa=new WeakSet;jl=function(){var s;this.mediaStore=gf({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(U.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(U.DEFAULT_DURATION)?+this.getAttribute(U.DEFAULT_DURATION):void 0,defaultStreamType:(s=this.getAttribute(U.DEFAULT_STREAM_TYPE))!=null?s:void 0,liveEdgeOffset:this.hasAttribute(U.LIVE_EDGE_OFFSET)?+this.getAttribute(U.LIVE_EDGE_OFFSET):void 0,seekToLiveOffset:this.hasAttribute(U.SEEK_TO_LIVE_OFFSET)?+this.getAttribute(U.SEEK_TO_LIVE_OFFSET):this.hasAttribute(U.LIVE_EDGE_OFFSET)?+this.getAttribute(U.LIVE_EDGE_OFFSET):void 0,noAutoSeekToLive:this.hasAttribute(U.NO_AUTO_SEEK_TO_LIVE),noVolumePref:this.hasAttribute(U.NO_VOLUME_PREF),noMutedPref:this.hasAttribute(U.NO_MUTED_PREF),noSubtitlesLangPref:this.hasAttribute(U.NO_SUBTITLES_LANG_PREF)}});};Zi=new WeakSet;Rs=function(s){let{key:e,shiftKey:t}=s;if(!(t&&(e==="/"||e==="?")||Af.includes(e))){this.removeEventListener("keyup",Qt(this,Zi,Rs));return}this.keyboardShortcutHandler(s);};Ea=new WeakSet;zl=function(s){var e;let{metaKey:t,altKey:i,key:r,shiftKey:n}=s,a=n&&(r==="/"||r==="?");if(a&&((e=Z(this,Xi))!=null&&e.open)){this.removeEventListener("keyup",Qt(this,Zi,Rs));return}if(t||i||!a&&!Af.includes(r)){this.removeEventListener("keyup",Qt(this,Zi,Rs));return}let o=s.target,l=o instanceof HTMLElement&&(o.tagName.toLowerCase()==="media-volume-range"||o.tagName.toLowerCase()==="media-time-range");[" ","ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(r)&&!(Z(this,Ci).contains(`no${r.toLowerCase()}`)||r===" "&&Z(this,Ci).contains("nospace"))&&!l&&s.preventDefault(),this.addEventListener("keyup",Qt(this,Zi,Rs),{once:true});};Ql=new WeakSet;bf=function(){Z(this,Xi)||(jt(this,Xi,chunkV54NMMTT_cjs.p.createElement("media-keyboard-shortcuts-dialog")),this.appendChild(Z(this,Xi))),Z(this,Xi).open=true;};var gE=Object.values(chunkV54NMMTT_cjs.d),pE=Object.values(chunkV54NMMTT_cjs.c),_f=s=>{var e,t,i,r;let{observedAttributes:n}=s.constructor;!n&&((e=s.nodeName)!=null&&e.includes("-"))&&(chunkV54NMMTT_cjs.o.customElements.upgrade(s),{observedAttributes:n}=s.constructor);let a=(r=(i=(t=s?.getAttribute)==null?void 0:t.call(s,chunkV54NMMTT_cjs.b.MEDIA_CHROME_ATTRIBUTES))==null?void 0:i.split)==null?void 0:r.call(i,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>gE.includes(o)):[]},EE=s=>{var e,t;return (e=s.nodeName)!=null&&e.includes("-")&&chunkV54NMMTT_cjs.o.customElements.get((t=s.nodeName)==null?void 0:t.toLowerCase())&&!(s instanceof chunkV54NMMTT_cjs.o.customElements.get(s.nodeName.toLowerCase()))&&chunkV54NMMTT_cjs.o.customElements.upgrade(s),pE.some(i=>i in s)},Zl=s=>EE(s)||!!_f(s).length,Tf=s=>{var e;return (e=s?.join)==null?void 0:e.call(s,":")},yf={[chunkV54NMMTT_cjs.d.MEDIA_SUBTITLES_LIST]:vi,[chunkV54NMMTT_cjs.d.MEDIA_SUBTITLES_SHOWING]:vi,[chunkV54NMMTT_cjs.d.MEDIA_SEEKABLE]:Tf,[chunkV54NMMTT_cjs.d.MEDIA_BUFFERED]:s=>s?.map(Tf).join(" "),[chunkV54NMMTT_cjs.d.MEDIA_PREVIEW_COORDS]:s=>s?.join(" "),[chunkV54NMMTT_cjs.d.MEDIA_RENDITION_LIST]:Kh,[chunkV54NMMTT_cjs.d.MEDIA_AUDIO_TRACK_LIST]:Wh},vE=async(s,e,t)=>{var i,r;if(s.isConnected||await Jn(0),typeof t=="boolean"||t==null)return chunkV54NMMTT_cjs.H(s,e,t);if(typeof t=="number")return chunkV54NMMTT_cjs.F(s,e,t);if(typeof t=="string")return chunkV54NMMTT_cjs.J(s,e,t);if(Array.isArray(t)&&!t.length)return s.removeAttribute(e);let n=(r=(i=yf[e])==null?void 0:i.call(yf,t))!=null?r:t;return s.setAttribute(e,n)},TE=s=>{var e;return !!((e=s.closest)!=null&&e.call(s,'*[slot="media"]'))},Qi=(s,e)=>{if(TE(s))return;let t=(r,n)=>{var a,o;Zl(r)&&n(r);let{children:l=[]}=r??{},d=(o=(a=r?.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(u=>Qi(u,n));},i=s?.nodeName.toLowerCase();if(i.includes("-")&&!Zl(s)){chunkV54NMMTT_cjs.o.customElements.whenDefined(i).then(()=>{t(s,e);});return}t(s,e);},Sf=(s,e,t)=>{s.forEach(i=>{if(e in i){i[e]=t;return}let r=_f(i),n=e.toLowerCase();r.includes(n)&&vE(i,n,t);});},yE=(s,e,t)=>{Qi(s,e);let i=c=>{var u;let h=(u=c?.composedPath()[0])!=null?u:c.target;e(h);},r=c=>{var u;let h=(u=c?.composedPath()[0])!=null?u:c.target;t(h);};s.addEventListener(chunkV54NMMTT_cjs.a.REGISTER_MEDIA_STATE_RECEIVER,i),s.addEventListener(chunkV54NMMTT_cjs.a.UNREGISTER_MEDIA_STATE_RECEIVER,r);let n=c=>{c.forEach(u=>{let{addedNodes:h=[],removedNodes:f=[],type:m,target:g,attributeName:E}=u;m==="childList"?(Array.prototype.forEach.call(h,v=>Qi(v,e)),Array.prototype.forEach.call(f,v=>Qi(v,t))):m==="attributes"&&E===chunkV54NMMTT_cjs.b.MEDIA_CHROME_ATTRIBUTES&&(Zl(g)?e(g):t(g));});},a=[],o=c=>{let u=c.target;u.name!=="media"&&(a.forEach(h=>Qi(h,t)),a=[...u.assignedElements({flatten:true})],a.forEach(h=>Qi(h,e)));};s.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(s,{childList:true,attributes:true,subtree:true}),()=>{Qi(s,t),s.removeEventListener("slotchange",o),l.disconnect(),s.removeEventListener(chunkV54NMMTT_cjs.a.REGISTER_MEDIA_STATE_RECEIVER,i),s.removeEventListener(chunkV54NMMTT_cjs.a.UNREGISTER_MEDIA_STATE_RECEIVER,r);}};chunkV54NMMTT_cjs.o.customElements.get("media-controller")||chunkV54NMMTT_cjs.o.customElements.define("media-controller",Xl);var If=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
159
|
+
`}var Q0=Object.values(chunk474VILDO_cjs.d),X0="sm:384 md:576 lg:768 xl:960";function Z0(s){Jh(s.target,s.contentRect.width);}function Jh(s,e){var t;if(!s.isConnected)return;let i=(t=s.getAttribute(J.BREAKPOINTS))!=null?t:X0,r=J0(i),n=eE(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(chunk474VILDO_cjs.e.BREAKPOINTS_CHANGE,{detail:n});s.dispatchEvent(o);}s.breakpointsComputed||(s.breakpointsComputed=true,s.dispatchEvent(new CustomEvent(chunk474VILDO_cjs.e.BREAKPOINTS_COMPUTED,{bubbles:true,composed:true})));}function J0(s){let e=s.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function eE(s,e){return Object.keys(s).filter(t=>e>=parseInt(s[t]))}var qi=class extends chunk474VILDO_cjs.o.HTMLElement{constructor(){if(super(),pt(this,Nl),pt(this,Ul),pt(this,$l),pt(this,_r),pt(this,na),pt(this,bs),pt(this,sa,0),pt(this,ys,null),pt(this,Ar,null),pt(this,Ss,void 0),this.breakpointsComputed=false,pt(this,ta,new MutationObserver(It(this,Nl,Qh).bind(this))),pt(this,br,false),pt(this,ia,t=>{Et(this,br)||(setTimeout(()=>{Z0(t),Yi(this,br,false);},0),Yi(this,br,true));}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let t=chunk474VILDO_cjs.q(this.attributes),i=this.constructor.getTemplateHTML(t);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(i):this.shadowRoot.innerHTML=i;}let e=this.querySelector(":scope > slot[slot=media]");e&&e.addEventListener("slotchange",()=>{if(!e.assignedElements({flatten:true}).length){Et(this,ys)&&this.mediaUnsetCallback(Et(this,ys));return}this.handleMediaUpdated(this.media);});}static get observedAttributes(){return [J.AUTOHIDE,J.GESTURES_DISABLED].concat(Q0).filter(e=>![chunk474VILDO_cjs.d.MEDIA_RENDITION_LIST,chunk474VILDO_cjs.d.MEDIA_AUDIO_TRACK_LIST,chunk474VILDO_cjs.d.MEDIA_CHAPTERS_CUES,chunk474VILDO_cjs.d.MEDIA_WIDTH,chunk474VILDO_cjs.d.MEDIA_HEIGHT,chunk474VILDO_cjs.d.MEDIA_ERROR,chunk474VILDO_cjs.d.MEDIA_ERROR_MESSAGE].includes(e))}attributeChangedCallback(e,t,i){e.toLowerCase()==J.AUTOHIDE&&(this.autohide=i);}get media(){let e=this.querySelector(":scope > [slot=media]");return e?.nodeName=="SLOT"&&(e=e.assignedElements({flatten:true})[0]),e}async handleMediaUpdated(e){e&&(Yi(this,ys,e),e.localName.includes("-")&&await chunk474VILDO_cjs.o.customElements.whenDefined(e.localName),this.mediaSetCallback(e));}connectedCallback(){var e;Et(this,ta).observe(this,{childList:true,subtree:true}),chunkLVGLIRQU_cjs.a(this,Et(this,ia));let i=this.getAttribute(J.AUDIO)!=null?chunk474VILDO_cjs.n("audio player"):chunk474VILDO_cjs.n("video player");this.setAttribute("role","region"),this.setAttribute("aria-label",i),this.handleMediaUpdated(this.media),this.setAttribute(J.USER_INACTIVE,""),Jh(this,this.getBoundingClientRect().width),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=chunk474VILDO_cjs.o.window)==null||e.addEventListener("mouseup",this);}disconnectedCallback(){var e;Et(this,ta).disconnect(),chunkLVGLIRQU_cjs.b(this,Et(this,ia)),this.media&&this.mediaUnsetCallback(this.media),(e=chunk474VILDO_cjs.o.window)==null||e.removeEventListener("mouseup",this);}mediaSetCallback(e){}mediaUnsetCallback(e){Yi(this,ys,null);}handleEvent(e){switch(e.type){case "pointerdown":Yi(this,sa,e.timeStamp);break;case "pointermove":It(this,Ul,Xh).call(this,e);break;case "pointerup":It(this,$l,Zh).call(this,e);break;case "mouseleave":It(this,_r,ra).call(this);break;case "mouseup":this.removeAttribute(J.KEYBOARD_CONTROL);break;case "keyup":It(this,bs,Ir).call(this),this.setAttribute(J.KEYBOARD_CONTROL,"");break}}set autohide(e){let t=Number(e);Yi(this,Ss,isNaN(t)?0:t);}get autohide(){return (Et(this,Ss)===void 0?2:Et(this,Ss)).toString()}get breakpoints(){return chunk474VILDO_cjs.H(this,J.BREAKPOINTS)}set breakpoints(e){chunk474VILDO_cjs.I(this,J.BREAKPOINTS,e);}get audio(){return chunk474VILDO_cjs.F(this,J.AUDIO)}set audio(e){chunk474VILDO_cjs.G(this,J.AUDIO,e);}get gesturesDisabled(){return chunk474VILDO_cjs.F(this,J.GESTURES_DISABLED)}set gesturesDisabled(e){chunk474VILDO_cjs.G(this,J.GESTURES_DISABLED,e);}get keyboardControl(){return chunk474VILDO_cjs.F(this,J.KEYBOARD_CONTROL)}set keyboardControl(e){chunk474VILDO_cjs.G(this,J.KEYBOARD_CONTROL,e);}get noAutohide(){return chunk474VILDO_cjs.F(this,J.NO_AUTOHIDE)}set noAutohide(e){chunk474VILDO_cjs.G(this,J.NO_AUTOHIDE,e);}get autohideOverControls(){return chunk474VILDO_cjs.F(this,J.AUTOHIDE_OVER_CONTROLS)}set autohideOverControls(e){chunk474VILDO_cjs.G(this,J.AUTOHIDE_OVER_CONTROLS,e);}get userInteractive(){return chunk474VILDO_cjs.F(this,J.USER_INACTIVE)}set userInteractive(e){chunk474VILDO_cjs.G(this,J.USER_INACTIVE,e);}};sa=new WeakMap;ys=new WeakMap;Ar=new WeakMap;Ss=new WeakMap;ta=new WeakMap;Nl=new WeakSet;Qh=function(s){let e=this.media;for(let t of s){if(t.type!=="childList")continue;let i=t.removedNodes;for(let r of i){if(r.slot!="media"||t.target!=this)continue;let n=t.previousSibling&&t.previousSibling.previousElementSibling;if(!n||!e)this.mediaUnsetCallback(r);else {let a=n.slot!=="media";for(;(n=n.previousSibling)!==null;)n.slot=="media"&&(a=false);a&&this.mediaUnsetCallback(r);}}if(e)for(let r of t.addedNodes)r===e&&this.handleMediaUpdated(e);}};br=new WeakMap;ia=new WeakMap;Ul=new WeakSet;Xh=function(s){if(s.pointerType!=="mouse"&&s.timeStamp-Et(this,sa)<250)return;It(this,na,Gl).call(this),clearTimeout(Et(this,Ar));let e=this.hasAttribute(J.AUTOHIDE_OVER_CONTROLS);([this,this.media].includes(s.target)||e)&&It(this,bs,Ir).call(this);};$l=new WeakSet;Zh=function(s){if(s.pointerType==="touch"){let e=!this.hasAttribute(J.USER_INACTIVE);[this,this.media].includes(s.target)&&e?It(this,_r,ra).call(this):It(this,bs,Ir).call(this);}else s.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e?.localName))&&It(this,bs,Ir).call(this);};_r=new WeakSet;ra=function(){if(Et(this,Ss)<0||this.hasAttribute(J.USER_INACTIVE))return;this.setAttribute(J.USER_INACTIVE,"");let s=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.e.USER_INACTIVE_CHANGE,{composed:true,bubbles:true,detail:true});this.dispatchEvent(s);};na=new WeakSet;Gl=function(){if(!this.hasAttribute(J.USER_INACTIVE))return;this.removeAttribute(J.USER_INACTIVE);let s=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.e.USER_INACTIVE_CHANGE,{composed:true,bubbles:true,detail:false});this.dispatchEvent(s);};bs=new WeakSet;Ir=function(){It(this,na,Gl).call(this),clearTimeout(Et(this,Ar));let s=parseInt(this.autohide);s<0||Yi(this,Ar,setTimeout(()=>{It(this,_r,ra).call(this);},s*1e3));};qi.shadowRootOptions={mode:"open"};qi.getTemplateHTML=z0;chunk474VILDO_cjs.o.customElements.get("media-container")||chunk474VILDO_cjs.o.customElements.define("media-container",qi);var ef=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},qe=(s,e,t)=>(ef(s,e,"read from private field"),t?t.call(s):e.get(s)),Lr=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},aa=(s,e,t,i)=>(ef(s,e,"write to private field"),e.set(s,t),t),As,_s,oa,ji,Ei,Ri,ki=class{constructor(e,t,{defaultValue:i}={defaultValue:void 0}){Lr(this,Ei),Lr(this,As,void 0),Lr(this,_s,void 0),Lr(this,oa,void 0),Lr(this,ji,new Set),aa(this,As,e),aa(this,_s,t),aa(this,oa,new Set(i));}[Symbol.iterator](){return qe(this,Ei,Ri).values()}get length(){return qe(this,Ei,Ri).size}get value(){var e;return (e=[...qe(this,Ei,Ri)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(aa(this,ji,new Set),this.add(...(t=e?.split(" "))!=null?t:[]));}toString(){return this.value}item(e){return [...qe(this,Ei,Ri)][e]}values(){return qe(this,Ei,Ri).values()}forEach(e,t){qe(this,Ei,Ri).forEach(e,t);}add(...e){var t,i;e.forEach(r=>qe(this,ji).add(r)),!(this.value===""&&!((t=qe(this,As))!=null&&t.hasAttribute(`${qe(this,_s)}`)))&&((i=qe(this,As))==null||i.setAttribute(`${qe(this,_s)}`,`${this.value}`));}remove(...e){var t;e.forEach(i=>qe(this,ji).delete(i)),(t=qe(this,As))==null||t.setAttribute(`${qe(this,_s)}`,`${this.value}`);}contains(e){return qe(this,Ei,Ri).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}};As=new WeakMap;_s=new WeakMap;oa=new WeakMap;ji=new WeakMap;Ei=new WeakSet;Ri=function(){return qe(this,ji).size?qe(this,ji):qe(this,oa)};var sf=s=>{var e;let{media:t,fullscreenElement:i}=s;try{let r=i&&"requestFullscreen"in i?"requestFullscreen":i&&"webkitRequestFullScreen"in i?"webkitRequestFullScreen":void 0;if(r){let n=(e=i[r])==null?void 0:e.call(i);if(n instanceof Promise)return n.catch(()=>{})}else t?.webkitEnterFullscreen?t.webkitEnterFullscreen():t?.requestFullscreen&&t.requestFullscreen();}catch(r){console.error(r);}},tf="exitFullscreen"in chunk474VILDO_cjs.p?"exitFullscreen":"webkitExitFullscreen"in chunk474VILDO_cjs.p?"webkitExitFullscreen":"webkitCancelFullScreen"in chunk474VILDO_cjs.p?"webkitCancelFullScreen":void 0,rf=s=>{var e;let{documentElement:t}=s;if(tf){let i=(e=t?.[tf])==null?void 0:e.call(t);if(i instanceof Promise)return i.catch(()=>{})}},xr="fullscreenElement"in chunk474VILDO_cjs.p?"fullscreenElement":"webkitFullscreenElement"in chunk474VILDO_cjs.p?"webkitFullscreenElement":void 0,tE=s=>{let{documentElement:e,media:t}=s,i=e?.[xr];return !i&&"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t&&t.webkitDisplayingFullscreen&&t.webkitPresentationMode===chunk474VILDO_cjs.l.FULLSCREEN?t:i},nf=s=>{var e;let{media:t,documentElement:i,fullscreenElement:r=t}=s;if(!t||!i)return false;let n=tE(s);if(!n)return false;if(n===r||n===t)return true;if(n.localName.includes("-")){let a=n.shadowRoot;if(!(xr in a))return chunk474VILDO_cjs.v(n,r);for(;a?.[xr];){if(a[xr]===r)return true;a=(e=a[xr])==null?void 0:e.shadowRoot;}}return false},iE="fullscreenEnabled"in chunk474VILDO_cjs.p?"fullscreenEnabled":"webkitFullscreenEnabled"in chunk474VILDO_cjs.p?"webkitFullscreenEnabled":void 0,af=s=>{let{documentElement:e,media:t}=s;return !!e?.[iE]||t&&"webkitSupportsFullscreen"in t};var la,Hl=()=>{var s,e;return la||(la=(e=(s=chunk474VILDO_cjs.p)==null?void 0:s.createElement)==null?void 0:e.call(s,"video"),la)},of=async(s=Hl())=>{if(!s)return false;let e=s.volume;s.volume=e/2+.1;let t=new AbortController,i=await Promise.race([sE(s,t.signal),rE(s,e)]);return t.abort(),i},sE=(s,e)=>new Promise(t=>{s.addEventListener("volumechange",()=>t(true),{signal:e});}),rE=async(s,e)=>{for(let t=0;t<10;t++){if(s.volume===e)return false;await Zn(10);}return s.volume!==e},nE=/.*Version\/.*Safari\/.*/.test(chunk474VILDO_cjs.o.navigator.userAgent),Kl=(s=Hl())=>chunk474VILDO_cjs.o.matchMedia("(display-mode: standalone)").matches&&nE?false:typeof s?.requestPictureInPicture=="function",Vl=(s=Hl())=>af({documentElement:chunk474VILDO_cjs.p,media:s}),lf=Vl(),df=Kl(),cf=!!chunk474VILDO_cjs.o.WebKitPlaybackTargetAvailabilityEvent,uf=!!chunk474VILDO_cjs.o.chrome;var Is=s=>chunk3BAQWQNY_cjs.f(s.media,e=>[chunk474VILDO_cjs.g.SUBTITLES,chunk474VILDO_cjs.g.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),Wl=s=>chunk3BAQWQNY_cjs.f(s.media,e=>e.mode===chunk474VILDO_cjs.h.SHOWING&&[chunk474VILDO_cjs.g.SUBTITLES,chunk474VILDO_cjs.g.CAPTIONS].includes(e.kind)),da=(s,e)=>{let t=Is(s),i=Wl(s),r=!!i.length;if(t.length){if(e===false||r&&e!==true)chunk3BAQWQNY_cjs.e(chunk474VILDO_cjs.h.DISABLED,t,i);else if(e===true||!r&&e!==false){let n=t[0],{options:a}=s;if(!a?.noSubtitlesLangPref){let c=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),u=c?[c,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>u.some(m=>f.language.toLowerCase().startsWith(m.split("-")[0]))).sort((f,m)=>{let g=u.findIndex(v=>f.language.toLowerCase().startsWith(v.split("-")[0])),E=u.findIndex(v=>m.language.toLowerCase().startsWith(v.split("-")[0]));return g-E});h[0]&&(n=h[0]);}let{language:o,label:d,kind:l}=n;chunk3BAQWQNY_cjs.e(chunk474VILDO_cjs.h.DISABLED,t,i),chunk3BAQWQNY_cjs.e(chunk474VILDO_cjs.h.SHOWING,t,[{language:o,label:d,kind:l}]);}}},ca=(s,e)=>s===e?true:s==null||e==null||typeof s!=typeof e?false:typeof s=="number"&&Number.isNaN(s)&&Number.isNaN(e)?true:typeof s!="object"?false:Array.isArray(s)?aE(s,e):Object.entries(s).every(([t,i])=>t in e&&ca(i,e[t])),aE=(s,e)=>{let t=Array.isArray(s),i=Array.isArray(e);return t!==i?false:t||i?s.length!==e.length?false:s.every((r,n)=>ca(r,e[n])):true};var oE=Object.values(chunk474VILDO_cjs.k),ua,lE=of().then(s=>(ua=s,ua)),hf=async(...s)=>{await Promise.all(s.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof chunk474VILDO_cjs.o.HTMLElement))return;let t=e.localName;if(!t.includes("-"))return;let i=chunk474VILDO_cjs.o.customElements.get(t);i&&e instanceof i||(await chunk474VILDO_cjs.o.customElements.whenDefined(t),chunk474VILDO_cjs.o.customElements.upgrade(e));}));},dE=new chunk474VILDO_cjs.o.DOMParser,cE=s=>s&&(dE.parseFromString(s,"text/html").body.textContent||s),Ls={mediaError:{get(s,e){let{media:t}=s;if(e?.type!=="playing")return t?.error},mediaEvents:["emptied","error","playing"]},mediaErrorCode:{get(s,e){var t;let{media:i}=s;if(e?.type!=="playing")return (t=i?.error)==null?void 0:t.code},mediaEvents:["emptied","error","playing"]},mediaErrorMessage:{get(s,e){var t,i;let{media:r}=s;if(e?.type!=="playing")return (i=(t=r?.error)==null?void 0:t.message)!=null?i:""},mediaEvents:["emptied","error","playing"]},mediaWidth:{get(s){var e;let{media:t}=s;return (e=t?.videoWidth)!=null?e:0},mediaEvents:["resize"]},mediaHeight:{get(s){var e;let{media:t}=s;return (e=t?.videoHeight)!=null?e:0},mediaEvents:["resize"]},mediaPaused:{get(s){var e;let{media:t}=s;return (e=t?.paused)!=null?e:true},set(s,e){var t;let{media:i}=e;i&&(s?i.pause():(t=i.play())==null||t.catch(()=>{}));},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(s,e){let{media:t}=s;return t?e?e.type==="playing":!t.paused:false},mediaEvents:["playing","emptied"]},mediaEnded:{get(s){var e;let{media:t}=s;return (e=t?.ended)!=null?e:false},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(s){var e;let{media:t}=s;return (e=t?.playbackRate)!=null?e:1},set(s,e){let{media:t}=e;t&&Number.isFinite(+s)&&(t.playbackRate=+s);},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(s){var e;let{media:t}=s;return (e=t?.muted)!=null?e:false},set(s,e){let{media:t,options:{noMutedPref:i}={}}=e;if(t){t.muted=s;try{let r=chunk474VILDO_cjs.o.localStorage.getItem("media-chrome-pref-muted")!==null,n=t.hasAttribute("muted");if(i){r&&chunk474VILDO_cjs.o.localStorage.removeItem("media-chrome-pref-muted");return}if(n&&!r)return;chunk474VILDO_cjs.o.localStorage.setItem("media-chrome-pref-muted",s?"true":"false");}catch(r){console.debug("Error setting muted pref",r);}}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(s,e)=>{let{options:{noMutedPref:t}}=e,{media:i}=e;if(!(!i||i.muted||t))try{let r=chunk474VILDO_cjs.o.localStorage.getItem("media-chrome-pref-muted")==="true";Ls.mediaMuted.set(r,e),s(r);}catch(r){console.debug("Error getting muted pref",r);}}]},mediaLoop:{get(s){let{media:e}=s;return e?.loop},set(s,e){let{media:t}=e;t&&(t.loop=s);},mediaEvents:["medialooprequest"]},mediaVolume:{get(s){var e;let{media:t}=s;return (e=t?.volume)!=null?e:1},set(s,e){let{media:t,options:{noVolumePref:i}={}}=e;if(t){try{s==null?chunk474VILDO_cjs.o.localStorage.removeItem("media-chrome-pref-volume"):!t.hasAttribute("muted")&&!i&&chunk474VILDO_cjs.o.localStorage.setItem("media-chrome-pref-volume",s.toString());}catch(r){console.debug("Error setting volume pref",r);}Number.isFinite(+s)&&(t.volume=+s);}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(s,e)=>{let{options:{noVolumePref:t}}=e;if(!t)try{let{media:i}=e;if(!i)return;let r=chunk474VILDO_cjs.o.localStorage.getItem("media-chrome-pref-volume");if(r==null)return;Ls.mediaVolume.set(+r,e),s(+r);}catch(i){console.debug("Error getting volume pref",i);}}]},mediaVolumeLevel:{get(s){let{media:e}=s;return typeof e?.volume>"u"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(s){var e;let{media:t}=s;return (e=t?.currentTime)!=null?e:0},set(s,e){let{media:t}=e;!t||!vs(s)||(t.currentTime=s);},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(s){let{media:e,options:{defaultDuration:t}={}}=s;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e?.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(s){let{media:e}=s;return e?.readyState<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(s){var e;let{media:t}=s;if(!((e=t?.seekable)!=null&&e.length))return;let i=t.seekable.start(0),r=t.seekable.end(t.seekable.length-1);if(!(!i&&!r))return [Number(i.toFixed(3)),Number(r.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(s){var e;let{media:t}=s,i=(e=t?.buffered)!=null?e:[];return Array.from(i).map((r,n)=>[Number(i.start(n).toFixed(3)),Number(i.end(n).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(s){let{media:e,options:{defaultStreamType:t}={}}=s,i=[chunk474VILDO_cjs.k.LIVE,chunk474VILDO_cjs.k.ON_DEMAND].includes(t)?t:void 0;if(!e)return i;let{streamType:r}=e;if(oE.includes(r))return r===chunk474VILDO_cjs.k.UNKNOWN?i:r;let n=e.duration;return n===1/0?chunk474VILDO_cjs.k.LIVE:Number.isFinite(n)?chunk474VILDO_cjs.k.ON_DEMAND:i},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(s){let{media:e}=s;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,i=Ls.mediaStreamType.get(s);return (t==null||Number.isNaN(t))&&i===chunk474VILDO_cjs.k.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(s){let{media:e,options:{liveEdgeOffset:t=10}={}}=s;if(!e)return false;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?false:e.currentTime>=e.liveEdgeStart;if(!(Ls.mediaStreamType.get(s)===chunk474VILDO_cjs.k.LIVE))return false;let r=e.seekable;if(!r)return true;if(!r.length)return false;let n=r.end(r.length-1)-t;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(s){return Is(s).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(s){return Wl(s).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(s,e)=>{var t,i;let{media:r,options:n}=e;if(!r)return;let a=o=>{var d;!n.defaultSubtitles||o&&![chunk474VILDO_cjs.g.CAPTIONS,chunk474VILDO_cjs.g.SUBTITLES].includes((d=o?.track)==null?void 0:d.kind)||da(e,true);};return r.addEventListener("loadstart",a),(t=r.textTracks)==null||t.addEventListener("addtrack",a),(i=r.textTracks)==null||i.addEventListener("removetrack",a),()=>{var o,d;r.removeEventListener("loadstart",a),(o=r.textTracks)==null||o.removeEventListener("addtrack",a),(d=r.textTracks)==null||d.removeEventListener("removetrack",a);}}]},mediaChaptersCues:{get(s){var e;let{media:t}=s;if(!t)return [];let[i]=chunk3BAQWQNY_cjs.f(t,{kind:chunk474VILDO_cjs.g.CHAPTERS});return Array.from((e=i?.cues)!=null?e:[]).map(({text:r,startTime:n,endTime:a})=>({text:cE(r),startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(s,e)=>{var t;let{media:i}=e;if(!i)return;let r=i.querySelector('track[kind="chapters"][default][src]'),n=(t=i.shadowRoot)==null?void 0:t.querySelector(':is(video,audio) > track[kind="chapters"][default][src]');return r?.addEventListener("load",s),n?.addEventListener("load",s),()=>{r?.removeEventListener("load",s),n?.removeEventListener("load",s);}}]},mediaIsPip:{get(s){var e,t;let{media:i,documentElement:r}=s;if(!i||!r||!r.pictureInPictureElement)return false;if(r.pictureInPictureElement===i)return true;if(r.pictureInPictureElement instanceof HTMLMediaElement)return (e=i.localName)!=null&&e.includes("-")?chunk474VILDO_cjs.v(i,r.pictureInPictureElement):false;if(r.pictureInPictureElement.localName.includes("-")){let n=r.pictureInPictureElement.shadowRoot;for(;n?.pictureInPictureElement;){if(n.pictureInPictureElement===i)return true;n=(t=n.pictureInPictureElement)==null?void 0:t.shadowRoot;}}return false},set(s,e){let{media:t}=e;if(t)if(s){if(!chunk474VILDO_cjs.p.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!t.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}let i=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.");};t.requestPictureInPicture().catch(r=>{if(r.code===11){if(!t.src){console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");return}if(t.readyState===0&&t.preload==="none"){let n=()=>{t.removeEventListener("loadedmetadata",a),t.preload="none";},a=()=>{t.requestPictureInPicture().catch(i),n();};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&i(),n();},1e3);}else throw r}else throw r});}else chunk474VILDO_cjs.p.pictureInPictureElement&&chunk474VILDO_cjs.p.exitPictureInPicture();},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(s){var e;let{media:t}=s;return [...(e=t?.videoRenditions)!=null?e:[]].map(i=>({...i}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(s){var e,t,i;let{media:r}=s;return (i=(t=r?.videoRenditions)==null?void 0:t[(e=r.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:i.id},set(s,e){let{media:t}=e;if(!t?.videoRenditions){console.warn("MediaController: Rendition selection not supported by this media.");return}let i=s,r=Array.prototype.findIndex.call(t.videoRenditions,n=>n.id==i);t.videoRenditions.selectedIndex!=r&&(t.videoRenditions.selectedIndex=r);},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(s){var e;let{media:t}=s;return [...(e=t?.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(s){var e,t;let{media:i}=s;return (t=[...(e=i?.audioTracks)!=null?e:[]].find(r=>r.enabled))==null?void 0:t.id},set(s,e){let{media:t}=e;if(!t?.audioTracks){console.warn("MediaChrome: Audio track selection not supported by this media.");return}let i=s;for(let r of t.audioTracks)r.enabled=i==r.id;},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(s){return nf(s)},set(s,e,t){var i;s?(sf(e),t.detail&&((i=e.media)==null||i.focus())):rf(e);},rootEvents:["fullscreenchange","webkitfullscreenchange"],mediaEvents:["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"]},mediaIsCasting:{get(s){var e;let{media:t}=s;return !t?.remote||((e=t.remote)==null?void 0:e.state)==="disconnected"?false:!!t.remote.state},set(s,e){var t,i;let{media:r}=e;if(r&&!(s&&((t=r.remote)==null?void 0:t.state)!=="disconnected")&&!(!s&&((i=r.remote)==null?void 0:i.state)!=="connected")){if(typeof r.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}r.remote.prompt().catch(()=>{});}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return false},set(s,e){let{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&chunk474VILDO_cjs.o.WebKitPlaybackTargetAvailabilityEvent)){console.error("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker();}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(s){let{media:e}=s;if(!lf||!Vl(e))return chunk474VILDO_cjs.j.UNSUPPORTED}},mediaPipUnavailable:{get(s){let{media:e}=s;if(!df||!Kl(e))return chunk474VILDO_cjs.j.UNSUPPORTED;if(e?.disablePictureInPicture)return chunk474VILDO_cjs.j.UNAVAILABLE}},mediaVolumeUnavailable:{get(s){let{media:e}=s;if(ua===false||e?.volume==null)return chunk474VILDO_cjs.j.UNSUPPORTED},stateOwnersUpdateHandlers:[s=>{ua==null&&lE.then(e=>s(e?void 0:chunk474VILDO_cjs.j.UNSUPPORTED));}]},mediaCastUnavailable:{get(s,{availability:e="not-available"}={}){var t;let{media:i}=s;if(!uf||!((t=i?.remote)!=null&&t.state))return chunk474VILDO_cjs.j.UNSUPPORTED;if(!(e==null||e==="available"))return chunk474VILDO_cjs.j.UNAVAILABLE},stateOwnersUpdateHandlers:[(s,e)=>{var t;let{media:i}=e;return i?(i.disableRemotePlayback||i.hasAttribute("disableremoteplayback")||(t=i?.remote)==null||t.watchAvailability(n=>{s({availability:n?"available":"not-available"});}).catch(n=>{n.name==="NotSupportedError"?s({availability:null}):s({availability:"not-available"});}),()=>{var n;(n=i?.remote)==null||n.cancelWatchAvailability().catch(()=>{});}):void 0}]},mediaAirplayUnavailable:{get(s,e){if(!cf)return chunk474VILDO_cjs.j.UNSUPPORTED;if(e?.availability==="not-available")return chunk474VILDO_cjs.j.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(s,e)=>{var t;let{media:i}=e;return i?(i.disableRemotePlayback||i.hasAttribute("disableremoteplayback")||(t=i?.remote)==null||t.watchAvailability(n=>{s({availability:n?"available":"not-available"});}).catch(n=>{n.name==="NotSupportedError"?s({availability:null}):s({availability:"not-available"});}),()=>{var n;(n=i?.remote)==null||n.cancelWatchAvailability().catch(()=>{});}):void 0}]},mediaRenditionUnavailable:{get(s){var e;let{media:t}=s;if(!t?.videoRenditions)return chunk474VILDO_cjs.j.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return chunk474VILDO_cjs.j.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(s){var e,t;let{media:i}=s;if(!i?.audioTracks)return chunk474VILDO_cjs.j.UNSUPPORTED;if(((t=(e=i.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return chunk474VILDO_cjs.j.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaLang:{get(s){let{options:{mediaLang:e}={}}=s;return e??"en"}}};var ff={[chunk474VILDO_cjs.a.MEDIA_PREVIEW_REQUEST](s,e,{detail:t}){var i,r,n;let{media:a}=e,o=t??void 0,d,l;if(a&&o!=null){let[f]=chunk3BAQWQNY_cjs.f(a,{kind:chunk474VILDO_cjs.g.METADATA,label:"thumbnails"}),m=Array.prototype.find.call((i=f?.cues)!=null?i:[],(g,E,v)=>E===0?g.endTime>o:E===v.length-1?g.startTime<=o:g.startTime<=o&&g.endTime>o);if(m){let g=/'^(?:[a-z]+:)?\/\//i.test(m.text)||(r=a?.querySelector('track[label="thumbnails"]'))==null?void 0:r.src,E=new URL(m.text,g);l=new URLSearchParams(E.hash).get("#xywh").split(",").map(T=>+T),d=E.href;}}let c=s.mediaDuration.get(e),h=(n=s.mediaChaptersCues.get(e).find((f,m,g)=>m===g.length-1&&c===f.endTime?f.startTime<=o&&f.endTime>=o:f.startTime<=o&&f.endTime>o))==null?void 0:n.text;return t!=null&&h==null&&(h=""),{mediaPreviewTime:o,mediaPreviewImage:d,mediaPreviewCoords:l,mediaPreviewChapter:h}},[chunk474VILDO_cjs.a.MEDIA_PAUSE_REQUEST](s,e){s["mediaPaused"].set(true,e);},[chunk474VILDO_cjs.a.MEDIA_PLAY_REQUEST](s,e){var t,i,r,n;let a="mediaPaused",d=s.mediaStreamType.get(e)===chunk474VILDO_cjs.k.LIVE,l=!((t=e.options)!=null&&t.noAutoSeekToLive),c=s.mediaTargetLiveWindow.get(e)>0;if(d&&l&&!c){let u=(i=s.mediaSeekable.get(e))==null?void 0:i[1];if(u){let h=(n=(r=e.options)==null?void 0:r.seekToLiveOffset)!=null?n:0,f=u-h;s.mediaCurrentTime.set(f,e);}}s[a].set(false,e);},[chunk474VILDO_cjs.a.MEDIA_PLAYBACK_RATE_REQUEST](s,e,{detail:t}){let i="mediaPlaybackRate",r=t;s[i].set(r,e);},[chunk474VILDO_cjs.a.MEDIA_MUTE_REQUEST](s,e){s["mediaMuted"].set(true,e);},[chunk474VILDO_cjs.a.MEDIA_UNMUTE_REQUEST](s,e){let t="mediaMuted";s.mediaVolume.get(e)||s.mediaVolume.set(.25,e),s[t].set(false,e);},[chunk474VILDO_cjs.a.MEDIA_LOOP_REQUEST](s,e,{detail:t}){let i="mediaLoop",r=!!t;return s[i].set(r,e),{mediaLoop:r}},[chunk474VILDO_cjs.a.MEDIA_VOLUME_REQUEST](s,e,{detail:t}){let i="mediaVolume",r=t;r&&s.mediaMuted.get(e)&&s.mediaMuted.set(false,e),s[i].set(r,e);},[chunk474VILDO_cjs.a.MEDIA_SEEK_REQUEST](s,e,{detail:t}){let i="mediaCurrentTime",r=t;s[i].set(r,e);},[chunk474VILDO_cjs.a.MEDIA_SEEK_TO_LIVE_REQUEST](s,e){var t,i,r;let n="mediaCurrentTime",a=(t=s.mediaSeekable.get(e))==null?void 0:t[1];if(Number.isNaN(Number(a)))return;let o=(r=(i=e.options)==null?void 0:i.seekToLiveOffset)!=null?r:0,d=a-o;s[n].set(d,e);},[chunk474VILDO_cjs.a.MEDIA_SHOW_SUBTITLES_REQUEST](s,e,{detail:t}){var i;let{options:r}=e,n=Is(e),a=chunk3BAQWQNY_cjs.b(t),o=(i=a[0])==null?void 0:i.language;o&&!r.noSubtitlesLangPref&&chunk474VILDO_cjs.o.localStorage.setItem("media-chrome-pref-subtitles-lang",o),chunk3BAQWQNY_cjs.e(chunk474VILDO_cjs.h.SHOWING,n,a);},[chunk474VILDO_cjs.a.MEDIA_DISABLE_SUBTITLES_REQUEST](s,e,{detail:t}){let i=Is(e),r=t??[];chunk3BAQWQNY_cjs.e(chunk474VILDO_cjs.h.DISABLED,i,r);},[chunk474VILDO_cjs.a.MEDIA_TOGGLE_SUBTITLES_REQUEST](s,e,{detail:t}){da(e,t);},[chunk474VILDO_cjs.a.MEDIA_RENDITION_REQUEST](s,e,{detail:t}){let i="mediaRenditionSelected",r=t;s[i].set(r,e);},[chunk474VILDO_cjs.a.MEDIA_AUDIO_TRACK_REQUEST](s,e,{detail:t}){let i="mediaAudioTrackEnabled",r=t;s[i].set(r,e);},[chunk474VILDO_cjs.a.MEDIA_ENTER_PIP_REQUEST](s,e){let t="mediaIsPip";s.mediaIsFullscreen.get(e)&&s.mediaIsFullscreen.set(false,e),s[t].set(true,e);},[chunk474VILDO_cjs.a.MEDIA_EXIT_PIP_REQUEST](s,e){s["mediaIsPip"].set(false,e);},[chunk474VILDO_cjs.a.MEDIA_ENTER_FULLSCREEN_REQUEST](s,e,t){let i="mediaIsFullscreen";s.mediaIsPip.get(e)&&s.mediaIsPip.set(false,e),s[i].set(true,e,t);},[chunk474VILDO_cjs.a.MEDIA_EXIT_FULLSCREEN_REQUEST](s,e){s["mediaIsFullscreen"].set(false,e);},[chunk474VILDO_cjs.a.MEDIA_ENTER_CAST_REQUEST](s,e){let t="mediaIsCasting";s.mediaIsFullscreen.get(e)&&s.mediaIsFullscreen.set(false,e),s[t].set(true,e);},[chunk474VILDO_cjs.a.MEDIA_EXIT_CAST_REQUEST](s,e){s["mediaIsCasting"].set(false,e);},[chunk474VILDO_cjs.a.MEDIA_AIRPLAY_REQUEST](s,e){s["mediaIsAirplaying"].set(true,e);}};var mf=({media:s,fullscreenElement:e,documentElement:t,stateMediator:i=Ls,requestMap:r=ff,options:n={},monitorStateOwnersOnlyWithSubscriptions:a=true})=>{let o=[],d={options:{...n}},l=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0}),c=g=>{g!=null&&(ca(g,l)||(l=Object.freeze({...l,...g}),o.forEach(E=>E(l))));},u=()=>{let g=Object.entries(i).reduce((E,[v,{get:T}])=>(E[v]=T(d),E),{});c(g);},h={},f,m=async(g,E)=>{var v,T,S,b,_,D,I,k,R,L,w,B,K,z,V,F;let q=!!f;if(f={...d,...f??{},...g},q)return;await hf(...Object.values(g));let G=o.length>0&&E===0&&a,j=d.media!==f.media,X=((v=d.media)==null?void 0:v.textTracks)!==((T=f.media)==null?void 0:T.textTracks),U=((S=d.media)==null?void 0:S.videoRenditions)!==((b=f.media)==null?void 0:b.videoRenditions),$=((_=d.media)==null?void 0:_.audioTracks)!==((D=f.media)==null?void 0:D.audioTracks),se=((I=d.media)==null?void 0:I.remote)!==((k=f.media)==null?void 0:k.remote),Ee=d.documentElement!==f.documentElement,re=!!d.media&&(j||G),ce=!!((R=d.media)!=null&&R.textTracks)&&(X||G),Ge=!!((L=d.media)!=null&&L.videoRenditions)&&(U||G),Ne=!!((w=d.media)!=null&&w.audioTracks)&&($||G),st=!!((B=d.media)!=null&&B.remote)&&(se||G),ft=!!d.documentElement&&(Ee||G),Ct=re||ce||Ge||Ne||st||ft,_i=o.length===0&&E===1&&a,gs=!!f.media&&(j||_i),ps=!!((K=f.media)!=null&&K.textTracks)&&(X||_i),wl=!!((z=f.media)!=null&&z.videoRenditions)&&(U||_i),fe=!!((V=f.media)!=null&&V.audioTracks)&&($||_i),He=!!((F=f.media)!=null&&F.remote)&&(se||_i),rt=!!f.documentElement&&(Ee||_i),Vt=gs||ps||wl||fe||He||rt;if(!(Ct||Vt)){Object.entries(f).forEach(([me,mt])=>{d[me]=mt;}),u(),f=void 0;return}Object.entries(i).forEach(([me,{get:mt,mediaEvents:Un=[],textTracksEvents:Es=[],videoRenditionsEvents:$n=[],audioTracksEvents:Gi=[],remoteEvents:Bn=[],rootEvents:Pl=[],stateOwnersUpdateHandlers:Gn=[]}])=>{h[me]||(h[me]={});let et=xe=>{let Ue=mt(d,xe);c({[me]:Ue});},Le;Le=h[me].mediaEvents,Un.forEach(xe=>{Le&&re&&(d.media.removeEventListener(xe,Le),h[me].mediaEvents=void 0),gs&&(f.media.addEventListener(xe,et),h[me].mediaEvents=et);}),Le=h[me].textTracksEvents,Es.forEach(xe=>{var Ue,Mt;Le&&ce&&((Ue=d.media.textTracks)==null||Ue.removeEventListener(xe,Le),h[me].textTracksEvents=void 0),ps&&((Mt=f.media.textTracks)==null||Mt.addEventListener(xe,et),h[me].textTracksEvents=et);}),Le=h[me].videoRenditionsEvents,$n.forEach(xe=>{var Ue,Mt;Le&&Ge&&((Ue=d.media.videoRenditions)==null||Ue.removeEventListener(xe,Le),h[me].videoRenditionsEvents=void 0),wl&&((Mt=f.media.videoRenditions)==null||Mt.addEventListener(xe,et),h[me].videoRenditionsEvents=et);}),Le=h[me].audioTracksEvents,Gi.forEach(xe=>{var Ue,Mt;Le&&Ne&&((Ue=d.media.audioTracks)==null||Ue.removeEventListener(xe,Le),h[me].audioTracksEvents=void 0),fe&&((Mt=f.media.audioTracks)==null||Mt.addEventListener(xe,et),h[me].audioTracksEvents=et);}),Le=h[me].remoteEvents,Bn.forEach(xe=>{var Ue,Mt;Le&&st&&((Ue=d.media.remote)==null||Ue.removeEventListener(xe,Le),h[me].remoteEvents=void 0),He&&((Mt=f.media.remote)==null||Mt.addEventListener(xe,et),h[me].remoteEvents=et);}),Le=h[me].rootEvents,Pl.forEach(xe=>{Le&&ft&&(d.documentElement.removeEventListener(xe,Le),h[me].rootEvents=void 0),rt&&(f.documentElement.addEventListener(xe,et),h[me].rootEvents=et);});let Hn=h[me].stateOwnersUpdateHandlers;if(Hn&&Ct&&(Array.isArray(Hn)?Hn:[Hn]).forEach(Ue=>{typeof Ue=="function"&&Ue();}),Vt){let xe=Gn.map(Ue=>Ue(et,f)).filter(Ue=>typeof Ue=="function");h[me].stateOwnersUpdateHandlers=xe.length===1?xe[0]:xe;}else Ct&&(h[me].stateOwnersUpdateHandlers=void 0);}),Object.entries(f).forEach(([me,mt])=>{d[me]=mt;}),u(),f=void 0;};return m({media:s,fullscreenElement:e,documentElement:t,options:n}),{dispatch(g){let{type:E,detail:v}=g;if(r[E]&&l.mediaErrorCode==null){c(r[E](i,d,g));return}E==="mediaelementchangerequest"?m({media:v}):E==="fullscreenelementchangerequest"?m({fullscreenElement:v}):E==="documentelementchangerequest"?m({documentElement:v}):E==="optionschangerequest"&&(Object.entries(v??{}).forEach(([T,S])=>{d.options[T]=S;}),u());},getState(){return l},subscribe(g){return m({},o.length+1),o.push(g),g(l),()=>{let E=o.indexOf(g);E>=0&&(m({},o.length-1),o.splice(E,1));}}}};var Xl=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Z=(s,e,t)=>(Xl(s,e,"read from private field"),t?t.call(s):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);},qt=(s,e,t,i)=>(Xl(s,e,"write to private field"),e.set(s,t),t),zt=(s,e,t)=>(Xl(s,e,"access private method"),t),Di,Rr,pe,Qi,kr,jt,ha,Dr,fa,Yl,Xi,xs,ma,ql,jl,Sf,bf=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Enter"," ","f","m","k","c","l","j",">","<","p"],gf=10,pf=.025,Ef=.25,uE=.25,hE=2,N={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYBOARD_BACKWARD_SEEK_OFFSET:"keyboardbackwardseekoffset",KEYBOARD_FORWARD_SEEK_OFFSET:"keyboardforwardseekoffset",KEYBOARD_DOWN_VOLUME_STEP:"keyboarddownvolumestep",KEYBOARD_UP_VOLUME_STEP:"keyboardupvolumestep",KEYS_USED:"keysused",LANG:"lang",LOOP:"loop",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_DEFAULT_STORE:"nodefaultstore",NO_HOTKEYS:"nohotkeys",NO_MUTED_PREF:"nomutedpref",NO_SUBTITLES_LANG_PREF:"nosubtitleslangpref",NO_VOLUME_PREF:"novolumepref",SEEK_TO_LIVE_OFFSET:"seektoliveoffset"},zl=class extends qi{constructor(){super(),Lt(this,fa),Lt(this,Xi),Lt(this,ma),Lt(this,jl),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,Lt(this,Di,new ki(this,N.HOTKEYS)),Lt(this,Rr,void 0),Lt(this,pe,void 0),Lt(this,Qi,null),Lt(this,kr,void 0),Lt(this,jt,void 0),Lt(this,ha,t=>{var i;(i=Z(this,pe))==null||i.dispatch(t);}),Lt(this,Dr,void 0),this.associateElement(this);let e={};qt(this,kr,t=>{Object.entries(t).forEach(([i,r])=>{if(i in e&&e[i]===r)return;this.propagateMediaState(i,r);let n=i.toLowerCase(),a=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.f[n],{composed:true,detail:r});this.dispatchEvent(a);}),e=t;}),this.hasAttribute(N.NO_HOTKEYS)?this.disableHotkeys():this.enableHotkeys();}static get observedAttributes(){return super.observedAttributes.concat(N.NO_HOTKEYS,N.HOTKEYS,N.DEFAULT_STREAM_TYPE,N.DEFAULT_SUBTITLES,N.DEFAULT_DURATION,N.NO_MUTED_PREF,N.NO_VOLUME_PREF,N.LANG,N.LOOP)}get mediaStore(){return Z(this,pe)}set mediaStore(e){var t,i;if(Z(this,pe)&&((t=Z(this,jt))==null||t.call(this),qt(this,jt,void 0)),qt(this,pe,e),!Z(this,pe)&&!this.hasAttribute(N.NO_DEFAULT_STORE)){zt(this,fa,Yl).call(this);return}qt(this,jt,(i=Z(this,pe))==null?void 0:i.subscribe(Z(this,kr)));}get fullscreenElement(){var e;return (e=Z(this,Rr))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(N.FULLSCREEN_ELEMENT)&&this.removeAttribute(N.FULLSCREEN_ELEMENT),qt(this,Rr,e),(t=Z(this,pe))==null||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement});}get defaultSubtitles(){return chunk474VILDO_cjs.F(this,N.DEFAULT_SUBTITLES)}set defaultSubtitles(e){chunk474VILDO_cjs.G(this,N.DEFAULT_SUBTITLES,e);}get defaultStreamType(){return chunk474VILDO_cjs.H(this,N.DEFAULT_STREAM_TYPE)}set defaultStreamType(e){chunk474VILDO_cjs.I(this,N.DEFAULT_STREAM_TYPE,e);}get defaultDuration(){return chunk474VILDO_cjs.D(this,N.DEFAULT_DURATION)}set defaultDuration(e){chunk474VILDO_cjs.E(this,N.DEFAULT_DURATION,e);}get noHotkeys(){return chunk474VILDO_cjs.F(this,N.NO_HOTKEYS)}set noHotkeys(e){chunk474VILDO_cjs.G(this,N.NO_HOTKEYS,e);}get keysUsed(){return chunk474VILDO_cjs.H(this,N.KEYS_USED)}set keysUsed(e){chunk474VILDO_cjs.I(this,N.KEYS_USED,e);}get liveEdgeOffset(){return chunk474VILDO_cjs.D(this,N.LIVE_EDGE_OFFSET)}set liveEdgeOffset(e){chunk474VILDO_cjs.E(this,N.LIVE_EDGE_OFFSET,e);}get noAutoSeekToLive(){return chunk474VILDO_cjs.F(this,N.NO_AUTO_SEEK_TO_LIVE)}set noAutoSeekToLive(e){chunk474VILDO_cjs.G(this,N.NO_AUTO_SEEK_TO_LIVE,e);}get noVolumePref(){return chunk474VILDO_cjs.F(this,N.NO_VOLUME_PREF)}set noVolumePref(e){chunk474VILDO_cjs.G(this,N.NO_VOLUME_PREF,e);}get noMutedPref(){return chunk474VILDO_cjs.F(this,N.NO_MUTED_PREF)}set noMutedPref(e){chunk474VILDO_cjs.G(this,N.NO_MUTED_PREF,e);}get noSubtitlesLangPref(){return chunk474VILDO_cjs.F(this,N.NO_SUBTITLES_LANG_PREF)}set noSubtitlesLangPref(e){chunk474VILDO_cjs.G(this,N.NO_SUBTITLES_LANG_PREF,e);}get noDefaultStore(){return chunk474VILDO_cjs.F(this,N.NO_DEFAULT_STORE)}set noDefaultStore(e){chunk474VILDO_cjs.G(this,N.NO_DEFAULT_STORE,e);}attributeChangedCallback(e,t,i){var r,n,a,o,d,l,c,u,h,f,m,g;if(super.attributeChangedCallback(e,t,i),e===N.NO_HOTKEYS)i!==t&&i===""?(this.hasAttribute(N.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===N.HOTKEYS)Z(this,Di).value=i;else if(e===N.DEFAULT_SUBTITLES&&i!==t)(r=Z(this,pe))==null||r.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(N.DEFAULT_SUBTITLES)}});else if(e===N.DEFAULT_STREAM_TYPE)(a=Z(this,pe))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(n=this.getAttribute(N.DEFAULT_STREAM_TYPE))!=null?n:void 0}});else if(e===N.LIVE_EDGE_OFFSET)(o=Z(this,pe))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(N.LIVE_EDGE_OFFSET)?+this.getAttribute(N.LIVE_EDGE_OFFSET):void 0,seekToLiveOffset:this.hasAttribute(N.SEEK_TO_LIVE_OFFSET)?void 0:+this.getAttribute(N.LIVE_EDGE_OFFSET)}});else if(e===N.SEEK_TO_LIVE_OFFSET)(d=Z(this,pe))==null||d.dispatch({type:"optionschangerequest",detail:{seekToLiveOffset:this.hasAttribute(N.SEEK_TO_LIVE_OFFSET)?+this.getAttribute(N.SEEK_TO_LIVE_OFFSET):void 0}});else if(e===N.NO_AUTO_SEEK_TO_LIVE)(l=Z(this,pe))==null||l.dispatch({type:"optionschangerequest",detail:{noAutoSeekToLive:this.hasAttribute(N.NO_AUTO_SEEK_TO_LIVE)}});else if(e===N.FULLSCREEN_ELEMENT){let E=i?(c=this.getRootNode())==null?void 0:c.getElementById(i):void 0;qt(this,Rr,E),(u=Z(this,pe))==null||u.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement});}else e===N.LANG&&i!==t?(chunk474VILDO_cjs.m(i),(h=Z(this,pe))==null||h.dispatch({type:"optionschangerequest",detail:{mediaLang:i}})):e===N.LOOP&&i!==t?(f=Z(this,pe))==null||f.dispatch({type:chunk474VILDO_cjs.a.MEDIA_LOOP_REQUEST,detail:i!=null}):e===N.NO_VOLUME_PREF&&i!==t?(m=Z(this,pe))==null||m.dispatch({type:"optionschangerequest",detail:{noVolumePref:this.hasAttribute(N.NO_VOLUME_PREF)}}):e===N.NO_MUTED_PREF&&i!==t&&((g=Z(this,pe))==null||g.dispatch({type:"optionschangerequest",detail:{noMutedPref:this.hasAttribute(N.NO_MUTED_PREF)}}));}connectedCallback(){var e,t;!Z(this,pe)&&!this.hasAttribute(N.NO_DEFAULT_STORE)&&zt(this,fa,Yl).call(this),(e=Z(this,pe))==null||e.dispatch({type:"documentelementchangerequest",detail:chunk474VILDO_cjs.p}),super.connectedCallback(),Z(this,pe)&&!Z(this,jt)&&qt(this,jt,(t=Z(this,pe))==null?void 0:t.subscribe(Z(this,kr))),Z(this,Dr)!==void 0&&Z(this,pe)&&this.media&&setTimeout(()=>{var i,r,n;(r=(i=this.media)==null?void 0:i.textTracks)!=null&&r.length&&((n=Z(this,pe))==null||n.dispatch({type:chunk474VILDO_cjs.a.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:Z(this,Dr)}));},0),this.hasAttribute(N.NO_HOTKEYS)?this.disableHotkeys():this.enableHotkeys();}disconnectedCallback(){var e,t,i,r,n;if((e=super.disconnectedCallback)==null||e.call(this),Z(this,pe)){let a=Z(this,pe).getState();qt(this,Dr,!!((t=a.mediaSubtitlesShowing)!=null&&t.length)),(i=Z(this,pe))==null||i.dispatch({type:"documentelementchangerequest",detail:void 0}),(r=Z(this,pe))==null||r.dispatch({type:chunk474VILDO_cjs.a.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:false});}Z(this,jt)&&((n=Z(this,jt))==null||n.call(this),qt(this,jt,void 0));}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=Z(this,pe))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1);}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=Z(this,pe))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0});}propagateMediaState(e,t){yf(this.mediaStateReceivers,e,t);}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let i=this.registerMediaStateReceiver.bind(this),r=this.unregisterMediaStateReceiver.bind(this),n=vE(e,i,r);Object.values(chunk474VILDO_cjs.a).forEach(a=>{e.addEventListener(a,Z(this,ha));}),t.set(e,n);}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.values(chunk474VILDO_cjs.a).forEach(r=>{e.removeEventListener(r,Z(this,ha));});}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),Z(this,pe)&&Object.entries(Z(this,pe).getState()).forEach(([r,n])=>{yf([e],r,n);}));}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,i=t.indexOf(e);i<0||t.splice(i,1);}enableHotkeys(){this.addEventListener("keydown",zt(this,ma,ql));}disableHotkeys(){this.removeEventListener("keydown",zt(this,ma,ql)),this.removeEventListener("keyup",zt(this,Xi,xs));}get hotkeys(){return chunk474VILDO_cjs.H(this,N.HOTKEYS)}set hotkeys(e){chunk474VILDO_cjs.I(this,N.HOTKEYS,e);}keyboardShortcutHandler(e){var t,i,r,n,a,o,d,l,c;let u=e.target;if(((r=(i=(t=u.getAttribute(N.KEYS_USED))==null?void 0:t.split(" "))!=null?i:u?.keysUsed)!=null?r:[]).map(v=>v==="Space"?" ":v).filter(Boolean).includes(e.key))return;let f,m,g;if(!(Z(this,Di).contains(`no${e.key.toLowerCase()}`)||e.key===" "&&Z(this,Di).contains("nospace")||e.shiftKey&&(e.key==="/"||e.key==="?")&&Z(this,Di).contains("noshift+/")))switch(e.key){case " ":case "k":f=Z(this,pe).getState().mediaPaused?chunk474VILDO_cjs.a.MEDIA_PLAY_REQUEST:chunk474VILDO_cjs.a.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(f,{composed:true,bubbles:true}));break;case "m":f=this.mediaStore.getState().mediaVolumeLevel==="off"?chunk474VILDO_cjs.a.MEDIA_UNMUTE_REQUEST:chunk474VILDO_cjs.a.MEDIA_MUTE_REQUEST,this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(f,{composed:true,bubbles:true}));break;case "f":f=this.mediaStore.getState().mediaIsFullscreen?chunk474VILDO_cjs.a.MEDIA_EXIT_FULLSCREEN_REQUEST:chunk474VILDO_cjs.a.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(f,{composed:true,bubbles:true}));break;case "c":this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:true,bubbles:true}));break;case "ArrowLeft":case "j":{let v=this.hasAttribute(N.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(N.KEYBOARD_BACKWARD_SEEK_OFFSET):gf;m=Math.max(((n=this.mediaStore.getState().mediaCurrentTime)!=null?n:0)-v,0),g=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:m}),this.dispatchEvent(g);break}case "ArrowRight":case "l":{let v=this.hasAttribute(N.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(N.KEYBOARD_FORWARD_SEEK_OFFSET):gf;m=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)+v,0),g=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:m}),this.dispatchEvent(g);break}case "ArrowUp":{let v=this.hasAttribute(N.KEYBOARD_UP_VOLUME_STEP)?+this.getAttribute(N.KEYBOARD_UP_VOLUME_STEP):pf;m=Math.min(((o=this.mediaStore.getState().mediaVolume)!=null?o:1)+v,1),g=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_VOLUME_REQUEST,{composed:true,bubbles:true,detail:m}),this.dispatchEvent(g);break}case "ArrowDown":{let v=this.hasAttribute(N.KEYBOARD_DOWN_VOLUME_STEP)?+this.getAttribute(N.KEYBOARD_DOWN_VOLUME_STEP):pf;m=Math.max(((d=this.mediaStore.getState().mediaVolume)!=null?d:1)-v,0),g=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_VOLUME_REQUEST,{composed:true,bubbles:true,detail:m}),this.dispatchEvent(g);break}case "<":{let v=(l=this.mediaStore.getState().mediaPlaybackRate)!=null?l:1;m=Math.max(v-Ef,uE).toFixed(2),g=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_PLAYBACK_RATE_REQUEST,{composed:true,bubbles:true,detail:m}),this.dispatchEvent(g);break}case ">":{let v=(c=this.mediaStore.getState().mediaPlaybackRate)!=null?c:1;m=Math.min(v+Ef,hE).toFixed(2),g=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_PLAYBACK_RATE_REQUEST,{composed:true,bubbles:true,detail:m}),this.dispatchEvent(g);break}case "/":case "?":{e.shiftKey&&zt(this,jl,Sf).call(this);break}case "p":{f=this.mediaStore.getState().mediaIsPip?chunk474VILDO_cjs.a.MEDIA_EXIT_PIP_REQUEST:chunk474VILDO_cjs.a.MEDIA_ENTER_PIP_REQUEST,g=new chunk474VILDO_cjs.o.CustomEvent(f,{composed:true,bubbles:true}),this.dispatchEvent(g);break}}}};Di=new WeakMap;Rr=new WeakMap;pe=new WeakMap;Qi=new WeakMap;kr=new WeakMap;jt=new WeakMap;ha=new WeakMap;Dr=new WeakMap;fa=new WeakSet;Yl=function(){var s;this.mediaStore=mf({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(N.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(N.DEFAULT_DURATION)?+this.getAttribute(N.DEFAULT_DURATION):void 0,defaultStreamType:(s=this.getAttribute(N.DEFAULT_STREAM_TYPE))!=null?s:void 0,liveEdgeOffset:this.hasAttribute(N.LIVE_EDGE_OFFSET)?+this.getAttribute(N.LIVE_EDGE_OFFSET):void 0,seekToLiveOffset:this.hasAttribute(N.SEEK_TO_LIVE_OFFSET)?+this.getAttribute(N.SEEK_TO_LIVE_OFFSET):this.hasAttribute(N.LIVE_EDGE_OFFSET)?+this.getAttribute(N.LIVE_EDGE_OFFSET):void 0,noAutoSeekToLive:this.hasAttribute(N.NO_AUTO_SEEK_TO_LIVE),noVolumePref:this.hasAttribute(N.NO_VOLUME_PREF),noMutedPref:this.hasAttribute(N.NO_MUTED_PREF),noSubtitlesLangPref:this.hasAttribute(N.NO_SUBTITLES_LANG_PREF)}});};Xi=new WeakSet;xs=function(s){let{key:e,shiftKey:t}=s;if(!(t&&(e==="/"||e==="?")||bf.includes(e))){this.removeEventListener("keyup",zt(this,Xi,xs));return}this.keyboardShortcutHandler(s);};ma=new WeakSet;ql=function(s){var e;let{metaKey:t,altKey:i,key:r,shiftKey:n}=s,a=n&&(r==="/"||r==="?");if(a&&((e=Z(this,Qi))!=null&&e.open)){this.removeEventListener("keyup",zt(this,Xi,xs));return}if(t||i||!a&&!bf.includes(r)){this.removeEventListener("keyup",zt(this,Xi,xs));return}let o=s.target,d=o instanceof HTMLElement&&(o.tagName.toLowerCase()==="media-volume-range"||o.tagName.toLowerCase()==="media-time-range");[" ","ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(r)&&!(Z(this,Di).contains(`no${r.toLowerCase()}`)||r===" "&&Z(this,Di).contains("nospace"))&&!d&&s.preventDefault(),this.addEventListener("keyup",zt(this,Xi,xs),{once:true});};jl=new WeakSet;Sf=function(){Z(this,Qi)||(qt(this,Qi,chunk474VILDO_cjs.p.createElement("media-keyboard-shortcuts-dialog")),this.appendChild(Z(this,Qi))),Z(this,Qi).open=true;};var fE=Object.values(chunk474VILDO_cjs.d),mE=Object.values(chunk474VILDO_cjs.c),Af=s=>{var e,t,i,r;let{observedAttributes:n}=s.constructor;!n&&((e=s.nodeName)!=null&&e.includes("-"))&&(chunk474VILDO_cjs.o.customElements.upgrade(s),{observedAttributes:n}=s.constructor);let a=(r=(i=(t=s?.getAttribute)==null?void 0:t.call(s,chunk474VILDO_cjs.b.MEDIA_CHROME_ATTRIBUTES))==null?void 0:i.split)==null?void 0:r.call(i,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>fE.includes(o)):[]},gE=s=>{var e,t;return (e=s.nodeName)!=null&&e.includes("-")&&chunk474VILDO_cjs.o.customElements.get((t=s.nodeName)==null?void 0:t.toLowerCase())&&!(s instanceof chunk474VILDO_cjs.o.customElements.get(s.nodeName.toLowerCase()))&&chunk474VILDO_cjs.o.customElements.upgrade(s),mE.some(i=>i in s)},Ql=s=>gE(s)||!!Af(s).length,vf=s=>{var e;return (e=s?.join)==null?void 0:e.call(s,":")},Tf={[chunk474VILDO_cjs.d.MEDIA_SUBTITLES_LIST]:chunk3BAQWQNY_cjs.d,[chunk474VILDO_cjs.d.MEDIA_SUBTITLES_SHOWING]:chunk3BAQWQNY_cjs.d,[chunk474VILDO_cjs.d.MEDIA_SEEKABLE]:vf,[chunk474VILDO_cjs.d.MEDIA_BUFFERED]:s=>s?.map(vf).join(" "),[chunk474VILDO_cjs.d.MEDIA_PREVIEW_COORDS]:s=>s?.join(" "),[chunk474VILDO_cjs.d.MEDIA_RENDITION_LIST]:Vh,[chunk474VILDO_cjs.d.MEDIA_AUDIO_TRACK_LIST]:Yh},pE=async(s,e,t)=>{var i,r;if(s.isConnected||await Zn(0),typeof t=="boolean"||t==null)return chunk474VILDO_cjs.G(s,e,t);if(typeof t=="number")return chunk474VILDO_cjs.E(s,e,t);if(typeof t=="string")return chunk474VILDO_cjs.I(s,e,t);if(Array.isArray(t)&&!t.length)return s.removeAttribute(e);let n=(r=(i=Tf[e])==null?void 0:i.call(Tf,t))!=null?r:t;return s.setAttribute(e,n)},EE=s=>{var e;return !!((e=s.closest)!=null&&e.call(s,'*[slot="media"]'))},zi=(s,e)=>{if(EE(s))return;let t=(r,n)=>{var a,o;Ql(r)&&n(r);let{children:d=[]}=r??{},l=(o=(a=r?.shadowRoot)==null?void 0:a.children)!=null?o:[];[...d,...l].forEach(u=>zi(u,n));},i=s?.nodeName.toLowerCase();if(i.includes("-")&&!Ql(s)){chunk474VILDO_cjs.o.customElements.whenDefined(i).then(()=>{t(s,e);});return}t(s,e);},yf=(s,e,t)=>{s.forEach(i=>{if(e in i){i[e]=t;return}let r=Af(i),n=e.toLowerCase();r.includes(n)&&pE(i,n,t);});},vE=(s,e,t)=>{zi(s,e);let i=c=>{var u;let h=(u=c?.composedPath()[0])!=null?u:c.target;e(h);},r=c=>{var u;let h=(u=c?.composedPath()[0])!=null?u:c.target;t(h);};s.addEventListener(chunk474VILDO_cjs.a.REGISTER_MEDIA_STATE_RECEIVER,i),s.addEventListener(chunk474VILDO_cjs.a.UNREGISTER_MEDIA_STATE_RECEIVER,r);let n=c=>{c.forEach(u=>{let{addedNodes:h=[],removedNodes:f=[],type:m,target:g,attributeName:E}=u;m==="childList"?(Array.prototype.forEach.call(h,v=>zi(v,e)),Array.prototype.forEach.call(f,v=>zi(v,t))):m==="attributes"&&E===chunk474VILDO_cjs.b.MEDIA_CHROME_ATTRIBUTES&&(Ql(g)?e(g):t(g));});},a=[],o=c=>{let u=c.target;u.name!=="media"&&(a.forEach(h=>zi(h,t)),a=[...u.assignedElements({flatten:true})],a.forEach(h=>zi(h,e)));};s.addEventListener("slotchange",o);let d=new MutationObserver(n);return d.observe(s,{childList:true,attributes:true,subtree:true}),()=>{zi(s,t),s.removeEventListener("slotchange",o),d.disconnect(),s.removeEventListener(chunk474VILDO_cjs.a.REGISTER_MEDIA_STATE_RECEIVER,i),s.removeEventListener(chunk474VILDO_cjs.a.UNREGISTER_MEDIA_STATE_RECEIVER,r);}};chunk474VILDO_cjs.o.customElements.get("media-controller")||chunk474VILDO_cjs.o.customElements.define("media-controller",zl);var _f=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
160
160
|
<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"/>
|
|
161
161
|
</svg>
|
|
162
|
-
`;function
|
|
162
|
+
`;function TE(s){return `
|
|
163
163
|
<style>
|
|
164
|
-
:host([${
|
|
164
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_IS_AIRPLAYING}]) slot[name=icon] slot:not([name=exit]) {
|
|
165
165
|
display: none !important;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
|
|
169
|
-
:host(:not([${
|
|
169
|
+
:host(:not([${chunk474VILDO_cjs.d.MEDIA_IS_AIRPLAYING}])) slot[name=icon] slot:not([name=enter]) {
|
|
170
170
|
display: none !important;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
:host([${
|
|
174
|
-
:host(:not([${
|
|
173
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_IS_AIRPLAYING}]) slot[name=tooltip-enter],
|
|
174
|
+
:host(:not([${chunk474VILDO_cjs.d.MEDIA_IS_AIRPLAYING}])) slot[name=tooltip-exit] {
|
|
175
175
|
display: none;
|
|
176
176
|
}
|
|
177
177
|
</style>
|
|
178
178
|
|
|
179
179
|
<slot name="icon">
|
|
180
|
-
<slot name="enter">${
|
|
181
|
-
<slot name="exit">${
|
|
180
|
+
<slot name="enter">${_f}</slot>
|
|
181
|
+
<slot name="exit">${_f}</slot>
|
|
182
182
|
</slot>
|
|
183
|
-
`}function
|
|
184
|
-
<slot name="tooltip-enter">${
|
|
185
|
-
<slot name="tooltip-exit">${
|
|
186
|
-
`}var
|
|
183
|
+
`}function yE(){return `
|
|
184
|
+
<slot name="tooltip-enter">${chunk474VILDO_cjs.n("start airplay")}</slot>
|
|
185
|
+
<slot name="tooltip-exit">${chunk474VILDO_cjs.n("stop airplay")}</slot>
|
|
186
|
+
`}var If=s=>{let e=s.mediaIsAirplaying?chunk474VILDO_cjs.n("stop airplay"):chunk474VILDO_cjs.n("start airplay");s.setAttribute("aria-label",e);},Cr=class extends chunk474VILDO_cjs.J{static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_IS_AIRPLAYING,chunk474VILDO_cjs.d.MEDIA_AIRPLAY_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),If(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunk474VILDO_cjs.d.MEDIA_IS_AIRPLAYING&&If(this);}get mediaIsAirplaying(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_IS_AIRPLAYING,e);}get mediaAirplayUnavailable(){return chunk474VILDO_cjs.H(this,chunk474VILDO_cjs.d.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){chunk474VILDO_cjs.I(this,chunk474VILDO_cjs.d.MEDIA_AIRPLAY_UNAVAILABLE,e);}handleClick(){let e=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_AIRPLAY_REQUEST,{composed:true,bubbles:true});this.dispatchEvent(e);}};Cr.getSlotTemplateHTML=TE;Cr.getTooltipContentHTML=yE;chunk474VILDO_cjs.o.customElements.get("media-airplay-button")||chunk474VILDO_cjs.o.customElements.define("media-airplay-button",Cr);var SE=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
187
187
|
<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"/>
|
|
188
|
-
</svg>`,
|
|
188
|
+
</svg>`,bE=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
189
189
|
<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"/>
|
|
190
|
-
</svg>`;function
|
|
190
|
+
</svg>`;function AE(s){return `
|
|
191
191
|
<style>
|
|
192
192
|
:host([aria-checked="true"]) slot[name=off] {
|
|
193
193
|
display: none !important;
|
|
@@ -205,37 +205,37 @@
|
|
|
205
205
|
</style>
|
|
206
206
|
|
|
207
207
|
<slot name="icon">
|
|
208
|
-
<slot name="on">${
|
|
209
|
-
<slot name="off">${
|
|
208
|
+
<slot name="on">${SE}</slot>
|
|
209
|
+
<slot name="off">${bE}</slot>
|
|
210
210
|
</slot>
|
|
211
|
-
`}function
|
|
212
|
-
<slot name="tooltip-enable">${
|
|
213
|
-
<slot name="tooltip-disable">${
|
|
214
|
-
`}var
|
|
211
|
+
`}function _E(){return `
|
|
212
|
+
<slot name="tooltip-enable">${chunk474VILDO_cjs.n("Enable captions")}</slot>
|
|
213
|
+
<slot name="tooltip-disable">${chunk474VILDO_cjs.n("Disable captions")}</slot>
|
|
214
|
+
`}var Lf=s=>{s.setAttribute("aria-checked",chunk3BAQWQNY_cjs.g(s).toString());},Mr=class extends chunk474VILDO_cjs.J{static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_SUBTITLES_LIST,chunk474VILDO_cjs.d.MEDIA_SUBTITLES_SHOWING]}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",chunk474VILDO_cjs.n("closed captions")),Lf(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunk474VILDO_cjs.d.MEDIA_SUBTITLES_SHOWING&&Lf(this);}get mediaSubtitlesList(){return xf(this,chunk474VILDO_cjs.d.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Rf(this,chunk474VILDO_cjs.d.MEDIA_SUBTITLES_LIST,e);}get mediaSubtitlesShowing(){return xf(this,chunk474VILDO_cjs.d.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Rf(this,chunk474VILDO_cjs.d.MEDIA_SUBTITLES_SHOWING,e);}handleClick(){this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:true,bubbles:true}));}};Mr.getSlotTemplateHTML=AE;Mr.getTooltipContentHTML=_E;var xf=(s,e)=>{let t=s.getAttribute(e);return t?chunk3BAQWQNY_cjs.a(t):[]},Rf=(s,e,t)=>{if(!t?.length){s.removeAttribute(e);return}let i=chunk3BAQWQNY_cjs.d(t);s.getAttribute(e)!==i&&s.setAttribute(e,i);};chunk474VILDO_cjs.o.customElements.get("media-captions-button")||chunk474VILDO_cjs.o.customElements.define("media-captions-button",Mr);var IE='<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>',LE='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>';function xE(s){return `
|
|
215
215
|
<style>
|
|
216
|
-
:host([${
|
|
216
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_IS_CASTING}]) slot[name=icon] slot:not([name=exit]) {
|
|
217
217
|
display: none !important;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
|
|
221
|
-
:host(:not([${
|
|
221
|
+
:host(:not([${chunk474VILDO_cjs.d.MEDIA_IS_CASTING}])) slot[name=icon] slot:not([name=enter]) {
|
|
222
222
|
display: none !important;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
:host([${
|
|
226
|
-
:host(:not([${
|
|
225
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_IS_CASTING}]) slot[name=tooltip-enter],
|
|
226
|
+
:host(:not([${chunk474VILDO_cjs.d.MEDIA_IS_CASTING}])) slot[name=tooltip-exit] {
|
|
227
227
|
display: none;
|
|
228
228
|
}
|
|
229
229
|
</style>
|
|
230
230
|
|
|
231
231
|
<slot name="icon">
|
|
232
|
-
<slot name="enter">${
|
|
233
|
-
<slot name="exit">${
|
|
232
|
+
<slot name="enter">${IE}</slot>
|
|
233
|
+
<slot name="exit">${LE}</slot>
|
|
234
234
|
</slot>
|
|
235
|
-
`}function
|
|
236
|
-
<slot name="tooltip-enter">${
|
|
237
|
-
<slot name="tooltip-exit">${
|
|
238
|
-
`}var
|
|
235
|
+
`}function RE(){return `
|
|
236
|
+
<slot name="tooltip-enter">${chunk474VILDO_cjs.n("Start casting")}</slot>
|
|
237
|
+
<slot name="tooltip-exit">${chunk474VILDO_cjs.n("Stop casting")}</slot>
|
|
238
|
+
`}var kf=s=>{let e=s.mediaIsCasting?chunk474VILDO_cjs.n("stop casting"):chunk474VILDO_cjs.n("start casting");s.setAttribute("aria-label",e);},wr=class extends chunk474VILDO_cjs.J{static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_IS_CASTING,chunk474VILDO_cjs.d.MEDIA_CAST_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),kf(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunk474VILDO_cjs.d.MEDIA_IS_CASTING&&kf(this);}get mediaIsCasting(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_IS_CASTING)}set mediaIsCasting(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_IS_CASTING,e);}get mediaCastUnavailable(){return chunk474VILDO_cjs.H(this,chunk474VILDO_cjs.d.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){chunk474VILDO_cjs.I(this,chunk474VILDO_cjs.d.MEDIA_CAST_UNAVAILABLE,e);}handleClick(){let e=this.mediaIsCasting?chunk474VILDO_cjs.a.MEDIA_EXIT_CAST_REQUEST:chunk474VILDO_cjs.a.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(e,{composed:true,bubbles:true}));}};wr.getSlotTemplateHTML=xE;wr.getTooltipContentHTML=RE;chunk474VILDO_cjs.o.customElements.get("media-cast-button")||chunk474VILDO_cjs.o.customElements.define("media-cast-button",wr);var rd=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Ji=(s,e,t)=>(rd(s,e,"read from private field"),e.get(s)),vi=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},nd=(s,e,t,i)=>(rd(s,e,"write to private field"),e.set(s,t),t),Zi=(s,e,t)=>(rd(s,e,"access private method"),t),pa,Or,es,ga,Zl,Jl,Df,ed,Cf,td,Mf,id,wf,sd,Pf;function kE(s){return `
|
|
239
239
|
<style>
|
|
240
240
|
:host {
|
|
241
241
|
font: var(--media-font,
|
|
@@ -276,9 +276,9 @@
|
|
|
276
276
|
}
|
|
277
277
|
</style>
|
|
278
278
|
${this.getSlotTemplateHTML(s)}
|
|
279
|
-
`}function
|
|
279
|
+
`}function DE(s){return `
|
|
280
280
|
<slot id="content"></slot>
|
|
281
|
-
`}var
|
|
281
|
+
`}var Pr={OPEN:"open",ANCHOR:"anchor"},Qt=class extends chunk474VILDO_cjs.o.HTMLElement{constructor(){super(),vi(this,ga),vi(this,Jl),vi(this,ed),vi(this,td),vi(this,id),vi(this,sd),vi(this,pa,false),vi(this,Or,null),vi(this,es,null),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this);}static get observedAttributes(){return [Pr.OPEN,Pr.ANCHOR]}get open(){return chunk474VILDO_cjs.F(this,Pr.OPEN)}set open(e){chunk474VILDO_cjs.G(this,Pr.OPEN,e);}handleEvent(e){switch(e.type){case "invoke":Zi(this,td,Mf).call(this,e);break;case "focusout":Zi(this,id,wf).call(this,e);break;case "keydown":Zi(this,sd,Pf).call(this,e);break}}connectedCallback(){Zi(this,ga,Zl).call(this),this.role||(this.role="dialog");}attributeChangedCallback(e,t,i){Zi(this,ga,Zl).call(this),e===Pr.OPEN&&i!==t&&(this.open?Zi(this,Jl,Df).call(this):Zi(this,ed,Cf).call(this));}focus(){nd(this,Or,chunk474VILDO_cjs.x());let e=!this.dispatchEvent(new Event("focus",{composed:true,cancelable:true})),t=!this.dispatchEvent(new Event("focusin",{composed:true,bubbles:true,cancelable:true}));if(e||t)return;let i=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');i?.focus();}get keysUsed(){return ["Escape","Tab"]}};pa=new WeakMap;Or=new WeakMap;es=new WeakMap;ga=new WeakSet;Zl=function(){if(!Ji(this,pa)&&(nd(this,pa,true),!this.shadowRoot)){this.attachShadow(this.constructor.shadowRootOptions);let s=chunk474VILDO_cjs.q(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(s),queueMicrotask(()=>{let{style:e}=chunk474VILDO_cjs.B(this.shadowRoot,":host");e.setProperty("transition","display .15s, visibility .15s, opacity .15s ease-in, transform .15s ease-in");});}};Jl=new WeakSet;Df=function(){var s;(s=Ji(this,es))==null||s.setAttribute("aria-expanded","true"),this.dispatchEvent(new Event("open",{composed:true,bubbles:true})),this.addEventListener("transitionend",()=>this.focus(),{once:true});};ed=new WeakSet;Cf=function(){var s;(s=Ji(this,es))==null||s.setAttribute("aria-expanded","false"),this.dispatchEvent(new Event("close",{composed:true,bubbles:true}));};td=new WeakSet;Mf=function(s){nd(this,es,s.relatedTarget),chunk474VILDO_cjs.v(this,s.relatedTarget)||(this.open=!this.open);};id=new WeakSet;wf=function(s){var e;chunk474VILDO_cjs.v(this,s.relatedTarget)||((e=Ji(this,Or))==null||e.focus(),Ji(this,es)&&Ji(this,es)!==s.relatedTarget&&this.open&&(this.open=false));};sd=new WeakSet;Pf=function(s){var e,t,i,r,n;let{key:a,ctrlKey:o,altKey:d,metaKey:l}=s;o||d||l||this.keysUsed.includes(a)&&(s.preventDefault(),s.stopPropagation(),a==="Tab"?(s.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(r=(i=this.nextElementSibling)==null?void 0:i.focus)==null||r.call(i),this.blur()):a==="Escape"&&((n=Ji(this,Or))==null||n.focus(),this.open=false));};Qt.shadowRootOptions={mode:"open"};Qt.getTemplateHTML=kE;Qt.getSlotTemplateHTML=DE;chunk474VILDO_cjs.o.customElements.get("media-chrome-dialog")||chunk474VILDO_cjs.o.customElements.define("media-chrome-dialog",Qt);var hd=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ke=(s,e,t)=>(hd(s,e,"read from private field"),t?t.call(s):e.get(s)),Xe=(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);},Ci=(s,e,t,i)=>(hd(s,e,"write to private field"),e.set(s,t),t),Ut=(s,e,t)=>(hd(s,e,"access private method"),t),Xt,La,Ea,va,$t,_a,Ta,ya,Sa,fd,Of,ba,ad,Aa,od,Ia,md,ld,Ff,dd,Nf,cd,Uf,ud,$f;function CE(s){return `
|
|
282
282
|
<style>
|
|
283
283
|
:host {
|
|
284
284
|
--_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
|
|
@@ -508,7 +508,7 @@
|
|
|
508
508
|
${this.getContainerTemplateHTML(s)}
|
|
509
509
|
</div>
|
|
510
510
|
<div id="rightgap"></div>
|
|
511
|
-
`}function
|
|
511
|
+
`}function ME(s){return ""}var Zt=class extends chunk474VILDO_cjs.o.HTMLElement{constructor(){if(super(),Xe(this,fd),Xe(this,ba),Xe(this,Aa),Xe(this,Ia),Xe(this,ld),Xe(this,dd),Xe(this,cd),Xe(this,ud),Xe(this,Xt,void 0),Xe(this,La,void 0),Xe(this,Ea,void 0),Xe(this,va,void 0),Xe(this,$t,{}),Xe(this,_a,[]),Xe(this,Ta,()=>{if(this.range.matches(":focus-visible")){let{style:e}=chunk474VILDO_cjs.B(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)");}}),Xe(this,ya,()=>{let{style:e}=chunk474VILDO_cjs.B(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow");}),Xe(this,Sa,()=>{let e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e);}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=chunk474VILDO_cjs.q(this.attributes),t=this.constructor.getTemplateHTML(e);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(t):this.shadowRoot.innerHTML=t;}this.container=this.shadowRoot.querySelector("#container"),Ci(this,Ea,this.shadowRoot.querySelector("#startpoint")),Ci(this,va,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance");}static get observedAttributes(){return ["disabled","aria-disabled",chunk474VILDO_cjs.b.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,n,a,o,d;e===chunk474VILDO_cjs.b.MEDIA_CONTROLLER?(t&&((n=(r=ke(this,Xt))==null?void 0:r.unassociateElement)==null||n.call(r,this),Ci(this,Xt,null)),i&&this.isConnected&&(Ci(this,Xt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=ke(this,Xt))==null?void 0:o.associateElement)==null||d.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==i)&&(i==null?(this.range.removeAttribute(e),Ut(this,ba,ad).call(this)):(this.range.setAttribute(e,i),Ut(this,Aa,od).call(this)));}connectedCallback(){var e,t,i;let{style:r}=chunk474VILDO_cjs.B(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),ke(this,$t).pointer=chunk474VILDO_cjs.B(this.shadowRoot,"#pointer"),ke(this,$t).progress=chunk474VILDO_cjs.B(this.shadowRoot,"#progress"),ke(this,$t).thumb=chunk474VILDO_cjs.B(this.shadowRoot,'#thumb, ::slotted([slot="thumb"])'),ke(this,$t).activeSegment=chunk474VILDO_cjs.B(this.shadowRoot,"#segments-clipping rect:nth-child(0)");let n=this.getAttribute(chunk474VILDO_cjs.b.MEDIA_CONTROLLER);n&&(Ci(this,Xt,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=ke(this,Xt))==null?void 0:t.associateElement)==null||i.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",ke(this,Ta)),this.shadowRoot.addEventListener("focusout",ke(this,ya)),Ut(this,ba,ad).call(this),chunkLVGLIRQU_cjs.a(this.container,ke(this,Sa));}disconnectedCallback(){var e,t;Ut(this,Aa,od).call(this),(t=(e=ke(this,Xt))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ci(this,Xt,null),this.shadowRoot.removeEventListener("focusin",ke(this,Ta)),this.shadowRoot.removeEventListener("focusout",ke(this,ya)),chunkLVGLIRQU_cjs.b(this.container,ke(this,Sa));}updatePointerBar(e){var t;(t=ke(this,$t).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`);}updateBar(){var e,t;let i=this.range.valueAsNumber*100;(e=ke(this,$t).progress)==null||e.style.setProperty("width",`${i}%`),(t=ke(this,$t).thumb)==null||t.style.setProperty("left",`${i}%`);}updateSegments(e){let t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!e?.length),!e?.length)return;let i=[...new Set([+this.range.min,...e.flatMap(n=>[n.start,n.end]),+this.range.max])];Ci(this,_a,[...i]);let r=i.pop();for(let[n,a]of i.entries()){let[o,d]=[n===0,n===i.length-1],l=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,u=`calc(${((d?r:i[n+1])-a)*100}%${o||d?"":" - var(--segments-gap)"})`,h=chunk474VILDO_cjs.p.createElementNS("http://www.w3.org/2000/svg","rect"),f=chunk474VILDO_cjs.C(this.shadowRoot,`#segments-clipping rect:nth-child(${n+1})`);f.style.setProperty("x",l),f.style.setProperty("width",u),t.append(h);}}getPointerRatio(e){return chunk474VILDO_cjs.A(e.clientX,e.clientY,ke(this,Ea).getBoundingClientRect(),ke(this,va).getBoundingClientRect())}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case "pointermove":Ut(this,ud,$f).call(this,e);break;case "input":this.updateBar();break;case "pointerenter":Ut(this,ld,Ff).call(this,e);break;case "pointerdown":Ut(this,Ia,md).call(this,e);break;case "pointerup":Ut(this,dd,Nf).call(this);break;case "pointerleave":Ut(this,cd,Uf).call(this);break}}get keysUsed(){return ["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};Xt=new WeakMap;La=new WeakMap;Ea=new WeakMap;va=new WeakMap;$t=new WeakMap;_a=new WeakMap;Ta=new WeakMap;ya=new WeakMap;Sa=new WeakMap;fd=new WeakSet;Of=function(s){let e=ke(this,$t).activeSegment;if(!e)return;let t=this.getPointerRatio(s),r=`#segments-clipping rect:nth-child(${ke(this,_a).findIndex((n,a,o)=>{let d=o[a+1];return d!=null&&t>=n&&t<=d})+1})`;(e.selectorText!=r||!e.style.transform)&&(e.selectorText=r,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"));};ba=new WeakSet;ad=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this));};Aa=new WeakSet;od=function(){var s,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(s=chunk474VILDO_cjs.o.window)==null||s.removeEventListener("pointerup",this),(e=chunk474VILDO_cjs.o.window)==null||e.removeEventListener("pointermove",this);};Ia=new WeakSet;md=function(s){var e;Ci(this,La,s.composedPath().includes(this.range)),(e=chunk474VILDO_cjs.o.window)==null||e.addEventListener("pointerup",this);};ld=new WeakSet;Ff=function(s){var e;s.pointerType!=="mouse"&&Ut(this,Ia,md).call(this,s),this.addEventListener("pointerleave",this),(e=chunk474VILDO_cjs.o.window)==null||e.addEventListener("pointermove",this);};dd=new WeakSet;Nf=function(){var s;(s=chunk474VILDO_cjs.o.window)==null||s.removeEventListener("pointerup",this),this.toggleAttribute("dragging",false),this.range.disabled=this.hasAttribute("disabled");};cd=new WeakSet;Uf=function(){var s,e;this.removeEventListener("pointerleave",this),(s=chunk474VILDO_cjs.o.window)==null||s.removeEventListener("pointermove",this),this.toggleAttribute("dragging",false),this.range.disabled=this.hasAttribute("disabled"),(e=ke(this,$t).activeSegment)==null||e.style.removeProperty("transform");};ud=new WeakSet;$f=function(s){s.pointerType==="pen"&&s.buttons===0||(this.toggleAttribute("dragging",s.buttons===1||s.pointerType!=="mouse"),this.updatePointerBar(s),Ut(this,fd,Of).call(this,s),this.dragging&&(s.pointerType!=="mouse"||!ke(this,La))&&(this.range.disabled=true,this.range.valueAsNumber=this.getPointerRatio(s),this.range.dispatchEvent(new Event("input",{bubbles:true,composed:true}))));};Zt.shadowRootOptions={mode:"open"};Zt.getTemplateHTML=CE;Zt.getContainerTemplateHTML=ME;chunk474VILDO_cjs.o.customElements.get("media-chrome-range")||chunk474VILDO_cjs.o.customElements.define("media-chrome-range",Zt);var Bf=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},xa=(s,e,t)=>(Bf(s,e,"read from private field"),t?t.call(s):e.get(s)),wE=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Ra=(s,e,t,i)=>(Bf(s,e,"write to private field"),e.set(s,t),t),Jt;function PE(s){return `
|
|
512
512
|
<style>
|
|
513
513
|
:host {
|
|
514
514
|
|
|
@@ -534,7 +534,7 @@
|
|
|
534
534
|
</style>
|
|
535
535
|
|
|
536
536
|
<slot></slot>
|
|
537
|
-
`}var
|
|
537
|
+
`}var Fr=class extends chunk474VILDO_cjs.o.HTMLElement{constructor(){if(super(),wE(this,Jt,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=chunk474VILDO_cjs.q(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}}static get observedAttributes(){return [chunk474VILDO_cjs.b.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,n,a,o,d;e===chunk474VILDO_cjs.b.MEDIA_CONTROLLER&&(t&&((n=(r=xa(this,Jt))==null?void 0:r.unassociateElement)==null||n.call(r,this),Ra(this,Jt,null)),i&&this.isConnected&&(Ra(this,Jt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=xa(this,Jt))==null?void 0:o.associateElement)==null||d.call(o,this)));}connectedCallback(){var e,t,i;let r=this.getAttribute(chunk474VILDO_cjs.b.MEDIA_CONTROLLER);r&&(Ra(this,Jt,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=xa(this,Jt))==null?void 0:t.associateElement)==null||i.call(t,this));}disconnectedCallback(){var e,t;(t=(e=xa(this,Jt))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ra(this,Jt,null);}};Jt=new WeakMap;Fr.shadowRootOptions={mode:"open"};Fr.getTemplateHTML=PE;chunk474VILDO_cjs.o.customElements.get("media-control-bar")||chunk474VILDO_cjs.o.customElements.define("media-control-bar",Fr);var Gf=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ka=(s,e,t)=>(Gf(s,e,"read from private field"),t?t.call(s):e.get(s)),OE=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Da=(s,e,t,i)=>(Gf(s,e,"write to private field"),e.set(s,t),t),ei;function FE(s,e={}){return `
|
|
538
538
|
<style>
|
|
539
539
|
:host {
|
|
540
540
|
font: var(--media-font,
|
|
@@ -568,11 +568,11 @@
|
|
|
568
568
|
</style>
|
|
569
569
|
|
|
570
570
|
${this.getSlotTemplateHTML(s,e)}
|
|
571
|
-
`}function
|
|
571
|
+
`}function NE(s,e){return `
|
|
572
572
|
<slot></slot>
|
|
573
|
-
`}var
|
|
573
|
+
`}var dt=class extends chunk474VILDO_cjs.o.HTMLElement{constructor(){if(super(),OE(this,ei,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=chunk474VILDO_cjs.q(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}}static get observedAttributes(){return [chunk474VILDO_cjs.b.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,n,a,o,d;e===chunk474VILDO_cjs.b.MEDIA_CONTROLLER&&(t&&((n=(r=ka(this,ei))==null?void 0:r.unassociateElement)==null||n.call(r,this),Da(this,ei,null)),i&&this.isConnected&&(Da(this,ei,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=ka(this,ei))==null?void 0:o.associateElement)==null||d.call(o,this)));}connectedCallback(){var e,t,i;let{style:r}=chunk474VILDO_cjs.B(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let n=this.getAttribute(chunk474VILDO_cjs.b.MEDIA_CONTROLLER);n&&(Da(this,ei,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=ka(this,ei))==null?void 0:t.associateElement)==null||i.call(t,this));}disconnectedCallback(){var e,t;(t=(e=ka(this,ei))==null?void 0:e.unassociateElement)==null||t.call(e,this),Da(this,ei,null);}};ei=new WeakMap;dt.shadowRootOptions={mode:"open"};dt.getTemplateHTML=FE;dt.getSlotTemplateHTML=NE;chunk474VILDO_cjs.o.customElements.get("media-text-display")||chunk474VILDO_cjs.o.customElements.define("media-text-display",dt);var Kf=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Hf=(s,e,t)=>(Kf(s,e,"read from private field"),t?t.call(s):e.get(s)),UE=(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);},$E=(s,e,t,i)=>(Kf(s,e,"write to private field"),e.set(s,t),t),Nr;function BE(s,e){return `
|
|
574
574
|
<slot>${Nt(e.mediaDuration)}</slot>
|
|
575
|
-
`}var
|
|
575
|
+
`}var Ca=class extends dt{constructor(){var e;super(),UE(this,Nr,void 0),$E(this,Nr,this.shadowRoot.querySelector("slot")),Hf(this,Nr).textContent=Nt((e=this.mediaDuration)!=null?e:0);}static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_DURATION]}attributeChangedCallback(e,t,i){e===chunk474VILDO_cjs.d.MEDIA_DURATION&&(Hf(this,Nr).textContent=Nt(+i)),super.attributeChangedCallback(e,t,i);}get mediaDuration(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_DURATION)}set mediaDuration(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_DURATION,e);}};Nr=new WeakMap;Ca.getSlotTemplateHTML=BE;chunk474VILDO_cjs.o.customElements.get("media-duration-display")||chunk474VILDO_cjs.o.customElements.define("media-duration-display",Ca);var GE={2:chunk474VILDO_cjs.n("Network Error"),3:chunk474VILDO_cjs.n("Decode Error"),4:chunk474VILDO_cjs.n("Source Not Supported"),5:chunk474VILDO_cjs.n("Encryption Error")},HE={2:chunk474VILDO_cjs.n("A network error caused the media download to fail."),3:chunk474VILDO_cjs.n("A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format."),4:chunk474VILDO_cjs.n("An unsupported error occurred. The server or network failed, or your browser does not support this format."),5:chunk474VILDO_cjs.n("The media is encrypted and there are no keys to decrypt it.")},gd=s=>{var e,t;return s.code===1?null:{title:(e=GE[s.code])!=null?e:`Error ${s.code}`,message:(t=HE[s.code])!=null?t:s.message}};var Wf=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},KE=(s,e,t)=>(Wf(s,e,"read from private field"),t?t.call(s):e.get(s)),VE=(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);},WE=(s,e,t,i)=>(Wf(s,e,"write to private field"),e.set(s,t),t),Ma;function YE(s){return `
|
|
576
576
|
<style>
|
|
577
577
|
:host {
|
|
578
578
|
background: rgb(20 20 30 / .8);
|
|
@@ -589,9 +589,9 @@
|
|
|
589
589
|
}
|
|
590
590
|
</style>
|
|
591
591
|
<slot name="error-${s.mediaerrorcode}" id="content">
|
|
592
|
-
${
|
|
592
|
+
${Yf({code:+s.mediaerrorcode,message:s.mediaerrormessage})}
|
|
593
593
|
</slot>
|
|
594
|
-
`}function
|
|
594
|
+
`}function qE(s){return s.code&&gd(s)!==null}function Yf(s){var e;let{title:t,message:i}=(e=gd(s))!=null?e:{},r="";return t&&(r+=`<slot name="error-${s.code}-title"><h3>${t}</h3></slot>`),i&&(r+=`<slot name="error-${s.code}-message"><p>${i}</p></slot>`),r}var Vf=[chunk474VILDO_cjs.d.MEDIA_ERROR_CODE,chunk474VILDO_cjs.d.MEDIA_ERROR_MESSAGE],Ur=class extends Qt{constructor(){super(...arguments),VE(this,Ma,null);}static get observedAttributes(){return [...super.observedAttributes,...Vf]}formatErrorMessage(e){return this.constructor.formatErrorMessage(e)}attributeChangedCallback(e,t,i){var r;if(super.attributeChangedCallback(e,t,i),!Vf.includes(e))return;let n=(r=this.mediaError)!=null?r:{code:this.mediaErrorCode,message:this.mediaErrorMessage};this.open=qE(n),this.open&&(this.shadowRoot.querySelector("slot").name=`error-${this.mediaErrorCode}`,this.shadowRoot.querySelector("#content").innerHTML=this.formatErrorMessage(n));}get mediaError(){return KE(this,Ma)}set mediaError(e){WE(this,Ma,e);}get mediaErrorCode(){return chunk474VILDO_cjs.D(this,"mediaerrorcode")}set mediaErrorCode(e){chunk474VILDO_cjs.E(this,"mediaerrorcode",e);}get mediaErrorMessage(){return chunk474VILDO_cjs.H(this,"mediaerrormessage")}set mediaErrorMessage(e){chunk474VILDO_cjs.I(this,"mediaerrormessage",e);}};Ma=new WeakMap;Ur.getSlotTemplateHTML=YE;Ur.formatErrorMessage=Yf;chunk474VILDO_cjs.o.customElements.get("media-error-dialog")||chunk474VILDO_cjs.o.customElements.define("media-error-dialog",Ur);var jE=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Mi=(s,e,t)=>(jE(s,e,"read from private field"),t?t.call(s):e.get(s)),qf=(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,ks;function zE(s){return `
|
|
595
595
|
<style>
|
|
596
596
|
:host {
|
|
597
597
|
position: fixed;
|
|
@@ -676,9 +676,9 @@
|
|
|
676
676
|
}
|
|
677
677
|
</style>
|
|
678
678
|
<slot id="content">
|
|
679
|
-
${
|
|
679
|
+
${QE()}
|
|
680
680
|
</slot>
|
|
681
|
-
`}function
|
|
681
|
+
`}function QE(){return `
|
|
682
682
|
<h2>Keyboard Shortcuts</h2>
|
|
683
683
|
<table class="shortcuts-table">${[{keys:["Space","k"],description:"Toggle Playback"},{keys:["m"],description:"Toggle mute"},{keys:["f"],description:"Toggle fullscreen"},{keys:["c"],description:"Toggle captions or subtitles, if available"},{keys:["p"],description:"Toggle Picture in Picture"},{keys:["\u2190","j"],description:"Seek back 10s"},{keys:["\u2192","l"],description:"Seek forward 10s"},{keys:["\u2191"],description:"Turn volume up"},{keys:["\u2193"],description:"Turn volume down"},{keys:["< (SHIFT+,)"],description:"Decrease playback rate"},{keys:["> (SHIFT+.)"],description:"Increase playback rate"}].map(({keys:t,description:i})=>`
|
|
684
684
|
<tr>
|
|
@@ -688,35 +688,35 @@
|
|
|
688
688
|
<td class="description">${i}</td>
|
|
689
689
|
</tr>
|
|
690
690
|
`).join("")}</table>
|
|
691
|
-
`}var
|
|
691
|
+
`}var wa=class extends Qt{constructor(){super(...arguments),qf(this,Rs,e=>{var t;if(!this.open)return;let i=(t=this.shadowRoot)==null?void 0:t.querySelector("#content");if(!i)return;let r=e.composedPath(),n=r[0]===this||r.includes(this),a=r.includes(i);n&&!a&&(this.open=false);}),qf(this,ks,e=>{if(!this.open)return;let t=e.shiftKey&&(e.key==="/"||e.key==="?");(e.key==="Escape"||t)&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&(this.open=false,e.preventDefault(),e.stopPropagation());});}connectedCallback(){super.connectedCallback(),this.open&&(this.addEventListener("click",Mi(this,Rs)),document.addEventListener("keydown",Mi(this,ks)));}disconnectedCallback(){this.removeEventListener("click",Mi(this,Rs)),document.removeEventListener("keydown",Mi(this,ks));}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e==="open"&&(this.open?(this.addEventListener("click",Mi(this,Rs)),document.addEventListener("keydown",Mi(this,ks))):(this.removeEventListener("click",Mi(this,Rs)),document.removeEventListener("keydown",Mi(this,ks))));}};Rs=new WeakMap;ks=new WeakMap;wa.getSlotTemplateHTML=zE;chunk474VILDO_cjs.o.customElements.get("media-keyboard-shortcuts-dialog")||chunk474VILDO_cjs.o.customElements.define("media-keyboard-shortcuts-dialog",wa);var zf=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},XE=(s,e,t)=>(zf(s,e,"read from private field"),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);},JE=(s,e,t,i)=>(zf(s,e,"write to private field"),e.set(s,t),t),Pa,ev=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
692
692
|
<path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
|
|
693
|
-
</svg>`,
|
|
693
|
+
</svg>`,tv=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
694
694
|
<path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
|
|
695
|
-
</svg>`;function
|
|
695
|
+
</svg>`;function iv(s){return `
|
|
696
696
|
<style>
|
|
697
|
-
:host([${
|
|
697
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_IS_FULLSCREEN}]) slot[name=icon] slot:not([name=exit]) {
|
|
698
698
|
display: none !important;
|
|
699
699
|
}
|
|
700
700
|
|
|
701
701
|
|
|
702
|
-
:host(:not([${
|
|
702
|
+
:host(:not([${chunk474VILDO_cjs.d.MEDIA_IS_FULLSCREEN}])) slot[name=icon] slot:not([name=enter]) {
|
|
703
703
|
display: none !important;
|
|
704
704
|
}
|
|
705
705
|
|
|
706
|
-
:host([${
|
|
707
|
-
:host(:not([${
|
|
706
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_IS_FULLSCREEN}]) slot[name=tooltip-enter],
|
|
707
|
+
:host(:not([${chunk474VILDO_cjs.d.MEDIA_IS_FULLSCREEN}])) slot[name=tooltip-exit] {
|
|
708
708
|
display: none;
|
|
709
709
|
}
|
|
710
710
|
</style>
|
|
711
711
|
|
|
712
712
|
<slot name="icon">
|
|
713
|
-
<slot name="enter">${
|
|
714
|
-
<slot name="exit">${
|
|
713
|
+
<slot name="enter">${ev}</slot>
|
|
714
|
+
<slot name="exit">${tv}</slot>
|
|
715
715
|
</slot>
|
|
716
|
-
`}function
|
|
717
|
-
<slot name="tooltip-enter">${
|
|
718
|
-
<slot name="tooltip-exit">${
|
|
719
|
-
`}var
|
|
716
|
+
`}function sv(){return `
|
|
717
|
+
<slot name="tooltip-enter">${chunk474VILDO_cjs.n("Enter fullscreen mode")}</slot>
|
|
718
|
+
<slot name="tooltip-exit">${chunk474VILDO_cjs.n("Exit fullscreen mode")}</slot>
|
|
719
|
+
`}var jf=s=>{let e=s.mediaIsFullscreen?chunk474VILDO_cjs.n("exit fullscreen mode"):chunk474VILDO_cjs.n("enter fullscreen mode");s.setAttribute("aria-label",e);},$r=class extends chunk474VILDO_cjs.J{constructor(){super(...arguments),ZE(this,Pa,null);}static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_IS_FULLSCREEN,chunk474VILDO_cjs.d.MEDIA_FULLSCREEN_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),jf(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunk474VILDO_cjs.d.MEDIA_IS_FULLSCREEN&&jf(this);}get mediaFullscreenUnavailable(){return chunk474VILDO_cjs.H(this,chunk474VILDO_cjs.d.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){chunk474VILDO_cjs.I(this,chunk474VILDO_cjs.d.MEDIA_FULLSCREEN_UNAVAILABLE,e);}get mediaIsFullscreen(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_IS_FULLSCREEN,e);}handleClick(e){JE(this,Pa,e);let t=XE(this,Pa)instanceof PointerEvent,i=this.mediaIsFullscreen?new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_EXIT_FULLSCREEN_REQUEST,{composed:true,bubbles:true}):new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_ENTER_FULLSCREEN_REQUEST,{composed:true,bubbles:true,detail:t});this.dispatchEvent(i);}};Pa=new WeakMap;$r.getSlotTemplateHTML=iv;$r.getTooltipContentHTML=sv;chunk474VILDO_cjs.o.customElements.get("media-fullscreen-button")||chunk474VILDO_cjs.o.customElements.define("media-fullscreen-button",$r);var{MEDIA_TIME_IS_LIVE:Oa,MEDIA_PAUSED:Br}=chunk474VILDO_cjs.d,{MEDIA_SEEK_TO_LIVE_REQUEST:rv,MEDIA_PLAY_REQUEST:nv}=chunk474VILDO_cjs.a,av='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>';function ov(s){return `
|
|
720
720
|
<style>
|
|
721
721
|
:host { --media-tooltip-display: none; }
|
|
722
722
|
|
|
@@ -728,13 +728,13 @@
|
|
|
728
728
|
color: var(--media-live-button-icon-color, rgb(140, 140, 140));
|
|
729
729
|
}
|
|
730
730
|
|
|
731
|
-
:host([${
|
|
732
|
-
:host([${
|
|
731
|
+
:host([${Oa}]:not([${Br}])) slot[name=indicator] > *,
|
|
732
|
+
:host([${Oa}]:not([${Br}])) ::slotted([slot=indicator]) {
|
|
733
733
|
fill: var(--media-live-button-indicator-color, rgb(255, 0, 0));
|
|
734
734
|
color: var(--media-live-button-indicator-color, rgb(255, 0, 0));
|
|
735
735
|
}
|
|
736
736
|
|
|
737
|
-
:host([${
|
|
737
|
+
:host([${Oa}]:not([${Br}])) {
|
|
738
738
|
cursor: var(--media-cursor, not-allowed);
|
|
739
739
|
}
|
|
740
740
|
|
|
@@ -744,10 +744,10 @@
|
|
|
744
744
|
|
|
745
745
|
</style>
|
|
746
746
|
|
|
747
|
-
<slot name="indicator">${
|
|
747
|
+
<slot name="indicator">${av}</slot>
|
|
748
748
|
|
|
749
|
-
<slot name="spacer"> </slot><slot name="text">${
|
|
750
|
-
`}var
|
|
749
|
+
<slot name="spacer"> </slot><slot name="text">${chunk474VILDO_cjs.n("live")}</slot>
|
|
750
|
+
`}var Qf=s=>{var e;let t=s.mediaPaused||!s.mediaTimeIsLive,i=t?chunk474VILDO_cjs.n("seek to live"):chunk474VILDO_cjs.n("playing live");s.setAttribute("aria-label",i);let r=(e=s.shadowRoot)==null?void 0:e.querySelector('slot[name="text"]');r&&(r.textContent=chunk474VILDO_cjs.n("live")),t?s.removeAttribute("aria-disabled"):s.setAttribute("aria-disabled","true");},Fa=class extends chunk474VILDO_cjs.J{static get observedAttributes(){return [...super.observedAttributes,Oa,Br]}connectedCallback(){super.connectedCallback(),Qf(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),Qf(this);}get mediaPaused(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_PAUSED)}set mediaPaused(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_PAUSED,e);}get mediaTimeIsLive(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_TIME_IS_LIVE,e);}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(rv,{composed:true,bubbles:true})),this.hasAttribute(Br)&&this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(nv,{composed:true,bubbles:true})));}};Fa.getSlotTemplateHTML=ov;chunk474VILDO_cjs.o.customElements.get("media-live-button")||chunk474VILDO_cjs.o.customElements.define("media-live-button",Fa);var Zf=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Gr=(s,e,t)=>(Zf(s,e,"read from private field"),t?t.call(s):e.get(s)),Xf=(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);},Hr=(s,e,t,i)=>(Zf(s,e,"write to private field"),e.set(s,t),t),ti,Ua,Na={LOADING_DELAY:"loadingdelay",NO_AUTOHIDE:"noautohide"},Jf=500,lv=`
|
|
751
751
|
<svg aria-hidden="true" viewBox="0 0 100 100">
|
|
752
752
|
<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">
|
|
753
753
|
<animateTransform
|
|
@@ -760,13 +760,13 @@
|
|
|
760
760
|
repeatCount="indefinite" />
|
|
761
761
|
</path>
|
|
762
762
|
</svg>
|
|
763
|
-
`;function
|
|
763
|
+
`;function dv(s){return `
|
|
764
764
|
<style>
|
|
765
765
|
:host {
|
|
766
766
|
display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));
|
|
767
767
|
vertical-align: middle;
|
|
768
768
|
box-sizing: border-box;
|
|
769
|
-
--_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${
|
|
769
|
+
--_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${Jf}ms);
|
|
770
770
|
}
|
|
771
771
|
|
|
772
772
|
#status {
|
|
@@ -781,8 +781,8 @@
|
|
|
781
781
|
transition: opacity 0.15s;
|
|
782
782
|
}
|
|
783
783
|
|
|
784
|
-
:host([${
|
|
785
|
-
:host([${
|
|
784
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_LOADING}]:not([${chunk474VILDO_cjs.d.MEDIA_PAUSED}])) slot[name=icon] > *,
|
|
785
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_LOADING}]:not([${chunk474VILDO_cjs.d.MEDIA_PAUSED}])) ::slotted([slot=icon]) {
|
|
786
786
|
opacity: var(--media-loading-indicator-opacity, 1);
|
|
787
787
|
transition: opacity 0.15s var(--_loading-indicator-delay);
|
|
788
788
|
}
|
|
@@ -792,7 +792,7 @@
|
|
|
792
792
|
transition: visibility 0.15s;
|
|
793
793
|
}
|
|
794
794
|
|
|
795
|
-
:host([${
|
|
795
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_LOADING}]:not([${chunk474VILDO_cjs.d.MEDIA_PAUSED}])) #status {
|
|
796
796
|
visibility: var(--media-loading-indicator-opacity, visible);
|
|
797
797
|
transition: visibility 0.15s var(--_loading-indicator-delay);
|
|
798
798
|
}
|
|
@@ -805,106 +805,106 @@
|
|
|
805
805
|
}
|
|
806
806
|
</style>
|
|
807
807
|
|
|
808
|
-
<slot name="icon">${
|
|
809
|
-
<div id="status" role="status" aria-live="polite">${
|
|
810
|
-
`}var
|
|
808
|
+
<slot name="icon">${lv}</slot>
|
|
809
|
+
<div id="status" role="status" aria-live="polite">${chunk474VILDO_cjs.n("media loading")}</div>
|
|
810
|
+
`}var Kr=class extends chunk474VILDO_cjs.o.HTMLElement{constructor(){if(super(),Xf(this,ti,void 0),Xf(this,Ua,Jf),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=chunk474VILDO_cjs.q(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}}static get observedAttributes(){return [chunk474VILDO_cjs.b.MEDIA_CONTROLLER,chunk474VILDO_cjs.d.MEDIA_PAUSED,chunk474VILDO_cjs.d.MEDIA_LOADING,Na.LOADING_DELAY]}attributeChangedCallback(e,t,i){var r,n,a,o,d;e===Na.LOADING_DELAY&&t!==i?this.loadingDelay=Number(i):e===chunk474VILDO_cjs.b.MEDIA_CONTROLLER&&(t&&((n=(r=Gr(this,ti))==null?void 0:r.unassociateElement)==null||n.call(r,this),Hr(this,ti,null)),i&&this.isConnected&&(Hr(this,ti,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=Gr(this,ti))==null?void 0:o.associateElement)==null||d.call(o,this)));}connectedCallback(){var e,t,i;let r=this.getAttribute(chunk474VILDO_cjs.b.MEDIA_CONTROLLER);r&&(Hr(this,ti,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=Gr(this,ti))==null?void 0:t.associateElement)==null||i.call(t,this));}disconnectedCallback(){var e,t;(t=(e=Gr(this,ti))==null?void 0:e.unassociateElement)==null||t.call(e,this),Hr(this,ti,null);}get loadingDelay(){return Gr(this,Ua)}set loadingDelay(e){Hr(this,Ua,e);let{style:t}=chunk474VILDO_cjs.B(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`);}get mediaPaused(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_PAUSED)}set mediaPaused(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_PAUSED,e);}get mediaLoading(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_LOADING)}set mediaLoading(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_LOADING,e);}get mediaController(){return chunk474VILDO_cjs.H(this,chunk474VILDO_cjs.b.MEDIA_CONTROLLER)}set mediaController(e){chunk474VILDO_cjs.I(this,chunk474VILDO_cjs.b.MEDIA_CONTROLLER,e);}get noAutohide(){return chunk474VILDO_cjs.F(this,Na.NO_AUTOHIDE)}set noAutohide(e){chunk474VILDO_cjs.G(this,Na.NO_AUTOHIDE,e);}};ti=new WeakMap;Ua=new WeakMap;Kr.shadowRootOptions={mode:"open"};Kr.getTemplateHTML=dv;chunk474VILDO_cjs.o.customElements.get("media-loading-indicator")||chunk474VILDO_cjs.o.customElements.define("media-loading-indicator",Kr);var cv=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
811
811
|
<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"/>
|
|
812
|
-
</svg>`,
|
|
812
|
+
</svg>`,em=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
813
813
|
<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"/>
|
|
814
|
-
</svg>`,
|
|
814
|
+
</svg>`,uv=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
815
815
|
<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"/>
|
|
816
|
-
</svg>`;function
|
|
816
|
+
</svg>`;function hv(s){return `
|
|
817
817
|
<style>
|
|
818
|
-
:host(:not([${
|
|
819
|
-
:host([${
|
|
818
|
+
:host(:not([${chunk474VILDO_cjs.d.MEDIA_VOLUME_LEVEL}])) slot[name=icon] slot:not([name=high]),
|
|
819
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_VOLUME_LEVEL}=high]) slot[name=icon] slot:not([name=high]) {
|
|
820
820
|
display: none !important;
|
|
821
821
|
}
|
|
822
822
|
|
|
823
|
-
:host([${
|
|
823
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_VOLUME_LEVEL}=off]) slot[name=icon] slot:not([name=off]) {
|
|
824
824
|
display: none !important;
|
|
825
825
|
}
|
|
826
826
|
|
|
827
|
-
:host([${
|
|
827
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_VOLUME_LEVEL}=low]) slot[name=icon] slot:not([name=low]) {
|
|
828
828
|
display: none !important;
|
|
829
829
|
}
|
|
830
830
|
|
|
831
|
-
:host([${
|
|
831
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_VOLUME_LEVEL}=medium]) slot[name=icon] slot:not([name=medium]) {
|
|
832
832
|
display: none !important;
|
|
833
833
|
}
|
|
834
834
|
|
|
835
|
-
:host(:not([${
|
|
836
|
-
:host([${
|
|
835
|
+
:host(:not([${chunk474VILDO_cjs.d.MEDIA_VOLUME_LEVEL}=off])) slot[name=tooltip-unmute],
|
|
836
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_VOLUME_LEVEL}=off]) slot[name=tooltip-mute] {
|
|
837
837
|
display: none;
|
|
838
838
|
}
|
|
839
839
|
</style>
|
|
840
840
|
|
|
841
841
|
<slot name="icon">
|
|
842
|
-
<slot name="off">${
|
|
843
|
-
<slot name="low">${
|
|
844
|
-
<slot name="medium">${
|
|
845
|
-
<slot name="high">${
|
|
842
|
+
<slot name="off">${cv}</slot>
|
|
843
|
+
<slot name="low">${em}</slot>
|
|
844
|
+
<slot name="medium">${em}</slot>
|
|
845
|
+
<slot name="high">${uv}</slot>
|
|
846
846
|
</slot>
|
|
847
|
-
`}function
|
|
848
|
-
<slot name="tooltip-mute">${
|
|
849
|
-
<slot name="tooltip-unmute">${
|
|
850
|
-
`}var
|
|
847
|
+
`}function fv(){return `
|
|
848
|
+
<slot name="tooltip-mute">${chunk474VILDO_cjs.n("Mute")}</slot>
|
|
849
|
+
<slot name="tooltip-unmute">${chunk474VILDO_cjs.n("Unmute")}</slot>
|
|
850
|
+
`}var tm=s=>{let t=s.mediaVolumeLevel==="off"?chunk474VILDO_cjs.n("unmute"):chunk474VILDO_cjs.n("mute");s.setAttribute("aria-label",t);},Vr=class extends chunk474VILDO_cjs.J{static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_VOLUME_LEVEL]}connectedCallback(){super.connectedCallback(),tm(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunk474VILDO_cjs.d.MEDIA_VOLUME_LEVEL&&tm(this);}get mediaVolumeLevel(){return chunk474VILDO_cjs.H(this,chunk474VILDO_cjs.d.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){chunk474VILDO_cjs.I(this,chunk474VILDO_cjs.d.MEDIA_VOLUME_LEVEL,e);}handleClick(){let e=this.mediaVolumeLevel==="off"?chunk474VILDO_cjs.a.MEDIA_UNMUTE_REQUEST:chunk474VILDO_cjs.a.MEDIA_MUTE_REQUEST;this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(e,{composed:true,bubbles:true}));}};Vr.getSlotTemplateHTML=hv;Vr.getTooltipContentHTML=fv;chunk474VILDO_cjs.o.customElements.get("media-mute-button")||chunk474VILDO_cjs.o.customElements.define("media-mute-button",Vr);var im=`<svg aria-hidden="true" viewBox="0 0 28 24">
|
|
851
851
|
<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"/>
|
|
852
|
-
</svg>`;function
|
|
852
|
+
</svg>`;function mv(s){return `
|
|
853
853
|
<style>
|
|
854
|
-
:host([${
|
|
854
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_IS_PIP}]) slot[name=icon] slot:not([name=exit]) {
|
|
855
855
|
display: none !important;
|
|
856
856
|
}
|
|
857
857
|
|
|
858
|
-
:host(:not([${
|
|
858
|
+
:host(:not([${chunk474VILDO_cjs.d.MEDIA_IS_PIP}])) slot[name=icon] slot:not([name=enter]) {
|
|
859
859
|
display: none !important;
|
|
860
860
|
}
|
|
861
861
|
|
|
862
|
-
:host([${
|
|
863
|
-
:host(:not([${
|
|
862
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_IS_PIP}]) slot[name=tooltip-enter],
|
|
863
|
+
:host(:not([${chunk474VILDO_cjs.d.MEDIA_IS_PIP}])) slot[name=tooltip-exit] {
|
|
864
864
|
display: none;
|
|
865
865
|
}
|
|
866
866
|
</style>
|
|
867
867
|
|
|
868
868
|
<slot name="icon">
|
|
869
|
-
<slot name="enter">${
|
|
870
|
-
<slot name="exit">${
|
|
869
|
+
<slot name="enter">${im}</slot>
|
|
870
|
+
<slot name="exit">${im}</slot>
|
|
871
871
|
</slot>
|
|
872
|
-
`}function
|
|
873
|
-
<slot name="tooltip-enter">${
|
|
874
|
-
<slot name="tooltip-exit">${
|
|
875
|
-
`}var
|
|
872
|
+
`}function gv(){return `
|
|
873
|
+
<slot name="tooltip-enter">${chunk474VILDO_cjs.n("Enter picture in picture mode")}</slot>
|
|
874
|
+
<slot name="tooltip-exit">${chunk474VILDO_cjs.n("Exit picture in picture mode")}</slot>
|
|
875
|
+
`}var sm=s=>{let e=s.mediaIsPip?chunk474VILDO_cjs.n("exit picture in picture mode"):chunk474VILDO_cjs.n("enter picture in picture mode");s.setAttribute("aria-label",e);},Wr=class extends chunk474VILDO_cjs.J{static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_IS_PIP,chunk474VILDO_cjs.d.MEDIA_PIP_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),sm(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunk474VILDO_cjs.d.MEDIA_IS_PIP&&sm(this);}get mediaPipUnavailable(){return chunk474VILDO_cjs.H(this,chunk474VILDO_cjs.d.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){chunk474VILDO_cjs.I(this,chunk474VILDO_cjs.d.MEDIA_PIP_UNAVAILABLE,e);}get mediaIsPip(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_IS_PIP)}set mediaIsPip(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_IS_PIP,e);}handleClick(){let e=this.mediaIsPip?chunk474VILDO_cjs.a.MEDIA_EXIT_PIP_REQUEST:chunk474VILDO_cjs.a.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(e,{composed:true,bubbles:true}));}};Wr.getSlotTemplateHTML=mv;Wr.getTooltipContentHTML=gv;chunk474VILDO_cjs.o.customElements.get("media-pip-button")||chunk474VILDO_cjs.o.customElements.define("media-pip-button",Wr);var pv=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Ds=(s,e,t)=>(pv(s,e,"read from private field"),t?t.call(s):e.get(s)),Ev=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},wi,pd={RATES:"rates"},Ed=[1,1.2,1.5,1.7,2],ts=1;function vv(s){return `
|
|
876
876
|
<style>
|
|
877
877
|
:host {
|
|
878
878
|
min-width: 5ch;
|
|
879
879
|
padding: var(--media-button-padding, var(--media-control-padding, 10px 5px));
|
|
880
880
|
}
|
|
881
881
|
</style>
|
|
882
|
-
<slot name="icon">${s.mediaplaybackrate||
|
|
883
|
-
`}function
|
|
882
|
+
<slot name="icon">${s.mediaplaybackrate||ts}x</slot>
|
|
883
|
+
`}function Tv(){return chunk474VILDO_cjs.n("Playback rate")}var Yr=class extends chunk474VILDO_cjs.J{constructor(){var e;super(),Ev(this,wi,new ki(this,pd.RATES,{defaultValue:Ed})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${(e=this.mediaPlaybackRate)!=null?e:ts}x`;}static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE,pd.RATES]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===pd.RATES&&(Ds(this,wi).value=i),e===chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE){let r=i?+i:Number.NaN,n=Number.isNaN(r)?ts:r;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",chunk474VILDO_cjs.n("Playback rate {playbackRate}",{playbackRate:n}));}}get rates(){return Ds(this,wi)}set rates(e){e?Array.isArray(e)?Ds(this,wi).value=e.join(" "):typeof e=="string"&&(Ds(this,wi).value=e):Ds(this,wi).value="";}get mediaPlaybackRate(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE,ts)}set mediaPlaybackRate(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE,e);}handleClick(){var e,t;let i=Array.from(Ds(this,wi).values(),a=>+a).sort((a,o)=>a-o),r=(t=(e=i.find(a=>a>this.mediaPlaybackRate))!=null?e:i[0])!=null?t:ts,n=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_PLAYBACK_RATE_REQUEST,{composed:true,bubbles:true,detail:r});this.dispatchEvent(n);}};wi=new WeakMap;Yr.getSlotTemplateHTML=vv;Yr.getTooltipContentHTML=Tv;chunk474VILDO_cjs.o.customElements.get("media-playback-rate-button")||chunk474VILDO_cjs.o.customElements.define("media-playback-rate-button",Yr);var yv=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
884
884
|
<path d="m6 21 15-9L6 3v18Z"/>
|
|
885
|
-
</svg>`,
|
|
885
|
+
</svg>`,Sv=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
886
886
|
<path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
|
|
887
|
-
</svg>`;function
|
|
887
|
+
</svg>`;function bv(s){return `
|
|
888
888
|
<style>
|
|
889
|
-
:host([${
|
|
890
|
-
:host(:not([${
|
|
889
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_PAUSED}]) slot[name=pause],
|
|
890
|
+
:host(:not([${chunk474VILDO_cjs.d.MEDIA_PAUSED}])) slot[name=play] {
|
|
891
891
|
display: none !important;
|
|
892
892
|
}
|
|
893
893
|
|
|
894
|
-
:host([${
|
|
895
|
-
:host(:not([${
|
|
894
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_PAUSED}]) slot[name=tooltip-pause],
|
|
895
|
+
:host(:not([${chunk474VILDO_cjs.d.MEDIA_PAUSED}])) slot[name=tooltip-play] {
|
|
896
896
|
display: none;
|
|
897
897
|
}
|
|
898
898
|
</style>
|
|
899
899
|
|
|
900
900
|
<slot name="icon">
|
|
901
|
-
<slot name="play">${
|
|
902
|
-
<slot name="pause">${
|
|
901
|
+
<slot name="play">${yv}</slot>
|
|
902
|
+
<slot name="pause">${Sv}</slot>
|
|
903
903
|
</slot>
|
|
904
|
-
`}function
|
|
905
|
-
<slot name="tooltip-play">${
|
|
906
|
-
<slot name="tooltip-pause">${
|
|
907
|
-
`}var
|
|
904
|
+
`}function Av(){return `
|
|
905
|
+
<slot name="tooltip-play">${chunk474VILDO_cjs.n("Play")}</slot>
|
|
906
|
+
<slot name="tooltip-pause">${chunk474VILDO_cjs.n("Pause")}</slot>
|
|
907
|
+
`}var rm=s=>{let e=s.mediaPaused?chunk474VILDO_cjs.n("play"):chunk474VILDO_cjs.n("pause");s.setAttribute("aria-label",e);},qr=class extends chunk474VILDO_cjs.J{static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_PAUSED,chunk474VILDO_cjs.d.MEDIA_ENDED]}connectedCallback(){super.connectedCallback(),rm(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),(e===chunk474VILDO_cjs.d.MEDIA_PAUSED||e===chunk474VILDO_cjs.d.MEDIA_LANG)&&rm(this);}get mediaPaused(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_PAUSED)}set mediaPaused(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_PAUSED,e);}handleClick(){let e=this.mediaPaused?chunk474VILDO_cjs.a.MEDIA_PLAY_REQUEST:chunk474VILDO_cjs.a.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(e,{composed:true,bubbles:true}));}};qr.getSlotTemplateHTML=bv;qr.getTooltipContentHTML=Av;chunk474VILDO_cjs.o.customElements.get("media-play-button")||chunk474VILDO_cjs.o.customElements.define("media-play-button",qr);var ii={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"};function _v(s){return `
|
|
908
908
|
<style>
|
|
909
909
|
:host {
|
|
910
910
|
pointer-events: none;
|
|
@@ -926,7 +926,7 @@
|
|
|
926
926
|
</style>
|
|
927
927
|
|
|
928
928
|
<img part="poster img" aria-hidden="true" id="image"/>
|
|
929
|
-
`}var
|
|
929
|
+
`}var Iv=s=>{s.style.removeProperty("background-image");},Lv=(s,e)=>{s.style["background-image"]=`url('${e}')`;},jr=class extends chunk474VILDO_cjs.o.HTMLElement{static get observedAttributes(){return [ii.PLACEHOLDER_SRC,ii.SRC]}constructor(){if(super(),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=chunk474VILDO_cjs.q(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}this.image=this.shadowRoot.querySelector("#image");}attributeChangedCallback(e,t,i){e===ii.SRC&&(i==null?this.image.removeAttribute(ii.SRC):this.image.setAttribute(ii.SRC,i)),e===ii.PLACEHOLDER_SRC&&(i==null?Iv(this.image):Lv(this.image,i));}get placeholderSrc(){return chunk474VILDO_cjs.H(this,ii.PLACEHOLDER_SRC)}set placeholderSrc(e){chunk474VILDO_cjs.I(this,ii.SRC,e);}get src(){return chunk474VILDO_cjs.H(this,ii.SRC)}set src(e){chunk474VILDO_cjs.I(this,ii.SRC,e);}};jr.shadowRootOptions={mode:"open"};jr.getTemplateHTML=_v;chunk474VILDO_cjs.o.customElements.get("media-poster-image")||chunk474VILDO_cjs.o.customElements.define("media-poster-image",jr);var nm=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},xv=(s,e,t)=>(nm(s,e,"read from private field"),t?t.call(s):e.get(s)),Rv=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},kv=(s,e,t,i)=>(nm(s,e,"write to private field"),e.set(s,t),t),$a,vd=class extends dt{constructor(){super(),Rv(this,$a,void 0),kv(this,$a,this.shadowRoot.querySelector("slot"));}static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_PREVIEW_CHAPTER,chunk474VILDO_cjs.d.MEDIA_LANG]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),(e===chunk474VILDO_cjs.d.MEDIA_PREVIEW_CHAPTER||e===chunk474VILDO_cjs.d.MEDIA_LANG)&&i!==t&&i!=null)if(xv(this,$a).textContent=i,i!==""){let r=chunk474VILDO_cjs.n("chapter: {chapterName}",{chapterName:i});this.setAttribute("aria-valuetext",r);}else this.removeAttribute("aria-valuetext");}get mediaPreviewChapter(){return chunk474VILDO_cjs.H(this,chunk474VILDO_cjs.d.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){chunk474VILDO_cjs.I(this,chunk474VILDO_cjs.d.MEDIA_PREVIEW_CHAPTER,e);}};$a=new WeakMap;chunk474VILDO_cjs.o.customElements.get("media-preview-chapter-display")||chunk474VILDO_cjs.o.customElements.define("media-preview-chapter-display",vd);var am=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Ba=(s,e,t)=>(am(s,e,"read from private field"),t?t.call(s):e.get(s)),Dv=(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);},Ga=(s,e,t,i)=>(am(s,e,"write to private field"),e.set(s,t),t),si;function Cv(s){return `
|
|
930
930
|
<style>
|
|
931
931
|
:host {
|
|
932
932
|
box-sizing: border-box;
|
|
@@ -940,27 +940,27 @@
|
|
|
940
940
|
}
|
|
941
941
|
</style>
|
|
942
942
|
<img crossorigin loading="eager" decoding="async">
|
|
943
|
-
`}var
|
|
943
|
+
`}var Cs=class extends chunk474VILDO_cjs.o.HTMLElement{constructor(){if(super(),Dv(this,si,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=chunk474VILDO_cjs.q(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}}static get observedAttributes(){return [chunk474VILDO_cjs.b.MEDIA_CONTROLLER,chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE,chunk474VILDO_cjs.d.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,i;let r=this.getAttribute(chunk474VILDO_cjs.b.MEDIA_CONTROLLER);r&&(Ga(this,si,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=Ba(this,si))==null?void 0:t.associateElement)==null||i.call(t,this));}disconnectedCallback(){var e,t;(t=(e=Ba(this,si))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ga(this,si,null);}attributeChangedCallback(e,t,i){var r,n,a,o,d;[chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE,chunk474VILDO_cjs.d.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===chunk474VILDO_cjs.b.MEDIA_CONTROLLER&&(t&&((n=(r=Ba(this,si))==null?void 0:r.unassociateElement)==null||n.call(r,this),Ga(this,si,null)),i&&this.isConnected&&(Ga(this,si,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=Ba(this,si))==null?void 0:o.associateElement)==null||d.call(o,this)));}get mediaPreviewImage(){return chunk474VILDO_cjs.H(this,chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){chunk474VILDO_cjs.I(this,chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE,e);}get mediaPreviewCoords(){let e=this.getAttribute(chunk474VILDO_cjs.d.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(chunk474VILDO_cjs.d.MEDIA_PREVIEW_COORDS);return}this.setAttribute(chunk474VILDO_cjs.d.MEDIA_PREVIEW_COORDS,e.join(" "));}update(){let e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;let[i,r,n,a]=e,o=t.split("#")[0],d=getComputedStyle(this),{maxWidth:l,maxHeight:c,minWidth:u,minHeight:h}=d,f=Math.min(parseInt(l)/n,parseInt(c)/a),m=Math.max(parseInt(u)/n,parseInt(h)/a),g=f<1,E=g?f:m>1?m:1,{style:v}=chunk474VILDO_cjs.B(this.shadowRoot,":host"),T=chunk474VILDO_cjs.B(this.shadowRoot,"img").style,S=this.shadowRoot.querySelector("img"),b=g?"min":"max";v.setProperty(`${b}-width`,"initial","important"),v.setProperty(`${b}-height`,"initial","important"),v.width=`${n*E}px`,v.height=`${a*E}px`;let _=()=>{T.width=`${this.imgWidth*E}px`,T.height=`${this.imgHeight*E}px`,T.display="block";};S.src!==o&&(S.onload=()=>{this.imgWidth=S.naturalWidth,this.imgHeight=S.naturalHeight,_();},S.src=o,_()),_(),T.transform=`translate(-${i*E}px, -${r*E}px)`;}};si=new WeakMap;Cs.shadowRootOptions={mode:"open"};Cs.getTemplateHTML=Cv;chunk474VILDO_cjs.o.customElements.get("media-preview-thumbnail")||chunk474VILDO_cjs.o.customElements.define("media-preview-thumbnail",Cs);var Ha=Cs;var lm=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},om=(s,e,t)=>(lm(s,e,"read from private field"),t?t.call(s):e.get(s)),Mv=(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);},wv=(s,e,t,i)=>(lm(s,e,"write to private field"),e.set(s,t),t),zr,Td=class extends dt{constructor(){super(),Mv(this,zr,void 0),wv(this,zr,this.shadowRoot.querySelector("slot")),om(this,zr).textContent=Nt(0);}static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunk474VILDO_cjs.d.MEDIA_PREVIEW_TIME&&i!=null&&(om(this,zr).textContent=Nt(parseFloat(i)));}get mediaPreviewTime(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_PREVIEW_TIME,e);}};zr=new WeakMap;chunk474VILDO_cjs.o.customElements.get("media-preview-time-display")||chunk474VILDO_cjs.o.customElements.define("media-preview-time-display",Td);var Ms={SEEK_OFFSET:"seekoffset"},yd=30,Pv=s=>`
|
|
944
944
|
<svg aria-hidden="true" viewBox="0 0 20 24">
|
|
945
945
|
<defs>
|
|
946
946
|
<style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>
|
|
947
947
|
</defs>
|
|
948
948
|
<text class="text value" transform="translate(2.18 19.87)">${s}</text>
|
|
949
949
|
<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"/>
|
|
950
|
-
</svg>`;function
|
|
951
|
-
<slot name="icon">${
|
|
952
|
-
`}function
|
|
950
|
+
</svg>`;function Ov(s,e){return `
|
|
951
|
+
<slot name="icon">${Pv(e.seekOffset)}</slot>
|
|
952
|
+
`}function Fv(){return chunk474VILDO_cjs.n("Seek backward")}var Nv=0,Qr=class extends chunk474VILDO_cjs.J{static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_CURRENT_TIME,Ms.SEEK_OFFSET]}connectedCallback(){super.connectedCallback(),this.seekOffset=chunk474VILDO_cjs.D(this,Ms.SEEK_OFFSET,yd);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===Ms.SEEK_OFFSET&&(this.seekOffset=chunk474VILDO_cjs.D(this,Ms.SEEK_OFFSET,yd));}get seekOffset(){return chunk474VILDO_cjs.D(this,Ms.SEEK_OFFSET,yd)}set seekOffset(e){chunk474VILDO_cjs.E(this,Ms.SEEK_OFFSET,e),this.setAttribute("aria-label",chunk474VILDO_cjs.n("seek back {seekOffset} seconds",{seekOffset:this.seekOffset})),chunk474VILDO_cjs.t(chunk474VILDO_cjs.u(this,"icon"),this.seekOffset);}get mediaCurrentTime(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_CURRENT_TIME,Nv)}set mediaCurrentTime(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_CURRENT_TIME,e);}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:e});this.dispatchEvent(t);}};Qr.getSlotTemplateHTML=Ov;Qr.getTooltipContentHTML=Fv;chunk474VILDO_cjs.o.customElements.get("media-seek-backward-button")||chunk474VILDO_cjs.o.customElements.define("media-seek-backward-button",Qr);var ws={SEEK_OFFSET:"seekoffset"},Sd=30,Uv=s=>`
|
|
953
953
|
<svg aria-hidden="true" viewBox="0 0 20 24">
|
|
954
954
|
<defs>
|
|
955
955
|
<style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>
|
|
956
956
|
</defs>
|
|
957
957
|
<text class="text value" transform="translate(8.9 19.87)">${s}</text>
|
|
958
958
|
<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"/>
|
|
959
|
-
</svg>`;function
|
|
960
|
-
<slot name="icon">${
|
|
961
|
-
`}function
|
|
962
|
-
<slot>${
|
|
963
|
-
`}var
|
|
959
|
+
</svg>`;function $v(s,e){return `
|
|
960
|
+
<slot name="icon">${Uv(e.seekOffset)}</slot>
|
|
961
|
+
`}function Bv(){return chunk474VILDO_cjs.n("Seek forward")}var Gv=0,Xr=class extends chunk474VILDO_cjs.J{static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_CURRENT_TIME,ws.SEEK_OFFSET]}connectedCallback(){super.connectedCallback(),this.seekOffset=chunk474VILDO_cjs.D(this,ws.SEEK_OFFSET,Sd);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===ws.SEEK_OFFSET&&(this.seekOffset=chunk474VILDO_cjs.D(this,ws.SEEK_OFFSET,Sd));}get seekOffset(){return chunk474VILDO_cjs.D(this,ws.SEEK_OFFSET,Sd)}set seekOffset(e){chunk474VILDO_cjs.E(this,ws.SEEK_OFFSET,e),this.setAttribute("aria-label",chunk474VILDO_cjs.n("seek forward {seekOffset} seconds",{seekOffset:this.seekOffset})),chunk474VILDO_cjs.t(chunk474VILDO_cjs.u(this,"icon"),this.seekOffset);}get mediaCurrentTime(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_CURRENT_TIME,Gv)}set mediaCurrentTime(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_CURRENT_TIME,e);}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:e});this.dispatchEvent(t);}};Xr.getSlotTemplateHTML=$v;Xr.getTooltipContentHTML=Bv;chunk474VILDO_cjs.o.customElements.get("media-seek-forward-button")||chunk474VILDO_cjs.o.customElements.define("media-seek-forward-button",Xr);var um=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},bd=(s,e,t)=>(um(s,e,"read from private field"),t?t.call(s):e.get(s)),Hv=(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);},Kv=(s,e,t,i)=>(um(s,e,"write to private field"),e.set(s,t),t),Ps,is={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},dm=[...Object.values(is),chunk474VILDO_cjs.d.MEDIA_CURRENT_TIME,chunk474VILDO_cjs.d.MEDIA_DURATION,chunk474VILDO_cjs.d.MEDIA_SEEKABLE],cm=["Enter"," "],Vv=" / ",Ad=(s,{timesSep:e=Vv}={})=>{var t,i;let r=(t=s.mediaCurrentTime)!=null?t:0,[,n]=(i=s.mediaSeekable)!=null?i:[],a=0;Number.isFinite(s.mediaDuration)?a=s.mediaDuration:Number.isFinite(n)&&(a=n);let o=s.remaining?Nt(0-(a-r)):Nt(r);return s.showDuration?`${o}${e}${Nt(a)}`:o},Wv="video not loaded, unknown time.",Yv=s=>{var e;let t=s.mediaCurrentTime,[,i]=(e=s.mediaSeekable)!=null?e:[],r=null;if(Number.isFinite(s.mediaDuration)?r=s.mediaDuration:Number.isFinite(i)&&(r=i),t==null||r===null){s.setAttribute("aria-valuetext",Wv);return}let n=s.remaining?Wi(0-(r-t)):Wi(t);if(!s.showDuration){s.setAttribute("aria-valuetext",n);return}let a=Wi(r),o=`${n} of ${a}`;s.setAttribute("aria-valuetext",o);};function qv(s,e){return `
|
|
962
|
+
<slot>${Ad(e)}</slot>
|
|
963
|
+
`}var Ka=class extends dt{constructor(){super(),Hv(this,Ps,void 0),Kv(this,Ps,this.shadowRoot.querySelector("slot")),bd(this,Ps).innerHTML=`${Ad(this)}`;}static get observedAttributes(){return [...super.observedAttributes,...dm,"disabled"]}connectedCallback(){let{style:e}=chunk474VILDO_cjs.B(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","var(--media-cursor, pointer)"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",chunk474VILDO_cjs.n("playback time"));let t=i=>{let{key:r}=i;if(!cm.includes(r)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay();};this.addEventListener("keydown",i=>{let{metaKey:r,altKey:n,key:a}=i;if(r||n||!cm.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){dm.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 chunk474VILDO_cjs.F(this,is.REMAINING)}set remaining(e){chunk474VILDO_cjs.G(this,is.REMAINING,e);}get showDuration(){return chunk474VILDO_cjs.F(this,is.SHOW_DURATION)}set showDuration(e){chunk474VILDO_cjs.G(this,is.SHOW_DURATION,e);}get noToggle(){return chunk474VILDO_cjs.F(this,is.NO_TOGGLE)}set noToggle(e){chunk474VILDO_cjs.G(this,is.NO_TOGGLE,e);}get mediaDuration(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_DURATION)}set mediaDuration(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_DURATION,e);}get mediaCurrentTime(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_CURRENT_TIME,e);}get mediaSeekable(){let e=this.getAttribute(chunk474VILDO_cjs.d.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(chunk474VILDO_cjs.d.MEDIA_SEEKABLE);return}this.setAttribute(chunk474VILDO_cjs.d.MEDIA_SEEKABLE,e.join(":"));}update(){let e=Ad(this);Yv(this),e!==bd(this,Ps).innerHTML&&(bd(this,Ps).innerHTML=e);}};Ps=new WeakMap;Ka.getSlotTemplateHTML=qv;chunk474VILDO_cjs.o.customElements.get("media-time-display")||chunk474VILDO_cjs.o.customElements.define("media-time-display",Ka);var hm=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},je=(s,e,t)=>(hm(s,e,"read from private field"),e.get(s)),ri=(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);},vt=(s,e,t,i)=>(hm(s,e,"write to private field"),e.set(s,t),t),jv=(s,e,t,i)=>({set _(r){vt(s,e,r);},get _(){return je(s,e)}}),Os,Va,Fs,Zr,Wa,Ya,qa,Ns,ss,ja,za=class{constructor(e,t,i){ri(this,Os,void 0),ri(this,Va,void 0),ri(this,Fs,void 0),ri(this,Zr,void 0),ri(this,Wa,void 0),ri(this,Ya,void 0),ri(this,qa,void 0),ri(this,Ns,void 0),ri(this,ss,0),ri(this,ja,(r=performance.now())=>{vt(this,ss,requestAnimationFrame(je(this,ja))),vt(this,Zr,performance.now()-je(this,Fs));let n=1e3/this.fps;if(je(this,Zr)>n){vt(this,Fs,r-je(this,Zr)%n);let a=1e3/((r-je(this,Va))/++jv(this,Wa)._),o=(r-je(this,Ya))/1e3/this.duration,d=je(this,qa)+o*this.playbackRate;d-je(this,Os).valueAsNumber>0?vt(this,Ns,this.playbackRate/this.duration/a):(vt(this,Ns,.995*je(this,Ns)),d=je(this,Os).valueAsNumber+je(this,Ns)),this.callback(d);}}),vt(this,Os,e),this.callback=t,this.fps=i;}start(){je(this,ss)===0&&(vt(this,Fs,performance.now()),vt(this,Va,je(this,Fs)),vt(this,Wa,0),je(this,ja).call(this));}stop(){je(this,ss)!==0&&(cancelAnimationFrame(je(this,ss)),vt(this,ss,0));}update({start:e,duration:t,playbackRate:i}){let r=e-je(this,Os).valueAsNumber,n=Math.abs(t-this.duration);(r>0||r<-0.03||n>=.5)&&this.callback(e),vt(this,qa,e),vt(this,Ya,performance.now()),this.duration=t,this.playbackRate=i;}};Os=new WeakMap;Va=new WeakMap;Fs=new WeakMap;Zr=new WeakMap;Wa=new WeakMap;Ya=new WeakMap;qa=new WeakMap;Ns=new WeakMap;ss=new WeakMap;ja=new WeakMap;var xd=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Oe=(s,e,t)=>(xd(s,e,"read from private field"),t?t.call(s):e.get(s)),Ke=(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);},xt=(s,e,t,i)=>(xd(s,e,"write to private field"),e.set(s,t),t),it=(s,e,t)=>(xd(s,e,"access private method"),t),Us,rs,Za,en,Ja,Xa,tn,sn,$s,Bs,Gs,Jr,Rd,fm,_d,eo,kd,to,Dd,io,Cd,Id,mm,rn,so,Ld,gm,zv="video not loaded, unknown time.",Qv=s=>{let e=s.range,t=Wi(+pm(s)),i=Wi(+s.mediaSeekableEnd),r=t&&i?`${t} of ${i}`:zv;e.setAttribute("aria-valuetext",r);};function Xv(s){return `
|
|
964
964
|
<style>
|
|
965
965
|
:host {
|
|
966
966
|
--media-box-border-radius: 4px;
|
|
@@ -1018,7 +1018,7 @@
|
|
|
1018
1018
|
opacity: 0;
|
|
1019
1019
|
}
|
|
1020
1020
|
|
|
1021
|
-
:host(:is([${
|
|
1021
|
+
:host(:is([${chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE}], [${chunk474VILDO_cjs.d.MEDIA_PREVIEW_TIME}])[dragging]) [part~="preview-box"] {
|
|
1022
1022
|
transition-duration: var(--media-preview-transition-duration-in, .5s);
|
|
1023
1023
|
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
1024
1024
|
visibility: visible;
|
|
@@ -1026,7 +1026,7 @@
|
|
|
1026
1026
|
}
|
|
1027
1027
|
|
|
1028
1028
|
@media (hover: hover) {
|
|
1029
|
-
:host(:is([${
|
|
1029
|
+
:host(:is([${chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE}], [${chunk474VILDO_cjs.d.MEDIA_PREVIEW_TIME}]):hover) [part~="preview-box"] {
|
|
1030
1030
|
transition-duration: var(--media-preview-transition-duration-in, .5s);
|
|
1031
1031
|
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
1032
1032
|
visibility: visible;
|
|
@@ -1051,20 +1051,20 @@
|
|
|
1051
1051
|
var(--media-preview-border-radius) var(--media-preview-border-radius) 0 0);
|
|
1052
1052
|
}
|
|
1053
1053
|
|
|
1054
|
-
:host([${
|
|
1055
|
-
:host([${
|
|
1054
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE}][dragging]) media-preview-thumbnail,
|
|
1055
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE}][dragging]) ::slotted(media-preview-thumbnail) {
|
|
1056
1056
|
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
1057
1057
|
visibility: visible;
|
|
1058
1058
|
}
|
|
1059
1059
|
|
|
1060
1060
|
@media (hover: hover) {
|
|
1061
|
-
:host([${
|
|
1062
|
-
:host([${
|
|
1061
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE}]:hover) media-preview-thumbnail,
|
|
1062
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE}]:hover) ::slotted(media-preview-thumbnail) {
|
|
1063
1063
|
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
1064
1064
|
visibility: visible;
|
|
1065
1065
|
}
|
|
1066
1066
|
|
|
1067
|
-
:host([${
|
|
1067
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_PREVIEW_TIME}]:hover) {
|
|
1068
1068
|
--media-time-range-hover-display: block;
|
|
1069
1069
|
}
|
|
1070
1070
|
}
|
|
@@ -1087,8 +1087,8 @@
|
|
|
1087
1087
|
text-shadow: var(--media-preview-chapter-text-shadow, 0 0 4px rgb(0 0 0 / .75));
|
|
1088
1088
|
}
|
|
1089
1089
|
|
|
1090
|
-
:host([${
|
|
1091
|
-
:host([${
|
|
1090
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE}]) media-preview-chapter-display,
|
|
1091
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-chapter-display) {
|
|
1092
1092
|
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
1093
1093
|
border-radius: var(--media-preview-chapter-border-radius, 0);
|
|
1094
1094
|
padding: var(--media-preview-chapter-padding, 3.5px 9px 0);
|
|
@@ -1096,8 +1096,8 @@
|
|
|
1096
1096
|
min-width: 100%;
|
|
1097
1097
|
}
|
|
1098
1098
|
|
|
1099
|
-
media-preview-chapter-display[${
|
|
1100
|
-
::slotted(media-preview-chapter-display[${
|
|
1099
|
+
media-preview-chapter-display[${chunk474VILDO_cjs.d.MEDIA_PREVIEW_CHAPTER}],
|
|
1100
|
+
::slotted(media-preview-chapter-display[${chunk474VILDO_cjs.d.MEDIA_PREVIEW_CHAPTER}]) {
|
|
1101
1101
|
visibility: visible;
|
|
1102
1102
|
}
|
|
1103
1103
|
|
|
@@ -1130,15 +1130,15 @@
|
|
|
1130
1130
|
));
|
|
1131
1131
|
}
|
|
1132
1132
|
|
|
1133
|
-
:host([${
|
|
1134
|
-
:host([${
|
|
1133
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE}]) media-preview-time-display,
|
|
1134
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-time-display) {
|
|
1135
1135
|
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
1136
1136
|
border-radius: var(--media-preview-time-border-radius,
|
|
1137
1137
|
0 0 var(--media-preview-border-radius) var(--media-preview-border-radius));
|
|
1138
1138
|
min-width: 100%;
|
|
1139
1139
|
}
|
|
1140
1140
|
|
|
1141
|
-
:host([${
|
|
1141
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_PREVIEW_TIME}]:hover) {
|
|
1142
1142
|
--media-time-range-hover-display: block;
|
|
1143
1143
|
}
|
|
1144
1144
|
|
|
@@ -1163,8 +1163,8 @@
|
|
|
1163
1163
|
<div id="preview-rail">
|
|
1164
1164
|
<slot name="preview" part="box preview-box">
|
|
1165
1165
|
<media-preview-thumbnail>
|
|
1166
|
-
<template shadowrootmode="${
|
|
1167
|
-
${
|
|
1166
|
+
<template shadowrootmode="${Ha.shadowRootOptions.mode}">
|
|
1167
|
+
${Ha.getTemplateHTML({})}
|
|
1168
1168
|
</template>
|
|
1169
1169
|
</media-preview-thumbnail>
|
|
1170
1170
|
<media-preview-chapter-display></media-preview-chapter-display>
|
|
@@ -1177,7 +1177,7 @@
|
|
|
1177
1177
|
|
|
1178
1178
|
</slot>
|
|
1179
1179
|
</div>
|
|
1180
|
-
`}var Ja=(s,e=s.mediaCurrentTime)=>{let t=Number.isFinite(s.mediaSeekableStart)?s.mediaSeekableStart:0,i=Number.isFinite(s.mediaDuration)?s.mediaDuration:s.mediaSeekableEnd;if(Number.isNaN(i))return 0;let r=(e-t)/(i-t);return Math.max(0,Math.min(r,1))},Em=(s,e=s.range.valueAsNumber)=>{let t=Number.isFinite(s.mediaSeekableStart)?s.mediaSeekableStart:0,i=Number.isFinite(s.mediaDuration)?s.mediaDuration:s.mediaSeekableEnd;return Number.isNaN(i)?0:e*(i-t)+t},on=class extends Jt{constructor(){super(),Ke(this,Hs),Ke(this,Dd),Ke(this,so),Ke(this,ro),Ke(this,no),Ke(this,xd),Ke(this,an),Ke(this,Rd),Ke(this,Bs,void 0),Ke(this,ns,void 0),Ke(this,to,void 0),Ke(this,sn,void 0),Ke(this,io,void 0),Ke(this,eo,void 0),Ke(this,rn,void 0),Ke(this,nn,void 0),Ke(this,$s,void 0),Ke(this,Gs,void 0),Ke(this,Ld,i=>{this.dragging||(Ts(i)&&(this.range.valueAsNumber=i),Oe(this,Gs)||this.updateBar());}),this.shadowRoot.querySelector("#track").insertAdjacentHTML("afterbegin",'<div id="buffered" part="buffered"></div>'),Rt(this,to,this.shadowRoot.querySelectorAll('[part~="box"]')),Rt(this,io,this.shadowRoot.querySelector('[part~="preview-box"]')),Rt(this,eo,this.shadowRoot.querySelector('[part~="current-box"]'));let t=getComputedStyle(this);Rt(this,rn,parseInt(t.getPropertyValue("--media-box-padding-left"))),Rt(this,nn,parseInt(t.getPropertyValue("--media-box-padding-right"))),Rt(this,ns,new Za(this.range,Oe(this,Ld),60));}static get observedAttributes(){return [...super.observedAttributes,chunkV54NMMTT_cjs.d.MEDIA_PAUSED,chunkV54NMMTT_cjs.d.MEDIA_DURATION,chunkV54NMMTT_cjs.d.MEDIA_SEEKABLE,chunkV54NMMTT_cjs.d.MEDIA_CURRENT_TIME,chunkV54NMMTT_cjs.d.MEDIA_PREVIEW_IMAGE,chunkV54NMMTT_cjs.d.MEDIA_PREVIEW_TIME,chunkV54NMMTT_cjs.d.MEDIA_PREVIEW_CHAPTER,chunkV54NMMTT_cjs.d.MEDIA_BUFFERED,chunkV54NMMTT_cjs.d.MEDIA_PLAYBACK_RATE,chunkV54NMMTT_cjs.d.MEDIA_LOADING,chunkV54NMMTT_cjs.d.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",chunkV54NMMTT_cjs.n("seek")),it(this,Hs,tn).call(this),Rt(this,Bs,this.getRootNode()),(e=Oe(this,Bs))==null||e.addEventListener("transitionstart",this);}disconnectedCallback(){var e;super.disconnectedCallback(),it(this,Hs,tn).call(this),(e=Oe(this,Bs))==null||e.removeEventListener("transitionstart",this),Rt(this,Bs,null);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),t!=i&&(e===chunkV54NMMTT_cjs.d.MEDIA_CURRENT_TIME||e===chunkV54NMMTT_cjs.d.MEDIA_PAUSED||e===chunkV54NMMTT_cjs.d.MEDIA_ENDED||e===chunkV54NMMTT_cjs.d.MEDIA_LOADING||e===chunkV54NMMTT_cjs.d.MEDIA_DURATION||e===chunkV54NMMTT_cjs.d.MEDIA_SEEKABLE?(Oe(this,ns).update({start:Ja(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),it(this,Hs,tn).call(this),Zv(this)):e===chunkV54NMMTT_cjs.d.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===chunkV54NMMTT_cjs.d.MEDIA_DURATION||e===chunkV54NMMTT_cjs.d.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=Oe(this,$s),this.updateBar()));}get mediaChaptersCues(){return Oe(this,$s)}set mediaChaptersCues(e){var t;Rt(this,$s,e),this.updateSegments((t=Oe(this,$s))==null?void 0:t.map(i=>({start:Ja(this,i.startTime),end:Ja(this,i.endTime)})));}get mediaPaused(){return chunkV54NMMTT_cjs.G(this,chunkV54NMMTT_cjs.d.MEDIA_PAUSED)}set mediaPaused(e){chunkV54NMMTT_cjs.H(this,chunkV54NMMTT_cjs.d.MEDIA_PAUSED,e);}get mediaLoading(){return chunkV54NMMTT_cjs.G(this,chunkV54NMMTT_cjs.d.MEDIA_LOADING)}set mediaLoading(e){chunkV54NMMTT_cjs.H(this,chunkV54NMMTT_cjs.d.MEDIA_LOADING,e);}get mediaDuration(){return chunkV54NMMTT_cjs.E(this,chunkV54NMMTT_cjs.d.MEDIA_DURATION)}set mediaDuration(e){chunkV54NMMTT_cjs.F(this,chunkV54NMMTT_cjs.d.MEDIA_DURATION,e);}get mediaCurrentTime(){return chunkV54NMMTT_cjs.E(this,chunkV54NMMTT_cjs.d.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){chunkV54NMMTT_cjs.F(this,chunkV54NMMTT_cjs.d.MEDIA_CURRENT_TIME,e);}get mediaPlaybackRate(){return chunkV54NMMTT_cjs.E(this,chunkV54NMMTT_cjs.d.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){chunkV54NMMTT_cjs.F(this,chunkV54NMMTT_cjs.d.MEDIA_PLAYBACK_RATE,e);}get mediaBuffered(){let e=this.getAttribute(chunkV54NMMTT_cjs.d.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(i=>+i)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(chunkV54NMMTT_cjs.d.MEDIA_BUFFERED);return}let t=e.map(i=>i.join(":")).join(" ");this.setAttribute(chunkV54NMMTT_cjs.d.MEDIA_BUFFERED,t);}get mediaSeekable(){let e=this.getAttribute(chunkV54NMMTT_cjs.d.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(chunkV54NMMTT_cjs.d.MEDIA_SEEKABLE);return}this.setAttribute(chunkV54NMMTT_cjs.d.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 chunkV54NMMTT_cjs.I(this,chunkV54NMMTT_cjs.d.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){chunkV54NMMTT_cjs.J(this,chunkV54NMMTT_cjs.d.MEDIA_PREVIEW_IMAGE,e);}get mediaPreviewTime(){return chunkV54NMMTT_cjs.E(this,chunkV54NMMTT_cjs.d.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){chunkV54NMMTT_cjs.F(this,chunkV54NMMTT_cjs.d.MEDIA_PREVIEW_TIME,e);}get mediaEnded(){return chunkV54NMMTT_cjs.G(this,chunkV54NMMTT_cjs.d.MEDIA_ENDED)}set mediaEnded(e){chunkV54NMMTT_cjs.H(this,chunkV54NMMTT_cjs.d.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=Ja(this,a);}let{style:r}=chunkV54NMMTT_cjs.C(this.shadowRoot,"#buffered");r.setProperty("width",`${i*100}%`);}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;let t=chunkV54NMMTT_cjs.C(this.shadowRoot,"#current-rail"),i=chunkV54NMMTT_cjs.C(this.shadowRoot,'[part~="current-box"]'),r=it(this,so,Cd).call(this,Oe(this,eo)),n=it(this,ro,Md).call(this,r,this.range.valueAsNumber),a=it(this,no,wd).call(this,r,this.range.valueAsNumber);t.style.transform=`translateX(${n})`,t.style.setProperty("--_range-width",`${r.range.width}`),i.style.setProperty("--_box-shift",`${a}`),i.style.setProperty("--_box-width",`${r.box.width}px`),i.style.setProperty("visibility","initial");}handleEvent(e){switch(super.handleEvent(e),e.type){case "input":it(this,Rd,pm).call(this);break;case "pointermove":it(this,xd,gm).call(this,e);break;case "pointerup":Oe(this,Gs)&&Rt(this,Gs,false);break;case "pointerdown":Rt(this,Gs,true);break;case "pointerleave":it(this,an,ao).call(this,null);break;case "transitionstart":chunkV54NMMTT_cjs.w(e.target,this)&&setTimeout(()=>it(this,Hs,tn).call(this),0);break}}};Bs=new WeakMap;ns=new WeakMap;to=new WeakMap;sn=new WeakMap;io=new WeakMap;eo=new WeakMap;rn=new WeakMap;nn=new WeakMap;$s=new WeakMap;Gs=new WeakMap;Hs=new WeakSet;tn=function(){it(this,Dd,mm).call(this)?Oe(this,ns).start():Oe(this,ns).stop();};Dd=new WeakSet;mm=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&chunkV54NMMTT_cjs.A(this)};Ld=new WeakMap;so=new WeakSet;Cd=function(s){var e;let i=((e=this.getAttribute("bounds")?chunkV54NMMTT_cjs.x(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),r=this.range.getBoundingClientRect(),n=s.offsetWidth,a=-(r.left-i.left-n/2),o=i.right-r.left-n/2;return {box:{width:n,min:a,max:o},bounds:i,range:r}};ro=new WeakSet;Md=function(s,e){let t=`${e*100}%`,{width:i,min:r,max:n}=s.box;if(!i)return t;if(Number.isNaN(r)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${r}% + var(--media-box-padding-left))`}, ${t})`),!Number.isNaN(n)){let o=`calc(1 / var(--_range-width) * 100 * ${n}% - var(--media-box-padding-right))`;t=`min(${t}, ${o})`;}return t};no=new WeakSet;wd=function(s,e){let{width:t,min:i,max:r}=s.box,n=e*s.range.width;if(n<i+Oe(this,rn)){let a=s.range.left-s.bounds.left-Oe(this,rn);return `${n-t/2+a}px`}if(n>r-Oe(this,nn)){let a=s.bounds.right-s.range.right-Oe(this,nn);return `${n+t/2-a-s.range.width}px`}return 0};xd=new WeakSet;gm=function(s){let e=[...Oe(this,to)].some(c=>s.composedPath().includes(c));if(!this.dragging&&(e||!s.composedPath().includes(this))){it(this,an,ao).call(this,null);return}let t=this.mediaSeekableEnd;if(!t)return;let i=chunkV54NMMTT_cjs.C(this.shadowRoot,"#preview-rail"),r=chunkV54NMMTT_cjs.C(this.shadowRoot,'[part~="preview-box"]'),n=it(this,so,Cd).call(this,Oe(this,io)),a=(s.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));let o=it(this,ro,Md).call(this,n,a),l=it(this,no,wd).call(this,n,a);i.style.transform=`translateX(${o})`,i.style.setProperty("--_range-width",`${n.range.width}`),r.style.setProperty("--_box-shift",`${l}`),r.style.setProperty("--_box-width",`${n.box.width}px`);let d=Math.round(Oe(this,sn))-Math.round(a*t);Math.abs(d)<1&&a>.01&&a<.99||(Rt(this,sn,a*t),it(this,an,ao).call(this,Oe(this,sn)));};an=new WeakSet;ao=function(s){this.dispatchEvent(new chunkV54NMMTT_cjs.o.CustomEvent(chunkV54NMMTT_cjs.a.MEDIA_PREVIEW_REQUEST,{composed:true,bubbles:true,detail:s}));};Rd=new WeakSet;pm=function(){Oe(this,ns).stop();let s=Em(this);this.dispatchEvent(new chunkV54NMMTT_cjs.o.CustomEvent(chunkV54NMMTT_cjs.a.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:s}));};on.shadowRootOptions={mode:"open"};on.getContainerTemplateHTML=Jv;chunkV54NMMTT_cjs.o.customElements.get("media-time-range")||chunkV54NMMTT_cjs.o.customElements.define("media-time-range",on);var eT=1,tT=s=>s.mediaMuted?0:s.mediaVolume,iT=s=>`${Math.round(s*100)}%`,Pd=class extends Jt{static get observedAttributes(){return [...super.observedAttributes,chunkV54NMMTT_cjs.d.MEDIA_VOLUME,chunkV54NMMTT_cjs.d.MEDIA_MUTED,chunkV54NMMTT_cjs.d.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{let e=this.range.value,t=new chunkV54NMMTT_cjs.o.CustomEvent(chunkV54NMMTT_cjs.a.MEDIA_VOLUME_REQUEST,{composed:true,bubbles:true,detail:e});this.dispatchEvent(t);});}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",chunkV54NMMTT_cjs.n("volume"));}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),(e===chunkV54NMMTT_cjs.d.MEDIA_VOLUME||e===chunkV54NMMTT_cjs.d.MEDIA_MUTED)&&(this.range.valueAsNumber=tT(this),this.range.setAttribute("aria-valuetext",iT(this.range.valueAsNumber)),this.updateBar());}get mediaVolume(){return chunkV54NMMTT_cjs.E(this,chunkV54NMMTT_cjs.d.MEDIA_VOLUME,eT)}set mediaVolume(e){chunkV54NMMTT_cjs.F(this,chunkV54NMMTT_cjs.d.MEDIA_VOLUME,e);}get mediaMuted(){return chunkV54NMMTT_cjs.G(this,chunkV54NMMTT_cjs.d.MEDIA_MUTED)}set mediaMuted(e){chunkV54NMMTT_cjs.H(this,chunkV54NMMTT_cjs.d.MEDIA_MUTED,e);}get mediaVolumeUnavailable(){return chunkV54NMMTT_cjs.I(this,chunkV54NMMTT_cjs.d.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){chunkV54NMMTT_cjs.J(this,chunkV54NMMTT_cjs.d.MEDIA_VOLUME_UNAVAILABLE,e);}};chunkV54NMMTT_cjs.o.customElements.get("media-volume-range")||chunkV54NMMTT_cjs.o.customElements.define("media-volume-range",Pd);function sT(s){return `
|
|
1180
|
+
`}var Qa=(s,e=s.mediaCurrentTime)=>{let t=Number.isFinite(s.mediaSeekableStart)?s.mediaSeekableStart:0,i=Number.isFinite(s.mediaDuration)?s.mediaDuration:s.mediaSeekableEnd;if(Number.isNaN(i))return 0;let r=(e-t)/(i-t);return Math.max(0,Math.min(r,1))},pm=(s,e=s.range.valueAsNumber)=>{let t=Number.isFinite(s.mediaSeekableStart)?s.mediaSeekableStart:0,i=Number.isFinite(s.mediaDuration)?s.mediaDuration:s.mediaSeekableEnd;return Number.isNaN(i)?0:e*(i-t)+t},nn=class extends Zt{constructor(){super(),Ke(this,Gs),Ke(this,Rd),Ke(this,eo),Ke(this,to),Ke(this,io),Ke(this,Id),Ke(this,rn),Ke(this,Ld),Ke(this,Us,void 0),Ke(this,rs,void 0),Ke(this,Za,void 0),Ke(this,en,void 0),Ke(this,Ja,void 0),Ke(this,Xa,void 0),Ke(this,tn,void 0),Ke(this,sn,void 0),Ke(this,$s,void 0),Ke(this,Bs,void 0),Ke(this,_d,i=>{this.dragging||(vs(i)&&(this.range.valueAsNumber=i),Oe(this,Bs)||this.updateBar());}),this.shadowRoot.querySelector("#track").insertAdjacentHTML("afterbegin",'<div id="buffered" part="buffered"></div>'),xt(this,Za,this.shadowRoot.querySelectorAll('[part~="box"]')),xt(this,Ja,this.shadowRoot.querySelector('[part~="preview-box"]')),xt(this,Xa,this.shadowRoot.querySelector('[part~="current-box"]'));let t=getComputedStyle(this);xt(this,tn,parseInt(t.getPropertyValue("--media-box-padding-left"))),xt(this,sn,parseInt(t.getPropertyValue("--media-box-padding-right"))),xt(this,rs,new za(this.range,Oe(this,_d),60));}static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_PAUSED,chunk474VILDO_cjs.d.MEDIA_DURATION,chunk474VILDO_cjs.d.MEDIA_SEEKABLE,chunk474VILDO_cjs.d.MEDIA_CURRENT_TIME,chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE,chunk474VILDO_cjs.d.MEDIA_PREVIEW_TIME,chunk474VILDO_cjs.d.MEDIA_PREVIEW_CHAPTER,chunk474VILDO_cjs.d.MEDIA_BUFFERED,chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE,chunk474VILDO_cjs.d.MEDIA_LOADING,chunk474VILDO_cjs.d.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",chunk474VILDO_cjs.n("seek")),it(this,Gs,Jr).call(this),xt(this,Us,this.getRootNode()),(e=Oe(this,Us))==null||e.addEventListener("transitionstart",this);}disconnectedCallback(){var e;super.disconnectedCallback(),it(this,Gs,Jr).call(this),(e=Oe(this,Us))==null||e.removeEventListener("transitionstart",this),xt(this,Us,null);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),t!=i&&(e===chunk474VILDO_cjs.d.MEDIA_CURRENT_TIME||e===chunk474VILDO_cjs.d.MEDIA_PAUSED||e===chunk474VILDO_cjs.d.MEDIA_ENDED||e===chunk474VILDO_cjs.d.MEDIA_LOADING||e===chunk474VILDO_cjs.d.MEDIA_DURATION||e===chunk474VILDO_cjs.d.MEDIA_SEEKABLE?(Oe(this,rs).update({start:Qa(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),it(this,Gs,Jr).call(this),Qv(this)):e===chunk474VILDO_cjs.d.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===chunk474VILDO_cjs.d.MEDIA_DURATION||e===chunk474VILDO_cjs.d.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=Oe(this,$s),this.updateBar()));}get mediaChaptersCues(){return Oe(this,$s)}set mediaChaptersCues(e){var t;xt(this,$s,e),this.updateSegments((t=Oe(this,$s))==null?void 0:t.map(i=>({start:Qa(this,i.startTime),end:Qa(this,i.endTime)})));}get mediaPaused(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_PAUSED)}set mediaPaused(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_PAUSED,e);}get mediaLoading(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_LOADING)}set mediaLoading(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_LOADING,e);}get mediaDuration(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_DURATION)}set mediaDuration(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_DURATION,e);}get mediaCurrentTime(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_CURRENT_TIME,e);}get mediaPlaybackRate(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE,e);}get mediaBuffered(){let e=this.getAttribute(chunk474VILDO_cjs.d.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(i=>+i)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(chunk474VILDO_cjs.d.MEDIA_BUFFERED);return}let t=e.map(i=>i.join(":")).join(" ");this.setAttribute(chunk474VILDO_cjs.d.MEDIA_BUFFERED,t);}get mediaSeekable(){let e=this.getAttribute(chunk474VILDO_cjs.d.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(chunk474VILDO_cjs.d.MEDIA_SEEKABLE);return}this.setAttribute(chunk474VILDO_cjs.d.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 chunk474VILDO_cjs.H(this,chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){chunk474VILDO_cjs.I(this,chunk474VILDO_cjs.d.MEDIA_PREVIEW_IMAGE,e);}get mediaPreviewTime(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_PREVIEW_TIME,e);}get mediaEnded(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_ENDED)}set mediaEnded(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_ENDED,e);}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox();}updateBufferedBar(){var e;let t=this.mediaBuffered;if(!t.length)return;let i;if(this.mediaEnded)i=1;else {let n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,d])=>o<=n&&n<=d))!=null?e:[];i=Qa(this,a);}let{style:r}=chunk474VILDO_cjs.B(this.shadowRoot,"#buffered");r.setProperty("width",`${i*100}%`);}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;let t=chunk474VILDO_cjs.B(this.shadowRoot,"#current-rail"),i=chunk474VILDO_cjs.B(this.shadowRoot,'[part~="current-box"]'),r=it(this,eo,kd).call(this,Oe(this,Xa)),n=it(this,to,Dd).call(this,r,this.range.valueAsNumber),a=it(this,io,Cd).call(this,r,this.range.valueAsNumber);t.style.transform=`translateX(${n})`,t.style.setProperty("--_range-width",`${r.range.width}`),i.style.setProperty("--_box-shift",`${a}`),i.style.setProperty("--_box-width",`${r.box.width}px`),i.style.setProperty("visibility","initial");}handleEvent(e){switch(super.handleEvent(e),e.type){case "input":it(this,Ld,gm).call(this);break;case "pointermove":it(this,Id,mm).call(this,e);break;case "pointerup":Oe(this,Bs)&&xt(this,Bs,false);break;case "pointerdown":xt(this,Bs,true);break;case "pointerleave":it(this,rn,so).call(this,null);break;case "transitionstart":chunk474VILDO_cjs.v(e.target,this)&&setTimeout(()=>it(this,Gs,Jr).call(this),0);break}}};Us=new WeakMap;rs=new WeakMap;Za=new WeakMap;en=new WeakMap;Ja=new WeakMap;Xa=new WeakMap;tn=new WeakMap;sn=new WeakMap;$s=new WeakMap;Bs=new WeakMap;Gs=new WeakSet;Jr=function(){it(this,Rd,fm).call(this)?Oe(this,rs).start():Oe(this,rs).stop();};Rd=new WeakSet;fm=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&chunk474VILDO_cjs.z(this)};_d=new WeakMap;eo=new WeakSet;kd=function(s){var e;let i=((e=this.getAttribute("bounds")?chunk474VILDO_cjs.w(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),r=this.range.getBoundingClientRect(),n=s.offsetWidth,a=-(r.left-i.left-n/2),o=i.right-r.left-n/2;return {box:{width:n,min:a,max:o},bounds:i,range:r}};to=new WeakSet;Dd=function(s,e){let t=`${e*100}%`,{width:i,min:r,max:n}=s.box;if(!i)return t;if(Number.isNaN(r)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${r}% + var(--media-box-padding-left))`}, ${t})`),!Number.isNaN(n)){let o=`calc(1 / var(--_range-width) * 100 * ${n}% - var(--media-box-padding-right))`;t=`min(${t}, ${o})`;}return t};io=new WeakSet;Cd=function(s,e){let{width:t,min:i,max:r}=s.box,n=e*s.range.width;if(n<i+Oe(this,tn)){let a=s.range.left-s.bounds.left-Oe(this,tn);return `${n-t/2+a}px`}if(n>r-Oe(this,sn)){let a=s.bounds.right-s.range.right-Oe(this,sn);return `${n+t/2-a-s.range.width}px`}return 0};Id=new WeakSet;mm=function(s){let e=[...Oe(this,Za)].some(c=>s.composedPath().includes(c));if(!this.dragging&&(e||!s.composedPath().includes(this))){it(this,rn,so).call(this,null);return}let t=this.mediaSeekableEnd;if(!t)return;let i=chunk474VILDO_cjs.B(this.shadowRoot,"#preview-rail"),r=chunk474VILDO_cjs.B(this.shadowRoot,'[part~="preview-box"]'),n=it(this,eo,kd).call(this,Oe(this,Ja)),a=(s.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));let o=it(this,to,Dd).call(this,n,a),d=it(this,io,Cd).call(this,n,a);i.style.transform=`translateX(${o})`,i.style.setProperty("--_range-width",`${n.range.width}`),r.style.setProperty("--_box-shift",`${d}`),r.style.setProperty("--_box-width",`${n.box.width}px`);let l=Math.round(Oe(this,en))-Math.round(a*t);Math.abs(l)<1&&a>.01&&a<.99||(xt(this,en,a*t),it(this,rn,so).call(this,Oe(this,en)));};rn=new WeakSet;so=function(s){this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_PREVIEW_REQUEST,{composed:true,bubbles:true,detail:s}));};Ld=new WeakSet;gm=function(){Oe(this,rs).stop();let s=pm(this);this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_SEEK_REQUEST,{composed:true,bubbles:true,detail:s}));};nn.shadowRootOptions={mode:"open"};nn.getContainerTemplateHTML=Xv;chunk474VILDO_cjs.o.customElements.get("media-time-range")||chunk474VILDO_cjs.o.customElements.define("media-time-range",nn);var Zv=1,Jv=s=>s.mediaMuted?0:s.mediaVolume,eT=s=>`${Math.round(s*100)}%`,Md=class extends Zt{static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_VOLUME,chunk474VILDO_cjs.d.MEDIA_MUTED,chunk474VILDO_cjs.d.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{let e=this.range.value,t=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_VOLUME_REQUEST,{composed:true,bubbles:true,detail:e});this.dispatchEvent(t);});}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",chunk474VILDO_cjs.n("volume"));}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),(e===chunk474VILDO_cjs.d.MEDIA_VOLUME||e===chunk474VILDO_cjs.d.MEDIA_MUTED)&&(this.range.valueAsNumber=Jv(this),this.range.setAttribute("aria-valuetext",eT(this.range.valueAsNumber)),this.updateBar());}get mediaVolume(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_VOLUME,Zv)}set mediaVolume(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_VOLUME,e);}get mediaMuted(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_MUTED)}set mediaMuted(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_MUTED,e);}get mediaVolumeUnavailable(){return chunk474VILDO_cjs.H(this,chunk474VILDO_cjs.d.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){chunk474VILDO_cjs.I(this,chunk474VILDO_cjs.d.MEDIA_VOLUME_UNAVAILABLE,e);}};chunk474VILDO_cjs.o.customElements.get("media-volume-range")||chunk474VILDO_cjs.o.customElements.define("media-volume-range",Md);function tT(s){return `
|
|
1181
1181
|
<style>
|
|
1182
1182
|
:host {
|
|
1183
1183
|
min-width: 4ch;
|
|
@@ -1193,7 +1193,7 @@
|
|
|
1193
1193
|
display: none;
|
|
1194
1194
|
}
|
|
1195
1195
|
|
|
1196
|
-
:host([${
|
|
1196
|
+
:host([${chunk474VILDO_cjs.d.MEDIA_LOOP}]) #checked-indicator {
|
|
1197
1197
|
display: block;
|
|
1198
1198
|
}
|
|
1199
1199
|
</style>
|
|
@@ -1206,7 +1206,7 @@
|
|
|
1206
1206
|
<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"/>
|
|
1207
1207
|
</svg>
|
|
1208
1208
|
</div>
|
|
1209
|
-
`}function
|
|
1209
|
+
`}function iT(){return chunk474VILDO_cjs.n("Loop")}var an=class extends chunk474VILDO_cjs.J{constructor(){super(...arguments),this.container=null;}static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_LOOP]}connectedCallback(){var e;super.connectedCallback(),this.container=((e=this.shadowRoot)==null?void 0:e.querySelector("#icon"))||null,this.container&&(this.container.textContent=chunk474VILDO_cjs.n("Loop"));}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunk474VILDO_cjs.d.MEDIA_LOOP&&this.container&&this.setAttribute("aria-checked",this.mediaLoop?"true":"false");}get mediaLoop(){return chunk474VILDO_cjs.F(this,chunk474VILDO_cjs.d.MEDIA_LOOP)}set mediaLoop(e){chunk474VILDO_cjs.G(this,chunk474VILDO_cjs.d.MEDIA_LOOP,e);}handleClick(){let e=!this.mediaLoop,t=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_LOOP_REQUEST,{composed:true,bubbles:true,detail:e});this.dispatchEvent(t);}};an.getSlotTemplateHTML=tT;an.getTooltipContentHTML=iT;chunk474VILDO_cjs.o.customElements.get("media-loop-button")||chunk474VILDO_cjs.o.customElements.define("media-loop-button",an);var Ud=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ni=(s,e,t)=>(Ud(s,e,"read from private field"),t?t.call(s):e.get(s)),Ti=(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);},wd=(s,e,t,i)=>(Ud(s,e,"write to private field"),e.set(s,t),t),Bt=(s,e,t)=>(Ud(s,e,"access private method"),t),ro,ln,Pd,Em,ao,$d,Bd,vm,ai,Hs,dn,Od,Tm,no,Fd;function sT(s){return `
|
|
1210
1210
|
<style>
|
|
1211
1211
|
:host {
|
|
1212
1212
|
transition: var(--media-menu-item-transition,
|
|
@@ -1324,8 +1324,8 @@
|
|
|
1324
1324
|
${this.getSuffixSlotInnerHTML(s)}
|
|
1325
1325
|
</slot>
|
|
1326
1326
|
<slot name="submenu"></slot>
|
|
1327
|
-
`}function
|
|
1328
|
-
${
|
|
1327
|
+
`}function rT(s){return ""}var Rt={TYPE:"type",VALUE:"value",CHECKED:"checked",DISABLED:"disabled"},Tt=class extends chunk474VILDO_cjs.o.HTMLElement{constructor(){if(super(),Ti(this,Pd),Ti(this,ao),Ti(this,Bd),Ti(this,Hs),Ti(this,Od),Ti(this,no),Ti(this,ro,false),Ti(this,ln,void 0),Ti(this,ai,()=>{var e,t;this.submenuElement.items&&this.setAttribute("submenusize",`${this.submenuElement.items.length}`);let i=this.shadowRoot.querySelector('slot[name="description"]'),r=(e=this.submenuElement.checkedItems)==null?void 0:e[0],n=(t=r?.dataset.description)!=null?t:r?.text,a=chunk474VILDO_cjs.p.createElement("span");a.textContent=n??"",i.replaceChildren(a);}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=chunk474VILDO_cjs.q(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e);}this.shadowRoot.addEventListener("slotchange",this);}static get observedAttributes(){return [Rt.TYPE,Rt.DISABLED,Rt.CHECKED,Rt.VALUE]}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),on(this)&&!this.hasAttribute("aria-checked")&&this.setAttribute("aria-checked","false"),this.addEventListener("click",this),this.addEventListener("keydown",this);}disable(){this.removeAttribute("tabindex"),this.removeEventListener("click",this),this.removeEventListener("keydown",this),this.removeEventListener("keyup",this);}handleEvent(e){switch(e.type){case "slotchange":Bt(this,Pd,Em).call(this,e);break;case "click":this.handleClick(e);break;case "keydown":Bt(this,Od,Tm).call(this,e);break;case "keyup":Bt(this,Hs,dn).call(this,e);break}}attributeChangedCallback(e,t,i){e===Rt.CHECKED&&on(this)&&!ni(this,ro)?this.setAttribute("aria-checked",i!=null?"true":"false"):e===Rt.TYPE&&i!==t?this.role="menuitem"+i:e===Rt.DISABLED&&i!==t&&(i==null?this.enable():this.disable());}connectedCallback(){this.hasAttribute(Rt.DISABLED)||this.enable(),this.role="menuitem"+this.type,wd(this,ln,Nd(this,this.parentNode)),Bt(this,no,Fd).call(this),this.submenuElement&&Bt(this,ao,$d).call(this);}disconnectedCallback(){this.disable(),Bt(this,no,Fd).call(this),wd(this,ln,null);}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`);}get invokeTargetElement(){var e;return this.invokeTarget?(e=chunk474VILDO_cjs.y(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):this.submenuElement}get submenuElement(){return this.shadowRoot.querySelector('slot[name="submenu"]').assignedElements({flatten:true})[0]}get type(){var e;return (e=this.getAttribute(Rt.TYPE))!=null?e:""}set type(e){this.setAttribute(Rt.TYPE,`${e}`);}get value(){var e;return (e=this.getAttribute(Rt.VALUE))!=null?e:this.text}set value(e){this.setAttribute(Rt.VALUE,e);}get text(){var e;return ((e=this.textContent)!=null?e:"").trim()}get checked(){if(on(this))return this.getAttribute("aria-checked")==="true"}set checked(e){on(this)&&(wd(this,ro,true),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"));}handleClick(e){on(this)||this.invokeTargetElement&&chunk474VILDO_cjs.v(this,e.target)&&this.invokeTargetElement.dispatchEvent(new chunk474VILDO_cjs.K({relatedTarget:this}));}get keysUsed(){return ["Enter"," "]}};ro=new WeakMap;ln=new WeakMap;Pd=new WeakSet;Em=function(s){let e=s.target;if(!e?.name)for(let i of e.assignedNodes({flatten:true}))i instanceof Text&&i.textContent.trim()===""&&i.remove();e.name==="submenu"&&(this.submenuElement?Bt(this,ao,$d).call(this):Bt(this,Bd,vm).call(this));};ao=new WeakSet;$d=async function(){this.setAttribute("aria-haspopup","menu"),this.setAttribute("aria-expanded",`${!this.submenuElement.hidden}`),this.submenuElement.addEventListener("change",ni(this,ai)),this.submenuElement.addEventListener("addmenuitem",ni(this,ai)),this.submenuElement.addEventListener("removemenuitem",ni(this,ai)),ni(this,ai).call(this);};Bd=new WeakSet;vm=function(){this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.submenuElement.removeEventListener("change",ni(this,ai)),this.submenuElement.removeEventListener("addmenuitem",ni(this,ai)),this.submenuElement.removeEventListener("removemenuitem",ni(this,ai)),ni(this,ai).call(this);};ai=new WeakMap;Hs=new WeakSet;dn=function(s){let{key:e}=s;if(!this.keysUsed.includes(e)){this.removeEventListener("keyup",Bt(this,Hs,dn));return}this.handleClick(s);};Od=new WeakSet;Tm=function(s){let{metaKey:e,altKey:t,key:i}=s;if(e||t||!this.keysUsed.includes(i)){this.removeEventListener("keyup",Bt(this,Hs,dn));return}this.addEventListener("keyup",Bt(this,Hs,dn),{once:true});};no=new WeakSet;Fd=function(){var s;let e=(s=ni(this,ln))==null?void 0:s.radioGroupItems;if(!e)return;let t=e.filter(i=>i.getAttribute("aria-checked")==="true").pop();t||(t=e[0]);for(let i of e)i.setAttribute("aria-checked","false");t?.setAttribute("aria-checked","true");};Tt.shadowRootOptions={mode:"open"};Tt.getTemplateHTML=sT;Tt.getSuffixSlotInnerHTML=rT;function on(s){return s.type==="radio"||s.type==="checkbox"}function Nd(s,e){if(!s)return null;let{host:t}=s.getRootNode();return !e&&t?Nd(s,t):e?.items?e:Nd(e,e?.parentNode)}chunk474VILDO_cjs.o.customElements.get("media-chrome-menu-item")||chunk474VILDO_cjs.o.customElements.define("media-chrome-menu-item",Tt);function nT(s){return `
|
|
1328
|
+
${chunkLVGLIRQU_cjs.e.getTemplateHTML(s)}
|
|
1329
1329
|
<style>
|
|
1330
1330
|
:host {
|
|
1331
1331
|
--_menu-bg: rgb(20 20 30 / .8);
|
|
@@ -1359,8 +1359,8 @@
|
|
|
1359
1359
|
--media-settings-menu-item-opacity: 0;
|
|
1360
1360
|
}
|
|
1361
1361
|
</style>
|
|
1362
|
-
`}var
|
|
1363
|
-
${
|
|
1362
|
+
`}var cn=class extends chunkLVGLIRQU_cjs.e{get anchorElement(){return this.anchor!=="auto"?super.anchorElement:chunk474VILDO_cjs.r(this).querySelector("media-settings-menu-button")}};cn.getTemplateHTML=nT;chunk474VILDO_cjs.o.customElements.get("media-settings-menu")||chunk474VILDO_cjs.o.customElements.define("media-settings-menu",cn);function aT(s){return `
|
|
1363
|
+
${Tt.getTemplateHTML.call(this,s)}
|
|
1364
1364
|
<style>
|
|
1365
1365
|
slot:not([name="submenu"]) {
|
|
1366
1366
|
opacity: var(--media-settings-menu-item-opacity, var(--media-menu-item-opacity));
|
|
@@ -1370,11 +1370,11 @@
|
|
|
1370
1370
|
background: transparent;
|
|
1371
1371
|
}
|
|
1372
1372
|
</style>
|
|
1373
|
-
`}function
|
|
1373
|
+
`}function oT(s){return `
|
|
1374
1374
|
<svg aria-hidden="true" viewBox="0 0 20 24">
|
|
1375
1375
|
<path d="m8.12 17.585-.742-.669 4.2-4.665-4.2-4.666.743-.669 4.803 5.335-4.803 5.334Z"/>
|
|
1376
1376
|
</svg>
|
|
1377
|
-
`}var
|
|
1377
|
+
`}var ns=class extends Tt{};ns.shadowRootOptions={mode:"open"};ns.getTemplateHTML=aT;ns.getSuffixSlotInnerHTML=oT;chunk474VILDO_cjs.o.customElements.get("media-settings-menu-item")||chunk474VILDO_cjs.o.customElements.define("media-settings-menu-item",ns);function lT(){return `
|
|
1378
1378
|
<style>
|
|
1379
1379
|
:host([aria-expanded="true"]) slot[name=tooltip] {
|
|
1380
1380
|
display: none;
|
|
@@ -1385,47 +1385,23 @@
|
|
|
1385
1385
|
<path d="M4.5 14.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z"/>
|
|
1386
1386
|
</svg>
|
|
1387
1387
|
</slot>
|
|
1388
|
-
`}function
|
|
1388
|
+
`}function dT(){return chunk474VILDO_cjs.n("Settings")}var Ks=class extends chunk474VILDO_cjs.M{static get observedAttributes(){return [...super.observedAttributes,"target"]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",chunk474VILDO_cjs.n("settings"));}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:chunk474VILDO_cjs.r(this).querySelector("media-settings-menu")}};Ks.getSlotTemplateHTML=lT;Ks.getTooltipContentHTML=dT;chunk474VILDO_cjs.o.customElements.get("media-settings-menu-button")||chunk474VILDO_cjs.o.customElements.define("media-settings-menu-button",Ks);var Vd=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ym=(s,e,t)=>(Vd(s,e,"read from private field"),t?t.call(s):e.get(s)),oo=(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);},Gd=(s,e,t,i)=>(Vd(s,e,"write to private field"),e.set(s,t),t),lo=(s,e,t)=>(Vd(s,e,"access private method"),t),un,ho,co,Hd,uo,Kd,fo=class extends chunkLVGLIRQU_cjs.e{constructor(){super(...arguments),oo(this,co),oo(this,uo),oo(this,un,[]),oo(this,ho,void 0);}static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_AUDIO_TRACK_LIST,chunk474VILDO_cjs.d.MEDIA_AUDIO_TRACK_ENABLED,chunk474VILDO_cjs.d.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunk474VILDO_cjs.d.MEDIA_AUDIO_TRACK_ENABLED&&t!==i?this.value=i:e===chunk474VILDO_cjs.d.MEDIA_AUDIO_TRACK_LIST&&t!==i&&(Gd(this,un,qh(i??"")),lo(this,co,Hd).call(this));}connectedCallback(){super.connectedCallback(),this.addEventListener("change",lo(this,uo,Kd));}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",lo(this,uo,Kd));}get anchorElement(){var e;return this.anchor!=="auto"?super.anchorElement:(e=chunk474VILDO_cjs.r(this))==null?void 0:e.querySelector("media-audio-track-menu-button")}get mediaAudioTrackList(){return ym(this,un)}set mediaAudioTrackList(e){Gd(this,un,e),lo(this,co,Hd).call(this);}get mediaAudioTrackEnabled(){var e;return (e=chunk474VILDO_cjs.H(this,chunk474VILDO_cjs.d.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){chunk474VILDO_cjs.I(this,chunk474VILDO_cjs.d.MEDIA_AUDIO_TRACK_ENABLED,e);}};un=new WeakMap;ho=new WeakMap;co=new WeakSet;Hd=function(){if(ym(this,ho)===JSON.stringify(this.mediaAudioTrackList))return;Gd(this,ho,JSON.stringify(this.mediaAudioTrackList));let s=this.mediaAudioTrackList;this.defaultSlot.textContent="",s.sort((e,t)=>e.id.localeCompare(t.id,void 0,{numeric:true}));for(let e of s){let t=this.formatMenuItemText(e.label,e),i=chunkLVGLIRQU_cjs.c({type:"radio",text:t,value:`${e.id}`,checked:e.enabled});i.prepend(chunkLVGLIRQU_cjs.d(this,"checked-indicator")),this.defaultSlot.append(i);}};uo=new WeakSet;Kd=function(){if(this.value==null)return;let s=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_AUDIO_TRACK_REQUEST,{composed:true,bubbles:true,detail:this.value});this.dispatchEvent(s);};chunk474VILDO_cjs.o.customElements.get("media-audio-track-menu")||chunk474VILDO_cjs.o.customElements.define("media-audio-track-menu",fo);var cT=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1389
1389
|
<path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/>
|
|
1390
1390
|
<path d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0Z"/>
|
|
1391
|
-
</svg>`;function
|
|
1391
|
+
</svg>`;function uT(){return `
|
|
1392
1392
|
<style>
|
|
1393
1393
|
:host([aria-expanded="true"]) slot[name=tooltip] {
|
|
1394
1394
|
display: none;
|
|
1395
1395
|
}
|
|
1396
1396
|
</style>
|
|
1397
|
-
<slot name="icon">${
|
|
1398
|
-
`}function
|
|
1397
|
+
<slot name="icon">${cT}</slot>
|
|
1398
|
+
`}function hT(){return chunk474VILDO_cjs.n("Audio")}var Sm=s=>{let e=chunk474VILDO_cjs.n("Audio");s.setAttribute("aria-label",e);},Vs=class extends chunk474VILDO_cjs.M{static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_AUDIO_TRACK_ENABLED,chunk474VILDO_cjs.d.MEDIA_AUDIO_TRACK_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),Sm(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunk474VILDO_cjs.d.MEDIA_LANG&&Sm(this);}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=chunk474VILDO_cjs.r(this))==null?void 0:e.querySelector("media-audio-track-menu")}get mediaAudioTrackEnabled(){var e;return (e=chunk474VILDO_cjs.H(this,chunk474VILDO_cjs.d.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){chunk474VILDO_cjs.I(this,chunk474VILDO_cjs.d.MEDIA_AUDIO_TRACK_ENABLED,e);}};Vs.getSlotTemplateHTML=uT;Vs.getTooltipContentHTML=hT;chunk474VILDO_cjs.o.customElements.get("media-audio-track-menu-button")||chunk474VILDO_cjs.o.customElements.define("media-audio-track-menu-button",Vs);var jd=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},fT=(s,e,t)=>(jd(s,e,"read from private field"),e.get(s)),Wd=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},mT=(s,e,t,i)=>(jd(s,e,"write to private field"),e.set(s,t),t),mo=(s,e,t)=>(jd(s,e,"access private method"),t),Eo,go,Yd,po,qd,gT=`
|
|
1399
1399
|
<svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">
|
|
1400
1400
|
<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"/>
|
|
1401
|
-
</svg>`;function
|
|
1402
|
-
${
|
|
1403
|
-
<slot name="captions-indicator" hidden>${
|
|
1404
|
-
`}var
|
|
1405
|
-
<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"/>
|
|
1406
|
-
</svg>`,yT=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
1407
|
-
<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"/>
|
|
1408
|
-
</svg>`;function ST(){return `
|
|
1409
|
-
<style>
|
|
1410
|
-
:host([data-captions-enabled="true"]) slot[name=off] {
|
|
1411
|
-
display: none !important;
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
:host(:not([data-captions-enabled="true"])) slot[name=on] {
|
|
1416
|
-
display: none !important;
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
:host([aria-expanded="true"]) slot[name=tooltip] {
|
|
1420
|
-
display: none;
|
|
1421
|
-
}
|
|
1422
|
-
</style>
|
|
1423
|
-
|
|
1424
|
-
<slot name="icon">
|
|
1425
|
-
<slot name="on">${TT}</slot>
|
|
1426
|
-
<slot name="off">${yT}</slot>
|
|
1427
|
-
</slot>
|
|
1428
|
-
`}function bT(){return chunkV54NMMTT_cjs.n("Captions")}var Im=s=>{s.setAttribute("data-captions-enabled",ca(s).toString());},Lm=s=>{s.setAttribute("aria-label",chunkV54NMMTT_cjs.n("closed captions"));},Ys=class extends chunkV54NMMTT_cjs.P{static get observedAttributes(){return [...super.observedAttributes,chunkV54NMMTT_cjs.d.MEDIA_SUBTITLES_LIST,chunkV54NMMTT_cjs.d.MEDIA_SUBTITLES_SHOWING,chunkV54NMMTT_cjs.d.MEDIA_LANG]}connectedCallback(){super.connectedCallback(),Lm(this),Im(this);}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunkV54NMMTT_cjs.d.MEDIA_SUBTITLES_SHOWING?Im(this):e===chunkV54NMMTT_cjs.d.MEDIA_LANG&&Lm(this);}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=chunkV54NMMTT_cjs.t(this))==null?void 0:e.querySelector("media-captions-menu")}get mediaSubtitlesList(){return xm(this,chunkV54NMMTT_cjs.d.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Rm(this,chunkV54NMMTT_cjs.d.MEDIA_SUBTITLES_LIST,e);}get mediaSubtitlesShowing(){return xm(this,chunkV54NMMTT_cjs.d.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Rm(this,chunkV54NMMTT_cjs.d.MEDIA_SUBTITLES_SHOWING,e);}};Ys.getSlotTemplateHTML=ST;Ys.getTooltipContentHTML=bT;var xm=(s,e)=>{let t=s.getAttribute(e);return t?qi(t):[]},Rm=(s,e,t)=>{if(!t?.length){s.removeAttribute(e);return}let i=vi(t);s.getAttribute(e)!==i&&s.setAttribute(e,i);};chunkV54NMMTT_cjs.o.customElements.get("media-captions-menu-button")||chunkV54NMMTT_cjs.o.customElements.define("media-captions-menu-button",Ys);var km=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},js=(s,e,t)=>(km(s,e,"read from private field"),t?t.call(s):e.get(s)),Xd=(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);},qs=(s,e,t)=>(km(s,e,"access private method"),t),Oi,zs,gn,So,Jd,Zd={RATES:"rates"},bo=class extends chunkV54NMMTT_cjs.O{constructor(){super(),Xd(this,zs),Xd(this,So),Xd(this,Oi,new Di(this,Zd.RATES,{defaultValue:Td})),qs(this,zs,gn).call(this);}static get observedAttributes(){return [...super.observedAttributes,chunkV54NMMTT_cjs.d.MEDIA_PLAYBACK_RATE,Zd.RATES]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunkV54NMMTT_cjs.d.MEDIA_PLAYBACK_RATE&&t!=i?(this.value=i,qs(this,zs,gn).call(this)):e===Zd.RATES&&t!=i&&(js(this,Oi).value=i,qs(this,zs,gn).call(this));}connectedCallback(){super.connectedCallback(),this.addEventListener("change",qs(this,So,Jd));}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",qs(this,So,Jd));}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:chunkV54NMMTT_cjs.t(this).querySelector("media-playback-rate-menu-button")}get rates(){return js(this,Oi)}set rates(e){e?Array.isArray(e)?js(this,Oi).value=e.join(" "):typeof e=="string"&&(js(this,Oi).value=e):js(this,Oi).value="",qs(this,zs,gn).call(this);}get mediaPlaybackRate(){return chunkV54NMMTT_cjs.E(this,chunkV54NMMTT_cjs.d.MEDIA_PLAYBACK_RATE,is)}set mediaPlaybackRate(e){chunkV54NMMTT_cjs.F(this,chunkV54NMMTT_cjs.d.MEDIA_PLAYBACK_RATE,e);}};Oi=new WeakMap;zs=new WeakSet;gn=function(){this.defaultSlot.textContent="";let s=this.mediaPlaybackRate,e=new Set(Array.from(js(this,Oi)).map(i=>Number(i)));s>0&&!e.has(s)&&e.add(s);let t=Array.from(e).sort((i,r)=>i-r);for(let i of t){let r=chunkV54NMMTT_cjs.M({type:"radio",text:this.formatMenuItemText(`${i}x`,i),value:i.toString(),checked:s===i});r.prepend(chunkV54NMMTT_cjs.N(this,"checked-indicator")),this.defaultSlot.append(r);}};So=new WeakSet;Jd=function(){if(!this.value)return;let s=new chunkV54NMMTT_cjs.o.CustomEvent(chunkV54NMMTT_cjs.a.MEDIA_PLAYBACK_RATE_REQUEST,{composed:true,bubbles:true,detail:this.value});this.dispatchEvent(s);};chunkV54NMMTT_cjs.o.customElements.get("media-playback-rate-menu")||chunkV54NMMTT_cjs.o.customElements.define("media-playback-rate-menu",bo);var Ao=1;function AT(s){return `
|
|
1401
|
+
</svg>`;function pT(s){return `
|
|
1402
|
+
${chunkLVGLIRQU_cjs.e.getTemplateHTML(s)}
|
|
1403
|
+
<slot name="captions-indicator" hidden>${gT}</slot>
|
|
1404
|
+
`}var hn=class extends chunkLVGLIRQU_cjs.e{constructor(){super(...arguments),Wd(this,go),Wd(this,po),Wd(this,Eo,void 0);}static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_SUBTITLES_LIST,chunk474VILDO_cjs.d.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunk474VILDO_cjs.d.MEDIA_SUBTITLES_LIST&&t!==i?mo(this,go,Yd).call(this):e===chunk474VILDO_cjs.d.MEDIA_SUBTITLES_SHOWING&&t!==i&&(this.value=i||"",mo(this,go,Yd).call(this));}connectedCallback(){super.connectedCallback(),this.addEventListener("change",mo(this,po,qd));}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",mo(this,po,qd));}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:chunk474VILDO_cjs.r(this).querySelector("media-captions-menu-button")}get mediaSubtitlesList(){return bm(this,chunk474VILDO_cjs.d.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Am(this,chunk474VILDO_cjs.d.MEDIA_SUBTITLES_LIST,e);}get mediaSubtitlesShowing(){return bm(this,chunk474VILDO_cjs.d.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Am(this,chunk474VILDO_cjs.d.MEDIA_SUBTITLES_SHOWING,e);}};Eo=new WeakMap;go=new WeakSet;Yd=function(){var s;let e=fT(this,Eo)!==JSON.stringify(this.mediaSubtitlesList),t=this.value!==this.getAttribute(chunk474VILDO_cjs.d.MEDIA_SUBTITLES_SHOWING);if(!e&&!t)return;mT(this,Eo,JSON.stringify(this.mediaSubtitlesList)),this.defaultSlot.textContent="";let i=!this.value,r=chunkLVGLIRQU_cjs.c({type:"radio",text:this.formatMenuItemText(chunk474VILDO_cjs.n("Off")),value:"off",checked:i});r.prepend(chunkLVGLIRQU_cjs.d(this,"checked-indicator")),this.defaultSlot.append(r);let n=this.mediaSubtitlesList;for(let a of n){let o=chunkLVGLIRQU_cjs.c({type:"radio",text:this.formatMenuItemText(a.label,a),value:chunk3BAQWQNY_cjs.c(a),checked:this.value==chunk3BAQWQNY_cjs.c(a)});o.prepend(chunkLVGLIRQU_cjs.d(this,"checked-indicator")),((s=a.kind)!=null?s:"subs")==="captions"&&o.append(chunkLVGLIRQU_cjs.d(this,"captions-indicator")),this.defaultSlot.append(o);}};po=new WeakSet;qd=function(){let s=this.mediaSubtitlesShowing,e=this.getAttribute(chunk474VILDO_cjs.d.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(s?.length&&t&&this.dispatchEvent(new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:true,bubbles:true,detail:s})),!this.value||!t)return;let i=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:true,bubbles:true,detail:this.value});this.dispatchEvent(i);};hn.getTemplateHTML=pT;var bm=(s,e)=>{let t=s.getAttribute(e);return t?chunk3BAQWQNY_cjs.a(t):[]},Am=(s,e,t)=>{if(!t?.length){s.removeAttribute(e);return}let i=chunk3BAQWQNY_cjs.d(t);s.getAttribute(e)!==i&&s.setAttribute(e,i);};chunk474VILDO_cjs.o.customElements.get("media-captions-menu")||chunk474VILDO_cjs.o.customElements.define("media-captions-menu",hn);var _m=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Ys=(s,e,t)=>(_m(s,e,"read from private field"),t?t.call(s):e.get(s)),zd=(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);},Ws=(s,e,t)=>(_m(s,e,"access private method"),t),Pi,qs,fn,vo,Xd,Qd={RATES:"rates"},To=class extends chunkLVGLIRQU_cjs.e{constructor(){super(),zd(this,qs),zd(this,vo),zd(this,Pi,new ki(this,Qd.RATES,{defaultValue:Ed})),Ws(this,qs,fn).call(this);}static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE,Qd.RATES]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE&&t!=i?(this.value=i,Ws(this,qs,fn).call(this)):e===Qd.RATES&&t!=i&&(Ys(this,Pi).value=i,Ws(this,qs,fn).call(this));}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Ws(this,vo,Xd));}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Ws(this,vo,Xd));}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:chunk474VILDO_cjs.r(this).querySelector("media-playback-rate-menu-button")}get rates(){return Ys(this,Pi)}set rates(e){e?Array.isArray(e)?Ys(this,Pi).value=e.join(" "):typeof e=="string"&&(Ys(this,Pi).value=e):Ys(this,Pi).value="",Ws(this,qs,fn).call(this);}get mediaPlaybackRate(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE,ts)}set mediaPlaybackRate(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE,e);}};Pi=new WeakMap;qs=new WeakSet;fn=function(){this.defaultSlot.textContent="";let s=this.mediaPlaybackRate,e=new Set(Array.from(Ys(this,Pi)).map(i=>Number(i)));s>0&&!e.has(s)&&e.add(s);let t=Array.from(e).sort((i,r)=>i-r);for(let i of t){let r=chunkLVGLIRQU_cjs.c({type:"radio",text:this.formatMenuItemText(`${i}x`,i),value:i.toString(),checked:s===i});r.prepend(chunkLVGLIRQU_cjs.d(this,"checked-indicator")),this.defaultSlot.append(r);}};vo=new WeakSet;Xd=function(){if(!this.value)return;let s=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_PLAYBACK_RATE_REQUEST,{composed:true,bubbles:true,detail:this.value});this.dispatchEvent(s);};chunk474VILDO_cjs.o.customElements.get("media-playback-rate-menu")||chunk474VILDO_cjs.o.customElements.define("media-playback-rate-menu",To);var yo=1;function ET(s){return `
|
|
1429
1405
|
<style>
|
|
1430
1406
|
:host {
|
|
1431
1407
|
min-width: 5ch;
|
|
@@ -1440,18 +1416,18 @@
|
|
|
1440
1416
|
display: none;
|
|
1441
1417
|
}
|
|
1442
1418
|
</style>
|
|
1443
|
-
<slot name="icon">${s.mediaplaybackrate||
|
|
1444
|
-
`}function
|
|
1419
|
+
<slot name="icon">${s.mediaplaybackrate||yo}x</slot>
|
|
1420
|
+
`}function vT(){return chunk474VILDO_cjs.n("Playback rate")}var js=class extends chunk474VILDO_cjs.M{static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE]}constructor(){var e;super(),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${(e=this.mediaPlaybackRate)!=null?e:yo}x`;}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE){let r=i?+i:Number.NaN,n=Number.isNaN(r)?yo:r;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",chunk474VILDO_cjs.n("Playback rate {playbackRate}",{playbackRate:n}));}}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:chunk474VILDO_cjs.r(this).querySelector("media-playback-rate-menu")}get mediaPlaybackRate(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE,yo)}set mediaPlaybackRate(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_PLAYBACK_RATE,e);}};js.getSlotTemplateHTML=ET;js.getTooltipContentHTML=vT;chunk474VILDO_cjs.o.customElements.get("media-playback-rate-menu-button")||chunk474VILDO_cjs.o.customElements.define("media-playback-rate-menu-button",js);var Jd=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},mn=(s,e,t)=>(Jd(s,e,"read from private field"),t?t.call(s):e.get(s)),So=(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);},Im=(s,e,t,i)=>(Jd(s,e,"write to private field"),e.set(s,t),t),zs=(s,e,t)=>(Jd(s,e,"access private method"),t),gn,Xs,Qs,pn,bo,Zd,Ao=class extends chunkLVGLIRQU_cjs.e{constructor(){super(...arguments),So(this,Qs),So(this,bo),So(this,gn,[]),So(this,Xs,{});}static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_RENDITION_LIST,chunk474VILDO_cjs.d.MEDIA_RENDITION_SELECTED,chunk474VILDO_cjs.d.MEDIA_RENDITION_UNAVAILABLE,chunk474VILDO_cjs.d.MEDIA_HEIGHT]}static formatMenuItemText(e,t){return super.formatMenuItemText(e,t)}static formatRendition(e,{showBitrate:t=false}={}){let i=`${Math.min(e.width,e.height)}p`;if(t&&e.bitrate){let r=e.bitrate/1e6,n=`${r.toFixed(r<1?1:0)} Mbps`;return `${i} (${n})`}return this.formatMenuItemText(i,e)}static compareRendition(e,t){var i,r;return t.height===e.height?((i=t.bitrate)!=null?i:0)-((r=e.bitrate)!=null?r:0):t.height-e.height}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===chunk474VILDO_cjs.d.MEDIA_RENDITION_SELECTED&&t!==i?(this.value=i??"auto",zs(this,Qs,pn).call(this)):e===chunk474VILDO_cjs.d.MEDIA_RENDITION_LIST&&t!==i?(Im(this,gn,Wh(i)),zs(this,Qs,pn).call(this)):e===chunk474VILDO_cjs.d.MEDIA_HEIGHT&&t!==i&&zs(this,Qs,pn).call(this);}connectedCallback(){super.connectedCallback(),this.addEventListener("change",zs(this,bo,Zd));}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",zs(this,bo,Zd));}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:chunk474VILDO_cjs.r(this).querySelector("media-rendition-menu-button")}get mediaRenditionList(){return mn(this,gn)}set mediaRenditionList(e){Im(this,gn,e),zs(this,Qs,pn).call(this);}get mediaRenditionSelected(){return chunk474VILDO_cjs.H(this,chunk474VILDO_cjs.d.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){chunk474VILDO_cjs.I(this,chunk474VILDO_cjs.d.MEDIA_RENDITION_SELECTED,e);}get mediaHeight(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_HEIGHT)}set mediaHeight(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_HEIGHT,e);}compareRendition(e,t){return this.constructor.compareRendition(e,t)}formatMenuItemText(e,t){return this.constructor.formatMenuItemText(e,t)}formatRendition(e,t){return this.constructor.formatRendition(e,t)}showRenditionBitrate(e){return this.mediaRenditionList.some(t=>t!==e&&t.height===e.height&&t.bitrate!==e.bitrate)}};gn=new WeakMap;Xs=new WeakMap;Qs=new WeakSet;pn=function(){if(mn(this,Xs).mediaRenditionList===JSON.stringify(this.mediaRenditionList)&&mn(this,Xs).mediaHeight===this.mediaHeight)return;mn(this,Xs).mediaRenditionList=JSON.stringify(this.mediaRenditionList),mn(this,Xs).mediaHeight=this.mediaHeight;let s=this.mediaRenditionList.sort(this.compareRendition.bind(this)),e=s.find(a=>a.id===this.mediaRenditionSelected);for(let a of s)a.selected=a===e;this.defaultSlot.textContent="";let t=!this.mediaRenditionSelected;for(let a of s){let o=this.formatRendition(a,{showBitrate:this.showRenditionBitrate(a)}),d=chunkLVGLIRQU_cjs.c({type:"radio",text:o,value:`${a.id}`,checked:a.selected&&!t});d.prepend(chunkLVGLIRQU_cjs.d(this,"checked-indicator")),this.defaultSlot.append(d);}let i=e&&this.showRenditionBitrate(e),r=t?e?this.formatMenuItemText(`${chunk474VILDO_cjs.n("Auto")} \u2022 ${this.formatRendition(e,{showBitrate:i})}`,e):this.formatMenuItemText(`${chunk474VILDO_cjs.n("Auto")} (${this.mediaHeight}p)`):this.formatMenuItemText(chunk474VILDO_cjs.n("Auto")),n=chunkLVGLIRQU_cjs.c({type:"radio",text:r,value:"auto",checked:t});n.dataset.description=r,n.prepend(chunkLVGLIRQU_cjs.d(this,"checked-indicator")),this.defaultSlot.append(n);};bo=new WeakSet;Zd=function(){if(this.value==null)return;let s=new chunk474VILDO_cjs.o.CustomEvent(chunk474VILDO_cjs.a.MEDIA_RENDITION_REQUEST,{composed:true,bubbles:true,detail:this.value});this.dispatchEvent(s);};chunk474VILDO_cjs.o.customElements.get("media-rendition-menu")||chunk474VILDO_cjs.o.customElements.define("media-rendition-menu",Ao);var TT=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1445
1421
|
<path d="M13.5 2.5h2v6h-2v-2h-11v-2h11v-2Zm4 2h4v2h-4v-2Zm-12 4h2v6h-2v-2h-3v-2h3v-2Zm4 2h12v2h-12v-2Zm1 4h2v6h-2v-2h-8v-2h8v-2Zm4 2h7v2h-7v-2Z" />
|
|
1446
|
-
</svg>`;function
|
|
1422
|
+
</svg>`;function yT(){return `
|
|
1447
1423
|
<style>
|
|
1448
1424
|
:host([aria-expanded="true"]) slot[name=tooltip] {
|
|
1449
1425
|
display: none;
|
|
1450
1426
|
}
|
|
1451
1427
|
</style>
|
|
1452
|
-
<slot name="icon">${
|
|
1453
|
-
`}function
|
|
1454
|
-
${
|
|
1428
|
+
<slot name="icon">${TT}</slot>
|
|
1429
|
+
`}function ST(){return chunk474VILDO_cjs.n("Quality")}var Zs=class extends chunk474VILDO_cjs.M{static get observedAttributes(){return [...super.observedAttributes,chunk474VILDO_cjs.d.MEDIA_RENDITION_SELECTED,chunk474VILDO_cjs.d.MEDIA_RENDITION_UNAVAILABLE,chunk474VILDO_cjs.d.MEDIA_HEIGHT]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",chunk474VILDO_cjs.n("quality"));}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:chunk474VILDO_cjs.r(this).querySelector("media-rendition-menu")}get mediaRenditionSelected(){return chunk474VILDO_cjs.H(this,chunk474VILDO_cjs.d.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){chunk474VILDO_cjs.I(this,chunk474VILDO_cjs.d.MEDIA_RENDITION_SELECTED,e);}get mediaHeight(){return chunk474VILDO_cjs.D(this,chunk474VILDO_cjs.d.MEDIA_HEIGHT)}set mediaHeight(e){chunk474VILDO_cjs.E(this,chunk474VILDO_cjs.d.MEDIA_HEIGHT,e);}};Zs.getSlotTemplateHTML=yT;Zs.getTooltipContentHTML=ST;chunk474VILDO_cjs.o.customElements.get("media-rendition-menu-button")||chunk474VILDO_cjs.o.customElements.define("media-rendition-menu-button",Zs);var ic=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},li=(s,e,t)=>(ic(s,e,"read from private field"),t?t.call(s):e.get(s)),oi=(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);},Lm=(s,e,t,i)=>(ic(s,e,"write to private field"),e.set(s,t),t),kt=(s,e,t)=>(ic(s,e,"access private method"),t),er,En,ko,as,Js,sc,xm,_o,ec,Io,tc,Rm,xo,Ro,Lo;function bT(s){return `
|
|
1430
|
+
${chunkLVGLIRQU_cjs.e.getTemplateHTML(s)}
|
|
1455
1431
|
<style>
|
|
1456
1432
|
:host {
|
|
1457
1433
|
--_menu-bg: rgb(20 20 30 / .8);
|
|
@@ -1464,8 +1440,8 @@
|
|
|
1464
1440
|
overflow: hidden;
|
|
1465
1441
|
}
|
|
1466
1442
|
</style>
|
|
1467
|
-
`}var
|
|
1468
|
-
${
|
|
1443
|
+
`}var vn=class extends chunkLVGLIRQU_cjs.e{constructor(){super(),oi(this,En),oi(this,as),oi(this,sc),oi(this,_o),oi(this,tc),oi(this,er,false),oi(this,Io,e=>{let t=e.target,i=t?.nodeName==="VIDEO",r=kt(this,_o,ec).call(this,t);(i||r)&&(li(this,er)?kt(this,as,Js).call(this):kt(this,tc,Rm).call(this,e));}),oi(this,xo,e=>{let t=e.target,i=this.contains(t),r=e.button===2,n=t?.nodeName==="VIDEO",a=kt(this,_o,ec).call(this,t);i||r&&(n||a)||kt(this,as,Js).call(this);}),oi(this,Ro,e=>{e.key==="Escape"&&kt(this,as,Js).call(this);}),oi(this,Lo,e=>{var t,i;let r=e.target;if((t=r.matches)!=null&&t.call(r,'button[invoke="copy"]')){let n=(i=r.closest("media-context-menu-item"))==null?void 0:i.querySelector('input[slot="copy"]');n&&navigator.clipboard.writeText(n.value);}kt(this,as,Js).call(this);}),this.setAttribute("noautohide",""),kt(this,En,ko).call(this);}connectedCallback(){super.connectedCallback(),chunk474VILDO_cjs.r(this).addEventListener("contextmenu",li(this,Io)),this.addEventListener("click",li(this,Lo));}disconnectedCallback(){super.disconnectedCallback(),chunk474VILDO_cjs.r(this).removeEventListener("contextmenu",li(this,Io)),this.removeEventListener("click",li(this,Lo)),document.removeEventListener("mousedown",li(this,xo)),document.removeEventListener("keydown",li(this,Ro));}};er=new WeakMap;En=new WeakSet;ko=function(){this.hidden=!li(this,er);};as=new WeakSet;Js=function(){Lm(this,er,false),kt(this,En,ko).call(this);};sc=new WeakSet;xm=function(){document.querySelectorAll("media-context-menu").forEach(e=>{var t;e!==this&&kt(t=e,as,Js).call(t);});};_o=new WeakSet;ec=function(s){return s?s.hasAttribute("slot")&&s.getAttribute("slot")==="media"?true:s.nodeName.includes("-")&&s.tagName.includes("-")?s.hasAttribute("src")||s.hasAttribute("poster")||s.hasAttribute("preload")||s.hasAttribute("playsinline"):false:false};Io=new WeakMap;tc=new WeakSet;Rm=function(s){s.preventDefault(),kt(this,sc,xm).call(this),Lm(this,er,true),this.style.position="fixed",this.style.left=`${s.clientX}px`,this.style.top=`${s.clientY}px`,kt(this,En,ko).call(this),document.addEventListener("mousedown",li(this,xo),{once:true}),document.addEventListener("keydown",li(this,Ro),{once:true});};xo=new WeakMap;Ro=new WeakMap;Lo=new WeakMap;vn.getTemplateHTML=bT;chunk474VILDO_cjs.o.customElements.get("media-context-menu")||chunk474VILDO_cjs.o.customElements.define("media-context-menu",vn);function AT(s){return `
|
|
1444
|
+
${Tt.getTemplateHTML.call(this,s)}
|
|
1469
1445
|
<style>
|
|
1470
1446
|
::slotted(*) {
|
|
1471
1447
|
color: var(--media-text-color, white);
|
|
@@ -1477,84 +1453,84 @@
|
|
|
1477
1453
|
min-height: var(--media-control-height, 24px);
|
|
1478
1454
|
}
|
|
1479
1455
|
</style>
|
|
1480
|
-
`}var sr=class extends yt{};sr.shadowRootOptions={mode:"open"};sr.getTemplateHTML=kT;chunkV54NMMTT_cjs.o.customElements.get("media-context-menu-item")||chunkV54NMMTT_cjs.o.customElements.define("media-context-menu-item",sr);var H=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},DT=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=CT},CT=Number.MAX_SAFE_INTEGER||9007199254740991,z=(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.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",s.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",s.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.ASSET_LIST_LOAD_ERROR="assetListLoadError",s.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",s.ASSET_LIST_PARSING_ERROR="assetListParsingError",s.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.ATTACH_MEDIA_ERROR="attachMediaError",s.UNKNOWN="unknown",s})({}),p=(function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.MEDIA_ENDED="hlsMediaEnded",s.STALL_RESOLVED="hlsStallResolved",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFERED_TO_END="hlsBufferedToEnd",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",s.ASSET_LIST_LOADING="hlsAssetListLoading",s.ASSET_LIST_LOADED="hlsAssetListLoaded",s.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",s.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",s.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",s.INTERSTITIAL_STARTED="hlsInterstitialStarted",s.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",s.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",s.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",s.INTERSTITIAL_ENDED="hlsInterstitialEnded",s.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",s.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",s.EVENT_CUE_ENTER="hlsEventCueEnter",s})({}),ue={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},W={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},Ni=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_}},Rc=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 Ni(e),this.fast_=new Ni(t),this.defaultTTFB_=r,this.ttfb_=new Ni(e);}update(e,t){let{slow_:i,fast_:r,ttfb_:n}=this;i.halfLife!==e&&(this.slow_=new Ni(e,i.getEstimate(),i.getTotalWeight())),r.halfLife!==t&&(this.fast_=new Ni(t,r.getEstimate(),r.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Ni(e,n.getEstimate(),n.getTotalWeight()));}sample(e,t){e=Math.max(e,this.minDelayMs_);let i=8*t,r=e/1e3,n=i/r;this.fast_.sample(r,n),this.slow_.sample(r,n);}sampleTTFB(e){let t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5));}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}};function MT(s,e,t){return (e=PT(e))in s?Object.defineProperty(s,e,{value:t,enumerable:true,configurable:true,writable:true}):s[e]=t,s}function Se(){return Se=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i]);}return s},Se.apply(null,arguments)}function Pm(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 Te(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Pm(Object(t),true).forEach(function(i){MT(s,i,t[i]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Pm(Object(t)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(t,i));});}return s}function wT(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 PT(s){var e=wT(s,"string");return typeof e=="symbol"?e:e+""}var ft=class{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;let i=`[${e}]:`;this.trace=Bi,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i);}},Bi=function(){},OT={trace:Bi,debug:Bi,log:Bi,warn:Bi,info:Bi,error:Bi};function kc(){return Se({},OT)}function FT(s,e){let t=self.console[s];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${s}] >`):Bi}function Om(s,e,t){return e[s]?e[s].bind(e):FT(s,t)}var Dc=kc();function UT(s,e,t){let i=kc();if(typeof console=="object"&&s===true||typeof s=="object"){let r=["debug","log","info","warn","error"];r.forEach(n=>{i[n]=Om(n,s,t);});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.6.15`);}catch{return kc()}r.forEach(n=>{Dc[n]=Om(n,s);});}else Se(Dc,i);return i}var ye=Dc;function $i(s=true){return typeof self>"u"?void 0:(s||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function NT(s){return typeof self<"u"&&s===self.ManagedMediaSource}function Yg(s,e){let t=Object.keys(s),i=Object.keys(e),r=t.length,n=i.length;return !r||!n||r===n&&!t.some(a=>i.indexOf(a)===-1)}function _t(s,e=false){if(typeof TextDecoder<"u"){let d=new TextDecoder("utf-8").decode(s);if(e){let c=d.indexOf("\0");return c!==-1?d.substring(0,c):d}return d.replace(/\0/g,"")}let t=s.length,i,r,n,a="",o=0;for(;o<t;){if(i=s[o++],i===0&&e)return a;if(i===0||i===3)continue;switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:r=s[o++],a+=String.fromCharCode((i&31)<<6|r&63);break;case 14:r=s[o++],n=s[o++],a+=String.fromCharCode((i&15)<<12|(r&63)<<6|(n&63)<<0);break}}return a}function Ze(s){let e="";for(let t=0;t<s.length;t++){let i=s[t].toString(16);i.length<2&&(i="0"+i),e+=i;}return e}function qg(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function BT(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var ac={exports:{}},Fm;function $T(){return Fm||(Fm=1,(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 u=o.parseURL(l);if(!u)throw new Error("Error trying to parse base URL.");return u.path=o.normalizePath(u.path),o.buildURLFromParts(u)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return c.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):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:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(g.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)g.path=f.path,h.params||(g.params=f.params,h.query||(g.query=f.query));else {var E=f.path,v=E.substring(0,E.lastIndexOf("/")+1)+h.path;g.path=o.normalizePath(v);}return g.path===null&&(g.path=c.alwaysNormalize?o.normalizePath(h.path):h.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;})();})(ac)),ac.exports}var qu=$T(),xn=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};}},be={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},el=class{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,GT(this,"stats");}setByteRange(e,t){let i=e.split("@",2),r;i.length===1?r=t?.byteRangeEndOffset||0:r=parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r];}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[be.AUDIO]:null,[be.VIDEO]:null,[be.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e;}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new xn),this._stats}set stats(e){this._stats=e;}get url(){return !this._url&&this.baseurl&&this.relurl&&(this._url=qu.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:true})),this._url||""}set url(e){this._url=e;}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[be.AUDIO]=null,e[be.VIDEO]=null,e[be.AUDIOVIDEO]=null;}};function Fe(s){return s.sn!=="initSegment"}var An=class extends el{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=false,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e;}get byteLength(){if(this.hasStats){let e=this.stats.total;if(e)return e}if(this.byteRange.length){let e=this.byteRange[0],t=this.byteRange[1];if(H(e)&&H(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e;}get decryptdata(){var e;let{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(!((e=this._decryptdata)!=null&&e.keyId)){let i=Object.keys(t);if(i.length===1){let r=this._decryptdata=t[i[0]]||null;r&&(this._decryptdata=r.getDecryptData(this.sn,t));}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;let e=H(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){var t;let i=Object.keys(this.levelkeys),r=i.length;if(r>1||r===1&&(t=this.levelkeys[i[0]])!=null&&t.encrypted)return true}return false}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!H(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e;}get ref(){return Fe(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e);}setStart(e){this.start=e,this._ref&&(this._ref.start=e);}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e);}setKeyFormat(e){let t=this.levelkeys;if(t){var i;let r=t[e];r&&!((i=this._decryptdata)!=null&&i.keyId)&&(this._decryptdata=r.getDecryptData(this.sn,t));}}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);}},Cc=class extends el{constructor(e,t,i,r,n){super(i),this.fragOffset=0,this.duration=0,this.gap=false,this.independent=false,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=r;let a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration);}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return !!(e.audio||e.video||e.audiovideo)}};function jg(s,e){let t=Object.getPrototypeOf(s);if(t){let i=Object.getOwnPropertyDescriptor(t,e);return i||jg(t,e)}}function GT(s,e){let t=jg(s,e);t&&(t.enumerable=true,Object.defineProperty(s,e,t));}var Um=Math.pow(2,32)-1,HT=[].push,zg={video:1,audio:2,id3:3,text:4};function Ve(s){return String.fromCharCode.apply(null,s)}function Qg(s,e){let t=s[e]<<8|s[e+1];return t<0?65536+t:t}function ie(s,e){let t=Xg(s,e);return t<0?4294967296+t:t}function Nm(s,e){let t=ie(s,e);return t*=Math.pow(2,32),t+=ie(s,e+4),t}function Xg(s,e){return s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3]}function KT(s){let e=s.byteLength;for(let t=0;t<e;){let i=ie(s,t);if(i>8&&s[t+4]===109&&s[t+5]===111&&s[t+6]===111&&s[t+7]===102)return true;t=i>1?t+i:e;}return false}function de(s,e){let t=[];if(!e.length)return t;let i=s.byteLength;for(let r=0;r<i;){let n=ie(s,r),a=Ve(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=de(s.subarray(r+8,o),e.slice(1));l.length&&HT.apply(t,l);}r=o;}return t}function VT(s){let e=[],t=s[0],i=8,r=ie(s,i);i+=4;let n=0,a=0;t===0?(n=ie(s,i),a=ie(s,i+4),i+=8):(n=Nm(s,i),a=Nm(s,i+8),i+=16),i+=2;let o=s.length+a,l=Qg(s,i);i+=2;for(let d=0;d<l;d++){let c=i,u=ie(s,c);c+=4;let h=u&2147483647;if((u&2147483648)>>>31===1)return ye.warn("SIDX has hierarchical references (not supported)"),null;let m=ie(s,c);c+=4,e.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/r,start:o,end:o+h-1}}),o+=h,c+=4,i=c;}return {earliestPresentationTime:n,timescale:r,version:t,referencesCount:l,references:e}}function Zg(s){let e=[],t=de(s,["moov","trak"]);for(let r=0;r<t.length;r++){let n=t[r],a=de(n,["tkhd"])[0];if(a){let o=a[0],l=ie(a,o===0?12:20),d=de(n,["mdia","mdhd"])[0];if(d){o=d[0];let c=ie(d,o===0?12:20),u=de(n,["mdia","hdlr"])[0];if(u){let h=Ve(u.subarray(8,12)),f={soun:be.AUDIO,vide:be.VIDEO}[h],m=de(n,["mdia","minf","stbl","stsd"])[0],g=WT(m);f?(e[l]={timescale:c,type:f,stsd:g},e[f]=Te({timescale:c,id:l},g)):e[l]={timescale:c,type:h,stsd:g};}}}}return de(s,["moov","mvex","trex"]).forEach(r=>{let n=ie(r,4),a=e[n];a&&(a.default={duration:ie(r,12),flags:ie(r,20)});}),e}function WT(s){let e=s.subarray(8),t=e.subarray(86),i=Ve(e.subarray(4,8)),r=i,n,a=i==="enca"||i==="encv";if(a){let d=de(e,[i])[0].subarray(i==="enca"?28:78);de(d,["sinf"]).forEach(u=>{let h=de(u,["schm"])[0];if(h){let f=Ve(h.subarray(4,8));if(f==="cbcs"||f==="cenc"){let m=de(u,["frma"])[0];m&&(r=Ve(m));}}});}let o=r;switch(r){case "avc1":case "avc2":case "avc3":case "avc4":{let l=de(t,["avcC"])[0];l&&l.length>3&&(r+="."+Po(l[1])+Po(l[2])+Po(l[3]),n=wo(o==="avc1"?"dva1":"dvav",t));break}case "mp4a":{let l=de(e,[i])[0],d=de(l.subarray(28),["esds"])[0];if(d&&d.length>7){let c=4;if(d[c++]!==3)break;c=oc(d,c),c+=2;let u=d[c++];if(u&128&&(c+=2),u&64&&(c+=d[c++]),d[c++]!==4)break;c=oc(d,c);let h=d[c++];if(h===64)r+="."+Po(h);else break;if(c+=12,d[c++]!==5)break;c=oc(d,c);let f=d[c++],m=(f&248)>>3;m===31&&(m+=1+((f&7)<<3)+((d[c]&224)>>5)),r+="."+m;}break}case "hvc1":case "hev1":{let l=de(t,["hvcC"])[0];if(l&&l.length>12){let d=l[1],c=["","A","B","C"][d>>6],u=d&31,h=ie(l,2),f=(d&32)>>5?"H":"L",m=l[12],g=l.subarray(6,12);r+="."+c+u,r+="."+YT(h).toString(16).toUpperCase(),r+="."+f+m;let E="";for(let v=g.length;v--;){let y=g[v];(y||E)&&(E="."+y.toString(16).toUpperCase()+E);}r+=E;}n=wo(o=="hev1"?"dvhe":"dvh1",t);break}case "dvh1":case "dvhe":case "dvav":case "dva1":case "dav1":{r=wo(r,t)||r;break}case "vp09":{let l=de(t,["vpcC"])[0];if(l&&l.length>6){let d=l[4],c=l[5],u=l[6]>>4&15;r+="."+hi(d)+"."+hi(c)+"."+hi(u);}break}case "av01":{let l=de(t,["av1C"])[0];if(l&&l.length>2){let d=l[1]>>>5,c=l[1]&31,u=l[2]>>>7?"H":"M",h=(l[2]&64)>>6,f=(l[2]&32)>>5,m=d===2&&h?f?12:10:h?10:8,g=(l[2]&16)>>4,E=(l[2]&8)>>3,v=(l[2]&4)>>2,y=l[2]&3;r+="."+d+"."+hi(c)+u+"."+hi(m)+"."+g+"."+E+v+y+"."+hi(1)+"."+hi(1)+"."+hi(1)+"."+0,n=wo("dav1",t);}break}}return {codec:r,encrypted:a,supplemental:n}}function wo(s,e){let t=de(e,["dvvC"]),i=t.length?t[0]:de(e,["dvcC"])[0];if(i){let r=i[2]>>1&127,n=i[2]<<5&32|i[3]>>3&31;return s+"."+hi(r)+"."+hi(n)}}function YT(s){let e=0;for(let t=0;t<32;t++)e|=(s>>t&1)<<31-t;return e>>>0}function oc(s,e){let t=e+5;for(;s[e++]&128&&e<t;);return e}function Po(s){return ("0"+s.toString(16).toUpperCase()).slice(-2)}function hi(s){return (s<10?"0":"")+s}function qT(s,e){if(!s||!e)return;let t=e.keyId;t&&e.isCommonEncryption&&Jg(s,(i,r)=>{let n=i.subarray(8,24);n.some(a=>a!==0)||(ye.log(`[eme] Patching keyId in 'enc${r?"a":"v"}>sinf>>tenc' box: ${Ze(n)} -> ${Ze(t)}`),i.set(t,8));});}function jT(s){let e=[];return Jg(s,t=>e.push(t.subarray(8,24))),e}function Jg(s,e){de(s,["moov","trak"]).forEach(i=>{let r=de(i,["mdia","minf","stbl","stsd"])[0];if(!r)return;let n=r.subarray(8),a=de(n,["enca"]),o=a.length>0;o||(a=de(n,["encv"])),a.forEach(l=>{let d=o?l.subarray(28):l.subarray(78);de(d,["sinf"]).forEach(u=>{let h=ep(u);h&&e(h,o);});});});}function ep(s){let e=de(s,["schm"])[0];if(e){let t=Ve(e.subarray(4,8));if(t==="cbcs"||t==="cenc"){let i=de(s,["schi","tenc"])[0];if(i)return i}}}function zT(s,e,t){let i={},r=de(s,["moof","traf"]);for(let n=0;n<r.length;n++){let a=r[n],o=de(a,["tfhd"])[0],l=ie(o,4),d=e[l];if(!d)continue;i[l]||(i[l]={start:NaN,duration:0,sampleCount:0,timescale:d.timescale,type:d.type});let c=i[l],u=de(a,["tfdt"])[0];if(u){let S=u[0],b=ie(u,4);S===1&&(b===Um?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(b*=Um+1,b+=ie(u,8))),H(b)&&(!H(c.start)||b<c.start)&&(c.start=b);}let h=d.default,f=ie(o,0)|h?.flags,m=h?.duration||0;f&8&&(f&2?m=ie(o,12):m=ie(o,8));let g=de(a,["trun"]),E=c.start||0,v=0,y=m;for(let S=0;S<g.length;S++){let b=g[S],_=ie(b,4),D=c.sampleCount;c.sampleCount+=_;let I=b[3]&1,k=b[3]&4,R=b[2]&1,L=b[2]&2,M=b[2]&4,$=b[2]&8,K=8,j=_;for(I&&(K+=4),k&&_&&(!(b[K+1]&1)&&c.keyFrameIndex===void 0&&(c.keyFrameIndex=D),K+=4,R?(y=ie(b,K),K+=4):y=m,L&&(K+=4),$&&(K+=4),E+=y,v+=y,j--);j--;)R?(y=ie(b,K),K+=4):y=m,L&&(K+=4),M&&(b[K+1]&1||c.keyFrameIndex===void 0&&(c.keyFrameIndex=c.sampleCount-(j+1),c.keyFrameStart=E),K+=4),$&&(K+=4),E+=y,v+=y;!v&&m&&(v+=m*_);}c.duration+=v;}if(!Object.keys(i).some(n=>i[n].duration)){let n=1/0,a=0,o=de(s,["sidx"]);for(let l=0;l<o.length;l++){let d=VT(o[l]);if(d!=null&&d.references){n=Math.min(n,d.earliestPresentationTime/d.timescale);let c=d.references.reduce((u,h)=>u+h.info.duration||0,0);a=Math.max(a,c+d.earliestPresentationTime/d.timescale);}}a&&H(a)&&Object.keys(i).forEach(l=>{i[l].duration||(i[l].duration=a*i[l].timescale-i[l].start);});}return i}function QT(s){let e={valid:null,remainder:null},t=de(s,["moof"]);if(t.length<2)return e.remainder=s,e;let i=t[t.length-1];return e.valid=s.slice(0,i.byteOffset-8),e.remainder=s.slice(i.byteOffset-8),e}function Ct(s,e){let t=new Uint8Array(s.length+e.length);return t.set(s),t.set(e,s.length),t}function Bm(s,e){let t=[],i=e.samples,r=e.timescale,n=e.id,a=false;return de(i,["moof"]).map(l=>{let d=l.byteOffset-8;de(l,["traf"]).map(u=>{let h=de(u,["tfdt"]).map(f=>{let m=f[0],g=ie(f,4);return m===1&&(g*=Math.pow(2,32),g+=ie(f,8)),g/r})[0];return h!==void 0&&(s=h),de(u,["tfhd"]).map(f=>{let m=ie(f,4),g=ie(f,0)&16777215,E=(g&1)!==0,v=(g&2)!==0,y=(g&8)!==0,S=0,b=(g&16)!==0,_=0,D=(g&32)!==0,I=8;m===n&&(E&&(I+=8),v&&(I+=4),y&&(S=ie(f,I),I+=4),b&&(_=ie(f,I),I+=4),D&&(I+=4),e.type==="video"&&(a=Ll(e.codec)),de(u,["trun"]).map(k=>{let R=k[0],L=ie(k,0)&16777215,M=(L&1)!==0,$=0,K=(L&4)!==0,j=(L&256)!==0,V=0,F=(L&512)!==0,Y=0,G=(L&1024)!==0,q=(L&2048)!==0,X=0,N=ie(k,4),B=8;M&&($=ie(k,B),B+=4),K&&(B+=4);let se=$+d;for(let Ee=0;Ee<N;Ee++){if(j?(V=ie(k,B),B+=4):V=S,F?(Y=ie(k,B),B+=4):Y=_,G&&(B+=4),q&&(R===0?X=ie(k,B):X=Xg(k,B),B+=4),e.type===be.VIDEO){let re=0;for(;re<Y;){let ce=ie(i,se);if(se+=4,XT(a,i[se])){let Ge=i.subarray(se,se+ce);ju(Ge,a?2:1,s+X/r,t);}se+=ce,re+=ce+4;}}s+=V/r;}}));})});}),t}function Ll(s){if(!s)return false;let e=s.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function XT(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=tp(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){ye.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(r[c++]===181){let h=Qg(r,c);if(c+=2,h===49){let f=ie(r,c);if(c+=4,f===1195456820){let m=r[c++];if(m===3){let g=r[c++],E=31&g,v=64&g,y=v?2+E*3:0,S=new Uint8Array(y);if(v){S[0]=g;for(let b=1;b<y;b++)S[b]=r[c++];}i.push({type:m,payloadType:a,pts:t,bytes:S});}}}}}else if(a===5&&o>16){let u=[];for(let m=0;m<16;m++){let g=r[c++].toString(16);u.push(g.length==1?"0"+g:g),(m===3||m===5||m===7||m===9)&&u.push("-");}let h=o-16,f=new Uint8Array(h);for(let m=0;m<h;m++)f[m]=r[c++];i.push({payloadType:a,pts:t,uuid:u.join(""),userData:_t(f),userDataBytes:f});}}}function tp(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 ZT(s){let e=s[0],t="",i="",r=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;Ve(s.subarray(d,d+1))!=="\0";)t+=Ve(s.subarray(d,d+1)),d+=1;for(t+=Ve(s.subarray(d,d+1)),d+=1;Ve(s.subarray(d,d+1))!=="\0";)i+=Ve(s.subarray(d,d+1)),d+=1;i+=Ve(s.subarray(d,d+1)),d+=1,r=ie(s,12),n=ie(s,16),o=ie(s,20),l=ie(s,24),d=28;}else if(e===1){d+=4,r=ie(s,d),d+=4;let u=ie(s,d);d+=4;let h=ie(s,d);for(d+=4,a=2**32*u+h,DT(a)||(a=Number.MAX_SAFE_INTEGER,ye.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ie(s,d),d+=4,l=ie(s,d),d+=4;Ve(s.subarray(d,d+1))!=="\0";)t+=Ve(s.subarray(d,d+1)),d+=1;for(t+=Ve(s.subarray(d,d+1)),d+=1;Ve(s.subarray(d,d+1))!=="\0";)i+=Ve(s.subarray(d,d+1)),d+=1;i+=Ve(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 JT(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 ey(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.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,false),JT([112,115,115,104],new Uint8Array([i,0,0,0]),s,n,r,a,t)}function ty(s){let e=[];if(s instanceof ArrayBuffer){let t=s.byteLength,i=0;for(;i+32<t;){let r=new DataView(s,i),n=iy(r);e.push(n),i+=n.size;}}return e}function iy(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=Ze(new Uint8Array(a,t+12,16)),l=null,d=null,c=0;if(n===0)c=28;else {let h=s.getUint32(28);if(!h||i<32+h*16)return {offset:t,size:e};l=[];for(let f=0;f<h;f++)l.push(new Uint8Array(a,t+32+f*16,16));c=32+h*16;}if(!c)return {offset:t,size:e};let u=s.getUint32(c);return e-32<u?{offset:t,size:e}:(d=new Uint8Array(a,t+c+4,u),{version:n,systemId:o,kids:l,data:d,offset:t,size:e})}var ip=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),gr={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function zu(s,e){let t=gr[e];return !!t&&!!t[s.slice(0,4)]}function Rn(s,e,t=true){return !s.split(",").some(i=>!Qu(i,e,t))}function Qu(s,e,t=true){var i;let r=$i(t);return (i=r?.isTypeSupported(kn(s,e)))!=null?i:false}function kn(s,e){return `${e}/mp4;codecs=${s}`}function $m(s){if(s){let e=s.substring(0,4);return gr.video[e]}return 2}function tl(s){let e=ip();return s.split(",").reduce((t,i)=>{let n=e&&Ll(i)?9:gr.video[i];return n?(n*2+t)/(t?3:2):(gr.audio[i]+t)/(t?2:1)},0)}var lc={};function sy(s,e=true){if(lc[s])return lc[s];let t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[s];for(let r=0;r<t.length;r++){var i;if(Qu(t[r],"audio",e))return lc[s]=t[r],t[r];if(t[r]==="mp3"&&(i=$i(e))!=null&&i.isTypeSupported("audio/mpeg"))return ""}return s}var ry=/flac|opus|mp4a\.40\.34/i;function il(s,e=true){return s.replace(ry,t=>sy(t.toLowerCase(),e))}function ny(s,e){let t=[];if(s){let i=s.split(",");for(let r=0;r<i.length;r++)zu(i[r],"video")||t.push(i[r]);}return e&&t.push(e),t.join(",")}function qo(s,e){if(s&&(s.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(s)!==-1)&&(Gm(s,"audio")||Gm(s,"video")))return s;if(e){let t=e.split(",");if(t.length>1){if(s){for(let i=t.length;i--;)if(t[i].substring(0,4)===s.substring(0,4))return t[i]}return t[0]}}return e||s}function Gm(s,e){return zu(s,e)&&Qu(s,e)}function ay(s){let e=s.split(",");for(let t=0;t<e.length;t++){let i=e[t].split(".");i.length>2&&i[0]==="avc1"&&(e[t]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`);}return e.join(",")}function oy(s){if(s.startsWith("av01.")){let e=s.split("."),t=["0","111","01","01","01","0"];for(let i=e.length;i>4&&i<10;i++)e[i]=t[i-4];return e.join(".")}return s}function Hm(s){let e=$i(s)||{isTypeSupported:()=>false};return {mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Mc(s){return s.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var ly={supported:true,powerEfficient:true,smooth:true},dy={supported:false,smooth:false,powerEfficient:false},sp={supported:true,configurations:[],decodingInfoResults:[ly]};function rp(s,e){return {supported:false,configurations:e,decodingInfoResults:[dy],error:s}}function cy(s,e,t,i,r,n){let a=s.videoCodec,o=s.audioCodec?s.audioGroups:null,l=n?.audioCodec,d=n?.channels,c=d?parseInt(d):l?1/0:2,u=null;if(o!=null&&o.length)try{o.length===1&&o[0]?u=e.groups[o[0]].channels:u=o.reduce((h,f)=>{if(f){let m=e.groups[f];if(!m)throw new Error(`Audio track group ${f} not found`);Object.keys(m.channels).forEach(g=>{h[g]=(h[g]||0)+m.channels[g];});}return h},{2:0});}catch{return true}return a!==void 0&&(a.split(",").some(h=>Ll(h))||s.width>1920&&s.height>1088||s.height>1920&&s.width>1088||s.frameRate>Math.max(i,30)||s.videoRange!=="SDR"&&s.videoRange!==t||s.bitrate>Math.max(r,8e6))||!!u&&H(c)&&Object.keys(u).some(h=>parseInt(h)>c)}function np(s,e,t,i={}){let r=s.videoCodec;if(!r&&!s.audioCodec||!t)return Promise.resolve(sp);let n=[],a=uy(s),o=a.length,l=hy(s,e,o>0),d=l.length;for(let c=o||1*d||1;c--;){let u={type:"media-source"};if(o&&(u.video=a[c%o]),d){u.audio=l[c%d];let h=u.audio.bitrate;u.video&&h&&(u.video.bitrate-=h);}n.push(u);}if(r){let c=navigator.userAgent;if(r.split(",").some(u=>Ll(u))&&ip())return Promise.resolve(rp(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${c})`),n))}return Promise.all(n.map(c=>{let u=my(c);return i[u]||(i[u]=t.decodingInfo(c))})).then(c=>({supported:!c.some(u=>!u.supported),configurations:n,decodingInfoResults:c})).catch(c=>({supported:false,configurations:n,decodingInfoResults:[],error:c}))}function uy(s){var e;let t=(e=s.videoCodec)==null?void 0:e.split(","),i=ap(s),r=s.width||640,n=s.height||480,a=s.frameRate||30,o=s.videoRange.toLowerCase();return t?t.map(l=>{let d={contentType:kn(oy(l),"video"),width:r,height:n,bitrate:i,framerate:a};return o!=="sdr"&&(d.transferFunction=o),d}):[]}function hy(s,e,t){var i;let r=(i=s.audioCodec)==null?void 0:i.split(","),n=ap(s);return r&&s.audioGroups?s.audioGroups.reduce((a,o)=>{var l;let d=o?(l=e.groups[o])==null?void 0:l.tracks:null;return d?d.reduce((c,u)=>{if(u.groupId===o){let h=parseFloat(u.channels||"");r.forEach(f=>{let m={contentType:kn(f,"audio"),bitrate:t?fy(f,n):n};h&&(m.channels=""+h),c.push(m);});}return c},a):a},[]):[]}function fy(s,e){if(e<=1)return 1;let t=128e3;return s==="ec-3"?t=768e3:s==="ac-3"&&(t=64e4),Math.min(e/2,t)}function ap(s){return Math.ceil(Math.max(s.bitrate*.9,s.averageBitrate)/1e3)*1e3||1}function my(s){let e="",{audio:t,video:i}=s;if(i){let r=Mc(i.contentType);e+=`${r}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`;}if(t){let r=Mc(t.contentType);e+=`${i?"_":""}${r}_c${t.channels}`;}return e}var wc=["NONE","TYPE-0","TYPE-1",null];function gy(s){return wc.indexOf(s)>-1}var sl=["SDR","PQ","HLG"];function py(s){return !!s&&sl.indexOf(s)>-1}var jo={No:"",Yes:"YES",v2:"v2"};function Km(s){let{canSkipUntil:e,canSkipDateRanges:t,age:i}=s,r=i<e/2;return e&&r?t?jo.v2:jo.Yes:jo.No}var rl=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}},ms=class{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(i=>!!i).map(i=>i.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;let i=(t=e.supplemental)==null?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`);}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES);}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return Vm(this._audioGroups,e)}hasSubtitleGroup(e){return Vm(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 Vm(s,e){return !e||!s?false:s.indexOf(e)!==-1}function Ey(){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 vy(s,e){let t=false,i=[];if(s&&(t=s!=="SDR",i=[s]),e){i=e.allowedVideoRanges||sl.slice(0);let r=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:r&&Ey(),t||(i=["SDR"]);}return {preferHDR:t,allowedVideoRanges:i}}var Ty=s=>{let e=new WeakSet;return (t,i)=>{if(s&&(i=s(t,i)),typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i);}return i}},Ae=(s,e)=>JSON.stringify(s,Ty(e));function yy(s,e,t,i,r){let n=Object.keys(s),a=i?.channels,o=i?.audioCodec,l=r?.videoCodec,d=a&&parseInt(a)===2,c=false,u=false,h=1/0,f=1/0,m=1/0,g=1/0,E=0,v=[],{preferHDR:y,allowedVideoRanges:S}=vy(e,r);for(let k=n.length;k--;){let R=s[n[k]];c||(c=R.channels[2]>0),h=Math.min(h,R.minHeight),f=Math.min(f,R.minFramerate),m=Math.min(m,R.minBitrate),S.filter(M=>R.videoRanges[M]>0).length>0&&(u=true);}h=H(h)?h:0,f=H(f)?f:0;let b=Math.max(1080,h),_=Math.max(30,f);m=H(m)?m:t,t=Math.max(m,t),u||(e=void 0);let D=n.length>1;return {codecSet:n.reduce((k,R)=>{let L=s[R];if(R===k)return k;if(v=u?S.filter(M=>L.videoRanges[M]>0):[],D){if(L.minBitrate>t)return ci(R,`min bitrate of ${L.minBitrate} > current estimate of ${t}`),k;if(!L.hasDefaultAudio)return ci(R,"no renditions with default or auto-select sound found"),k;if(o&&R.indexOf(o.substring(0,4))%5!==0)return ci(R,`audio codec preference "${o}" not found`),k;if(a&&!d){if(!L.channels[a])return ci(R,`no renditions with ${a} channel sound found (channels options: ${Object.keys(L.channels)})`),k}else if((!o||d)&&c&&L.channels[2]===0)return ci(R,"no renditions with stereo sound found"),k;if(L.minHeight>b)return ci(R,`min resolution of ${L.minHeight} > maximum of ${b}`),k;if(L.minFramerate>_)return ci(R,`min framerate of ${L.minFramerate} > maximum of ${_}`),k;if(!v.some(M=>L.videoRanges[M]>0))return ci(R,`no variants with VIDEO-RANGE of ${Ae(v)} found`),k;if(l&&R.indexOf(l.substring(0,4))%5!==0)return ci(R,`video codec preference "${l}" not found`),k;if(L.maxScore<E)return ci(R,`max score of ${L.maxScore} < selected max of ${E}`),k}return k&&(tl(R)>=tl(k)||L.fragmentError>s[k].fragmentError)?k:(g=L.minIndex,E=L.maxScore,R)},void 0),videoRanges:v,preferHDR:y,minFramerate:f,minBitrate:m,minIndex:g}}function ci(s,e){ye.log(`[abr] start candidates with "${s}" ignored because ${e}`);}function op(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 Sy(s,e,t,i){return s.slice(t,i+1).reduce((r,n,a)=>{if(!n.codecSet)return r;let o=n.audioGroups,l=r[n.codecSet];l||(r[n.codecSet]=l={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:a,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),l.minBitrate=Math.min(l.minBitrate,n.bitrate);let d=Math.min(n.height,n.width);return l.minHeight=Math.min(l.minHeight,d),l.minFramerate=Math.min(l.minFramerate,n.frameRate),l.minIndex=Math.min(l.minIndex,a),l.maxScore=Math.max(l.maxScore,n.score),l.fragmentError+=n.fragmentError,l.videoRanges[n.videoRange]=(l.videoRanges[n.videoRange]||0)+1,o&&o.forEach(c=>{if(!c)return;let u=e.groups[c];u&&(l.hasDefaultAudio=l.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(h=>{l.channels[h]=(l.channels[h]||0)+u.channels[h];}));}),r},{})}function Wm(s){if(!s)return s;let{lang:e,assocLang:t,characteristics:i,channels:r,audioCodec:n}=s;return {lang:e,assocLang:t,characteristics:i,channels:r,audioCodec:n}}function mi(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(hs(s,r,t))return i}return -1}function hs(s,e,t){let{groupId:i,name:r,lang:n,assocLang:a,default:o}=s,l=s.forced;return (i===void 0||e.groupId===i)&&(r===void 0||e.name===r)&&(n===void 0||by(n,e.lang))&&(n===void 0||e.assocLang===a)&&(o===void 0||e.default===o)&&(l===void 0||e.forced===l)&&(!("characteristics"in s)||Ay(s.characteristics||"",e.characteristics))&&(t===void 0||t(s,e))}function by(s,e="--"){return s.length===e.length?s===e:s.startsWith(e)||e.startsWith(s)}function Ay(s,e=""){let t=s.split(","),i=e.split(",");return t.length===i.length&&!t.some(r=>i.indexOf(r)===-1)}function cs(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 _y(s,e,t,i,r){let n=e[i],o=e.reduce((h,f,m)=>{let g=f.uri;return (h[g]||(h[g]=[])).push(m),h},{})[n.uri];o.length>1&&(i=Math.max.apply(Math,o));let l=n.videoRange,d=n.frameRate,c=n.codecSet.substring(0,4),u=Ym(e,i,h=>{if(h.videoRange!==l||h.frameRate!==d||h.codecSet.substring(0,4)!==c)return false;let f=h.audioGroups,m=t.filter(g=>!f||f.indexOf(g.groupId)!==-1);return mi(s,m,r)>-1});return u>-1?u:Ym(e,i,h=>{let f=h.audioGroups,m=t.filter(g=>!f||f.indexOf(g.groupId)!==-1);return mi(s,m,r)>-1})}function Ym(s,e,t){for(let i=e;i>-1;i--)if(t(s[i]))return i;for(let i=e+1;i<s.length;i++)if(t(s[i]))return i;return -1}function nl(s,e){var t;return !!s&&s!==((t=e.loadLevelObj)==null?void 0:t.uri)}var Pc=class extends ft{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var i;let{fragCurrent:r,partCurrent:n,hls:a}=this,{autoLevelEnabled:o,media:l}=a;if(!r||!l)return;let d=performance.now(),c=n?n.stats:r.stats,u=n?n.duration:r.duration,h=d-c.loading.start,f=a.minAutoLevel,m=r.level,g=this._nextAutoLevel;if(c.aborted||c.loaded&&c.loaded===c.total||m<=f){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;let E=g>-1&&g!==m,v=!!t||E;if(!v&&(l.paused||!l.playbackRate||!l.readyState))return;let y=a.mainForwardBufferInfo;if(!v&&y===null)return;let S=this.bwEstimator.getEstimateTTFB(),b=Math.abs(l.playbackRate);if(h<=Math.max(S,1e3*(u/(b*2))))return;let _=y?y.len/b:0,D=c.loading.first?c.loading.first-c.loading.start:-1,I=c.loaded&&D>-1,k=this.getBwEstimate(),R=a.levels,L=R[m],M=Math.max(c.loaded,Math.round(u*(r.bitrate||L.averageBitrate)/8)),$=I?h-D:h;$<1&&I&&($=Math.min(h,c.loaded*8/k));let K=I?c.loaded*1e3/$:0,j=S/1e3,V=K?(M-c.loaded)/K:M*8/k+j;if(V<=_)return;let F=K?K*8:k,Y=((i=t?.details||this.hls.latestLevelDetails)==null?void 0:i.live)===true,G=this.hls.config.abrBandWidthUpFactor,q=Number.POSITIVE_INFINITY,X;for(X=m-1;X>f;X--){let Ee=R[X].maxBitrate,re=!R[X].details||Y;if(q=this.getTimeToLoadFrag(j,F,u*Ee,re),q<Math.min(_,u+j))break}if(q>=V||q>u*10)return;I?this.bwEstimator.sample(h-Math.min(S,D),c.loaded):this.bwEstimator.sampleTTFB(h);let N=R[X].maxBitrate;this.getBwEstimate()*G>N&&this.resetEstimator(N);let B=this.findBestLevel(N,f,X,0,_,1,1);B>-1&&(X=B),this.warn(`Fragment ${r.sn}${n?" part "+n.index:""} of level ${m} is loading too slowly;
|
|
1456
|
+
`}var tr=class extends Tt{};tr.shadowRootOptions={mode:"open"};tr.getTemplateHTML=AT;chunk474VILDO_cjs.o.customElements.get("media-context-menu-item")||chunk474VILDO_cjs.o.customElements.define("media-context-menu-item",tr);var H=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},_T=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=IT},IT=Number.MAX_SAFE_INTEGER||9007199254740991,Q=(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.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",s.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",s.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.ASSET_LIST_LOAD_ERROR="assetListLoadError",s.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",s.ASSET_LIST_PARSING_ERROR="assetListParsingError",s.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.ATTACH_MEDIA_ERROR="attachMediaError",s.UNKNOWN="unknown",s})({}),p=(function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.MEDIA_ENDED="hlsMediaEnded",s.STALL_RESOLVED="hlsStallResolved",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFERED_TO_END="hlsBufferedToEnd",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",s.ASSET_LIST_LOADING="hlsAssetListLoading",s.ASSET_LIST_LOADED="hlsAssetListLoaded",s.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",s.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",s.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",s.INTERSTITIAL_STARTED="hlsInterstitialStarted",s.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",s.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",s.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",s.INTERSTITIAL_ENDED="hlsInterstitialEnded",s.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",s.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",s.EVENT_CUE_ENTER="hlsEventCueEnter",s})({}),ue={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Y={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},Ni=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_}},Lc=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 Ni(e),this.fast_=new Ni(t),this.defaultTTFB_=r,this.ttfb_=new Ni(e);}update(e,t){let{slow_:i,fast_:r,ttfb_:n}=this;i.halfLife!==e&&(this.slow_=new Ni(e,i.getEstimate(),i.getTotalWeight())),r.halfLife!==t&&(this.fast_=new Ni(t,r.getEstimate(),r.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Ni(e,n.getEstimate(),n.getTotalWeight()));}sample(e,t){e=Math.max(e,this.minDelayMs_);let i=8*t,r=e/1e3,n=i/r;this.fast_.sample(r,n),this.slow_.sample(r,n);}sampleTTFB(e){let t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5));}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}};function LT(s,e,t){return (e=RT(e))in s?Object.defineProperty(s,e,{value:t,enumerable:true,configurable:true,writable:true}):s[e]=t,s}function Se(){return Se=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i]);}return s},Se.apply(null,arguments)}function km(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 Te(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?km(Object(t),true).forEach(function(i){LT(s,i,t[i]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):km(Object(t)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(t,i));});}return s}function xT(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 RT(s){var e=xT(s,"string");return typeof e=="symbol"?e:e+""}var ht=class{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;let i=`[${e}]:`;this.trace=Ui,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i);}},Ui=function(){},kT={trace:Ui,debug:Ui,log:Ui,warn:Ui,info:Ui,error:Ui};function xc(){return Se({},kT)}function DT(s,e){let t=self.console[s];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${s}] >`):Ui}function Dm(s,e,t){return e[s]?e[s].bind(e):DT(s,t)}var Rc=xc();function CT(s,e,t){let i=xc();if(typeof console=="object"&&s===true||typeof s=="object"){let r=["debug","log","info","warn","error"];r.forEach(n=>{i[n]=Dm(n,s,t);});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.6.15`);}catch{return xc()}r.forEach(n=>{Rc[n]=Dm(n,s);});}else Se(Rc,i);return i}var ye=Rc;function $i(s=true){return typeof self>"u"?void 0:(s||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function MT(s){return typeof self<"u"&&s===self.ManagedMediaSource}function Gg(s,e){let t=Object.keys(s),i=Object.keys(e),r=t.length,n=i.length;return !r||!n||r===n&&!t.some(a=>i.indexOf(a)===-1)}function At(s,e=false){if(typeof TextDecoder<"u"){let l=new TextDecoder("utf-8").decode(s);if(e){let c=l.indexOf("\0");return c!==-1?l.substring(0,c):l}return l.replace(/\0/g,"")}let t=s.length,i,r,n,a="",o=0;for(;o<t;){if(i=s[o++],i===0&&e)return a;if(i===0||i===3)continue;switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:r=s[o++],a+=String.fromCharCode((i&31)<<6|r&63);break;case 14:r=s[o++],n=s[o++],a+=String.fromCharCode((i&15)<<12|(r&63)<<6|(n&63)<<0);break}}return a}function Ze(s){let e="";for(let t=0;t<s.length;t++){let i=s[t].toString(16);i.length<2&&(i="0"+i),e+=i;}return e}function Hg(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function wT(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var rc={exports:{}},Cm;function PT(){return Cm||(Cm=1,(function(s,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(d,l,c){if(c=c||{},d=d.trim(),l=l.trim(),!l){if(!c.alwaysNormalize)return d;var u=o.parseURL(d);if(!u)throw new Error("Error trying to parse base URL.");return u.path=o.normalizePath(u.path),o.buildURLFromParts(u)}var h=o.parseURL(l);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return c.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):l;var f=o.parseURL(d);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=r.exec(f.path);f.netLoc=m[1],f.path=m[2];}f.netLoc&&!f.path&&(f.path="/");var g={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(g.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)g.path=f.path,h.params||(g.params=f.params,h.query||(g.query=f.query));else {var E=f.path,v=E.substring(0,E.lastIndexOf("/")+1)+h.path;g.path=o.normalizePath(v);}return g.path===null&&(g.path=c.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(g)},parseURL:function(d){var l=i.exec(d);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(d){for(d=d.split("").reverse().join("").replace(n,"");d.length!==(d=d.replace(a,"")).length;);return d.split("").reverse().join("")},buildURLFromParts:function(d){return d.scheme+d.netLoc+d.path+d.params+d.query+d.fragment}};s.exports=o;})();})(rc)),rc.exports}var Wu=PT(),In=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};}},be={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},Xo=class{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,OT(this,"stats");}setByteRange(e,t){let i=e.split("@",2),r;i.length===1?r=t?.byteRangeEndOffset||0:r=parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r];}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[be.AUDIO]:null,[be.VIDEO]:null,[be.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e;}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new In),this._stats}set stats(e){this._stats=e;}get url(){return !this._url&&this.baseurl&&this.relurl&&(this._url=Wu.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:true})),this._url||""}set url(e){this._url=e;}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[be.AUDIO]=null,e[be.VIDEO]=null,e[be.AUDIOVIDEO]=null;}};function Fe(s){return s.sn!=="initSegment"}var Sn=class extends Xo{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=false,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e;}get byteLength(){if(this.hasStats){let e=this.stats.total;if(e)return e}if(this.byteRange.length){let e=this.byteRange[0],t=this.byteRange[1];if(H(e)&&H(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e;}get decryptdata(){var e;let{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(!((e=this._decryptdata)!=null&&e.keyId)){let i=Object.keys(t);if(i.length===1){let r=this._decryptdata=t[i[0]]||null;r&&(this._decryptdata=r.getDecryptData(this.sn,t));}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;let e=H(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){var t;let i=Object.keys(this.levelkeys),r=i.length;if(r>1||r===1&&(t=this.levelkeys[i[0]])!=null&&t.encrypted)return true}return false}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!H(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e;}get ref(){return Fe(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e);}setStart(e){this.start=e,this._ref&&(this._ref.start=e);}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e);}setKeyFormat(e){let t=this.levelkeys;if(t){var i;let r=t[e];r&&!((i=this._decryptdata)!=null&&i.keyId)&&(this._decryptdata=r.getDecryptData(this.sn,t));}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort();}setElementaryStreamInfo(e,t,i,r,n,a=false){let{elementaryStreams:o}=this,d=o[e];if(!d){o[e]={startPTS:t,endPTS:i,startDTS:r,endDTS:n,partial:a};return}d.startPTS=Math.min(d.startPTS,t),d.endPTS=Math.max(d.endPTS,i),d.startDTS=Math.min(d.startDTS,r),d.endDTS=Math.max(d.endDTS,n);}},kc=class extends Xo{constructor(e,t,i,r,n){super(i),this.fragOffset=0,this.duration=0,this.gap=false,this.independent=false,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=r;let a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration);}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return !!(e.audio||e.video||e.audiovideo)}};function Kg(s,e){let t=Object.getPrototypeOf(s);if(t){let i=Object.getOwnPropertyDescriptor(t,e);return i||Kg(t,e)}}function OT(s,e){let t=Kg(s,e);t&&(t.enumerable=true,Object.defineProperty(s,e,t));}var Mm=Math.pow(2,32)-1,FT=[].push,Vg={video:1,audio:2,id3:3,text:4};function Ve(s){return String.fromCharCode.apply(null,s)}function Wg(s,e){let t=s[e]<<8|s[e+1];return t<0?65536+t:t}function ie(s,e){let t=Yg(s,e);return t<0?4294967296+t:t}function wm(s,e){let t=ie(s,e);return t*=Math.pow(2,32),t+=ie(s,e+4),t}function Yg(s,e){return s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3]}function NT(s){let e=s.byteLength;for(let t=0;t<e;){let i=ie(s,t);if(i>8&&s[t+4]===109&&s[t+5]===111&&s[t+6]===111&&s[t+7]===102)return true;t=i>1?t+i:e;}return false}function de(s,e){let t=[];if(!e.length)return t;let i=s.byteLength;for(let r=0;r<i;){let n=ie(s,r),a=Ve(s.subarray(r+4,r+8)),o=n>1?r+n:i;if(a===e[0])if(e.length===1)t.push(s.subarray(r+8,o));else {let d=de(s.subarray(r+8,o),e.slice(1));d.length&&FT.apply(t,d);}r=o;}return t}function UT(s){let e=[],t=s[0],i=8,r=ie(s,i);i+=4;let n=0,a=0;t===0?(n=ie(s,i),a=ie(s,i+4),i+=8):(n=wm(s,i),a=wm(s,i+8),i+=16),i+=2;let o=s.length+a,d=Wg(s,i);i+=2;for(let l=0;l<d;l++){let c=i,u=ie(s,c);c+=4;let h=u&2147483647;if((u&2147483648)>>>31===1)return ye.warn("SIDX has hierarchical references (not supported)"),null;let m=ie(s,c);c+=4,e.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/r,start:o,end:o+h-1}}),o+=h,c+=4,i=c;}return {earliestPresentationTime:n,timescale:r,version:t,referencesCount:d,references:e}}function qg(s){let e=[],t=de(s,["moov","trak"]);for(let r=0;r<t.length;r++){let n=t[r],a=de(n,["tkhd"])[0];if(a){let o=a[0],d=ie(a,o===0?12:20),l=de(n,["mdia","mdhd"])[0];if(l){o=l[0];let c=ie(l,o===0?12:20),u=de(n,["mdia","hdlr"])[0];if(u){let h=Ve(u.subarray(8,12)),f={soun:be.AUDIO,vide:be.VIDEO}[h],m=de(n,["mdia","minf","stbl","stsd"])[0],g=$T(m);f?(e[d]={timescale:c,type:f,stsd:g},e[f]=Te({timescale:c,id:d},g)):e[d]={timescale:c,type:h,stsd:g};}}}}return de(s,["moov","mvex","trex"]).forEach(r=>{let n=ie(r,4),a=e[n];a&&(a.default={duration:ie(r,12),flags:ie(r,20)});}),e}function $T(s){let e=s.subarray(8),t=e.subarray(86),i=Ve(e.subarray(4,8)),r=i,n,a=i==="enca"||i==="encv";if(a){let l=de(e,[i])[0].subarray(i==="enca"?28:78);de(l,["sinf"]).forEach(u=>{let h=de(u,["schm"])[0];if(h){let f=Ve(h.subarray(4,8));if(f==="cbcs"||f==="cenc"){let m=de(u,["frma"])[0];m&&(r=Ve(m));}}});}let o=r;switch(r){case "avc1":case "avc2":case "avc3":case "avc4":{let d=de(t,["avcC"])[0];d&&d.length>3&&(r+="."+Co(d[1])+Co(d[2])+Co(d[3]),n=Do(o==="avc1"?"dva1":"dvav",t));break}case "mp4a":{let d=de(e,[i])[0],l=de(d.subarray(28),["esds"])[0];if(l&&l.length>7){let c=4;if(l[c++]!==3)break;c=nc(l,c),c+=2;let u=l[c++];if(u&128&&(c+=2),u&64&&(c+=l[c++]),l[c++]!==4)break;c=nc(l,c);let h=l[c++];if(h===64)r+="."+Co(h);else break;if(c+=12,l[c++]!==5)break;c=nc(l,c);let f=l[c++],m=(f&248)>>3;m===31&&(m+=1+((f&7)<<3)+((l[c]&224)>>5)),r+="."+m;}break}case "hvc1":case "hev1":{let d=de(t,["hvcC"])[0];if(d&&d.length>12){let l=d[1],c=["","A","B","C"][l>>6],u=l&31,h=ie(d,2),f=(l&32)>>5?"H":"L",m=d[12],g=d.subarray(6,12);r+="."+c+u,r+="."+BT(h).toString(16).toUpperCase(),r+="."+f+m;let E="";for(let v=g.length;v--;){let T=g[v];(T||E)&&(E="."+T.toString(16).toUpperCase()+E);}r+=E;}n=Do(o=="hev1"?"dvhe":"dvh1",t);break}case "dvh1":case "dvhe":case "dvav":case "dva1":case "dav1":{r=Do(r,t)||r;break}case "vp09":{let d=de(t,["vpcC"])[0];if(d&&d.length>6){let l=d[4],c=d[5],u=d[6]>>4&15;r+="."+ui(l)+"."+ui(c)+"."+ui(u);}break}case "av01":{let d=de(t,["av1C"])[0];if(d&&d.length>2){let l=d[1]>>>5,c=d[1]&31,u=d[2]>>>7?"H":"M",h=(d[2]&64)>>6,f=(d[2]&32)>>5,m=l===2&&h?f?12:10:h?10:8,g=(d[2]&16)>>4,E=(d[2]&8)>>3,v=(d[2]&4)>>2,T=d[2]&3;r+="."+l+"."+ui(c)+u+"."+ui(m)+"."+g+"."+E+v+T+"."+ui(1)+"."+ui(1)+"."+ui(1)+"."+0,n=Do("dav1",t);}break}}return {codec:r,encrypted:a,supplemental:n}}function Do(s,e){let t=de(e,["dvvC"]),i=t.length?t[0]:de(e,["dvcC"])[0];if(i){let r=i[2]>>1&127,n=i[2]<<5&32|i[3]>>3&31;return s+"."+ui(r)+"."+ui(n)}}function BT(s){let e=0;for(let t=0;t<32;t++)e|=(s>>t&1)<<31-t;return e>>>0}function nc(s,e){let t=e+5;for(;s[e++]&128&&e<t;);return e}function Co(s){return ("0"+s.toString(16).toUpperCase()).slice(-2)}function ui(s){return (s<10?"0":"")+s}function GT(s,e){if(!s||!e)return;let t=e.keyId;t&&e.isCommonEncryption&&jg(s,(i,r)=>{let n=i.subarray(8,24);n.some(a=>a!==0)||(ye.log(`[eme] Patching keyId in 'enc${r?"a":"v"}>sinf>>tenc' box: ${Ze(n)} -> ${Ze(t)}`),i.set(t,8));});}function HT(s){let e=[];return jg(s,t=>e.push(t.subarray(8,24))),e}function jg(s,e){de(s,["moov","trak"]).forEach(i=>{let r=de(i,["mdia","minf","stbl","stsd"])[0];if(!r)return;let n=r.subarray(8),a=de(n,["enca"]),o=a.length>0;o||(a=de(n,["encv"])),a.forEach(d=>{let l=o?d.subarray(28):d.subarray(78);de(l,["sinf"]).forEach(u=>{let h=zg(u);h&&e(h,o);});});});}function zg(s){let e=de(s,["schm"])[0];if(e){let t=Ve(e.subarray(4,8));if(t==="cbcs"||t==="cenc"){let i=de(s,["schi","tenc"])[0];if(i)return i}}}function KT(s,e,t){let i={},r=de(s,["moof","traf"]);for(let n=0;n<r.length;n++){let a=r[n],o=de(a,["tfhd"])[0],d=ie(o,4),l=e[d];if(!l)continue;i[d]||(i[d]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type});let c=i[d],u=de(a,["tfdt"])[0];if(u){let S=u[0],b=ie(u,4);S===1&&(b===Mm?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(b*=Mm+1,b+=ie(u,8))),H(b)&&(!H(c.start)||b<c.start)&&(c.start=b);}let h=l.default,f=ie(o,0)|h?.flags,m=h?.duration||0;f&8&&(f&2?m=ie(o,12):m=ie(o,8));let g=de(a,["trun"]),E=c.start||0,v=0,T=m;for(let S=0;S<g.length;S++){let b=g[S],_=ie(b,4),D=c.sampleCount;c.sampleCount+=_;let I=b[3]&1,k=b[3]&4,R=b[2]&1,L=b[2]&2,w=b[2]&4,B=b[2]&8,K=8,z=_;for(I&&(K+=4),k&&_&&(!(b[K+1]&1)&&c.keyFrameIndex===void 0&&(c.keyFrameIndex=D),K+=4,R?(T=ie(b,K),K+=4):T=m,L&&(K+=4),B&&(K+=4),E+=T,v+=T,z--);z--;)R?(T=ie(b,K),K+=4):T=m,L&&(K+=4),w&&(b[K+1]&1||c.keyFrameIndex===void 0&&(c.keyFrameIndex=c.sampleCount-(z+1),c.keyFrameStart=E),K+=4),B&&(K+=4),E+=T,v+=T;!v&&m&&(v+=m*_);}c.duration+=v;}if(!Object.keys(i).some(n=>i[n].duration)){let n=1/0,a=0,o=de(s,["sidx"]);for(let d=0;d<o.length;d++){let l=UT(o[d]);if(l!=null&&l.references){n=Math.min(n,l.earliestPresentationTime/l.timescale);let c=l.references.reduce((u,h)=>u+h.info.duration||0,0);a=Math.max(a,c+l.earliestPresentationTime/l.timescale);}}a&&H(a)&&Object.keys(i).forEach(d=>{i[d].duration||(i[d].duration=a*i[d].timescale-i[d].start);});}return i}function VT(s){let e={valid:null,remainder:null},t=de(s,["moof"]);if(t.length<2)return e.remainder=s,e;let i=t[t.length-1];return e.valid=s.slice(0,i.byteOffset-8),e.remainder=s.slice(i.byteOffset-8),e}function Dt(s,e){let t=new Uint8Array(s.length+e.length);return t.set(s),t.set(e,s.length),t}function Pm(s,e){let t=[],i=e.samples,r=e.timescale,n=e.id,a=false;return de(i,["moof"]).map(d=>{let l=d.byteOffset-8;de(d,["traf"]).map(u=>{let h=de(u,["tfdt"]).map(f=>{let m=f[0],g=ie(f,4);return m===1&&(g*=Math.pow(2,32),g+=ie(f,8)),g/r})[0];return h!==void 0&&(s=h),de(u,["tfhd"]).map(f=>{let m=ie(f,4),g=ie(f,0)&16777215,E=(g&1)!==0,v=(g&2)!==0,T=(g&8)!==0,S=0,b=(g&16)!==0,_=0,D=(g&32)!==0,I=8;m===n&&(E&&(I+=8),v&&(I+=4),T&&(S=ie(f,I),I+=4),b&&(_=ie(f,I),I+=4),D&&(I+=4),e.type==="video"&&(a=Al(e.codec)),de(u,["trun"]).map(k=>{let R=k[0],L=ie(k,0)&16777215,w=(L&1)!==0,B=0,K=(L&4)!==0,z=(L&256)!==0,V=0,F=(L&512)!==0,q=0,G=(L&1024)!==0,j=(L&2048)!==0,X=0,U=ie(k,4),$=8;w&&(B=ie(k,$),$+=4),K&&($+=4);let se=B+l;for(let Ee=0;Ee<U;Ee++){if(z?(V=ie(k,$),$+=4):V=S,F?(q=ie(k,$),$+=4):q=_,G&&($+=4),j&&(R===0?X=ie(k,$):X=Yg(k,$),$+=4),e.type===be.VIDEO){let re=0;for(;re<q;){let ce=ie(i,se);if(se+=4,WT(a,i[se])){let Ge=i.subarray(se,se+ce);Yu(Ge,a?2:1,s+X/r,t);}se+=ce,re+=ce+4;}}s+=V/r;}}));})});}),t}function Al(s){if(!s)return false;let e=s.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function WT(s,e){if(s){let t=e>>1&63;return t===39||t===40}else return (e&31)===6}function Yu(s,e,t,i){let r=Qg(s),n=0;n+=e;let a=0,o=0,d=0;for(;n<r.length;){a=0;do{if(n>=r.length)break;d=r[n++],a+=d;}while(d===255);o=0;do{if(n>=r.length)break;d=r[n++],o+=d;}while(d===255);let l=r.length-n,c=n;if(o<l)n+=o;else if(o>l){ye.error(`Malformed SEI payload. ${o} is too small, only ${l} bytes left to parse.`);break}if(a===4){if(r[c++]===181){let h=Wg(r,c);if(c+=2,h===49){let f=ie(r,c);if(c+=4,f===1195456820){let m=r[c++];if(m===3){let g=r[c++],E=31&g,v=64&g,T=v?2+E*3:0,S=new Uint8Array(T);if(v){S[0]=g;for(let b=1;b<T;b++)S[b]=r[c++];}i.push({type:m,payloadType:a,pts:t,bytes:S});}}}}}else if(a===5&&o>16){let u=[];for(let m=0;m<16;m++){let g=r[c++].toString(16);u.push(g.length==1?"0"+g:g),(m===3||m===5||m===7||m===9)&&u.push("-");}let h=o-16,f=new Uint8Array(h);for(let m=0;m<h;m++)f[m]=r[c++];i.push({payloadType:a,pts:t,uuid:u.join(""),userData:At(f),userDataBytes:f});}}}function Qg(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 YT(s){let e=s[0],t="",i="",r=0,n=0,a=0,o=0,d=0,l=0;if(e===0){for(;Ve(s.subarray(l,l+1))!=="\0";)t+=Ve(s.subarray(l,l+1)),l+=1;for(t+=Ve(s.subarray(l,l+1)),l+=1;Ve(s.subarray(l,l+1))!=="\0";)i+=Ve(s.subarray(l,l+1)),l+=1;i+=Ve(s.subarray(l,l+1)),l+=1,r=ie(s,12),n=ie(s,16),o=ie(s,20),d=ie(s,24),l=28;}else if(e===1){l+=4,r=ie(s,l),l+=4;let u=ie(s,l);l+=4;let h=ie(s,l);for(l+=4,a=2**32*u+h,_T(a)||(a=Number.MAX_SAFE_INTEGER,ye.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ie(s,l),l+=4,d=ie(s,l),l+=4;Ve(s.subarray(l,l+1))!=="\0";)t+=Ve(s.subarray(l,l+1)),l+=1;for(t+=Ve(s.subarray(l,l+1)),l+=1;Ve(s.subarray(l,l+1))!=="\0";)i+=Ve(s.subarray(l,l+1)),l+=1;i+=Ve(s.subarray(l,l+1)),l+=1;}let c=s.subarray(l,s.byteLength);return {schemeIdUri:t,value:i,timeScale:r,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:d,payload:c}}function qT(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 jT(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.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,false),qT([112,115,115,104],new Uint8Array([i,0,0,0]),s,n,r,a,t)}function zT(s){let e=[];if(s instanceof ArrayBuffer){let t=s.byteLength,i=0;for(;i+32<t;){let r=new DataView(s,i),n=QT(r);e.push(n),i+=n.size;}}return e}function QT(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=Ze(new Uint8Array(a,t+12,16)),d=null,l=null,c=0;if(n===0)c=28;else {let h=s.getUint32(28);if(!h||i<32+h*16)return {offset:t,size:e};d=[];for(let f=0;f<h;f++)d.push(new Uint8Array(a,t+32+f*16,16));c=32+h*16;}if(!c)return {offset:t,size:e};let u=s.getUint32(c);return e-32<u?{offset:t,size:e}:(l=new Uint8Array(a,t+c+4,u),{version:n,systemId:o,kids:d,data:l,offset:t,size:e})}var Xg=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),fr={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function qu(s,e){let t=fr[e];return !!t&&!!t[s.slice(0,4)]}function Ln(s,e,t=true){return !s.split(",").some(i=>!ju(i,e,t))}function ju(s,e,t=true){var i;let r=$i(t);return (i=r?.isTypeSupported(xn(s,e)))!=null?i:false}function xn(s,e){return `${e}/mp4;codecs=${s}`}function Om(s){if(s){let e=s.substring(0,4);return fr.video[e]}return 2}function Zo(s){let e=Xg();return s.split(",").reduce((t,i)=>{let n=e&&Al(i)?9:fr.video[i];return n?(n*2+t)/(t?3:2):(fr.audio[i]+t)/(t?2:1)},0)}var ac={};function XT(s,e=true){if(ac[s])return ac[s];let t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[s];for(let r=0;r<t.length;r++){var i;if(ju(t[r],"audio",e))return ac[s]=t[r],t[r];if(t[r]==="mp3"&&(i=$i(e))!=null&&i.isTypeSupported("audio/mpeg"))return ""}return s}var ZT=/flac|opus|mp4a\.40\.34/i;function Jo(s,e=true){return s.replace(ZT,t=>XT(t.toLowerCase(),e))}function JT(s,e){let t=[];if(s){let i=s.split(",");for(let r=0;r<i.length;r++)qu(i[r],"video")||t.push(i[r]);}return e&&t.push(e),t.join(",")}function Vo(s,e){if(s&&(s.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(s)!==-1)&&(Fm(s,"audio")||Fm(s,"video")))return s;if(e){let t=e.split(",");if(t.length>1){if(s){for(let i=t.length;i--;)if(t[i].substring(0,4)===s.substring(0,4))return t[i]}return t[0]}}return e||s}function Fm(s,e){return qu(s,e)&&ju(s,e)}function ey(s){let e=s.split(",");for(let t=0;t<e.length;t++){let i=e[t].split(".");i.length>2&&i[0]==="avc1"&&(e[t]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`);}return e.join(",")}function ty(s){if(s.startsWith("av01.")){let e=s.split("."),t=["0","111","01","01","01","0"];for(let i=e.length;i>4&&i<10;i++)e[i]=t[i-4];return e.join(".")}return s}function Nm(s){let e=$i(s)||{isTypeSupported:()=>false};return {mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Dc(s){return s.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var iy={supported:true,powerEfficient:true,smooth:true},sy={supported:false,smooth:false,powerEfficient:false},Zg={supported:true,configurations:[],decodingInfoResults:[iy]};function Jg(s,e){return {supported:false,configurations:e,decodingInfoResults:[sy],error:s}}function ry(s,e,t,i,r,n){let a=s.videoCodec,o=s.audioCodec?s.audioGroups:null,d=n?.audioCodec,l=n?.channels,c=l?parseInt(l):d?1/0:2,u=null;if(o!=null&&o.length)try{o.length===1&&o[0]?u=e.groups[o[0]].channels:u=o.reduce((h,f)=>{if(f){let m=e.groups[f];if(!m)throw new Error(`Audio track group ${f} not found`);Object.keys(m.channels).forEach(g=>{h[g]=(h[g]||0)+m.channels[g];});}return h},{2:0});}catch{return true}return a!==void 0&&(a.split(",").some(h=>Al(h))||s.width>1920&&s.height>1088||s.height>1920&&s.width>1088||s.frameRate>Math.max(i,30)||s.videoRange!=="SDR"&&s.videoRange!==t||s.bitrate>Math.max(r,8e6))||!!u&&H(c)&&Object.keys(u).some(h=>parseInt(h)>c)}function ep(s,e,t,i={}){let r=s.videoCodec;if(!r&&!s.audioCodec||!t)return Promise.resolve(Zg);let n=[],a=ny(s),o=a.length,d=ay(s,e,o>0),l=d.length;for(let c=o||1*l||1;c--;){let u={type:"media-source"};if(o&&(u.video=a[c%o]),l){u.audio=d[c%l];let h=u.audio.bitrate;u.video&&h&&(u.video.bitrate-=h);}n.push(u);}if(r){let c=navigator.userAgent;if(r.split(",").some(u=>Al(u))&&Xg())return Promise.resolve(Jg(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${c})`),n))}return Promise.all(n.map(c=>{let u=ly(c);return i[u]||(i[u]=t.decodingInfo(c))})).then(c=>({supported:!c.some(u=>!u.supported),configurations:n,decodingInfoResults:c})).catch(c=>({supported:false,configurations:n,decodingInfoResults:[],error:c}))}function ny(s){var e;let t=(e=s.videoCodec)==null?void 0:e.split(","),i=tp(s),r=s.width||640,n=s.height||480,a=s.frameRate||30,o=s.videoRange.toLowerCase();return t?t.map(d=>{let l={contentType:xn(ty(d),"video"),width:r,height:n,bitrate:i,framerate:a};return o!=="sdr"&&(l.transferFunction=o),l}):[]}function ay(s,e,t){var i;let r=(i=s.audioCodec)==null?void 0:i.split(","),n=tp(s);return r&&s.audioGroups?s.audioGroups.reduce((a,o)=>{var d;let l=o?(d=e.groups[o])==null?void 0:d.tracks:null;return l?l.reduce((c,u)=>{if(u.groupId===o){let h=parseFloat(u.channels||"");r.forEach(f=>{let m={contentType:xn(f,"audio"),bitrate:t?oy(f,n):n};h&&(m.channels=""+h),c.push(m);});}return c},a):a},[]):[]}function oy(s,e){if(e<=1)return 1;let t=128e3;return s==="ec-3"?t=768e3:s==="ac-3"&&(t=64e4),Math.min(e/2,t)}function tp(s){return Math.ceil(Math.max(s.bitrate*.9,s.averageBitrate)/1e3)*1e3||1}function ly(s){let e="",{audio:t,video:i}=s;if(i){let r=Dc(i.contentType);e+=`${r}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`;}if(t){let r=Dc(t.contentType);e+=`${i?"_":""}${r}_c${t.channels}`;}return e}var Cc=["NONE","TYPE-0","TYPE-1",null];function dy(s){return Cc.indexOf(s)>-1}var el=["SDR","PQ","HLG"];function cy(s){return !!s&&el.indexOf(s)>-1}var Wo={No:"",Yes:"YES",v2:"v2"};function Um(s){let{canSkipUntil:e,canSkipDateRanges:t,age:i}=s,r=i<e/2;return e&&r?t?Wo.v2:Wo.Yes:Wo.No}var tl=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}},fs=class{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(i=>!!i).map(i=>i.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;let i=(t=e.supplemental)==null?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`);}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES);}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return $m(this._audioGroups,e)}hasSubtitleGroup(e){return $m(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 $m(s,e){return !e||!s?false:s.indexOf(e)!==-1}function uy(){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 hy(s,e){let t=false,i=[];if(s&&(t=s!=="SDR",i=[s]),e){i=e.allowedVideoRanges||el.slice(0);let r=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:r&&uy(),t||(i=["SDR"]);}return {preferHDR:t,allowedVideoRanges:i}}var fy=s=>{let e=new WeakSet;return (t,i)=>{if(s&&(i=s(t,i)),typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i);}return i}},Ae=(s,e)=>JSON.stringify(s,fy(e));function my(s,e,t,i,r){let n=Object.keys(s),a=i?.channels,o=i?.audioCodec,d=r?.videoCodec,l=a&&parseInt(a)===2,c=false,u=false,h=1/0,f=1/0,m=1/0,g=1/0,E=0,v=[],{preferHDR:T,allowedVideoRanges:S}=hy(e,r);for(let k=n.length;k--;){let R=s[n[k]];c||(c=R.channels[2]>0),h=Math.min(h,R.minHeight),f=Math.min(f,R.minFramerate),m=Math.min(m,R.minBitrate),S.filter(w=>R.videoRanges[w]>0).length>0&&(u=true);}h=H(h)?h:0,f=H(f)?f:0;let b=Math.max(1080,h),_=Math.max(30,f);m=H(m)?m:t,t=Math.max(m,t),u||(e=void 0);let D=n.length>1;return {codecSet:n.reduce((k,R)=>{let L=s[R];if(R===k)return k;if(v=u?S.filter(w=>L.videoRanges[w]>0):[],D){if(L.minBitrate>t)return di(R,`min bitrate of ${L.minBitrate} > current estimate of ${t}`),k;if(!L.hasDefaultAudio)return di(R,"no renditions with default or auto-select sound found"),k;if(o&&R.indexOf(o.substring(0,4))%5!==0)return di(R,`audio codec preference "${o}" not found`),k;if(a&&!l){if(!L.channels[a])return di(R,`no renditions with ${a} channel sound found (channels options: ${Object.keys(L.channels)})`),k}else if((!o||l)&&c&&L.channels[2]===0)return di(R,"no renditions with stereo sound found"),k;if(L.minHeight>b)return di(R,`min resolution of ${L.minHeight} > maximum of ${b}`),k;if(L.minFramerate>_)return di(R,`min framerate of ${L.minFramerate} > maximum of ${_}`),k;if(!v.some(w=>L.videoRanges[w]>0))return di(R,`no variants with VIDEO-RANGE of ${Ae(v)} found`),k;if(d&&R.indexOf(d.substring(0,4))%5!==0)return di(R,`video codec preference "${d}" not found`),k;if(L.maxScore<E)return di(R,`max score of ${L.maxScore} < selected max of ${E}`),k}return k&&(Zo(R)>=Zo(k)||L.fragmentError>s[k].fragmentError)?k:(g=L.minIndex,E=L.maxScore,R)},void 0),videoRanges:v,preferHDR:T,minFramerate:f,minBitrate:m,minIndex:g}}function di(s,e){ye.log(`[abr] start candidates with "${s}" ignored because ${e}`);}function ip(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 gy(s,e,t,i){return s.slice(t,i+1).reduce((r,n,a)=>{if(!n.codecSet)return r;let o=n.audioGroups,d=r[n.codecSet];d||(r[n.codecSet]=d={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:a,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),d.minBitrate=Math.min(d.minBitrate,n.bitrate);let l=Math.min(n.height,n.width);return d.minHeight=Math.min(d.minHeight,l),d.minFramerate=Math.min(d.minFramerate,n.frameRate),d.minIndex=Math.min(d.minIndex,a),d.maxScore=Math.max(d.maxScore,n.score),d.fragmentError+=n.fragmentError,d.videoRanges[n.videoRange]=(d.videoRanges[n.videoRange]||0)+1,o&&o.forEach(c=>{if(!c)return;let u=e.groups[c];u&&(d.hasDefaultAudio=d.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(h=>{d.channels[h]=(d.channels[h]||0)+u.channels[h];}));}),r},{})}function Bm(s){if(!s)return s;let{lang:e,assocLang:t,characteristics:i,channels:r,audioCodec:n}=s;return {lang:e,assocLang:t,characteristics:i,channels:r,audioCodec:n}}function fi(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(us(s,r,t))return i}return -1}function us(s,e,t){let{groupId:i,name:r,lang:n,assocLang:a,default:o}=s,d=s.forced;return (i===void 0||e.groupId===i)&&(r===void 0||e.name===r)&&(n===void 0||py(n,e.lang))&&(n===void 0||e.assocLang===a)&&(o===void 0||e.default===o)&&(d===void 0||e.forced===d)&&(!("characteristics"in s)||Ey(s.characteristics||"",e.characteristics))&&(t===void 0||t(s,e))}function py(s,e="--"){return s.length===e.length?s===e:s.startsWith(e)||e.startsWith(s)}function Ey(s,e=""){let t=s.split(","),i=e.split(",");return t.length===i.length&&!t.some(r=>i.indexOf(r)===-1)}function ds(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 vy(s,e,t,i,r){let n=e[i],o=e.reduce((h,f,m)=>{let g=f.uri;return (h[g]||(h[g]=[])).push(m),h},{})[n.uri];o.length>1&&(i=Math.max.apply(Math,o));let d=n.videoRange,l=n.frameRate,c=n.codecSet.substring(0,4),u=Gm(e,i,h=>{if(h.videoRange!==d||h.frameRate!==l||h.codecSet.substring(0,4)!==c)return false;let f=h.audioGroups,m=t.filter(g=>!f||f.indexOf(g.groupId)!==-1);return fi(s,m,r)>-1});return u>-1?u:Gm(e,i,h=>{let f=h.audioGroups,m=t.filter(g=>!f||f.indexOf(g.groupId)!==-1);return fi(s,m,r)>-1})}function Gm(s,e,t){for(let i=e;i>-1;i--)if(t(s[i]))return i;for(let i=e+1;i<s.length;i++)if(t(s[i]))return i;return -1}function il(s,e){var t;return !!s&&s!==((t=e.loadLevelObj)==null?void 0:t.uri)}var Mc=class extends ht{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var i;let{fragCurrent:r,partCurrent:n,hls:a}=this,{autoLevelEnabled:o,media:d}=a;if(!r||!d)return;let l=performance.now(),c=n?n.stats:r.stats,u=n?n.duration:r.duration,h=l-c.loading.start,f=a.minAutoLevel,m=r.level,g=this._nextAutoLevel;if(c.aborted||c.loaded&&c.loaded===c.total||m<=f){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;let E=g>-1&&g!==m,v=!!t||E;if(!v&&(d.paused||!d.playbackRate||!d.readyState))return;let T=a.mainForwardBufferInfo;if(!v&&T===null)return;let S=this.bwEstimator.getEstimateTTFB(),b=Math.abs(d.playbackRate);if(h<=Math.max(S,1e3*(u/(b*2))))return;let _=T?T.len/b:0,D=c.loading.first?c.loading.first-c.loading.start:-1,I=c.loaded&&D>-1,k=this.getBwEstimate(),R=a.levels,L=R[m],w=Math.max(c.loaded,Math.round(u*(r.bitrate||L.averageBitrate)/8)),B=I?h-D:h;B<1&&I&&(B=Math.min(h,c.loaded*8/k));let K=I?c.loaded*1e3/B:0,z=S/1e3,V=K?(w-c.loaded)/K:w*8/k+z;if(V<=_)return;let F=K?K*8:k,q=((i=t?.details||this.hls.latestLevelDetails)==null?void 0:i.live)===true,G=this.hls.config.abrBandWidthUpFactor,j=Number.POSITIVE_INFINITY,X;for(X=m-1;X>f;X--){let Ee=R[X].maxBitrate,re=!R[X].details||q;if(j=this.getTimeToLoadFrag(z,F,u*Ee,re),j<Math.min(_,u+z))break}if(j>=V||j>u*10)return;I?this.bwEstimator.sample(h-Math.min(S,D),c.loaded):this.bwEstimator.sampleTTFB(h);let U=R[X].maxBitrate;this.getBwEstimate()*G>U&&this.resetEstimator(U);let $=this.findBestLevel(U,f,X,0,_,1,1);$>-1&&(X=$),this.warn(`Fragment ${r.sn}${n?" part "+n.index:""} of level ${m} is loading too slowly;
|
|
1481
1457
|
Fragment duration: ${r.duration.toFixed(3)}
|
|
1482
1458
|
Time to underbuffer: ${_.toFixed(3)} s
|
|
1483
1459
|
Estimated load time for current fragment: ${V.toFixed(3)} s
|
|
1484
|
-
Estimated load time for down switch fragment: ${
|
|
1460
|
+
Estimated load time for down switch fragment: ${j.toFixed(3)} s
|
|
1485
1461
|
TTFB estimate: ${D|0} ms
|
|
1486
1462
|
Current BW estimate: ${H(k)?k|0:"Unknown"} bps
|
|
1487
1463
|
New BW estimate: ${this.getBwEstimate()|0} bps
|
|
1488
|
-
Switching to level ${X} @ ${
|
|
1464
|
+
Switching to level ${X} @ ${U|0} bps`),a.nextLoadLevel=a.nextAutoLevel=X,this.clearTimer();let se=()=>{if(this.clearTimer(),this.fragCurrent===r&&this.hls.loadLevel===X&&X>0){let Ee=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${X>0?"and switching down":""}
|
|
1489
1465
|
Fragment duration: ${r.duration.toFixed(3)} s
|
|
1490
|
-
Time to underbuffer: ${Ee.toFixed(3)} s`),r.abortRequests(),this.fragCurrent=this.partCurrent=null,X>f){let re=this.findBestLevel(this.hls.levels[f].bitrate,f,X,0,Ee,1,1);re===-1&&(re=f),this.hls.nextLoadLevel=this.hls.nextAutoLevel=re,this.resetEstimator(this.hls.levels[re].bitrate);}}};E||V>q*2?se():this.timer=self.setInterval(se,q*1e3),a.trigger(p.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:n,stats:c});},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners();}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator();}initEstimator(){let e=this.hls.config;return new Rc(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=this.supportedCache=null,this.fragCurrent=this.partCurrent=null;}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer();}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null;}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey="";}onFragLoading(e,t){let i=t.frag;if(!this.ignoreFragment(i)){if(!i.bitrateTest){var r;this.fragCurrent=i,this.partCurrent=(r=t.part)!=null?r:null;}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100);}}onLevelSwitching(e,t){this.clearTimer();}onError(e,t){if(!t.fatal)switch(t.details){case 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 u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(u,d),o.loaded);}else this.bwEstimator.sampleTTFB(l);}break}}}getTimeToLoadFrag(e,t,i,r){let n=e+i/t,a=r?e+this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let i=this.hls.config,{loading:r}=t.stats,n=r.end-r.first;H(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo);}onFragLoaded(e,{frag:t,part:i}){let r=i?i.stats:t.stats;if(t.type===W.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!==W.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1);}get firstAutoLevel(){let{maxAutoLevel:e,minAutoLevel:t}=this.hls,i=this.getBwEstimate(),r=this.hls.config.maxStarvationDelay,n=this.findBestLevel(i,t,e,0,r,1,1);if(n>-1)return n;let a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){let e=this.forcedAutoLevel,i=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(e!==-1&&(!i||!r||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;let n=i&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){let a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return `${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:i}=this;if(i.levels.length<=1)return i.loadLevel;let{maxAutoLevel:r,config:n,minAutoLevel:a}=i,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),d=this.getStarvationDelay(),c=n.abrBandWidthFactor,u=n.abrBandWidthUpFactor;if(d){let E=this.findBestLevel(l,a,r,d,0,c,u);if(E>=0)return this.rebufferNotice=-1,E}let h=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!d){let E=this.bitrateTestDelay;E&&(h=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-E,this.info(`bitrate test took ${Math.round(1e3*E)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),c=u=1);}let f=this.findBestLevel(l,a,r,d,h,c,u);if(this.rebufferNotice!==f&&(this.rebufferNotice=f,this.info(`${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`)),f>-1)return f;let m=i.levels[a],g=i.loadLevelObj;return g&&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,u=c===-1?this.hls.firstLevel:c,{fragCurrent:h,partCurrent:f}=this,{levels:m,allAudioTracks:g,loadLevel:E,config:v}=this.hls;if(m.length===1)return 0;let y=m[u],S=!!((l=this.hls.latestLevelDetails)!=null&&l.live),b=E===-1||c===-1,_,D="SDR",I=y?.frameRate||0,{audioPreference:k,videoPreference:R}=v,L=this.audioTracksByGroup||(this.audioTracksByGroup=op(g)),M=-1;if(b){if(this.firstSelection!==-1)return this.firstSelection;let F=this.codecTiers||(this.codecTiers=Sy(m,L,t,i)),Y=yy(F,D,e,k,R),{codecSet:G,videoRanges:q,minFramerate:X,minBitrate:N,minIndex:B,preferHDR:se}=Y;M=B,_=G,D=se?q[q.length-1]:q[0],I=X,e=Math.max(e,N),this.log(`picked start tier ${Ae(Y)}`);}else _=y?.codecSet,D=y?.videoRange;let $=f?f.duration:h?h.duration:0,K=this.bwEstimator.getEstimateTTFB()/1e3,j=[];for(let F=i;F>=t;F--){var V;let Y=m[F],G=F>u;if(!Y)continue;if(v.useMediaCapabilities&&!Y.supportedResult&&!Y.supportedPromise){let re=navigator.mediaCapabilities;typeof re?.decodingInfo=="function"&&cy(Y,L,D,I,e,k)?(Y.supportedPromise=np(Y,L,re,this.supportedCache),Y.supportedPromise.then(ce=>{if(!this.hls)return;Y.supportedResult=ce;let Ge=this.hls.levels,Ue=Ge.indexOf(Y);ce.error?this.warn(`MediaCapabilities decodingInfo error: "${ce.error}" for level ${Ue} ${Ae(ce)}`):ce.supported?ce.decodingInfoResults.some(st=>st.smooth===false||st.powerEfficient===false)&&this.log(`MediaCapabilities decodingInfo for level ${Ue} not smooth or powerEfficient: ${Ae(ce)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${Ue} ${Ae(ce)}`),Ue>-1&&Ge.length>1&&(this.log(`Removing unsupported level ${Ue}`),this.hls.removeLevel(Ue),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)));}).catch(ce=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${ce}`);})):Y.supportedResult=sp;}if((_&&Y.codecSet!==_||D&&Y.videoRange!==D||G&&I>Y.frameRate||!G&&I>0&&I<Y.frameRate||(V=Y.supportedResult)!=null&&(V=V.decodingInfoResults)!=null&&V.some(re=>re.smooth===false))&&(!b||F!==M)){j.push(F);continue}let q=Y.details,X=(f?q?.partTarget:q?.averagetargetduration)||$,N;G?N=o*e:N=a*e;let B=$&&r>=$*2&&n===0?Y.averageBitrate:Y.maxBitrate,se=this.getTimeToLoadFrag(K,N,B*X,q===void 0);if(N>=B&&(F===c||Y.loadError===0&&Y.fragmentError===0)&&(se<=K||!H(se)||S&&!this.bitrateTestDelay||se<d)){let re=this.forcedAutoLevel;return F!==E&&(re===-1||re!==E)&&(j.length&&this.trace(`Skipped level(s) ${j.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${m[j[0]].codecs}" ${m[j[0]].videoRange}; not compatible with "${_}" ${D}`),this.info(`switch candidate:${u}->${F} adjustedbw(${Math.round(N)})-bitrate=${Math.round(N-B)} ttfb:${K.toFixed(1)} avgDuration:${X.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${se.toFixed(1)} firstSelection:${b} codecSet:${Y.codecSet} videoRange:${Y.videoRange} hls.loadLevel:${E}`)),b&&(this.firstSelection=F),F}}return -1}set nextAutoLevel(e){let t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t);}deriveNextAutoLevel(e){let{maxAutoLevel:t,minAutoLevel:i}=this.hls;return Math.min(Math.max(e,i),t)}},lp={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 Iy(s,e,t){if(e===null||!Array.isArray(s)||!s.length||!H(e))return null;let i=s[0].programDateTime;if(e<(i||0))return null;let r=s[s.length-1].endProgramDateTime;if(e>=(r||0))return null;for(let n=0;n<s.length;++n){let a=s[n];if(xy(e,t,a))return a}return null}function gs(s,e,t=0,i=0,r=.005){let n=null;if(s){n=e[1+s.sn-e[0].sn]||null;let o=s.endDTS-t;o>0&&o<15e-7&&(t+=15e-7),n&&s.level!==n.level&&n.end<=s.end&&(n=e[2+s.sn-e[0].sn]||null);}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!s||s.level===n.level)&&qm(t,i,n)===0||Ly(n,s,Math.min(r,i))))return n;let a=lp.search(e,qm.bind(null,t,i));return a&&(a!==s||!n)?a:n}function Ly(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 qm(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 xy(s,e,t){let i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return (t.endProgramDateTime||0)-i>s}function dp(s,e,t){if(s&&s.startCC<=e&&s.endCC>=e){let i=s.fragments,{fragmentHint:r}=s;r&&(i=i.concat(r));let n;return lp.search(i,a=>a.cc<e?1:a.cc>e?-1:(n=a,a.end<=t?1:a.start>t?-1:0)),n||null}return null}function al(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 cp(s){return s.details.startsWith("key")}function up(s){return cp(s)&&!!s.frag&&!s.frag.decryptdata}function jm(s,e){let t=al(e);return s.default[`${t?"timeout":"error"}Retry`]}function Xu(s,e){let t=s.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*s.retryDelayMs,s.maxRetryDelayMs)}function zm(s){return Te(Te({},s),{errorRetry:null,timeoutRetry:null})}function ol(s,e,t,i){if(!s)return false;let r=i?.code,n=e<s.maxNumRetry&&(Ry(r)||!!t);return s.shouldRetry?s.shouldRetry(s,e,t,i,n):n}function Ry(s){return Oc(s)||!!s&&(s<400||s>499)}function Oc(s){return s===0&&navigator.onLine===false}var Qe={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},St={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4},Fc=class extends ft{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,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;}startLoad(e){}stopLoad(){this.playlistError=0;}getVariantLevelIndex(e){return e?.type===W.MAIN?e.level:this.getVariantIndex()}getVariantIndex(){var e;let t=this.hls,i=t.currentLevel;return (e=t.loadLevelObj)!=null&&e.details||i===-1?t.loadLevel:i}variantHasKey(e,t){if(e){var i;if((i=e.details)!=null&&i.hasKey(t))return true;let r=e.audioGroups;if(r)return this.hls.allAudioTracks.filter(a=>r.indexOf(a.groupId)>=0).some(a=>{var o;return (o=a.details)==null?void 0:o.hasKey(t)})}return false}onManifestLoading(){this.playlistError=0;}onLevelUpdated(){this.playlistError=0;}onError(e,t){var i;if(t.fatal)return;let r=this.hls,n=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=ur();return}case x.FRAG_GAP:case x.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Qe.SendAlternateToPenaltyBox;return}case x.LEVEL_EMPTY_ERROR:case x.LEVEL_PARSING_ERROR:{var a;let l=t.parent===W.MAIN?t.level:r.loadLevel;t.details===x.LEVEL_EMPTY_ERROR&&((a=t.context)!=null&&(a=a.levelDetails)!=null&&a.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l):(t.levelRetry=false,t.errorAction=this.getLevelSwitchAction(t,l));}return;case x.LEVEL_LOAD_ERROR:case x.LEVEL_LOAD_TIMEOUT:typeof n?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.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(n){let l=r.loadLevelObj;if(l&&(n.type===ue.AUDIO_TRACK&&l.hasAudioGroup(n.groupId)||n.type===ue.SUBTITLE_TRACK&&l.hasSubtitleGroup(n.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.loadLevel),t.errorAction.action=Qe.SendAlternateToPenaltyBox,t.errorAction.flags=St.MoveAllAlternatesMatchingHost;return}}return;case x.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:Qe.SendAlternateToPenaltyBox,flags:St.MoveAllAlternatesMatchingHDCP};return;case x.KEY_SYSTEM_SESSION_UPDATE_FAILED:case x.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case x.KEY_SYSTEM_NO_SESSION:t.errorAction={action:Qe.SendAlternateToPenaltyBox,flags:St.MoveAllAlternatesMatchingKey};return;case x.BUFFER_ADD_CODEC_ERROR:case x.REMUX_ALLOC_ERROR:case x.BUFFER_APPEND_ERROR:if(!t.errorAction){var o;t.errorAction=this.getLevelSwitchAction(t,(o=t.level)!=null?o:r.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=ur();return}t.type===z.KEY_SYSTEM_ERROR&&(t.levelRetry=false,t.errorAction=ur());}getPlaylistRetryOrSwitchAction(e,t){let i=this.hls,r=jm(i.config.playlistLoadPolicy,e),n=this.playlistError++;if(ol(r,n,al(e),e.response))return {action:Qe.RetryRequest,flags:St.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=jm(cp(e)?a:n,e),l=t.levels.reduce((c,u)=>c+u.fragmentError,0);if(r&&(e.details!==x.FRAG_GAP&&r.fragmentError++,!up(e)&&ol(o,l,al(e),e.response)))return {action:Qe.RetryRequest,flags:St.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:u,loadLevel:h,minAutoLevel:f,maxAutoLevel:m}=i;!i.autoLevelEnabled&&!i.config.preserveManualLevelOnError&&(i.loadLevel=-1);let g=(n=e.frag)==null?void 0:n.type,v=(g===W.AUDIO&&d===x.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===x.BUFFER_ADD_CODEC_ERROR||d===x.BUFFER_APPEND_ERROR))&&u.some(({audioCodec:D})=>r.audioCodec!==D),S=e.sourceBufferName==="video"&&(d===x.BUFFER_ADD_CODEC_ERROR||d===x.BUFFER_APPEND_ERROR)&&u.some(({codecSet:D,audioCodec:I})=>r.codecSet!==D&&r.audioCodec===I),{type:b,groupId:_}=(a=e.context)!=null?a:{};for(let D=u.length;D--;){let I=(D+h)%u.length;if(I!==h&&I>=f&&I<=m&&u[I].loadError===0){var o,l;let k=u[I];if(d===x.FRAG_GAP&&g===W.MAIN&&e.frag){let R=u[I].details;if(R){let L=gs(e.frag,R.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else {if(b===ue.AUDIO_TRACK&&k.hasAudioGroup(_)||b===ue.SUBTITLE_TRACK&&k.hasSubtitleGroup(_))continue;if(g===W.AUDIO&&(o=r.audioGroups)!=null&&o.some(R=>k.hasAudioGroup(R))||g===W.SUBTITLE&&(l=r.subtitleGroups)!=null&&l.some(R=>k.hasSubtitleGroup(R))||v&&r.audioCodec===k.audioCodec||S&&r.codecSet===k.codecSet||!v&&r.codecSet!==k.codecSet)continue}c=I;break}}if(c>-1&&i.loadLevel!==c)return e.levelRetry=true,this.playlistError=0,{action:Qe.SendAlternateToPenaltyBox,flags:St.None,nextAutoLevel:c}}return {action:Qe.SendAlternateToPenaltyBox,flags:St.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case Qe.DoNothing:break;case Qe.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}=i,n=i.nextAutoLevel;switch(r){case St.None:this.switchLevel(e,n);break;case St.MoveAllAlternatesMatchingHDCP:{let l=this.getVariantLevelIndex(e.frag),d=t.levels[l],c=d?.attrs["HDCP-LEVEL"];if(i.hdcpLevel=c,c==="NONE")this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(c){t.maxHdcpLevel=wc[wc.indexOf(c)-1],i.resolved=true,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case St.MoveAllAlternatesMatchingKey:{let l=e.decryptdata;if(l){let d=this.hls.levels,c=d.length;for(let h=c;h--;)if(this.variantHasKey(d[h],l)){var a,o;this.log(`Banned key found in level ${h} (${d[h].bitrate}bps) or audio group "${(a=d[h].audioGroups)==null?void 0:a.join(",")}" (${(o=e.frag)==null?void 0:o.type} fragment) ${Ze(l.keyId||[])}`),d[h].fragmentError++,d[h].loadError++,this.log(`Removing level ${h} with key error (${e.error})`),this.hls.removeLevel(h);}let u=e.frag;if(this.hls.levels.length<c)i.resolved=true;else if(u&&u.type!==W.MAIN){let h=u.decryptdata;h&&!l.matches(h)&&(i.resolved=true);}}break}}i.resolved||this.switchLevel(e,n);}switchLevel(e,t){if(t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=true,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===x.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){let i=Mc(e.mimeType),r=this.hls.levels;for(let n=r.length;n--;)r[n][`${e.sourceBufferName}Codec`]===i&&(this.log(`Removing level ${n} for ${e.details} ("${i}" not supported)`),this.hls.removeLevel(n));}}};function ur(s){let e={action:Qe.DoNothing,flags:St.None};return s&&(e.resolved=true),e}var We={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Uc=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&&(e.on(p.MANIFEST_LOADING,this.onManifestLoading,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&&(e.off(p.MANIFEST_LOADING,this.onManifestLoading,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.hls=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;if(n.start<=e&&e<=n.end&&n.loaded)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,true)}getFragAtPos(e,t,i){let{fragments:r}=this,n=Object.keys(r);for(let a=n.length;a--;){let o=r[n[a]];if(o?.body.type===t&&(!i||o.buffered)){let l=o.body;if(l.start<=e&&e<=l.end)return l}}return null}detectEvictedFragments(e,t,i,r,n){this.timeRanges&&(this.timeRanges[e]=t);let a=r?.fragment.sn||-1;Object.keys(this.fragments).forEach(o=>{let l=this.fragments[o];if(!l||a>=l.body.sn)return;if(!l.buffered&&(!l.loaded||n)){l.body.type===i&&this.removeFragment(l.body);return}let d=l.range[e];if(d){if(d.time.length===0){this.removeFragment(l.body);return}d.time.some(c=>{let u=!this.isTimeBuffered(c.startPTS,c.endPTS,t);return u&&this.removeFragment(l.body),u});}});}detectPartialFragments(e){let t=this.timeRanges;if(!t||e.frag.sn==="initSegment")return;let i=e.frag,r=rr(i),n=this.fragments[r];if(!n||n.buffered&&i.gap)return;let a=!i.relurl;Object.keys(t).forEach(o=>{let l=i.elementaryStreams[o];if(!l)return;let d=t[o],c=a||l.partial===true;n.range[o]=this.getBufferedTimes(i,e.part,c,d);}),n.loaded=null,Object.keys(n.range).length?(this.bufferedEnd(n,i),Oo(n)||this.removeParts(i.sn-1,i.type)):this.removeFragment(n.body);}bufferedEnd(e,t){e.buffered=true,(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e);}removeParts(e,t){let i=this.activePartLists[t];i&&(this.activePartLists[t]=Qm(i,r=>r.fragment.sn>=e));}fragBuffered(e,t){let i=rr(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,this.bufferedEnd(r,e));}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 u=r.start(c)-this.bufferPadding,h=r.end(c)+this.bufferPadding;if(d>=u&&l<=h){n.time.push({startPTS:Math.max(a,r.start(c)),endPTS:Math.min(o,r.end(c))});break}else if(a<h&&o>u){let f=Math.max(a,r.start(c)),m=Math.min(o,r.end(c));m>f&&(n.partial=true,n.time.push({startPTS:f,endPTS:m}));}else if(o<=u)break}return n}getPartialFragment(e){let t=null,i,r,n,a=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{let c=l[d];c&&Oo(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||Oo(t))}getState(e){let t=rr(e),i=this.fragments[t];return i?i.buffered?Oo(i)?We.PARTIAL:We.OK:We.APPENDING:We.NOT_LOADED}isTimeBuffered(e,t,i){let r,n;for(let a=0;a<i.length;a++){if(r=i.start(a)-this.bufferPadding,n=i.end(a)+this.bufferPadding,e>=r&&t<=n)return true;if(t<=r)return false}return false}onManifestLoading(){this.removeAllFragments();}onFragLoaded(e,t){if(t.frag.sn==="initSegment"||t.frag.bitrateTest)return;let i=t.frag,r=t.part?null:t,n=rr(i);this.fragments[n]={body:i,appendedPTS:null,loaded:r,buffered:false,range:Object.create(null)};}onBufferAppended(e,t){let{frag:i,part:r,timeRanges:n,type:a}=t;if(i.sn==="initSegment")return;let o=i.type;if(r){let d=this.activePartLists[o];d||(this.activePartLists[o]=d=[]),d.push(r);}this.timeRanges=n;let l=n[a];this.detectEvictedFragments(a,l,o,r);}onFragBuffered(e,t){this.detectPartialFragments(t);}hasFragment(e){let t=rr(e);return !!this.fragments[t]}hasFragments(e){let{fragments:t}=this,i=Object.keys(t);if(!e)return i.length>0;for(let r=i.length;r--;){let n=t[i[r]];if(n?.body.type===e)return true}return false}hasParts(e){var t;return !!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,r,n){r&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o)return;let 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=rr(e);e.clearElementaryStreamInfo();let i=this.activePartLists[e.type];if(i){let r=e.sn;this.activePartLists[e.type]=Qm(i,n=>n.fragment.sn!==r);}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type];}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=false;let t=(e=this.hls)==null||(e=e.latestLevelDetails)==null?void 0:e.partList;t&&t.forEach(i=>i.clearElementaryStreamInfo());}};function Oo(s){var e,t,i;return s.buffered&&!!(s.body.gap||(e=s.range.video)!=null&&e.partial||(t=s.range.audio)!=null&&t.partial||(i=s.range.audiovideo)!=null&&i.partial)}function rr(s){return `${s.type}_${s.level}_${s.sn}`}function Qm(s,e){return s.filter(t=>{let i=e(t);return i||t.clearElementaryStreamInfo(),i})}var Gi={cbc:0,ctr:1},Nc=class{constructor(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i;}decrypt(e,t){switch(this.aesMode){case Gi.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Gi.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}};function ky(s){let e=s.byteLength,t=e&&new DataView(s.buffer).getUint8(e-1);return t?s.slice(0,e-t):s}var Bc=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],u=l[2],h=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 y=f[m],S=f[y],b=f[S],_=f[v]*257^v*16843008;r[m]=_<<24|_>>>8,n[m]=_<<16|_>>>16,a[m]=_<<8|_>>>24,o[m]=_,_=b*16843009^S*65537^y*257^m*16843008,d[v]=_<<24|_>>>8,c[v]=_<<16|_>>>16,u[v]=_<<8|_>>>24,h[v]=_,m?(m=y^f[f[f[b^y]]],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),u=this.sBox,h=this.rcon,f=this.invSubMix,m=f[0],g=f[1],E=f[2],v=f[3],y,S;for(o=0;o<a;o++){if(o<n){y=d[o]=t[o];continue}S=y,o%n===0?(S=S<<8|S>>>24,S=u[S>>>24]<<24|u[S>>>16&255]<<16|u[S>>>8&255]<<8|u[S&255],S^=h[o/n|0]<<24):n>6&&o%n===4&&(S=u[S>>>24]<<24|u[S>>>16&255]<<16|u[S>>>8&255]<<8|u[S&255]),d[o]=y=(d[o-n]^S)>>>0;}for(l=0;l<a;l++)o=a-l,l&3?S=d[o]:S=d[o-4],l<4||o<=4?c[l]=S:c[l]=m[u[S>>>24]]^g[u[S>>>16&255]]^E[u[S>>>8&255]]^v[u[S&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],u=o[3],h=this.uint8ArrayToUint32Array_(i),f=h[0],m=h[1],g=h[2],E=h[3],v=new Int32Array(e),y=new Int32Array(v.length),S,b,_,D,I,k,R,L,M,$,K,j,V,F,Y=this.networkToHostOrderSwap;for(;t<v.length;){for(M=Y(v[t]),$=Y(v[t+1]),K=Y(v[t+2]),j=Y(v[t+3]),I=M^n[0],k=j^n[1],R=K^n[2],L=$^n[3],V=4,F=1;F<r;F++)S=l[I>>>24]^d[k>>16&255]^c[R>>8&255]^u[L&255]^n[V],b=l[k>>>24]^d[R>>16&255]^c[L>>8&255]^u[I&255]^n[V+1],_=l[R>>>24]^d[L>>16&255]^c[I>>8&255]^u[k&255]^n[V+2],D=l[L>>>24]^d[I>>16&255]^c[k>>8&255]^u[R&255]^n[V+3],I=S,k=b,R=_,L=D,V=V+4;S=a[I>>>24]<<24^a[k>>16&255]<<16^a[R>>8&255]<<8^a[L&255]^n[V],b=a[k>>>24]<<24^a[R>>16&255]<<16^a[L>>8&255]<<8^a[I&255]^n[V+1],_=a[R>>>24]<<24^a[L>>16&255]<<16^a[I>>8&255]<<8^a[k&255]^n[V+2],D=a[L>>>24]<<24^a[I>>16&255]<<16^a[k>>8&255]<<8^a[R&255]^n[V+3],y[t]=Y(S^f),y[t+1]=Y(D^m),y[t+2]=Y(_^g),y[t+3]=Y(b^E),f=M,m=$,g=K,E=j,t=t+4;}return y.buffer}},$c=class{constructor(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i;}expandKey(){let e=Dy(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},false,["encrypt","decrypt"])}};function Dy(s){switch(s){case Gi.cbc:return "AES-CBC";case Gi.ctr:return "AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${s}`)}}var Cy=16,Dn=class{constructor(e,{removePKCS7Padding:t=true}={}){if(this.logEnabled=true,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{let i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle);}catch{}this.useSoftware=!this.subtle;}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null;}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?ky(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null);}decrypt(e,t,i,r){return this.useSoftware?new Promise((n,a)=>{let o=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(o,t,i,r);let l=this.flush();l?n(l.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"));}):this.webCryptoDecrypt(new Uint8Array(e),t,i,r)}softwareDecrypt(e,t,i,r){let{currentIV:n,currentResult:a,remainderData:o}=this;if(r!==Gi.cbc||t.byteLength!==16)return ye.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=Ct(o,e),this.remainderData=null);let l=this.getValidChunk(e);if(!l.length)return null;n&&(i=n);let d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new Bc),d.expandKey(t);let c=a;return this.currentResult=d.decrypt(l.buffer,0,i),this.currentIV=l.slice(-16).buffer,c||null}webCryptoDecrypt(e,t,i,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,r));this.key=t,this.fastAesKey=new $c(this.subtle,t,r);}return this.fastAesKey.expandKey().then(n=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new Nc(this.subtle,new Uint8Array(i),r).decrypt(e.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(ye.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,i,r)))}onWebCryptoError(e,t,i,r){let n=this.enableSoftwareAES;if(n){this.useSoftware=true,this.logEnabled=true,this.softwareDecrypt(e,t,i,r);let a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(n?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e,i=e.length-e.length%Cy;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(ye.log(`[decrypter]: ${e}`),this.logEnabled=false);}},Xm=Math.pow(2,17),Gc=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 Vt({type:z.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(m=>m[0]==="GAP")){l(Jm(e));return}else e.gap=false;let d=this.loader=n?new n(r):new a(r),c=Zm(e);e.loader=d;let u=zm(r.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Xm};e.stats=d.stats;let f={onSuccess:(m,g,E,v)=>{this.resetLoader(e,d);let y=m.data;E.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(y.slice(0,16)),y=y.slice(16)),o({frag:e,part:null,payload:y,networkDetails:v});},onError:(m,g,E,v)=>{this.resetLoader(e,d),l(new Vt({type:z.NETWORK_ERROR,details:x.FRAG_LOAD_ERROR,fatal:false,frag:e,response:Te({url:i,data:void 0},m),error:new Error(`HTTP Error ${m.code} ${m.text}`),networkDetails:E,stats:v}));},onAbort:(m,g,E)=>{this.resetLoader(e,d),l(new Vt({type:z.NETWORK_ERROR,details:x.INTERNAL_ABORTED,fatal:false,frag:e,error:new Error("Aborted"),networkDetails:E,stats:m}));},onTimeout:(m,g,E)=>{this.resetLoader(e,d),l(new Vt({type:z.NETWORK_ERROR,details:x.FRAG_LOAD_TIMEOUT,fatal:false,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:E,stats:m}));}};t&&(f.onProgress=(m,g,E,v)=>t({frag:e,part:null,payload:E,networkDetails:v})),d.load(c,h,f);})}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(Jm(e,t));return}let d=this.loader=n?new n(r):new a(r),c=Zm(e,t);e.loader=d;let u=zm(r.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Xm};t.stats=d.stats,d.load(c,h,{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 Vt({type:z.NETWORK_ERROR,details:x.FRAG_LOAD_ERROR,fatal:false,frag:e,part:t,response:Te({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 Vt({type:z.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 Vt({type:z.NETWORK_ERROR,details:x.FRAG_LOAD_TIMEOUT,fatal:false,frag:e,part:t,error:new Error(`Timeout after ${h.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),u=(l-d)*Math.round(i.loaded/d);i.total=i.loaded+u;}else i.total=Math.max(i.loaded,i.total);let a=i.loading,o=r.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end;}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy();}};function Zm(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(H(r)&&H(n)){var a;let o=r,l=n;if(s.sn==="initSegment"&&My((a=s.decryptdata)==null?void 0:a.method)){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 Jm(s,e){let t=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:z.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 Vt(i)}function My(s){return s==="AES-128"||s==="AES-256"}var Vt=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e;}},ll=class extends ft{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this);}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed();}onHandlerDestroying(){this.clearNextTick(),this.clearInterval();}onHandlerDestroyed(){}hasInterval(){return !!this._tickInterval}hasNextTick(){return !!this._tickTimer}setInterval(e){return this._tickInterval?false:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),true)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,true):false}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,true):false}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0);}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0);}doTick(){}},Cn=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=Fo(),this.buffering={audio:Fo(),video:Fo(),audiovideo:Fo()},this.level=e,this.sn=t,this.id=i,this.size=r,this.part=n,this.partial=a;}};function Fo(){return {start:0,executeStart:0,executeEnd:0,end:0}}var eg={length:0,start:()=>0,end:()=>0},ne=class s{static isBuffered(e,t){if(e){let i=s.getBuffered(e);for(let r=i.length;r--;)if(t>=i.start(r)&&t<=i.end(r))return true}return false}static bufferedRanges(e){if(e){let t=s.getBuffered(e);return s.timeRangesToArray(t)}return []}static timeRangesToArray(e){let t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}static bufferInfo(e,t,i){if(e){let r=s.bufferedRanges(e);if(r.length)return s.bufferedInfo(r,t,i)}return {len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((c,u)=>c.start-u.start||u.end-c.end);let r=-1,n=[];if(i)for(let c=0;c<e.length;c++){t>=e[c].start&&t<=e[c].end&&(r=c);let u=n.length;if(u){let h=n[u-1].end;e[c].start-h<i?e[c].end>h&&(n[u-1].end=e[c].end):n.push(e[c]);}else n.push(e[c]);}else n=e;let a=0,o,l=t,d=t;for(let c=0;c<n.length;c++){let u=n[c].start,h=n[c].end;if(r===-1&&t>=u&&t<=h&&(r=c),t+i>=u&&t<h)l=u,d=h,a=d-t;else if(t+i<u){o=u;break}}return {len:a,start:l||0,end:d||0,nextStart:o,buffered:e,bufferedIndex:r}}static getBuffered(e){try{return e.buffered||eg}catch(t){return ye.log("failed to get media.buffered",t),eg}}},hp=/\{\$([a-zA-Z0-9-_]+)\}/g;function tg(s){return hp.test(s)}function Hc(s,e){if(s.variableList!==null||s.hasVariableRefs){let t=s.variableList;return e.replace(hp,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 ig(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 wy(s,e,t){let i=e.IMPORT;if(t&&i in t){let r=s.variableList;r||(s.variableList=r={}),r[i]=t[i];}else s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`));}var Py=/^(\d+)x(\d+)$/,sg=/(.+?)=(".*?"|.*?)(?:,|$)/g,Ce=class s{constructor(e,t){typeof e=="string"&&(e=s.parseAttrList(e,t)),Se(this,e);}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;let i=new Uint8Array(t.length/2);for(let r=0;r<t.length/2;r++)i[r]=parseInt(t.slice(r*2,r*2+2),16);return i}return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){let i=this[e];return (i?i.split(/[ ,]+/):[]).reduce((r,n)=>(r[n.toLowerCase()]=true,r),t)}bool(e){return this[e]==="YES"}decimalResolution(e){let t=Py.exec(this[e]);if(t!==null)return {width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let i,r={};for(sg.lastIndex=0;(i=sg.exec(e))!==null;){let a=i[1].trim(),o=i[2],l=o.indexOf('"')===0&&o.lastIndexOf('"')===o.length-1,d=false;if(l)o=o.slice(1,-1);else switch(a){case "IV":case "SCTE35-CMD":case "SCTE35-IN":case "SCTE35-OUT":d=true;}if(t&&(l||d))o=Hc(t,o);else if(!d&&!l)switch(a){case "CLOSED-CAPTIONS":if(o==="NONE")break;case "ALLOWED-CPC":case "CLASS":case "ASSOC-LANGUAGE":case "AUDIO":case "BYTERANGE":case "CHANNELS":case "CHARACTERISTICS":case "CODECS":case "DATA-ID":case "END-DATE":case "GROUP-ID":case "ID":case "IMPORT":case "INSTREAM-ID":case "KEYFORMAT":case "KEYFORMATVERSIONS":case "LANGUAGE":case "NAME":case "PATHWAY-ID":case "QUERYPARAM":case "RECENTLY-REMOVED-DATERANGES":case "SERVER-URI":case "STABLE-RENDITION-ID":case "STABLE-VARIANT-ID":case "START-DATE":case "SUBTITLES":case "SUPPLEMENTAL-CODECS":case "URI":case "VALUE":case "VIDEO":case "X-ASSET-LIST":case "X-ASSET-URI":ye.warn(`${e}: attribute ${a} is missing quotes`);}r[a]=o;}return r}},Oy="com.apple.hls.interstitial";function Fy(s){return s!=="ID"&&s!=="CLASS"&&s!=="CUE"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function Uy(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"||s==="SCTE35-CMD"}var dl=class{constructor(e,t,i=0){var r;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=t?.tagAnchor||null,this.tagOrder=(r=t?.tagOrder)!=null?r:i,t){let n=t.attr;for(let a in n)if(Object.prototype.hasOwnProperty.call(e,a)&&e[a]!==n[a]){ye.warn(`DATERANGE tag attribute: "${a}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=a;break}e=Se(new Ce({}),n,e);}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let n=t?.endDate||new Date(this.attr["END-DATE"]);H(n.getTime())&&(this._endDate=n);}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){let e=this._cue;return e===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:false,post:false,once:false}):e}get startTime(){let{tagAnchor:e}=this;return e===null||e.programDateTime===null?(ye.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){let e=this._endDate||this._dateAtEnd;if(e)return e;let t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(H(e))return e}else if(this._endDate)return (this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return "PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return this.class===Oy}get isValid(){return !!this.id&&!this._badValueForSameId&&H(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}},Ny=10,Kc=class{constructor(e){this.PTSKnown=false,this.alignedSliding=false,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=true,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=true,this.advanced=true,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=false,this.canSkipUntil=0,this.canSkipDateRanges=false,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=false,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e;}reloaded(e){if(!e){this.advanced=true,this.updated=true;return}let t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1;}hasKey(e){return this.encryptedFragments.some(t=>{let i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}get hasProgramDateTime(){return this.fragments.length?H(this.fragments[this.fragments.length-1].programDateTime):false}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Ny}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(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return (e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){let e=this.partList;if(e){let t=this.lastPartIndex;if(t!==-1){for(let i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}get lastPartSn(){var e;return (e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){let e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return false}};function cl(s,e){return s.length===e.length?!s.some((t,i)=>t!==e[i]):false}function rg(s,e){return !s&&!e?true:!s||!e?false:cl(s,e)}function hr(s){return s==="AES-128"||s==="AES-256"||s==="AES-256-CTR"}function Zu(s){switch(s){case "AES-128":case "AES-256":return Gi.cbc;case "AES-256-CTR":return Gi.ctr;default:throw new Error(`invalid full segment method ${s}`)}}function Ju(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0))}function Vc(s){return Uint8Array.from(unescape(encodeURIComponent(s)),e=>e.charCodeAt(0))}function By(s){let e=Vc(s).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function fp(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 mp(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=Ju(a)):t=By(a);}}return t}var ul=typeof self<"u"?self:void 0,Me={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Je={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function zo(s){switch(s){case Je.FAIRPLAY:return Me.FAIRPLAY;case Je.PLAYREADY:return Me.PLAYREADY;case Je.WIDEVINE:return Me.WIDEVINE;case Je.CLEARKEY:return Me.CLEARKEY}}function dc(s){switch(s){case Me.FAIRPLAY:return Je.FAIRPLAY;case Me.PLAYREADY:return Je.PLAYREADY;case Me.WIDEVINE:return Je.WIDEVINE;case Me.CLEARKEY:return Je.CLEARKEY}}function bn(s){let{drmSystems:e,widevineLicenseUrl:t}=s,i=e?[Me.FAIRPLAY,Me.WIDEVINE,Me.PLAYREADY,Me.CLEARKEY].filter(r=>!!e[r]):[];return !i[Me.WIDEVINE]&&t&&i.push(Me.WIDEVINE),i}var gp=(function(s){return ul!=null&&(s=ul.navigator)!=null&&s.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null})();function $y(s,e,t,i){let r;switch(s){case Me.FAIRPLAY:r=["cenc","sinf"];break;case Me.WIDEVINE:case Me.PLAYREADY:r=["cenc"];break;case Me.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return Gy(r,e,t,i)}function Gy(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 Hy(s){var e;return !!s&&(s.sessionType==="persistent-license"||!!((e=s.sessionTypes)!=null&&e.some(t=>t==="persistent-license")))}function pp(s){let e=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),i=t.substring(t.indexOf("<"),t.length),a=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(a){let o=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(o){let l=Ju(o).subarray(0,16);return fp(l),l}}return null}var nr={},pr=class s{static clearKeyUriToKeyIdMap(){nr={};}static setKeyIdForUri(e,t){nr[e]=t;}static addKeyIdForUri(e){let t=Object.keys(nr).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),nr[e]=i,i}constructor(e,t,i,r=[1],n=null,a){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=r,this.iv=n,this.encrypted=e?e!=="NONE":false,this.isCommonEncryption=this.encrypted&&!hr(e),a!=null&&a.startsWith("0x")&&(this.keyId=new Uint8Array(qg(a)));}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&cl(e.keyFormatVersions,this.keyFormatVersions)&&rg(e.iv,this.iv)&&rg(e.keyId,this.keyId)}isSupported(){if(this.method){if(hr(this.method)||this.method==="NONE")return true;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Je.FAIRPLAY:case Je.WIDEVINE:case Je.PLAYREADY:case Je.CLEARKEY:return ["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return false}getDecryptData(e,t){if(!this.encrypted||!this.uri)return null;if(hr(this.method)){let n=this.iv;return n||(typeof e!="number"&&(ye.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),n=Vy(e)),new s(this.method,this.uri,"identity",this.keyFormatVersions,n)}if(this.keyId){let n=nr[this.uri];if(n&&!cl(this.keyId,n)&&s.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}let i=mp(this.uri);if(i)switch(this.keyFormat){case Je.WIDEVINE:if(this.pssh=i,!this.keyId){let n=ty(i.buffer);if(n.length){var r;let a=n[0];this.keyId=(r=a.kids)!=null&&r.length?a.kids[0]:null;}}this.keyId||(this.keyId=ng(t));break;case Je.PLAYREADY:{let n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=ey(n,null,i),this.keyId=pp(i);break}default:{let n=i.subarray(0,16);if(n.length!==16){let a=new Uint8Array(16);a.set(n,16-n.length),n=a;}this.keyId=n;break}}if(!this.keyId||this.keyId.byteLength!==16){let n;n=Ky(t),n||(n=ng(t),n||(n=nr[this.uri])),n&&(this.keyId=n,s.setKeyIdForUri(this.uri,n));}return this}};function Ky(s){let e=s?.[Je.WIDEVINE];return e?e.keyId:null}function ng(s){let e=s?.[Je.PLAYREADY];if(e){let t=mp(e.uri);if(t)return pp(t)}return null}function Vy(s){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=s>>8*(15-t)&255;return e}var ag=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,og=/#EXT-X-MEDIA:(.*)/g,Wy=/^#EXT(?:INF|-X-TARGETDURATION):/m,cc=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Yy=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),us=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 qu.buildAbsoluteURL(t,e,{alwaysNormalize:true})}static isMediaPlaylist(e){return Wy.test(e)}static parseMasterPlaylist(e,t){let i=tg(e),r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];if(ag.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=new Error("no EXTM3U delimiter"),r;let a;for(;(a=ag.exec(e))!=null;)if(a[1]){var o;let d=new Ce(a[1],r),c=Hc(r,a[2]),u={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:s.resolve(c,t)},h=d.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),cg(d.CODECS,u);let f=d["SUPPLEMENTAL-CODECS"];f&&(u.supplemental={},cg(f,u.supplemental)),(o=u.unknownCodecs)!=null&&o.length||n.push(u),r.levels.push(u);}else if(a[3]){let d=a[3],c=a[4];switch(d){case "SESSION-DATA":{let u=new Ce(c,r),h=u["DATA-ID"];h&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[h]=u);break}case "SESSION-KEY":{let u=lg(c,t,r);u.encrypted&&u.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(u)):ye.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${c}"`);break}case "DEFINE":{{let u=new Ce(c,r);ig(r,u,t);}break}case "CONTENT-STEERING":{let u=new Ce(c,r);r.contentSteering={uri:s.resolve(u["SERVER-URI"],t),pathwayId:u["PATHWAY-ID"]||"."};break}case "START":{r.startTimeOffset=dg(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(og.lastIndex=0;(r=og.exec(e))!==null;){let d=new Ce(r[1],i),c=d.TYPE;if(c){let u=o[c],h=n[c]||[];n[c]=h;let f=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],g=d.CHANNELS,E=d.CHARACTERISTICS,v=d["INSTREAM-ID"],y={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&&(y.assocLang=m),g&&(y.channels=g),E&&(y.characteristics=E),v&&(y.instreamId=v),u!=null&&u.length){let S=s.findGroup(u,y.groupId)||u[0];ug(y,S,"audioCodec"),ug(y,S,"textCodec");}h.push(y);}}return n}static parseLevelPlaylist(e,t,i,r,n,a){var o;let l={url:t},d=new Kc(t),c=d.fragments,u=[],h=null,f=0,m=0,g=0,E=0,v=0,y=null,S=new An(r,l),b,_,D,I=-1,k=false,R=null,L;if(cc.lastIndex=0,d.m3u8=e,d.hasVariableRefs=tg(e),((o=cc.exec(e))==null?void 0:o[0])!=="#EXTM3U")return d.playlistParsingError=new Error("Missing format identifier #EXTM3U"),d;for(;(b=cc.exec(e))!==null;){k&&(k=false,S=new An(r,l),S.playlistOffset=g,S.setStart(g),S.sn=f,S.cc=E,v&&(S.bitrate=v),S.level=i,h&&(S.initSegment=h,h.rawProgramDateTime&&(S.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null),R&&(S.setByteRange(R),R=null)));let j=b[1];if(j){S.duration=parseFloat(j);let V=(" "+b[2]).slice(1);S.title=V||null,S.tagList.push(V?["INF",j,V]:["INF",j]);}else if(b[3]){if(H(S.duration)){S.playlistOffset=g,S.setStart(g),D&&fg(S,D,d),S.sn=f,S.level=i,S.cc=E,c.push(S);let V=(" "+b[3]).slice(1);S.relurl=Hc(d,V),Wc(S,y,u),y=S,g+=S.duration,f++,m=0,k=true;}}else {if(b=b[0].match(Yy),!b){ye.warn("No matches on slow regex match for level playlist!");continue}for(_=1;_<b.length&&b[_]===void 0;_++);let V=(" "+b[_]).slice(1),F=(" "+b[_+1]).slice(1),Y=b[_+2]?(" "+b[_+2]).slice(1):null;switch(V){case "BYTERANGE":y?S.setByteRange(F,y):S.setByteRange(F);break;case "PROGRAM-DATE-TIME":S.rawProgramDateTime=F,S.tagList.push(["PROGRAM-DATE-TIME",F]),I===-1&&(I=c.length);break;case "PLAYLIST-TYPE":d.type&&Si(d,V,b),d.type=F.toUpperCase();break;case "MEDIA-SEQUENCE":d.startSN!==0?Si(d,V,b):c.length>0&&mg(d,V,b),f=d.startSN=parseInt(F);break;case "SKIP":{d.skippedSegments&&Si(d,V,b);let G=new Ce(F,d),q=G.decimalInteger("SKIPPED-SEGMENTS");if(H(q)){d.skippedSegments+=q;for(let N=q;N--;)c.push(null);f+=q;}let X=G.enumeratedString("RECENTLY-REMOVED-DATERANGES");X&&(d.recentlyRemovedDateranges=(d.recentlyRemovedDateranges||[]).concat(X.split(" ")));break}case "TARGETDURATION":d.targetduration!==0&&Si(d,V,b),d.targetduration=Math.max(parseInt(F),1);break;case "VERSION":d.version!==null&&Si(d,V,b),d.version=parseInt(F);break;case "INDEPENDENT-SEGMENTS":break;case "ENDLIST":d.live||Si(d,V,b),d.live=false;break;case "#":(F||Y)&&S.tagList.push(Y?[F,Y]:[F]);break;case "DISCONTINUITY":E++,S.tagList.push(["DIS"]);break;case "GAP":S.gap=true,S.tagList.push([V]);break;case "BITRATE":S.tagList.push([V,F]),v=parseInt(F)*1e3,H(v)?S.bitrate=v:v=0;break;case "DATERANGE":{let G=new Ce(F,d),q=new dl(G,d.dateRanges[G.ID],d.dateRangeTagCount);d.dateRangeTagCount++,q.isValid||d.skippedSegments?d.dateRanges[q.id]=q:ye.warn(`Ignoring invalid DATERANGE tag: "${F}"`),S.tagList.push(["EXT-X-DATERANGE",F]);break}case "DEFINE":{{let G=new Ce(F,d);"IMPORT"in G?wy(d,G,a):ig(d,G,t);}break}case "DISCONTINUITY-SEQUENCE":d.startCC!==0?Si(d,V,b):c.length>0&&mg(d,V,b),d.startCC=E=parseInt(F);break;case "KEY":{let G=lg(F,t,d);if(G.isSupported()){if(G.method==="NONE"){D=void 0;break}D||(D={});let q=D[G.keyFormat];q!=null&&q.matches(G)||(q&&(D=Se({},D)),D[G.keyFormat]=G);}else ye.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${F}"`);break}case "START":d.startTimeOffset=dg(F);break;case "MAP":{let G=new Ce(F,d);if(S.duration){let q=new An(r,l);hg(q,G,i,D),h=q,S.initSegment=h,h.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=h.rawProgramDateTime);}else {let q=S.byteRangeEndOffset;if(q){let X=S.byteRangeStartOffset;R=`${q-X}@${X}`;}else R=null;hg(S,G,i,D),h=S,k=true;}h.cc=E;break}case "SERVER-CONTROL":{L&&Si(d,V,b),L=new Ce(F),d.canBlockReload=L.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=L.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&L.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=L.optionalFloat("PART-HOLD-BACK",0),d.holdBack=L.optionalFloat("HOLD-BACK",0);break}case "PART-INF":{d.partTarget&&Si(d,V,b);let G=new Ce(F);d.partTarget=G.decimalFloatingPoint("PART-TARGET");break}case "PART":{let G=d.partList;G||(G=d.partList=[]);let q=m>0?G[G.length-1]:void 0,X=m++,N=new Ce(F,d),B=new Cc(N,S,l,X,q);G.push(B),S.duration+=B.duration;break}case "PRELOAD-HINT":{let G=new Ce(F,d);d.preloadHint=G;break}case "RENDITION-REPORT":{let G=new Ce(F,d);d.renditionReports=d.renditionReports||[],d.renditionReports.push(G);break}default:ye.warn(`line parsed but not handled: ${b}`);break}}}y&&!y.relurl?(c.pop(),g-=y.duration,d.partList&&(d.fragmentHint=y)):d.partList&&(Wc(S,y,u),S.cc=E,d.fragmentHint=S,D&&fg(S,D,d)),d.targetduration||(d.playlistParsingError=new Error("Missing Target Duration"));let M=c.length,$=c[0],K=c[M-1];if(g+=d.skippedSegments*d.targetduration,g>0&&M&&K){d.averagetargetduration=g/M;let j=K.sn;d.endSN=j!=="initSegment"?j:0,d.live||(K.endList=true),I>0&&(jy(c,I),$&&u.unshift($));}return d.fragmentHint&&(g+=d.fragmentHint.duration),d.totalduration=g,u.length&&d.dateRangeTagCount&&$&&Ep(u,d),d.endCC=E,d}};function Ep(s,e){let t=s.length;if(!t)if(e.hasProgramDateTime){let o=e.fragments[e.fragments.length-1];s.push(o),t++;}else return;let i=s[t-1],r=e.live?1/0:e.totalduration,n=Object.keys(e.dateRanges);for(let o=n.length;o--;){let l=e.dateRanges[n[o]],d=l.startDate.getTime();l.tagAnchor=i.ref;for(let c=t;c--;){var a;if(((a=s[c])==null?void 0:a.sn)<e.startSN)break;let u=qy(e,d,s,c,r);if(u!==-1){l.tagAnchor=e.fragments[u].ref;break}}}}function qy(s,e,t,i,r){let n=t[i];if(n){let o=n.programDateTime;if(e>=o||i===0){var a;let l=(((a=t[i+1])==null?void 0:a.start)||r)-n.start;if(e<=o+l*1e3){let d=t[i].sn-s.startSN;if(d<0)return -1;let c=s.fragments;if(c.length>t.length){let h=(t[i+1]||c[c.length-1]).sn-s.startSN;for(let f=h;f>d;f--){let m=c[f].programDateTime;if(e>=m&&e<m+c[f].duration*1e3)return f}}return d}}}return -1}function lg(s,e,t){var i,r;let n=new Ce(s,t),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&&ye.error(`Invalid IV: ${n.IV}`);let u=o?us.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new pr(a,u,c,h,l,n.KEYID)}function dg(s){let t=new Ce(s).decimalFloatingPoint("TIME-OFFSET");return H(t)?t:null}function cg(s,e){let t=(s||"").split(/[ ,]+/).filter(i=>i);["video","audio","text"].forEach(i=>{let r=t.filter(n=>zu(n,i));r.length&&(e[`${i}Codec`]=r.map(n=>n.split("/")[0]).join(","),t=t.filter(n=>r.indexOf(n)===-1));}),e.unknownCodecs=t;}function ug(s,e,t){let i=e[t];i&&(s[t]=i);}function jy(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 Wc(s,e,t){s.rawProgramDateTime?t.push(s):e!=null&&e.programDateTime&&(s.programDateTime=e.endProgramDateTime);}function hg(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 fg(s,e,t){s.levelkeys=e;let{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(r=>e[r].isCommonEncryption)&&i.push(s);}function Si(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${t[0]})`);}function mg(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`);}function uc(s,e){let t=e.startPTS;if(H(t)){let i=0,r;e.sn>s.sn?(i=t-s.start,r=s):(i=s.start-t,r=e),r.duration!==i&&r.setDuration(i);}else e.sn>s.sn?s.cc===e.cc&&s.minEndPTS?e.setStart(s.start+(s.minEndPTS-s.start)):e.setStart(s.start+s.duration):e.setStart(Math.max(s.start-e.duration,0));}function vp(s,e,t,i,r,n,a){i-t<=0&&(a.warn("Fragment should have a positive duration",e),i=t+e.duration,n=r+e.duration);let l=t,d=i,c=e.startPTS,u=e.endPTS;if(H(c)){let v=Math.abs(c-t);s&&v>s.totalduration?a.warn(`media timestamps and playlist times differ by ${v}s for level ${e.level} ${s.url}`):H(e.deltaPTS)?e.deltaPTS=Math.max(v,e.deltaPTS):e.deltaPTS=v,l=Math.max(t,c),t=Math.min(t,c),r=e.startDTS!==void 0?Math.min(r,e.startDTS):r,d=Math.min(i,u),i=Math.max(i,u),n=e.endDTS!==void 0?Math.max(n,e.endDTS):n;}let h=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(i-e.start),e.startPTS=t,e.maxStartPTS=l,e.startDTS=r,e.endPTS=i,e.minEndPTS=d,e.endDTS=n;let f=e.sn;if(!s||f<s.startSN||f>s.endSN)return 0;let m,g=f-s.startSN,E=s.fragments;for(E[g]=e,m=g;m>0;m--)uc(E[m],E[m-1]);for(m=g;m<E.length-1;m++)uc(E[m],E[m+1]);return s.fragmentHint&&uc(E[E.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=true,h}function zy(s,e,t){if(s===e)return;let i=null,r=s.fragments;for(let c=r.length-1;c>=0;c--){let u=r[c].initSegment;if(u){i=u;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let n;Zy(s,e,(c,u,h,f)=>{if((!e.startCC||e.skippedSegments)&&u.cc!==c.cc){let m=c.cc-u.cc;for(let g=h;g<f.length;g++)f[g].cc+=m;e.endCC=f[f.length-1].cc;}H(c.startPTS)&&H(c.endPTS)&&(u.setStart(u.startPTS=c.startPTS),u.startDTS=c.startDTS,u.maxStartPTS=c.maxStartPTS,u.endPTS=c.endPTS,u.endDTS=c.endDTS,u.minEndPTS=c.minEndPTS,u.setDuration(c.endPTS-c.startPTS),u.duration&&(n=u),e.PTSKnown=e.alignedSliding=true),c.hasStreams&&(u.elementaryStreams=c.elementaryStreams),u.loader=c.loader,c.hasStats&&(u.stats=c.stats),c.initSegment&&(u.initSegment=c.initSegment,i=c.initSegment);});let a=e.fragments,o=e.fragmentHint?a.concat(e.fragmentHint):a;if(i&&o.forEach(c=>{var u;c&&(!c.initSegment||c.initSegment.relurl===((u=i)==null?void 0:u.relurl))&&(c.initSegment=i);}),e.skippedSegments){if(e.deltaUpdateFailed=a.some(c=>!c),e.deltaUpdateFailed){t.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let c=e.skippedSegments;c--;)a.shift();e.startSN=a[0].sn;}else {e.canSkipDateRanges&&(e.dateRanges=Qy(s.dateRanges,e,t));let c=s.fragments.filter(u=>u.rawProgramDateTime);if(s.hasProgramDateTime&&!e.hasProgramDateTime)for(let u=1;u<o.length;u++)o[u].programDateTime===null&&Wc(o[u],o[u-1],c);Ep(c,e);}e.endCC=a[a.length-1].cc;}if(!e.startCC){var l;let c=Sp(s,e.startSN-1);e.startCC=(l=c?.cc)!=null?l:a[0].cc;}Xy(s.partList,e.partList,(c,u)=>{u.elementaryStreams=c.elementaryStreams,u.stats=c.stats;}),n?vp(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS,t):Tp(s,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=s.driftStartTime,e.driftStart=s.driftStart;let d=e.advancedDateTime;if(e.advanced&&d){let c=e.edge;e.driftStart||(e.driftStartTime=d,e.driftStart=c),e.driftEndTime=d,e.driftEnd=c;}else e.driftEndTime=s.driftEndTime,e.driftEnd=s.driftEnd,e.advancedDateTime=s.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=s.requestScheduled);}function Qy(s,e,t){let{dateRanges:i,recentlyRemovedDateranges:r}=e,n=Se({},s);r&&r.forEach(l=>{delete n[l];});let o=Object.keys(n).length;return o?(Object.keys(i).forEach(l=>{let d=n[l],c=new dl(i[l].attr,d);c.isValid?(n[l]=c,d||(c.tagOrder+=o)):t.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${Ae(i[l].attr)}"`);}),n):i}function Xy(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 Zy(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],u=o[d];if(i&&!u&&c&&(u=e.fragments[d]=c),c&&u){t(c,u,d,o);let h=c.relurl,f=u.relurl;if(h&&Jy(h,f)){e.playlistParsingError=gg(`media sequence mismatch ${u.sn}:`,s,e,c,u);return}else if(c.cc!==u.cc){e.playlistParsingError=gg(`discontinuity sequence mismatch (${c.cc}!=${u.cc})`,s,e,c,u);return}}}}function gg(s,e,t,i,r){return new Error(`${s} ${r.url}
|
|
1466
|
+
Time to underbuffer: ${Ee.toFixed(3)} s`),r.abortRequests(),this.fragCurrent=this.partCurrent=null,X>f){let re=this.findBestLevel(this.hls.levels[f].bitrate,f,X,0,Ee,1,1);re===-1&&(re=f),this.hls.nextLoadLevel=this.hls.nextAutoLevel=re,this.resetEstimator(this.hls.levels[re].bitrate);}}};E||V>j*2?se():this.timer=self.setInterval(se,j*1e3),a.trigger(p.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:n,stats:c});},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners();}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator();}initEstimator(){let e=this.hls.config;return new Lc(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=this.supportedCache=null,this.fragCurrent=this.partCurrent=null;}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer();}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null;}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey="";}onFragLoading(e,t){let i=t.frag;if(!this.ignoreFragment(i)){if(!i.bitrateTest){var r;this.fragCurrent=i,this.partCurrent=(r=t.part)!=null?r:null;}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100);}}onLevelSwitching(e,t){this.clearTimer();}onError(e,t){if(!t.fatal)switch(t.details){case 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,d=a-o.loading.start,l=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&l>-1){let u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(d-Math.min(u,l),o.loaded);}else this.bwEstimator.sampleTTFB(d);}break}}}getTimeToLoadFrag(e,t,i,r){let n=e+i/t,a=r?e+this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let i=this.hls.config,{loading:r}=t.stats,n=r.end-r.first;H(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo);}onFragLoaded(e,{frag:t,part:i}){let r=i?i.stats:t.stats;if(t.type===Y.MAIN&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){let n=i?i.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+r.loaded,d=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:d},a.realBitrate=Math.round(8*o/d);}if(t.bitrateTest){let n={stats:r,frag:t,part:i,id:t.type};this.onFragBuffered(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!==Y.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1);}get firstAutoLevel(){let{maxAutoLevel:e,minAutoLevel:t}=this.hls,i=this.getBwEstimate(),r=this.hls.config.maxStarvationDelay,n=this.findBestLevel(i,t,e,0,r,1,1);if(n>-1)return n;let a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){let e=this.forcedAutoLevel,i=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(e!==-1&&(!i||!r||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;let n=i&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){let a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return `${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:i}=this;if(i.levels.length<=1)return i.loadLevel;let{maxAutoLevel:r,config:n,minAutoLevel:a}=i,o=t?t.duration:e?e.duration:0,d=this.getBwEstimate(),l=this.getStarvationDelay(),c=n.abrBandWidthFactor,u=n.abrBandWidthUpFactor;if(l){let E=this.findBestLevel(d,a,r,l,0,c,u);if(E>=0)return this.rebufferNotice=-1,E}let h=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!l){let E=this.bitrateTestDelay;E&&(h=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-E,this.info(`bitrate test took ${Math.round(1e3*E)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),c=u=1);}let f=this.findBestLevel(d,a,r,l,h,c,u);if(this.rebufferNotice!==f&&(this.rebufferNotice=f,this.info(`${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`)),f>-1)return f;let m=i.levels[a],g=i.loadLevelObj;return g&&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 d;let l=r+n,c=this.lastLoadedFragLevel,u=c===-1?this.hls.firstLevel:c,{fragCurrent:h,partCurrent:f}=this,{levels:m,allAudioTracks:g,loadLevel:E,config:v}=this.hls;if(m.length===1)return 0;let T=m[u],S=!!((d=this.hls.latestLevelDetails)!=null&&d.live),b=E===-1||c===-1,_,D="SDR",I=T?.frameRate||0,{audioPreference:k,videoPreference:R}=v,L=this.audioTracksByGroup||(this.audioTracksByGroup=ip(g)),w=-1;if(b){if(this.firstSelection!==-1)return this.firstSelection;let F=this.codecTiers||(this.codecTiers=gy(m,L,t,i)),q=my(F,D,e,k,R),{codecSet:G,videoRanges:j,minFramerate:X,minBitrate:U,minIndex:$,preferHDR:se}=q;w=$,_=G,D=se?j[j.length-1]:j[0],I=X,e=Math.max(e,U),this.log(`picked start tier ${Ae(q)}`);}else _=T?.codecSet,D=T?.videoRange;let B=f?f.duration:h?h.duration:0,K=this.bwEstimator.getEstimateTTFB()/1e3,z=[];for(let F=i;F>=t;F--){var V;let q=m[F],G=F>u;if(!q)continue;if(v.useMediaCapabilities&&!q.supportedResult&&!q.supportedPromise){let re=navigator.mediaCapabilities;typeof re?.decodingInfo=="function"&&ry(q,L,D,I,e,k)?(q.supportedPromise=ep(q,L,re,this.supportedCache),q.supportedPromise.then(ce=>{if(!this.hls)return;q.supportedResult=ce;let Ge=this.hls.levels,Ne=Ge.indexOf(q);ce.error?this.warn(`MediaCapabilities decodingInfo error: "${ce.error}" for level ${Ne} ${Ae(ce)}`):ce.supported?ce.decodingInfoResults.some(st=>st.smooth===false||st.powerEfficient===false)&&this.log(`MediaCapabilities decodingInfo for level ${Ne} not smooth or powerEfficient: ${Ae(ce)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${Ne} ${Ae(ce)}`),Ne>-1&&Ge.length>1&&(this.log(`Removing unsupported level ${Ne}`),this.hls.removeLevel(Ne),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)));}).catch(ce=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${ce}`);})):q.supportedResult=Zg;}if((_&&q.codecSet!==_||D&&q.videoRange!==D||G&&I>q.frameRate||!G&&I>0&&I<q.frameRate||(V=q.supportedResult)!=null&&(V=V.decodingInfoResults)!=null&&V.some(re=>re.smooth===false))&&(!b||F!==w)){z.push(F);continue}let j=q.details,X=(f?j?.partTarget:j?.averagetargetduration)||B,U;G?U=o*e:U=a*e;let $=B&&r>=B*2&&n===0?q.averageBitrate:q.maxBitrate,se=this.getTimeToLoadFrag(K,U,$*X,j===void 0);if(U>=$&&(F===c||q.loadError===0&&q.fragmentError===0)&&(se<=K||!H(se)||S&&!this.bitrateTestDelay||se<l)){let re=this.forcedAutoLevel;return F!==E&&(re===-1||re!==E)&&(z.length&&this.trace(`Skipped level(s) ${z.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${m[z[0]].codecs}" ${m[z[0]].videoRange}; not compatible with "${_}" ${D}`),this.info(`switch candidate:${u}->${F} adjustedbw(${Math.round(U)})-bitrate=${Math.round(U-$)} ttfb:${K.toFixed(1)} avgDuration:${X.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${se.toFixed(1)} firstSelection:${b} codecSet:${q.codecSet} videoRange:${q.videoRange} hls.loadLevel:${E}`)),b&&(this.firstSelection=F),F}}return -1}set nextAutoLevel(e){let t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t);}deriveNextAutoLevel(e){let{maxAutoLevel:t,minAutoLevel:i}=this.hls;return Math.min(Math.max(e,i),t)}},sp={search:function(s,e){let t=0,i=s.length-1,r=null,n=null;for(;t<=i;){r=(t+i)/2|0,n=s[r];let a=e(n);if(a>0)t=r+1;else if(a<0)i=r-1;else return n}return null}};function Ty(s,e,t){if(e===null||!Array.isArray(s)||!s.length||!H(e))return null;let i=s[0].programDateTime;if(e<(i||0))return null;let r=s[s.length-1].endProgramDateTime;if(e>=(r||0))return null;for(let n=0;n<s.length;++n){let a=s[n];if(Sy(e,t,a))return a}return null}function ms(s,e,t=0,i=0,r=.005){let n=null;if(s){n=e[1+s.sn-e[0].sn]||null;let o=s.endDTS-t;o>0&&o<15e-7&&(t+=15e-7),n&&s.level!==n.level&&n.end<=s.end&&(n=e[2+s.sn-e[0].sn]||null);}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!s||s.level===n.level)&&Hm(t,i,n)===0||yy(n,s,Math.min(r,i))))return n;let a=sp.search(e,Hm.bind(null,t,i));return a&&(a!==s||!n)?a:n}function yy(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 Hm(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 Sy(s,e,t){let i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return (t.endProgramDateTime||0)-i>s}function rp(s,e,t){if(s&&s.startCC<=e&&s.endCC>=e){let i=s.fragments,{fragmentHint:r}=s;r&&(i=i.concat(r));let n;return sp.search(i,a=>a.cc<e?1:a.cc>e?-1:(n=a,a.end<=t?1:a.start>t?-1:0)),n||null}return null}function sl(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 np(s){return s.details.startsWith("key")}function ap(s){return np(s)&&!!s.frag&&!s.frag.decryptdata}function Km(s,e){let t=sl(e);return s.default[`${t?"timeout":"error"}Retry`]}function zu(s,e){let t=s.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*s.retryDelayMs,s.maxRetryDelayMs)}function Vm(s){return Te(Te({},s),{errorRetry:null,timeoutRetry:null})}function rl(s,e,t,i){if(!s)return false;let r=i?.code,n=e<s.maxNumRetry&&(by(r)||!!t);return s.shouldRetry?s.shouldRetry(s,e,t,i,n):n}function by(s){return wc(s)||!!s&&(s<400||s>499)}function wc(s){return s===0&&navigator.onLine===false}var Qe={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},yt={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4},Pc=class extends ht{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,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;}startLoad(e){}stopLoad(){this.playlistError=0;}getVariantLevelIndex(e){return e?.type===Y.MAIN?e.level:this.getVariantIndex()}getVariantIndex(){var e;let t=this.hls,i=t.currentLevel;return (e=t.loadLevelObj)!=null&&e.details||i===-1?t.loadLevel:i}variantHasKey(e,t){if(e){var i;if((i=e.details)!=null&&i.hasKey(t))return true;let r=e.audioGroups;if(r)return this.hls.allAudioTracks.filter(a=>r.indexOf(a.groupId)>=0).some(a=>{var o;return (o=a.details)==null?void 0:o.hasKey(t)})}return false}onManifestLoading(){this.playlistError=0;}onLevelUpdated(){this.playlistError=0;}onError(e,t){var i;if(t.fatal)return;let r=this.hls,n=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=dr();return}case x.FRAG_GAP:case x.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Qe.SendAlternateToPenaltyBox;return}case x.LEVEL_EMPTY_ERROR:case x.LEVEL_PARSING_ERROR:{var a;let d=t.parent===Y.MAIN?t.level:r.loadLevel;t.details===x.LEVEL_EMPTY_ERROR&&((a=t.context)!=null&&(a=a.levelDetails)!=null&&a.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 n?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.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(n){let d=r.loadLevelObj;if(d&&(n.type===ue.AUDIO_TRACK&&d.hasAudioGroup(n.groupId)||n.type===ue.SUBTITLE_TRACK&&d.hasSubtitleGroup(n.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.loadLevel),t.errorAction.action=Qe.SendAlternateToPenaltyBox,t.errorAction.flags=yt.MoveAllAlternatesMatchingHost;return}}return;case x.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:Qe.SendAlternateToPenaltyBox,flags:yt.MoveAllAlternatesMatchingHDCP};return;case x.KEY_SYSTEM_SESSION_UPDATE_FAILED:case x.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case x.KEY_SYSTEM_NO_SESSION:t.errorAction={action:Qe.SendAlternateToPenaltyBox,flags:yt.MoveAllAlternatesMatchingKey};return;case x.BUFFER_ADD_CODEC_ERROR:case x.REMUX_ALLOC_ERROR:case x.BUFFER_APPEND_ERROR:if(!t.errorAction){var o;t.errorAction=this.getLevelSwitchAction(t,(o=t.level)!=null?o:r.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=dr();return}t.type===Q.KEY_SYSTEM_ERROR&&(t.levelRetry=false,t.errorAction=dr());}getPlaylistRetryOrSwitchAction(e,t){let i=this.hls,r=Km(i.config.playlistLoadPolicy,e),n=this.playlistError++;if(rl(r,n,sl(e),e.response))return {action:Qe.RetryRequest,flags:yt.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=Km(np(e)?a:n,e),d=t.levels.reduce((c,u)=>c+u.fragmentError,0);if(r&&(e.details!==x.FRAG_GAP&&r.fragmentError++,!ap(e)&&rl(o,d,sl(e),e.response)))return {action:Qe.RetryRequest,flags:yt.None,retryConfig:o,retryCount:d};let l=this.getLevelSwitchAction(e,i);return o&&(l.retryConfig=o,l.retryCount=d),l}getLevelSwitchAction(e,t){let i=this.hls;t==null&&(t=i.loadLevel);let r=this.hls.levels[t];if(r){var n,a;let l=e.details;r.loadError++,l===x.BUFFER_APPEND_ERROR&&r.fragmentError++;let c=-1,{levels:u,loadLevel:h,minAutoLevel:f,maxAutoLevel:m}=i;!i.autoLevelEnabled&&!i.config.preserveManualLevelOnError&&(i.loadLevel=-1);let g=(n=e.frag)==null?void 0:n.type,v=(g===Y.AUDIO&&l===x.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(l===x.BUFFER_ADD_CODEC_ERROR||l===x.BUFFER_APPEND_ERROR))&&u.some(({audioCodec:D})=>r.audioCodec!==D),S=e.sourceBufferName==="video"&&(l===x.BUFFER_ADD_CODEC_ERROR||l===x.BUFFER_APPEND_ERROR)&&u.some(({codecSet:D,audioCodec:I})=>r.codecSet!==D&&r.audioCodec===I),{type:b,groupId:_}=(a=e.context)!=null?a:{};for(let D=u.length;D--;){let I=(D+h)%u.length;if(I!==h&&I>=f&&I<=m&&u[I].loadError===0){var o,d;let k=u[I];if(l===x.FRAG_GAP&&g===Y.MAIN&&e.frag){let R=u[I].details;if(R){let L=ms(e.frag,R.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else {if(b===ue.AUDIO_TRACK&&k.hasAudioGroup(_)||b===ue.SUBTITLE_TRACK&&k.hasSubtitleGroup(_))continue;if(g===Y.AUDIO&&(o=r.audioGroups)!=null&&o.some(R=>k.hasAudioGroup(R))||g===Y.SUBTITLE&&(d=r.subtitleGroups)!=null&&d.some(R=>k.hasSubtitleGroup(R))||v&&r.audioCodec===k.audioCodec||S&&r.codecSet===k.codecSet||!v&&r.codecSet!==k.codecSet)continue}c=I;break}}if(c>-1&&i.loadLevel!==c)return e.levelRetry=true,this.playlistError=0,{action:Qe.SendAlternateToPenaltyBox,flags:yt.None,nextAutoLevel:c}}return {action:Qe.SendAlternateToPenaltyBox,flags:yt.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case Qe.DoNothing:break;case Qe.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}=i,n=i.nextAutoLevel;switch(r){case yt.None:this.switchLevel(e,n);break;case yt.MoveAllAlternatesMatchingHDCP:{let d=this.getVariantLevelIndex(e.frag),l=t.levels[d],c=l?.attrs["HDCP-LEVEL"];if(i.hdcpLevel=c,c==="NONE")this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(c){t.maxHdcpLevel=Cc[Cc.indexOf(c)-1],i.resolved=true,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case yt.MoveAllAlternatesMatchingKey:{let d=e.decryptdata;if(d){let l=this.hls.levels,c=l.length;for(let h=c;h--;)if(this.variantHasKey(l[h],d)){var a,o;this.log(`Banned key found in level ${h} (${l[h].bitrate}bps) or audio group "${(a=l[h].audioGroups)==null?void 0:a.join(",")}" (${(o=e.frag)==null?void 0:o.type} fragment) ${Ze(d.keyId||[])}`),l[h].fragmentError++,l[h].loadError++,this.log(`Removing level ${h} with key error (${e.error})`),this.hls.removeLevel(h);}let u=e.frag;if(this.hls.levels.length<c)i.resolved=true;else if(u&&u.type!==Y.MAIN){let h=u.decryptdata;h&&!d.matches(h)&&(i.resolved=true);}}break}}i.resolved||this.switchLevel(e,n);}switchLevel(e,t){if(t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=true,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===x.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){let i=Dc(e.mimeType),r=this.hls.levels;for(let n=r.length;n--;)r[n][`${e.sourceBufferName}Codec`]===i&&(this.log(`Removing level ${n} for ${e.details} ("${i}" not supported)`),this.hls.removeLevel(n));}}};function dr(s){let e={action:Qe.DoNothing,flags:yt.None};return s&&(e.resolved=true),e}var We={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Oc=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&&(e.on(p.MANIFEST_LOADING,this.onManifestLoading,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&&(e.off(p.MANIFEST_LOADING,this.onManifestLoading,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.hls=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;if(n.start<=e&&e<=n.end&&n.loaded)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,true)}getFragAtPos(e,t,i){let{fragments:r}=this,n=Object.keys(r);for(let a=n.length;a--;){let o=r[n[a]];if(o?.body.type===t&&(!i||o.buffered)){let d=o.body;if(d.start<=e&&e<=d.end)return d}}return null}detectEvictedFragments(e,t,i,r,n){this.timeRanges&&(this.timeRanges[e]=t);let a=r?.fragment.sn||-1;Object.keys(this.fragments).forEach(o=>{let d=this.fragments[o];if(!d||a>=d.body.sn)return;if(!d.buffered&&(!d.loaded||n)){d.body.type===i&&this.removeFragment(d.body);return}let l=d.range[e];if(l){if(l.time.length===0){this.removeFragment(d.body);return}l.time.some(c=>{let u=!this.isTimeBuffered(c.startPTS,c.endPTS,t);return u&&this.removeFragment(d.body),u});}});}detectPartialFragments(e){let t=this.timeRanges;if(!t||e.frag.sn==="initSegment")return;let i=e.frag,r=ir(i),n=this.fragments[r];if(!n||n.buffered&&i.gap)return;let a=!i.relurl;Object.keys(t).forEach(o=>{let d=i.elementaryStreams[o];if(!d)return;let l=t[o],c=a||d.partial===true;n.range[o]=this.getBufferedTimes(i,e.part,c,l);}),n.loaded=null,Object.keys(n.range).length?(this.bufferedEnd(n,i),Mo(n)||this.removeParts(i.sn-1,i.type)):this.removeFragment(n.body);}bufferedEnd(e,t){e.buffered=true,(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e);}removeParts(e,t){let i=this.activePartLists[t];i&&(this.activePartLists[t]=Wm(i,r=>r.fragment.sn>=e));}fragBuffered(e,t){let i=ir(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,this.bufferedEnd(r,e));}getBufferedTimes(e,t,i,r){let n={time:[],partial:i},a=e.start,o=e.end,d=e.minEndPTS||o,l=e.maxStartPTS||a;for(let c=0;c<r.length;c++){let u=r.start(c)-this.bufferPadding,h=r.end(c)+this.bufferPadding;if(l>=u&&d<=h){n.time.push({startPTS:Math.max(a,r.start(c)),endPTS:Math.min(o,r.end(c))});break}else if(a<h&&o>u){let f=Math.max(a,r.start(c)),m=Math.min(o,r.end(c));m>f&&(n.partial=true,n.time.push({startPTS:f,endPTS:m}));}else if(o<=u)break}return n}getPartialFragment(e){let t=null,i,r,n,a=0,{bufferPadding:o,fragments:d}=this;return Object.keys(d).forEach(l=>{let c=d[l];c&&Mo(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||Mo(t))}getState(e){let t=ir(e),i=this.fragments[t];return i?i.buffered?Mo(i)?We.PARTIAL:We.OK:We.APPENDING:We.NOT_LOADED}isTimeBuffered(e,t,i){let r,n;for(let a=0;a<i.length;a++){if(r=i.start(a)-this.bufferPadding,n=i.end(a)+this.bufferPadding,e>=r&&t<=n)return true;if(t<=r)return false}return false}onManifestLoading(){this.removeAllFragments();}onFragLoaded(e,t){if(t.frag.sn==="initSegment"||t.frag.bitrateTest)return;let i=t.frag,r=t.part?null:t,n=ir(i);this.fragments[n]={body:i,appendedPTS:null,loaded:r,buffered:false,range:Object.create(null)};}onBufferAppended(e,t){let{frag:i,part:r,timeRanges:n,type:a}=t;if(i.sn==="initSegment")return;let o=i.type;if(r){let l=this.activePartLists[o];l||(this.activePartLists[o]=l=[]),l.push(r);}this.timeRanges=n;let d=n[a];this.detectEvictedFragments(a,d,o,r);}onFragBuffered(e,t){this.detectPartialFragments(t);}hasFragment(e){let t=ir(e);return !!this.fragments[t]}hasFragments(e){let{fragments:t}=this,i=Object.keys(t);if(!e)return i.length>0;for(let r=i.length;r--;){let n=t[i[r]];if(n?.body.type===e)return true}return false}hasParts(e){var t;return !!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,r,n){r&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o)return;let d=o.body;d.type!==i||r&&!d.gap||d.start<t&&d.end>e&&(o.buffered||n)&&this.removeFragment(d);});}removeFragment(e){let t=ir(e);e.clearElementaryStreamInfo();let i=this.activePartLists[e.type];if(i){let r=e.sn;this.activePartLists[e.type]=Wm(i,n=>n.fragment.sn!==r);}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type];}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=false;let t=(e=this.hls)==null||(e=e.latestLevelDetails)==null?void 0:e.partList;t&&t.forEach(i=>i.clearElementaryStreamInfo());}};function Mo(s){var e,t,i;return s.buffered&&!!(s.body.gap||(e=s.range.video)!=null&&e.partial||(t=s.range.audio)!=null&&t.partial||(i=s.range.audiovideo)!=null&&i.partial)}function ir(s){return `${s.type}_${s.level}_${s.sn}`}function Wm(s,e){return s.filter(t=>{let i=e(t);return i||t.clearElementaryStreamInfo(),i})}var Bi={cbc:0,ctr:1},Fc=class{constructor(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i;}decrypt(e,t){switch(this.aesMode){case Bi.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Bi.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}};function Ay(s){let e=s.byteLength,t=e&&new DataView(s.buffer).getUint8(e-1);return t?s.slice(0,e-t):s}var Nc=class{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable();}uint8ArrayToUint32Array_(e){let t=new DataView(e),i=new Uint32Array(4);for(let r=0;r<4;r++)i[r]=t.getUint32(r*4);return i}initTable(){let e=this.sBox,t=this.invSBox,i=this.subMix,r=i[0],n=i[1],a=i[2],o=i[3],d=this.invSubMix,l=d[0],c=d[1],u=d[2],h=d[3],f=new Uint32Array(256),m=0,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 T=f[m],S=f[T],b=f[S],_=f[v]*257^v*16843008;r[m]=_<<24|_>>>8,n[m]=_<<16|_>>>16,a[m]=_<<8|_>>>24,o[m]=_,_=b*16843009^S*65537^T*257^m*16843008,l[v]=_<<24|_>>>8,c[v]=_<<16|_>>>16,u[v]=_<<8|_>>>24,h[v]=_,m?(m=T^f[f[f[b^T]]],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,d,l=this.keySchedule=new Uint32Array(a),c=this.invKeySchedule=new Uint32Array(a),u=this.sBox,h=this.rcon,f=this.invSubMix,m=f[0],g=f[1],E=f[2],v=f[3],T,S;for(o=0;o<a;o++){if(o<n){T=l[o]=t[o];continue}S=T,o%n===0?(S=S<<8|S>>>24,S=u[S>>>24]<<24|u[S>>>16&255]<<16|u[S>>>8&255]<<8|u[S&255],S^=h[o/n|0]<<24):n>6&&o%n===4&&(S=u[S>>>24]<<24|u[S>>>16&255]<<16|u[S>>>8&255]<<8|u[S&255]),l[o]=T=(l[o-n]^S)>>>0;}for(d=0;d<a;d++)o=a-d,d&3?S=l[o]:S=l[o-4],d<4||o<=4?c[d]=S:c[d]=m[u[S>>>24]]^g[u[S>>>16&255]]^E[u[S>>>8&255]]^v[u[S&255]],c[d]=c[d]>>>0;}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){let r=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,d=o[0],l=o[1],c=o[2],u=o[3],h=this.uint8ArrayToUint32Array_(i),f=h[0],m=h[1],g=h[2],E=h[3],v=new Int32Array(e),T=new Int32Array(v.length),S,b,_,D,I,k,R,L,w,B,K,z,V,F,q=this.networkToHostOrderSwap;for(;t<v.length;){for(w=q(v[t]),B=q(v[t+1]),K=q(v[t+2]),z=q(v[t+3]),I=w^n[0],k=z^n[1],R=K^n[2],L=B^n[3],V=4,F=1;F<r;F++)S=d[I>>>24]^l[k>>16&255]^c[R>>8&255]^u[L&255]^n[V],b=d[k>>>24]^l[R>>16&255]^c[L>>8&255]^u[I&255]^n[V+1],_=d[R>>>24]^l[L>>16&255]^c[I>>8&255]^u[k&255]^n[V+2],D=d[L>>>24]^l[I>>16&255]^c[k>>8&255]^u[R&255]^n[V+3],I=S,k=b,R=_,L=D,V=V+4;S=a[I>>>24]<<24^a[k>>16&255]<<16^a[R>>8&255]<<8^a[L&255]^n[V],b=a[k>>>24]<<24^a[R>>16&255]<<16^a[L>>8&255]<<8^a[I&255]^n[V+1],_=a[R>>>24]<<24^a[L>>16&255]<<16^a[I>>8&255]<<8^a[k&255]^n[V+2],D=a[L>>>24]<<24^a[I>>16&255]<<16^a[k>>8&255]<<8^a[R&255]^n[V+3],T[t]=q(S^f),T[t+1]=q(D^m),T[t+2]=q(_^g),T[t+3]=q(b^E),f=w,m=B,g=K,E=z,t=t+4;}return T.buffer}},Uc=class{constructor(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i;}expandKey(){let e=_y(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},false,["encrypt","decrypt"])}};function _y(s){switch(s){case Bi.cbc:return "AES-CBC";case Bi.ctr:return "AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${s}`)}}var Iy=16,Rn=class{constructor(e,{removePKCS7Padding:t=true}={}){if(this.logEnabled=true,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{let i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle);}catch{}this.useSoftware=!this.subtle;}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null;}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?Ay(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null);}decrypt(e,t,i,r){return this.useSoftware?new Promise((n,a)=>{let o=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(o,t,i,r);let d=this.flush();d?n(d.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"));}):this.webCryptoDecrypt(new Uint8Array(e),t,i,r)}softwareDecrypt(e,t,i,r){let{currentIV:n,currentResult:a,remainderData:o}=this;if(r!==Bi.cbc||t.byteLength!==16)return ye.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=Dt(o,e),this.remainderData=null);let d=this.getValidChunk(e);if(!d.length)return null;n&&(i=n);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Nc),l.expandKey(t);let c=a;return this.currentResult=l.decrypt(d.buffer,0,i),this.currentIV=d.slice(-16).buffer,c||null}webCryptoDecrypt(e,t,i,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,r));this.key=t,this.fastAesKey=new Uc(this.subtle,t,r);}return this.fastAesKey.expandKey().then(n=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new Fc(this.subtle,new Uint8Array(i),r).decrypt(e.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(ye.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,i,r)))}onWebCryptoError(e,t,i,r){let n=this.enableSoftwareAES;if(n){this.useSoftware=true,this.logEnabled=true,this.softwareDecrypt(e,t,i,r);let a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(n?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e,i=e.length-e.length%Iy;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(ye.log(`[decrypter]: ${e}`),this.logEnabled=false);}},Ym=Math.pow(2,17),$c=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 Kt({type:Q.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,d)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(m=>m[0]==="GAP")){d(jm(e));return}else e.gap=false;let l=this.loader=n?new n(r):new a(r),c=qm(e);e.loader=l;let u=Vm(r.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Ym};e.stats=l.stats;let f={onSuccess:(m,g,E,v)=>{this.resetLoader(e,l);let T=m.data;E.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(T.slice(0,16)),T=T.slice(16)),o({frag:e,part:null,payload:T,networkDetails:v});},onError:(m,g,E,v)=>{this.resetLoader(e,l),d(new Kt({type:Q.NETWORK_ERROR,details:x.FRAG_LOAD_ERROR,fatal:false,frag:e,response:Te({url:i,data:void 0},m),error:new Error(`HTTP Error ${m.code} ${m.text}`),networkDetails:E,stats:v}));},onAbort:(m,g,E)=>{this.resetLoader(e,l),d(new Kt({type:Q.NETWORK_ERROR,details:x.INTERNAL_ABORTED,fatal:false,frag:e,error:new Error("Aborted"),networkDetails:E,stats:m}));},onTimeout:(m,g,E)=>{this.resetLoader(e,l),d(new Kt({type:Q.NETWORK_ERROR,details:x.FRAG_LOAD_TIMEOUT,fatal:false,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:E,stats:m}));}};t&&(f.onProgress=(m,g,E,v)=>t({frag:e,part:null,payload:E,networkDetails:v})),l.load(c,h,f);})}loadPart(e,t,i){this.abort();let r=this.config,n=r.fLoader,a=r.loader;return new Promise((o,d)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){d(jm(e,t));return}let l=this.loader=n?new n(r):new a(r),c=qm(e,t);e.loader=l;let u=Vm(r.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Ym};t.stats=l.stats,l.load(c,h,{onSuccess:(f,m,g,E)=>{this.resetLoader(e,l),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,l),d(new Kt({type:Q.NETWORK_ERROR,details:x.FRAG_LOAD_ERROR,fatal:false,frag:e,part:t,response:Te({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,l),d(new Kt({type:Q.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,l),d(new Kt({type:Q.NETWORK_ERROR,details:x.FRAG_LOAD_TIMEOUT,fatal:false,frag:e,part:t,error:new Error(`Timeout after ${h.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 d=Math.round(e.duration/t.duration),l=Math.min(Math.round(i.loaded/n),d),u=(d-l)*Math.round(i.loaded/l);i.total=i.loaded+u;}else i.total=Math.max(i.loaded,i.total);let a=i.loading,o=r.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end;}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy();}};function qm(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(H(r)&&H(n)){var a;let o=r,d=n;if(s.sn==="initSegment"&&Ly((a=s.decryptdata)==null?void 0:a.method)){let l=n-r;l%16&&(d=n+(16-l%16)),r!==0&&(i.resetIV=true,o=r-16);}i.rangeStart=o,i.rangeEnd=d;}return i}function jm(s,e){let t=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:Q.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 Kt(i)}function Ly(s){return s==="AES-128"||s==="AES-256"}var Kt=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e;}},nl=class extends ht{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this);}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed();}onHandlerDestroying(){this.clearNextTick(),this.clearInterval();}onHandlerDestroyed(){}hasInterval(){return !!this._tickInterval}hasNextTick(){return !!this._tickTimer}setInterval(e){return this._tickInterval?false:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),true)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,true):false}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,true):false}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0);}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0);}doTick(){}},kn=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=wo(),this.buffering={audio:wo(),video:wo(),audiovideo:wo()},this.level=e,this.sn=t,this.id=i,this.size=r,this.part=n,this.partial=a;}};function wo(){return {start:0,executeStart:0,executeEnd:0,end:0}}var zm={length:0,start:()=>0,end:()=>0},ne=class s{static isBuffered(e,t){if(e){let i=s.getBuffered(e);for(let r=i.length;r--;)if(t>=i.start(r)&&t<=i.end(r))return true}return false}static bufferedRanges(e){if(e){let t=s.getBuffered(e);return s.timeRangesToArray(t)}return []}static timeRangesToArray(e){let t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}static bufferInfo(e,t,i){if(e){let r=s.bufferedRanges(e);if(r.length)return s.bufferedInfo(r,t,i)}return {len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((c,u)=>c.start-u.start||u.end-c.end);let r=-1,n=[];if(i)for(let c=0;c<e.length;c++){t>=e[c].start&&t<=e[c].end&&(r=c);let u=n.length;if(u){let h=n[u-1].end;e[c].start-h<i?e[c].end>h&&(n[u-1].end=e[c].end):n.push(e[c]);}else n.push(e[c]);}else n=e;let a=0,o,d=t,l=t;for(let c=0;c<n.length;c++){let u=n[c].start,h=n[c].end;if(r===-1&&t>=u&&t<=h&&(r=c),t+i>=u&&t<h)d=u,l=h,a=l-t;else if(t+i<u){o=u;break}}return {len:a,start:d||0,end:l||0,nextStart:o,buffered:e,bufferedIndex:r}}static getBuffered(e){try{return e.buffered||zm}catch(t){return ye.log("failed to get media.buffered",t),zm}}},op=/\{\$([a-zA-Z0-9-_]+)\}/g;function Qm(s){return op.test(s)}function Bc(s,e){if(s.variableList!==null||s.hasVariableRefs){let t=s.variableList;return e.replace(op,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 Xm(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 xy(s,e,t){let i=e.IMPORT;if(t&&i in t){let r=s.variableList;r||(s.variableList=r={}),r[i]=t[i];}else s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`));}var Ry=/^(\d+)x(\d+)$/,Zm=/(.+?)=(".*?"|.*?)(?:,|$)/g,De=class s{constructor(e,t){typeof e=="string"&&(e=s.parseAttrList(e,t)),Se(this,e);}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;let i=new Uint8Array(t.length/2);for(let r=0;r<t.length/2;r++)i[r]=parseInt(t.slice(r*2,r*2+2),16);return i}return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){let i=this[e];return (i?i.split(/[ ,]+/):[]).reduce((r,n)=>(r[n.toLowerCase()]=true,r),t)}bool(e){return this[e]==="YES"}decimalResolution(e){let t=Ry.exec(this[e]);if(t!==null)return {width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let i,r={};for(Zm.lastIndex=0;(i=Zm.exec(e))!==null;){let a=i[1].trim(),o=i[2],d=o.indexOf('"')===0&&o.lastIndexOf('"')===o.length-1,l=false;if(d)o=o.slice(1,-1);else switch(a){case "IV":case "SCTE35-CMD":case "SCTE35-IN":case "SCTE35-OUT":l=true;}if(t&&(d||l))o=Bc(t,o);else if(!l&&!d)switch(a){case "CLOSED-CAPTIONS":if(o==="NONE")break;case "ALLOWED-CPC":case "CLASS":case "ASSOC-LANGUAGE":case "AUDIO":case "BYTERANGE":case "CHANNELS":case "CHARACTERISTICS":case "CODECS":case "DATA-ID":case "END-DATE":case "GROUP-ID":case "ID":case "IMPORT":case "INSTREAM-ID":case "KEYFORMAT":case "KEYFORMATVERSIONS":case "LANGUAGE":case "NAME":case "PATHWAY-ID":case "QUERYPARAM":case "RECENTLY-REMOVED-DATERANGES":case "SERVER-URI":case "STABLE-RENDITION-ID":case "STABLE-VARIANT-ID":case "START-DATE":case "SUBTITLES":case "SUPPLEMENTAL-CODECS":case "URI":case "VALUE":case "VIDEO":case "X-ASSET-LIST":case "X-ASSET-URI":ye.warn(`${e}: attribute ${a} is missing quotes`);}r[a]=o;}return r}},ky="com.apple.hls.interstitial";function Dy(s){return s!=="ID"&&s!=="CLASS"&&s!=="CUE"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function Cy(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"||s==="SCTE35-CMD"}var al=class{constructor(e,t,i=0){var r;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=t?.tagAnchor||null,this.tagOrder=(r=t?.tagOrder)!=null?r:i,t){let n=t.attr;for(let a in n)if(Object.prototype.hasOwnProperty.call(e,a)&&e[a]!==n[a]){ye.warn(`DATERANGE tag attribute: "${a}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=a;break}e=Se(new De({}),n,e);}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let n=t?.endDate||new Date(this.attr["END-DATE"]);H(n.getTime())&&(this._endDate=n);}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){let e=this._cue;return e===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:false,post:false,once:false}):e}get startTime(){let{tagAnchor:e}=this;return e===null||e.programDateTime===null?(ye.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){let e=this._endDate||this._dateAtEnd;if(e)return e;let t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(H(e))return e}else if(this._endDate)return (this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return "PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return this.class===ky}get isValid(){return !!this.id&&!this._badValueForSameId&&H(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}},My=10,Gc=class{constructor(e){this.PTSKnown=false,this.alignedSliding=false,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=true,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=true,this.advanced=true,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=false,this.canSkipUntil=0,this.canSkipDateRanges=false,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=false,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e;}reloaded(e){if(!e){this.advanced=true,this.updated=true;return}let t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1;}hasKey(e){return this.encryptedFragments.some(t=>{let i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}get hasProgramDateTime(){return this.fragments.length?H(this.fragments[this.fragments.length-1].programDateTime):false}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||My}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(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return (e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){let e=this.partList;if(e){let t=this.lastPartIndex;if(t!==-1){for(let i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}get lastPartSn(){var e;return (e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){let e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return false}};function ol(s,e){return s.length===e.length?!s.some((t,i)=>t!==e[i]):false}function Jm(s,e){return !s&&!e?true:!s||!e?false:ol(s,e)}function cr(s){return s==="AES-128"||s==="AES-256"||s==="AES-256-CTR"}function Qu(s){switch(s){case "AES-128":case "AES-256":return Bi.cbc;case "AES-256-CTR":return Bi.ctr;default:throw new Error(`invalid full segment method ${s}`)}}function Xu(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0))}function Hc(s){return Uint8Array.from(unescape(encodeURIComponent(s)),e=>e.charCodeAt(0))}function wy(s){let e=Hc(s).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function lp(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 dp(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=Xu(a)):t=wy(a);}}return t}var ll=typeof self<"u"?self:void 0,Ce={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Je={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Yo(s){switch(s){case Je.FAIRPLAY:return Ce.FAIRPLAY;case Je.PLAYREADY:return Ce.PLAYREADY;case Je.WIDEVINE:return Ce.WIDEVINE;case Je.CLEARKEY:return Ce.CLEARKEY}}function oc(s){switch(s){case Ce.FAIRPLAY:return Je.FAIRPLAY;case Ce.PLAYREADY:return Je.PLAYREADY;case Ce.WIDEVINE:return Je.WIDEVINE;case Ce.CLEARKEY:return Je.CLEARKEY}}function yn(s){let{drmSystems:e,widevineLicenseUrl:t}=s,i=e?[Ce.FAIRPLAY,Ce.WIDEVINE,Ce.PLAYREADY,Ce.CLEARKEY].filter(r=>!!e[r]):[];return !i[Ce.WIDEVINE]&&t&&i.push(Ce.WIDEVINE),i}var cp=(function(s){return ll!=null&&(s=ll.navigator)!=null&&s.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null})();function Py(s,e,t,i){let r;switch(s){case Ce.FAIRPLAY:r=["cenc","sinf"];break;case Ce.WIDEVINE:case Ce.PLAYREADY:r=["cenc"];break;case Ce.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return Oy(r,e,t,i)}function Oy(s,e,t,i){return [{initDataTypes:s,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs=${n}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs=${n}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function Fy(s){var e;return !!s&&(s.sessionType==="persistent-license"||!!((e=s.sessionTypes)!=null&&e.some(t=>t==="persistent-license")))}function up(s){let e=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),i=t.substring(t.indexOf("<"),t.length),a=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(a){let o=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(o){let d=Xu(o).subarray(0,16);return lp(d),d}}return null}var sr={},mr=class s{static clearKeyUriToKeyIdMap(){sr={};}static setKeyIdForUri(e,t){sr[e]=t;}static addKeyIdForUri(e){let t=Object.keys(sr).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),sr[e]=i,i}constructor(e,t,i,r=[1],n=null,a){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=r,this.iv=n,this.encrypted=e?e!=="NONE":false,this.isCommonEncryption=this.encrypted&&!cr(e),a!=null&&a.startsWith("0x")&&(this.keyId=new Uint8Array(Hg(a)));}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&ol(e.keyFormatVersions,this.keyFormatVersions)&&Jm(e.iv,this.iv)&&Jm(e.keyId,this.keyId)}isSupported(){if(this.method){if(cr(this.method)||this.method==="NONE")return true;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Je.FAIRPLAY:case Je.WIDEVINE:case Je.PLAYREADY:case Je.CLEARKEY:return ["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return false}getDecryptData(e,t){if(!this.encrypted||!this.uri)return null;if(cr(this.method)){let n=this.iv;return n||(typeof e!="number"&&(ye.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),n=Uy(e)),new s(this.method,this.uri,"identity",this.keyFormatVersions,n)}if(this.keyId){let n=sr[this.uri];if(n&&!ol(this.keyId,n)&&s.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}let i=dp(this.uri);if(i)switch(this.keyFormat){case Je.WIDEVINE:if(this.pssh=i,!this.keyId){let n=zT(i.buffer);if(n.length){var r;let a=n[0];this.keyId=(r=a.kids)!=null&&r.length?a.kids[0]:null;}}this.keyId||(this.keyId=eg(t));break;case Je.PLAYREADY:{let n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=jT(n,null,i),this.keyId=up(i);break}default:{let n=i.subarray(0,16);if(n.length!==16){let a=new Uint8Array(16);a.set(n,16-n.length),n=a;}this.keyId=n;break}}if(!this.keyId||this.keyId.byteLength!==16){let n;n=Ny(t),n||(n=eg(t),n||(n=sr[this.uri])),n&&(this.keyId=n,s.setKeyIdForUri(this.uri,n));}return this}};function Ny(s){let e=s?.[Je.WIDEVINE];return e?e.keyId:null}function eg(s){let e=s?.[Je.PLAYREADY];if(e){let t=dp(e.uri);if(t)return up(t)}return null}function Uy(s){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=s>>8*(15-t)&255;return e}var tg=/#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,ig=/#EXT-X-MEDIA:(.*)/g,$y=/^#EXT(?:INF|-X-TARGETDURATION):/m,lc=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),By=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),cs=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 Wu.buildAbsoluteURL(t,e,{alwaysNormalize:true})}static isMediaPlaylist(e){return $y.test(e)}static parseMasterPlaylist(e,t){let i=Qm(e),r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];if(tg.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=new Error("no EXTM3U delimiter"),r;let a;for(;(a=tg.exec(e))!=null;)if(a[1]){var o;let l=new De(a[1],r),c=Bc(r,a[2]),u={attrs:l,bitrate:l.decimalInteger("BANDWIDTH")||l.decimalInteger("AVERAGE-BANDWIDTH"),name:l.NAME,url:s.resolve(c,t)},h=l.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),ng(l.CODECS,u);let f=l["SUPPLEMENTAL-CODECS"];f&&(u.supplemental={},ng(f,u.supplemental)),(o=u.unknownCodecs)!=null&&o.length||n.push(u),r.levels.push(u);}else if(a[3]){let l=a[3],c=a[4];switch(l){case "SESSION-DATA":{let u=new De(c,r),h=u["DATA-ID"];h&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[h]=u);break}case "SESSION-KEY":{let u=sg(c,t,r);u.encrypted&&u.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(u)):ye.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${c}"`);break}case "DEFINE":{{let u=new De(c,r);Xm(r,u,t);}break}case "CONTENT-STEERING":{let u=new De(c,r);r.contentSteering={uri:s.resolve(u["SERVER-URI"],t),pathwayId:u["PATHWAY-ID"]||"."};break}case "START":{r.startTimeOffset=rg(c);break}}}let d=n.length>0&&n.length<r.levels.length;return r.levels=d?n:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,i){let r,n={},a=i.levels,o={AUDIO:a.map(l=>({id:l.attrs.AUDIO,audioCodec:l.audioCodec})),SUBTITLES:a.map(l=>({id:l.attrs.SUBTITLES,textCodec:l.textCodec})),"CLOSED-CAPTIONS":[]},d=0;for(ig.lastIndex=0;(r=ig.exec(e))!==null;){let l=new De(r[1],i),c=l.TYPE;if(c){let u=o[c],h=n[c]||[];n[c]=h;let f=l.LANGUAGE,m=l["ASSOC-LANGUAGE"],g=l.CHANNELS,E=l.CHARACTERISTICS,v=l["INSTREAM-ID"],T={attrs:l,bitrate:0,id:d++,groupId:l["GROUP-ID"]||"",name:l.NAME||f||"",type:c,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:f,url:l.URI?s.resolve(l.URI,t):""};if(m&&(T.assocLang=m),g&&(T.channels=g),E&&(T.characteristics=E),v&&(T.instreamId=v),u!=null&&u.length){let S=s.findGroup(u,T.groupId)||u[0];ag(T,S,"audioCodec"),ag(T,S,"textCodec");}h.push(T);}}return n}static parseLevelPlaylist(e,t,i,r,n,a){var o;let d={url:t},l=new Gc(t),c=l.fragments,u=[],h=null,f=0,m=0,g=0,E=0,v=0,T=null,S=new Sn(r,d),b,_,D,I=-1,k=false,R=null,L;if(lc.lastIndex=0,l.m3u8=e,l.hasVariableRefs=Qm(e),((o=lc.exec(e))==null?void 0:o[0])!=="#EXTM3U")return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;(b=lc.exec(e))!==null;){k&&(k=false,S=new Sn(r,d),S.playlistOffset=g,S.setStart(g),S.sn=f,S.cc=E,v&&(S.bitrate=v),S.level=i,h&&(S.initSegment=h,h.rawProgramDateTime&&(S.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null),R&&(S.setByteRange(R),R=null)));let z=b[1];if(z){S.duration=parseFloat(z);let V=(" "+b[2]).slice(1);S.title=V||null,S.tagList.push(V?["INF",z,V]:["INF",z]);}else if(b[3]){if(H(S.duration)){S.playlistOffset=g,S.setStart(g),D&&lg(S,D,l),S.sn=f,S.level=i,S.cc=E,c.push(S);let V=(" "+b[3]).slice(1);S.relurl=Bc(l,V),Kc(S,T,u),T=S,g+=S.duration,f++,m=0,k=true;}}else {if(b=b[0].match(By),!b){ye.warn("No matches on slow regex match for level playlist!");continue}for(_=1;_<b.length&&b[_]===void 0;_++);let V=(" "+b[_]).slice(1),F=(" "+b[_+1]).slice(1),q=b[_+2]?(" "+b[_+2]).slice(1):null;switch(V){case "BYTERANGE":T?S.setByteRange(F,T):S.setByteRange(F);break;case "PROGRAM-DATE-TIME":S.rawProgramDateTime=F,S.tagList.push(["PROGRAM-DATE-TIME",F]),I===-1&&(I=c.length);break;case "PLAYLIST-TYPE":l.type&&yi(l,V,b),l.type=F.toUpperCase();break;case "MEDIA-SEQUENCE":l.startSN!==0?yi(l,V,b):c.length>0&&dg(l,V,b),f=l.startSN=parseInt(F);break;case "SKIP":{l.skippedSegments&&yi(l,V,b);let G=new De(F,l),j=G.decimalInteger("SKIPPED-SEGMENTS");if(H(j)){l.skippedSegments+=j;for(let U=j;U--;)c.push(null);f+=j;}let X=G.enumeratedString("RECENTLY-REMOVED-DATERANGES");X&&(l.recentlyRemovedDateranges=(l.recentlyRemovedDateranges||[]).concat(X.split(" ")));break}case "TARGETDURATION":l.targetduration!==0&&yi(l,V,b),l.targetduration=Math.max(parseInt(F),1);break;case "VERSION":l.version!==null&&yi(l,V,b),l.version=parseInt(F);break;case "INDEPENDENT-SEGMENTS":break;case "ENDLIST":l.live||yi(l,V,b),l.live=false;break;case "#":(F||q)&&S.tagList.push(q?[F,q]:[F]);break;case "DISCONTINUITY":E++,S.tagList.push(["DIS"]);break;case "GAP":S.gap=true,S.tagList.push([V]);break;case "BITRATE":S.tagList.push([V,F]),v=parseInt(F)*1e3,H(v)?S.bitrate=v:v=0;break;case "DATERANGE":{let G=new De(F,l),j=new al(G,l.dateRanges[G.ID],l.dateRangeTagCount);l.dateRangeTagCount++,j.isValid||l.skippedSegments?l.dateRanges[j.id]=j:ye.warn(`Ignoring invalid DATERANGE tag: "${F}"`),S.tagList.push(["EXT-X-DATERANGE",F]);break}case "DEFINE":{{let G=new De(F,l);"IMPORT"in G?xy(l,G,a):Xm(l,G,t);}break}case "DISCONTINUITY-SEQUENCE":l.startCC!==0?yi(l,V,b):c.length>0&&dg(l,V,b),l.startCC=E=parseInt(F);break;case "KEY":{let G=sg(F,t,l);if(G.isSupported()){if(G.method==="NONE"){D=void 0;break}D||(D={});let j=D[G.keyFormat];j!=null&&j.matches(G)||(j&&(D=Se({},D)),D[G.keyFormat]=G);}else ye.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${F}"`);break}case "START":l.startTimeOffset=rg(F);break;case "MAP":{let G=new De(F,l);if(S.duration){let j=new Sn(r,d);og(j,G,i,D),h=j,S.initSegment=h,h.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=h.rawProgramDateTime);}else {let j=S.byteRangeEndOffset;if(j){let X=S.byteRangeStartOffset;R=`${j-X}@${X}`;}else R=null;og(S,G,i,D),h=S,k=true;}h.cc=E;break}case "SERVER-CONTROL":{L&&yi(l,V,b),L=new De(F),l.canBlockReload=L.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=L.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&L.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=L.optionalFloat("PART-HOLD-BACK",0),l.holdBack=L.optionalFloat("HOLD-BACK",0);break}case "PART-INF":{l.partTarget&&yi(l,V,b);let G=new De(F);l.partTarget=G.decimalFloatingPoint("PART-TARGET");break}case "PART":{let G=l.partList;G||(G=l.partList=[]);let j=m>0?G[G.length-1]:void 0,X=m++,U=new De(F,l),$=new kc(U,S,d,X,j);G.push($),S.duration+=$.duration;break}case "PRELOAD-HINT":{let G=new De(F,l);l.preloadHint=G;break}case "RENDITION-REPORT":{let G=new De(F,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(G);break}default:ye.warn(`line parsed but not handled: ${b}`);break}}}T&&!T.relurl?(c.pop(),g-=T.duration,l.partList&&(l.fragmentHint=T)):l.partList&&(Kc(S,T,u),S.cc=E,l.fragmentHint=S,D&&lg(S,D,l)),l.targetduration||(l.playlistParsingError=new Error("Missing Target Duration"));let w=c.length,B=c[0],K=c[w-1];if(g+=l.skippedSegments*l.targetduration,g>0&&w&&K){l.averagetargetduration=g/w;let z=K.sn;l.endSN=z!=="initSegment"?z:0,l.live||(K.endList=true),I>0&&(Hy(c,I),B&&u.unshift(B));}return l.fragmentHint&&(g+=l.fragmentHint.duration),l.totalduration=g,u.length&&l.dateRangeTagCount&&B&&hp(u,l),l.endCC=E,l}};function hp(s,e){let t=s.length;if(!t)if(e.hasProgramDateTime){let o=e.fragments[e.fragments.length-1];s.push(o),t++;}else return;let i=s[t-1],r=e.live?1/0:e.totalduration,n=Object.keys(e.dateRanges);for(let o=n.length;o--;){let d=e.dateRanges[n[o]],l=d.startDate.getTime();d.tagAnchor=i.ref;for(let c=t;c--;){var a;if(((a=s[c])==null?void 0:a.sn)<e.startSN)break;let u=Gy(e,l,s,c,r);if(u!==-1){d.tagAnchor=e.fragments[u].ref;break}}}}function Gy(s,e,t,i,r){let n=t[i];if(n){let o=n.programDateTime;if(e>=o||i===0){var a;let d=(((a=t[i+1])==null?void 0:a.start)||r)-n.start;if(e<=o+d*1e3){let l=t[i].sn-s.startSN;if(l<0)return -1;let c=s.fragments;if(c.length>t.length){let h=(t[i+1]||c[c.length-1]).sn-s.startSN;for(let f=h;f>l;f--){let m=c[f].programDateTime;if(e>=m&&e<m+c[f].duration*1e3)return f}}return l}}}return -1}function sg(s,e,t){var i,r;let n=new De(s,t),a=(i=n.METHOD)!=null?i:"",o=n.URI,d=n.hexadecimalInteger("IV"),l=n.KEYFORMATVERSIONS,c=(r=n.KEYFORMAT)!=null?r:"identity";o&&n.IV&&!d&&ye.error(`Invalid IV: ${n.IV}`);let u=o?cs.resolve(o,e):"",h=(l||"1").split("/").map(Number).filter(Number.isFinite);return new mr(a,u,c,h,d,n.KEYID)}function rg(s){let t=new De(s).decimalFloatingPoint("TIME-OFFSET");return H(t)?t:null}function ng(s,e){let t=(s||"").split(/[ ,]+/).filter(i=>i);["video","audio","text"].forEach(i=>{let r=t.filter(n=>qu(n,i));r.length&&(e[`${i}Codec`]=r.map(n=>n.split("/")[0]).join(","),t=t.filter(n=>r.indexOf(n)===-1));}),e.unknownCodecs=t;}function ag(s,e,t){let i=e[t];i&&(s[t]=i);}function Hy(s,e){let t=s[e];for(let i=e;i--;){let r=s[i];if(!r)return;r.programDateTime=t.programDateTime-r.duration*1e3,t=r;}}function Kc(s,e,t){s.rawProgramDateTime?t.push(s):e!=null&&e.programDateTime&&(s.programDateTime=e.endProgramDateTime);}function og(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 lg(s,e,t){s.levelkeys=e;let{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(r=>e[r].isCommonEncryption)&&i.push(s);}function yi(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${t[0]})`);}function dg(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`);}function dc(s,e){let t=e.startPTS;if(H(t)){let i=0,r;e.sn>s.sn?(i=t-s.start,r=s):(i=s.start-t,r=e),r.duration!==i&&r.setDuration(i);}else e.sn>s.sn?s.cc===e.cc&&s.minEndPTS?e.setStart(s.start+(s.minEndPTS-s.start)):e.setStart(s.start+s.duration):e.setStart(Math.max(s.start-e.duration,0));}function fp(s,e,t,i,r,n,a){i-t<=0&&(a.warn("Fragment should have a positive duration",e),i=t+e.duration,n=r+e.duration);let d=t,l=i,c=e.startPTS,u=e.endPTS;if(H(c)){let v=Math.abs(c-t);s&&v>s.totalduration?a.warn(`media timestamps and playlist times differ by ${v}s for level ${e.level} ${s.url}`):H(e.deltaPTS)?e.deltaPTS=Math.max(v,e.deltaPTS):e.deltaPTS=v,d=Math.max(t,c),t=Math.min(t,c),r=e.startDTS!==void 0?Math.min(r,e.startDTS):r,l=Math.min(i,u),i=Math.max(i,u),n=e.endDTS!==void 0?Math.max(n,e.endDTS):n;}let h=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(i-e.start),e.startPTS=t,e.maxStartPTS=d,e.startDTS=r,e.endPTS=i,e.minEndPTS=l,e.endDTS=n;let f=e.sn;if(!s||f<s.startSN||f>s.endSN)return 0;let m,g=f-s.startSN,E=s.fragments;for(E[g]=e,m=g;m>0;m--)dc(E[m],E[m-1]);for(m=g;m<E.length-1;m++)dc(E[m],E[m+1]);return s.fragmentHint&&dc(E[E.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=true,h}function Ky(s,e,t){if(s===e)return;let i=null,r=s.fragments;for(let c=r.length-1;c>=0;c--){let u=r[c].initSegment;if(u){i=u;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let n;Yy(s,e,(c,u,h,f)=>{if((!e.startCC||e.skippedSegments)&&u.cc!==c.cc){let m=c.cc-u.cc;for(let g=h;g<f.length;g++)f[g].cc+=m;e.endCC=f[f.length-1].cc;}H(c.startPTS)&&H(c.endPTS)&&(u.setStart(u.startPTS=c.startPTS),u.startDTS=c.startDTS,u.maxStartPTS=c.maxStartPTS,u.endPTS=c.endPTS,u.endDTS=c.endDTS,u.minEndPTS=c.minEndPTS,u.setDuration(c.endPTS-c.startPTS),u.duration&&(n=u),e.PTSKnown=e.alignedSliding=true),c.hasStreams&&(u.elementaryStreams=c.elementaryStreams),u.loader=c.loader,c.hasStats&&(u.stats=c.stats),c.initSegment&&(u.initSegment=c.initSegment,i=c.initSegment);});let a=e.fragments,o=e.fragmentHint?a.concat(e.fragmentHint):a;if(i&&o.forEach(c=>{var u;c&&(!c.initSegment||c.initSegment.relurl===((u=i)==null?void 0:u.relurl))&&(c.initSegment=i);}),e.skippedSegments){if(e.deltaUpdateFailed=a.some(c=>!c),e.deltaUpdateFailed){t.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let c=e.skippedSegments;c--;)a.shift();e.startSN=a[0].sn;}else {e.canSkipDateRanges&&(e.dateRanges=Vy(s.dateRanges,e,t));let c=s.fragments.filter(u=>u.rawProgramDateTime);if(s.hasProgramDateTime&&!e.hasProgramDateTime)for(let u=1;u<o.length;u++)o[u].programDateTime===null&&Kc(o[u],o[u-1],c);hp(c,e);}e.endCC=a[a.length-1].cc;}if(!e.startCC){var d;let c=pp(s,e.startSN-1);e.startCC=(d=c?.cc)!=null?d:a[0].cc;}Wy(s.partList,e.partList,(c,u)=>{u.elementaryStreams=c.elementaryStreams,u.stats=c.stats;}),n?fp(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS,t):mp(s,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=s.driftStartTime,e.driftStart=s.driftStart;let l=e.advancedDateTime;if(e.advanced&&l){let c=e.edge;e.driftStart||(e.driftStartTime=l,e.driftStart=c),e.driftEndTime=l,e.driftEnd=c;}else e.driftEndTime=s.driftEndTime,e.driftEnd=s.driftEnd,e.advancedDateTime=s.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=s.requestScheduled);}function Vy(s,e,t){let{dateRanges:i,recentlyRemovedDateranges:r}=e,n=Se({},s);r&&r.forEach(d=>{delete n[d];});let o=Object.keys(n).length;return o?(Object.keys(i).forEach(d=>{let l=n[d],c=new al(i[d].attr,l);c.isValid?(n[d]=c,l||(c.tagOrder+=o)):t.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${Ae(i[d].attr)}"`);}),n):i}function Wy(s,e,t){if(s&&e){let i=0;for(let r=0,n=s.length;r<=n;r++){let a=s[r],o=e[r+i];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):i--;}}}function Yy(s,e,t){let i=e.skippedSegments,r=Math.max(s.startSN,e.startSN)-e.startSN,n=(s.fragmentHint?1:0)+(i?e.endSN:Math.min(s.endSN,e.endSN))-e.startSN,a=e.startSN-s.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,d=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments;for(let l=r;l<=n;l++){let c=d[a+l],u=o[l];if(i&&!u&&c&&(u=e.fragments[l]=c),c&&u){t(c,u,l,o);let h=c.relurl,f=u.relurl;if(h&&qy(h,f)){e.playlistParsingError=cg(`media sequence mismatch ${u.sn}:`,s,e,c,u);return}else if(c.cc!==u.cc){e.playlistParsingError=cg(`discontinuity sequence mismatch (${c.cc}!=${u.cc})`,s,e,c,u);return}}}}function cg(s,e,t,i,r){return new Error(`${s} ${r.url}
|
|
1491
1467
|
Playlist starting @${e.startSN}
|
|
1492
1468
|
${e.m3u8}
|
|
1493
1469
|
|
|
1494
1470
|
Playlist starting @${t.startSN}
|
|
1495
|
-
${t.m3u8}`)}function Tp(s,e,t=true){let i=e.startSN+e.skippedSegments-s.startSN,r=s.fragments,n=i>=0,a=0;if(n&&i<r.length)a=r[i].start;else if(n&&e.startSN===s.endSN+1)a=s.fragmentEnd;else if(n&&t)a=s.fragmentStart+i*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)a=s.fragmentStart;else return;Yc(e,a);}function Yc(s,e){if(e){let t=s.fragments;for(let i=s.skippedSegments;i<t.length;i++)t[i].addStart(e);s.fragmentHint&&s.fragmentHint.addStart(e);}}function yp(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 Sp(s,e,t){if(!s)return null;let i=s.fragments[e-s.startSN];return i||(i=s.fragmentHint,i&&i.sn===e)?i:e<s.startSN&&t&&t.sn===e?t:null}function pg(s,e,t){return s?bp(s.partList,e,t):null}function bp(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 Ap(s){s.forEach((e,t)=>{var i;(i=e.details)==null||i.fragments.forEach(r=>{r.level=t,r.initSegment&&(r.initSegment.level=t);});});}function Jy(s,e){return s!==e&&e?Eg(s)!==Eg(e):false}function Eg(s){return s.replace(/\?[^?]*$/,"")}function _n(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 eS(s,e){return !!(s&&e.startCC<s.endCC&&e.endCC>s.startCC)}function vg(s,e){let t=s.start+e;s.startPTS=t,s.setStart(t),s.endPTS=t+s.duration;}function _p(s,e){let t=e.fragments;for(let i=0,r=t.length;i<r;i++)vg(t[i],s);e.fragmentHint&&vg(e.fragmentHint,s),e.alignedSliding=true;}function tS(s,e){s&&(Ip(e,s),e.alignedSliding||hl(e,s),!e.alignedSliding&&!e.skippedSegments&&Tp(s,e,false));}function Ip(s,e){if(!eS(e,s))return;let t=Math.min(e.endCC,s.endCC),i=_n(e.fragments,t),r=_n(s.fragments,t);if(!i||!r)return;ye.log(`Aligning playlist at start of dicontinuity sequence ${t}`);let n=i.start-r.start;_p(n,s);}function hl(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=_n(i,a),n=_n(t,a)),(!r||!n)&&(r=i[Math.floor(i.length/2)],n=_n(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);_p(d,s);}function at(s,e,t){ht(s,e,t),s.addEventListener(e,t);}function ht(s,e,t){s.removeEventListener(e,t);}var iS={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"},Mn=class extends ll{constructor(e,t,i,r,n){super(r,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=C.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=false,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=false,this.decrypter=void 0,this.initPTS=[],this.buffering=true,this.loadingParts=false,this.loopSn=void 0,this.onMediaSeeking=()=>{let{config:a,fragCurrent:o,media:l,mediaBuffer:d,state:c}=this,u=l?l.currentTime:0,h=ne.bufferInfo(d||l,u,a.maxBufferHole),f=!h.len;if(this.log(`Media seeking to ${H(u)?u.toFixed(3):u}, state: ${c}, ${f?"out of":"in"} buffer`),this.state===C.ENDED)this.resetLoadingState();else if(o){let m=a.maxFragLookUpTolerance,g=o.start-m,E=o.start+o.duration+m;if(f||E<h.start||g>h.end){let v=u>E;(u<g||v)&&(v&&o.loader&&(this.log(`Cancelling fragment load for seek (sn: ${o.sn})`),o.abortRequests(),this.resetLoadingState()),this.fragPrevious=null);}}if(l){this.fragmentTracker.removeFragmentsInRange(u,1/0,this.playlistType,true);let m=this.lastCurrentTime;if(u>m&&(this.lastCurrentTime=u),!this.loadingParts){let g=Math.max(h.end,u),E=this.shouldLoadParts(this.getLevelDetails(),g);E&&(this.log(`LL-Part loading ON after seeking to ${u.toFixed(2)} with buffer @${g.toFixed(2)}`),this.loadingParts=E);}}this.hls.hasEnoughToStart||(this.log(`Setting ${f?"startPosition":"nextLoadPosition"} to ${u} for seek without enough to start`),this.nextLoadPosition=u,f&&(this.startPosition=u)),f&&this.state===C.IDLE&&this.tickImmediate();},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0;},this.playlistType=n,this.hls=e,this.fragmentLoader=new Gc(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Dn(e.config);}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_LOADED,this.onManifestLoaded,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_LOADED,this.onManifestLoaded,this),e.off(p.ERROR,this.onError,this);}doTick(){this.onTickEnd();}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===C.STOPPED)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=C.STOPPED;}get startPositionValue(){let{nextLoadPosition:e,startPosition:t}=this;return t===-1&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=false;}resumeBuffering(){this.buffering=true;}get inFlightFrag(){return {frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return false;let i=e.end||0,r=this.config.timelineOffset||0;if(i<=r)return false;let n=e.buffered;this.config.maxBufferHole&&n&&n.length>1&&(e=ne.bufferedInfo(n,e.start,0));let a=e.nextStart;if(a&&a>r&&a<t.edge||this.media.currentTime<e.start)return false;let l=t.partList;if(l!=null&&l.length){let c=l[l.length-1];return ne.isBuffered(this.media,c.start+c.duration/2)}let d=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(d)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null)return this.levelLastLoaded.details}get timelineOffset(){let e=this.config.timelineOffset;if(e){var t;return ((t=this.getLevelDetails())==null?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){let i=this.media=this.mediaBuffer=t.media;at(i,"seeking",this.onMediaSeeking),at(i,"ended",this.onMediaEnded);let r=this.config;this.levels&&r.autoStartLoad&&this.state===C.STOPPED&&this.startLoad(r.startPosition);}onMediaDetaching(e,t){let i=!!t.transferMedia,r=this.media;if(r!==null){if(r.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),ht(r,"seeking",this.onMediaSeeking),ht(r,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=false,this.fragmentTracker.removeAllFragments(),this.stopLoad();}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=false;}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset;}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null;}onHandlerDestroyed(){this.state=C.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed();}loadFragment(e,t,i){this.startFragRequested=true,this._loadFragForPlayback(e,t,i);}_loadFragForPlayback(e,t,i){let r=n=>{let a=n.frag;if(this.fragContextChanged(a)){this.warn(`${a.type} sn: ${a.sn}${n.part?" part: "+n.part.index:""} of ${this.fragInfo(a,false,n.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(a);return}a.stats.chunkCount++,this._handleFragmentLoadProgress(n);};this._doFragLoad(e,t,i,r).then(n=>{if(!n)return;let a=this.state,o=n.frag;if(this.fragContextChanged(o)){(a===C.FRAG_LOADING||!this.fragCurrent&&a===C.PARSING)&&(this.fragmentTracker.removeFragment(o),this.state=C.IDLE);return}"payload"in n&&(this.log(`Loaded ${o.type} sn: ${o.sn} of ${this.playlistLabel()} ${o.level}`),this.hls.trigger(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)===We.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)===We.PARTIAL&&i.removeFragment(e));}checkLiveUpdate(e){if(e.updated&&!e.live){let t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type});}e.fragments[0]||(e.deltaUpdateFailed=true);}waitForLive(e){let t=e.details;return t?.live&&t.type!=="EVENT"&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,i=null){if(!(e-t))return;let r={startOffset:e,endOffset:t,type:i};this.hls.trigger(p.BUFFER_FLUSHING,r);}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{let r=i?.frag;if(!r||this.fragContextChanged(r)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{let{hls:r}=this,{frag:n,payload:a}=i,o=n.decryptdata;if(a&&a.byteLength>0&&o!=null&&o.key&&o.iv&&hr(o.method)){let l=self.performance.now();return this.decrypter.decrypt(new Uint8Array(a),o.key.buffer,o.iv.buffer,Zu(o.method)).catch(d=>{throw r.trigger(p.ERROR,{type:z.MEDIA_ERROR,details:x.FRAG_DECRYPT_ERROR,fatal:false,error:d,reason:d.message,frag:n}),d}).then(d=>{let c=self.performance.now();return r.trigger(p.FRAG_DECRYPTED,{frag:n,payload:d,stats:{tstart:l,tdecrypt:c}}),i.payload=d,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)}).catch(i=>{this.state===C.STOPPED||this.state===C.ERROR||(this.warn(i),this.resetFragmentLoading(e));});}completeInitSegmentLoad(e){let{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");let i=e.frag.stats;this.state!==C.STOPPED&&(this.state=C.IDLE),e.frag.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),this.tick();}unhandledEncryptionError(e,t){var i,r;let n=e.tracks;if(n&&!t.encrypted&&((i=n.audio)!=null&&i.encrypted||(r=n.video)!=null&&r.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){let a=this.media,o=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${a?"attached mediaKeys: "+a.mediaKeys:"detached"})`);return this.warn(o.message),!a||a.mediaKeys?false:(this.hls.trigger(p.ERROR,{type:z.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_KEYS,fatal:false,error:o,frag:t}),this.resetTransmuxer(),true)}return false}fragContextChanged(e){let{fragCurrent:t}=this;return !e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){let i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,false,t)} > buffer:${i?iS.toString(ne.getBuffered(i)):"(detached)"})`),Fe(e)){var r;if(e.type!==W.SUBTITLE){let a=e.elementaryStreams;if(!Object.keys(a).some(o=>!!a[o])){this.state=C.IDLE;return}}let n=(r=this.levels)==null?void 0:r[e.level];n!=null&&n.fragmentError&&(this.log(`Resetting level fragment error count of ${n.fragmentError} on frag buffered`),n.fragmentError=0);}this.state=C.IDLE;}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:i,part:r,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new Cn(i.level,i.sn,i.stats.chunkCount+1,0,r?r.index:-1,!a);t.flush(o);}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,r){var n;this.fragCurrent=e;let a=t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)){if(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=C.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(h=>{if(!this.fragContextChanged(h.frag))return this.hls.trigger(p.KEY_LOADED,h),this.state===C.KEY_LOADING&&(this.state=C.IDLE),h}),this.hls.trigger(p.KEY_LOADING,{frag:e}),this.fragCurrent===null)return this.log("context changed in KEY_LOADING"),Promise.resolve(null)}else e.encrypted||(o=this.keyLoader.loadClear(e,a.encryptedFragments,this.startFragRequested),o&&this.log("[eme] blocking frag load until media-keys acquired"));let l=this.fragPrevious;if(Fe(e)&&(!l||e.sn!==l.sn)){let h=this.shouldLoadParts(t.details,e.end);h!==this.loadingParts&&(this.log(`LL-Part loading ${h?"ON":"OFF"} loading sn ${l?.sn}->${e.sn}`),this.loadingParts=h);}if(i=Math.max(e.start,i||0),this.loadingParts&&Fe(e)){let h=a.partList;if(h&&r){i>a.fragmentEnd&&a.fragmentHint&&(e=a.fragmentHint);let f=this.getNextPart(h,e,i);if(f>-1){let m=h[f];e=this.fragCurrent=m.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${m.index} (${f}/${h.length-1}) of ${this.fragInfo(e,false,m)}) cc: ${e.cc} [${a.startSN}-${a.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=m.start+m.duration,this.state=C.FRAG_LOADING;let g;return o?g=o.then(E=>!E||this.fragContextChanged(E.frag)?null:this.doFragPartsLoad(e,m,t,r)).catch(E=>this.handleFragLoadError(E)):g=this.doFragPartsLoad(e,m,t,r).catch(E=>this.handleFragLoadError(E)),this.hls.trigger(p.FRAG_LOADING,{frag:e,part:m,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):g}else if(!e.url||this.loadedEndOfParts(h,i))return Promise.resolve(null)}}if(Fe(e)&&this.loadingParts){var d;this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${(d=a.partList)==null?void 0:d.filter(h=>h.loaded).map(h=>`[${h.start}-${h.end}]`)}`),this.loadingParts=false;}else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,false)}) cc: ${e.cc} ${"["+a.startSN+"-"+a.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),H(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=C.FRAG_LOADING;let c=this.config.progressive&&e.type!==W.SUBTITLE,u;return c&&o?u=o.then(h=>!h||this.fragContextChanged(h.frag)?null:this.fragmentLoader.load(e,r)).catch(h=>this.handleFragLoadError(h)):u=Promise.all([this.fragmentLoader.load(e,c?r:void 0),o]).then(([h])=>(!c&&r&&r(h),h)).catch(h=>this.handleFragLoadError(h)),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")):u}doFragPartsLoad(e,t,i,r){return new Promise((n,a)=>{var o;let l=[],d=(o=i.details)==null?void 0:o.partList,c=u=>{this.fragmentLoader.loadPart(e,u,r).then(h=>{l[u.index]=h;let f=h.part;this.hls.trigger(p.FRAG_LOADED,h);let m=pg(i.details,e.sn,u.index+1)||bp(d,e.sn,u.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;t.frag&&t.details===x.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===z.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(p.ERROR,t);}else this.hls.trigger(p.ERROR,{type:z.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);let o=this.getLevelDetails(),d=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);d!==this.loadingParts&&(this.log(`LL-Part loading ${d?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=d),this.updateLevelTiming(i,r,n,e.partial);}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var i;let n=e.partList[0];if(n.fragment.type===W.SUBTITLE)return false;let a=n.end+(((i=e.fragmentHint)==null?void 0:i.duration)||0);if(t>=a){var r;if((this.hls.hasEnoughToStart?((r=this.media)==null?void 0:r.currentTime)||this.lastCurrentTime:this.getLoadPosition())>n.start-n.fragment.duration)return true}}}return false}getCurrentContext(e){let{levels:t,fragCurrent:i}=this,{level:r,sn:n,part:a}=e;if(!(t!=null&&t[r]))return this.warn(`Levels object was unset while buffering fragment ${n} of ${this.playlistLabel()} ${r}. The current chunk will not be buffered.`),null;let o=t[r],l=o.details,d=a>-1?pg(l,n,a):null,c=d?d.fragment:Sp(l,n,i);return c?(i&&i!==c&&(c.stats=i.stats),{frag:c,part:d,level:o}):null}bufferFragmentData(e,t,i,r,n){if(this.state!==C.PARSING)return;let{data1:a,data2:o}=e,l=a;if(o&&(l=Ct(a,o)),!l.length)return;let d=this.initPTS[t.cc],c=d?-d.baseTime/d.timescale:void 0,u={type:e.type,frag:t,part:i,chunkMeta:r,offset:c,parent:t.type,data:l};if(this.hls.trigger(p.BUFFER_APPENDING,u),e.dropped&&e.independent&&!i){if(n)return;this.flushBufferGap(t);}}flushBufferGap(e){let t=this.media;if(!t)return;if(!ne.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let i=t.currentTime,r=ne.bufferInfo(t,i,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,r.end-a),i+a);e.start-o>a&&this.flushMainBuffer(o,e.start);}getFwdBufferInfo(e,t){var i;let r=this.getLoadPosition();if(!H(r))return null;let a=this.lastCurrentTime>r||(i=this.media)!=null&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,r,t,a)}getFwdBufferInfoAtPos(e,t,i,r){let n=ne.bufferInfo(e,t,r);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&(n.nextStart<=a.end||a.gap)){let o=Math.max(Math.min(n.nextStart,a.end)-t,r);return ne.bufferInfo(e,t,o)}}return n}getMaxBufferLength(e){let{config:t}=this,i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){let i=this.config,r=Math.max(Math.min(e-t,i.maxBufferLength),t),n=Math.max(e-t*3,i.maxMaxBufferLength/2,r);return n>=r?(i.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),true):false}getAppendedFrag(e,t=W.MAIN){let i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;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=n.lowLatencyMode&&!!t.partList,l=null;if(t.live){let u=n.initialLiveManifestSize;if(r<u)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${u})`),null;if(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a){var d;o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=true),l=this.getInitialLiveFragment(t);let h=this.hls.startPosition,f=this.hls.liveSyncPosition,m=l?(h!==-1&&h>=a?h:f)||l.start:e;this.log(`Setting startPosition to ${m} to match start frag at live edge. mainStart: ${h} liveSyncPosition: ${f} frag.start: ${(d=l)==null?void 0:d.start}`),this.startPosition=this.nextLoadPosition=m;}}else e<=a&&(l=i[0]);if(!l){let u=this.loadingParts?t.partEnd:t.fragmentEnd;l=this.getFragmentAtPosition(e,u,t);}let c=this.filterReplacedPrimary(l,t);if(!c&&l){let u=l.sn-t.startSN;c=this.filterReplacedPrimary(i[u+1]||null,t);}return this.mapToInitFragWhenRequired(c)}isLoopLoading(e,t){let i=this.fragmentTracker.getState(e);return (i===We.OK||i===We.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,r,n){let a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t),a&&!a.gap&&i.nextStart)){let o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,r,0);if(o!==null&&i.len+o.len>=n){let l=a.sn;return this.loopSn!==l&&(this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${l}`),this.loopSn=l),null}}return this.loopSn=void 0,a}get primaryPrefetch(){if(Tg(this.config)){var e;if((e=this.hls.interstitialsManager)==null||(e=e.playingItem)==null?void 0:e.event)return true}return false}filterReplacedPrimary(e,t){if(!e)return e;if(Tg(this.config)&&e.type!==W.SUBTITLE){let i=this.hls.interstitialsManager,r=i?.bufferingItem;if(r){let a=r.event;if(a){if(a.appendInPlace||Math.abs(e.start-r.start)>1||r.start===0)return null}else if(e.end<=r.start&&t?.live===false||e.start>r.end&&r.nextEvent&&(r.nextEvent.appendInPlace||e.start-r.end>1))return null}let n=i?.playerQueue;if(n)for(let a=n.length;a--;){let o=n[a].interstitial;if(o.appendInPlace&&e.start>=o.startTime&&e.end<=o.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!e.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)&&(d.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${d.start}`),r=o),n=c;}return r}loadedEndOfParts(e,t){let i;for(let r=e.length;r--;){if(i=e[r],!i.loaded)return false;if(t>i.start)return true}return false}getInitialLiveFragment(e){let t=e.fragments,i=this.fragPrevious,r=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),r=Iy(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=dp(e,i.cc,i.end),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`));}}else {let n=this.hls.liveSyncPosition;n!==null&&(r=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e));}return r}getFragmentAtPosition(e,t,i){let{config:r}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=i,{fragmentHint:l}=i,{maxFragLookUpTolerance:d}=r,c=i.partList,u=!!(this.loadingParts&&c!=null&&c.length&&l);u&&!this.bitrateTest&&c[c.length-1].fragment.sn===l.sn&&(a=a.concat(l),o=l.sn);let h;if(e<t){var f;let g=e<this.lastCurrentTime||e>t-d||(f=this.media)!=null&&f.paused||!this.startFragRequested?0:d;h=gs(n,a,e,g);}else h=a[a.length-1];if(h){let m=h.sn-i.startSN,g=this.fragmentTracker.getState(h);if((g===We.OK||g===We.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!u||c[0].fragment.sn>h.sn||!i.live)&&h.level===n.level){let v=a[m+1];h.sn<o&&this.fragmentTracker.getState(v)!==We.OK?h=v:h=null;}}return h}alignPlaylists(e,t,i){let r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;let n=e.fragmentStart,a=!t,o=e.alignedSliding&&H(n);if(a||!o&&!n){tS(i,e);let l=e.fragmentStart;return this.log(`Live playlist sliding: ${l.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${r}`),l}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;i<t&&(i=-1);let r=this.timelineOffset;if(i===-1){let n=this.startTimeOffset!==null,a=n?this.startTimeOffset:e.startTimeOffset;a!==null&&H(a)?(i=t+a,a<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${a} found in ${n?"multivariant":"media"} playlist`),this.startPosition=i):e.live?(i=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${i}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=i=0),this.lastCurrentTime=i+r;}this.nextLoadPosition=i+r;}getLoadPosition(){var e;let{media:t}=this,i=0;return (e=this.hls)!=null&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&Fe(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e));}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==C.FRAG_LOADING_WAITING_RETRY)&&(this.state=C.IDLE);}onFragmentOrKeyLoadError(e,t){var i;if(t.chunkMeta&&!t.frag){let v=this.getCurrentContext(t.chunkMeta);v&&(t.frag=v.frag);}let r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var n;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(n=this.fragCurrent)==null?void 0:n.url}`);return}let a=t.details===x.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(r,true);let o=t.errorAction;if(!o){this.state=C.ERROR;return}let{action:l,flags:d,retryCount:c=0,retryConfig:u}=o,h=!!u,f=h&&l===Qe.RetryRequest,m=h&&!o.resolved&&d===St.MoveAllAlternatesMatchingHost,g=(i=this.hls.latestLevelDetails)==null?void 0:i.live;if(!f&&m&&Fe(r)&&!r.endList&&g&&!up(t))this.resetFragmentErrors(e),this.treatAsGap(r),o.resolved=true;else if((f||m)&&c<u.maxNumRetry){var E;let v=Oc((E=t.response)==null?void 0:E.code),y=Xu(u,c);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+y,this.state=C.FRAG_LOADING_WAITING_RETRY,o.resolved=true,v){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${c+1}/${u.maxNumRetry} in ${y}ms`);}else if(u)if(this.resetFragmentErrors(e),c<u.maxNumRetry)!a&&l!==Qe.RemoveAlternatePermanently&&(o.resolved=true);else {this.warn(`${t.details} reached or exceeded max retry (${c})`);return}else l===Qe.SendAlternateToPenaltyBox?this.state=C.WAITING_LEVEL:this.state=C.ERROR;this.tickImmediate();}checkRetryDate(){let e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!Oc(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=C.IDLE);}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 (${this.getLoadPosition()}) is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return false}resetFragmentErrors(e){e===W.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=false),this.state!==C.STOPPED&&(this.state=C.IDLE);}afterBufferFlushed(e,t,i){if(!e)return;let r=ne.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,i),this.state===C.ENDED&&this.resetLoadingState();}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==C.STOPPED&&(this.state=C.IDLE);}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=false;let e=this.levelLastLoaded,t=e?e.details:null;t!=null&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition;}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${e.level===-1?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState();}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,false,true);}updateLevelTiming(e,t,i,r){let n=i.details;if(!n){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,d)=>{let c=e.elementaryStreams[d];if(c){let u=c.endPTS-c.startPTS;if(u<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${u})`),l||false;let h=r?0:vp(n,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS,this);return this.hls.trigger(p.LEVEL_PTS_UPDATED,{details:n,level:i,drift:h,type:d,frag:e,start:c.startPTS,end:c.endPTS}),true}return l},false)){var o;let l=((o=this.transmuxer)==null?void 0:o.error)===null;if((i.fragmentError===0||l&&(i.fragmentError<2||e.endList))&&this.treatAsGap(e,i),l){let d=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(d.message),this.hls.trigger(p.ERROR,{type:z.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:false,error:d,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer();}}this.state=C.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,false,t)})`),this.hls.trigger(p.FRAG_PARSED,{frag:e,part:t});}playlistLabel(){return this.playlistType===W.MAIN?"level":"track"}fragInfo(e,t=true,i){var r,n;return `${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${((r=t&&!i?e.startPTS:(i||e).start)!=null?r:NaN).toFixed(3)}-${((n=t&&!i?e.endPTS:(i||e).end)!=null?n:NaN).toFixed(3)}]${i&&e.type==="main"?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=true,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,true);}resetTransmuxer(){var e;(e=this.transmuxer)==null||e.reset();}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState());}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`));}get state(){return this._state}};function Tg(s){return !!s.interstitialsController&&s.enableInterstitialPlayback!==false}var fl=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=sS(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0;}};function sS(s,e){let t=new Uint8Array(e),i=0;for(let r=0;r<s.length;r++){let n=s[r];t.set(n,i),i+=n.length;}return t}var hc={exports:{}},yg;function rS(){return yg||(yg=1,(function(s){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=false));function r(l,d,c){this.fn=l,this.context=d,this.once=c||false;}function n(l,d,c,u,h){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new r(c,u||l,h),m=t?t+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new i:delete l._events[d];}function o(){this._events=new i,this._eventsCount=0;}o.prototype.eventNames=function(){var d=[],c,u;if(this._eventsCount===0)return d;for(u in c=this._events)e.call(c,u)&&d.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},o.prototype.listeners=function(d){var c=t?t+d:d,u=this._events[c];if(!u)return [];if(u.fn)return [u.fn];for(var h=0,f=u.length,m=new Array(f);h<f;h++)m[h]=u[h].fn;return m},o.prototype.listenerCount=function(d){var c=t?t+d:d,u=this._events[c];return u?u.fn?1:u.length:0},o.prototype.emit=function(d,c,u,h,f,m){var g=t?t+d:d;if(!this._events[g])return false;var E=this._events[g],v=arguments.length,y,S;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,u),true;case 4:return E.fn.call(E.context,c,u,h),true;case 5:return E.fn.call(E.context,c,u,h,f),true;case 6:return E.fn.call(E.context,c,u,h,f,m),true}for(S=1,y=new Array(v-1);S<v;S++)y[S-1]=arguments[S];E.fn.apply(E.context,y);}else {var b=E.length,_;for(S=0;S<b;S++)switch(E[S].once&&this.removeListener(d,E[S].fn,void 0,true),v){case 1:E[S].fn.call(E[S].context);break;case 2:E[S].fn.call(E[S].context,c);break;case 3:E[S].fn.call(E[S].context,c,u);break;case 4:E[S].fn.call(E[S].context,c,u,h);break;default:if(!y)for(_=1,y=new Array(v-1);_<v;_++)y[_-1]=arguments[_];E[S].fn.apply(E[S].context,y);}}return true},o.prototype.on=function(d,c,u){return n(this,d,c,u,false)},o.prototype.once=function(d,c,u){return n(this,d,c,u,true)},o.prototype.removeListener=function(d,c,u,h){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&&(!h||m.once)&&(!u||m.context===u)&&a(this,f);else {for(var g=0,E=[],v=m.length;g<v;g++)(m[g].fn!==c||h&&!m[g].once||u&&m[g].context!==u)&&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;})(hc)),hc.exports}var nS=rS(),eh=BT(nS),wn="1.6.15",Er={};function aS(){return typeof __HLS_WORKER_BUNDLE__=="function"}function oS(){let s=Er[wn];if(s)return s.clientCount++,s;let e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e),r={worker:new self.Worker(t),objectURL:t,clientCount:1};return Er[wn]=r,r}function lS(s){let e=Er[s];if(e)return e.clientCount++,e;let t=new self.URL(s,self.location.href).href,r={worker:new self.Worker(t),scriptURL:t,clientCount:1};return Er[s]=r,r}function dS(s){let e=Er[s||wn];if(e&&e.clientCount--===1){let{worker:i,objectURL:r}=e;delete Er[s||wn],r&&self.URL.revokeObjectURL(r),i.terminate();}}function Lp(s,e){return e+10<=s.length&&s[e]===51&&s[e+1]===68&&s[e+2]===73&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128}function th(s,e){return e+10<=s.length&&s[e]===73&&s[e+1]===68&&s[e+2]===51&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128}function xl(s,e){let t=0;return t=(s[e]&127)<<21,t|=(s[e+1]&127)<<14,t|=(s[e+2]&127)<<7,t|=s[e+3]&127,t}function Pn(s,e){let t=e,i=0;for(;th(s,e);){i+=10;let r=xl(s,e+6);i+=r,Lp(s,e+10)&&(i+=10),e+=i;}if(i>0)return s.subarray(t,t+i)}function cS(s,e,t,i){let r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],n=e[t+2],a=n>>2&15;if(a>12){let f=new Error(`invalid ADTS sampling index:${a}`);s.emit(p.ERROR,p.ERROR,{type:z.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:true,error:f,reason:f.message});return}let o=(n>>6&3)+1,l=e[t+3]>>6&3|(n&1)<<2,d="mp4a.40."+o,c=r[a],u=a;(o===5||o===29)&&(u-=3);let h=[o<<3|(u&14)>>1,(u&1)<<7|l<<3];return ye.log(`manifest codec:${i}, parsed codec:${d}, channels:${l}, rate:${c} (ADTS object type:${o} sampling index:${a})`),{config:h,samplerate:c,channelCount:l,codec:d,parsedCodec:d,manifestCodec:i}}function xp(s,e){return s[e]===255&&(s[e+1]&246)===240}function Rp(s,e){return s[e+1]&1?7:9}function ih(s,e){return (s[e+3]&3)<<11|s[e+4]<<3|(s[e+5]&224)>>>5}function uS(s,e){return e+5<s.length}function ml(s,e){return e+1<s.length&&xp(s,e)}function hS(s,e){return uS(s,e)&&xp(s,e)&&ih(s,e)<=s.length-e}function fS(s,e){if(ml(s,e)){let t=Rp(s,e);if(e+t>=s.length)return false;let i=ih(s,e);if(i<=t)return false;let r=e+i;return r===s.length||ml(s,r)}return false}function kp(s,e,t,i,r){if(!s.samplerate){let n=cS(e,t,i,r);if(!n)return;Se(s,n);}}function Dp(s){return 1024*9e4/s}function mS(s,e){let t=Rp(s,e);if(e+t<=s.length){let i=ih(s,e)-t;if(i>0)return {headerLength:t,frameLength:i}}}function Cp(s,e,t,i,r){let n=Dp(s.samplerate),a=i+r*n,o=mS(e,t),l;if(o){let{frameLength:u,headerLength:h}=o,f=h+u,m=Math.max(0,t+f-e.length);m?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);let 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}}function gS(s,e){return th(s,e)&&xl(s,e+6)+10<=s.length-e}function pS(s){return s instanceof ArrayBuffer?s:s.byteOffset==0&&s.byteLength==s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer}function fc(s,e=0,t=1/0){return ES(s,e,t,Uint8Array)}function ES(s,e,t,i){let r=vS(s),n=1;"BYTES_PER_ELEMENT"in i&&(n=i.BYTES_PER_ELEMENT);let a=TS(s)?s.byteOffset:0,o=(a+s.byteLength)/n,l=(a+e)/n,d=Math.floor(Math.max(0,Math.min(l,o))),c=Math.floor(Math.min(d+Math.max(t,0),o));return new i(r,d,c-d)}function vS(s){return s instanceof ArrayBuffer?s:s.buffer}function TS(s){return s&&s.buffer instanceof ArrayBuffer&&s.byteLength!==void 0&&s.byteOffset!==void 0}function yS(s){let e={key:s.type,description:"",data:"",mimeType:null,pictureType:null},t=3;if(s.size<2)return;if(s.data[0]!==t){console.log("Ignore frame with unrecognized character encoding");return}let i=s.data.subarray(1).indexOf(0);if(i===-1)return;let r=_t(fc(s.data,1,i)),n=s.data[2+i],a=s.data.subarray(3+i).indexOf(0);if(a===-1)return;let o=_t(fc(s.data,3+i,a)),l;return r==="-->"?l=_t(fc(s.data,4+i+a)):l=pS(s.data.subarray(4+i+a)),e.mimeType=r,e.pictureType=n,e.description=o,e.data=l,e}function SS(s){if(s.size<2)return;let e=_t(s.data,true),t=new Uint8Array(s.data.subarray(e.length+1));return {key:s.type,info:e,data:t.buffer}}function bS(s){if(s.size<2)return;if(s.type==="TXXX"){let t=1,i=_t(s.data.subarray(t),true);t+=i.length+1;let r=_t(s.data.subarray(t));return {key:s.type,info:i,data:r}}let e=_t(s.data.subarray(1));return {key:s.type,info:"",data:e}}function AS(s){if(s.type==="WXXX"){if(s.size<2)return;let t=1,i=_t(s.data.subarray(t),true);t+=i.length+1;let r=_t(s.data.subarray(t));return {key:s.type,info:i,data:r}}let e=_t(s.data);return {key:s.type,info:"",data:e}}function _S(s){return s.type==="PRIV"?SS(s):s.type[0]==="W"?AS(s):s.type==="APIC"?yS(s):bS(s)}function IS(s){let e=String.fromCharCode(s[0],s[1],s[2],s[3]),t=xl(s,4),i=10;return {type:e,size:t,data:s.subarray(i,i+t)}}var Uo=10,LS=10;function Mp(s){let e=0,t=[];for(;th(s,e);){let i=xl(s,e+6);s[e+5]>>6&1&&(e+=Uo),e+=Uo;let r=e+i;for(;e+LS<r;){let n=IS(s.subarray(e)),a=_S(n);a&&t.push(a),e+=n.size+Uo;}Lp(s,e)&&(e+=Uo);}return t}function wp(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"}function xS(s){if(s.data.byteLength===8){let e=new Uint8Array(s.data),t=e[3]&1,i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}}function sh(s){let e=Mp(s);for(let t=0;t<e.length;t++){let i=e[t];if(wp(i))return xS(i)}}var At=(function(s){return s.audioId3="org.id3",s.dateRange="com.apple.quicktime.HLS",s.emsg="https://aomedia.org/emsg/ID3",s.misbklv="urn:misb:KLV:bin:1910.1",s})({});function fi(s="",e=9e4){return {type:s,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var On=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=Ct(this.cachedData,e),this.cachedData=null);let i=Pn(e,0),r=i?i.length:0,n,a=this._audioTrack,o=this._id3Track,l=i?sh(i):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&H(l))&&(this.basePTS=RS(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:At.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 gS(e,r)?(i=Pn(e,r),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:At.audioId3,duration:Number.POSITIVE_INFINITY}),r+=i.length,n=r):r++;if(r===d&&n!==d){let c=e.slice(n);this.cachedData?this.cachedData=Ct(this.cachedData,c):this.cachedData=c;}}return {audioTrack:a,videoTrack:fi(),id3Track:o,textTrack:fi()}}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:fi(),id3Track:this._id3Track,textTrack:fi()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0;}},RS=(s,e,t)=>{if(H(s))return s*90;let i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i},No=null,kS=[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],DS=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],CS=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],MS=[0,1,1,4];function Pp(s,e,t,i,r){if(t+24>e.length)return;let n=Op(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 Op(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=kS[l*14+r-1]*1e3,u=DS[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=CS[t][i],m=MS[i],g=f*8*m,E=Math.floor(f*d/u+a)*m;if(No===null){let S=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);No=S?parseInt(S[1]):0;}return No&&No<=87&&i===2&&d>=224e3&&o===0&&(s[e+3]=s[e+3]|128),{sampleRate:u,channelCount:h,frameLength:E,samplesPerFrame:g}}}function rh(s,e){return s[e]===255&&(s[e+1]&224)===224&&(s[e+1]&6)!==0}function Fp(s,e){return e+1<s.length&&rh(s,e)}function wS(s,e){return rh(s,e)&&4<=s.length-e}function Up(s,e){if(e+1<s.length&&rh(s,e)){let i=Op(s,e),r=4;i!=null&&i.frameLength&&(r=i.frameLength);let n=e+r;return n===s.length||Fp(s,n)}return false}var qc=class extends On{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t;}resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0};}static probe(e,t){if(!e)return false;let i=Pn(e,0),r=i?.length||0;if(Up(e,r))return false;for(let n=e.length;r<n;r++)if(fS(e,r))return t.log("ADTS sync word found !"),true;return false}canParse(e,t){return hS(e,t)}appendFrame(e,t,i){kp(e,this.observer,t,i,e.manifestCodec);let r=Cp(e,t,i,this.basePTS,this.frameIndex);if(r&&r.missing===0)return r}},Np=(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},jc=class extends On{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=Bp(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=Pn(e,0);if(!t)return false;let i=t.length;return e[i]===11&&e[i+1]===119&&sh(t)!==void 0&&Np(e,i)<16}};function Bp(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 u=e[t+6]>>5,h=0;u===2?h+=2:(u&1&&u!==1&&(h+=2),u&4&&(h+=2));let f=(e[t+6]<<8|e[t+7])>>12-h&1,g=[2,1,2,3,3,4,4,5][u]+f,E=e[t+5]>>3,v=e[t+5]&7,y=new Uint8Array([n<<6|E<<1|v>>2,(v&3)<<6|u<<3|f<<2|l>>4,l<<4&224]),S=1536/o*9e4,b=i+r*S,_=e.subarray(t,t+c);return s.config=y,s.channelCount=g,s.samplerate=o,s.samples.push({unit:_,pts:b}),c}var zc=class extends On{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=Pn(e,0),i=t?.length||0;if(t&&e[i]===11&&e[i+1]===119&&sh(t)!==void 0&&Np(e,i)<=16)return false;for(let r=e.length;i<r;i++)if(Up(e,i))return ye.log("MPEG Audio sync word found !"),true;return false}canParse(e,t){return wS(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return Pp(e,t,i,this.basePTS,this.frameIndex)}},PS=/\/emsg[-/]ID3/i,Qc=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=fi("video",1),a=this.audioTrack=fi("audio",1),o=this.txtTrack=fi("text",1);if(this.id3Track=fi("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=Zg(e);if(l.video){let{id:d,timescale:c,codec:u,supplemental:h}=l.video;n.id=d,n.timescale=o.timescale=c,n.codec=u,n.supplemental=h;}if(l.audio){let{id:d,timescale:c,codec:u}=l.audio;a.id=d,a.timescale=c,a.codec=u;}o.id=zg.text,n.sampleDuration=0,n.duration=a.duration=r;}resetContiguity(){this.remainderData=null;}static probe(e){return KT(e)}demux(e,t){this.timeOffset=t;let i=e,r=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=Ct(this.remainderData,e));let o=QT(i);this.remainderData=o.remainder,r.samples=o.valid||new Uint8Array;}else r.samples=i;let a=this.extractID3Track(r,t);return n.samples=Bm(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=Bm(e,t),{videoTrack:t,audioTrack:fi(),id3Track:r,textTrack:fi()}}extractID3Track(e,t){let i=this.id3Track;if(e.samples.length){let r=de(e.samples,["emsg"]);r&&r.forEach(n=>{let a=ZT(n);if(PS.test(a.schemeIdUri)){let o=Sg(a,t),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:At.emsg,duration:l});}else if(this.config.enableEmsgKLVMetadata&&a.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){let o=Sg(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:o,pts:o,type:At.misbklv,duration:Number.POSITIVE_INFINITY});}});}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0;}};function Sg(s,e){return H(s.presentationTime)?s.presentationTime/s.timeScale:e+s.presentationTimeDelta/s.timeScale}var Xc=class{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Dn(t,{removePKCS7Padding:false});}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Gi.cbc)}decryptAacSample(e,t,i){let r=e[t].unit;if(r.length<=16)return;let n=r.subarray(16,r.length-r.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{let l=new Uint8Array(o);r.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i);}).catch(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=tp(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);}).catch(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}}}},gl=class{constructor(){this.VideoSample=null;}createVideoSample(e,t,i){return {key:e,frame:false,pts:t,dts:i,units:[],length:0}}getLastNalUnit(e){var t;let i=this.VideoSample,r;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){let n=i.units;r=n[n.length-1];}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){let i=t.samples,r=i.length;if(r){let n=i[r-1];e.pts=n.pts,e.dts=n.dts;}else {t.dropped++;return}}t.samples.push(e);}}parseNALu(e,t,i){let r=t.byteLength,n=e.naluState||0,a=n,o=[],l=0,d,c,u,h=-1,f=0;for(n===-1&&(h=0,f=this.getNALuType(t,0),n=0,l=1);l<r;){if(d=t[l++],!n){n=d?0:1;continue}if(n===1){n=d?0:2;continue}if(!d)n=3;else if(d===1){if(c=l-n-1,h>=0){let m={data:t.subarray(h,c),type:f};o.push(m);}else {let m=this.getLastNalUnit(e.samples);m&&(a&&l<=4-a&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-a)),c>0&&(m.data=Ct(m.data,t.subarray(0,c)),m.state=0));}l<r?(u=this.getNALuType(t,l),h=l,f=u,n=0):n=-1;}else n=0;}if(h>=0&&n>=0){let m={data:t.subarray(h,r),type:f,state:n};o.push(m);}if(o.length===0){let m=this.getLastNalUnit(e.samples);m&&(m.data=Ct(m.data,t));}return e.naluState=n,o}},fs=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&&ye.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)}},Zc=class extends gl{parsePES(e,t,i,r){let n=this.parseNALu(e,i.data,r),a=this.VideoSample,o,l=false;i.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts)),n.forEach(d=>{var c,u;switch(d.type){case 1:{let g=false;o=true;let E=d.data;if(l&&E.length>4){let v=this.readSliceType(E);(v===2||v===4||v===7||v===9)&&(g=true);}if(g){var h;(h=a)!=null&&h.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);}a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.frame=true,a.key=g;break}case 5:o=true,(c=a)!=null&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.key=true,a.frame=true;break;case 6:{o=true,ju(d.data,1,i.pts,t.samples);break}case 7:{var f,m;o=true,l=true;let g=d.data,E=this.readSPS(g);if(!e.sps||e.width!==E.width||e.height!==E.height||((f=e.pixelRatio)==null?void 0:f[0])!==E.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==E.pixelRatio[1]){e.width=E.width,e.height=E.height,e.pixelRatio=E.pixelRatio,e.sps=[g];let v=g.subarray(1,4),y="avc1.";for(let S=0;S<3;S++){let b=v[S].toString(16);b.length<2&&(b="0"+b),y+=b;}e.codec=y;}break}case 8:o=true,e.pps=[d.data];break;case 9:o=true,e.audFound=true,(u=a)!=null&&u.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts));break;case 12:o=true;break;default:o=false;break}a&&o&&a.units.push(d);}),r&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null);}getNALuType(e,t){return e[t]&31}readSliceType(e){let t=new fs(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,r=8,n;for(let a=0;a<e;a++)r!==0&&(n=t.readEG(),r=(i+n+256)%256),i=r===0?i:r;}readSPS(e){let t=new fs(e),i=0,r=0,n=0,a=0,o,l,d,c=t.readUByte.bind(t),u=t.readBits.bind(t),h=t.readUEG.bind(t),f=t.readBoolean.bind(t),m=t.skipBits.bind(t),g=t.skipEG.bind(t),E=t.skipUEG.bind(t),v=this.skipScalingList.bind(this);c();let y=c();if(u(5),m(3),c(),E(),y===100||y===110||y===122||y===244||y===44||y===83||y===86||y===118||y===128){let k=h();if(k===3&&m(1),E(),E(),m(1),f())for(l=k!==3?8:12,d=0;d<l;d++)f()&&(d<6?v(16,t):v(64,t));}E();let S=h();if(S===0)h();else if(S===1)for(m(1),g(),g(),o=h(),d=0;d<o;d++)g();E(),m(1);let b=h(),_=h(),D=u(1);D===0&&m(1),m(1),f()&&(i=h(),r=h(),n=h(),a=h());let I=[1,1];if(f()&&f())switch(c()){case 1:I=[1,1];break;case 2:I=[12,11];break;case 3:I=[10,11];break;case 4:I=[16,11];break;case 5:I=[40,33];break;case 6:I=[24,11];break;case 7:I=[20,11];break;case 8:I=[32,11];break;case 9:I=[80,33];break;case 10:I=[18,11];break;case 11:I=[15,11];break;case 12:I=[64,33];break;case 13:I=[160,99];break;case 14:I=[4,3];break;case 15:I=[3,2];break;case 16:I=[2,1];break;case 255:{I=[c()<<8|c(),c()<<8|c()];break}}return {width:Math.ceil((b+1)*16-i*2-r*2),height:(2-D)*(_+1)*16-(D?2:4)*(n+a),pixelRatio:I}}},Jc=class extends gl{constructor(...e){super(...e),this.initVPS=null;}parsePES(e,t,i,r){let n=this.parseNALu(e,i.data,r),a=this.VideoSample,o,l=false;i.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts)),n.forEach(d=>{var c,u;switch(d.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts)),a.frame=true,o=true;break;case 16:case 17:case 18:case 21:if(o=true,l){var h;(h=a)!=null&&h.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);}a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.key=true,a.frame=true;break;case 19:case 20:o=true,(c=a)!=null&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.key=true,a.frame=true;break;case 39:o=true,ju(d.data,2,i.pts,t.samples);break;case 32:o=true,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=Se(e.params,this.readVPS(d.data)),this.initVPS=d.data),e.vps=[d.data];break;case 33:if(o=true,l=true,e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],d.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){let f=this.readSPS(d.data);e.width=f.width,e.height=f.height,e.pixelRatio=f.pixelRatio,e.codec=f.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(let m in f.params)e.params[m]=f.params[m];}this.pushParameterSet(e.sps,d.data,e.vps),a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.key=true;break;case 34:if(o=true,typeof e.params=="object"){if(!e.pps){e.pps=[];let f=this.readPPS(d.data);for(let m in f)e.params[m]=f[m];}this.pushParameterSet(e.pps,d.data,e.vps);}break;case 35:o=true,e.audFound=true,(u=a)!=null&&u.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts));break;default:o=false;break}a&&o&&a.units.push(d);}),r&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null);}pushParameterSet(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t);}getNALuType(e,t){return (e[t]&126)>>>1}ebsp2rbsp(e){let t=new Uint8Array(e.byteLength),i=0;for(let r=0;r<e.byteLength;r++)r>=2&&e[r]===3&&e[r-1]===0&&e[r-2]===0||(t[i]=e[r],i++);return new Uint8Array(t.buffer,0,i)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null);}readVPS(e){let t=new fs(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);let i=t.readBits(3),r=t.readBoolean();return {numTemporalLayers:i+1,temporalIdNested:r}}readSPS(e){let t=new fs(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);let i=t.readBits(3);t.readBoolean();let r=t.readBits(2),n=t.readBoolean(),a=t.readBits(5),o=t.readUByte(),l=t.readUByte(),d=t.readUByte(),c=t.readUByte(),u=t.readUByte(),h=t.readUByte(),f=t.readUByte(),m=t.readUByte(),g=t.readUByte(),E=t.readUByte(),v=t.readUByte(),y=[],S=[];for(let fe=0;fe<i;fe++)y.push(t.readBoolean()),S.push(t.readBoolean());if(i>0)for(let fe=i;fe<8;fe++)t.readBits(2);for(let fe=0;fe<i;fe++)y[fe]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),S[fe]&&t.readUByte();t.readUEG();let b=t.readUEG();b==3&&t.skipBits(1);let _=t.readUEG(),D=t.readUEG(),I=t.readBoolean(),k=0,R=0,L=0,M=0;I&&(k+=t.readUEG(),R+=t.readUEG(),L+=t.readUEG(),M+=t.readUEG());let $=t.readUEG(),K=t.readUEG(),j=t.readUEG(),V=t.readBoolean();for(let fe=V?0:i;fe<=i;fe++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let He=0;He<4;He++)for(let rt=0;rt<(He===3?2:6);rt++)if(!t.readBoolean())t.readUEG();else {let It=Math.min(64,1<<4+(He<<1));He>1&&t.readEG();for(let me=0;me<It;me++)t.readEG();}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());let G=t.readUEG(),q=0;for(let fe=0;fe<G;fe++){let He=false;if(fe!==0&&(He=t.readBoolean()),He){fe===G&&t.readUEG(),t.readBoolean(),t.readUEG();let rt=0;for(let Wt=0;Wt<=q;Wt++){let It=t.readBoolean(),me=false;It||(me=t.readBoolean()),(It||me)&&rt++;}q=rt;}else {let rt=t.readUEG(),Wt=t.readUEG();q=rt+Wt;for(let It=0;It<rt;It++)t.readUEG(),t.readBoolean();for(let It=0;It<Wt;It++)t.readUEG(),t.readBoolean();}}if(t.readBoolean()){let fe=t.readUEG();for(let He=0;He<fe;He++){for(let rt=0;rt<j+4;rt++)t.readBits(1);t.readBits(1);}}let N=0,B=1,se=1,Ee=true,re=1,ce=0;t.readBoolean(),t.readBoolean();let Ge=false;if(t.readBoolean()){if(t.readBoolean()){let gt=t.readUByte(),$n=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],vs=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];gt>0&><16?(B=$n[gt-1],se=vs[gt-1]):gt===255&&(B=t.readBits(16),se=t.readBits(16));}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),Ge=t.readBoolean(),Ge&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(re=t.readBits(32),ce=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){let vs=t.readBoolean(),Gn=t.readBoolean(),Hi=false;(vs||Gn)&&(Hi=t.readBoolean(),Hi&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),Hi&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let Hn=0;Hn<=i;Hn++){Ee=t.readBoolean();let Fl=Ee||t.readBoolean(),Kn=false;Fl?t.readEG():Kn=t.readBoolean();let et=Kn?1:t.readUEG()+1;if(vs)for(let Le=0;Le<et;Le++)t.readUEG(),t.readUEG(),Hi&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(Gn)for(let Le=0;Le<et;Le++)t.readUEG(),t.readUEG(),Hi&&(t.readUEG(),t.readUEG()),t.skipBits(1);}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),N=t.readUEG());}let st=_,mt=D;if(I){let fe=1,He=1;b===1?fe=He=2:b==2&&(fe=2),st=_-fe*R-fe*k,mt=D-He*M-He*L;}let Mt=r?["A","B","C"][r]:"",Ii=o<<24|l<<16|d<<8|c,ps=0;for(let fe=0;fe<32;fe++)ps=(ps|(Ii>>fe&1)<<31-fe)>>>0;let Es=ps.toString(16);return a===1&&Es==="2"&&(Es="6"),{codecString:`hvc1.${Mt}${a}.${Es}.${n?"H":"L"}${v}.B0`,params:{general_tier_flag:n,general_profile_idc:a,general_profile_space:r,general_profile_compatibility_flags:[o,l,d,c],general_constraint_indicator_flags:[u,h,f,m,g,E],general_level_idc:v,bit_depth:$+8,bit_depth_luma_minus8:$,bit_depth_chroma_minus8:K,min_spatial_segmentation_idc:N,chroma_format_idc:b,frame_rate:{fixed:Ee,fps:ce/re}},width:st,height:mt,pixelRatio:[B,se]}}readPPS(e){let t=new fs(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);let r=t.readBoolean(),n=t.readBoolean(),a=1;return n&&r?a=0:n?a=3:r&&(a=2),{parallelismType:a}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}},ze=188,eu=class s{constructor(e,t,i,r){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=false,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.logger=r,this.videoParser=null;}static probe(e,t){let i=s.syncOffset(e);return i>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),i!==-1}static syncOffset(e){let t=e.length,i=Math.min(ze*5,t-ze)+1,r=0;for(;r<i;){let n=false,a=-1,o=0;for(let l=r;l<t;l+=ze)if(e[l]===71&&(t-l===ze||e[l+ze]===71)){if(o++,a===-1&&(a=l,a!==0&&(i=Math.min(a+ze*99,e.length-ze)+1)),n||(n=tu(e,l)===0),n&&o>1&&(a===0&&o>2||l+ze>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:zg[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,r){this.pmtParsed=false,this._pmtId=-1,this._videoTrack=s.createTrack("video"),this._videoTrack.duration=r,this._audioTrack=s.createTrack("audio",r),this._id3Track=s.createTrack("id3"),this._txtTrack=s.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i;}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null;}demux(e,t,i=false,r=false){i||(this.sampleAes=null);let n,a=this._videoTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack,c=a.pid,u=a.pesData,h=o.pid,f=l.pid,m=o.pesData,g=l.pesData,E=null,v=this.pmtParsed,y=this._pmtId,S=e.length;if(this.remainderData&&(e=Ct(this.remainderData,e),S=e.length,this.remainderData=null),S<ze&&!r)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let b=Math.max(0,s.syncOffset(e));S-=(S-b)%ze,S<e.byteLength&&!r&&(this.remainderData=new Uint8Array(e.buffer,S,e.buffer.byteLength-S));let _=0;for(let I=b;I<S;I+=ze)if(e[I]===71){let k=!!(e[I+1]&64),R=tu(e,I),L=(e[I+3]&48)>>4,M;if(L>1){if(M=I+5+e[I+4],M===I+ze)continue}else M=I+4;switch(R){case c:k&&(u&&(n=ar(u,this.logger))&&(this.readyVideoParser(a.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(a,d,n,false)),u={data:[],size:0}),u&&(u.data.push(e.subarray(M,I+ze)),u.size+=I+ze-M);break;case h:if(k){if(m&&(n=ar(m,this.logger)))switch(o.segmentCodec){case "aac":this.parseAACPES(o,n);break;case "mp3":this.parseMPEGPES(o,n);break;case "ac3":this.parseAC3PES(o,n);break}m={data:[],size:0};}m&&(m.data.push(e.subarray(M,I+ze)),m.size+=I+ze-M);break;case f:k&&(g&&(n=ar(g,this.logger))&&this.parseID3PES(l,n),g={data:[],size:0}),g&&(g.data.push(e.subarray(M,I+ze)),g.size+=I+ze-M);break;case 0:k&&(M+=e[M]+1),y=this._pmtId=OS(e,M);break;case y:{k&&(M+=e[M]+1);let $=FS(e,M,this.typeSupported,i,this.observer,this.logger);c=$.videoPid,c>0&&(a.pid=c,a.segmentCodec=$.segmentVideoCodec),h=$.audioPid,h>0&&(o.pid=h,o.segmentCodec=$.segmentAudioCodec),f=$.id3Pid,f>0&&(l.pid=f),E!==null&&!v&&(this.logger.warn(`MPEG-TS PMT found at ${I} after unknown PID '${E}'. Backtracking to sync byte @${b} to parse all TS packets.`),E=null,I=b-188),v=this.pmtParsed=true;break}case 17:case 8191:break;default:E=R;break}}else _++;_>0&&iu(this.observer,new Error(`Found ${_} TS packet/s that do not start with 0x47`),void 0,this.logger),a.pesData=u,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=ar(a,this.logger))?(this.readyVideoParser(i.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(i,n,d,true),i.pesData=null)):i.pesData=a,o&&(d=ar(o,this.logger))){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&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=ar(l,this.logger))?(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 Xc(this.observer,this.config,t);return this.decrypt(r,n)}readyVideoParser(e){this.videoParser===null&&(e==="avc"?this.videoParser=new Zc:e==="hevc"&&(this.videoParser=new Jc));}decrypt(e,t){return new Promise(i=>{let{audioTrack:r,videoTrack:n}=e;r.samples&&r.segmentCodec==="aac"?t.decryptAacSamples(r.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{i(e);}):i(e);}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{i(e);});})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0;}parseAACPES(e,t){let i=0,r=this.aacOverFlow,n=t.data;if(r){this.aacOverFlow=null;let u=r.missing,h=r.sample.unit.byteLength;if(u===-1)n=Ct(r.sample.unit,n);else {let f=h-u;r.sample.unit.set(n.subarray(0,u),f),e.samples.push(r.sample),i=r.missing;}}let a,o;for(a=i,o=n.length;a<o-1&&!ml(n,a);a++);if(a!==i){let u,h=a<o-1;if(h?u=`AAC PES did not start with ADTS header,offset:${a}`:u="No ADTS header found in AAC PES",iu(this.observer,new Error(u),h,this.logger),!h)return}kp(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(r){let u=Dp(e.samplerate);l=r.sample.pts+u;}else {this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,c;for(;a<o;)if(c=Cp(e,n,a,l,d),a+=c.length,c.missing){this.aacOverFlow=c;break}else for(d++;a<o-1&&!ml(n,a);a++);}parseMPEGPES(e,t){let i=t.data,r=i.length,n=0,a=0,o=t.pts;if(o===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<r;)if(Fp(i,a)){let l=Pp(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){this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");return}let n=i.length,a=0,o=0,l;for(;o<n&&(l=Bp(e,i,o,r,a++))>0;)o+=l;}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let i=Se({},t,{type:this._videoTrack?At.emsg:At.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i);}};function tu(s,e){return ((s[e+1]&31)<<8)+s[e+2]}function OS(s,e){return (s[e+10]&31)<<8|s[e+11]}function FS(s,e,t,i,r,n){let a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=(s[e+1]&15)<<8|s[e+2],l=e+3+o-4,d=(s[e+10]&15)<<8|s[e+11];for(e+=12+d;e<l;){let c=tu(s,e),u=(s[e+3]&15)<<8|s[e+4];switch(s[e]){case 207:if(!i){mc("ADTS AAC",n);break}case 15:a.audioPid===-1&&(a.audioPid=c);break;case 21:a.id3Pid===-1&&(a.id3Pid=c);break;case 219:if(!i){mc("H.264",n);break}case 27:a.videoPid===-1&&(a.videoPid=c);break;case 3:case 4:!t.mpeg&&!t.mp3?n.log("MPEG audio found, not supported in this browser"):a.audioPid===-1&&(a.audioPid=c,a.segmentAudioCodec="mp3");break;case 193:if(!i){mc("AC-3",n);break}case 129:t.ac3?a.audioPid===-1&&(a.audioPid=c,a.segmentAudioCodec="ac3"):n.log("AC-3 audio found, not supported in this browser");break;case 6:if(a.audioPid===-1&&u>0){let h=e+5,f=u;for(;f>2;){s[h]===106&&(t.ac3!==true?n.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=c,a.segmentAudioCodec="ac3"));let g=s[h+1]+2;h+=g,f-=g;}}break;case 194:case 135:return iu(r,new Error("Unsupported EC-3 in M2TS found"),void 0,n),a;case 36:a.videoPid===-1&&(a.videoPid=c,a.segmentVideoCodec="hevc",n.log("HEVC in M2TS found"));break}e+=u+5;}return a}function iu(s,e,t,i){i.warn(`parsing error: ${e.message}`),s.emit(p.ERROR,p.ERROR,{type:z.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:false,levelRetry:t,error:e,reason:e.message});}function mc(s,e){e.log(`${s} with AES-128-CBC encryption found in unencrypted stream`);}function ar(s,e){let t=0,i,r,n,a,o,l=s.data;if(!s||s.size===0)return null;for(;l[0].length<19&&l.length>1;)l[0]=Ct(l[0],l[1]),l.splice(1,1);if(i=l[0],(i[0]<<16)+(i[1]<<8)+i[2]===1){if(r=(i[4]<<8)+i[5],r&&r>s.size-6)return null;let c=i[7];c&192&&(a=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,c&64?(o=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,a-o>60*9e4&&(e.warn(`${Math.round((a-o)/9e4)}s delta between PTS and DTS, align them`),a=o)):o=a),n=i[8];let u=n+9;if(s.size<=u)return null;s.size-=u;let h=new Uint8Array(s.size);for(let f=0,m=l.length;f<m;f++){i=l[f];let g=i.byteLength;if(u)if(u>g){u-=g;continue}else i=i.subarray(u),g-=u,u=0;h.set(i,t),t+=g;}return r&&(r-=n+3),{data:h,pts:a,dts:o,len:r}}return null}var su=class{static getSilentFrame(e,t){switch(e){case "mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}},Fi=Math.pow(2,32)-1,Ye=class s{static init(){s.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in s.types)s.types.hasOwnProperty(e)&&(s.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);s.HDLR_TYPES={video:t,audio:i};let r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);s.STTS=s.STSC=s.STCO=n,s.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),s.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),s.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),s.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),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/(Fi+1)),r=Math.floor(t%(Fi+1));return s.box(s.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))}static mdia(e){return s.box(s.types.mdia,s.mdhd(e.timescale||0,e.duration||0),s.hdlr(e.type),s.minf(e))}static mfhd(e){return s.box(s.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?s.box(s.types.minf,s.box(s.types.smhd,s.SMHD),s.DINF,s.stbl(e)):s.box(s.types.minf,s.box(s.types.vmhd,s.VMHD),s.DINF,s.stbl(e))}static moof(e,t,i){return s.box(s.types.moof,s.mfhd(e),s.traf(i,t))}static moov(e){let t=e.length,i=[];for(;t--;)i[t]=s.trak(e[t]);return s.box.apply(null,[s.types.moov,s.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(s.mvex(e)))}static mvex(e){let t=e.length,i=[];for(;t--;)i[t]=s.trex(e[t]);return s.box.apply(null,[s.types.mvex,...i])}static mvhd(e,t){t*=e;let i=Math.floor(t/(Fi+1)),r=Math.floor(t%(Fi+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,r>>24,r>>16&255,r>>8&255,r&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return s.box(s.types.mvhd,n)}static sdtp(e){let t=e.samples||[],i=new Uint8Array(4+t.length),r,n;for(r=0;r<t.length;r++)n=t[r].flags,i[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return s.box(s.types.sdtp,i)}static stbl(e){return s.box(s.types.stbl,s.stsd(e),s.box(s.types.stts,s.STTS),s.box(s.types.stsc,s.STSC),s.box(s.types.stsz,s.STSZ),s.box(s.types.stco,s.STCO))}static avc1(e){let t=[],i=[],r,n,a;for(r=0;r<e.sps.length;r++)n=e.sps[r],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(r=0;r<e.pps.length;r++)n=e.pps[r],a=n.byteLength,i.push(a>>>8&255),i.push(a&255),i=i.concat(Array.prototype.slice.call(n));let o=s.box(s.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),l=e.width,d=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return s.box(s.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,u>>24,u>>16&255,u>>8&255,u&255])))}static esds(e){let t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}static audioStsd(e){let t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return s.box(s.types.mp4a,s.audioStsd(e),s.box(s.types.esds,s.esds(e)))}static mp3(e){return s.box(s.types[".mp3"],s.audioStsd(e))}static ac3(e){return s.box(s.types["ac-3"],s.audioStsd(e),s.box(s.types.dac3,e.config))}static stsd(e){let{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return s.box(s.types.stsd,s.STSD,s.mp4a(e));if(t==="ac3"&&e.config)return s.box(s.types.stsd,s.STSD,s.ac3(e));if(t==="mp3"&&e.codec==="mp3")return s.box(s.types.stsd,s.STSD,s.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return s.box(s.types.stsd,s.STSD,s.avc1(e));if(t==="hevc"&&e.vps)return s.box(s.types.stsd,s.STSD,s.hvc1(e))}else throw new Error("video track missing pps or sps");throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){let t=e.id,i=(e.duration||0)*(e.timescale||0),r=e.width||0,n=e.height||0,a=Math.floor(i/(Fi+1)),o=Math.floor(i%(Fi+1));return s.box(s.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,r&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){let i=s.sdtp(e),r=e.id,n=Math.floor(t/(Fi+1)),a=Math.floor(t%(Fi+1));return s.box(s.types.traf,s.box(s.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),s.box(s.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),s.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,s.box(s.types.trak,s.tkhd(e),s.mdia(e))}static trex(e){let t=e.id;return s.box(s.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let i=e.samples||[],r=i.length,n=12+16*r,a=new Uint8Array(n),o,l,d,c,u,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<r;o++)l=i[o],d=l.duration,c=l.size,u=l.flags,h=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,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,u.degradPrio&61440,u.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return s.box(s.types.trun,a)}static initSegment(e){s.types||s.init();let t=s.moov(e);return Ct(s.FTYP,t)}static hvc1(e){let t=e.params,i=[e.vps,e.sps,e.pps],r=4,n=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),r-1|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),i.length]),a=n.length;for(let m=0;m<i.length;m+=1){a+=3;for(let g=0;g<i[m].length;g+=1)a+=2+i[m][g].length;}let o=new Uint8Array(a);o.set(n,0),a=n.length;let l=i.length-1;for(let m=0;m<i.length;m+=1){o.set(new Uint8Array([32+m|(m===l?128:0),0,i[m].length]),a),a+=3;for(let g=0;g<i[m].length;g+=1)o.set(new Uint8Array([i[m][g].length>>8,i[m][g].length&255]),a),a+=2,o.set(i[m][g],a),a+=i[m][g].length;}let d=s.box(s.types.hvcC,o),c=e.width,u=e.height,h=e.pixelRatio[0],f=e.pixelRatio[1];return s.box(s.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c>>8&255,c&255,u>>8&255,u&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,f>>24,f>>16&255,f>>8&255,f&255])))}};Ye.types=void 0;Ye.HDLR_TYPES=void 0;Ye.STTS=void 0;Ye.STSC=void 0;Ye.STCO=void 0;Ye.STSZ=void 0;Ye.VMHD=void 0;Ye.SMHD=void 0;Ye.STSD=void 0;Ye.FTYP=void 0;Ye.DINF=void 0;var $p=9e4;function nh(s,e,t=1,i=false){let r=s*e*t;return i?Math.round(r):r}function US(s,e,t=1,i=false){return nh(s,e,1/t,i)}function Sn(s,e=false){return nh(s,1e3,1/$p,e)}function NS(s,e=1){return nh(s,$p,1/e)}function bg(s){let{baseTime:e,timescale:t,trackId:i}=s;return `${e/t} (${e}/${t}) trackId: ${i}`}var BS=10*1e3,$S=1024,GS=1152,HS=1536,or=null,gc=null;function Ag(s,e,t,i){return {duration:e,size:t,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:s?2:1,isNonSync:s?0:1}}}var fr=class extends ft{constructor(e,t,i,r){if(super("mp4-remuxer",r),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=false,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=false,this.isVideoContiguous=false,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=false,or===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);or=a?parseInt(a[1]):0;}if(gc===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);gc=n?parseInt(n[1]):0;}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null;}resetTimeStamp(e){let t=this._initPTS;(!t||!e||e.trackId!==t.trackId||e.baseTime!==t.baseTime||e.timescale!==t.timescale)&&this.log(`Reset initPTS: ${t&&bg(t)} > ${e&&bg(e)}`),this._initPTS=this._initDTS=e;}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=false,this.isAudioContiguous=false;}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=false,this.videoTrackConfig=void 0;}getVideoStartPts(e){let t=false,i=e[0].pts,r=e.reduce((n,a)=>{let o=a.pts,l=o-n;return l<-4294967296&&(t=true,o=bt(o,i),l=o-n),l>0?n:o},i);return t&&this.debug("PTS rollover detected"),r}remux(e,t,i,r,n,a,o,l){let d,c,u,h,f,m,g=n,E=n,v=e.pid>-1,y=t.pid>-1,S=t.samples.length,b=e.samples.length>0,_=o&&S>0||S>1;if((!v||b)&&(!y||_)||this.ISGenerated||o){if(this.ISGenerated){var I,k,R,L;let j=this.videoTrackConfig;(j&&(t.width!==j.width||t.height!==j.height||((I=t.pixelRatio)==null?void 0:I[0])!==((k=j.pixelRatio)==null?void 0:k[0])||((R=t.pixelRatio)==null?void 0:R[1])!==((L=j.pixelRatio)==null?void 0:L[1]))||!j&&_||this.nextAudioTs===null&&b)&&this.resetInitSegment();}this.ISGenerated||(u=this.generateIS(e,t,n,a));let M=this.isVideoContiguous,$=-1,K;if(_&&($=KS(t.samples),!M&&this.config.forceKeyFrameOnDiscontinuity))if(m=true,$>0){this.warn(`Dropped ${$} out of ${S} video samples due to a missing keyframe`);let j=this.getVideoStartPts(t.samples);t.samples=t.samples.slice($),t.dropped+=$,E+=(t.samples[0].pts-j)/t.inputTimeScale,K=E;}else $===-1&&(this.warn(`No keyframe found out of ${S} video samples`),m=false);if(this.ISGenerated){if(b&&_){let j=this.getVideoStartPts(t.samples),F=(bt(e.samples[0].pts,j)-j)/t.inputTimeScale;g+=Math.max(0,F),E+=Math.max(0,-F);}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),u=this.generateIS(e,t,n,a)),c=this.remuxAudio(e,g,this.isAudioContiguous,a,y||_||l===W.AUDIO?E:void 0),_){let j=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),u=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,E,M,j);}}else _&&(d=this.remuxVideo(t,E,M,0));d&&(d.firstKeyFrame=$,d.independent=$!==-1,d.firstKeyFramePTS=K);}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(f=Gp(i,n,this._initPTS,this._initDTS)),r.samples.length&&(h=Hp(r,n,this._initPTS))),{audio:c,video:d,initSegment:u,independent:m,text:h,id3:f}}computeInitPts(e,t,i,r){let n=Math.round(i*t),a=bt(e,n);if(a<n+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(n-a)/t} ${r}`);a<n+t;)a+=8589934592;return a-n}generateIS(e,t,i,r){let n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS,c=!d||r,u="audio/mp4",h,f,m,g=-1;if(c&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case "mp3":o.mpeg?(u="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case "ac3":e.codec="ac-3";break}l.audio={id:"audio",container:u,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):Ye.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(g=e.id,m=e.inputTimeScale,!d||m!==d.timescale?h=f=this.computeInitPts(n[0].pts,m,i,"audio"):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:Ye.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(g=t.id,m=t.inputTimeScale,!d||m!==d.timescale){let E=this.getVideoStartPts(a),v=bt(a[0].dts,E),y=this.computeInitPts(v,m,i,"video"),S=this.computeInitPts(E,m,i,"video");f=Math.min(f,y),h=Math.min(h,S);}else c=false;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio};}if(Object.keys(l).length)return this.ISGenerated=true,c?(d&&this.warn(`Timestamps at playlist time: ${r?"":"~"}${i} ${h/m} != initPTS: ${d.baseTime/d.timescale} (${d.baseTime}/${d.timescale}) trackId: ${d.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${h/m} (${h}/${m}) trackId: ${g}`),this._initPTS={baseTime:h,timescale:m,trackId:g},this._initDTS={baseTime:f,timescale:m,trackId:g}):h=m=void 0,{tracks:l,initPTS:h,timescale:m,trackId:g}}remuxVideo(e,t,i,r){let n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS,c=d.baseTime*n/d.timescale,u=this.nextVideoTs,h=8,f=this.videoSampleDuration,m,g,E=Number.POSITIVE_INFINITY,v=Number.NEGATIVE_INFINITY,y=false;if(!i||u===null){let N=c+t*n,B=a[0].pts-bt(a[0].dts,a[0].pts);or&&u!==null&&Math.abs(N-B-(u+c))<15e3?i=true:u=N-B-c;}let S=u+c;for(let N=0;N<l;N++){let B=a[N];B.pts=bt(B.pts,S),B.dts=bt(B.dts,S),B.dts<a[N>0?N-1:N].dts&&(y=true);}y&&a.sort(function(N,B){let se=N.dts-B.dts,Ee=N.pts-B.pts;return se||Ee}),m=a[0].dts,g=a[a.length-1].dts;let b=g-m,_=b?Math.round(b/(l-1)):f||e.inputTimeScale/30;if(i){let N=m-S,B=N>_,se=N<-1;if((B||se)&&(B?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Sn(N,true)} ms (${N}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Sn(-N,true)} ms (${N}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!se||S>=a[0].pts||or)){m=S;let Ee=a[0].pts-N;if(B)a[0].dts=m,a[0].pts=Ee;else {let re=true;for(let ce=0;ce<a.length&&!(a[ce].dts>Ee&&re);ce++){let Ge=a[ce].pts;if(a[ce].dts-=N,a[ce].pts-=N,ce<a.length-1){let Ue=a[ce+1].pts,st=a[ce].pts,mt=Ue<=st,Mt=Ue<=Ge;re=mt==Mt;}}}this.log(`Video: Initial PTS/DTS adjusted: ${Sn(Ee,true)}/${Sn(m,true)}, delta: ${Sn(N,true)} ms`);}}m=Math.max(0,m);let D=0,I=0,k=m;for(let N=0;N<l;N++){let B=a[N],se=B.units,Ee=se.length,re=0;for(let ce=0;ce<Ee;ce++)re+=se[ce].data.length;I+=re,D+=Ee,B.length=re,B.dts<k?(B.dts=k,k+=_/4|0||1):k=B.dts,E=Math.min(B.pts,E),v=Math.max(B.pts,v);}g=a[l-1].dts;let R=I+4*D+8,L;try{L=new Uint8Array(R);}catch(N){this.observer.emit(p.ERROR,p.ERROR,{type:z.MUX_ERROR,details:x.REMUX_ALLOC_ERROR,fatal:false,error:N,bytes:R,reason:`fail allocating video mdat ${R}`});return}let M=new DataView(L.buffer);M.setUint32(0,R),L.set(Ye.types.mdat,4);let $=false,K=Number.POSITIVE_INFINITY,j=Number.POSITIVE_INFINITY,V=Number.NEGATIVE_INFINITY,F=Number.NEGATIVE_INFINITY;for(let N=0;N<l;N++){let B=a[N],se=B.units,Ee=0;for(let Ge=0,Ue=se.length;Ge<Ue;Ge++){let st=se[Ge],mt=st.data,Mt=st.data.byteLength;M.setUint32(h,Mt),h+=4,L.set(mt,h),h+=Mt,Ee+=4+Mt;}let re;if(N<l-1)f=a[N+1].dts-B.dts,re=a[N+1].pts-B.pts;else {let Ge=this.config,Ue=N>0?B.dts-a[N-1].dts:_;if(re=N>0?B.pts-a[N-1].pts:_,Ge.stretchShortVideoTrack&&this.nextAudioTs!==null){let st=Math.floor(Ge.maxBufferHole*n),mt=(r?E+r*n:this.nextAudioTs+c)-B.pts;mt>st?(f=mt-Ue,f<0?f=Ue:$=true,this.log(`It is approximately ${mt/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=Ue;}else f=Ue;}let ce=Math.round(B.pts-B.dts);K=Math.min(K,f),V=Math.max(V,f),j=Math.min(j,re),F=Math.max(F,re),o.push(Ag(B.key,f,Ee,ce));}if(o.length){if(or){if(or<70){let N=o[0].flags;N.dependsOn=2,N.isNonSync=0;}}else if(gc&&F-j<V-K&&_/V<.025&&o[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let N=m;for(let B=0,se=o.length;B<se;B++){let Ee=N+o[B].duration,re=N+o[B].cts;if(B<se-1){let ce=Ee+o[B+1].cts;o[B].duration=ce-re;}else o[B].duration=B?o[B-1].duration:_;o[B].cts=0,N=Ee;}}}f=$||!f?_:f;let Y=g+f;this.nextVideoTs=u=Y-c,this.videoSampleDuration=f,this.isVideoContiguous=true;let X={data1:Ye.moof(e.sequenceNumber++,m,Se(e,{samples:o})),data2:L,startPTS:(E-c)/n,endPTS:(v+f-c)/n,startDTS:(m-c)/n,endDTS:u/n,type:"video",hasAudio:false,hasVideo:true,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,X}getSamplesPerFrame(e){switch(e.segmentCodec){case "mp3":return GS;case "ac3":return HS;default:return $S}}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,u=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=n!==void 0,g=e.samples,E=h?0:8,v=this.nextAudioTs||-1,y=u.baseTime*a/u.timescale,S=y+t*a;if(this.isAudioContiguous=i=i||g.length&&v>0&&(r&&Math.abs(S-(v+y))<9e3||Math.abs(bt(g[0].pts,S)-(v+y))<20*c),g.forEach(function(F){F.pts=bt(F.pts,S);}),!i||v<0){let F=g.length;if(g=g.filter(Y=>Y.pts>=0),F!==g.length&&this.warn(`Removed ${g.length-F} of ${F} samples (initPTS ${y} / ${a})`),!g.length)return;n===0?v=0:r&&!m?v=Math.max(0,S-y):v=g[0].pts-y;}if(e.segmentCodec==="aac"){let F=this.config.maxAudioFramesDrift;for(let Y=0,G=v+y;Y<g.length;Y++){let q=g[Y],X=q.pts,N=X-G,B=Math.abs(1e3*N/a);if(N<=-F*c&&m)Y===0&&(this.warn(`Audio frame @ ${(X/a).toFixed(3)}s overlaps marker by ${Math.round(1e3*N/a)} ms.`),this.nextAudioTs=v=X-y,G=X);else if(N>=F*c&&B<BS&&m){let se=Math.round(N/c);for(G=X-se*c;G<0&&se&&c;)se--,G+=c;Y===0&&(this.nextAudioTs=v=G-y),this.warn(`Injecting ${se} audio frames @ ${((G-y)/a).toFixed(3)}s due to ${Math.round(1e3*N/a)} ms gap.`);for(let Ee=0;Ee<se;Ee++){let re=su.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);re||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),re=q.unit.subarray()),g.splice(Y,0,{unit:re,pts:G}),G+=c,Y++;}}q.pts=G,G+=c;}}let b=null,_=null,D,I=0,k=g.length;for(;k--;)I+=g[k].unit.byteLength;for(let F=0,Y=g.length;F<Y;F++){let G=g[F],q=G.unit,X=G.pts;if(_!==null){let B=f[F-1];B.duration=Math.round((X-_)/l);}else if(i&&e.segmentCodec==="aac"&&(X=v+y),b=X,I>0){I+=E;try{D=new Uint8Array(I);}catch(B){this.observer.emit(p.ERROR,p.ERROR,{type:z.MUX_ERROR,details:x.REMUX_ALLOC_ERROR,fatal:false,error:B,bytes:I,reason:`fail allocating audio mdat ${I}`});return}h||(new DataView(D.buffer).setUint32(0,I),D.set(Ye.types.mdat,4));}else return;D.set(q,E);let N=q.byteLength;E+=N,f.push(Ag(true,d,N,0)),_=X;}let R=f.length;if(!R)return;let L=f[f.length-1];v=_-y,this.nextAudioTs=v+l*L.duration;let M=h?new Uint8Array(0):Ye.moof(e.sequenceNumber++,b/l,Se({},e,{samples:f}));e.samples=[];let $=(b-y)/a,K=this.nextAudioTs/a,V={data1:M,data2:D,startPTS:$,endPTS:K,startDTS:$,endDTS:K,type:"audio",hasAudio:true,hasVideo:false,nb:R};return this.isAudioContiguous=true,V}};function bt(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 KS(s){for(let e=0;e<s.length;e++)if(s[e].key)return e;return -1}function Gp(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=bt(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=bt(l.dts-i.baseTime*n/i.timescale,e*n)/n;}let a=s.samples;return s.samples=[],{samples:a}}function Hp(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=bt(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 ru=class extends ft{constructor(e,t,i,r){super("passthrough-remuxer",r),this.emitInitSegment=false,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=false;}destroy(){}resetTimeStamp(e){this.lastEndTime=null;let t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e);}resetNextTimestamp(){this.isVideoContiguous=false,this.lastEndTime=null;}resetInitSegment(e,t,i,r){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(e,r),this.emitInitSegment=true;}generateInitSegment(e,t){let{audioCodec:i,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let{audio:n,video:a}=this.initData=Zg(e);if(t)qT(e,t);else {let l=n||a;l!=null&&l.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${l.codec}")!`);}n&&(i=_g(n,be.AUDIO,this)),a&&(r=_g(a,be.VIDEO,this));let o={};n&&a?o.audiovideo={container:"video/mp4",codec:i+","+r,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:n?o.audio={container:"audio/mp4",codec:i,encrypted:n.encrypted,initSegment:e,id:"audio"}:a?o.video={container:"video/mp4",codec:r,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=o;}remux(e,t,i,r,n,a){var o,l;let{initPTS:d,lastEndTime:c}=this,u={audio:void 0,video:void 0,text:r,id3:i,initSegment:void 0};H(c)||(c=this.lastEndTime=n||0);let h=t.samples;if(!h.length)return u;let f={initPTS:void 0,timescale:void 0,trackId:void 0},m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(h),m=this.initData),!((l=m)!=null&&l.length))return this.warn("Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=false);let g=zT(h,m,this),E=m.audio?g[m.audio.id]:null,v=m.video?g[m.video.id]:null,y=Bo(v,1/0),S=Bo(E,1/0),b=Bo(v,0,true),_=Bo(E,0,true),D=n,I=0,k=E&&(!v||!d&&S<y||d&&d.trackId===m.audio.id),R=k?E:v;if(R){let G=R.timescale,q=R.start-n*G,X=k?m.audio.id:m.video.id;D=R.start/G,I=k?_-S:b-y,(a||!d)&&(VS(d,D,n,I)||G!==d.timescale)&&(d&&this.warn(`Timestamps at playlist time: ${a?"":"~"}${n} ${q/G} != initPTS: ${d.baseTime/d.timescale} (${d.baseTime}/${d.timescale}) trackId: ${d.trackId}`),this.log(`Found initPTS at playlist time: ${n} offset: ${D-n} (${q}/${G}) trackId: ${X}`),d=null,f.initPTS=q,f.timescale=G,f.trackId=X);}else this.warn(`No audio or video samples found for initPTS at playlist time: ${n}`);d?(f.initPTS=d.baseTime,f.timescale=d.timescale,f.trackId=d.trackId):((!f.timescale||f.trackId===void 0||f.initPTS===void 0)&&(this.warn("Could not set initPTS"),f.initPTS=D,f.timescale=1,f.trackId=-1),this.initPTS=d={baseTime:f.initPTS,timescale:f.timescale,trackId:f.trackId});let L=D-d.baseTime/d.timescale,M=L+I;I>0?this.lastEndTime=M:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let $=!!m.audio,K=!!m.video,j="";$&&(j+="audio"),K&&(j+="video");let V=(m.audio?m.audio.encrypted:false)||(m.video?m.video.encrypted:false),F={data1:h,startPTS:L,startDTS:L,endPTS:M,endDTS:M,type:j,hasAudio:$,hasVideo:K,nb:1,dropped:0,encrypted:V};u.audio=$&&!K?F:void 0,u.video=K?F:void 0;let Y=v?.sampleCount;if(Y){let G=v.keyFrameIndex,q=G!==-1;F.nb=Y,F.dropped=G===0||this.isVideoContiguous?0:q?G:Y,F.independent=q,F.firstKeyFrame=G,q&&v.keyFrameStart&&(F.firstKeyFramePTS=(v.keyFrameStart-d.baseTime)/d.timescale),this.isVideoContiguous||(u.independent=q),this.isVideoContiguous||(this.isVideoContiguous=q),F.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${G}/${Y} dropped: ${F.dropped} start: ${F.firstKeyFramePTS||"NA"}`);}return u.initSegment=f,u.id3=Gp(i,n,d,d),r.samples.length&&(u.text=Hp(r,n,d)),u}};function Bo(s,e,t=false){return s?.start!==void 0?(s.start+(t?s.duration:0))/s.timescale:e}function VS(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 _g(s,e,t){let i=s.codec;return i&&i.length>4?i:e===be.AUDIO?i==="ec-3"||i==="ac-3"||i==="alac"?i:i==="fLaC"||i==="Opus"?il(i,false):(t.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"):(t.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1")}var Ai;try{Ai=self.performance.now.bind(self.performance);}catch{Ai=Date.now;}var Qo=[{demux:Qc,remux:ru},{demux:eu,remux:fr},{demux:qc,remux:fr},{demux:zc,remux:fr}];Qo.splice(2,0,{demux:jc,remux:fr});var pl=class{constructor(e,t,i,r,n,a){this.asyncResult=false,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.id=n,this.logger=a;}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset();}push(e,t,i,r){let n=i.transmuxing;n.executeStart=Ai();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;r&&(this.currentTransmuxState=r);let{contiguous:d,discontinuity:c,trackSwitch:u,accurateTimeOffset:h,timeOffset:f,initSegmentChange:m}=r||o,{audioCodec:g,videoCodec:E,defaultInitPts:v,duration:y,initSegmentData:S}=l,b=WS(a,t);if(b&&hr(b.method)){let k=this.getDecrypter(),R=Zu(b.method);if(k.isSync()){let L=k.softwareDecrypt(a,b.key.buffer,b.iv.buffer,R);if(i.part>-1){let $=k.flush();L=$&&$.buffer;}if(!L)return n.executeEnd=Ai(),pc(i);a=new Uint8Array(L);}else return this.asyncResult=true,this.decryptionPromise=k.webCryptoDecrypt(a,b.key.buffer,b.iv.buffer,R).then(L=>{let M=this.push(L,null,i);return this.decryptionPromise=null,M}),this.decryptionPromise}let _=this.needsProbing(c,u);if(_){let k=this.configureTransmuxer(a);if(k)return this.logger.warn(`[transmuxer] ${k.message}`),this.observer.emit(p.ERROR,p.ERROR,{type:z.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:false,error:k,reason:k.message}),n.executeEnd=Ai(),pc(i)}(c||u||m||_)&&this.resetInitSegment(S,g,E,y,t),(c||m||_)&&this.resetInitialTimestamp(v),d||this.resetContiguity();let D=this.transmux(a,b,f,h,i);this.asyncResult=Fn(D);let I=this.currentTransmuxState;return I.contiguous=true,I.discontinuity=false,I.trackSwitch=false,n.executeEnd=Ai(),D}flush(e){let t=e.transmuxing;t.executeStart=Ai();let{decrypter:i,currentTransmuxState:r,decryptionPromise:n}=this;if(n)return this.asyncResult=true,n.then(()=>this.flush(e));let a=[],{timeOffset:o}=r;if(i){let u=i.flush();u&&a.push(this.push(u.buffer,null,e));}let{demuxer:l,remuxer:d}=this;if(!l||!d){t.executeEnd=Ai();let u=[pc(e)];return this.asyncResult?Promise.resolve(u):u}let c=l.flush(o);return Fn(c)?(this.asyncResult=true,c.then(u=>(this.flushRemux(a,u,e),a))):(this.flushRemux(a,c,e),this.asyncResult?Promise.resolve(a):a)}flushRemux(e,t,i){let{audioTrack:r,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===W.MAIN?"level":"track"} ${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=Ai();}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}=this,n;for(let u=0,h=Qo.length;u<h;u++){var a;if((a=Qo[u].demux)!=null&&a.probe(e,this.logger)){n=Qo[u];break}}if(!n)return new Error("Failed to find demuxer by probing fragment data");let o=this.demuxer,l=this.remuxer,d=n.remux,c=n.demux;(!l||!(l instanceof d))&&(this.remuxer=new d(i,t,r,this.logger)),(!o||!(o instanceof c))&&(this.demuxer=new c(i,t,r,this.logger),this.probe=c.probe);}needsProbing(e,t){return !this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Dn(this.config)),e}};function WS(s,e){let t=null;return s.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var pc=s=>({remuxResult:{},chunkMeta:s});function Fn(s){return "then"in s&&s.then instanceof Function}var nu=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;}},au=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;}},Ig=0,El=class{constructor(e,t,i,r){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Ig++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=l=>{let d=l.data,c=this.hls;if(!(!c||!(d!=null&&d.event)||d.instanceNo!==this.instanceNo))switch(d.event){case "init":{var u;let h=(u=this.workerContext)==null?void 0:u.objectURL;h&&self.URL.revokeObjectURL(h);break}case "transmuxComplete":{this.handleTransmuxComplete(d.data);break}case "flush":{this.onFlush(d.data);break}case "workerLog":{c.logger[d.data.logType]&&c.logger[d.data.logType](d.data.message);break}default:{d.data=d.data||{},d.data.frag=this.frag,d.data.part=this.part,d.data.id=this.id,c.trigger(d.event,d.data);break}}},this.onWorkerError=l=>{if(!this.hls)return;let d=new Error(`${l.message} (${l.filename}:${l.lineno})`);this.hls.config.enableWorker=false,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(p.ERROR,{type:z.OTHER_ERROR,details:x.INTERNAL_EXCEPTION,fatal:false,event:"demuxerWorker",error:d});};let n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=i,this.onFlush=r;let a=(l,d)=>{d=d||{},d.frag=this.frag||void 0,l===p.ERROR&&(d=d,d.parent=this.id,d.part=this.part,this.error=d.error),this.hls.trigger(l,d);};this.observer=new eh,this.observer.on(p.FRAG_DECRYPTED,a),this.observer.on(p.ERROR,a);let o=Hm(n.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){let l=this.hls.logger;if(n.workerPath||aS()){try{n.workerPath?(l.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=lS(n.workerPath)):(l.log(`injecting Web Worker for "${t}"`),this.workerContext=oS());let{worker:c}=this.workerContext;c.addEventListener("message",this.onWorkerMessage),c.addEventListener("error",this.onWorkerError),c.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:o,id:t,config:Ae(n)});}catch(c){l.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.terminateWorker(),this.error=null,this.transmuxer=new pl(this.observer,o,n,"",t,e.logger);}return}}this.transmuxer=new pl(this.observer,o,n,"",t,e.logger);}reset(){if(this.frag=null,this.part=null,this.workerContext){let e=this.instanceNo;this.instanceNo=Ig++;let t=this.hls.config,i=Hm(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:Ae(t)});}}terminateWorker(){if(this.workerContext){let{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),dS(this.hls.config.workerPath);}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else {let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null);}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null;}push(e,t,i,r,n,a,o,l,d,c){var u,h;d.transmuxing.start=self.performance.now();let{instanceNo:f,transmuxer:m}=this,g=a?a.start:n.start,E=n.decryptdata,v=this.frag,y=!(v&&n.cc===v.cc),S=!(v&&d.level===v.level),b=v?d.sn-v.sn:-1,_=this.part?d.part-this.part.index:-1,D=b===0&&d.id>1&&d.id===v?.stats.chunkCount,I=!S&&(b===1||b===0&&(_===1||D&&_<=0)),k=self.performance.now();(S||b||n.stats.parsing.start===0)&&(n.stats.parsing.start=k),a&&(_||!I)&&(a.stats.parsing.start=k);let R=!(v&&((u=n.initSegment)==null?void 0:u.url)===((h=v.initSegment)==null?void 0:h.url)),L=new au(y,I,l,S,g,R);if(!I||y||R){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${n.type} sn: ${d.sn}${d.part>-1?" part: "+d.part:""} ${this.id===W.MAIN?"level":"track"}: ${d.level} id: ${d.id}
|
|
1496
|
-
discontinuity: ${
|
|
1471
|
+
${t.m3u8}`)}function mp(s,e,t=true){let i=e.startSN+e.skippedSegments-s.startSN,r=s.fragments,n=i>=0,a=0;if(n&&i<r.length)a=r[i].start;else if(n&&e.startSN===s.endSN+1)a=s.fragmentEnd;else if(n&&t)a=s.fragmentStart+i*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)a=s.fragmentStart;else return;Vc(e,a);}function Vc(s,e){if(e){let t=s.fragments;for(let i=s.skippedSegments;i<t.length;i++)t[i].addStart(e);s.fragmentHint&&s.fragmentHint.addStart(e);}}function gp(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 pp(s,e,t){if(!s)return null;let i=s.fragments[e-s.startSN];return i||(i=s.fragmentHint,i&&i.sn===e)?i:e<s.startSN&&t&&t.sn===e?t:null}function ug(s,e,t){return s?Ep(s.partList,e,t):null}function Ep(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 vp(s){s.forEach((e,t)=>{var i;(i=e.details)==null||i.fragments.forEach(r=>{r.level=t,r.initSegment&&(r.initSegment.level=t);});});}function qy(s,e){return s!==e&&e?hg(s)!==hg(e):false}function hg(s){return s.replace(/\?[^?]*$/,"")}function bn(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 jy(s,e){return !!(s&&e.startCC<s.endCC&&e.endCC>s.startCC)}function fg(s,e){let t=s.start+e;s.startPTS=t,s.setStart(t),s.endPTS=t+s.duration;}function Tp(s,e){let t=e.fragments;for(let i=0,r=t.length;i<r;i++)fg(t[i],s);e.fragmentHint&&fg(e.fragmentHint,s),e.alignedSliding=true;}function zy(s,e){s&&(yp(e,s),e.alignedSliding||dl(e,s),!e.alignedSliding&&!e.skippedSegments&&mp(s,e,false));}function yp(s,e){if(!jy(e,s))return;let t=Math.min(e.endCC,s.endCC),i=bn(e.fragments,t),r=bn(s.fragments,t);if(!i||!r)return;ye.log(`Aligning playlist at start of dicontinuity sequence ${t}`);let n=i.start-r.start;Tp(n,s);}function dl(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=bn(i,a),n=bn(t,a)),(!r||!n)&&(r=i[Math.floor(i.length/2)],n=bn(t,r.cc)||t[Math.floor(t.length/2)]);let o=r.programDateTime,d=n.programDateTime;if(!o||!d)return;let l=(d-o)/1e3-(n.start-r.start);Tp(l,s);}function at(s,e,t){ut(s,e,t),s.addEventListener(e,t);}function ut(s,e,t){s.removeEventListener(e,t);}var Qy={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}},M={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"},Dn=class extends nl{constructor(e,t,i,r,n){super(r,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=M.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=false,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=false,this.decrypter=void 0,this.initPTS=[],this.buffering=true,this.loadingParts=false,this.loopSn=void 0,this.onMediaSeeking=()=>{let{config:a,fragCurrent:o,media:d,mediaBuffer:l,state:c}=this,u=d?d.currentTime:0,h=ne.bufferInfo(l||d,u,a.maxBufferHole),f=!h.len;if(this.log(`Media seeking to ${H(u)?u.toFixed(3):u}, state: ${c}, ${f?"out of":"in"} buffer`),this.state===M.ENDED)this.resetLoadingState();else if(o){let m=a.maxFragLookUpTolerance,g=o.start-m,E=o.start+o.duration+m;if(f||E<h.start||g>h.end){let v=u>E;(u<g||v)&&(v&&o.loader&&(this.log(`Cancelling fragment load for seek (sn: ${o.sn})`),o.abortRequests(),this.resetLoadingState()),this.fragPrevious=null);}}if(d){this.fragmentTracker.removeFragmentsInRange(u,1/0,this.playlistType,true);let m=this.lastCurrentTime;if(u>m&&(this.lastCurrentTime=u),!this.loadingParts){let g=Math.max(h.end,u),E=this.shouldLoadParts(this.getLevelDetails(),g);E&&(this.log(`LL-Part loading ON after seeking to ${u.toFixed(2)} with buffer @${g.toFixed(2)}`),this.loadingParts=E);}}this.hls.hasEnoughToStart||(this.log(`Setting ${f?"startPosition":"nextLoadPosition"} to ${u} for seek without enough to start`),this.nextLoadPosition=u,f&&(this.startPosition=u)),f&&this.state===M.IDLE&&this.tickImmediate();},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0;},this.playlistType=n,this.hls=e,this.fragmentLoader=new $c(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Rn(e.config);}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_LOADED,this.onManifestLoaded,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_LOADED,this.onManifestLoaded,this),e.off(p.ERROR,this.onError,this);}doTick(){this.onTickEnd();}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===M.STOPPED)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=M.STOPPED;}get startPositionValue(){let{nextLoadPosition:e,startPosition:t}=this;return t===-1&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=false;}resumeBuffering(){this.buffering=true;}get inFlightFrag(){return {frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return false;let i=e.end||0,r=this.config.timelineOffset||0;if(i<=r)return false;let n=e.buffered;this.config.maxBufferHole&&n&&n.length>1&&(e=ne.bufferedInfo(n,e.start,0));let a=e.nextStart;if(a&&a>r&&a<t.edge||this.media.currentTime<e.start)return false;let d=t.partList;if(d!=null&&d.length){let c=d[d.length-1];return ne.isBuffered(this.media,c.start+c.duration/2)}let l=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(l)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null)return this.levelLastLoaded.details}get timelineOffset(){let e=this.config.timelineOffset;if(e){var t;return ((t=this.getLevelDetails())==null?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){let i=this.media=this.mediaBuffer=t.media;at(i,"seeking",this.onMediaSeeking),at(i,"ended",this.onMediaEnded);let r=this.config;this.levels&&r.autoStartLoad&&this.state===M.STOPPED&&this.startLoad(r.startPosition);}onMediaDetaching(e,t){let i=!!t.transferMedia,r=this.media;if(r!==null){if(r.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),ut(r,"seeking",this.onMediaSeeking),ut(r,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=false,this.fragmentTracker.removeAllFragments(),this.stopLoad();}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=false;}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset;}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null;}onHandlerDestroyed(){this.state=M.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed();}loadFragment(e,t,i){this.startFragRequested=true,this._loadFragForPlayback(e,t,i);}_loadFragForPlayback(e,t,i){let r=n=>{let a=n.frag;if(this.fragContextChanged(a)){this.warn(`${a.type} sn: ${a.sn}${n.part?" part: "+n.part.index:""} of ${this.fragInfo(a,false,n.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(a);return}a.stats.chunkCount++,this._handleFragmentLoadProgress(n);};this._doFragLoad(e,t,i,r).then(n=>{if(!n)return;let a=this.state,o=n.frag;if(this.fragContextChanged(o)){(a===M.FRAG_LOADING||!this.fragCurrent&&a===M.PARSING)&&(this.fragmentTracker.removeFragment(o),this.state=M.IDLE);return}"payload"in n&&(this.log(`Loaded ${o.type} sn: ${o.sn} of ${this.playlistLabel()} ${o.level}`),this.hls.trigger(p.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n);}).catch(n=>{this.state===M.STOPPED||this.state===M.ERROR||(this.warn(`Frag error: ${n?.message||n}`),this.resetFragmentLoading(e));});}clearTrackerIfNeeded(e){var t;let{fragmentTracker:i}=this;if(i.getState(e)===We.APPENDING){let n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),d=this.backtrackFragment;((d?e.sn-d.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&i.removeFragment(e);}else ((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===We.PARTIAL&&i.removeFragment(e));}checkLiveUpdate(e){if(e.updated&&!e.live){let t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type});}e.fragments[0]||(e.deltaUpdateFailed=true);}waitForLive(e){let t=e.details;return t?.live&&t.type!=="EVENT"&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,i=null){if(!(e-t))return;let r={startOffset:e,endOffset:t,type:i};this.hls.trigger(p.BUFFER_FLUSHING,r);}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{let r=i?.frag;if(!r||this.fragContextChanged(r)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{let{hls:r}=this,{frag:n,payload:a}=i,o=n.decryptdata;if(a&&a.byteLength>0&&o!=null&&o.key&&o.iv&&cr(o.method)){let d=self.performance.now();return this.decrypter.decrypt(new Uint8Array(a),o.key.buffer,o.iv.buffer,Qu(o.method)).catch(l=>{throw r.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.FRAG_DECRYPT_ERROR,fatal:false,error:l,reason:l.message,frag:n}),l}).then(l=>{let c=self.performance.now();return r.trigger(p.FRAG_DECRYPTED,{frag:n,payload:l,stats:{tstart:d,tdecrypt:c}}),i.payload=l,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)}).catch(i=>{this.state===M.STOPPED||this.state===M.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!==M.STOPPED&&(this.state=M.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();}unhandledEncryptionError(e,t){var i,r;let n=e.tracks;if(n&&!t.encrypted&&((i=n.audio)!=null&&i.encrypted||(r=n.video)!=null&&r.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){let a=this.media,o=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${a?"attached mediaKeys: "+a.mediaKeys:"detached"})`);return this.warn(o.message),!a||a.mediaKeys?false:(this.hls.trigger(p.ERROR,{type:Q.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_KEYS,fatal:false,error:o,frag:t}),this.resetTransmuxer(),true)}return false}fragContextChanged(e){let{fragCurrent:t}=this;return !e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){let i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,false,t)} > buffer:${i?Qy.toString(ne.getBuffered(i)):"(detached)"})`),Fe(e)){var r;if(e.type!==Y.SUBTITLE){let a=e.elementaryStreams;if(!Object.keys(a).some(o=>!!a[o])){this.state=M.IDLE;return}}let n=(r=this.levels)==null?void 0:r[e.level];n!=null&&n.fragmentError&&(this.log(`Resetting level fragment error count of ${n.fragmentError} on frag buffered`),n.fragmentError=0);}this.state=M.IDLE;}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:i,part:r,partsLoaded:n}=e,a=!n||n.length===0||n.some(d=>!d),o=new kn(i.level,i.sn,i.stats.chunkCount+1,0,r?r.index:-1,!a);t.flush(o);}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,r){var n;this.fragCurrent=e;let a=t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)){if(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=M.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(h=>{if(!this.fragContextChanged(h.frag))return this.hls.trigger(p.KEY_LOADED,h),this.state===M.KEY_LOADING&&(this.state=M.IDLE),h}),this.hls.trigger(p.KEY_LOADING,{frag:e}),this.fragCurrent===null)return this.log("context changed in KEY_LOADING"),Promise.resolve(null)}else e.encrypted||(o=this.keyLoader.loadClear(e,a.encryptedFragments,this.startFragRequested),o&&this.log("[eme] blocking frag load until media-keys acquired"));let d=this.fragPrevious;if(Fe(e)&&(!d||e.sn!==d.sn)){let h=this.shouldLoadParts(t.details,e.end);h!==this.loadingParts&&(this.log(`LL-Part loading ${h?"ON":"OFF"} loading sn ${d?.sn}->${e.sn}`),this.loadingParts=h);}if(i=Math.max(e.start,i||0),this.loadingParts&&Fe(e)){let h=a.partList;if(h&&r){i>a.fragmentEnd&&a.fragmentHint&&(e=a.fragmentHint);let f=this.getNextPart(h,e,i);if(f>-1){let m=h[f];e=this.fragCurrent=m.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${m.index} (${f}/${h.length-1}) of ${this.fragInfo(e,false,m)}) cc: ${e.cc} [${a.startSN}-${a.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=m.start+m.duration,this.state=M.FRAG_LOADING;let g;return o?g=o.then(E=>!E||this.fragContextChanged(E.frag)?null:this.doFragPartsLoad(e,m,t,r)).catch(E=>this.handleFragLoadError(E)):g=this.doFragPartsLoad(e,m,t,r).catch(E=>this.handleFragLoadError(E)),this.hls.trigger(p.FRAG_LOADING,{frag:e,part:m,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):g}else if(!e.url||this.loadedEndOfParts(h,i))return Promise.resolve(null)}}if(Fe(e)&&this.loadingParts){var l;this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${(l=a.partList)==null?void 0:l.filter(h=>h.loaded).map(h=>`[${h.start}-${h.end}]`)}`),this.loadingParts=false;}else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,false)}) cc: ${e.cc} ${"["+a.startSN+"-"+a.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),H(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=M.FRAG_LOADING;let c=this.config.progressive&&e.type!==Y.SUBTITLE,u;return c&&o?u=o.then(h=>!h||this.fragContextChanged(h.frag)?null:this.fragmentLoader.load(e,r)).catch(h=>this.handleFragLoadError(h)):u=Promise.all([this.fragmentLoader.load(e,c?r:void 0),o]).then(([h])=>(!c&&r&&r(h),h)).catch(h=>this.handleFragLoadError(h)),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")):u}doFragPartsLoad(e,t,i,r){return new Promise((n,a)=>{var o;let d=[],l=(o=i.details)==null?void 0:o.partList,c=u=>{this.fragmentLoader.loadPart(e,u,r).then(h=>{d[u.index]=h;let f=h.part;this.hls.trigger(p.FRAG_LOADED,h);let m=ug(i.details,e.sn,u.index+1)||Ep(l,e.sn,u.index+1);if(m)c(m);else return n({frag:e,part:f,partsLoaded:d})}).catch(a);};c(t);})}handleFragLoadError(e){if("data"in e){let t=e.data;t.frag&&t.details===x.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===Q.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(p.ERROR,t);}else this.hls.trigger(p.ERROR,{type:Q.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!==M.PARSING){!this.fragCurrent&&this.state!==M.STOPPED&&this.state!==M.ERROR&&(this.state=M.IDLE);return}let{frag:i,part:r,level:n}=t,a=self.performance.now();i.stats.parsing.end=a,r&&(r.stats.parsing.end=a);let o=this.getLevelDetails(),l=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);l!==this.loadingParts&&(this.log(`LL-Part loading ${l?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=l),this.updateLevelTiming(i,r,n,e.partial);}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var i;let n=e.partList[0];if(n.fragment.type===Y.SUBTITLE)return false;let a=n.end+(((i=e.fragmentHint)==null?void 0:i.duration)||0);if(t>=a){var r;if((this.hls.hasEnoughToStart?((r=this.media)==null?void 0:r.currentTime)||this.lastCurrentTime:this.getLoadPosition())>n.start-n.fragment.duration)return true}}}return false}getCurrentContext(e){let{levels:t,fragCurrent:i}=this,{level:r,sn:n,part:a}=e;if(!(t!=null&&t[r]))return this.warn(`Levels object was unset while buffering fragment ${n} of ${this.playlistLabel()} ${r}. The current chunk will not be buffered.`),null;let o=t[r],d=o.details,l=a>-1?ug(d,n,a):null,c=l?l.fragment:pp(d,n,i);return c?(i&&i!==c&&(c.stats=i.stats),{frag:c,part:l,level:o}):null}bufferFragmentData(e,t,i,r,n){if(this.state!==M.PARSING)return;let{data1:a,data2:o}=e,d=a;if(o&&(d=Dt(a,o)),!d.length)return;let l=this.initPTS[t.cc],c=l?-l.baseTime/l.timescale:void 0,u={type:e.type,frag:t,part:i,chunkMeta:r,offset:c,parent:t.type,data:d};if(this.hls.trigger(p.BUFFER_APPENDING,u),e.dropped&&e.independent&&!i){if(n)return;this.flushBufferGap(t);}}flushBufferGap(e){let t=this.media;if(!t)return;if(!ne.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let i=t.currentTime,r=ne.bufferInfo(t,i,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,r.end-a),i+a);e.start-o>a&&this.flushMainBuffer(o,e.start);}getFwdBufferInfo(e,t){var i;let r=this.getLoadPosition();if(!H(r))return null;let a=this.lastCurrentTime>r||(i=this.media)!=null&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,r,t,a)}getFwdBufferInfoAtPos(e,t,i,r){let n=ne.bufferInfo(e,t,r);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&(n.nextStart<=a.end||a.gap)){let o=Math.max(Math.min(n.nextStart,a.end)-t,r);return ne.bufferInfo(e,t,o)}}return n}getMaxBufferLength(e){let{config:t}=this,i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){let i=this.config,r=Math.max(Math.min(e-t,i.maxBufferLength),t),n=Math.max(e-t*3,i.maxMaxBufferLength/2,r);return n>=r?(i.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),true):false}getAppendedFrag(e,t=Y.MAIN){let i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;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=n.lowLatencyMode&&!!t.partList,d=null;if(t.live){let u=n.initialLiveManifestSize;if(r<u)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${u})`),null;if(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a){var l;o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=true),d=this.getInitialLiveFragment(t);let h=this.hls.startPosition,f=this.hls.liveSyncPosition,m=d?(h!==-1&&h>=a?h:f)||d.start:e;this.log(`Setting startPosition to ${m} to match start frag at live edge. mainStart: ${h} liveSyncPosition: ${f} frag.start: ${(l=d)==null?void 0:l.start}`),this.startPosition=this.nextLoadPosition=m;}}else e<=a&&(d=i[0]);if(!d){let u=this.loadingParts?t.partEnd:t.fragmentEnd;d=this.getFragmentAtPosition(e,u,t);}let c=this.filterReplacedPrimary(d,t);if(!c&&d){let u=d.sn-t.startSN;c=this.filterReplacedPrimary(i[u+1]||null,t);}return this.mapToInitFragWhenRequired(c)}isLoopLoading(e,t){let i=this.fragmentTracker.getState(e);return (i===We.OK||i===We.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,r,n){let a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t),a&&!a.gap&&i.nextStart)){let o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,r,0);if(o!==null&&i.len+o.len>=n){let d=a.sn;return this.loopSn!==d&&(this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${d}`),this.loopSn=d),null}}return this.loopSn=void 0,a}get primaryPrefetch(){if(mg(this.config)){var e;if((e=this.hls.interstitialsManager)==null||(e=e.playingItem)==null?void 0:e.event)return true}return false}filterReplacedPrimary(e,t){if(!e)return e;if(mg(this.config)&&e.type!==Y.SUBTITLE){let i=this.hls.interstitialsManager,r=i?.bufferingItem;if(r){let a=r.event;if(a){if(a.appendInPlace||Math.abs(e.start-r.start)>1||r.start===0)return null}else if(e.end<=r.start&&t?.live===false||e.start>r.end&&r.nextEvent&&(r.nextEvent.appendInPlace||e.start-r.end>1))return null}let n=i?.playerQueue;if(n)for(let a=n.length;a--;){let o=n[a].interstitial;if(o.appendInPlace&&e.start>=o.startTime&&e.end<=o.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!e.initSegment.data&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,i){let r=-1,n=false,a=true;for(let o=0,d=e.length;o<d;o++){let l=e[o];if(a=a&&!l.independent,r>-1&&i<l.start)break;let c=l.loaded;c?r=-1:(n||(l.independent||a)&&l.fragment===t)&&(l.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${l.start}`),r=o),n=c;}return r}loadedEndOfParts(e,t){let i;for(let r=e.length;r--;){if(i=e[r],!i.loaded)return false;if(t>i.start)return true}return false}getInitialLiveFragment(e){let t=e.fragments,i=this.fragPrevious,r=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),r=Ty(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=rp(e,i.cc,i.end),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`));}}else {let n=this.hls.liveSyncPosition;n!==null&&(r=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e));}return r}getFragmentAtPosition(e,t,i){let{config:r}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=i,{fragmentHint:d}=i,{maxFragLookUpTolerance:l}=r,c=i.partList,u=!!(this.loadingParts&&c!=null&&c.length&&d);u&&!this.bitrateTest&&c[c.length-1].fragment.sn===d.sn&&(a=a.concat(d),o=d.sn);let h;if(e<t){var f;let g=e<this.lastCurrentTime||e>t-l||(f=this.media)!=null&&f.paused||!this.startFragRequested?0:l;h=ms(n,a,e,g);}else h=a[a.length-1];if(h){let m=h.sn-i.startSN,g=this.fragmentTracker.getState(h);if((g===We.OK||g===We.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!u||c[0].fragment.sn>h.sn||!i.live)&&h.level===n.level){let v=a[m+1];h.sn<o&&this.fragmentTracker.getState(v)!==We.OK?h=v:h=null;}}return h}alignPlaylists(e,t,i){let r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;let n=e.fragmentStart,a=!t,o=e.alignedSliding&&H(n);if(a||!o&&!n){zy(i,e);let d=e.fragmentStart;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${r}`),d}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;i<t&&(i=-1);let r=this.timelineOffset;if(i===-1){let n=this.startTimeOffset!==null,a=n?this.startTimeOffset:e.startTimeOffset;a!==null&&H(a)?(i=t+a,a<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${a} found in ${n?"multivariant":"media"} playlist`),this.startPosition=i):e.live?(i=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${i}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=i=0),this.lastCurrentTime=i+r;}this.nextLoadPosition=i+r;}getLoadPosition(){var e;let{media:t}=this,i=0;return (e=this.hls)!=null&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&Fe(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e));}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==M.FRAG_LOADING_WAITING_RETRY)&&(this.state=M.IDLE);}onFragmentOrKeyLoadError(e,t){var i;if(t.chunkMeta&&!t.frag){let v=this.getCurrentContext(t.chunkMeta);v&&(t.frag=v.frag);}let r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var n;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(n=this.fragCurrent)==null?void 0:n.url}`);return}let a=t.details===x.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(r,true);let o=t.errorAction;if(!o){this.state=M.ERROR;return}let{action:d,flags:l,retryCount:c=0,retryConfig:u}=o,h=!!u,f=h&&d===Qe.RetryRequest,m=h&&!o.resolved&&l===yt.MoveAllAlternatesMatchingHost,g=(i=this.hls.latestLevelDetails)==null?void 0:i.live;if(!f&&m&&Fe(r)&&!r.endList&&g&&!ap(t))this.resetFragmentErrors(e),this.treatAsGap(r),o.resolved=true;else if((f||m)&&c<u.maxNumRetry){var E;let v=wc((E=t.response)==null?void 0:E.code),T=zu(u,c);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+T,this.state=M.FRAG_LOADING_WAITING_RETRY,o.resolved=true,v){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${c+1}/${u.maxNumRetry} in ${T}ms`);}else if(u)if(this.resetFragmentErrors(e),c<u.maxNumRetry)!a&&d!==Qe.RemoveAlternatePermanently&&(o.resolved=true);else {this.warn(`${t.details} reached or exceeded max retry (${c})`);return}else d===Qe.SendAlternateToPenaltyBox?this.state=M.WAITING_LEVEL:this.state=M.ERROR;this.tickImmediate();}checkRetryDate(){let e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!wc(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=M.IDLE);}reduceLengthAndFlushBuffer(e){if(this.state===M.PARSING||this.state===M.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 (${this.getLoadPosition()}) is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return false}resetFragmentErrors(e){e===Y.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=false),this.state!==M.STOPPED&&(this.state=M.IDLE);}afterBufferFlushed(e,t,i){if(!e)return;let r=ne.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,i),this.state===M.ENDED&&this.resetLoadingState();}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==M.STOPPED&&(this.state=M.IDLE);}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=false;let e=this.levelLastLoaded,t=e?e.details:null;t!=null&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition;}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${e.level===-1?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState();}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,false,true);}updateLevelTiming(e,t,i,r){let n=i.details;if(!n){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((d,l)=>{let c=e.elementaryStreams[l];if(c){let u=c.endPTS-c.startPTS;if(u<=0)return this.warn(`Could not parse fragment ${e.sn} ${l} duration reliably (${u})`),d||false;let h=r?0:fp(n,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS,this);return this.hls.trigger(p.LEVEL_PTS_UPDATED,{details:n,level:i,drift:h,type:l,frag:e,start:c.startPTS,end:c.endPTS}),true}return d},false)){var o;let d=((o=this.transmuxer)==null?void 0:o.error)===null;if((i.fragmentError===0||d&&(i.fragmentError<2||e.endList))&&this.treatAsGap(e,i),d){let l=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(l.message),this.hls.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:false,error:l,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer();}}this.state=M.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,false,t)})`),this.hls.trigger(p.FRAG_PARSED,{frag:e,part:t});}playlistLabel(){return this.playlistType===Y.MAIN?"level":"track"}fragInfo(e,t=true,i){var r,n;return `${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${((r=t&&!i?e.startPTS:(i||e).start)!=null?r:NaN).toFixed(3)}-${((n=t&&!i?e.endPTS:(i||e).end)!=null?n:NaN).toFixed(3)}]${i&&e.type==="main"?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=true,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,true);}resetTransmuxer(){var e;(e=this.transmuxer)==null||e.reset();}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState());}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`));}get state(){return this._state}};function mg(s){return !!s.interstitialsController&&s.enableInterstitialPlayback!==false}var cl=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=Xy(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0;}};function Xy(s,e){let t=new Uint8Array(e),i=0;for(let r=0;r<s.length;r++){let n=s[r];t.set(n,i),i+=n.length;}return t}var cc={exports:{}},gg;function Zy(){return gg||(gg=1,(function(s){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=false));function r(d,l,c){this.fn=d,this.context=l,this.once=c||false;}function n(d,l,c,u,h){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new r(c,u||d,h),m=t?t+l:l;return d._events[m]?d._events[m].fn?d._events[m]=[d._events[m],f]:d._events[m].push(f):(d._events[m]=f,d._eventsCount++),d}function a(d,l){--d._eventsCount===0?d._events=new i:delete d._events[l];}function o(){this._events=new i,this._eventsCount=0;}o.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)e.call(c,u)&&l.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},o.prototype.listeners=function(l){var c=t?t+l:l,u=this._events[c];if(!u)return [];if(u.fn)return [u.fn];for(var h=0,f=u.length,m=new Array(f);h<f;h++)m[h]=u[h].fn;return m},o.prototype.listenerCount=function(l){var c=t?t+l:l,u=this._events[c];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,c,u,h,f,m){var g=t?t+l:l;if(!this._events[g])return false;var E=this._events[g],v=arguments.length,T,S;if(E.fn){switch(E.once&&this.removeListener(l,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,u),true;case 4:return E.fn.call(E.context,c,u,h),true;case 5:return E.fn.call(E.context,c,u,h,f),true;case 6:return E.fn.call(E.context,c,u,h,f,m),true}for(S=1,T=new Array(v-1);S<v;S++)T[S-1]=arguments[S];E.fn.apply(E.context,T);}else {var b=E.length,_;for(S=0;S<b;S++)switch(E[S].once&&this.removeListener(l,E[S].fn,void 0,true),v){case 1:E[S].fn.call(E[S].context);break;case 2:E[S].fn.call(E[S].context,c);break;case 3:E[S].fn.call(E[S].context,c,u);break;case 4:E[S].fn.call(E[S].context,c,u,h);break;default:if(!T)for(_=1,T=new Array(v-1);_<v;_++)T[_-1]=arguments[_];E[S].fn.apply(E[S].context,T);}}return true},o.prototype.on=function(l,c,u){return n(this,l,c,u,false)},o.prototype.once=function(l,c,u){return n(this,l,c,u,true)},o.prototype.removeListener=function(l,c,u,h){var f=t?t+l:l;if(!this._events[f])return this;if(!c)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===c&&(!h||m.once)&&(!u||m.context===u)&&a(this,f);else {for(var g=0,E=[],v=m.length;g<v;g++)(m[g].fn!==c||h&&!m[g].once||u&&m[g].context!==u)&&E.push(m[g]);E.length?this._events[f]=E.length===1?E[0]:E:a(this,f);}return this},o.prototype.removeAllListeners=function(l){var c;return l?(c=t?t+l:l,this._events[c]&&a(this,c)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,s.exports=o;})(cc)),cc.exports}var Jy=Zy(),Zu=wT(Jy),Cn="1.6.15",gr={};function eS(){return typeof __HLS_WORKER_BUNDLE__=="function"}function tS(){let s=gr[Cn];if(s)return s.clientCount++,s;let e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e),r={worker:new self.Worker(t),objectURL:t,clientCount:1};return gr[Cn]=r,r}function iS(s){let e=gr[s];if(e)return e.clientCount++,e;let t=new self.URL(s,self.location.href).href,r={worker:new self.Worker(t),scriptURL:t,clientCount:1};return gr[s]=r,r}function sS(s){let e=gr[s||Cn];if(e&&e.clientCount--===1){let{worker:i,objectURL:r}=e;delete gr[s||Cn],r&&self.URL.revokeObjectURL(r),i.terminate();}}function Sp(s,e){return e+10<=s.length&&s[e]===51&&s[e+1]===68&&s[e+2]===73&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128}function Ju(s,e){return e+10<=s.length&&s[e]===73&&s[e+1]===68&&s[e+2]===51&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128}function _l(s,e){let t=0;return t=(s[e]&127)<<21,t|=(s[e+1]&127)<<14,t|=(s[e+2]&127)<<7,t|=s[e+3]&127,t}function Mn(s,e){let t=e,i=0;for(;Ju(s,e);){i+=10;let r=_l(s,e+6);i+=r,Sp(s,e+10)&&(i+=10),e+=i;}if(i>0)return s.subarray(t,t+i)}function rS(s,e,t,i){let r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],n=e[t+2],a=n>>2&15;if(a>12){let f=new Error(`invalid ADTS sampling index:${a}`);s.emit(p.ERROR,p.ERROR,{type:Q.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:true,error:f,reason:f.message});return}let o=(n>>6&3)+1,d=e[t+3]>>6&3|(n&1)<<2,l="mp4a.40."+o,c=r[a],u=a;(o===5||o===29)&&(u-=3);let h=[o<<3|(u&14)>>1,(u&1)<<7|d<<3];return ye.log(`manifest codec:${i}, parsed codec:${l}, channels:${d}, rate:${c} (ADTS object type:${o} sampling index:${a})`),{config:h,samplerate:c,channelCount:d,codec:l,parsedCodec:l,manifestCodec:i}}function bp(s,e){return s[e]===255&&(s[e+1]&246)===240}function Ap(s,e){return s[e+1]&1?7:9}function eh(s,e){return (s[e+3]&3)<<11|s[e+4]<<3|(s[e+5]&224)>>>5}function nS(s,e){return e+5<s.length}function ul(s,e){return e+1<s.length&&bp(s,e)}function aS(s,e){return nS(s,e)&&bp(s,e)&&eh(s,e)<=s.length-e}function oS(s,e){if(ul(s,e)){let t=Ap(s,e);if(e+t>=s.length)return false;let i=eh(s,e);if(i<=t)return false;let r=e+i;return r===s.length||ul(s,r)}return false}function _p(s,e,t,i,r){if(!s.samplerate){let n=rS(e,t,i,r);if(!n)return;Se(s,n);}}function Ip(s){return 1024*9e4/s}function lS(s,e){let t=Ap(s,e);if(e+t<=s.length){let i=eh(s,e)-t;if(i>0)return {headerLength:t,frameLength:i}}}function Lp(s,e,t,i,r){let n=Ip(s.samplerate),a=i+r*n,o=lS(e,t),d;if(o){let{frameLength:u,headerLength:h}=o,f=h+u,m=Math.max(0,t+f-e.length);m?(d=new Uint8Array(f-h),d.set(e.subarray(t+h,e.length),0)):d=e.subarray(t+h,t+f);let g={unit:d,pts:a};return m||s.samples.push(g),{sample:g,length:f,missing:m}}let l=e.length-t;return d=new Uint8Array(l),d.set(e.subarray(t,e.length),0),{sample:{unit:d,pts:a},length:l,missing:-1}}function dS(s,e){return Ju(s,e)&&_l(s,e+6)+10<=s.length-e}function cS(s){return s instanceof ArrayBuffer?s:s.byteOffset==0&&s.byteLength==s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer}function uc(s,e=0,t=1/0){return uS(s,e,t,Uint8Array)}function uS(s,e,t,i){let r=hS(s),n=1;"BYTES_PER_ELEMENT"in i&&(n=i.BYTES_PER_ELEMENT);let a=fS(s)?s.byteOffset:0,o=(a+s.byteLength)/n,d=(a+e)/n,l=Math.floor(Math.max(0,Math.min(d,o))),c=Math.floor(Math.min(l+Math.max(t,0),o));return new i(r,l,c-l)}function hS(s){return s instanceof ArrayBuffer?s:s.buffer}function fS(s){return s&&s.buffer instanceof ArrayBuffer&&s.byteLength!==void 0&&s.byteOffset!==void 0}function mS(s){let e={key:s.type,description:"",data:"",mimeType:null,pictureType:null},t=3;if(s.size<2)return;if(s.data[0]!==t){console.log("Ignore frame with unrecognized character encoding");return}let i=s.data.subarray(1).indexOf(0);if(i===-1)return;let r=At(uc(s.data,1,i)),n=s.data[2+i],a=s.data.subarray(3+i).indexOf(0);if(a===-1)return;let o=At(uc(s.data,3+i,a)),d;return r==="-->"?d=At(uc(s.data,4+i+a)):d=cS(s.data.subarray(4+i+a)),e.mimeType=r,e.pictureType=n,e.description=o,e.data=d,e}function gS(s){if(s.size<2)return;let e=At(s.data,true),t=new Uint8Array(s.data.subarray(e.length+1));return {key:s.type,info:e,data:t.buffer}}function pS(s){if(s.size<2)return;if(s.type==="TXXX"){let t=1,i=At(s.data.subarray(t),true);t+=i.length+1;let r=At(s.data.subarray(t));return {key:s.type,info:i,data:r}}let e=At(s.data.subarray(1));return {key:s.type,info:"",data:e}}function ES(s){if(s.type==="WXXX"){if(s.size<2)return;let t=1,i=At(s.data.subarray(t),true);t+=i.length+1;let r=At(s.data.subarray(t));return {key:s.type,info:i,data:r}}let e=At(s.data);return {key:s.type,info:"",data:e}}function vS(s){return s.type==="PRIV"?gS(s):s.type[0]==="W"?ES(s):s.type==="APIC"?mS(s):pS(s)}function TS(s){let e=String.fromCharCode(s[0],s[1],s[2],s[3]),t=_l(s,4),i=10;return {type:e,size:t,data:s.subarray(i,i+t)}}var Po=10,yS=10;function xp(s){let e=0,t=[];for(;Ju(s,e);){let i=_l(s,e+6);s[e+5]>>6&1&&(e+=Po),e+=Po;let r=e+i;for(;e+yS<r;){let n=TS(s.subarray(e)),a=vS(n);a&&t.push(a),e+=n.size+Po;}Sp(s,e)&&(e+=Po);}return t}function Rp(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"}function SS(s){if(s.data.byteLength===8){let e=new Uint8Array(s.data),t=e[3]&1,i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}}function th(s){let e=xp(s);for(let t=0;t<e.length;t++){let i=e[t];if(Rp(i))return SS(i)}}var bt=(function(s){return s.audioId3="org.id3",s.dateRange="com.apple.quicktime.HLS",s.emsg="https://aomedia.org/emsg/ID3",s.misbklv="urn:misb:KLV:bin:1910.1",s})({});function hi(s="",e=9e4){return {type:s,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var wn=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=Dt(this.cachedData,e),this.cachedData=null);let i=Mn(e,0),r=i?i.length:0,n,a=this._audioTrack,o=this._id3Track,d=i?th(i):void 0,l=e.length;for((this.basePTS===null||this.frameIndex===0&&H(d))&&(this.basePTS=bS(d,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:bt.audioId3,duration:Number.POSITIVE_INFINITY});r<l;){if(this.canParse(e,r)){let c=this.appendFrame(a,e,r);c?(this.frameIndex++,this.lastPTS=c.sample.pts,r+=c.length,n=r):r=l;}else dS(e,r)?(i=Mn(e,r),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:bt.audioId3,duration:Number.POSITIVE_INFINITY}),r+=i.length,n=r):r++;if(r===l&&n!==l){let c=e.slice(n);this.cachedData?this.cachedData=Dt(this.cachedData,c):this.cachedData=c;}}return {audioTrack:a,videoTrack:hi(),id3Track:o,textTrack:hi()}}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:hi(),id3Track:this._id3Track,textTrack:hi()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0;}},bS=(s,e,t)=>{if(H(s))return s*90;let i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i},Oo=null,AS=[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],_S=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],IS=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],LS=[0,1,1,4];function kp(s,e,t,i,r){if(t+24>e.length)return;let n=Dp(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=i+r*a,d={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return s.config=[],s.channelCount=n.channelCount,s.samplerate=n.sampleRate,s.samples.push(d),{sample:d,length:n.frameLength,missing:0}}}function Dp(s,e){let t=s[e+1]>>3&3,i=s[e+1]>>1&3,r=s[e+2]>>4&15,n=s[e+2]>>2&3;if(t!==1&&r!==0&&r!==15&&n!==3){let a=s[e+2]>>1&1,o=s[e+3]>>6,d=t===3?3-i:i===3?3:4,l=AS[d*14+r-1]*1e3,u=_S[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=IS[t][i],m=LS[i],g=f*8*m,E=Math.floor(f*l/u+a)*m;if(Oo===null){let S=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Oo=S?parseInt(S[1]):0;}return Oo&&Oo<=87&&i===2&&l>=224e3&&o===0&&(s[e+3]=s[e+3]|128),{sampleRate:u,channelCount:h,frameLength:E,samplesPerFrame:g}}}function ih(s,e){return s[e]===255&&(s[e+1]&224)===224&&(s[e+1]&6)!==0}function Cp(s,e){return e+1<s.length&&ih(s,e)}function xS(s,e){return ih(s,e)&&4<=s.length-e}function Mp(s,e){if(e+1<s.length&&ih(s,e)){let i=Dp(s,e),r=4;i!=null&&i.frameLength&&(r=i.frameLength);let n=e+r;return n===s.length||Cp(s,n)}return false}var Wc=class extends wn{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t;}resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0};}static probe(e,t){if(!e)return false;let i=Mn(e,0),r=i?.length||0;if(Mp(e,r))return false;for(let n=e.length;r<n;r++)if(oS(e,r))return t.log("ADTS sync word found !"),true;return false}canParse(e,t){return aS(e,t)}appendFrame(e,t,i){_p(e,this.observer,t,i,e.manifestCodec);let r=Lp(e,t,i,this.basePTS,this.frameIndex);if(r&&r.missing===0)return r}},wp=(s,e)=>{let t=0,i=5;e+=i;let r=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=s[e];let o=Math.min(i,8),d=8-o;n[0]=4278190080>>>24+d<<d,r[0]=(a[0]&n[0])>>d,t=t?t<<o|r[0]:r[0],e+=1,i-=o;}return t},Yc=class extends wn{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=Pp(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=Mn(e,0);if(!t)return false;let i=t.length;return e[i]===11&&e[i+1]===119&&th(t)!==void 0&&wp(e,i)<16}};function Pp(s,e,t,i,r){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return -1;let n=e[t+4]>>6;if(n>=3)return -1;let o=[48e3,44100,32e3][n],d=e[t+4]&63,c=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][d*3+n]*2;if(t+c>e.length)return -1;let u=e[t+6]>>5,h=0;u===2?h+=2:(u&1&&u!==1&&(h+=2),u&4&&(h+=2));let f=(e[t+6]<<8|e[t+7])>>12-h&1,g=[2,1,2,3,3,4,4,5][u]+f,E=e[t+5]>>3,v=e[t+5]&7,T=new Uint8Array([n<<6|E<<1|v>>2,(v&3)<<6|u<<3|f<<2|d>>4,d<<4&224]),S=1536/o*9e4,b=i+r*S,_=e.subarray(t,t+c);return s.config=T,s.channelCount=g,s.samplerate=o,s.samples.push({unit:_,pts:b}),c}var qc=class extends wn{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=Mn(e,0),i=t?.length||0;if(t&&e[i]===11&&e[i+1]===119&&th(t)!==void 0&&wp(e,i)<=16)return false;for(let r=e.length;i<r;i++)if(Mp(e,i))return ye.log("MPEG Audio sync word found !"),true;return false}canParse(e,t){return xS(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return kp(e,t,i,this.basePTS,this.frameIndex)}},RS=/\/emsg[-/]ID3/i,jc=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=hi("video",1),a=this.audioTrack=hi("audio",1),o=this.txtTrack=hi("text",1);if(this.id3Track=hi("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let d=qg(e);if(d.video){let{id:l,timescale:c,codec:u,supplemental:h}=d.video;n.id=l,n.timescale=o.timescale=c,n.codec=u,n.supplemental=h;}if(d.audio){let{id:l,timescale:c,codec:u}=d.audio;a.id=l,a.timescale=c,a.codec=u;}o.id=Vg.text,n.sampleDuration=0,n.duration=a.duration=r;}resetContiguity(){this.remainderData=null;}static probe(e){return NT(e)}demux(e,t){this.timeOffset=t;let i=e,r=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=Dt(this.remainderData,e));let o=VT(i);this.remainderData=o.remainder,r.samples=o.valid||new Uint8Array;}else r.samples=i;let a=this.extractID3Track(r,t);return n.samples=Pm(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=Pm(e,t),{videoTrack:t,audioTrack:hi(),id3Track:r,textTrack:hi()}}extractID3Track(e,t){let i=this.id3Track;if(e.samples.length){let r=de(e.samples,["emsg"]);r&&r.forEach(n=>{let a=YT(n);if(RS.test(a.schemeIdUri)){let o=pg(a,t),d=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);let l=a.payload;i.samples.push({data:l,len:l.byteLength,dts:o,pts:o,type:bt.emsg,duration:d});}else if(this.config.enableEmsgKLVMetadata&&a.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){let o=pg(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:o,pts:o,type:bt.misbklv,duration:Number.POSITIVE_INFINITY});}});}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0;}};function pg(s,e){return H(s.presentationTime)?s.presentationTime/s.timeScale:e+s.presentationTimeDelta/s.timeScale}var zc=class{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Rn(t,{removePKCS7Padding:false});}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Bi.cbc)}decryptAacSample(e,t,i){let r=e[t].unit;if(r.length<=16)return;let n=r.subarray(16,r.length-r.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{let d=new Uint8Array(o);r.set(d,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i);}).catch(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=Qg(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(d=>{n.data=this.getAvcDecryptedUnit(a,d),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,r);}).catch(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}}}},hl=class{constructor(){this.VideoSample=null;}createVideoSample(e,t,i){return {key:e,frame:false,pts:t,dts:i,units:[],length:0}}getLastNalUnit(e){var t;let i=this.VideoSample,r;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){let n=i.units;r=n[n.length-1];}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){let i=t.samples,r=i.length;if(r){let n=i[r-1];e.pts=n.pts,e.dts=n.dts;}else {t.dropped++;return}}t.samples.push(e);}}parseNALu(e,t,i){let r=t.byteLength,n=e.naluState||0,a=n,o=[],d=0,l,c,u,h=-1,f=0;for(n===-1&&(h=0,f=this.getNALuType(t,0),n=0,d=1);d<r;){if(l=t[d++],!n){n=l?0:1;continue}if(n===1){n=l?0:2;continue}if(!l)n=3;else if(l===1){if(c=d-n-1,h>=0){let m={data:t.subarray(h,c),type:f};o.push(m);}else {let m=this.getLastNalUnit(e.samples);m&&(a&&d<=4-a&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-a)),c>0&&(m.data=Dt(m.data,t.subarray(0,c)),m.state=0));}d<r?(u=this.getNALuType(t,d),h=d,f=u,n=0):n=-1;}else n=0;}if(h>=0&&n>=0){let m={data:t.subarray(h,r),type:f,state:n};o.push(m);}if(o.length===0){let m=this.getLastNalUnit(e.samples);m&&(m.data=Dt(m.data,t));}return e.naluState=n,o}},hs=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&&ye.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)}},Qc=class extends hl{parsePES(e,t,i,r){let n=this.parseNALu(e,i.data,r),a=this.VideoSample,o,d=false;i.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts)),n.forEach(l=>{var c,u;switch(l.type){case 1:{let g=false;o=true;let E=l.data;if(d&&E.length>4){let v=this.readSliceType(E);(v===2||v===4||v===7||v===9)&&(g=true);}if(g){var h;(h=a)!=null&&h.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);}a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.frame=true,a.key=g;break}case 5:o=true,(c=a)!=null&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.key=true,a.frame=true;break;case 6:{o=true,Yu(l.data,1,i.pts,t.samples);break}case 7:{var f,m;o=true,d=true;let g=l.data,E=this.readSPS(g);if(!e.sps||e.width!==E.width||e.height!==E.height||((f=e.pixelRatio)==null?void 0:f[0])!==E.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==E.pixelRatio[1]){e.width=E.width,e.height=E.height,e.pixelRatio=E.pixelRatio,e.sps=[g];let v=g.subarray(1,4),T="avc1.";for(let S=0;S<3;S++){let b=v[S].toString(16);b.length<2&&(b="0"+b),T+=b;}e.codec=T;}break}case 8:o=true,e.pps=[l.data];break;case 9:o=true,e.audFound=true,(u=a)!=null&&u.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts));break;case 12:o=true;break;default:o=false;break}a&&o&&a.units.push(l);}),r&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null);}getNALuType(e,t){return e[t]&31}readSliceType(e){let t=new hs(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,r=8,n;for(let a=0;a<e;a++)r!==0&&(n=t.readEG(),r=(i+n+256)%256),i=r===0?i:r;}readSPS(e){let t=new hs(e),i=0,r=0,n=0,a=0,o,d,l,c=t.readUByte.bind(t),u=t.readBits.bind(t),h=t.readUEG.bind(t),f=t.readBoolean.bind(t),m=t.skipBits.bind(t),g=t.skipEG.bind(t),E=t.skipUEG.bind(t),v=this.skipScalingList.bind(this);c();let T=c();if(u(5),m(3),c(),E(),T===100||T===110||T===122||T===244||T===44||T===83||T===86||T===118||T===128){let k=h();if(k===3&&m(1),E(),E(),m(1),f())for(d=k!==3?8:12,l=0;l<d;l++)f()&&(l<6?v(16,t):v(64,t));}E();let S=h();if(S===0)h();else if(S===1)for(m(1),g(),g(),o=h(),l=0;l<o;l++)g();E(),m(1);let b=h(),_=h(),D=u(1);D===0&&m(1),m(1),f()&&(i=h(),r=h(),n=h(),a=h());let I=[1,1];if(f()&&f())switch(c()){case 1:I=[1,1];break;case 2:I=[12,11];break;case 3:I=[10,11];break;case 4:I=[16,11];break;case 5:I=[40,33];break;case 6:I=[24,11];break;case 7:I=[20,11];break;case 8:I=[32,11];break;case 9:I=[80,33];break;case 10:I=[18,11];break;case 11:I=[15,11];break;case 12:I=[64,33];break;case 13:I=[160,99];break;case 14:I=[4,3];break;case 15:I=[3,2];break;case 16:I=[2,1];break;case 255:{I=[c()<<8|c(),c()<<8|c()];break}}return {width:Math.ceil((b+1)*16-i*2-r*2),height:(2-D)*(_+1)*16-(D?2:4)*(n+a),pixelRatio:I}}},Xc=class extends hl{constructor(...e){super(...e),this.initVPS=null;}parsePES(e,t,i,r){let n=this.parseNALu(e,i.data,r),a=this.VideoSample,o,d=false;i.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts)),n.forEach(l=>{var c,u;switch(l.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts)),a.frame=true,o=true;break;case 16:case 17:case 18:case 21:if(o=true,d){var h;(h=a)!=null&&h.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);}a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.key=true,a.frame=true;break;case 19:case 20:o=true,(c=a)!=null&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.key=true,a.frame=true;break;case 39:o=true,Yu(l.data,2,i.pts,t.samples);break;case 32:o=true,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=Se(e.params,this.readVPS(l.data)),this.initVPS=l.data),e.vps=[l.data];break;case 33:if(o=true,d=true,e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],l.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){let f=this.readSPS(l.data);e.width=f.width,e.height=f.height,e.pixelRatio=f.pixelRatio,e.codec=f.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(let m in f.params)e.params[m]=f.params[m];}this.pushParameterSet(e.sps,l.data,e.vps),a||(a=this.VideoSample=this.createVideoSample(true,i.pts,i.dts)),a.key=true;break;case 34:if(o=true,typeof e.params=="object"){if(!e.pps){e.pps=[];let f=this.readPPS(l.data);for(let m in f)e.params[m]=f[m];}this.pushParameterSet(e.pps,l.data,e.vps);}break;case 35:o=true,e.audFound=true,(u=a)!=null&&u.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(false,i.pts,i.dts));break;default:o=false;break}a&&o&&a.units.push(l);}),r&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null);}pushParameterSet(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t);}getNALuType(e,t){return (e[t]&126)>>>1}ebsp2rbsp(e){let t=new Uint8Array(e.byteLength),i=0;for(let r=0;r<e.byteLength;r++)r>=2&&e[r]===3&&e[r-1]===0&&e[r-2]===0||(t[i]=e[r],i++);return new Uint8Array(t.buffer,0,i)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null);}readVPS(e){let t=new hs(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);let i=t.readBits(3),r=t.readBoolean();return {numTemporalLayers:i+1,temporalIdNested:r}}readSPS(e){let t=new hs(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);let i=t.readBits(3);t.readBoolean();let r=t.readBits(2),n=t.readBoolean(),a=t.readBits(5),o=t.readUByte(),d=t.readUByte(),l=t.readUByte(),c=t.readUByte(),u=t.readUByte(),h=t.readUByte(),f=t.readUByte(),m=t.readUByte(),g=t.readUByte(),E=t.readUByte(),v=t.readUByte(),T=[],S=[];for(let fe=0;fe<i;fe++)T.push(t.readBoolean()),S.push(t.readBoolean());if(i>0)for(let fe=i;fe<8;fe++)t.readBits(2);for(let fe=0;fe<i;fe++)T[fe]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),S[fe]&&t.readUByte();t.readUEG();let b=t.readUEG();b==3&&t.skipBits(1);let _=t.readUEG(),D=t.readUEG(),I=t.readBoolean(),k=0,R=0,L=0,w=0;I&&(k+=t.readUEG(),R+=t.readUEG(),L+=t.readUEG(),w+=t.readUEG());let B=t.readUEG(),K=t.readUEG(),z=t.readUEG(),V=t.readBoolean();for(let fe=V?0:i;fe<=i;fe++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let He=0;He<4;He++)for(let rt=0;rt<(He===3?2:6);rt++)if(!t.readBoolean())t.readUEG();else {let _t=Math.min(64,1<<4+(He<<1));He>1&&t.readEG();for(let me=0;me<_t;me++)t.readEG();}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());let G=t.readUEG(),j=0;for(let fe=0;fe<G;fe++){let He=false;if(fe!==0&&(He=t.readBoolean()),He){fe===G&&t.readUEG(),t.readBoolean(),t.readUEG();let rt=0;for(let Vt=0;Vt<=j;Vt++){let _t=t.readBoolean(),me=false;_t||(me=t.readBoolean()),(_t||me)&&rt++;}j=rt;}else {let rt=t.readUEG(),Vt=t.readUEG();j=rt+Vt;for(let _t=0;_t<rt;_t++)t.readUEG(),t.readBoolean();for(let _t=0;_t<Vt;_t++)t.readUEG(),t.readBoolean();}}if(t.readBoolean()){let fe=t.readUEG();for(let He=0;He<fe;He++){for(let rt=0;rt<z+4;rt++)t.readBits(1);t.readBits(1);}}let U=0,$=1,se=1,Ee=true,re=1,ce=0;t.readBoolean(),t.readBoolean();let Ge=false;if(t.readBoolean()){if(t.readBoolean()){let mt=t.readUByte(),Un=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],Es=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];mt>0&&mt<16?($=Un[mt-1],se=Es[mt-1]):mt===255&&($=t.readBits(16),se=t.readBits(16));}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),Ge=t.readBoolean(),Ge&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(re=t.readBits(32),ce=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){let Es=t.readBoolean(),$n=t.readBoolean(),Gi=false;(Es||$n)&&(Gi=t.readBoolean(),Gi&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),Gi&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let Bn=0;Bn<=i;Bn++){Ee=t.readBoolean();let Pl=Ee||t.readBoolean(),Gn=false;Pl?t.readEG():Gn=t.readBoolean();let et=Gn?1:t.readUEG()+1;if(Es)for(let Le=0;Le<et;Le++)t.readUEG(),t.readUEG(),Gi&&(t.readUEG(),t.readUEG()),t.skipBits(1);if($n)for(let Le=0;Le<et;Le++)t.readUEG(),t.readUEG(),Gi&&(t.readUEG(),t.readUEG()),t.skipBits(1);}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),U=t.readUEG());}let st=_,ft=D;if(I){let fe=1,He=1;b===1?fe=He=2:b==2&&(fe=2),st=_-fe*R-fe*k,ft=D-He*w-He*L;}let Ct=r?["A","B","C"][r]:"",_i=o<<24|d<<16|l<<8|c,gs=0;for(let fe=0;fe<32;fe++)gs=(gs|(_i>>fe&1)<<31-fe)>>>0;let ps=gs.toString(16);return a===1&&ps==="2"&&(ps="6"),{codecString:`hvc1.${Ct}${a}.${ps}.${n?"H":"L"}${v}.B0`,params:{general_tier_flag:n,general_profile_idc:a,general_profile_space:r,general_profile_compatibility_flags:[o,d,l,c],general_constraint_indicator_flags:[u,h,f,m,g,E],general_level_idc:v,bit_depth:B+8,bit_depth_luma_minus8:B,bit_depth_chroma_minus8:K,min_spatial_segmentation_idc:U,chroma_format_idc:b,frame_rate:{fixed:Ee,fps:ce/re}},width:st,height:ft,pixelRatio:[$,se]}}readPPS(e){let t=new hs(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);let r=t.readBoolean(),n=t.readBoolean(),a=1;return n&&r?a=0:n?a=3:r&&(a=2),{parallelismType:a}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}},ze=188,Zc=class s{constructor(e,t,i,r){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=false,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.logger=r,this.videoParser=null;}static probe(e,t){let i=s.syncOffset(e);return i>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),i!==-1}static syncOffset(e){let t=e.length,i=Math.min(ze*5,t-ze)+1,r=0;for(;r<i;){let n=false,a=-1,o=0;for(let d=r;d<t;d+=ze)if(e[d]===71&&(t-d===ze||e[d+ze]===71)){if(o++,a===-1&&(a=d,a!==0&&(i=Math.min(a+ze*99,e.length-ze)+1)),n||(n=Jc(e,d)===0),n&&o>1&&(a===0&&o>2||d+ze>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:Vg[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,r){this.pmtParsed=false,this._pmtId=-1,this._videoTrack=s.createTrack("video"),this._videoTrack.duration=r,this._audioTrack=s.createTrack("audio",r),this._id3Track=s.createTrack("id3"),this._txtTrack=s.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i;}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null;}demux(e,t,i=false,r=false){i||(this.sampleAes=null);let n,a=this._videoTrack,o=this._audioTrack,d=this._id3Track,l=this._txtTrack,c=a.pid,u=a.pesData,h=o.pid,f=d.pid,m=o.pesData,g=d.pesData,E=null,v=this.pmtParsed,T=this._pmtId,S=e.length;if(this.remainderData&&(e=Dt(this.remainderData,e),S=e.length,this.remainderData=null),S<ze&&!r)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:d,textTrack:l};let b=Math.max(0,s.syncOffset(e));S-=(S-b)%ze,S<e.byteLength&&!r&&(this.remainderData=new Uint8Array(e.buffer,S,e.buffer.byteLength-S));let _=0;for(let I=b;I<S;I+=ze)if(e[I]===71){let k=!!(e[I+1]&64),R=Jc(e,I),L=(e[I+3]&48)>>4,w;if(L>1){if(w=I+5+e[I+4],w===I+ze)continue}else w=I+4;switch(R){case c:k&&(u&&(n=rr(u,this.logger))&&(this.readyVideoParser(a.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(a,l,n,false)),u={data:[],size:0}),u&&(u.data.push(e.subarray(w,I+ze)),u.size+=I+ze-w);break;case h:if(k){if(m&&(n=rr(m,this.logger)))switch(o.segmentCodec){case "aac":this.parseAACPES(o,n);break;case "mp3":this.parseMPEGPES(o,n);break;case "ac3":this.parseAC3PES(o,n);break}m={data:[],size:0};}m&&(m.data.push(e.subarray(w,I+ze)),m.size+=I+ze-w);break;case f:k&&(g&&(n=rr(g,this.logger))&&this.parseID3PES(d,n),g={data:[],size:0}),g&&(g.data.push(e.subarray(w,I+ze)),g.size+=I+ze-w);break;case 0:k&&(w+=e[w]+1),T=this._pmtId=kS(e,w);break;case T:{k&&(w+=e[w]+1);let B=DS(e,w,this.typeSupported,i,this.observer,this.logger);c=B.videoPid,c>0&&(a.pid=c,a.segmentCodec=B.segmentVideoCodec),h=B.audioPid,h>0&&(o.pid=h,o.segmentCodec=B.segmentAudioCodec),f=B.id3Pid,f>0&&(d.pid=f),E!==null&&!v&&(this.logger.warn(`MPEG-TS PMT found at ${I} after unknown PID '${E}'. Backtracking to sync byte @${b} to parse all TS packets.`),E=null,I=b-188),v=this.pmtParsed=true;break}case 17:case 8191:break;default:E=R;break}}else _++;_>0&&eu(this.observer,new Error(`Found ${_} TS packet/s that do not start with 0x47`),void 0,this.logger),a.pesData=u,o.pesData=m,d.pesData=g;let D={audioTrack:o,videoTrack:a,id3Track:d,textTrack:l};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,d=r.pesData,l;if(a&&(l=rr(a,this.logger))?(this.readyVideoParser(i.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(i,n,l,true),i.pesData=null)):i.pesData=a,o&&(l=rr(o,this.logger))){switch(t.segmentCodec){case "aac":this.parseAACPES(t,l);break;case "mp3":this.parseMPEGPES(t,l);break;case "ac3":this.parseAC3PES(t,l);break}t.pesData=null;}else o!=null&&o.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;d&&(l=rr(d,this.logger))?(this.parseID3PES(r,l),r.pesData=null):r.pesData=d;}demuxSampleAes(e,t,i){let r=this.demux(e,i,true,!this.config.progressive),n=this.sampleAes=new zc(this.observer,this.config,t);return this.decrypt(r,n)}readyVideoParser(e){this.videoParser===null&&(e==="avc"?this.videoParser=new Qc:e==="hevc"&&(this.videoParser=new Xc));}decrypt(e,t){return new Promise(i=>{let{audioTrack:r,videoTrack:n}=e;r.samples&&r.segmentCodec==="aac"?t.decryptAacSamples(r.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{i(e);}):i(e);}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{i(e);});})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0;}parseAACPES(e,t){let i=0,r=this.aacOverFlow,n=t.data;if(r){this.aacOverFlow=null;let u=r.missing,h=r.sample.unit.byteLength;if(u===-1)n=Dt(r.sample.unit,n);else {let f=h-u;r.sample.unit.set(n.subarray(0,u),f),e.samples.push(r.sample),i=r.missing;}}let a,o;for(a=i,o=n.length;a<o-1&&!ul(n,a);a++);if(a!==i){let u,h=a<o-1;if(h?u=`AAC PES did not start with ADTS header,offset:${a}`:u="No ADTS header found in AAC PES",eu(this.observer,new Error(u),h,this.logger),!h)return}_p(e,this.observer,n,a,this.audioCodec);let d;if(t.pts!==void 0)d=t.pts;else if(r){let u=Ip(e.samplerate);d=r.sample.pts+u;}else {this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let l=0,c;for(;a<o;)if(c=Lp(e,n,a,d,l),a+=c.length,c.missing){this.aacOverFlow=c;break}else for(l++;a<o-1&&!ul(n,a);a++);}parseMPEGPES(e,t){let i=t.data,r=i.length,n=0,a=0,o=t.pts;if(o===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<r;)if(Cp(i,a)){let d=kp(e,i,a,o,n);if(d)a+=d.length,n++;else break}else a++;}parseAC3PES(e,t){{let i=t.data,r=t.pts;if(r===void 0){this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");return}let n=i.length,a=0,o=0,d;for(;o<n&&(d=Pp(e,i,o,r,a++))>0;)o+=d;}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let i=Se({},t,{type:this._videoTrack?bt.emsg:bt.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i);}};function Jc(s,e){return ((s[e+1]&31)<<8)+s[e+2]}function kS(s,e){return (s[e+10]&31)<<8|s[e+11]}function DS(s,e,t,i,r,n){let a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=(s[e+1]&15)<<8|s[e+2],d=e+3+o-4,l=(s[e+10]&15)<<8|s[e+11];for(e+=12+l;e<d;){let c=Jc(s,e),u=(s[e+3]&15)<<8|s[e+4];switch(s[e]){case 207:if(!i){hc("ADTS AAC",n);break}case 15:a.audioPid===-1&&(a.audioPid=c);break;case 21:a.id3Pid===-1&&(a.id3Pid=c);break;case 219:if(!i){hc("H.264",n);break}case 27:a.videoPid===-1&&(a.videoPid=c);break;case 3:case 4:!t.mpeg&&!t.mp3?n.log("MPEG audio found, not supported in this browser"):a.audioPid===-1&&(a.audioPid=c,a.segmentAudioCodec="mp3");break;case 193:if(!i){hc("AC-3",n);break}case 129:t.ac3?a.audioPid===-1&&(a.audioPid=c,a.segmentAudioCodec="ac3"):n.log("AC-3 audio found, not supported in this browser");break;case 6:if(a.audioPid===-1&&u>0){let h=e+5,f=u;for(;f>2;){s[h]===106&&(t.ac3!==true?n.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=c,a.segmentAudioCodec="ac3"));let g=s[h+1]+2;h+=g,f-=g;}}break;case 194:case 135:return eu(r,new Error("Unsupported EC-3 in M2TS found"),void 0,n),a;case 36:a.videoPid===-1&&(a.videoPid=c,a.segmentVideoCodec="hevc",n.log("HEVC in M2TS found"));break}e+=u+5;}return a}function eu(s,e,t,i){i.warn(`parsing error: ${e.message}`),s.emit(p.ERROR,p.ERROR,{type:Q.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:false,levelRetry:t,error:e,reason:e.message});}function hc(s,e){e.log(`${s} with AES-128-CBC encryption found in unencrypted stream`);}function rr(s,e){let t=0,i,r,n,a,o,d=s.data;if(!s||s.size===0)return null;for(;d[0].length<19&&d.length>1;)d[0]=Dt(d[0],d[1]),d.splice(1,1);if(i=d[0],(i[0]<<16)+(i[1]<<8)+i[2]===1){if(r=(i[4]<<8)+i[5],r&&r>s.size-6)return null;let c=i[7];c&192&&(a=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,c&64?(o=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,a-o>60*9e4&&(e.warn(`${Math.round((a-o)/9e4)}s delta between PTS and DTS, align them`),a=o)):o=a),n=i[8];let u=n+9;if(s.size<=u)return null;s.size-=u;let h=new Uint8Array(s.size);for(let f=0,m=d.length;f<m;f++){i=d[f];let g=i.byteLength;if(u)if(u>g){u-=g;continue}else i=i.subarray(u),g-=u,u=0;h.set(i,t),t+=g;}return r&&(r-=n+3),{data:h,pts:a,dts:o,len:r}}return null}var tu=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}}},Oi=Math.pow(2,32)-1,Ye=class s{static init(){s.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in s.types)s.types.hasOwnProperty(e)&&(s.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);s.HDLR_TYPES={video:t,audio:i};let r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);s.STTS=s.STSC=s.STCO=n,s.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),s.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),s.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),s.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),d=new Uint8Array([0,0,0,1]);s.FTYP=s.box(s.types.ftyp,a,d,a,o),s.DINF=s.box(s.types.dinf,s.box(s.types.dref,r));}static box(e,...t){let i=8,r=t.length,n=r;for(;r--;)i+=t[r].byteLength;let a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=i&255,a.set(e,4),r=0,i=8;r<n;r++)a.set(t[r],i),i+=t[r].byteLength;return a}static hdlr(e){return s.box(s.types.hdlr,s.HDLR_TYPES[e])}static mdat(e){return s.box(s.types.mdat,e)}static mdhd(e,t){t*=e;let i=Math.floor(t/(Oi+1)),r=Math.floor(t%(Oi+1));return s.box(s.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))}static mdia(e){return s.box(s.types.mdia,s.mdhd(e.timescale||0,e.duration||0),s.hdlr(e.type),s.minf(e))}static mfhd(e){return s.box(s.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?s.box(s.types.minf,s.box(s.types.smhd,s.SMHD),s.DINF,s.stbl(e)):s.box(s.types.minf,s.box(s.types.vmhd,s.VMHD),s.DINF,s.stbl(e))}static moof(e,t,i){return s.box(s.types.moof,s.mfhd(e),s.traf(i,t))}static moov(e){let t=e.length,i=[];for(;t--;)i[t]=s.trak(e[t]);return s.box.apply(null,[s.types.moov,s.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(s.mvex(e)))}static mvex(e){let t=e.length,i=[];for(;t--;)i[t]=s.trex(e[t]);return s.box.apply(null,[s.types.mvex,...i])}static mvhd(e,t){t*=e;let i=Math.floor(t/(Oi+1)),r=Math.floor(t%(Oi+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,r>>24,r>>16&255,r>>8&255,r&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return s.box(s.types.mvhd,n)}static sdtp(e){let t=e.samples||[],i=new Uint8Array(4+t.length),r,n;for(r=0;r<t.length;r++)n=t[r].flags,i[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return s.box(s.types.sdtp,i)}static stbl(e){return s.box(s.types.stbl,s.stsd(e),s.box(s.types.stts,s.STTS),s.box(s.types.stsc,s.STSC),s.box(s.types.stsz,s.STSZ),s.box(s.types.stco,s.STCO))}static avc1(e){let t=[],i=[],r,n,a;for(r=0;r<e.sps.length;r++)n=e.sps[r],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(r=0;r<e.pps.length;r++)n=e.pps[r],a=n.byteLength,i.push(a>>>8&255),i.push(a&255),i=i.concat(Array.prototype.slice.call(n));let o=s.box(s.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),d=e.width,l=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return s.box(s.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,d>>8&255,d&255,l>>8&255,l&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,c&255,u>>24,u>>16&255,u>>8&255,u&255])))}static esds(e){let t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}static audioStsd(e){let t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return s.box(s.types.mp4a,s.audioStsd(e),s.box(s.types.esds,s.esds(e)))}static mp3(e){return s.box(s.types[".mp3"],s.audioStsd(e))}static ac3(e){return s.box(s.types["ac-3"],s.audioStsd(e),s.box(s.types.dac3,e.config))}static stsd(e){let{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return s.box(s.types.stsd,s.STSD,s.mp4a(e));if(t==="ac3"&&e.config)return s.box(s.types.stsd,s.STSD,s.ac3(e));if(t==="mp3"&&e.codec==="mp3")return s.box(s.types.stsd,s.STSD,s.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return s.box(s.types.stsd,s.STSD,s.avc1(e));if(t==="hevc"&&e.vps)return s.box(s.types.stsd,s.STSD,s.hvc1(e))}else throw new Error("video track missing pps or sps");throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){let t=e.id,i=(e.duration||0)*(e.timescale||0),r=e.width||0,n=e.height||0,a=Math.floor(i/(Oi+1)),o=Math.floor(i%(Oi+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/(Oi+1)),a=Math.floor(t%(Oi+1));return s.box(s.types.traf,s.box(s.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),s.box(s.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),s.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,s.box(s.types.trak,s.tkhd(e),s.mdia(e))}static trex(e){let t=e.id;return s.box(s.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let i=e.samples||[],r=i.length,n=12+16*r,a=new Uint8Array(n),o,d,l,c,u,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<r;o++)d=i[o],l=d.duration,c=d.size,u=d.flags,h=d.cts,a.set([l>>>24&255,l>>>16&255,l>>>8&255,l&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,u.degradPrio&61440,u.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return s.box(s.types.trun,a)}static initSegment(e){s.types||s.init();let t=s.moov(e);return Dt(s.FTYP,t)}static hvc1(e){let t=e.params,i=[e.vps,e.sps,e.pps],r=4,n=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),r-1|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),i.length]),a=n.length;for(let m=0;m<i.length;m+=1){a+=3;for(let g=0;g<i[m].length;g+=1)a+=2+i[m][g].length;}let o=new Uint8Array(a);o.set(n,0),a=n.length;let d=i.length-1;for(let m=0;m<i.length;m+=1){o.set(new Uint8Array([32+m|(m===d?128:0),0,i[m].length]),a),a+=3;for(let g=0;g<i[m].length;g+=1)o.set(new Uint8Array([i[m][g].length>>8,i[m][g].length&255]),a),a+=2,o.set(i[m][g],a),a+=i[m][g].length;}let l=s.box(s.types.hvcC,o),c=e.width,u=e.height,h=e.pixelRatio[0],f=e.pixelRatio[1];return s.box(s.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c>>8&255,c&255,u>>8&255,u&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,f>>24,f>>16&255,f>>8&255,f&255])))}};Ye.types=void 0;Ye.HDLR_TYPES=void 0;Ye.STTS=void 0;Ye.STSC=void 0;Ye.STCO=void 0;Ye.STSZ=void 0;Ye.VMHD=void 0;Ye.SMHD=void 0;Ye.STSD=void 0;Ye.FTYP=void 0;Ye.DINF=void 0;var Op=9e4;function sh(s,e,t=1,i=false){let r=s*e*t;return i?Math.round(r):r}function CS(s,e,t=1,i=false){return sh(s,e,1/t,i)}function Tn(s,e=false){return sh(s,1e3,1/Op,e)}function MS(s,e=1){return sh(s,Op,1/e)}function Eg(s){let{baseTime:e,timescale:t,trackId:i}=s;return `${e/t} (${e}/${t}) trackId: ${i}`}var wS=10*1e3,PS=1024,OS=1152,FS=1536,nr=null,fc=null;function vg(s,e,t,i){return {duration:e,size:t,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:s?2:1,isNonSync:s?0:1}}}var ur=class extends ht{constructor(e,t,i,r){if(super("mp4-remuxer",r),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=false,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=false,this.isVideoContiguous=false,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=false,nr===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);nr=a?parseInt(a[1]):0;}if(fc===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);fc=n?parseInt(n[1]):0;}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null;}resetTimeStamp(e){let t=this._initPTS;(!t||!e||e.trackId!==t.trackId||e.baseTime!==t.baseTime||e.timescale!==t.timescale)&&this.log(`Reset initPTS: ${t&&Eg(t)} > ${e&&Eg(e)}`),this._initPTS=this._initDTS=e;}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=false,this.isAudioContiguous=false;}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=false,this.videoTrackConfig=void 0;}getVideoStartPts(e){let t=false,i=e[0].pts,r=e.reduce((n,a)=>{let o=a.pts,d=o-n;return d<-4294967296&&(t=true,o=St(o,i),d=o-n),d>0?n:o},i);return t&&this.debug("PTS rollover detected"),r}remux(e,t,i,r,n,a,o,d){let l,c,u,h,f,m,g=n,E=n,v=e.pid>-1,T=t.pid>-1,S=t.samples.length,b=e.samples.length>0,_=o&&S>0||S>1;if((!v||b)&&(!T||_)||this.ISGenerated||o){if(this.ISGenerated){var I,k,R,L;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])||((R=t.pixelRatio)==null?void 0:R[1])!==((L=z.pixelRatio)==null?void 0:L[1]))||!z&&_||this.nextAudioTs===null&&b)&&this.resetInitSegment();}this.ISGenerated||(u=this.generateIS(e,t,n,a));let w=this.isVideoContiguous,B=-1,K;if(_&&(B=NS(t.samples),!w&&this.config.forceKeyFrameOnDiscontinuity))if(m=true,B>0){this.warn(`Dropped ${B} out of ${S} video samples due to a missing keyframe`);let z=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(B),t.dropped+=B,E+=(t.samples[0].pts-z)/t.inputTimeScale,K=E;}else B===-1&&(this.warn(`No keyframe found out of ${S} video samples`),m=false);if(this.ISGenerated){if(b&&_){let z=this.getVideoStartPts(t.samples),F=(St(e.samples[0].pts,z)-z)/t.inputTimeScale;g+=Math.max(0,F),E+=Math.max(0,-F);}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),u=this.generateIS(e,t,n,a)),c=this.remuxAudio(e,g,this.isAudioContiguous,a,T||_||d===Y.AUDIO?E:void 0),_){let z=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),u=this.generateIS(e,t,n,a)),l=this.remuxVideo(t,E,w,z);}}else _&&(l=this.remuxVideo(t,E,w,0));l&&(l.firstKeyFrame=B,l.independent=B!==-1,l.firstKeyFramePTS=K);}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(f=Fp(i,n,this._initPTS,this._initDTS)),r.samples.length&&(h=Np(r,n,this._initPTS))),{audio:c,video:l,initSegment:u,independent:m,text:h,id3:f}}computeInitPts(e,t,i,r){let n=Math.round(i*t),a=St(e,n);if(a<n+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(n-a)/t} ${r}`);a<n+t;)a+=8589934592;return a-n}generateIS(e,t,i,r){let n=e.samples,a=t.samples,o=this.typeSupported,d={},l=this._initPTS,c=!l||r,u="audio/mp4",h,f,m,g=-1;if(c&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case "mp3":o.mpeg?(u="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case "ac3":e.codec="ac-3";break}d.audio={id:"audio",container:u,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):Ye.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(g=e.id,m=e.inputTimeScale,!l||m!==l.timescale?h=f=this.computeInitPts(n[0].pts,m,i,"audio"):c=false);}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Ye.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(g=t.id,m=t.inputTimeScale,!l||m!==l.timescale){let E=this.getVideoStartPts(a),v=St(a[0].dts,E),T=this.computeInitPts(v,m,i,"video"),S=this.computeInitPts(E,m,i,"video");f=Math.min(f,T),h=Math.min(h,S);}else c=false;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio};}if(Object.keys(d).length)return this.ISGenerated=true,c?(l&&this.warn(`Timestamps at playlist time: ${r?"":"~"}${i} ${h/m} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${h/m} (${h}/${m}) trackId: ${g}`),this._initPTS={baseTime:h,timescale:m,trackId:g},this._initDTS={baseTime:f,timescale:m,trackId:g}):h=m=void 0,{tracks:d,initPTS:h,timescale:m,trackId:g}}remuxVideo(e,t,i,r){let n=e.inputTimeScale,a=e.samples,o=[],d=a.length,l=this._initPTS,c=l.baseTime*n/l.timescale,u=this.nextVideoTs,h=8,f=this.videoSampleDuration,m,g,E=Number.POSITIVE_INFINITY,v=Number.NEGATIVE_INFINITY,T=false;if(!i||u===null){let U=c+t*n,$=a[0].pts-St(a[0].dts,a[0].pts);nr&&u!==null&&Math.abs(U-$-(u+c))<15e3?i=true:u=U-$-c;}let S=u+c;for(let U=0;U<d;U++){let $=a[U];$.pts=St($.pts,S),$.dts=St($.dts,S),$.dts<a[U>0?U-1:U].dts&&(T=true);}T&&a.sort(function(U,$){let se=U.dts-$.dts,Ee=U.pts-$.pts;return se||Ee}),m=a[0].dts,g=a[a.length-1].dts;let b=g-m,_=b?Math.round(b/(d-1)):f||e.inputTimeScale/30;if(i){let U=m-S,$=U>_,se=U<-1;if(($||se)&&($?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Tn(U,true)} ms (${U}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Tn(-U,true)} ms (${U}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!se||S>=a[0].pts||nr)){m=S;let Ee=a[0].pts-U;if($)a[0].dts=m,a[0].pts=Ee;else {let re=true;for(let ce=0;ce<a.length&&!(a[ce].dts>Ee&&re);ce++){let Ge=a[ce].pts;if(a[ce].dts-=U,a[ce].pts-=U,ce<a.length-1){let Ne=a[ce+1].pts,st=a[ce].pts,ft=Ne<=st,Ct=Ne<=Ge;re=ft==Ct;}}}this.log(`Video: Initial PTS/DTS adjusted: ${Tn(Ee,true)}/${Tn(m,true)}, delta: ${Tn(U,true)} ms`);}}m=Math.max(0,m);let D=0,I=0,k=m;for(let U=0;U<d;U++){let $=a[U],se=$.units,Ee=se.length,re=0;for(let ce=0;ce<Ee;ce++)re+=se[ce].data.length;I+=re,D+=Ee,$.length=re,$.dts<k?($.dts=k,k+=_/4|0||1):k=$.dts,E=Math.min($.pts,E),v=Math.max($.pts,v);}g=a[d-1].dts;let R=I+4*D+8,L;try{L=new Uint8Array(R);}catch(U){this.observer.emit(p.ERROR,p.ERROR,{type:Q.MUX_ERROR,details:x.REMUX_ALLOC_ERROR,fatal:false,error:U,bytes:R,reason:`fail allocating video mdat ${R}`});return}let w=new DataView(L.buffer);w.setUint32(0,R),L.set(Ye.types.mdat,4);let B=false,K=Number.POSITIVE_INFINITY,z=Number.POSITIVE_INFINITY,V=Number.NEGATIVE_INFINITY,F=Number.NEGATIVE_INFINITY;for(let U=0;U<d;U++){let $=a[U],se=$.units,Ee=0;for(let Ge=0,Ne=se.length;Ge<Ne;Ge++){let st=se[Ge],ft=st.data,Ct=st.data.byteLength;w.setUint32(h,Ct),h+=4,L.set(ft,h),h+=Ct,Ee+=4+Ct;}let re;if(U<d-1)f=a[U+1].dts-$.dts,re=a[U+1].pts-$.pts;else {let Ge=this.config,Ne=U>0?$.dts-a[U-1].dts:_;if(re=U>0?$.pts-a[U-1].pts:_,Ge.stretchShortVideoTrack&&this.nextAudioTs!==null){let st=Math.floor(Ge.maxBufferHole*n),ft=(r?E+r*n:this.nextAudioTs+c)-$.pts;ft>st?(f=ft-Ne,f<0?f=Ne:B=true,this.log(`It is approximately ${ft/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=Ne;}else f=Ne;}let ce=Math.round($.pts-$.dts);K=Math.min(K,f),V=Math.max(V,f),z=Math.min(z,re),F=Math.max(F,re),o.push(vg($.key,f,Ee,ce));}if(o.length){if(nr){if(nr<70){let U=o[0].flags;U.dependsOn=2,U.isNonSync=0;}}else if(fc&&F-z<V-K&&_/V<.025&&o[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let U=m;for(let $=0,se=o.length;$<se;$++){let Ee=U+o[$].duration,re=U+o[$].cts;if($<se-1){let ce=Ee+o[$+1].cts;o[$].duration=ce-re;}else o[$].duration=$?o[$-1].duration:_;o[$].cts=0,U=Ee;}}}f=B||!f?_:f;let q=g+f;this.nextVideoTs=u=q-c,this.videoSampleDuration=f,this.isVideoContiguous=true;let X={data1:Ye.moof(e.sequenceNumber++,m,Se(e,{samples:o})),data2:L,startPTS:(E-c)/n,endPTS:(v+f-c)/n,startDTS:(m-c)/n,endDTS:u/n,type:"video",hasAudio:false,hasVideo:true,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,X}getSamplesPerFrame(e){switch(e.segmentCodec){case "mp3":return OS;case "ac3":return FS;default:return PS}}remuxAudio(e,t,i,r,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,d=a/o,l=this.getSamplesPerFrame(e),c=l*d,u=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=n!==void 0,g=e.samples,E=h?0:8,v=this.nextAudioTs||-1,T=u.baseTime*a/u.timescale,S=T+t*a;if(this.isAudioContiguous=i=i||g.length&&v>0&&(r&&Math.abs(S-(v+T))<9e3||Math.abs(St(g[0].pts,S)-(v+T))<20*c),g.forEach(function(F){F.pts=St(F.pts,S);}),!i||v<0){let F=g.length;if(g=g.filter(q=>q.pts>=0),F!==g.length&&this.warn(`Removed ${g.length-F} of ${F} samples (initPTS ${T} / ${a})`),!g.length)return;n===0?v=0:r&&!m?v=Math.max(0,S-T):v=g[0].pts-T;}if(e.segmentCodec==="aac"){let F=this.config.maxAudioFramesDrift;for(let q=0,G=v+T;q<g.length;q++){let j=g[q],X=j.pts,U=X-G,$=Math.abs(1e3*U/a);if(U<=-F*c&&m)q===0&&(this.warn(`Audio frame @ ${(X/a).toFixed(3)}s overlaps marker by ${Math.round(1e3*U/a)} ms.`),this.nextAudioTs=v=X-T,G=X);else if(U>=F*c&&$<wS&&m){let se=Math.round(U/c);for(G=X-se*c;G<0&&se&&c;)se--,G+=c;q===0&&(this.nextAudioTs=v=G-T),this.warn(`Injecting ${se} audio frames @ ${((G-T)/a).toFixed(3)}s due to ${Math.round(1e3*U/a)} ms gap.`);for(let Ee=0;Ee<se;Ee++){let re=tu.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);re||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),re=j.unit.subarray()),g.splice(q,0,{unit:re,pts:G}),G+=c,q++;}}j.pts=G,G+=c;}}let b=null,_=null,D,I=0,k=g.length;for(;k--;)I+=g[k].unit.byteLength;for(let F=0,q=g.length;F<q;F++){let G=g[F],j=G.unit,X=G.pts;if(_!==null){let $=f[F-1];$.duration=Math.round((X-_)/d);}else if(i&&e.segmentCodec==="aac"&&(X=v+T),b=X,I>0){I+=E;try{D=new Uint8Array(I);}catch($){this.observer.emit(p.ERROR,p.ERROR,{type:Q.MUX_ERROR,details:x.REMUX_ALLOC_ERROR,fatal:false,error:$,bytes:I,reason:`fail allocating audio mdat ${I}`});return}h||(new DataView(D.buffer).setUint32(0,I),D.set(Ye.types.mdat,4));}else return;D.set(j,E);let U=j.byteLength;E+=U,f.push(vg(true,l,U,0)),_=X;}let R=f.length;if(!R)return;let L=f[f.length-1];v=_-T,this.nextAudioTs=v+d*L.duration;let w=h?new Uint8Array(0):Ye.moof(e.sequenceNumber++,b/d,Se({},e,{samples:f}));e.samples=[];let B=(b-T)/a,K=this.nextAudioTs/a,V={data1:w,data2:D,startPTS:B,endPTS:K,startDTS:B,endDTS:K,type:"audio",hasAudio:true,hasVideo:false,nb:R};return this.isAudioContiguous=true,V}};function St(s,e){let t;if(e===null)return s;for(e<s?t=-8589934592:t=8589934592;Math.abs(s-e)>4294967296;)s+=t;return s}function NS(s){for(let e=0;e<s.length;e++)if(s[e].key)return e;return -1}function Fp(s,e,t,i){let r=s.samples.length;if(!r)return;let n=s.inputTimeScale;for(let o=0;o<r;o++){let d=s.samples[o];d.pts=St(d.pts-t.baseTime*n/t.timescale,e*n)/n,d.dts=St(d.dts-i.baseTime*n/i.timescale,e*n)/n;}let a=s.samples;return s.samples=[],{samples:a}}function Np(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=St(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 iu=class extends ht{constructor(e,t,i,r){super("passthrough-remuxer",r),this.emitInitSegment=false,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=false;}destroy(){}resetTimeStamp(e){this.lastEndTime=null;let t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e);}resetNextTimestamp(){this.isVideoContiguous=false,this.lastEndTime=null;}resetInitSegment(e,t,i,r){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(e,r),this.emitInitSegment=true;}generateInitSegment(e,t){let{audioCodec:i,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let{audio:n,video:a}=this.initData=qg(e);if(t)GT(e,t);else {let d=n||a;d!=null&&d.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${d.codec}")!`);}n&&(i=Tg(n,be.AUDIO,this)),a&&(r=Tg(a,be.VIDEO,this));let o={};n&&a?o.audiovideo={container:"video/mp4",codec:i+","+r,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:n?o.audio={container:"audio/mp4",codec:i,encrypted:n.encrypted,initSegment:e,id:"audio"}:a?o.video={container:"video/mp4",codec:r,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=o;}remux(e,t,i,r,n,a){var o,d;let{initPTS:l,lastEndTime:c}=this,u={audio:void 0,video:void 0,text:r,id3:i,initSegment:void 0};H(c)||(c=this.lastEndTime=n||0);let h=t.samples;if(!h.length)return u;let f={initPTS:void 0,timescale:void 0,trackId:void 0},m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(h),m=this.initData),!((d=m)!=null&&d.length))return this.warn("Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=false);let g=KT(h,m,this),E=m.audio?g[m.audio.id]:null,v=m.video?g[m.video.id]:null,T=Fo(v,1/0),S=Fo(E,1/0),b=Fo(v,0,true),_=Fo(E,0,true),D=n,I=0,k=E&&(!v||!l&&S<T||l&&l.trackId===m.audio.id),R=k?E:v;if(R){let G=R.timescale,j=R.start-n*G,X=k?m.audio.id:m.video.id;D=R.start/G,I=k?_-S:b-T,(a||!l)&&(US(l,D,n,I)||G!==l.timescale)&&(l&&this.warn(`Timestamps at playlist time: ${a?"":"~"}${n} ${j/G} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${n} offset: ${D-n} (${j}/${G}) trackId: ${X}`),l=null,f.initPTS=j,f.timescale=G,f.trackId=X);}else this.warn(`No audio or video samples found for initPTS at playlist time: ${n}`);l?(f.initPTS=l.baseTime,f.timescale=l.timescale,f.trackId=l.trackId):((!f.timescale||f.trackId===void 0||f.initPTS===void 0)&&(this.warn("Could not set initPTS"),f.initPTS=D,f.timescale=1,f.trackId=-1),this.initPTS=l={baseTime:f.initPTS,timescale:f.timescale,trackId:f.trackId});let L=D-l.baseTime/l.timescale,w=L+I;I>0?this.lastEndTime=w:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let B=!!m.audio,K=!!m.video,z="";B&&(z+="audio"),K&&(z+="video");let V=(m.audio?m.audio.encrypted:false)||(m.video?m.video.encrypted:false),F={data1:h,startPTS:L,startDTS:L,endPTS:w,endDTS:w,type:z,hasAudio:B,hasVideo:K,nb:1,dropped:0,encrypted:V};u.audio=B&&!K?F:void 0,u.video=K?F:void 0;let q=v?.sampleCount;if(q){let G=v.keyFrameIndex,j=G!==-1;F.nb=q,F.dropped=G===0||this.isVideoContiguous?0:j?G:q,F.independent=j,F.firstKeyFrame=G,j&&v.keyFrameStart&&(F.firstKeyFramePTS=(v.keyFrameStart-l.baseTime)/l.timescale),this.isVideoContiguous||(u.independent=j),this.isVideoContiguous||(this.isVideoContiguous=j),F.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${G}/${q} dropped: ${F.dropped} start: ${F.firstKeyFramePTS||"NA"}`);}return u.initSegment=f,u.id3=Fp(i,n,l,l),r.samples.length&&(u.text=Np(r,n,l)),u}};function Fo(s,e,t=false){return s?.start!==void 0?(s.start+(t?s.duration:0))/s.timescale:e}function US(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 Tg(s,e,t){let i=s.codec;return i&&i.length>4?i:e===be.AUDIO?i==="ec-3"||i==="ac-3"||i==="alac"?i:i==="fLaC"||i==="Opus"?Jo(i,false):(t.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"):(t.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1")}var bi;try{bi=self.performance.now.bind(self.performance);}catch{bi=Date.now;}var qo=[{demux:jc,remux:iu},{demux:Zc,remux:ur},{demux:Wc,remux:ur},{demux:qc,remux:ur}];qo.splice(2,0,{demux:Yc,remux:ur});var fl=class{constructor(e,t,i,r,n,a){this.asyncResult=false,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.id=n,this.logger=a;}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset();}push(e,t,i,r){let n=i.transmuxing;n.executeStart=bi();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:d}=this;r&&(this.currentTransmuxState=r);let{contiguous:l,discontinuity:c,trackSwitch:u,accurateTimeOffset:h,timeOffset:f,initSegmentChange:m}=r||o,{audioCodec:g,videoCodec:E,defaultInitPts:v,duration:T,initSegmentData:S}=d,b=$S(a,t);if(b&&cr(b.method)){let k=this.getDecrypter(),R=Qu(b.method);if(k.isSync()){let L=k.softwareDecrypt(a,b.key.buffer,b.iv.buffer,R);if(i.part>-1){let B=k.flush();L=B&&B.buffer;}if(!L)return n.executeEnd=bi(),mc(i);a=new Uint8Array(L);}else return this.asyncResult=true,this.decryptionPromise=k.webCryptoDecrypt(a,b.key.buffer,b.iv.buffer,R).then(L=>{let w=this.push(L,null,i);return this.decryptionPromise=null,w}),this.decryptionPromise}let _=this.needsProbing(c,u);if(_){let k=this.configureTransmuxer(a);if(k)return this.logger.warn(`[transmuxer] ${k.message}`),this.observer.emit(p.ERROR,p.ERROR,{type:Q.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:false,error:k,reason:k.message}),n.executeEnd=bi(),mc(i)}(c||u||m||_)&&this.resetInitSegment(S,g,E,T,t),(c||m||_)&&this.resetInitialTimestamp(v),l||this.resetContiguity();let D=this.transmux(a,b,f,h,i);this.asyncResult=Pn(D);let I=this.currentTransmuxState;return I.contiguous=true,I.discontinuity=false,I.trackSwitch=false,n.executeEnd=bi(),D}flush(e){let t=e.transmuxing;t.executeStart=bi();let{decrypter:i,currentTransmuxState:r,decryptionPromise:n}=this;if(n)return this.asyncResult=true,n.then(()=>this.flush(e));let a=[],{timeOffset:o}=r;if(i){let u=i.flush();u&&a.push(this.push(u.buffer,null,e));}let{demuxer:d,remuxer:l}=this;if(!d||!l){t.executeEnd=bi();let u=[mc(e)];return this.asyncResult?Promise.resolve(u):u}let c=d.flush(o);return Pn(c)?(this.asyncResult=true,c.then(u=>(this.flushRemux(a,u,e),a))):(this.flushRemux(a,c,e),this.asyncResult?Promise.resolve(a):a)}flushRemux(e,t,i){let{audioTrack:r,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:d,timeOffset:l}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===Y.MAIN?"level":"track"} ${i.level}`);let c=this.remuxer.remux(r,n,a,o,l,d,true,this.id);e.push({remuxResult:c,chunkMeta:i}),i.transmuxing.executeEnd=bi();}resetInitialTimestamp(e){let{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e));}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp());}resetInitSegment(e,t,i,r,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,i,r),o.resetInitSegment(e,t,i,n));}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0);}transmux(e,t,i,r,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,i,r,n):a=this.transmuxUnencrypted(e,i,r,n),a}transmuxUnencrypted(e,t,i,r){let{audioTrack:n,videoTrack:a,id3Track:o,textTrack:d}=this.demuxer.demux(e,t,false,!this.config.progressive);return {remuxResult:this.remuxer.remux(n,a,o,d,t,i,false,this.id),chunkMeta:r}}transmuxSampleAes(e,t,i,r,n){return this.demuxer.demuxSampleAes(e,t,i).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,i,r,false,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:i,typeSupported:r}=this,n;for(let u=0,h=qo.length;u<h;u++){var a;if((a=qo[u].demux)!=null&&a.probe(e,this.logger)){n=qo[u];break}}if(!n)return new Error("Failed to find demuxer by probing fragment data");let o=this.demuxer,d=this.remuxer,l=n.remux,c=n.demux;(!d||!(d instanceof l))&&(this.remuxer=new l(i,t,r,this.logger)),(!o||!(o instanceof c))&&(this.demuxer=new c(i,t,r,this.logger),this.probe=c.probe);}needsProbing(e,t){return !this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Rn(this.config)),e}};function $S(s,e){let t=null;return s.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var mc=s=>({remuxResult:{},chunkMeta:s});function Pn(s){return "then"in s&&s.then instanceof Function}var su=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;}},ru=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;}},yg=0,ml=class{constructor(e,t,i,r){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=yg++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=d=>{let l=d.data,c=this.hls;if(!(!c||!(l!=null&&l.event)||l.instanceNo!==this.instanceNo))switch(l.event){case "init":{var u;let h=(u=this.workerContext)==null?void 0:u.objectURL;h&&self.URL.revokeObjectURL(h);break}case "transmuxComplete":{this.handleTransmuxComplete(l.data);break}case "flush":{this.onFlush(l.data);break}case "workerLog":{c.logger[l.data.logType]&&c.logger[l.data.logType](l.data.message);break}default:{l.data=l.data||{},l.data.frag=this.frag,l.data.part=this.part,l.data.id=this.id,c.trigger(l.event,l.data);break}}},this.onWorkerError=d=>{if(!this.hls)return;let l=new Error(`${d.message} (${d.filename}:${d.lineno})`);this.hls.config.enableWorker=false,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(p.ERROR,{type:Q.OTHER_ERROR,details:x.INTERNAL_EXCEPTION,fatal:false,event:"demuxerWorker",error:l});};let n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=i,this.onFlush=r;let a=(d,l)=>{l=l||{},l.frag=this.frag||void 0,d===p.ERROR&&(l=l,l.parent=this.id,l.part=this.part,this.error=l.error),this.hls.trigger(d,l);};this.observer=new Zu,this.observer.on(p.FRAG_DECRYPTED,a),this.observer.on(p.ERROR,a);let o=Nm(n.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){let d=this.hls.logger;if(n.workerPath||eS()){try{n.workerPath?(d.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=iS(n.workerPath)):(d.log(`injecting Web Worker for "${t}"`),this.workerContext=tS());let{worker:c}=this.workerContext;c.addEventListener("message",this.onWorkerMessage),c.addEventListener("error",this.onWorkerError),c.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:o,id:t,config:Ae(n)});}catch(c){d.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.terminateWorker(),this.error=null,this.transmuxer=new fl(this.observer,o,n,"",t,e.logger);}return}}this.transmuxer=new fl(this.observer,o,n,"",t,e.logger);}reset(){if(this.frag=null,this.part=null,this.workerContext){let e=this.instanceNo;this.instanceNo=yg++;let t=this.hls.config,i=Nm(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:Ae(t)});}}terminateWorker(){if(this.workerContext){let{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),sS(this.hls.config.workerPath);}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else {let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null);}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null;}push(e,t,i,r,n,a,o,d,l,c){var u,h;l.transmuxing.start=self.performance.now();let{instanceNo:f,transmuxer:m}=this,g=a?a.start:n.start,E=n.decryptdata,v=this.frag,T=!(v&&n.cc===v.cc),S=!(v&&l.level===v.level),b=v?l.sn-v.sn:-1,_=this.part?l.part-this.part.index:-1,D=b===0&&l.id>1&&l.id===v?.stats.chunkCount,I=!S&&(b===1||b===0&&(_===1||D&&_<=0)),k=self.performance.now();(S||b||n.stats.parsing.start===0)&&(n.stats.parsing.start=k),a&&(_||!I)&&(a.stats.parsing.start=k);let R=!(v&&((u=n.initSegment)==null?void 0:u.url)===((h=v.initSegment)==null?void 0:h.url)),L=new ru(T,I,d,S,g,R);if(!I||T||R){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${n.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===Y.MAIN?"level":"track"}: ${l.level} id: ${l.id}
|
|
1472
|
+
discontinuity: ${T}
|
|
1497
1473
|
trackSwitch: ${S}
|
|
1498
1474
|
contiguous: ${I}
|
|
1499
|
-
accurateTimeOffset: ${
|
|
1475
|
+
accurateTimeOffset: ${d}
|
|
1500
1476
|
timeOffset: ${g}
|
|
1501
|
-
initSegmentChange: ${R}`);let M=new nu(i,r,t,o,c);this.configureTransmuxer(M);}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({instanceNo:f,cmd:"demux",data:e,decryptdata:E,chunkMeta:d,state:L},e instanceof ArrayBuffer?[e]:[]);else if(m){let M=m.push(e,E,d,L);Fn(M)?M.then($=>{this.handleTransmuxComplete($);}).catch($=>{this.transmuxerError($,d,"transmuxer-interface push error");}):this.handleTransmuxComplete(M);}}flush(e){e.transmuxing.start=self.performance.now();let{instanceNo:t,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){let r=i.flush(e);Fn(r)?r.then(n=>{this.handleFlushResult(n,e);}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error");}):this.handleFlushResult(r,e);}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(p.ERROR,{type:z.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:false,error:e,err:e,reason:i}));}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i);}),this.onFlush(t);}configureTransmuxer(e){let{instanceNo:t,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e);}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e);}},Lg=100,ou=class extends Mn{constructor(e,t,i){super(e,t,i,"audio-stream-controller",W.AUDIO),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=false,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=false,this.bufferFlushed=false,this.cachedTrackLoadedData=null,this.registerListeners();}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem();}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null;}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(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.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_LOADING,this.onFragLoading,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this);}unregisterListeners(){let{hls:e}=this;e&&(super.unregisterListeners(),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.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_LOADING,this.onFragLoading,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this));}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:n,trackId:a}){if(i===W.MAIN){let o=t.cc,l=this.fragCurrent;if(this.initPTS[o]={baseTime:r,timescale:n,trackId:a},this.log(`InitPTS for cc: ${o} found from main: ${r/n} (${r}/${n}) trackId: ${a}`),this.mainAnchor=t,this.state===C.WAITING_INIT_PTS){let d=this.waitingData;(!d&&!this.loadingParts||d&&d.frag.cc!==o)&&this.syncWithAnchor(t,d?.frag);}else !this.hls.hasEnoughToStart&&l&&l.cc!==o?(l.abortRequests(),this.syncWithAnchor(t,l)):this.state===C.IDLE&&this.tick();}}getLoadPosition(){return !this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var i;let r=((i=this.mainFragLoading)==null?void 0:i.frag)||null;if(t&&r?.cc===t.cc)return;let n=(r||e).cc,a=this.getLevelDetails(),o=this.getLoadPosition(),l=dp(a,n,o);l&&(this.log(`Syncing with main frag at ${l.start} cc ${l.cc}`),this.startFragRequested=false,this.nextLoadPosition=l.start,this.resetLoadingState(),this.state===C.IDLE&&this.doTickIdle());}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=C.STOPPED;return}let i=this.lastCurrentTime;this.stopLoad(),this.setInterval(Lg),i>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=C.IDLE):this.state=C.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick();}doTick(){switch(this.state){case C.IDLE:this.doTickIdle();break;case C.WAITING_TRACK:{let{levels:e,trackId:t}=this,i=e?.[t],r=i?.details;if(r&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(r))break;this.state=C.WAITING_INIT_PTS;}break}case C.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case C.WAITING_INIT_PTS:{let e=this.waitingData;if(e){let{frag:t,part:i,cache:r,complete:n}=e,a=this.mainAnchor;if(this.initPTS[t.cc]!==void 0){this.waitingData=null,this.state=C.FRAG_LOADING;let o=r.flush().buffer,l={frag:t,part:i,payload:o,networkDetails:null};this._handleFragmentLoadProgress(l),n&&super._handleFragmentLoadComplete(l);}else a&&a.cc!==e.frag.cc&&this.syncWithAnchor(a,e.frag);}else this.state=C.IDLE;}}this.onTickEnd();}resetLoadingState(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState();}onTickEnd(){let{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime);}doTickIdle(){var e;let{hls:t,levels:i,media:r,trackId:n}=this,a=t.config;if(!this.buffering||!r&&!this.primaryPrefetch&&(this.startFragRequested||!a.startFragPrefetch)||!(i!=null&&i[n]))return;let o=i[n],l=o.details;if(!l||this.waitForLive(o)||this.waitForCdnTuneIn(l)){this.state=C.WAITING_TRACK,this.startFragRequested=false;return}let d=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&d&&(this.bufferFlushed=false,this.afterBufferFlushed(d,be.AUDIO,W.AUDIO));let c=this.getFwdBufferInfo(d,W.AUDIO);if(c===null)return;if(!this.switchingTrack&&this._streamEnded(c,l)){t.trigger(p.BUFFER_EOS,{type:"audio"}),this.state=C.ENDED;return}let u=c.len,h=t.maxBufferLength,f=l.fragments,m=f[0].start,g=this.getLoadPosition(),E=this.flushing?g:c.end;if(this.switchingTrack&&r){let S=g;l.PTSKnown&&S<m&&(c.end>m||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=m+.05);}if(u>=h&&!this.switchingTrack&&E<f[f.length-1].start)return;let v=this.getNextFragment(E,l);if(v&&this.isLoopLoading(v,E)&&(v=this.getNextFragmentLoopLoading(v,l,c,W.MAIN,h)),!v){this.bufferFlushed=true;return}let y=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&y&&Fe(v)&&!v.endList&&(!l.live||!this.loadingParts&&E<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(y)===We.OK&&(this.mainFragLoading=y=null),y&&Fe(y))){if(v.start>y.end){let b=this.fragmentTracker.getFragAtPos(E,W.MAIN);b&&b.end>y.end&&(y=b,this.mainFragLoading={frag:b,targetBufferTime:null});}if(v.start>y.end)return}this.loadFragment(v,o,E);}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=false,super.onMediaDetaching(e,t);}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new ms(i));}onAudioTrackSwitching(e,t){let i=!!t.url;this.trackId=t.id;let{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==C.STOPPED&&(this.setInterval(Lg),this.state=C.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval());}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=false,this.resetItem(),this.trackId=-1;}onLevelLoaded(e,t){this.mainDetails=t.details;let i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(p.AUDIO_TRACK_LOADED,i));}onAudioTrackLoaded(e,t){var i;let{levels:r}=this,{details:n,id:a,groupId:o,track:l}=t;if(!r){this.warn(`Audio tracks reset while loading track ${a} "${l.name}" of "${o}"`);return}let d=this.mainDetails;if(!d||n.endCC>d.endCC||d.expired){this.cachedTrackLoadedData=t,this.state!==C.STOPPED&&(this.state=C.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${a} "${l.name}" of "${o}" loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);let c=r[a],u=0;if(n.live||(i=c.details)!=null&&i.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;if(c.details){var h;u=this.alignPlaylists(n,c.details,(h=this.levelLastLoaded)==null?void 0:h.details);}n.alignedSliding||(Ip(n,d),n.alignedSliding||hl(n,d),u=n.fragmentStart);}c.details=n,this.levelLastLoaded=c,this.startFragRequested||this.setStartPosition(d,u),this.hls.trigger(p.AUDIO_TRACK_UPDATED,{details:n,id:a,groupId:t.groupId}),this.state===C.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=C.IDLE),this.tick();}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:r,payload:n}=e,{config:a,trackId:o,levels: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 u=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new El(this.hls,W.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,y=new Cn(i.level,i.sn,i.stats.chunkCount,n.byteLength,E,v);h.push(n,m,u,"",i,r,c.totalduration,false,y,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 fl,complete:false};g.push(new Uint8Array(n)),this.state!==C.STOPPED&&(this.state=C.WAITING_INIT_PTS);}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=true;return}super._handleFragmentLoadComplete(e);}onBufferReset(){this.mediaBuffer=null;}onBufferCreated(e,t){this.bufferFlushed=this.flushing=false;let i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null);}onFragLoading(e,t){!this.audioOnly&&t.frag.type===W.MAIN&&Fe(t.frag)&&(this.mainFragLoading=t,this.state===C.IDLE&&this.tick());}onFragBuffered(e,t){let{frag:i,part:r}=t;if(i.type!==W.AUDIO){!this.audioOnly&&i.type===W.MAIN&&!i.elementaryStreams.video&&!i.elementaryStreams.audiovideo&&(this.audioOnly=true,this.mainFragLoading=null);return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(Fe(i)){this.fragPrevious=i;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(p.AUDIO_TRACK_SWITCHED,Te({},n)));}this.fragBufferedComplete(i,r),this.media&&this.tick();}onError(e,t){var i;if(t.fatal){this.state=C.ERROR;return}switch(t.details){case 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(W.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)===ue.AUDIO_TRACK&&(this.state=C.IDLE);break;case x.BUFFER_ADD_CODEC_ERROR:case x.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case x.BUFFER_FULL_ERROR:if(t.parent!=="audio")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!==be.VIDEO&&(this.flushing=true);}onBufferFlushed(e,{type:t}){if(t!==be.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,W.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:u}=c,{audio:h,text:f,id3:m,initSegment:g}=n;if(this.fragContextChanged(l)||!u){this.fragmentTracker.removeFragment(l);return}if(this.state=C.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),g!=null&&g.tracks){let E=l.initSegment||l;if(this.unhandledEncryptionError(g,l))return;this._bufferInitSegment(c,g.tracks,E,a),r.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:E,id:i,tracks:g.tracks});}if(h){let{startPTS:E,endPTS:v,startDTS:y,endDTS:S}=h;d&&(d.elementaryStreams[be.AUDIO]={startPTS:E,endPTS:v,startDTS:y,endDTS:S}),l.setElementaryStreamInfo(be.AUDIO,E,v,y,S),this.bufferFragmentData(h,l,d,a);}if(m!=null&&(t=m.samples)!=null&&t.length){let E=Se({id:i,frag:l,details:u},m);r.trigger(p.FRAG_PARSING_METADATA,E);}if(f){let E=Se({id:i,frag:l,details:u},f);r.trigger(p.FRAG_PARSING_USERDATA,E);}}_bufferInitSegment(e,t,i,r){if(this.state!==C.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;let n=t.audio;n.id=W.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.switchingTrack||r===We.NOT_LOADED||r===We.PARTIAL){var n;if(!Fe(e))this._loadInitSegment(e,t);else if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=C.WAITING_INIT_PTS;let a=this.mainDetails;a&&a.fragmentStart!==t.details.fragmentStart&&hl(t.details,a);}else super.loadFragment(e,t,i);}else this.clearTrackerIfNeeded(e);}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){let{name:t,lang:i,assocLang:r,characteristics:n,audioCodec:a,channels:o}=this.bufferedTrack;hs({name:t,lang:i,assocLang:r,characteristics:n,audioCodec:a,channels:o},e,cs)||(nl(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e);}}completeAudioSwitch(e){let{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(p.AUDIO_TRACK_SWITCHED,Te({},e));}},Un=class extends ft{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=false,this.timer=-1,this.hls=e;}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null;}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1);}startLoad(){this.canLoad=true,this.loadPlaylist();}stopLoad(){this.canLoad=false,this.clearTimer();}switchParams(e,t,i){let r=t?.renditionReports;if(r){let n=-1;for(let a=0;a<r.length;a++){let o=r[a],l;try{l=new self.URL(o.URI,t.url).href;}catch(d){this.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&&Km(i);return new rl(o,l>=0?l:void 0,d)}}}loadPlaylist(e){this.clearTimer();}loadingPlaylist(e,t){this.clearTimer();}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(i){this.warn(`Could not construct new URL with HLS Delivery Directives: ${i}`);}return e}playlistLoaded(e,t,i){let{details:r,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;r.advancedDateTime=Date.now()-o;let l=this.hls.config.timelineOffset;if(l!==r.appliedTimelineOffset){let c=Math.max(l||0,0);r.appliedTimelineOffset=c,r.fragments.forEach(u=>{u.setStart(u.playlistOffset+c);});}if(r.live||i!=null&&i.live){let c="levelInfo"in t?t.levelInfo:t.track;if(r.reloaded(i),i&&r.fragments.length>0){zy(i,r,this);let y=r.playlistParsingError;if(y){this.warn(y);let S=this.hls;if(!S.config.ignorePlaylistParsingErrors){var d;let{networkDetails:b}=t;S.trigger(p.ERROR,{type:z.NETWORK_ERROR,details:x.LEVEL_PARSING_ERROR,fatal:false,url:r.url,error:y,reason:y.message,level:t.level||void 0,parent:(d=r.fragments[0])==null?void 0:d.type,networkDetails:b,stats:n});return}r.playlistParsingError=null;}}r.requestScheduled===-1&&(r.requestScheduled=n.loading.start);let u=this.hls.mainForwardBufferInfo,h=u?u.end-u.len:0,f=(r.edge-h)*1e3,m=yp(r,f);if(r.requestScheduled+m<a?r.requestScheduled=a:r.requestScheduled+=m,this.log(`live playlist ${e} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),!this.canLoad||!r.live)return;let g,E,v;if(r.canBlockReload&&r.endSN&&r.advanced){let y=this.hls.config.lowLatencyMode,S=r.lastPartSn,b=r.endSN,_=r.lastPartIndex,D=_!==-1,I=S===b;D?I?(E=b+1,v=y?0:_):(E=S,v=y?_+1:r.maxPartIndex):E=b+1;let k=r.age,R=k+r.ageHeader,L=Math.min(R-r.partTarget,r.targetduration*1.5);if(L>0){if(R>r.targetduration*3)this.log(`Playlist last advanced ${k.toFixed(2)}s ago. Omitting segment and part directives.`),E=void 0,v=void 0;else if(i!=null&&i.tuneInGoal&&R-r.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${L} with playlist age: ${r.age}`),L=0;else {let M=Math.floor(L/r.targetduration);if(E+=M,v!==void 0){let $=Math.round(L%r.targetduration/r.partTarget);v+=$;}this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${k.toFixed(2)}s goal: ${L} skip sn ${M} to part ${v}`);}r.tuneInGoal=L;}if(g=this.getDeliveryDirectives(r,t.deliveryDirectives,E,v),y||!I){r.requestScheduled=a,this.loadingPlaylist(c,g);return}}else (r.canBlockReload||r.canSkipUntil)&&(g=this.getDeliveryDirectives(r,t.deliveryDirectives,E,v));g&&E!==void 0&&r.canBlockReload&&(r.requestScheduled=n.loading.first+Math.max(m-o*2,m/2)),this.scheduleLoading(c,g,r);}else this.clearTimer();}scheduleLoading(e,t,i){let r=i||e.details;if(!r){this.loadingPlaylist(e,t);return}let n=self.performance.now(),a=r.requestScheduled;if(n>=a){this.loadingPlaylist(e,t);return}let o=a-n;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o);}getDeliveryDirectives(e,t,i,r){let n=Km(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,r=t.part,n=jo.No),new rl(i,r,n)}checkRetry(e){let t=e.details,i=al(e),r=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=r||{},l=!!r&&!!o&&(n===Qe.RetryRequest||!r.resolved&&n===Qe.SendAlternateToPenaltyBox);if(l){var d;if(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=Xu(o,a);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${c}ms`);}e.levelRetry=true,r.resolved=true;}return l}};function Kp(s,e){if(s.length!==e.length)return false;for(let t=0;t<s.length;t++)if(!Nn(s[t].attrs,e[t].attrs))return false;return true}function Nn(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 lu(s,e){return e.label.toLowerCase()===s.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(s.lang||"").toLowerCase())}var du=class extends Un{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(h=>!i||i.indexOf(h.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(h=>h.default)&&(this.selectDefaultTrack=false),o.forEach((h,f)=>{h.id=f;});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;let l=this.hls.config.audioPreference;if(!n&&l){let h=mi(l,o,cs);if(h>-1)n=o[h];else {let f=mi(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 u=this.trackId;if(d!==-1&&u===-1)this.setAudioTrack(d);else if(o.length&&u===-1){var a;let h=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(h.message),this.hls.trigger(p.ERROR,{type:z.MEDIA_ERROR,details:x.AUDIO_TRACK_LOAD_ERROR,fatal:true,error:h});}}}onError(e,t){t.fatal||!t.context||t.context.type===ue.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t);}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=false,this.setAudioTrack(e);}setAudioOption(e){let t=this.hls;if(t.config.audioPreference=e,e){let i=this.allAudioTracks;if(this.selectDefaultTrack=false,i.length){let r=this.currentTrack;if(r&&hs(e,r,cs))return r;let n=mi(e,this.tracksInGroup,cs);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=_y(e,t.levels,i,a,cs);if(o===-1)return null;t.nextLoadLevel=o;}if(e.channels||e.audioCodec){let a=mi(e,i);if(a>-1)return i[a]}}}return null}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.selectDefaultTrack=false;let i=this.currentTrack,r=t[e],n=r.details&&!r.details.live;if(e===this.trackId&&r===i&&n||(this.log(`Switching to audio-track ${e} "${r.name}" lang:${r.lang} group:${r.groupId} channels:${r.channels}`),this.trackId=e,this.currentTrack=r,this.hls.trigger(p.AUDIO_TRACK_SWITCHING,Te({},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||hs(e,r,cs)))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(hs({name:i,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:l},c,cs))return d}for(let d=0;d<t.length;d++){let c=t[d];if(Nn(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){let c=t[d];if(Nn(e.attrs,c.attrs,["LANGUAGE"]))return d}}return -1}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;this.shouldLoadPlaylist(t)&&nl(t.url,this.hls)&&this.scheduleLoading(t,e);}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=e.id,r=e.groupId,n=this.getUrlWithDirectives(e.url,t),a=e.details,o=a?.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${n}`),this.hls.trigger(p.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:t||null,track:e});}},cu=class{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e;}destroy(){this.tracks=this.queues=null;}append(e,t,i){if(this.queues===null||this.tracks===null)return;let r=this.queues[t];r.push(e),r.length===1&&!i&&this.executeNext(t);}appendBlocker(e){return new Promise(t=>{let i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e);})}prependBlocker(e){return new Promise(t=>{if(this.queues){let i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i);}})}removeBlockers(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;let i=(t=e[0])==null?void 0:t.label;(i==="async-blocker"||i==="async-blocker-prepend")&&(e[0].execute(),e.splice(0,1));});}unblockAudio(e){if(this.queues===null)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio");}executeNext(e){if(this.queues===null||this.tracks===null)return;let t=this.queues[e];if(t.length){let r=t[0];try{r.execute();}catch(n){var i;if(r.onError(n),this.queues===null||this.tracks===null)return;let a=(i=this.tracks[e])==null?void 0:i.buffer;a!=null&&a.updating||this.shiftAndExecuteNext(e);}}}shiftAndExecuteNext(e){this.queues!==null&&(this.queues[e].shift(),this.executeNext(e));}current(e){var t;return ((t=this.queues)==null?void 0:t[e][0])||null}toString(){let{queues:e,tracks:t}=this;return e===null||t===null?"<destroyed>":`
|
|
1477
|
+
initSegmentChange: ${R}`);let w=new su(i,r,t,o,c);this.configureTransmuxer(w);}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({instanceNo:f,cmd:"demux",data:e,decryptdata:E,chunkMeta:l,state:L},e instanceof ArrayBuffer?[e]:[]);else if(m){let w=m.push(e,E,l,L);Pn(w)?w.then(B=>{this.handleTransmuxComplete(B);}).catch(B=>{this.transmuxerError(B,l,"transmuxer-interface push error");}):this.handleTransmuxComplete(w);}}flush(e){e.transmuxing.start=self.performance.now();let{instanceNo:t,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){let r=i.flush(e);Pn(r)?r.then(n=>{this.handleFlushResult(n,e);}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error");}):this.handleFlushResult(r,e);}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:false,error:e,err:e,reason:i}));}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i);}),this.onFlush(t);}configureTransmuxer(e){let{instanceNo:t,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e);}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e);}},Sg=100,nu=class extends Dn{constructor(e,t,i){super(e,t,i,"audio-stream-controller",Y.AUDIO),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=false,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=false,this.bufferFlushed=false,this.cachedTrackLoadedData=null,this.registerListeners();}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem();}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null;}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(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.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_LOADING,this.onFragLoading,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this);}unregisterListeners(){let{hls:e}=this;e&&(super.unregisterListeners(),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.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_LOADING,this.onFragLoading,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this));}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:n,trackId:a}){if(i===Y.MAIN){let o=t.cc,d=this.fragCurrent;if(this.initPTS[o]={baseTime:r,timescale:n,trackId:a},this.log(`InitPTS for cc: ${o} found from main: ${r/n} (${r}/${n}) trackId: ${a}`),this.mainAnchor=t,this.state===M.WAITING_INIT_PTS){let l=this.waitingData;(!l&&!this.loadingParts||l&&l.frag.cc!==o)&&this.syncWithAnchor(t,l?.frag);}else !this.hls.hasEnoughToStart&&d&&d.cc!==o?(d.abortRequests(),this.syncWithAnchor(t,d)):this.state===M.IDLE&&this.tick();}}getLoadPosition(){return !this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var i;let r=((i=this.mainFragLoading)==null?void 0:i.frag)||null;if(t&&r?.cc===t.cc)return;let n=(r||e).cc,a=this.getLevelDetails(),o=this.getLoadPosition(),d=rp(a,n,o);d&&(this.log(`Syncing with main frag at ${d.start} cc ${d.cc}`),this.startFragRequested=false,this.nextLoadPosition=d.start,this.resetLoadingState(),this.state===M.IDLE&&this.doTickIdle());}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=M.STOPPED;return}let i=this.lastCurrentTime;this.stopLoad(),this.setInterval(Sg),i>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=M.IDLE):this.state=M.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick();}doTick(){switch(this.state){case M.IDLE:this.doTickIdle();break;case M.WAITING_TRACK:{let{levels:e,trackId:t}=this,i=e?.[t],r=i?.details;if(r&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(r))break;this.state=M.WAITING_INIT_PTS;}break}case M.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case M.WAITING_INIT_PTS:{let e=this.waitingData;if(e){let{frag:t,part:i,cache:r,complete:n}=e,a=this.mainAnchor;if(this.initPTS[t.cc]!==void 0){this.waitingData=null,this.state=M.FRAG_LOADING;let o=r.flush().buffer,d={frag:t,part:i,payload:o,networkDetails:null};this._handleFragmentLoadProgress(d),n&&super._handleFragmentLoadComplete(d);}else a&&a.cc!==e.frag.cc&&this.syncWithAnchor(a,e.frag);}else this.state=M.IDLE;}}this.onTickEnd();}resetLoadingState(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState();}onTickEnd(){let{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime);}doTickIdle(){var e;let{hls:t,levels:i,media:r,trackId:n}=this,a=t.config;if(!this.buffering||!r&&!this.primaryPrefetch&&(this.startFragRequested||!a.startFragPrefetch)||!(i!=null&&i[n]))return;let o=i[n],d=o.details;if(!d||this.waitForLive(o)||this.waitForCdnTuneIn(d)){this.state=M.WAITING_TRACK,this.startFragRequested=false;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=false,this.afterBufferFlushed(l,be.AUDIO,Y.AUDIO));let c=this.getFwdBufferInfo(l,Y.AUDIO);if(c===null)return;if(!this.switchingTrack&&this._streamEnded(c,d)){t.trigger(p.BUFFER_EOS,{type:"audio"}),this.state=M.ENDED;return}let u=c.len,h=t.maxBufferLength,f=d.fragments,m=f[0].start,g=this.getLoadPosition(),E=this.flushing?g:c.end;if(this.switchingTrack&&r){let S=g;d.PTSKnown&&S<m&&(c.end>m||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=m+.05);}if(u>=h&&!this.switchingTrack&&E<f[f.length-1].start)return;let v=this.getNextFragment(E,d);if(v&&this.isLoopLoading(v,E)&&(v=this.getNextFragmentLoopLoading(v,d,c,Y.MAIN,h)),!v){this.bufferFlushed=true;return}let T=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&T&&Fe(v)&&!v.endList&&(!d.live||!this.loadingParts&&E<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(T)===We.OK&&(this.mainFragLoading=T=null),T&&Fe(T))){if(v.start>T.end){let b=this.fragmentTracker.getFragAtPos(E,Y.MAIN);b&&b.end>T.end&&(T=b,this.mainFragLoading={frag:b,targetBufferTime:null});}if(v.start>T.end)return}this.loadFragment(v,o,E);}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=false,super.onMediaDetaching(e,t);}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new fs(i));}onAudioTrackSwitching(e,t){let i=!!t.url;this.trackId=t.id;let{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==M.STOPPED&&(this.setInterval(Sg),this.state=M.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval());}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=false,this.resetItem(),this.trackId=-1;}onLevelLoaded(e,t){this.mainDetails=t.details;let i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(p.AUDIO_TRACK_LOADED,i));}onAudioTrackLoaded(e,t){var i;let{levels:r}=this,{details:n,id:a,groupId:o,track:d}=t;if(!r){this.warn(`Audio tracks reset while loading track ${a} "${d.name}" of "${o}"`);return}let l=this.mainDetails;if(!l||n.endCC>l.endCC||l.expired){this.cachedTrackLoadedData=t,this.state!==M.STOPPED&&(this.state=M.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${a} "${d.name}" of "${o}" loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);let c=r[a],u=0;if(n.live||(i=c.details)!=null&&i.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;if(c.details){var h;u=this.alignPlaylists(n,c.details,(h=this.levelLastLoaded)==null?void 0:h.details);}n.alignedSliding||(yp(n,l),n.alignedSliding||dl(n,l),u=n.fragmentStart);}c.details=n,this.levelLastLoaded=c,this.startFragRequested||this.setStartPosition(l,u),this.hls.trigger(p.AUDIO_TRACK_UPDATED,{details:n,id:a,groupId:t.groupId}),this.state===M.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=M.IDLE),this.tick();}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:r,payload:n}=e,{config:a,trackId:o,levels:d}=this;if(!d){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}let l=d[o];if(!l){this.warn("Audio track is undefined on fragment load progress");return}let c=l.details;if(!c){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}let u=a.defaultAudioCodec||l.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new ml(this.hls,Y.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,T=new kn(i.level,i.sn,i.stats.chunkCount,n.byteLength,E,v);h.push(n,m,u,"",i,r,c.totalduration,false,T,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 cl,complete:false};g.push(new Uint8Array(n)),this.state!==M.STOPPED&&(this.state=M.WAITING_INIT_PTS);}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=true;return}super._handleFragmentLoadComplete(e);}onBufferReset(){this.mediaBuffer=null;}onBufferCreated(e,t){this.bufferFlushed=this.flushing=false;let i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null);}onFragLoading(e,t){!this.audioOnly&&t.frag.type===Y.MAIN&&Fe(t.frag)&&(this.mainFragLoading=t,this.state===M.IDLE&&this.tick());}onFragBuffered(e,t){let{frag:i,part:r}=t;if(i.type!==Y.AUDIO){!this.audioOnly&&i.type===Y.MAIN&&!i.elementaryStreams.video&&!i.elementaryStreams.audiovideo&&(this.audioOnly=true,this.mainFragLoading=null);return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(Fe(i)){this.fragPrevious=i;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(p.AUDIO_TRACK_SWITCHED,Te({},n)));}this.fragBufferedComplete(i,r),this.media&&this.tick();}onError(e,t){var i;if(t.fatal){this.state=M.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(Y.AUDIO,t);break;case x.AUDIO_TRACK_LOAD_ERROR:case x.AUDIO_TRACK_LOAD_TIMEOUT:case x.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===M.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===ue.AUDIO_TRACK&&(this.state=M.IDLE);break;case x.BUFFER_ADD_CODEC_ERROR:case x.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case x.BUFFER_FULL_ERROR:if(t.parent!=="audio")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!==be.VIDEO&&(this.flushing=true);}onBufferFlushed(e,{type:t}){if(t!==be.VIDEO){this.flushing=false,this.bufferFlushed=true,this.state===M.ENDED&&(this.state=M.IDLE);let i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,Y.AUDIO),this.tick());}}_handleTransmuxComplete(e){var t;let i="audio",{hls:r}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:d,part:l,level:c}=o,{details:u}=c,{audio:h,text:f,id3:m,initSegment:g}=n;if(this.fragContextChanged(d)||!u){this.fragmentTracker.removeFragment(d);return}if(this.state=M.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),g!=null&&g.tracks){let E=d.initSegment||d;if(this.unhandledEncryptionError(g,d))return;this._bufferInitSegment(c,g.tracks,E,a),r.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:E,id:i,tracks:g.tracks});}if(h){let{startPTS:E,endPTS:v,startDTS:T,endDTS:S}=h;l&&(l.elementaryStreams[be.AUDIO]={startPTS:E,endPTS:v,startDTS:T,endDTS:S}),d.setElementaryStreamInfo(be.AUDIO,E,v,T,S),this.bufferFragmentData(h,d,l,a);}if(m!=null&&(t=m.samples)!=null&&t.length){let E=Se({id:i,frag:d,details:u},m);r.trigger(p.FRAG_PARSING_METADATA,E);}if(f){let E=Se({id:i,frag:d,details:u},f);r.trigger(p.FRAG_PARSING_USERDATA,E);}}_bufferInitSegment(e,t,i,r){if(this.state!==M.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;let n=t.audio;n.id=Y.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 d={type:"audio",frag:i,part:null,chunkMeta:r,parent:i.type,data:o};this.hls.trigger(p.BUFFER_APPENDING,d);}this.tickImmediate();}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);if(this.switchingTrack||r===We.NOT_LOADED||r===We.PARTIAL){var n;if(!Fe(e))this._loadInitSegment(e,t);else if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=M.WAITING_INIT_PTS;let a=this.mainDetails;a&&a.fragmentStart!==t.details.fragmentStart&&dl(t.details,a);}else super.loadFragment(e,t,i);}else this.clearTrackerIfNeeded(e);}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){let{name:t,lang:i,assocLang:r,characteristics:n,audioCodec:a,channels:o}=this.bufferedTrack;us({name:t,lang:i,assocLang:r,characteristics:n,audioCodec:a,channels:o},e,ds)||(il(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e);}}completeAudioSwitch(e){let{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(p.AUDIO_TRACK_SWITCHED,Te({},e));}},On=class extends ht{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=false,this.timer=-1,this.hls=e;}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null;}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1);}startLoad(){this.canLoad=true,this.loadPlaylist();}stopLoad(){this.canLoad=false,this.clearTimer();}switchParams(e,t,i){let r=t?.renditionReports;if(r){let n=-1;for(let a=0;a<r.length;a++){let o=r[a],d;try{d=new self.URL(o.URI,t.url).href;}catch(l){this.warn(`Could not construct new URL for Rendition Report: ${l}`),d=o.URI||"";}if(d===e){n=a;break}else d===e.substring(0,d.length)&&(n=a);}if(n!==-1){let a=r[n],o=parseInt(a["LAST-MSN"])||t.lastPartSn,d=parseInt(a["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){let c=Math.min(t.age-t.partTarget,t.targetduration);d>=0&&c>t.partTarget&&(d+=1);}let l=i&&Um(i);return new tl(o,d>=0?d:void 0,l)}}}loadPlaylist(e){this.clearTimer();}loadingPlaylist(e,t){this.clearTimer();}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(i){this.warn(`Could not construct new URL with HLS Delivery Directives: ${i}`);}return e}playlistLoaded(e,t,i){let{details:r,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;r.advancedDateTime=Date.now()-o;let d=this.hls.config.timelineOffset;if(d!==r.appliedTimelineOffset){let c=Math.max(d||0,0);r.appliedTimelineOffset=c,r.fragments.forEach(u=>{u.setStart(u.playlistOffset+c);});}if(r.live||i!=null&&i.live){let c="levelInfo"in t?t.levelInfo:t.track;if(r.reloaded(i),i&&r.fragments.length>0){Ky(i,r,this);let T=r.playlistParsingError;if(T){this.warn(T);let S=this.hls;if(!S.config.ignorePlaylistParsingErrors){var l;let{networkDetails:b}=t;S.trigger(p.ERROR,{type:Q.NETWORK_ERROR,details:x.LEVEL_PARSING_ERROR,fatal:false,url:r.url,error:T,reason:T.message,level:t.level||void 0,parent:(l=r.fragments[0])==null?void 0:l.type,networkDetails:b,stats:n});return}r.playlistParsingError=null;}}r.requestScheduled===-1&&(r.requestScheduled=n.loading.start);let u=this.hls.mainForwardBufferInfo,h=u?u.end-u.len:0,f=(r.edge-h)*1e3,m=gp(r,f);if(r.requestScheduled+m<a?r.requestScheduled=a:r.requestScheduled+=m,this.log(`live playlist ${e} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),!this.canLoad||!r.live)return;let g,E,v;if(r.canBlockReload&&r.endSN&&r.advanced){let T=this.hls.config.lowLatencyMode,S=r.lastPartSn,b=r.endSN,_=r.lastPartIndex,D=_!==-1,I=S===b;D?I?(E=b+1,v=T?0:_):(E=S,v=T?_+1:r.maxPartIndex):E=b+1;let k=r.age,R=k+r.ageHeader,L=Math.min(R-r.partTarget,r.targetduration*1.5);if(L>0){if(R>r.targetduration*3)this.log(`Playlist last advanced ${k.toFixed(2)}s ago. Omitting segment and part directives.`),E=void 0,v=void 0;else if(i!=null&&i.tuneInGoal&&R-r.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${L} with playlist age: ${r.age}`),L=0;else {let w=Math.floor(L/r.targetduration);if(E+=w,v!==void 0){let B=Math.round(L%r.targetduration/r.partTarget);v+=B;}this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${k.toFixed(2)}s goal: ${L} skip sn ${w} to part ${v}`);}r.tuneInGoal=L;}if(g=this.getDeliveryDirectives(r,t.deliveryDirectives,E,v),T||!I){r.requestScheduled=a,this.loadingPlaylist(c,g);return}}else (r.canBlockReload||r.canSkipUntil)&&(g=this.getDeliveryDirectives(r,t.deliveryDirectives,E,v));g&&E!==void 0&&r.canBlockReload&&(r.requestScheduled=n.loading.first+Math.max(m-o*2,m/2)),this.scheduleLoading(c,g,r);}else this.clearTimer();}scheduleLoading(e,t,i){let r=i||e.details;if(!r){this.loadingPlaylist(e,t);return}let n=self.performance.now(),a=r.requestScheduled;if(n>=a){this.loadingPlaylist(e,t);return}let o=a-n;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o);}getDeliveryDirectives(e,t,i,r){let n=Um(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,r=t.part,n=Wo.No),new tl(i,r,n)}checkRetry(e){let t=e.details,i=sl(e),r=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=r||{},d=!!r&&!!o&&(n===Qe.RetryRequest||!r.resolved&&n===Qe.SendAlternateToPenaltyBox);if(d){var l;if(a>=o.maxNumRetry)return false;if(i&&(l=e.context)!=null&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else {let c=zu(o,a);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${c}ms`);}e.levelRetry=true,r.resolved=true;}return d}};function Up(s,e){if(s.length!==e.length)return false;for(let t=0;t<s.length;t++)if(!Fn(s[t].attrs,e[t].attrs))return false;return true}function Fn(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 au(s,e){return e.label.toLowerCase()===s.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(s.lang||"").toLowerCase())}var ou=class extends On{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(h=>!i||i.indexOf(h.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(h=>h.default)&&(this.selectDefaultTrack=false),o.forEach((h,f)=>{h.id=f;});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;let d=this.hls.config.audioPreference;if(!n&&d){let h=fi(d,o,ds);if(h>-1)n=o[h];else {let f=fi(d,this.tracks);n=this.tracks[f];}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));let c={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${i?.join(",")}`),this.hls.trigger(p.AUDIO_TRACKS_UPDATED,c);let u=this.trackId;if(l!==-1&&u===-1)this.setAudioTrack(l);else if(o.length&&u===-1){var a;let h=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(h.message),this.hls.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.AUDIO_TRACK_LOAD_ERROR,fatal:true,error:h});}}}onError(e,t){t.fatal||!t.context||t.context.type===ue.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t);}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=false,this.setAudioTrack(e);}setAudioOption(e){let t=this.hls;if(t.config.audioPreference=e,e){let i=this.allAudioTracks;if(this.selectDefaultTrack=false,i.length){let r=this.currentTrack;if(r&&us(e,r,ds))return r;let n=fi(e,this.tracksInGroup,ds);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=vy(e,t.levels,i,a,ds);if(o===-1)return null;t.nextLoadLevel=o;}if(e.channels||e.audioCodec){let a=fi(e,i);if(a>-1)return i[a]}}}return null}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.selectDefaultTrack=false;let i=this.currentTrack,r=t[e],n=r.details&&!r.details.live;if(e===this.trackId&&r===i&&n||(this.log(`Switching to audio-track ${e} "${r.name}" lang:${r.lang} group:${r.groupId} channels:${r.channels}`),this.trackId=e,this.currentTrack=r,this.hls.trigger(p.AUDIO_TRACK_SWITCHING,Te({},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||us(e,r,ds)))return i}if(e){let{name:i,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:d}=e;for(let l=0;l<t.length;l++){let c=t[l];if(us({name:i,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:d},c,ds))return l}for(let l=0;l<t.length;l++){let c=t[l];if(Fn(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return l}for(let l=0;l<t.length;l++){let c=t[l];if(Fn(e.attrs,c.attrs,["LANGUAGE"]))return l}}return -1}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;this.shouldLoadPlaylist(t)&&il(t.url,this.hls)&&this.scheduleLoading(t,e);}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=e.id,r=e.groupId,n=this.getUrlWithDirectives(e.url,t),a=e.details,o=a?.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${n}`),this.hls.trigger(p.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:t||null,track:e});}},lu=class{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e;}destroy(){this.tracks=this.queues=null;}append(e,t,i){if(this.queues===null||this.tracks===null)return;let r=this.queues[t];r.push(e),r.length===1&&!i&&this.executeNext(t);}appendBlocker(e){return new Promise(t=>{let i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e);})}prependBlocker(e){return new Promise(t=>{if(this.queues){let i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i);}})}removeBlockers(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;let i=(t=e[0])==null?void 0:t.label;(i==="async-blocker"||i==="async-blocker-prepend")&&(e[0].execute(),e.splice(0,1));});}unblockAudio(e){if(this.queues===null)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio");}executeNext(e){if(this.queues===null||this.tracks===null)return;let t=this.queues[e];if(t.length){let r=t[0];try{r.execute();}catch(n){var i;if(r.onError(n),this.queues===null||this.tracks===null)return;let a=(i=this.tracks[e])==null?void 0:i.buffer;a!=null&&a.updating||this.shiftAndExecuteNext(e);}}}shiftAndExecuteNext(e){this.queues!==null&&(this.queues[e].shift(),this.executeNext(e));}current(e){var t;return ((t=this.queues)==null?void 0:t[e][0])||null}toString(){let{queues:e,tracks:t}=this;return e===null||t===null?"<destroyed>":`
|
|
1502
1478
|
${this.list("video")}
|
|
1503
1479
|
${this.list("audio")}
|
|
1504
|
-
${this.list("audiovideo")}}`}list(e){var t,i;return (t=this.queues)!=null&&t[e]||(i=this.tracks)!=null&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;let i=(t=this.tracks)==null?void 0:t[e],r=i?.buffer;return r?`SourceBuffer${r.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(e){var t;return ((t=this.queues)==null?void 0:t[e].map(i=>i.label).join(", "))||""}},
|
|
1505
|
-
required tracks: ${Ae(i,(l
|
|
1506
|
-
transfer tracks: ${Ae(r,(l,d)=>l==="initSegment"?void 0:d)}}`),!Yg(r,i)){t.mediaSource=null,t.tracks=void 0;let l=e.currentTime,d=this.details,c=Math.max(l,d?.fragments[0].start||0);if(c-l>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${l} -> ${c}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(r)}"->"${Object.keys(i)}") start time: ${c} currentTime: ${l}`),this.onMediaDetaching(p.MEDIA_DETACHING,{}),this.onMediaAttaching(p.MEDIA_ATTACHING,t),e.currentTime=c;return}this.transferData=void 0,n.forEach(l=>{let d=l,c=r[d];if(c){let u=c.buffer;if(u){let h=this.fragmentTracker,f=c.id;if(h.hasFragments(f)||h.hasParts(f)){let E=ne.getBuffered(u);h.detectEvictedFragments(d,E,f,null,true);}let m=Ec(d),g=[d,u];this.sourceBuffers[m]=g,u.updating&&this.operationQueue&&this.operationQueue.prependBlocker(d),this.trackSourceBuffer(d,c);}}}),o(),this.bufferCreated();}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o();}get mediaSourceOpenOrEnded(){var e;let t=(e=this.mediaSource)==null?void 0:e.readyState;return t==="open"||t==="ended"}onMediaDetaching(e,t){let i=!!t.transferMedia;this.transferData=this.overrides=void 0;let{media:r,mediaSource:n,_objectUrl:a}=this;if(n){if(this.log(`media source ${i?"transferring":"detaching"}`),i)this.sourceBuffers.forEach(([o])=>{o&&this.removeBuffer(o);}),this.resetQueue();else {if(this.mediaSourceOpenOrEnded){let o=n.readyState==="open";try{let l=n.sourceBuffers;for(let d=l.length;d--;)o&&l[d].abort(),n.removeSourceBuffer(l[d]);o&&n.endOfStream();}catch(l){this.warn(`onMediaDetaching: ${l.message} while calling endOfStream`);}}this.sourceBufferCount&&this.onBufferReset();}n.removeEventListener("sourceopen",this._onMediaSourceOpen),n.removeEventListener("sourceended",this._onMediaSourceEnded),n.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(n.removeEventListener("startstreaming",this._onStartStreaming),n.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null;}r&&(r.removeEventListener("emptied",this._onMediaEmptied),i||(a&&self.URL.revokeObjectURL(a),this.mediaSrc===a?(r.removeAttribute("src"),this.appendSource&&Rg(r),r.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(p.MEDIA_DETACHED,t);}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e);}),this.initTracks();}resetBuffer(e){var t;let i=(t=this.tracks[e])==null?void 0:t.buffer;if(this.removeBuffer(e),i)try{var r;(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i);}catch(n){this.warn(`onBufferReset ${e}`,n);}delete this.tracks[e];}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[Ec(e)]=[null,null];let t=this.tracks[e];t&&(t.buffer=void 0);}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new cu(this.tracks);}onBufferCodecs(e,t){var i;let r=this.tracks,n=Object.keys(t);this.log(`BUFFER_CODECS: "${n}" (current SB count ${this.sourceBufferCount})`);let a="audiovideo"in t&&(r.audio||r.video)||r.audiovideo&&("audio"in t||"video"in t),o=!a&&this.sourceBufferCount&&this.media&&n.some(l=>!r[l]);if(a||o){this.warn(`Unsupported transition between "${Object.keys(r)}" and "${n}" SourceBuffers`);return}n.forEach(l=>{var d,c;let u=t[l],{id:h,codec:f,levelCodec:m,container:g,metadata:E,supplemental:v}=u,y=r[l],S=(d=this.transferData)==null||(d=d.tracks)==null?void 0:d[l],b=S!=null&&S.buffer?S:y,_=b?.pendingCodec||b?.codec,D=b?.levelCodec;y||(y=r[l]={buffer:void 0,listeners:[],codec:f,supplemental:v,container:g,levelCodec:m,metadata:E,id:h});let I=qo(_,D),k=I?.replace(xg,"$1"),R=qo(f,m),L=(c=R)==null?void 0:c.replace(xg,"$1");R&&I&&k!==L&&(l.slice(0,5)==="audio"&&(R=il(R,this.appendSource)),this.log(`switching codec ${_} to ${R}`),R!==(y.pendingCodec||y.codec)&&(y.pendingCodec=R),y.container=g,this.appendChangeType(l,g,R));}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&((i=t.audio)==null?void 0:i.id)==="main"&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks());}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{let i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}appendChangeType(e,t,i){let r=`${t};codecs=${i}`,n={label:`change-type=${r}`,execute:()=>{let a=this.tracks[e];if(a){let o=a.buffer;o!=null&&o.changeType&&(this.log(`changing ${e} sourceBuffer type to ${r}`),o.changeType(r),a.codec=i,a.container=t);}this.shiftAndExecuteNext(e);},onStart:()=>{},onComplete:()=>{},onError:a=>{this.warn(`Failed to change ${e} SourceBuffer type`,a);}};this.append(n,e,this.isPending(this.tracks[e]));}blockAudio(e){var t;let i=e.start,r=i+e.duration*.05;if(((t=this.fragmentTracker.getAppendedFrag(i,W.MAIN))==null?void 0:t.gap)===true)return;let a={label:"block-audio",execute:()=>{var o;let l=this.tracks.video;(this.lastVideoAppendEnd>r||l!=null&&l.buffer&&ne.isBuffered(l.buffer,r)||((o=this.fragmentTracker.getAppendedFrag(r,W.MAIN))==null?void 0:o.gap)===true)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"));},onStart:()=>{},onComplete:()=>{},onError:o=>{this.warn("Error executing block-audio operation",o);}};this.blockedAudioAppend={op:a,frag:e},this.append(a,"audio",true);}unblockAudio(){let{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op));}onBufferAppending(e,t){let{tracks:i}=this,{data:r,type:n,parent:a,frag:o,part:l,chunkMeta:d,offset:c}=t,u=d.buffering[n],{sn:h,cc:f}=o,m=self.performance.now();u.start=m;let g=o.stats.buffering,E=l?l.stats.buffering:null;g.start===0&&(g.start=m),E&&E.start===0&&(E.start=m);let v=i.audio,y=false;n==="audio"&&v?.container==="audio/mpeg"&&(y=!this.lastMpegAudioChunk||d.id===1||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);let S=i.video,b=S?.buffer;if(b&&h!=="initSegment"){let I=l||o,k=this.blockedAudioAppend;if(n==="audio"&&a!=="main"&&!this.blockedAudioAppend&&!(S.ending||S.ended)){let L=I.start+I.duration*.05,M=b.buffered,$=this.currentOp("video");!M.length&&!$?this.blockAudio(I):!$&&!ne.isBuffered(b,L)&&this.lastVideoAppendEnd<L&&this.blockAudio(I);}else if(n==="video"){let R=I.end;if(k){let L=k.frag.start;(R>L||R<this.lastVideoAppendEnd||ne.isBuffered(b,L))&&this.unblockAudio();}this.lastVideoAppendEnd=R;}}let _=(l||o).start,D={label:`append-${n}`,execute:()=>{var I;u.executeStart=self.performance.now();let k=(I=this.tracks[n])==null?void 0:I.buffer;k&&(y?this.updateTimestampOffset(k,_,.1,n,h,f):c!==void 0&&H(c)&&this.updateTimestampOffset(k,c,1e-6,n,h,f)),this.appendExecutor(r,n);},onStart:()=>{},onComplete:()=>{let I=self.performance.now();u.executeEnd=u.end=I,g.first===0&&(g.first=I),E&&E.first===0&&(E.first=I);let k={};this.sourceBuffers.forEach(([R,L])=>{R&&(k[R]=ne.getBuffered(L));}),this.appendErrors[n]=0,n==="audio"||n==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(p.BUFFER_APPENDED,{type:n,frag:o,part:l,chunkMeta:d,parent:o.type,timeRanges:k});},onError:I=>{var k;let R={type:z.MEDIA_ERROR,parent:o.type,details:x.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:o,part:l,chunkMeta:d,error:I,err:I,fatal:false},L=(k=this.media)==null?void 0:k.error;if(I.code===DOMException.QUOTA_EXCEEDED_ERR||I.name=="QuotaExceededError"||"quota"in I)R.details=x.BUFFER_FULL_ERROR;else if(I.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!L)R.errorAction=ur(true);else if(I.name===Vp&&this.sourceBufferCount===0)R.errorAction=ur(true);else {let M=++this.appendErrors[n];this.warn(`Failed ${M}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${n}" sourceBuffer (${L||"no media error"})`),(M>=this.hls.config.appendErrorMaxRetry||L)&&(R.fatal=true);}this.hls.trigger(p.ERROR,R);}};this.log(`queuing "${n}" append sn: ${h}${l?" p: "+l.index:""} of ${o.type===W.MAIN?"level":"track"} ${o.level} cc: ${f}`),this.append(D,n,this.isPending(this.tracks[n]));}getFlushOp(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i);},onStart:()=>{},onComplete:()=>{this.hls.trigger(p.BUFFER_FLUSHED,{type:e});},onError:r=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,r);}}}onBufferFlushing(e,t){let{type:i,startOffset:r,endOffset:n}=t;i?this.append(this.getFlushOp(i,r,n),i):this.sourceBuffers.forEach(([a])=>{a&&this.append(this.getFlushOp(a,r,n),a);});}onFragParsed(e,t){let{frag:i,part:r}=t,n=[],a=r?r.elementaryStreams:i.elementaryStreams;a[be.AUDIOVIDEO]?n.push("audiovideo"):(a[be.AUDIO]&&n.push("audio"),a[be.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).catch(l=>{this.warn(`Fragment buffered callback ${l}`),this.stepOperationQueue(this.sourceBufferTypes);});}onFragChanged(e,t){this.trimBuffers();}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){let t=this.tracks[e];if(t)return !t.ended||t.ending}return false})}onBufferEos(e,t){var i;this.sourceBuffers.forEach(([a])=>{if(a){let o=this.tracks[a];(!t.type||t.type===a)&&(o.ending=true,o.ended||(o.ended=true,this.log(`${a} buffer reached EOS`)));}});let r=((i=this.overrides)==null?void 0:i.endOfStream)!==false;this.sourceBufferCount>0&&!this.sourceBuffers.some(([a])=>{var o;return a&&!((o=this.tracks[a])!=null&&o.ended)})?r?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();let{mediaSource:a}=this;if(!a||a.readyState!=="open"){a&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${a.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),a.endOfStream(),this.hls.trigger(p.BUFFERED_TO_END,void 0);})):(this.tracksEnded(),this.hls.trigger(p.BUFFERED_TO_END,void 0)):t.type==="video"&&this.unblockAudio();}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(e!==null){let t=this.tracks[e];t&&(t.ending=false);}});}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration());}updateDuration(){this.blockUntilOpen(()=>{let e=this.getDurationAndRange();e&&this.updateMediaSource(e);});}onError(e,t){if(t.details===x.BUFFER_APPEND_ERROR&&t.frag){var i;let r=(i=t.errorAction)==null?void 0:i.nextAutoLevel;H(r)&&r!==t.frag.level&&this.resetAppendErrors();}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0};}trimBuffers(){let{hls:e,details:t,media:i}=this;if(!i||t===null||!this.sourceBufferCount)return;let r=e.config,n=i.currentTime,a=t.levelTargetDuration,o=t.live&&r.liveBackBufferLength!==null?r.liveBackBufferLength:r.backBufferLength;if(H(o)&&o>=0){let d=Math.max(o,a),c=Math.floor(n/a)*a-d;this.flushBackBuffer(n,a,c);}let l=r.frontBufferFlushThreshold;if(H(l)&&l>0){let d=Math.max(r.maxBufferLength,l),c=Math.max(d,a),u=Math.floor(n/a)*a+c;this.flushFrontBuffer(n,a,u);}}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([r,n])=>{if(n){let o=ne.getBuffered(n);if(o.length>0&&i>o.start(0)){var a;this.hls.trigger(p.BACK_BUFFER_REACHED,{bufferEnd:i});let l=this.tracks[r];if((a=this.details)!=null&&a.live)this.hls.trigger(p.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(l!=null&&l.ended){this.log(`Cannot flush ${r} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:r});}}});}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([r,n])=>{if(n){let a=ne.getBuffered(n),o=a.length;if(o<2)return;let l=a.start(o-1),d=a.end(o-1);if(i>l||e>=l&&e<=d)return;this.hls.trigger(p.BUFFER_FLUSHING,{startOffset:l,endOffset:1/0,type:r});}});}getDurationAndRange(){var e;let{details:t,mediaSource:i}=this;if(!t||!this.media||i?.readyState!=="open")return null;let r=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){let d=Math.max(0,t.fragmentStart),c=Math.max(d,r);return {duration:1/0,start:d,end:c}}return {duration:1/0}}let n=(e=this.overrides)==null?void 0:e.duration;if(n)return H(n)?{duration:n}:null;let a=this.media.duration,o=H(i.duration)?i.duration:0;return r>o&&r>a||!H(a)?{duration:r}:null}updateMediaSource({duration:e,start:t,end:i}){let r=this.mediaSource;!this.media||!r||r.readyState!=="open"||(r.duration!==e&&(H(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),r.duration=e),t!==void 0&&i!==void 0&&(this.log(`MediaSource duration is set to ${r.duration}. Setting seekable range to ${t}-${i}.`),r.setLiveSeekableRange(t,i)));}get tracksReady(){let e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){let{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:i}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${Ae(i)}`),this.tracksReady){var r;let n=(r=this.transferData)==null?void 0:r.tracks;n&&Object.keys(n).length?this.attachTransferred():this.createSourceBuffers();}}bufferCreated(){if(this.sourceBufferCount){let e={};this.sourceBuffers.forEach(([t,i])=>{if(t){let r=this.tracks[t];e[t]={buffer:i,container:r.container,codec:r.codec,supplemental:r.supplemental,levelCodec:r.levelCodec,id:r.id,metadata:r.metadata};}}),this.hls.trigger(p.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([t])=>{this.executeNext(t);});}else {let e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(p.ERROR,{type:z.MEDIA_ERROR,details:x.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:true,error:e,reason:e.message});}}createSourceBuffers(){let{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(let n in e){let a=n,o=e[a];if(this.isPending(o)){let l=this.getTrackCodec(o,a),d=`${o.container};codecs=${l}`;o.codec=l,this.log(`creating sourceBuffer(${d})${this.currentOp(a)?" Queued":""} ${Ae(o)}`);try{let c=i.addSourceBuffer(d),u=Ec(a),h=[a,c];t[u]=h,o.buffer=c;}catch(c){var r;this.error(`error while trying to add sourceBuffer: ${c.message}`),this.shiftAndExecuteNext(a),(r=this.operationQueue)==null||r.removeBlockers(),delete this.tracks[a],this.hls.trigger(p.ERROR,{type:z.MEDIA_ERROR,details:x.BUFFER_ADD_CODEC_ERROR,fatal:false,error:c,sourceBufferName:a,mimeType:d,parent:o.id});return}this.trackSourceBuffer(a,o);}}this.bufferCreated();}getTrackCodec(e,t){let i=e.supplemental,r=e.codec;i&&(t==="video"||t==="audiovideo")&&Rn(i,"video")&&(r=ny(r,i));let n=qo(r,e.levelCodec);return n?t.slice(0,5)==="audio"?il(n,this.appendSource):n:""}trackSourceBuffer(e,t){let i=t.buffer;if(!i)return;let r=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:r,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(n,a)=>{let o=a.removedRanges;o!=null&&o.length&&this.hls.trigger(p.BUFFER_FLUSHED,{type:n});});}get mediaSrc(){var e,t;let i=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return i?.src}onSBUpdateStart(e){let t=this.currentOp(e);t&&t.onStart();}onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}let i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e));}onSBUpdateError(e,t){var i;let r=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(i=this.mediaSource)==null?void 0:i.readyState}`);this.error(`${r}`,t),this.hls.trigger(p.ERROR,{type:z.MEDIA_ERROR,details:x.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:r,fatal:false});let n=this.currentOp(e);n&&n.onError(r);}updateTimestampOffset(e,t,i,r,n,a){let o=t-e.timestampOffset;Math.abs(o)>=i&&(this.log(`Updating ${r} SourceBuffer timestampOffset to ${t} (sn: ${n} cc: ${a})`),e.timestampOffset=t);}removeExecutor(e,t,i){let{media:r,mediaSource:n}=this,a=this.tracks[e],o=a?.buffer;if(!r||!n||!o){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),this.shiftAndExecuteNext(e);return}let l=H(r.duration)?r.duration:1/0,d=H(n.duration)?n.duration:1/0,c=Math.max(0,t),u=Math.min(i,l,d);u>c&&(!a.ending||a.ended)?(a.ended=false,this.log(`Removing [${c},${u}] from the ${e} SourceBuffer`),o.remove(c,u)):this.shiftAndExecuteNext(e);}appendExecutor(e,t){let i=this.tracks[t],r=i?.buffer;if(!r)throw new uu(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=false,i.ended=false,r.appendBuffer(e);}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(t=>{this.warn(`SourceBuffer blocked callback ${t}`),this.stepOperationQueue(this.sourceBufferTypes);});else try{e();}catch(t){this.warn(`Callback run without blocking ${this.operationQueue} ${t}`);}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return !!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);let{operationQueue:i}=this,r=t.map(a=>this.appendBlocker(a));return t.length>1&&this.blockedAudioAppend&&this.unblockAudio(),Promise.all(r).then(a=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes));})}stepOperationQueue(e){e.forEach(t=>{var i;let r=(i=this.tracks[t])==null?void 0:i.buffer;!r||r.updating||this.shiftAndExecuteNext(t);});}append(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i);}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e);}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e);}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,i){let r=this.tracks[e];if(!r)return;let n=r.buffer;if(!n)return;let a=i.bind(this,e);r.listeners.push({event:t,listener:a}),n.addEventListener(t,a);}removeBufferListeners(e){let t=this.tracks[e];if(!t)return;let i=t.buffer;i&&(t.listeners.forEach(r=>{i.removeEventListener(r.event,r.listener);}),t.listeners.length=0);}};function Rg(s){let e=s.querySelectorAll("source");[].slice.call(e).forEach(t=>{s.removeChild(t);});}function YS(s,e){let t=self.document.createElement("source");t.type="video/mp4",t.src=e,s.appendChild(t);}function Ec(s){return s==="audio"?1:0}var fu=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&&H(this.autoLevelCapping)&&this.detectPlayerSize();}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping();}onMediaDetaching(){this.stopCapping(),this.media=null;}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}let e=this.hls.levels;if(e.length){let t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping;}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return -1;let i=t.filter((r,n)=>this.isLevelAllowed(r)&&n<=e);return this.clientRect=null,s.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize());}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0);}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0);}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio;}catch{}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return !this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return -1;let r=(o,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}},qS={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},ut=qS,jS={HLS:"h"},zS=jS,_i=class s{constructor(e,t){Array.isArray(e)&&(e=e.map(i=>i instanceof s?i:new s(i))),this.value=e,this.params=t;}},QS="Dict";function XS(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 ZS(s,e,t,i){return new Error(`failed to ${s} "${XS(e)}" as ${t}`,{cause:i})}function gi(s,e,t){return ZS("serialize",s,e,t)}var vl=class{constructor(e){this.description=e;}},kg="Bare Item",JS="Boolean";function eb(s){if(typeof s!="boolean")throw gi(s,JS);return s?"?1":"?0"}function tb(s){return btoa(String.fromCharCode(...s))}var ib="Byte Sequence";function sb(s){if(ArrayBuffer.isView(s)===false)throw gi(s,ib);return `:${tb(s)}:`}var rb="Integer";function nb(s){return s<-999999999999999||999999999999999<s}function Wp(s){if(nb(s))throw gi(s,rb);return s.toString()}function ab(s){return `@${Wp(s.getTime()/1e3)}`}function Yp(s,e){if(s<0)return -Yp(-s,e);let t=Math.pow(10,e);if(Math.abs(s*t%1-.5)<Number.EPSILON){let r=Math.floor(s*t);return (r%2===0?r:r+1)/t}else return Math.round(s*t)/t}var ob="Decimal";function lb(s){let e=Yp(s,3);if(Math.floor(Math.abs(e)).toString().length>12)throw gi(s,ob);let t=e.toString();return t.includes(".")?t:`${t}.0`}var db="String",cb=/[\x00-\x1f\x7f]+/;function ub(s){if(cb.test(s))throw gi(s,db);return `"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function hb(s){return s.description||s.toString().slice(7,-1)}var fb="Token";function Dg(s){let e=hb(s);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===false)throw gi(e,fb);return e}function mu(s){switch(typeof s){case "number":if(!H(s))throw gi(s,kg);return Number.isInteger(s)?Wp(s):lb(s);case "string":return ub(s);case "symbol":return Dg(s);case "boolean":return eb(s);case "object":if(s instanceof Date)return ab(s);if(s instanceof Uint8Array)return sb(s);if(s instanceof vl)return Dg(s);default:throw gi(s,kg)}}var mb="Key";function gu(s){if(/^[a-z*][a-z0-9\-_.*]*$/.test(s)===false)throw gi(s,mb);return s}function ah(s){return s==null?"":Object.entries(s).map(([e,t])=>t===true?`;${gu(e)}`:`;${gu(e)}=${mu(t)}`).join("")}function qp(s){return s instanceof _i?`${mu(s.value)}${ah(s.params)}`:mu(s)}function gb(s){return `(${s.value.map(qp).join(" ")})${ah(s.params)}`}function pb(s,e={whitespace:true}){if(typeof s!="object"||s==null)throw gi(s,QS);let t=s instanceof Map?s.entries():Object.entries(s),i=e?.whitespace?" ":"";return Array.from(t).map(([r,n])=>{n instanceof _i||(n=new _i(n));let a=gu(r);return n.value===true?a+=ah(n.params):(a+="=",Array.isArray(n.value)?a+=gb(n):a+=qp(n)),a}).join(`,${i}`)}function jp(s,e){return pb(s,e)}var ui="CMCD-Object",Pe="CMCD-Request",ls="CMCD-Session",Ui="CMCD-Status",Eb={br:ui,ab:ui,d:ui,ot:ui,tb:ui,tpb:ui,lb:ui,tab:ui,lab:ui,url:ui,pb:Pe,bl:Pe,tbl:Pe,dl:Pe,ltc:Pe,mtp:Pe,nor:Pe,nrr:Pe,rc:Pe,sn:Pe,sta:Pe,su:Pe,ttfb:Pe,ttfbb:Pe,ttlb:Pe,cmsdd:Pe,cmsds:Pe,smrt:Pe,df:Pe,cs:Pe,ts:Pe,cid:ls,pr:ls,sf:ls,sid:ls,st:ls,v:ls,msd:ls,bs:Ui,bsd:Ui,cdn:Ui,rtp:Ui,bg:Ui,pt:Ui,ec:Ui,e:Ui},vb={REQUEST:Pe};function Tb(s){return Object.keys(s).reduce((e,t)=>{var i;return (i=s[t])===null||i===void 0||i.forEach(r=>e[r]=t),e},{})}function yb(s,e){let t={};if(!s)return t;let i=Object.keys(s),r=e?Tb(e):{};return i.reduce((n,a)=>{var o;let l=Eb[a]||r[a]||vb.REQUEST,d=(o=n[l])!==null&&o!==void 0?o:n[l]={};return d[a]=s[a],n},t)}function Sb(s){return ["ot","sf","st","e","sta"].includes(s)}function bb(s){return typeof s=="number"?H(s):s!=null&&s!==""&&s!==false}var zp="event";function Ab(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("/")+t.search+t.hash}var Xo=s=>Math.round(s),pu=(s,e)=>Array.isArray(s)?s.map(t=>pu(t,e)):s instanceof _i&&typeof s.value=="string"?new _i(pu(s.value,e),s.params):(e.baseUrl&&(s=Ab(s,e.baseUrl)),e.version===1?encodeURIComponent(s):s),$o=s=>Xo(s/100)*100,_b=(s,e)=>{let t=s;return e.version>=2&&(s instanceof _i&&typeof s.value=="string"?t=new _i([s]):typeof s=="string"&&(t=[s])),pu(t,e)},Ib={br:Xo,d:Xo,bl:$o,dl:$o,mtp:$o,nor:_b,rtp:$o,tb:Xo},Qp="request",Xp="response",oh=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],Lb=["e"],xb=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function Rl(s){return xb.test(s)}function Rb(s){return oh.includes(s)||Lb.includes(s)||Rl(s)}var Zp=["d","dl","nor","ot","rtp","su"];function kb(s){return oh.includes(s)||Zp.includes(s)||Rl(s)}var Db=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];function Cb(s){return oh.includes(s)||Zp.includes(s)||Db.includes(s)||Rl(s)}var Mb=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function wb(s){return Mb.includes(s)||Rl(s)}var Pb={[Xp]:Cb,[zp]:Rb,[Qp]:kb};function Jp(s,e={}){let t={};if(s==null||typeof s!="object")return t;let i=e.version||s.v||1,r=e.reportingMode||Qp,n=i===1?wb:Pb[r],a=Object.keys(s).filter(n),o=e.filter;typeof o=="function"&&(a=a.filter(o));let l=r===Xp||r===zp;l&&!a.includes("ts")&&a.push("ts"),i>1&&!a.includes("v")&&a.push("v");let d=Se({},Ib,e.formatters),c={version:i,reportingMode:r,baseUrl:e.baseUrl};return a.sort().forEach(u=>{let h=s[u],f=d[u];if(typeof f=="function"&&(h=f(h,c)),u==="v"){if(i===1)return;h=i;}u=="pr"&&h===1||(l&&u==="ts"&&!H(h)&&(h=Date.now()),bb(h)&&(Sb(u)&&typeof h=="string"&&(h=new vl(h)),t[u]=h));}),t}function Ob(s,e={}){let t={};if(!s)return t;let i=Jp(s,e),r=yb(i,e?.customHeaderMap);return Object.entries(r).reduce((n,[a,o])=>{let l=jp(o,{whitespace:false});return l&&(n[a]=l),n},t)}function Fb(s,e,t){return Se(s,Ob(e,t))}var Ub="CMCD";function Nb(s,e={}){return s?jp(Jp(s,e),{whitespace:false}):""}function Bb(s,e={}){if(!s)return "";let t=Nb(s,e);return encodeURIComponent(t)}function $b(s,e={}){if(!s)return "";let t=Bb(s,e);return `${Ub}=${t}`}var Cg=/CMCD=[^&#]+/;function Gb(s,e,t){let i=$b(e,t);if(!i)return s;if(Cg.test(s))return s.replace(Cg,i);let r=s.includes("?")?"&":"?";return `${s}${r}${i}`}var Eu=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=false,this.includeKeys=void 0,this.initialized=false,this.starved=false,this.buffering=true,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=true),this.buffering=true;},this.onPlaying=()=>{this.initialized||(this.initialized=true),this.buffering=false;},this.applyPlaylistData=r=>{try{this.apply(r,{ot:ut.MANIFEST,su:!this.initialized});}catch(n){this.hls.logger.warn("Could not generate manifest CMCD data.",n);}},this.applyFragmentData=r=>{try{let{frag:n,part:a}=r,o=this.hls.levels[n.level],l=this.getObjectType(n),d={d:(a||n).duration*1e3,ot:l};(l===ut.VIDEO||l===ut.AUDIO||l==ut.MUXED)&&(d.br=o.bitrate/1e3,d.tb=this.getTopBandwidth(l)/1e3,d.bl=this.getBufferLength(l));let c=a?this.getNextPart(a):this.getNextFrag(n);c!=null&&c.url&&c.url!==n.url&&(d.nor=c.url),this.apply(r,d);}catch(n){this.hls.logger.warn("Could not generate segment CMCD data.",n);}},this.hls=e;let t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||e.sessionId,this.cid=i.contentId,this.useHeaders=i.useHeaders===true,this.includeKeys=i.includeKeys,this.registerListeners());}registerListeners(){let e=this.hls;e.on(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=this.media=null;}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying);}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null);}onBufferCreated(e,t){var i,r;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer;}createData(){var e;return {v:1,sf:zS.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Se(t,this.createData());let i=t.ot===ut.INIT||t.ot===ut.VIDEO||t.ot===ut.MUXED;this.starved&&i&&(t.bs=true,t.su=true,this.starved=false),t.su==null&&(t.su=this.buffering);let{includeKeys:r}=this;r&&(t=Object.keys(t).reduce((a,o)=>(r.includes(o)&&(a[o]=t[o]),a),{}));let n={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),Fb(e.headers,t,n)):e.url=Gb(e.url,t,n);}getNextFrag(e){var t;let i=(t=this.hls.levels[e.level])==null?void 0:t.details;if(i){let r=e.sn-i.startSN;return i.fragments[r+1]}}getNextPart(e){var t;let{index:i,fragment:r}=e,n=(t=this.hls.levels[r.level])==null||(t=t.details)==null?void 0:t.partList;if(n){let{sn:a}=r;for(let o=n.length-1;o>=0;o--){let l=n[o];if(l.index===i&&l.fragment.sn===a)return n[o+1]}}}getObjectType(e){let{type:t}=e;if(t==="subtitle")return ut.TIMED_TEXT;if(e.sn==="initSegment")return ut.INIT;if(t==="audio")return ut.AUDIO;if(t==="main")return this.hls.audioTracks.length?ut.VIDEO:ut.MUXED}getTopBandwidth(e){let t=0,i,r=this.hls;if(e===ut.AUDIO)i=r.audioTracks;else {let n=r.maxAutoLevel,a=n>-1?n+1:r.levels.length;i=r.levels.slice(0,a);}return i.forEach(n=>{n.bitrate>t&&(t=n.bitrate);}),t>0?t:NaN}getBufferLength(e){let t=this.media,i=e===ut.AUDIO?this.audioBuffer:this.videoBuffer;return !i||!t?NaN:ne.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n);}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy();}abort(){this.loader.abort();}load(n,a,o){t(n),this.loader.load(n,a,o);}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n);}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy();}abort(){this.loader.abort();}load(n,a,o){t(n),this.loader.load(n,a,o);}}}},Hb=3e5,vu=class extends ft{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=false,this.enabled=true,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners();}registerListeners(){let e=this.hls;e.on(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));}pathways(){return (this.levels||[]).reduce((e,t)=>(e.indexOf(t.pathwayId)===-1&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e);}startLoad(){if(this.started=true,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){let e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri);}}stopLoad(){this.started=false,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout();}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1);}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null;}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(i=>i!==e));}onManifestLoading(){this.stopLoad(),this.enabled=true,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null;}onManifestLoaded(e,t){let{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad());}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks;}onError(e,t){let{errorAction:i}=t;if(i?.action===Qe.SendAlternateToPenaltyBox&&i.flags===St.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=this.pathways()),n&&n.length>1&&(this.updatePathwayPriority(n),i.resolved=this.pathwayId!==a),t.details===x.BUFFER_APPEND_ERROR&&!t.fatal?i.resolved=true:i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${r&&r.length} priorities: ${Ae(n)} penalized: ${Ae(this.penalizedPathways)}`);}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i;}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this._pathwayPriority=e;let t,i=this.penalizedPathways,r=performance.now();Object.keys(i).forEach(n=>{r-i[n]>Hb&&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,Ap(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===ue.AUDIO_TRACK&&r[n].hasAudioGroup(e)||t===ue.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 u=new Ce(c.attrs);u["PATHWAY-ID"]=a;let h=u.AUDIO&&`${u.AUDIO}_clone_${a}`,f=u.SUBTITLES&&`${u.SUBTITLES}_clone_${a}`;h&&(i[u.AUDIO]=h,u.AUDIO=h),f&&(r[u.SUBTITLES]=f,u.SUBTITLES=f);let m=e0(c.uri,u["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),g=new ms({attrs:u,audioCodec:c.audioCodec,bitrate:c.bitrate,height:c.height,name:c.name,url:m,videoCodec:c.videoCodec,width:c.width});if(c.audioGroups)for(let 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),Mg(this.audioTracks,i,l,a),Mg(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,u,h,f)=>{this.log(`Loaded steering manifest: "${r}"`);let m=c.data;if(m?.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;let{"RELOAD-URI":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||h.url),E&&this.clonePathways(E);let y={steeringManifest:m,url:r.toString()};this.hls.trigger(p.STEERING_MANIFEST_LOADED,y),v&&this.updatePathwayPriority(v);},onError:(c,u,h,f)=>{if(this.log(`Error loading steering manifest: ${c.code} ${c.text} (${u.url})`),this.stopLoad(),c.code===410){this.enabled=false,this.log(`Steering manifest ${u.url} no longer available`);return}let m=this.timeToLoad*1e3;if(c.code===429){let g=this.loader;if(typeof g?.getResponseHeader=="function"){let E=g.getResponseHeader("Retry-After");E&&(m=parseFloat(E)*1e3);}this.log(`Steering manifest ${u.url} rate limited`);return}this.scheduleRefresh(this.uri||u.url,m);},onTimeout:(c,u,h)=>{this.log(`Timeout loading steering manifest (${u.url})`),this.scheduleRefresh(this.uri||u.url);}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(n,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 Mg(s,e,t,i){s&&Object.keys(e).forEach(r=>{let n=s.filter(a=>a.groupId===r).map(a=>{let o=Se({},a);return o.details=void 0,o.attrs=new Ce(o.attrs),o.url=o.attrs.URI=e0(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 e0(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 Tl=class s extends ft{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=s.CDMCleanupPromise?[s.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=t=>{let{initDataType:i,initData:r}=t,n=`"${t.type}" event: init data type: "${i}"`;if(this.debug(n),r!==null){if(!this.keyFormatPromise){let a=Object.keys(this.keySystemAccessPromises);a.length||(a=bn(this.config));let o=a.map(dc).filter(l=>!!l);this.keyFormatPromise=this.getKeyFormatPromise(o);}this.keyFormatPromise.then(a=>{let o=zo(a);if(i!=="sinf"||o!==Me.FAIRPLAY){this.log(`Ignoring "${t.type}" event with init data type: "${i}" for selected key-system ${o}`);return}let l;try{let f=Ve(new Uint8Array(r)),m=Ju(JSON.parse(f).sinf),g=ep(m);if(!g)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");l=new Uint8Array(g.subarray(8,24));}catch(f){this.warn(`${n} Failed to parse sinf: ${f}`);return}let d=Ze(l),{keyIdToKeySessionPromise:c,mediaKeySessions:u}=this,h=c[d];for(let f=0;f<u.length;f++){let m=u[f],g=m.decryptdata;if(!g.keyId)continue;let E=Ze(g.keyId);if(cl(l,g.keyId)||g.uri.replace(/-/g,"").indexOf(d)!==-1){if(h=c[E],!h)continue;if(g.pssh)break;delete c[E],g.pssh=new Uint8Array(r),g.keyId=l,h=c[d]=h.then(()=>this.generateRequestWithPreferredKeySession(m,i,r,"encrypted-event-key-match")),h.catch(v=>this.handleError(v));break}}h||this.handleError(new Error(`Key ID ${d} not encountered in playlist. Key-system sessions ${u.length}.`));}).catch(a=>this.handleError(a));}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`);},this.hls=e,this.config=e.config,this.registerListeners();}destroy(){this.onDestroying(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=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),this.hls.on(p.DESTROYING,this.onDestroying,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),this.hls.off(p.DESTROYING,this.onDestroying,this);}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:i}=this.config,r=t?.[e];if(r)return r.licenseUrl;if(e===Me.WIDEVINE&&i)return i}getLicenseServerUrlOrThrow(e){let t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){let{drmSystems:t}=this.config,i=t?.[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`);}attemptKeySystemAccess(e){let t=this.hls.levels,i=(a,o,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(u=>a({keySystem:c,mediaKeys:u})).catch(u=>{d.length?l(d):u instanceof nt?o(u):o(new nt({type:z.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_ACCESS,error:u,fatal:true},u.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 gp===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){var r;let n=$y(e,t,i,this.config.drmSystemOptions||{}),a=this.keySystemAccessPromises[e],o=(r=a)==null?void 0:r.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${Ae(n)}`),o=this.requestMediaKeySystemAccess(e,n);let l=a=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(d=>{this.log(`Failed to obtain access to key-system "${e}": ${d}`);}),o.then(d=>{this.log(`Access for key-system "${d.keySystem}" obtained`);let c=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);let u=l.mediaKeys=d.createMediaKeys().then(h=>(this.log(`Media-keys created for "${e}"`),l.hasMediaKeys=true,c.then(f=>f?this.setMediaKeysServerCertificate(h,e,f):h)));return u.catch(h=>{this.error(`Failed to create media-keys for "${e}"}: ${h}`);}),u})}return o.then(()=>a.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${Ze(e.keyId||[])} keyUri: ${e.uri}`);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=Go(t),n="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(i,n,t.pssh.buffer,"expired");}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e);}updateKeySession(e,t){let i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyId ${Ze(e.decryptdata.keyId||[])}
|
|
1507
|
-
} (data length: ${t.byteLength})`),i.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>dc(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t,mediaKeys:i})=>this.attemptSetMediaKeys(t,i))}selectKeySystem(e){return new Promise((t,i)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:r})=>{let n=dc(r);n?t(n):i(new Error(`Unable to find format for key-system "${r}"`));}).catch(i);})}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){let t=bn(this.config),i=e.map(zo).filter(r=>!!r&&t.indexOf(r)!==-1);return this.selectKeySystem(i)}getKeyStatus(e){let{mediaKeySessions:t}=this;for(let i=0;i<t.length;i++){let r=Kb(e,t[i]);if(r)return r}}loadKey(e){let t=e.keyInfo.decryptdata,i=Go(t),r=this.bannedKeyIds[i];if(r||this.getKeyStatus(t)==="internal-error"){let o=wg(r||"internal-error",t);return this.handleError(o,e.frag),Promise.reject(o)}let n=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${n}`);let a=this.keyIdToKeySessionPromise[i];if(!a){let o=this.getKeySystemForKeyPromise(t).then(({keySystem:l,mediaKeys:d})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${n}`),this.attemptSetMediaKeys(l,d).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:l,mediaKeys:d,decryptdata:t}))))).then(l=>{let d="cenc",c=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(l,d,c,"playlist-key")});return o.catch(l=>this.handleError(l,e.frag)),this.keyIdToKeySessionPromise[i]=o,o}return a.catch(o=>{if(o instanceof nt){let l=Te({},o.data);this.getKeyStatus(t)==="internal-error"&&(l.decryptdata=t);let d=new nt(l,o.message);this.handleError(d,e.frag);}}),a}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof nt){t&&(e.data.frag=t);let i=e.data.decryptdata;this.error(`${e.message}${i?` (${Ze(i.keyId||[])})`:""}`),this.hls.trigger(p.ERROR,e.data);}else this.error(e.message),this.hls.trigger(p.ERROR,{type:z.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_KEYS,error:e,fatal:true});}getKeySystemForKeyPromise(e){let t=Go(e),i=this.keyIdToKeySessionPromise[t];if(!i){let r=zo(e.keyFormat),n=r?[r]:bn(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=bn(this.config)),e.length===0)throw new nt({type:z.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:true},`Missing key-system license configuration options ${Ae({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();let i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let r=Promise.all(i).then(()=>this.media?this.media.setMediaKeys(t):new Promise((n,a)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return a(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(n).catch(a);};}));return this.mediaKeys=t,this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>i.indexOf(n)===-1);})}generateRequestWithPreferredKeySession(e,t,i,r){var n;let a=(n=this.config.drmSystems)==null||(n=n[e.keySystem])==null?void 0:n.generateRequest;if(a)try{let m=a.call(this.hls,t,i,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,i=m.initData?m.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null;}catch(m){if(this.warn(m.message),this.hls&&this.hls.config.debug)throw m}if(i===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);let o=Go(e.decryptdata),l=e.decryptdata.uri;this.log(`Generating key-session request for "${r}" keyId: ${o} URI: ${l} (init data type: ${t} length: ${i.byteLength})`);let d=new eh,c=e._onmessage=m=>{let g=e.mediaKeysSession;if(!g){d.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(y=>{d.eventNames().length?d.emit("error",y):this.handleError(y);}):E==="license-release"?e.keySystem===Me.FAIRPLAY&&this.updateKeySession(e,Vc("acknowledged")).then(()=>this.removeSession(e)).catch(y=>this.handleError(y)):this.warn(`unhandled media key message type "${E}"`);},u=(m,g)=>{g.keyStatus=m;let E;m.startsWith("usable")?d.emit("resolved"):m==="internal-error"||m==="output-restricted"||m==="output-downscaled"?E=wg(m,g.decryptdata):m==="expired"?E=new Error(`key expired (keyId: ${o})`):m==="released"?E=new Error("key released"):m==="status-pending"||this.warn(`unhandled key status change "${m}" (keyId: ${o})`),E&&(d.eventNames().length?d.emit("error",E):this.handleError(E));},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){d.emit("error",new Error("invalid state"));return}let E=this.getKeyStatuses(e);if(!Object.keys(E).some(b=>E[b]!=="status-pending"))return;if(E[o]==="expired"){this.log(`Expired key ${Ae(E)} in key-session "${e.mediaKeysSession.sessionId}"`),this.renewKeySession(e);return}let y=E[o];if(y)u(y,e);else {var S;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(S=e.keyStatusTimeouts)[o]||(S[o]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;let _=this.getKeyStatus(e.decryptdata);if(_&&_!=="status-pending")return this.log(`No status for keyId ${o} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${_} from other session.`),u(_,e);this.log(`key status for ${o} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),y="internal-error",u(y,e);},1e3)),this.log(`No status for keyId ${o} (${Ae(E)}).`);}};at(e.mediaKeysSession,"message",c),at(e.mediaKeysSession,"keystatuseschange",h);let f=new Promise((m,g)=>{d.on("error",g),d.on("resolved",m);});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${o} URI: ${l}`);}).catch(m=>{throw new nt({type:z.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_SESSION,error:m,decryptdata:e.decryptdata,fatal:false},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>(d.removeAllListeners(),this.removeSession(e).then(()=>{throw m}))).then(()=>(d.removeAllListeners(),e))}getKeyStatuses(e){let t={};return e.mediaKeysSession.keyStatuses.forEach((i,r)=>{if(typeof r=="string"&&typeof i=="object"){let o=r;r=i,i=o;}let n="buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r);if(e.keySystem===Me.PLAYREADY&&n.length===16){let o=Ze(n);t[o]=i,fp(n);}let a=Ze(n);i==="internal-error"&&(this.bannedKeyIds[a]=i),this.log(`key status change "${i}" for keyStatuses keyId: ${a} key-session "${e.mediaKeysSession.sessionId}"`),t[a]=i;}),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},u={onSuccess:(h,f,m,g)=>{a(h.data);},onError:(h,f,m,g)=>{o(new nt({type:z.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:true,networkDetails:m,response:Te({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`));},onTimeout:(h,f,m)=>{o(new nt({type:z.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:(h,f,m)=>{o(new Error("aborted"));}};r.load(l,c,u);})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((r,n)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),r(e);}).catch(a=>{n(new nt({type:z.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 nt({type:z.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:r,fatal:false},r.message)}))}unpackPlayReadyKeyMessage(e,t){let i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;let r=new DOMParser().parseFromString(i,"application/xml"),n=r.querySelectorAll("HttpHeader");if(n.length>0){let c;for(let u=0,h=n.length;u<h;u++){var a,o;c=n[u];let f=(a=c.querySelector("name"))==null?void 0:a.textContent,m=(o=c.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m);}}let l=r.querySelector("Challenge"),d=l?.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return Vc(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.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${a}`);let o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);let d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e);}catch(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 nt({type:z.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,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==Me.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(l,d)),l.send(d);}).catch(n);})}onDestroying(){this.unregisterListeners(),this._clear();}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let i=t.media;this.media=i,at(i,"encrypted",this.onMediaEncrypted),at(i,"waitingforkey",this.onWaitingForKey);let r=this.mediaResolved;r?r():this.mediaKeys=i.mediaKeys;}onMediaDetached(){let e=this.media;e&&(ht(e,"encrypted",this.onMediaEncrypted),ht(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null);}_clear(){var e;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};let t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;let i=this.media,r=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,pr.clearKeyUriToKeyIdMap();let n=r.length;s.CDMCleanupPromise=Promise.all(r.map(a=>this.removeSession(a)).concat((i==null||(e=i.setMediaKeys(null))==null?void 0:e.catch(a=>{this.log(`Could not clear media keys: ${a}`),this.hls&&this.hls.trigger(p.ERROR,{type:z.OTHER_ERROR,details:x.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:false,error:new Error(`Could not clear media keys: ${a}`)});}))||Promise.resolve())).catch(a=>{this.log(`Could not close sessions and clear media keys: ${a}`),this.hls&&this.hls.trigger(p.ERROR,{type:z.OTHER_ERROR,details:x.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:false,error:new Error(`Could not close sessions and clear media keys: ${a}`)});}).then(()=>{n&&this.log("finished closing key sessions and clearing media keys");});}onManifestLoading(){this._clear();}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,decryptdata:r}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${Ze(r?.keyId||[])}`),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 n=this.mediaKeySessions.indexOf(e);n>-1&&this.mediaKeySessions.splice(n,1);let{keyStatusTimeouts:a}=e;a&&Object.keys(a).forEach(d=>self.clearTimeout(a[d]));let{drmSystemOptions:o}=this.config;return (Hy(o)?new Promise((d,c)=>{self.setTimeout(()=>c(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(d).catch(c);}):Promise.resolve()).catch(d=>{this.log(`Could not remove session: ${d}`),this.hls&&this.hls.trigger(p.ERROR,{type:z.OTHER_ERROR,details:x.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:false,error:new Error(`Could not remove session: ${d}`)});}).then(()=>t.close()).catch(d=>{this.log(`Could not close session: ${d}`),this.hls&&this.hls.trigger(p.ERROR,{type:z.OTHER_ERROR,details:x.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:false,error:new Error(`Could not close session: ${d}`)});})}return Promise.resolve()}};Tl.CDMCleanupPromise=void 0;function Go(s){if(!s)throw new Error("Could not read keyId of undefined decryptdata");if(s.keyId===null)throw new Error("keyId is null");return Ze(s.keyId)}function Kb(s,e){if(s.keyId&&e.mediaKeysSession.keyStatuses.has(s.keyId))return e.mediaKeysSession.keyStatuses.get(s.keyId);if(s.matches(e.decryptdata))return e.keyStatus}var nt=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;}};function wg(s,e){let t=s==="output-restricted",i=t?x.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:x.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new nt({type:z.KEY_SYSTEM_ERROR,details:i,fatal:false,decryptdata:e},t?"HDCP level output restricted":`key status changed to "${s}"`)}var Tu=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),this.hls.on(p.MEDIA_DETACHING,this.onMediaDetaching,this);}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(p.MEDIA_DETACHING,this.onMediaDetaching,this);}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=false,this.media=null;}onMediaAttaching(e,t){let i=this.hls.config;if(i.capLevelOnFPSDrop){let r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=true),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod);}}onMediaDetaching(){this.media=null;}checkFPS(e,t,i){let r=performance.now();if(t){if(this.lastTime){let n=r-this.lastTime,a=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,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;d.logger.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);}};function t0(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 i0(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){ye.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){ye.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${r}`);}}t==="disabled"&&(s.mode=t);}function dr(s,e){let t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues)for(let i=s.cues.length;i--;)e&&s.cues[i].removeEventListener("enter",e),s.removeCue(s.cues[i]);t==="disabled"&&(s.mode=t);}function yu(s,e,t,i){let r=s.mode;if(r==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){let n=Wb(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 Vb(s,e){if(e<=s[0].startTime)return 0;let t=s.length-1;if(e>s[t].endTime)return -1;let i=0,r=t,n;for(;i<=r;)if(n=Math.floor((r+i)/2),e<s[n].startTime)r=n-1;else if(e>s[n].startTime&&i<t)i=n+1;else return n;return s[i].startTime-e<e-s[r].startTime?i:r}function Wb(s,e,t){let i=[],r=Vb(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 Zo(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 Su=class extends Un{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=true,this.queuedDefaultTrack=-1,this.useTextTrackPolling=false,this.subtitlePollingInterval=-1,this._subtitleDisplay=true,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null,i=Zo(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(e,t){let i=this.media;if(!i)return;let r=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,r)return;Zo(i.textTracks).forEach(a=>{dr(a);});}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=true;}onManifestParsed(e,t){this.tracks=t.subtitleTracks;}onSubtitleTrackLoaded(e,t){let{id:i,groupId:r,details:n}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==r){this.warn(`Subtitle track with id:${i} and group:${r} not found in active group ${a?.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Subtitle track ${i} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o);}onLevelLoading(e,t){this.switchLevel(t.level);}onLevelSwitching(e,t){this.switchLevel(t.level);}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let i=t.subtitleGroups||null,r=this.groupIds,n=this.currentTrack;if(!i||r?.length!==i?.length||i!=null&&i.some(a=>r?.indexOf(a)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;let a=this.tracks.filter(c=>!i||i.indexOf(c.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(c=>c.default)&&(this.selectDefaultTrack=false),a.forEach((c,u)=>{c.id=u;});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;let o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=false;let c=mi(o,a);if(c>-1)n=a[c];else {let u=mi(o,this.tracks);n=this.tracks[u];}}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);}}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||hs(n,e)))return r}if(e){for(let r=0;r<t.length;r++){let n=t[r];if(Nn(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){let n=t[r];if(Nn(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(lu(r,e))return i}}return -1}onError(e,t){t.fatal||!t.context||t.context.type===ue.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t);}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=false,this.setSubtitleTrack(e);}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(e.id===-1)return this.setSubtitleTrack(-1),null;let t=this.allSubtitleTracks;if(this.selectDefaultTrack=false,t.length){let i=this.currentTrack;if(i&&hs(e,i))return i;let r=mi(e,this.tracksInGroup);if(r>-1){let n=this.tracksInGroup[r];return this.setSubtitleTrack(r),n}else {if(i)return null;{let n=mi(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e);}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=e.id,r=e.groupId,n=this.getUrlWithDirectives(e.url,t),a=e.details,o=a?.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${n}`),this.hls.trigger(p.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:t||null,track:e});}toggleTrackModes(){let{media:e}=this;if(!e)return;let t=Zo(e.textTracks),i=this.currentTrack,r;if(i&&(r=t.filter(n=>lu(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||!H(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.selectDefaultTrack=false;let i=this.currentTrack,r=t[e]||null;if(this.trackId=e,this.currentTrack=r,this.toggleTrackModes(),!r){this.hls.trigger(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 u=this.switchParams(r.url,i?.details,r.details);this.loadPlaylist(u);}};function Yb(){try{return crypto.randomUUID()}catch{try{let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(r=="x"?n:n&3|8).toString(16)})}}}function In(s){let e=5381,t=s.length;for(;t;)e=e*33^s.charCodeAt(--t);return (e>>>0).toString()}var mr=.025,yl=(function(s){return s[s.Point=0]="Point",s[s.Range=1]="Range",s})({});function qb(s,e,t){return `${s.identifier}-${t+1}-${In(e)}`}var bu=class{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=false,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:false,jump:false},this.snapOptions={out:false,in:false},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e);}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions);}reset(){var e;this.appendInPlaceStarted=false,(e=this.assetListLoader)==null||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null);}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return true;let i=this.playoutLimit;return e<=0||isNaN(i)?false:i===0?true:(((t=this.assetList[e])==null?void 0:t.startOffset)||0)>i}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){let e=this.dateRange.startTime;if(this.snapOptions.out){let t=this.dateRange.tagAnchor;if(t)return vc(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(this.startTime===0||this.snapOptions.out)return true;let e=this.dateRange.tagAnchor;if(e){let t=this.dateRange.startTime,i=vc(t,e);return t-i<.1}return false}get resumptionOffset(){let e=this.resumeOffset,t=H(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){let e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){let t=this.resumeAnchor;if(t)return vc(e,t)}return e}get appendInPlace(){return this.appendInPlaceStarted?true:this.appendInPlaceDisabled?false:!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<mr))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e;}get timelineStart(){return this._timelineStart!==null?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e;}get duration(){let e=this.playoutLimit,t;return this._duration!==null?t=this._duration:this.dateRange.duration?t=this.dateRange.duration:t=this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e;}get cue(){return this.dateRange.cue}get timelineOccupancy(){return this.dateRange.attr["X-TIMELINE-OCCUPIES"]==="RANGE"?yl.Range:yl.Point}get supplementsPrimary(){return this.dateRange.attr["X-TIMELINE-STYLE"]==="PRIMARY"}get contentMayVary(){return this.dateRange.attr["X-CONTENT-MAY-VARY"]!=="NO"}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||this.assetListResponse!==null}toString(){return jb(this)}};function vc(s,e){return s-e.start<e.duration/2&&!(Math.abs(s-(e.start+e.duration))<mr)?e.start:e.start+e.duration}function s0(s,e,t){let i=new self.URL(s,t);return i.protocol!=="data:"&&i.searchParams.set("_HLS_primary_id",e),i}function Tc(s,e){for(;(t=s.assetList[++e])!=null&&t.error;)var t;return e}function jb(s){return `["${s.identifier}" ${s.cue.pre?"<pre>":s.cue.post?"<post>":""}${s.timelineStart.toFixed(2)}-${s.resumeTime.toFixed(2)}]`}function lr(s){let e=s.timelineStart,t=s.duration||0;return `["${s.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}var Au=class{constructor(e,t,i,r){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=false,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(p.PLAYOUT_LIMIT_REACHED,{});};let n=this.hls=new e(t);this.interstitial=i,this.assetItem=r;let a=()=>{this.hasDetails=true;};n.once(p.LEVEL_LOADED,a),n.once(p.AUDIO_TRACK_LOADED,a),n.once(p.SUBTITLE_TRACK_LOADED,a),n.on(p.MEDIA_ATTACHING,(o,{media:l})=>{this.removeMediaListeners(),this.mediaAttached=l,this.interstitial.playoutLimit&&(l.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&n.on(p.BUFFER_APPENDED,()=>{let c=this.bufferedEnd;this.reachedPlayout(c)&&(this._bufferedEosTime=c,n.trigger(p.BUFFERED_TO_END,void 0));}));});}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){let e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,true);else {let t=this.assetItem.uri;try{t=s0(t,e.config.primarySessionId||"").href;}catch{}e.loadSource(t);}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return false;if((t=this.hls)!=null&&t.bufferedToEnd)return true;if(!e)return false;let i=Math.min(this._bufferedEosTime||1/0,this.duration),r=this.timelineOffset,n=ne.bufferInfo(e,r,0);return this.getAssetTime(n.end)>=i-.02}reachedPlayout(e){let i=this.interstitial.playoutLimit;return this.startOffset+e>=i}get destroyed(){var e;return !((e=this.hls)!=null&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return ((e=this.hls)==null?void 0:e.media)||null}get bufferedEnd(){let e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;let t=ne.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){let e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){let e=this.assetItem.duration;if(!e)return 0;let t=this.interstitial.playoutLimit;if(t){let i=t-this.startOffset;if(i>0&&i<e)return i}return e}get remaining(){let e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return ((e=this.hls)==null?void 0:e.config.timelineOffset)||0}set timelineOffset(e){let t=this.timelineOffset;if(e!==t){let i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e;}}}getAssetTime(e){let t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}removeMediaListeners(){let e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout));}bufferSnapShot(){if(this.mediaAttached){var e;(e=this.hls)!=null&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd);}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null;}attachMedia(e){var t;this.loadSource(),(t=this.hls)==null||t.attachMedia(e);}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,(e=this.hls)==null||e.detachMedia();}resumeBuffering(){var e;(e=this.hls)==null||e.resumeBuffering();}pauseBuffering(){var e;(e=this.hls)==null||e.pauseBuffering();}transferMedia(){var e;return this.bufferSnapShot(),((e=this.hls)==null?void 0:e.transferMedia())||null}resetDetails(){let e=this.hls;if(e&&this.hasDetails){e.stopLoad();let t=i=>delete i.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=false;}}on(e,t,i){var r;(r=this.hls)==null||r.on(e,t);}once(e,t,i){var r;(r=this.hls)==null||r.once(e,t);}off(e,t,i){var r;(r=this.hls)==null||r.off(e,t);}toString(){var e;return `HlsAssetPlayer: ${lr(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}},Pg=.033,_u=class extends ft{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e;}destroy(){this.reset(),this.onScheduleUpdate=null;}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null;}resetErrorsInRange(e,t){return this.events?this.events.reduce((i,r)=>e<=r.startOffset&&t>r.startOffset?(delete r.error,i+1):i,0):0}get duration(){let e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);let r=this.items;if(r)for(r[i]||(t===void 0&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&(n=r[i])!=null&&n.event;){var n;i--;}return i}findItemIndexAtTime(e,t){let i=this.items;if(i)for(let r=0;r<i.length;r++){let n=i[r];if(t&&t!=="primary"&&(n=n[t]),e===n.start||e>n.start&&e<n.end)return r}return -1}findJumpRestrictedIndex(e,t){let i=this.items;if(i)for(let r=e;r<=t&&i[r];r++){let n=i[r].event;if(n!=null&&n.restrictions.jump&&!n.appendInPlace)return r}return -1}findEventIndex(e){let t=this.items;if(t)for(let r=t.length;r--;){var i;if(((i=t[r].event)==null?void 0:i.identifier)===e)return r}return -1}findAssetIndex(e,t){let i=e.assetList,r=i.length;if(r>1)for(let n=0;n<r;n++){let a=i[n];if(!a.error){let o=a.timelineStart;if(t===o||t>o&&(t<o+(a.duration||0)||n===r-1))return n}}return 0}get assetIdAtEnd(){var e;let t=(e=this.items)==null||(e=e[this.length-1])==null?void 0:e.event;if(t){let i=t.assetList,r=i[i.length-1];if(r)return r.identifier}return null}parseInterstitialDateRanges(e,t){let i=e.main.details,{dateRanges:r}=i,n=this.events,a=this.parseDateRanges(r,{url:i.url},t),o=Object.keys(r),l=n?n.filter(d=>!o.includes(d.identifier)):[];a.length&&a.sort((d,c)=>{let u=d.cue.pre,h=d.cue.post,f=c.cue.pre,m=c.cue.post;if(u&&!f)return -1;if(f&&!u||h&&!m)return 1;if(m&&!h)return -1;if(!u&&!f&&!h&&!m){let g=d.startTime,E=c.startTime;if(g!==E)return g-E}return d.dateRange.tagOrder-c.dateRange.tagOrder}),this.events=a,l.forEach(d=>{this.removeEvent(d);}),this.updateSchedule(e,l);}updateSchedule(e,t=[],i=false){let r=this.events||[];if(r.length||t.length||this.length<2){let n=this.items,a=this.parseSchedule(r,e);(i||t.length||n?.length!==a.length||a.some((l,d)=>Math.abs(l.playout.start-n[d].playout.start)>.005||Math.abs(l.playout.end-n[d].playout.end)>.005))&&(this.items=a,this.onScheduleUpdate(t,n));}}parseDateRanges(e,t,i){let r=[],n=Object.keys(e);for(let a=0;a<n.length;a++){let o=n[a],l=e[o];if(l.isInterstitial){let d=this.eventMap[o];d?d.setDateRange(l):(d=new bu(l,t),this.eventMap[o]=d,i===false&&(d.appendInPlace=i)),r.push(d);}}return r}parseSchedule(e,t){let i=[],r=t.main.details,n=r.live?1/0:r.edge,a=0;if(e=e.filter(l=>!l.error&&!(l.cue.once&&l.hasPlayed)),e.length){this.resolveOffsets(e,t);let l=0,d=0;if(e.forEach((c,u)=>{let h=c.cue.pre,f=c.cue.post,m=e[u-1]||null,g=c.appendInPlace,E=f?n:c.startOffset,v=c.duration,y=c.timelineOccupancy===yl.Range?v:0,S=c.resumptionOffset,b=m?.startTime===E,_=E+c.cumulativeDuration,D=g?_+v:E+S;if(h||!f&&E<=0){let k=d;d+=y,c.timelineStart=_;let R=a;a+=v,i.push({event:c,start:_,end:D,playout:{start:R,end:a},integrated:{start:k,end:d}});}else if(E<=n){if(!b){let L=E-l;if(L>Pg){let M=l,$=d;d+=L;let K=a;a+=L;let j={previousEvent:e[u-1]||null,nextEvent:c,start:M,end:M+L,playout:{start:K,end:a},integrated:{start:$,end:d}};i.push(j);}else L>0&&m&&(m.cumulativeDuration+=L,i[i.length-1].end=E);}f&&(D=_),c.timelineStart=_;let k=d;d+=y;let R=a;a+=v,i.push({event:c,start:_,end:D,playout:{start:R,end:a},integrated:{start:k,end:d}});}else return;let I=c.resumeTime;f||I>n?l=n:l=I;}),l<n){var o;let c=l,u=d,h=n-l;d+=h;let f=a;a+=h,i.push({previousEvent:((o=i[i.length-1])==null?void 0:o.event)||null,nextEvent:null,start:l,end:c+h,playout:{start:f,end:a},integrated:{start:u,end:d}});}this.setDurations(n,a,d);}else i.push({previousEvent:null,nextEvent:null,start:0,end:n,playout:{start:0,end:n},integrated:{start:0,end:n}}),this.setDurations(n,n,n);return i}setDurations(e,t,i){this.durations={primary:e,playout:t,integrated:i};}resolveOffsets(e,t){let i=t.main.details,r=i.live?1/0:i.edge,n=0,a=-1;e.forEach((o,l)=>{let d=o.cue.pre,c=o.cue.post,u=d?0:c?r:o.startTime;this.updateAssetDurations(o),a===u?o.cumulativeDuration=n:(n=0,a=u),!c&&o.snapOptions.in&&(o.resumeAnchor=gs(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=false)),!o.appendInPlace&&l+1<e.length&&e[l+1].startTime-e[l].resumeTime<Pg&&(e[l+1].appendInPlace=false,e[l+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`));let f=H(o.resumeOffset)?o.resumeOffset:o.duration;n+=f;});}primaryCanResumeInPlaceAt(e,t){let i=e.resumeTime,r=e.startTime+e.resumptionOffset;return Math.abs(i-r)>mr?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${r}`),false):!Object.keys(t).some(a=>{let o=t[a].details,l=o.edge;if(i>=l)return this.log(`"${e.identifier}" resumption ${i} past ${a} playlist end ${l}`),false;let d=gs(null,o.fragments,i);if(!d)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${a} playlist (${o.fragStart}-${o.fragmentEnd})`),true;let c=a==="audio"?.175:0;return Math.abs(d.start-i)<mr+c||Math.abs(d.end-i)<mr+c?false:(this.log(`"${e.identifier}" resumption ${i} not aligned with ${a} fragment bounds (${d.start}-${d.end} sn: ${d.sn} cc: ${d.cc})`),true)})}updateAssetDurations(e){if(!e.assetListLoaded)return;let t=e.timelineStart,i=0,r=false,n=false;for(let a=0;a<e.assetList.length;a++){let o=e.assetList[a],l=t+i;o.startOffset=i,o.timelineStart=l,r||(r=o.duration===null),n||(n=!!o.error);let d=o.error?0:o.duration||0;i+=d;}r&&!n?e.duration=Math.max(i,e.duration):e.duration=i;}removeEvent(e){e.reset(),delete this.eventMap[e.identifier];}};function Ht(s){return `[${s.event?'"'+s.event.identifier+'"':"primary"}: ${s.start.toFixed(2)}-${s.end.toFixed(2)}]`}var Iu=class{constructor(e){this.hls=void 0,this.hls=e;}destroy(){this.hls=null;}loadAssetList(e,t){let i=e.assetListUrl,r;try{r=s0(i,this.hls.sessionId,e.baseUrl);}catch(h){let f=this.assignAssetListError(e,x.ASSET_LIST_LOAD_ERROR,h,i);this.hls.trigger(p.ERROR,f);return}t&&r.protocol!=="data:"&&r.searchParams.set("_HLS_start_offset",""+t);let n=this.hls.config,a=n.loader,o=new a(n),l={responseType:"json",url:r.href},d=n.interstitialAssetListLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,g)=>{let E=h.data,v=E?.ASSETS;if(!Array.isArray(v)){let y=this.assignAssetListError(e,x.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),m.url,f,g);this.hls.trigger(p.ERROR,y);return}e.assetListResponse=E,this.hls.trigger(p.ASSET_LIST_LOADED,{event:e,assetListResponse:E,networkDetails:g});},onError:(h,f,m,g)=>{let E=this.assignAssetListError(e,x.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${h.code} ${h.text} (${f.url})`),f.url,g,m);this.hls.trigger(p.ERROR,E);},onTimeout:(h,f,m)=>{let g=this.assignAssetListError(e,x.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${f.url})`),f.url,h,m);this.hls.trigger(p.ERROR,g);}};return o.load(l,c,u),this.hls.trigger(p.ASSET_LIST_LOADING,{event:e}),o}assignAssetListError(e,t,i,r,n,a){return e.error=i,{type:z.NETWORK_ERROR,details:t,fatal:false,interstitial:e,url:r,error:i,networkDetails:a,stats:n}}};function Og(s){var e;s==null||(e=s.play())==null||e.catch(()=>{});}function Ho(s,e){return `[${s}] Advancing timeline position to ${e}`}var Lu=class extends ft{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=false,this.onPlay=()=>{this.shouldPlay=true;},this.onPause=()=>{this.shouldPlay=false;},this.onSeeking=()=>{let i=this.currentTime;if(i===void 0||this.playbackDisabled||!this.schedule)return;let r=i-this.timelinePos;if(Math.abs(r)<1/7056e5)return;let a=r<=-0.01;this.timelinePos=i,this.bufferedPos=i;let o=this.playingItem;if(!o){this.checkBuffer();return}if(a&&this.schedule.resetErrorsInRange(i,i-r)&&this.updateSchedule(true),this.checkBuffer(),a&&i<o.start||i>=o.end){var l;let f=this.findItemIndex(o),m=this.schedule.findItemIndexAtTime(i);if(m===-1&&(m=f+(a?-1:1),this.log(`seeked ${a?"back ":""}to position not covered by schedule ${i} (resolving from ${f} to ${m})`)),!this.isInterstitial(o)&&(l=this.media)!=null&&l.paused&&(this.shouldPlay=false),!a&&m>f){let g=this.schedule.findJumpRestrictedIndex(f+1,m);if(g>f){this.setSchedulePosition(g);return}}this.setSchedulePosition(m);return}let d=this.playingAsset;if(!d){if(this.playingLastItem&&this.isInterstitial(o)){let f=o.event.assetList[0];f&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,f));}return}let c=d.timelineStart,u=d.duration||0;if(a&&i<c||i>=c+u){var h;(h=o.event)!=null&&h.appendInPlace&&(this.clearAssetPlayers(o.event,o),this.flushFrontBuffer(i)),this.setScheduleToAssetAtTime(i,d);}},this.onTimeupdate=()=>{let i=this.currentTime;if(i===void 0||this.playbackDisabled)return;if(i>this.timelinePos)this.timelinePos=i,i>this.bufferedPos&&this.checkBuffer();else return;let r=this.playingItem;if(!r||this.playingLastItem)return;if(i>=r.end){this.timelinePos=r.end;let o=this.findItemIndex(r);this.setSchedulePosition(o+1);}let n=this.playingAsset;if(!n)return;let a=n.timelineStart+(n.duration||0);i>=a&&this.setScheduleToAssetAtTime(i,n);},this.onScheduleUpdate=(i,r)=>{let n=this.schedule;if(!n)return;let a=this.playingItem,o=n.events||[],l=n.items||[],d=n.durations,c=i.map(g=>g.identifier),u=!!(o.length||c.length);(u||r)&&this.log(`INTERSTITIALS_UPDATED (${o.length}): ${o}
|
|
1508
|
-
Schedule: ${l.map(g=>Ht(g))} pos: ${this.timelinePos}`),c.length&&this.log(`Removed events ${c}`);let h=null,f=null;a&&(h=this.updateItem(a,this.timelinePos),this.itemsMatch(a,h)?this.playingItem=h:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);let m=this.bufferingItem;if(m&&(f=this.updateItem(m,this.bufferedPos),this.itemsMatch(m,f)?this.bufferingItem=f:m.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(m.event,null))),i.forEach(g=>{g.assetList.forEach(E=>{this.clearAssetPlayer(E.identifier,null);});}),this.playerQueue.forEach(g=>{if(g.interstitial.appendInPlace){let E=g.assetItem.timelineStart,v=g.timelineOffset-E;if(v)try{g.timelineOffset=E;}catch(y){Math.abs(v)>mr&&this.warn(`${y} ("${g.assetId}" ${g.timelineOffset}->${E})`);}}}),u||r){if(this.hls.trigger(p.INTERSTITIALS_UPDATED,{events:o.slice(0),schedule:l.slice(0),durations:d,removedIds:c}),this.isInterstitial(a)&&c.includes(a.event.identifier)){this.warn(`Interstitial "${a.event.identifier}" removed while playing`),this.primaryFallback(a.event);return}a&&this.trimInPlace(h,a),m&&f!==h&&this.trimInPlace(f,m),this.checkBuffer();}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new Iu(e),this.schedule=new _u(this.onScheduleUpdate,e.logger),this.registerListeners();}registerListeners(){let e=this.hls;e&&(e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,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_UPDATED,this.onLevelUpdated,this),e.on(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(p.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(p.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(p.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(p.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(p.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(p.BUFFER_APPENDED,this.onBufferAppended,this),e.on(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(p.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(p.MEDIA_ENDED,this.onMediaEnded,this),e.on(p.ERROR,this.onError,this),e.on(p.DESTROYING,this.onDestroying,this));}unregisterListeners(){let e=this.hls;e&&(e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,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_UPDATED,this.onLevelUpdated,this),e.off(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(p.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(p.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(p.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(p.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(p.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(p.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.BUFFER_APPENDED,this.onBufferAppended,this),e.off(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(p.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(p.MEDIA_ENDED,this.onMediaEnded,this),e.off(p.ERROR,this.onError,this),e.off(p.DESTROYING,this.onDestroying,this));}startLoad(){this.resumeBuffering();}stopLoad(){this.pauseBuffering();}resumeBuffering(){var e;(e=this.getBufferingPlayer())==null||e.resumeBuffering();}pauseBuffering(){var e;(e=this.getBufferingPlayer())==null||e.pauseBuffering();}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null;}onDestroying(){let e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e);}removeMediaListeners(e){ht(e,"play",this.onPlay),ht(e,"pause",this.onPause),ht(e,"seeking",this.onSeeking),ht(e,"timeupdate",this.onTimeupdate);}onMediaAttaching(e,t){let i=this.media=t.media;at(i,"seeking",this.onSeeking),at(i,"timeupdate",this.onTimeupdate),at(i,"play",this.onPlay),at(i,"pause",this.onPause);}onMediaAttached(e,t){let i=this.effectivePlayingItem,r=this.detachedData;if(this.detachedData=null,i===null)this.checkStart();else if(!r){this.clearScheduleState();let n=this.findItemIndex(i);this.setSchedulePosition(n);}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null;}onMediaDetaching(e,t){let i=!!t.transferMedia,r=this.media;if(this.media=null,!i&&(r&&this.removeMediaListeners(r),this.detachedData)){let n=this.getBufferingPlayer();n&&(this.log(`Removing schedule state for detachedData and ${n}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,n.detachMedia()),this.shouldPlay=false;}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;let e=this,t=()=>e.bufferingItem||e.waitingItem,i=u=>u&&e.getAssetPlayer(u.identifier),r=(u,h,f,m,g)=>{if(u){let E=u[h].start,v=u.event;if(v){if(h==="playout"||v.timelineOccupancy!==yl.Point){let y=i(f);y?.interstitial===v&&(E+=y.assetItem.startOffset+y[g]);}}else {let y=m==="bufferedPos"?a():e[m];E+=y-u.start;}return E}return 0},n=(u,h)=>{var f;if(u!==0&&h!=="primary"&&(f=e.schedule)!=null&&f.length){var m;let g=e.schedule.findItemIndexAtTime(u),E=(m=e.schedule.items)==null?void 0:m[g];if(E){let v=E[h].start-E.start;return u+v}}return u},a=()=>{let u=e.bufferedPos;return u===Number.MAX_VALUE?o("primary"):Math.max(u,0)},o=u=>{var h,f;return (h=e.primaryDetails)!=null&&h.live?e.primaryDetails.edge:((f=e.schedule)==null?void 0:f.durations[u])||0},l=(u,h)=>{var f,m;let g=e.effectivePlayingItem;if(g!=null&&(f=g.event)!=null&&f.restrictions.skip||!e.schedule)return;e.log(`seek to ${u} "${h}"`);let E=e.effectivePlayingItem,v=e.schedule.findItemIndexAtTime(u,h),y=(m=e.schedule.items)==null?void 0:m[v],S=e.getBufferingPlayer(),b=S?.interstitial,_=b?.appendInPlace,D=E&&e.itemsMatch(E,y);if(E&&(_||D)){let I=i(e.playingAsset),k=I?.media||e.primaryMedia;if(k){let R=h==="primary"?k.currentTime:r(E,h,e.playingAsset,"timelinePos","currentTime"),L=u-R,M=(_?R:k.currentTime)+L;if(M>=0&&(!I||_||M<=I.duration)){k.currentTime=M;return}}}if(y){let I=u;if(h!=="primary"){let R=y[h].start,L=u-R;I=y.start+L;}let k=!e.isInterstitial(y);if((!e.isInterstitial(E)||E.event.appendInPlace)&&(k||y.event.appendInPlace)){let R=e.media||(_?S?.media:null);R&&(R.currentTime=I);}else if(E){let R=e.findItemIndex(E);if(v>R){let M=e.schedule.findJumpRestrictedIndex(R+1,v);if(M>R){e.setSchedulePosition(M);return}}let L=0;if(k)e.timelinePos=I,e.checkBuffer();else {let M=y.event.assetList,$=u-(y[h]||y).start;for(let K=M.length;K--;){let j=M[K];if(j.duration&&$>=j.startOffset&&$<j.startOffset+j.duration){L=K;break}}}e.setSchedulePosition(v,L);}}},d=()=>{let u=e.effectivePlayingItem;if(e.isInterstitial(u))return u;let h=t();return e.isInterstitial(h)?h:null},c={get bufferedEnd(){let u=t(),h=e.bufferingItem;if(h&&h===u){var f;return r(h,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-h.playout.start||((f=e.bufferingAsset)==null?void 0:f.startOffset)||0}return 0},get currentTime(){let u=d(),h=e.effectivePlayingItem;return h&&h===u?r(h,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-h.playout.start:0},set currentTime(u){let h=d(),f=e.effectivePlayingItem;f&&f===h&&l(u+f.playout.start,"playout");},get duration(){let u=d();return u?u.playout.end-u.playout.start:0},get assetPlayers(){var u;let h=(u=d())==null?void 0:u.event.assetList;return h?h.map(f=>e.getAssetPlayer(f.identifier)):[]},get playingIndex(){var u;let h=(u=d())==null?void 0:u.event;return h&&e.effectivePlayingAsset?h.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return d()}};return this.manager={get events(){var u;return ((u=e.schedule)==null||(u=u.events)==null?void 0:u.slice(0))||[]},get schedule(){var u;return ((u=e.schedule)==null||(u=u.items)==null?void 0:u.slice(0))||[]},get interstitialPlayer(){return d()?c:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){let u=t();return e.findItemIndex(u)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){let u=e.effectivePlayingItem;return e.findItemIndex(u)},primary:{get bufferedEnd(){return a()},get currentTime(){let u=e.timelinePos;return u>0?u:0},set currentTime(u){l(u,"primary");},get duration(){return o("primary")},get seekableStart(){var u;return ((u=e.primaryDetails)==null?void 0:u.fragmentStart)||0}},integrated:{get bufferedEnd(){return r(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return r(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(u){l(u,"integrated");},get duration(){return o("integrated")},get seekableStart(){var u;return n(((u=e.primaryDetails)==null?void 0:u.fragmentStart)||0,"integrated")}},skip:()=>{let u=e.effectivePlayingItem,h=u?.event;if(h&&!h.restrictions.skip){let f=e.findItemIndex(u);if(h.appendInPlace){let m=u.playout.start+u.event.duration;l(m+.001,"playout");}else e.advanceAfterAssetEnded(h,f,1/0);}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;let t=this.playingItem,i=(e=this.schedule)==null?void 0:e.items;return !this.playbackStarted||!t||!i?false:this.findItemIndex(t)===i.length-1}get playbackStarted(){return this.effectivePlayingItem!==null}get currentTime(){var e,t;if(this.mediaSelection===null)return;let i=this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&!i.event.appendInPlace)return;let r=this.media;!r&&(e=this.bufferingItem)!=null&&(e=e.event)!=null&&e.appendInPlace&&(r=this.primaryMedia);let n=(t=r)==null?void 0:t.currentTime;if(!(n===void 0||!H(n)))return n}get primaryMedia(){var e;return this.media||((e=this.detachedData)==null?void 0:e.media)||null}isInterstitial(e){return !!(e!=null&&e.event)}retreiveMediaSource(e,t){let i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t);}transferMediaFromPlayer(e,t){let i=e.interstitial.appendInPlace,r=e.media;if(i&&r===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&r){this.detachedData={media:r};return}let n=e.transferMedia();this.log(`transfer MediaSource from ${e} ${Ae(n)}`),this.detachedData=n;}else t&&r&&(this.shouldPlay||(this.shouldPlay=!r.paused));}transferMediaTo(e,t){var i,r;if(e.media===t)return;let n=null,a=this.hls,o=e!==a,l=o&&e.interstitial.appendInPlace,d=(i=this.detachedData)==null?void 0:i.mediaSource,c;if(a.media)l&&(n=a.transferMedia(),this.detachedData=n),c="Primary";else if(d){let m=this.getBufferingPlayer();m?(n=m.transferMedia(),c=`${m}`):c="detached MediaSource";}else c="detached media";if(!n){if(d)n=this.detachedData,this.log(`using detachedData: MediaSource ${Ae(n)}`);else if(!this.detachedData||a.media===t){let m=this.playerQueue;m.length>1&&m.forEach(g=>{if(o&&g.interstitial.appendInPlace!==l){let E=g.interstitial;this.clearInterstitial(g.interstitial,null),E.appendInPlace=false,E.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${E}`);}}),this.hls.detachMedia(),this.detachedData={media:t};}}let u=n&&"mediaSource"in n&&((r=n.mediaSource)==null?void 0:r.readyState)!=="closed",h=u&&n?n:t;this.log(`${u?"transfering MediaSource":"attaching media"} to ${o?e:"Primary"} from ${c} (media.currentTime: ${t.currentTime})`);let f=this.schedule;if(h===n&&f){let m=o&&e.assetId===f.assetIdAtEnd;h.overrides={duration:f.duration,endOfStream:!o||m,cueRemoval:!o};}e.attachMedia(h);}onInterstitialCueEnter(){this.onTimeupdate();}checkStart(){let e=this.schedule,t=e?.events;if(!t||this.playbackDisabled||!this.media)return;this.bufferedPos===-1&&(this.bufferedPos=0);let i=this.timelinePos,r=this.effectivePlayingItem;if(i===-1){let n=this.hls.startPosition;if(this.log(Ho("checkStart",n)),this.timelinePos=n,t.length&&t[0].cue.pre){let a=e.findEventIndex(t[0].identifier);this.setSchedulePosition(a);}else if(n>=0||!this.primaryLive){let a=this.timelinePos=n>0?n:0,o=e.findItemIndexAtTime(a);this.setSchedulePosition(o);}}else if(r&&!this.playingItem){let n=e.findItemIndex(r);this.setSchedulePosition(n);}}advanceAssetBuffering(e,t){let i=e.event,r=i.findAssetIndex(t),n=Tc(i,r);if(!i.isAssetPastPlayoutLimit(n))this.bufferedToEvent(e,n);else if(this.schedule){var a;let o=(a=this.schedule.items)==null?void 0:a[this.findItemIndex(e)+1];o&&this.bufferedToItem(o);}}advanceAfterAssetEnded(e,t,i){let r=Tc(e,i);if(e.isAssetPastPlayoutLimit(r)){if(this.schedule){let n=this.schedule.items;if(n){let a=t+1,o=n.length;if(a>=o){this.setSchedulePosition(-1);return}let l=e.resumeTime;this.timelinePos<l&&(this.log(Ho("advanceAfterAssetEnded",l)),this.timelinePos=l,e.appendInPlace&&this.advanceInPlace(l),this.checkBuffer(this.bufferedPos<l)),this.setSchedulePosition(a);}}}else {if(e.appendInPlace){let n=e.assetList[r];n&&this.advanceInPlace(n.timelineStart);}this.setSchedulePosition(t,r);}}setScheduleToAssetAtTime(e,t){let i=this.schedule;if(!i)return;let r=t.parentIdentifier,n=i.getEvent(r);if(n){let a=i.findEventIndex(r),o=i.findAssetIndex(n,e);this.advanceAfterAssetEnded(n,a,o-1);}}setSchedulePosition(e,t){var i;let r=(i=this.schedule)==null?void 0:i.items;if(!r||this.playbackDisabled)return;let n=e>=0?r[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${n&&Ht(n)}) pos: ${this.timelinePos}`);let a=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(a)){let c=a.event,u=this.playingAsset,h=u?.identifier,f=h?this.getAssetPlayer(h):null;if(f&&h&&(!this.eventItemsMatch(a,n)||t!==void 0&&h!==c.assetList[t].identifier)){var l;let m=c.findAssetIndex(u);if(this.log(`INTERSTITIAL_ASSET_ENDED ${m+1}/${c.assetList.length} ${lr(u)}`),this.endedAsset=u,this.playingAsset=null,this.hls.trigger(p.INTERSTITIAL_ASSET_ENDED,{asset:u,assetListIndex:m,event:c,schedule:r.slice(0),scheduleIndex:e,player:f}),a!==this.playingItem){this.itemsMatch(a,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(c,this.findItemIndex(this.playingItem),m);return}this.retreiveMediaSource(h,n),f.media&&!((l=this.detachedData)!=null&&l.mediaSource)&&f.detachMedia();}if(!this.eventItemsMatch(a,n)&&(this.endedItem=a,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${c} ${Ht(a)}`),c.hasPlayed=true,this.hls.trigger(p.INTERSTITIAL_ENDED,{event:c,schedule:r.slice(0),scheduleIndex:e}),c.cue.once)){var d;this.updateSchedule();let m=(d=this.schedule)==null?void 0:d.items;if(n&&m){let g=this.findItemIndex(n);this.advanceSchedule(g,m,t,a,o);}return}}this.advanceSchedule(e,r,t,a,o);}advanceSchedule(e,t,i,r,n){let a=this.schedule;if(!a)return;let o=t[e]||null,l=this.primaryMedia,d=this.playerQueue;if(d.length&&d.forEach(c=>{let u=c.interstitial,h=a.findEventIndex(u.identifier);(h<e||h>e+1)&&this.clearInterstitial(u,o);}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);let c=o.event;if(i===void 0){i=a.findAssetIndex(c,this.timelinePos);let m=Tc(c,i-1);if(c.isAssetPastPlayoutLimit(m)||c.appendInPlace&&this.timelinePos===o.end){this.advanceAfterAssetEnded(c,e,i);return}i=m;}let u=this.waitingItem;this.assetsBuffered(o,l)||this.setBufferingItem(o);let h=this.preloadAssets(c,i);if(this.eventItemsMatch(o,u||r)||(this.waitingItem=o,this.log(`INTERSTITIAL_STARTED ${Ht(o)} ${c.appendInPlace?"append in place":""}`),this.hls.trigger(p.INTERSTITIAL_STARTED,{event:c,schedule:t.slice(0),scheduleIndex:e})),!c.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${c}`);return}if(c.assetListLoader&&(c.assetListLoader.destroy(),c.assetListLoader=void 0),!l){this.log(`Waiting for attachMedia to start Interstitial ${c}`);return}this.waitingItem=this.endedItem=null,this.playingItem=o;let f=c.assetList[i];if(!f){this.advanceAfterAssetEnded(c,e,i||0);return}if(h||(h=this.getAssetPlayer(f.identifier)),h===null||h.destroyed){let m=c.assetList.length;this.warn(`asset ${i+1}/${m} player destroyed ${c}`),h=this.createAssetPlayer(c,f,i),h.loadSource();}if(!this.eventItemsMatch(o,this.bufferingItem)&&c.appendInPlace&&this.isAssetBuffered(f))return;this.startAssetPlayer(h,i,t,e,l),this.shouldPlay&&Og(h.media);}else o?(this.resumePrimary(o,e,r),this.shouldPlay&&Og(this.hls.media)):n&&this.isInterstitial(r)&&(this.endedItem=null,this.playingItem=r,r.event.appendInPlace||this.attachPrimary(a.durations.primary,null));}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===false}get primaryDetails(){var e;return (e=this.mediaSelection)==null?void 0:e.main.details}get primaryLive(){var e;return !!((e=this.primaryDetails)!=null&&e.live)}resumePrimary(e,t,i){var r,n;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${Ht(e)}`),!((r=this.detachedData)!=null&&r.mediaSource)){let o=this.timelinePos;(o<e.start||o>=e.end)&&(o=this.getPrimaryResumption(e,t),this.log(Ho("resumePrimary",o)),this.timelinePos=o),this.attachPrimary(o,e);}if(!i)return;let a=(n=this.schedule)==null?void 0:n.items;a&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${Ht(e)}`),this.hls.trigger(p.INTERSTITIALS_PRIMARY_RESUMED,{schedule:a.slice(0),scheduleIndex:t}),this.checkBuffer());}getPrimaryResumption(e,t){let i=e.start;if(this.primaryLive){let r=this.primaryDetails;if(t===0)return this.hls.startPosition;if(r&&(i<r.fragmentStart||i>r.edge))return this.hls.liveSyncPosition||-1}return i}isAssetBuffered(e){let t=this.getAssetPlayer(e.identifier);return t!=null&&t.hls?t.hls.bufferedToEnd:ne.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;let r=this.primaryMedia;if(!r)return;let n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,r),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log(Ho("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i));}startLoadingPrimaryAt(e,t){var i;let r=this.hls;!r.loadingEnabled||!r.media||Math.abs((((i=r.mainForwardBufferInfo)==null?void 0:i.start)||r.media.currentTime)-e)>.5?r.startLoad(e,t):r.bufferingEnabled||r.resumeBuffering();}onManifestLoading(){var e;this.stopLoad(),(e=this.schedule)==null||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=false,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(p.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(p.BUFFER_CODECS,this.onBufferCodecs,this);}onLevelUpdated(e,t){if(t.level===-1||!this.schedule)return;let i=this.hls.levels[t.level];if(!i.details)return;let r=Te(Te({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=r,this.schedule.parseInterstitialDateRanges(r,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart();}onAudioTrackUpdated(e,t){let i=this.hls.audioTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=Te(Te({},this.altSelection),{},{audio:i});return}let n=Te(Te({},r),{},{audio:i});this.mediaSelection=n;}onSubtitleTrackUpdated(e,t){let i=this.hls.subtitleTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=Te(Te({},this.altSelection),{},{subtitles:i});return}let n=Te(Te({},r),{},{subtitles:i});this.mediaSelection=n;}onAudioTrackSwitching(e,t){let i=Wm(t);this.playerQueue.forEach(({hls:r})=>r&&(r.setAudioOption(t)||r.setAudioOption(i)));}onSubtitleTrackSwitch(e,t){let i=Wm(t);this.playerQueue.forEach(({hls:r})=>r&&(r.setSubtitleOption(t)||t.id!==-1&&r.setSubtitleOption(i)));}onBufferCodecs(e,t){let i=t.tracks;i&&(this.requiredTracks=i);}onBufferAppended(e,t){this.checkBuffer();}onBufferFlushed(e,t){let i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){let r=this.timelinePos;this.bufferedPos=r,this.checkBuffer();}}onBufferedToEnd(e){if(!this.schedule)return;let t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let r=0;r<t.length;r++){let n=t[r];if(n.cue.post){var i;let a=this.schedule.findEventIndex(n.identifier),o=(i=this.schedule.items)==null?void 0:i[a];this.isInterstitial(o)&&this.eventItemsMatch(o,this.bufferingItem)&&this.bufferedToItem(o,0);break}}this.bufferedPos=Number.MAX_VALUE;}}onMediaEnded(e){let t=this.playingItem;if(!this.playingLastItem&&t){let i=this.findItemIndex(t);this.setSchedulePosition(i+1);}else this.shouldPlay=false;}updateItem(e,t){var i;let r=(i=this.schedule)==null?void 0:i.items;if(e&&r){let n=this.findItemIndex(e,t);return r[n]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((n,a)=>{e.event.isAssetPastPlayoutLimit(a)&&this.clearAssetPlayer(n.identifier,null);});let i=e.end+.25,r=ne.bufferInfo(this.primaryMedia,i,0);(r.end>i||(r.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${Ht(e)} (was ${Ht(t)})`),this.attachPrimary(i,null,true),this.flushFrontBuffer(i));}}itemsMatch(e,t){return !!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var i;return !!t&&(e===t||e.event.identifier===((i=t.event)==null?void 0:i.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=false){var t;let i=this.mediaSelection;i&&((t=this.schedule)==null||t.updateSchedule(i,[],e));}checkBuffer(e){var t;let i=(t=this.schedule)==null?void 0:t.items;if(!i)return;let r=ne.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=r.len<1),this.updateBufferedPos(r.end,i,e);}updateBufferedPos(e,t,i){let r=this.schedule,n=this.bufferingItem;if(this.bufferedPos>e||!r)return;if(t.length===1&&this.itemsMatch(t[0],n)){this.bufferedPos=e;return}let a=this.playingItem,o=this.findItemIndex(a),l=r.findItemIndexAtTime(e);if(this.bufferedPos<e){var d;let c=this.findItemIndex(n),u=Math.min(c+1,t.length-1),h=t[u];if((l===-1&&n&&e>=n.end||(d=h.event)!=null&&d.appendInPlace&&e+.01>=h.start)&&(l=u),this.isInterstitial(n)){let f=n.event;if(u-o>1&&f.appendInPlace===false||f.assetList.length===0&&f.assetListLoader)return}if(this.bufferedPos=e,l>c&&l>o)this.bufferedToItem(h);else {let f=this.primaryDetails;this.primaryLive&&f&&e>f.edge-f.targetduration&&h.start<f.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0);}}else i&&a&&!this.itemsMatch(a,n)&&(l===o?this.bufferedToItem(a):l===o+1&&this.bufferedToItem(t[l]));}assetsBuffered(e,t){return e.event.assetList.length===0?false:!e.event.assetList.some(r=>{let n=this.getAssetPlayer(r.identifier);return !(n!=null&&n.bufferedInPlaceToEnd(t))})}setBufferingItem(e){let t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){let{items:r,events:n}=i;if(!r||!n)return t;let a=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));let l=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${Ht(e)}`+(t?` (${l.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(a){let d=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((c,u)=>{let h=this.getAssetPlayer(c.identifier);h&&(u===d&&h.loadSource(),h.resumeBuffering());});}else this.hls.resumeBuffering(),this.playerQueue.forEach(d=>d.pauseBuffering());this.hls.trigger(p.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:n.slice(0),schedule:r.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)});}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){let i=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(i!==null){this.bufferingAsset=null;let r=this.detachedData;r?r.mediaSource?this.attachPrimary(e.start,e,true):this.preloadPrimary(e):this.preloadPrimary(e);}}}preloadPrimary(e){let t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i);}bufferedToEvent(e,t){let i=e.event,r=i.assetList.length===0&&!i.assetListLoader,n=i.cue.once;if(r||!n){let a=this.preloadAssets(i,t);if(a!=null&&a.interstitial.appendInPlace){let o=this.primaryMedia;o&&this.bufferAssetPlayer(a,o);}}}preloadAssets(e,t){let i=e.assetUrl,r=e.assetList.length,n=r===0&&!e.assetListLoader,a=e.cue.once;if(n){let l=e.timelineStart;if(e.appendInPlace){var o;let h=this.playingItem;!this.isInterstitial(h)&&(h==null||(o=h.nextEvent)==null?void 0:o.identifier)===e.identifier&&this.flushFrontBuffer(l+.25);}let d,c=0;if(!this.playingItem&&this.primaryLive&&(c=this.hls.startPosition,c===-1&&(c=this.hls.liveSyncPosition||0)),c&&!(e.cue.pre||e.cue.post)){let h=c-l;h>0&&(d=Math.round(h*1e3)/1e3);}if(this.log(`Load interstitial asset ${t+1}/${i?1:r} ${e}${d?` live-start: ${c} start-offset: ${d}`:""}`),i)return this.createAsset(e,0,0,l,e.duration,i);let u=this.assetListLoader.loadAssetList(e,d);u&&(e.assetListLoader=u);}else if(!a&&r){for(let d=t;d<r;d++){let c=e.assetList[d],u=this.getAssetPlayerQueueIndex(c.identifier);(u===-1||this.playerQueue[u].destroyed)&&!c.error&&this.createAssetPlayer(e,c,d);}let l=e.assetList[t];if(l){let d=this.getAssetPlayer(l.identifier);return d&&d.loadSource(),d}}return null}flushFrontBuffer(e){let t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(r=>{this.hls.trigger(p.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:r});});}getAssetPlayerQueueIndex(e){let t=this.playerQueue;for(let i=0;i<t.length;i++)if(e===t[i].assetId)return i;return -1}getAssetPlayer(e){let t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){let{playerQueue:e,primaryMedia:t}=this;if(t){for(let i=0;i<e.length;i++)if(e[i].media===t)return e[i]}return null}createAsset(e,t,i,r,n,a){let o={parentIdentifier:e.identifier,identifier:qb(e,a,t),duration:n,startOffset:i,timelineStart:r,uri:a};return this.createAssetPlayer(e,o,t)}createAssetPlayer(e,t,i){let r=this.hls,n=r.userConfig,a=n.videoPreference,o=r.loadLevelObj||r.levels[r.currentLevel];(a||o)&&(a=Se({},a),o.videoCodec&&(a.videoCodec=o.videoCodec),o.videoRange&&(a.allowedVideoRanges=[o.videoRange]));let l=r.audioTracks[r.audioTrack],d=r.subtitleTracks[r.subtitleTrack],c=0;if(this.primaryLive||e.appendInPlace){let b=this.timelinePos-t.timelineStart;if(b>1){let _=t.duration;_&&b<_&&(c=b);}}let u=t.identifier,h=Te(Te({},n),{},{maxMaxBufferLength:Math.min(180,r.config.maxMaxBufferLength),autoStartLoad:true,startFragPrefetch:true,primarySessionId:r.sessionId,assetPlayerId:u,abrEwmaDefaultEstimate:r.bandwidthEstimate,interstitialsController:void 0,startPosition:c,liveDurationInfinity:false,testBandwidth:false,videoPreference:a,audioPreference:l||n.audioPreference,subtitlePreference:d||n.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=true,t.timelineStart&&(h.timelineOffset=t.timelineStart));let f=h.cmcd;f!=null&&f.sessionId&&f.contentId&&(h.cmcd=Se({},f,{contentId:In(t.uri)})),this.getAssetPlayer(u)&&this.warn(`Duplicate date range identifier ${e} and asset ${u}`);let m=new Au(this.HlsPlayerClass,h,e,t);this.playerQueue.push(m),e.assetList[i]=t;let g=true,E=b=>{if(b.live){var _;let k=new Error(`Interstitials MUST be VOD assets ${e}`),R={fatal:true,type:z.OTHER_ERROR,details:x.INTERSTITIAL_ASSET_ITEM_ERROR,error:k},L=((_=this.schedule)==null?void 0:_.findEventIndex(e.identifier))||-1;this.handleAssetItemError(R,e,L,i,k.message);return}let D=b.edge-b.fragmentStart,I=t.duration;(g||I===null||D>I)&&(g=false,this.log(`Interstitial asset "${u}" duration change ${I} > ${D}`),t.duration=D,this.updateSchedule());};m.on(p.LEVEL_UPDATED,(b,{details:_})=>E(_)),m.on(p.LEVEL_PTS_UPDATED,(b,{details:_})=>E(_)),m.on(p.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());let v=(b,_)=>{let D=this.getAssetPlayer(u);if(D&&_.tracks){D.off(p.BUFFER_CODECS,v),D.tracks=_.tracks;let I=this.primaryMedia;this.bufferingAsset===D.assetItem&&I&&!D.media&&this.bufferAssetPlayer(D,I);}};m.on(p.BUFFER_CODECS,v);let y=()=>{var b;let _=this.getAssetPlayer(u);if(this.log(`buffered to end of asset ${_}`),!_||!this.schedule)return;let D=this.schedule.findEventIndex(e.identifier),I=(b=this.schedule.items)==null?void 0:b[D];this.isInterstitial(I)&&this.advanceAssetBuffering(I,t);};m.on(p.BUFFERED_TO_END,y);let S=b=>()=>{if(!this.getAssetPlayer(u)||!this.schedule)return;this.shouldPlay=true;let D=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,D,b);};return m.once(p.MEDIA_ENDED,S(i)),m.once(p.PLAYOUT_LIMIT_REACHED,S(1/0)),m.on(p.ERROR,(b,_)=>{if(!this.schedule)return;let D=this.getAssetPlayer(u);if(_.details===x.BUFFER_STALLED_ERROR){if(D!=null&&D.appendInPlace){this.handleInPlaceStall(e);return}this.onTimeupdate(),this.checkBuffer(true);return}this.handleAssetItemError(_,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${_.error} ${e}`);}),m.on(p.DESTROYING,()=>{if(!this.getAssetPlayer(u)||!this.schedule)return;let _=new Error(`Asset player destroyed unexpectedly ${u}`),D={fatal:true,type:z.OTHER_ERROR,details:x.INTERSTITIAL_ASSET_ITEM_ERROR,error:_};this.handleAssetItemError(D,e,this.schedule.findEventIndex(e.identifier),i,_.message);}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${lr(t)}`),this.hls.trigger(p.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:m}),m}clearInterstitial(e,t){this.clearAssetPlayers(e,t),e.reset();}clearAssetPlayers(e,t){e.assetList.forEach(i=>{this.clearAssetPlayer(i.identifier,t);});}resetAssetPlayer(e){let t=this.getAssetPlayerQueueIndex(e);if(t!==-1){this.log(`reset asset player "${e}" after error`);let i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails();}}clearAssetPlayer(e,t){let i=this.getAssetPlayerQueueIndex(e);if(i!==-1){let r=this.playerQueue[i];this.log(`clear ${r} toSegment: ${t&&Ht(t)}`),this.transferMediaFromPlayer(r,t),this.playerQueue.splice(i,1),r.destroy();}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[];}startAssetPlayer(e,t,i,r,n){let{interstitial:a,assetItem:o,assetId:l}=e,d=a.assetList.length,c=this.playingAsset;this.endedAsset=null,this.playingAsset=o,(!c||c.identifier!==l)&&(c&&(this.clearAssetPlayer(c.identifier,i[r]),delete c.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${d} ${lr(o)}`),this.hls.trigger(p.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:a,schedule:i.slice(0),scheduleIndex:r,player:e})),this.bufferAssetPlayer(e,n);}bufferAssetPlayer(e,t){var i,r;if(!this.schedule)return;let{interstitial:n,assetItem:a}=e,o=this.schedule.findEventIndex(n.identifier),l=(i=this.schedule.items)==null?void 0:i[o];if(!l)return;e.loadSource(),this.setBufferingItem(l),this.bufferingAsset=a;let d=this.getBufferingPlayer();if(d===e)return;let c=n.appendInPlace;if(c&&d?.interstitial.appendInPlace===false)return;let u=d?.tracks||((r=this.detachedData)==null?void 0:r.tracks)||this.requiredTracks;if(c&&a!==this.playingAsset){if(!e.tracks){this.log(`Waiting for track info before buffering ${e}`);return}if(u&&!Yg(u,e.tracks)){let h=new Error(`Asset ${lr(a)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(u)}')`),f={fatal:true,type:z.OTHER_ERROR,details:x.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},m=n.findAssetIndex(a);this.handleAssetItemError(f,n,o,m,h.message);return}}this.transferMediaTo(e,t);}handleInPlaceStall(e){let t=this.schedule,i=this.primaryMedia;if(!t||!i)return;let r=i.currentTime,n=t.findAssetIndex(e,r),a=e.assetList[n];if(a){let o=this.getAssetPlayer(a.identifier);if(o){let l=o.currentTime||r-a.timelineStart,d=o.duration-l;if(this.warn(`Stalled at ${l} of ${l+d} in ${o} ${e} (media.currentTime: ${r})`),l&&(d/i.playbackRate<.5||o.bufferedInPlaceToEnd(i))&&o.hls){let c=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,c,n);}}}}advanceInPlace(e){let t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e);}handleAssetItemError(e,t,i,r,n){if(e.details===x.BUFFER_STALLED_ERROR)return;let a=t.assetList[r]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${a&&lr(a)} ${e.error}`),!this.schedule)return;let o=a?.identifier||"",l=this.getAssetPlayerQueueIndex(o),d=this.playerQueue[l]||null,c=this.schedule.items,u=Se({},e,{fatal:false,errorAction:ur(true),asset:a,assetListIndex:r,event:t,schedule:c,scheduleIndex:i,player:d});if(this.hls.trigger(p.INTERSTITIAL_ASSET_ERROR,u),!e.fatal)return;let h=this.playingAsset,f=this.bufferingAsset,m=new Error(n);if(a&&(this.clearAssetPlayer(o,null),a.error=m),!t.assetList.some(g=>!g.error))t.error=m;else for(let g=r;g<t.assetList.length;g++)this.resetAssetPlayer(t.assetList[g].identifier);this.updateSchedule(true),t.error?this.primaryFallback(t):h&&h.identifier===o?this.advanceAfterAssetEnded(t,i,r):f&&f.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,f);}primaryFallback(e){let t=e.timelineStart,i=this.effectivePlayingItem,r=this.timelinePos;if(i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${r} playing: ${Ht(i)} error: ${e.error}`),r===-1&&(r=this.hls.startPosition);let a=this.updateItem(i,r);this.itemsMatch(i,a)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t));}else if(r===-1){this.checkStart();return}if(!this.schedule)return;let n=this.schedule.findItemIndexAtTime(r);this.setSchedulePosition(n);}onAssetListLoaded(e,t){var i,r;let n=t.event,a=n.identifier,o=t.assetListResponse.ASSETS;if(!((i=this.schedule)!=null&&i.hasEvent(a)))return;let l=n.timelineStart,d=n.duration,c=0;o.forEach((g,E)=>{let v=parseFloat(g.DURATION);this.createAsset(n,E,c,l+c,v,g.URI),c+=v;}),n.duration=c,this.log(`Loaded asset-list with duration: ${c} (was: ${d}) ${n}`);let u=this.waitingItem,h=u?.event.identifier===a;this.updateSchedule();let f=(r=this.bufferingItem)==null?void 0:r.event;if(h){var m;let g=this.schedule.findEventIndex(a),E=(m=this.schedule.items)==null?void 0:m[g];if(E){if(!this.playingItem&&this.timelinePos>E.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==g){n.error=new Error(`Interstitial ${o.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${n}`),this.log(n.error.message),this.updateSchedule(true),this.primaryFallback(n);return}this.setBufferingItem(E);}this.setSchedulePosition(g);}else if(f?.identifier===a){let g=n.assetList[0];if(g){let E=this.getAssetPlayer(g.identifier);if(f.appendInPlace){let v=this.primaryMedia;E&&v&&this.bufferAssetPlayer(E,v);}else E&&E.loadSource();}}}onError(e,t){if(this.schedule)switch(t.details){case x.ASSET_LIST_PARSING_ERROR:case x.ASSET_LIST_LOAD_ERROR:case x.ASSET_LIST_LOAD_TIMEOUT:{let i=t.interstitial;i&&(this.updateSchedule(true),this.primaryFallback(i));break}case x.BUFFER_STALLED_ERROR:{let i=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&i.event.appendInPlace){this.handleInPlaceStall(i.event);return}this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(true);break}}}},Fg=500,xu=class extends Mn{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",W.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners();}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null;}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(p.LEVEL_LOADED,this.onLevelLoaded,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);}unregisterListeners(){super.unregisterListeners();let{hls:e}=this;e.off(p.LEVEL_LOADED,this.onLevelLoaded,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);}startLoad(e,t){this.stopLoad(),this.state=C.IDLE,this.setInterval(Fg),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick();}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null;}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t);}onLevelLoaded(e,t){this.mainDetails=t.details;}onSubtitleFragProcessed(e,t){let{frag:i,success:r}=t;if(this.fragContextChanged(i)||(Fe(i)&&(this.fragPrevious=i),this.state=C.IDLE),!r)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=i.start;for(let 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),this.media&&this.tick();}onBufferFlushing(e,t){let{startOffset:i,endOffset:r}=t;if(i===0&&r!==Number.POSITIVE_INFINITY){let n=r-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++;}}),this.fragmentTracker.removeFragmentsInRange(i,n,W.SUBTITLE);}}onError(e,t){let i=t.frag;i?.type===W.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&&Kp(this.levels,t)){this.levels=t.map(i=>new ms(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{let r=new ms(i);return this.tracksBuffered[r.id]=[],r}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,W.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null;}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,!((i=this.levels)!=null&&i.length)||this.currentTrackId===-1){this.clearInterval();return}let r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.state!==C.STOPPED&&this.setInterval(Fg);}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){if(a.deltaUpdateFailed)return;let u=this.mainDetails;if(!u){this.startFragRequested=false;return}let h=u.fragments[0];if(!l.details)a.hasProgramDateTime&&u.hasProgramDateTime?(hl(a,u),d=a.fragmentStart):h&&(d=h.start,Yc(a,d));else {var c;d=this.alignPlaylists(a,l.details,(c=this.levelLastLoaded)==null?void 0:c.details),d===0&&h&&(d=h.start,Yc(a,d));}u&&!this.startFragRequested&&this.setStartPosition(u,d);}l.details=a,this.levelLastLoaded=l,o===r&&(this.hls.trigger(p.SUBTITLE_TRACK_UPDATED,{details:a,id:o,groupId:t.groupId}),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===C.IDLE&&(gs(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&&hr(r.method)){let a=performance.now();this.decrypter.decrypt(new Uint8Array(i),r.key.buffer,r.iv.buffer,Zu(r.method)).catch(o=>{throw n.trigger(p.ERROR,{type:z.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||this.waitForLive(i))return;let{config:r}=this,n=this.getLoadPosition(),a=ne.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,r.maxBufferHole),{end:o,len:l}=a,d=i.details,c=this.hls.maxBufferLength+d.levelTargetDuration;if(l>c)return;let u=d.fragments,h=u.length,f=d.edge,m=null,g=this.fragPrevious;if(o<f){let y=r.maxFragLookUpTolerance,S=o>f-y?0:y;m=gs(g,u,Math.max(u[0].start,o),S),!m&&g&&g.start<u[0].start&&(m=u[0]);}else m=u[h-1];if(m=this.filterReplacedPrimary(m,i.details),!m)return;let E=m.sn-d.startSN,v=u[E-1];if(v&&v.cc===m.cc&&this.fragmentTracker.getState(v)===We.NOT_LOADED&&(m=v),this.fragmentTracker.getState(m)===We.NOT_LOADED){let y=this.mapToInitFragWhenRequired(m);y&&this.loadFragment(y,i,o);}}}loadFragment(e,t,i){Fe(e)?super.loadFragment(e,t,i):this._loadInitSegment(e,t);}get mediaBufferTimeRanges(){return new Ru(this.tracksBuffered[this.currentTrackId]||[])}},Ru=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)}};}},zb={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},r0=s=>String.fromCharCode(zb[s]||s),Kt=15,bi=100,Qb={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Xb={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Zb={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Jb={25:2,26:4,29:6,30:8,31:10,27:13,28:15},eA=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],ku=class{constructor(){this.time=null,this.verboseLevel=0;}log(e,t){if(this.verboseLevel>=e){let i=typeof t=="function"?t():t;ye.log(`${this.time} [${e}] ${i}`);}}},ds=function(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t},Sl=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}},Du=class{constructor(){this.uchar=" ",this.penState=new Sl;}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()}},Cu=class{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Sl,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<bi;t++)this.chars.push(new Du);this.logger=e;}equals(e){for(let t=0;t<bi;t++)if(!this.chars[t].equals(e.chars[t]))return false;return true}copy(e){for(let t=0;t<bi;t++)this.chars[t].copy(e.chars[t]);}isEmpty(){let e=true;for(let t=0;t<bi;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>bi&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=bi);}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=r0(e);if(this.pos>=bi){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<bi;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<bi;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);}},Ln=class{constructor(e){this.rows=[],this.currRow=Kt-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Kt;t++)this.rows.push(new Cu(e));this.logger=e;}reset(){for(let e=0;e<Kt;e++)this.rows[e].clear();this.currRow=Kt-1;}equals(e){let t=true;for(let i=0;i<Kt;i++)if(!this.rows[i].equals(e.rows[i])){t=false;break}return t}copy(e){for(let t=0;t<Kt;t++)this.rows[t].copy(e.rows[t]);}isEmpty(){let e=true;for(let t=0;t<Kt;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 = "+Ae(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<Kt;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 = "+Ae(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<Kt;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(`
|
|
1509
|
-
`)),i}getTextAndFormat(){return this.rows}},bl=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 Ln(i),this.nonDisplayedMemory=new Ln(i),this.lastOutputScreen=new Ln(i),this.currRollUpRow=this.displayedMemory.rows[Kt-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[Kt-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: "+Ae(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));}},Al=class{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=iA(),this.logger=void 0;let r=this.logger=new ku;this.channels=[null,new bl(e,t,r),new bl(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,()=>"["+ds([t[i],t[i+1]])+"] -> ("+ds([r,n])+")");let l=this.cmdHistory;if(r>=16&&r<=31){if(tA(r,n,l)){Ko(null,null,l),this.logger.log(3,()=>"Repeated command ("+ds([r,n])+") is dropped");continue}Ko(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 Ko(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 "+ds([r,n])+" orig: "+ds([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 ("+ds([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?Qb[e]:Zb[e]:i=a===1?Xb[e]:Jb[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 '"+r0(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 = "+ds(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=eA[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();}Ko(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 Ko(s,e,t){t.a=s,t.b=e;}function tA(s,e,t){return t.a===s&&t.b===e}function iA(){return {a:null,b:null}}var lh=(function(){if(ul!=null&&ul.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 u in c)o[u]=c[u];}return o}function a(o,l,d){let c=this,u={enumerable:true};c.hasBeenReset=false;let h="",f=false,m=o,g=l,E=d,v=null,y="",S=true,b="auto",_="start",D=50,I="middle",k=50,R="middle";Object.defineProperty(c,"id",n({},u,{get:function(){return h},set:function(L){h=""+L;}})),Object.defineProperty(c,"pauseOnExit",n({},u,{get:function(){return f},set:function(L){f=!!L;}})),Object.defineProperty(c,"startTime",n({},u,{get:function(){return m},set:function(L){if(typeof L!="number")throw new TypeError("Start time must be set to a number.");m=L,this.hasBeenReset=true;}})),Object.defineProperty(c,"endTime",n({},u,{get:function(){return g},set:function(L){if(typeof L!="number")throw new TypeError("End time must be set to a number.");g=L,this.hasBeenReset=true;}})),Object.defineProperty(c,"text",n({},u,{get:function(){return E},set:function(L){E=""+L,this.hasBeenReset=true;}})),Object.defineProperty(c,"region",n({},u,{get:function(){return v},set:function(L){v=L,this.hasBeenReset=true;}})),Object.defineProperty(c,"vertical",n({},u,{get:function(){return y},set:function(L){let M=i(L);if(M===false)throw new SyntaxError("An invalid or illegal string was specified.");y=M,this.hasBeenReset=true;}})),Object.defineProperty(c,"snapToLines",n({},u,{get:function(){return S},set:function(L){S=!!L,this.hasBeenReset=true;}})),Object.defineProperty(c,"line",n({},u,{get:function(){return b},set:function(L){if(typeof L!="number"&&L!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");b=L,this.hasBeenReset=true;}})),Object.defineProperty(c,"lineAlign",n({},u,{get:function(){return _},set:function(L){let M=r(L);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");_=M,this.hasBeenReset=true;}})),Object.defineProperty(c,"position",n({},u,{get:function(){return D},set:function(L){if(L<0||L>100)throw new Error("Position must be between 0 and 100.");D=L,this.hasBeenReset=true;}})),Object.defineProperty(c,"positionAlign",n({},u,{get:function(){return I},set:function(L){let M=r(L);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");I=M,this.hasBeenReset=true;}})),Object.defineProperty(c,"size",n({},u,{get:function(){return k},set:function(L){if(L<0||L>100)throw new Error("Size must be between 0 and 100.");k=L,this.hasBeenReset=true;}})),Object.defineProperty(c,"align",n({},u,{get:function(){return R},set:function(L){let M=r(L);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");R=M,this.hasBeenReset=true;}})),c.displayState=void 0;}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a})(),Mu=class{decode(e,t){if(!e)return "";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function n0(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 wu=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 a0(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 Pu=new lh(0,0,""),Vo=Pu.align==="middle"?"middle":"center";function sA(s,e,t){let i=s;function r(){let o=n0(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 wu;a0(o,function(h,f){let m;switch(h){case "region":for(let g=t.length-1;g>=0;g--)if(t[g].id===f){d.set(h,t[g].region);break}break;case "vertical":d.alt(h,f,["rl","lr"]);break;case "line":m=f.split(","),d.integer(h,m[0]),d.percent(h,m[0])&&d.set("snapToLines",false),d.alt(h,m[0],["auto"]),m.length===2&&d.alt("lineAlign",m[1],["start",Vo,"end"]);break;case "position":m=f.split(","),d.percent(h,m[0]),m.length===2&&d.alt("positionAlign",m[1],["start",Vo,"end","line-left","line-right","auto"]);break;case "size":d.percent(h,f);break;case "align":d.alt(h,f,["start",Vo,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let c=d.get("line","auto");c==="auto"&&Pu.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",Vo);let u=d.get("position","auto");u==="auto"&&Pu.position===50&&(u=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=u;}function a(){s=s.replace(/^\s+/,"");}if(a(),e.startTime=r(),a(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.slice(3),a(),e.endTime=r(),a(),n(s,e);}function o0(s){return s.replace(/<br(?: \/)?>/gi,`
|
|
1510
|
-
`)}var
|
|
1480
|
+
${this.list("audiovideo")}}`}list(e){var t,i;return (t=this.queues)!=null&&t[e]||(i=this.tracks)!=null&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;let i=(t=this.tracks)==null?void 0:t[e],r=i?.buffer;return r?`SourceBuffer${r.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(e){var t;return ((t=this.queues)==null?void 0:t[e].map(i=>i.label).join(", "))||""}},bg=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,$p="HlsJsTrackRemovedError",du=class extends Error{constructor(e){super(e),this.name=$p;}},cu=class extends ht{constructor(e,t){super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=i=>{var r;this.hls&&((r=this.mediaSource)==null?void 0:r.readyState)==="open"&&this.hls.pauseBuffering();},this._onStartStreaming=i=>{this.hls&&this.hls.resumeBuffering();},this._onMediaSourceOpen=i=>{let{media:r,mediaSource:n}=this;i&&this.log("Media source opened"),!(!r||!n)&&(n.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(p.MEDIA_ATTACHED,{media:r,mediaSource:n}),this.mediaSource!==null&&this.checkPendingTracks());},this._onMediaSourceClose=()=>{this.log("Media source closed");},this._onMediaSourceEnded=()=>{this.log("Media source ended");},this._onMediaEmptied=()=>{let{mediaSrc:i,_objectUrl:r}=this;i!==r&&this.error(`Media element src was set while attaching MediaSource (${r} > ${i})`);},this.hls=e,this.fragmentTracker=t,this.appendSource=MT($i(e.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners();}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null;}registerListeners(){let{hls:e}=this;e.on(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),e.on(p.ERROR,this.onError,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),e.off(p.ERROR,this.onError,this);}transferMedia(){let{media:e,mediaSource:t}=this;if(!e)return null;let i={};if(this.operationQueue){let n=this.isUpdating();n||this.operationQueue.removeBlockers();let a=this.isQueued();(n||a)&&this.warn(`Transfering MediaSource with${a?" operations in queue":""}${n?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy();}let r=this.transferData;return !this.sourceBufferCount&&r&&r.mediaSource===t?Se(i,r.tracks):this.sourceBuffers.forEach(n=>{let[a]=n;a&&(i[a]=Se({},this.tracks[a]),this.removeBuffer(a)),n[0]=n[1]=null;}),{media:e,mediaSource:t,tracks:i}}initTracks(){let e={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0;}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null;}onManifestParsed(e,t){var i;let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsTotal=r,this.log(`${r} bufferCodec event(s) expected.`),(i=this.transferData)!=null&&i.mediaSource&&this.sourceBufferCount&&r&&this.bufferCreated();}onMediaAttaching(e,t){let i=this.media=t.media;this.transferData=this.overrides=void 0;let r=$i(this.appendSource);if(r){let n=!!t.mediaSource;(n||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);let a=this.mediaSource=t.mediaSource||new r;if(this.assignMediaSource(a),n)this._objectUrl=i.src,this.attachTransferred();else {let o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{i.removeAttribute("src");let d=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||d&&a instanceof d,Ag(i),BS(i,o),i.load();}catch{i.src=o;}else i.src=o;}i.addEventListener("emptied",this._onMediaEmptied);}}assignMediaSource(e){var t,i;this.log(`${((t=this.transferData)==null?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${(i=e.constructor)==null?void 0:i.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming));}attachTransferred(){let e=this.media,t=this.transferData;if(!t||!e)return;let i=this.tracks,r=t.tracks,n=r?Object.keys(r):null,a=n?n.length:0,o=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen();});};if(r&&n&&a){if(!this.tracksReady){this.hls.config.startFragPrefetch=true,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
|
|
1481
|
+
required tracks: ${Ae(i,(d,l)=>d==="initSegment"?void 0:l)};
|
|
1482
|
+
transfer tracks: ${Ae(r,(d,l)=>d==="initSegment"?void 0:l)}}`),!Gg(r,i)){t.mediaSource=null,t.tracks=void 0;let d=e.currentTime,l=this.details,c=Math.max(d,l?.fragments[0].start||0);if(c-d>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${d} -> ${c}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(r)}"->"${Object.keys(i)}") start time: ${c} currentTime: ${d}`),this.onMediaDetaching(p.MEDIA_DETACHING,{}),this.onMediaAttaching(p.MEDIA_ATTACHING,t),e.currentTime=c;return}this.transferData=void 0,n.forEach(d=>{let l=d,c=r[l];if(c){let u=c.buffer;if(u){let h=this.fragmentTracker,f=c.id;if(h.hasFragments(f)||h.hasParts(f)){let E=ne.getBuffered(u);h.detectEvictedFragments(l,E,f,null,true);}let m=gc(l),g=[l,u];this.sourceBuffers[m]=g,u.updating&&this.operationQueue&&this.operationQueue.prependBlocker(l),this.trackSourceBuffer(l,c);}}}),o(),this.bufferCreated();}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o();}get mediaSourceOpenOrEnded(){var e;let t=(e=this.mediaSource)==null?void 0:e.readyState;return t==="open"||t==="ended"}onMediaDetaching(e,t){let i=!!t.transferMedia;this.transferData=this.overrides=void 0;let{media:r,mediaSource:n,_objectUrl:a}=this;if(n){if(this.log(`media source ${i?"transferring":"detaching"}`),i)this.sourceBuffers.forEach(([o])=>{o&&this.removeBuffer(o);}),this.resetQueue();else {if(this.mediaSourceOpenOrEnded){let o=n.readyState==="open";try{let d=n.sourceBuffers;for(let l=d.length;l--;)o&&d[l].abort(),n.removeSourceBuffer(d[l]);o&&n.endOfStream();}catch(d){this.warn(`onMediaDetaching: ${d.message} while calling endOfStream`);}}this.sourceBufferCount&&this.onBufferReset();}n.removeEventListener("sourceopen",this._onMediaSourceOpen),n.removeEventListener("sourceended",this._onMediaSourceEnded),n.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(n.removeEventListener("startstreaming",this._onStartStreaming),n.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null;}r&&(r.removeEventListener("emptied",this._onMediaEmptied),i||(a&&self.URL.revokeObjectURL(a),this.mediaSrc===a?(r.removeAttribute("src"),this.appendSource&&Ag(r),r.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(p.MEDIA_DETACHED,t);}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e);}),this.initTracks();}resetBuffer(e){var t;let i=(t=this.tracks[e])==null?void 0:t.buffer;if(this.removeBuffer(e),i)try{var r;(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i);}catch(n){this.warn(`onBufferReset ${e}`,n);}delete this.tracks[e];}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[gc(e)]=[null,null];let t=this.tracks[e];t&&(t.buffer=void 0);}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new lu(this.tracks);}onBufferCodecs(e,t){var i;let r=this.tracks,n=Object.keys(t);this.log(`BUFFER_CODECS: "${n}" (current SB count ${this.sourceBufferCount})`);let a="audiovideo"in t&&(r.audio||r.video)||r.audiovideo&&("audio"in t||"video"in t),o=!a&&this.sourceBufferCount&&this.media&&n.some(d=>!r[d]);if(a||o){this.warn(`Unsupported transition between "${Object.keys(r)}" and "${n}" SourceBuffers`);return}n.forEach(d=>{var l,c;let u=t[d],{id:h,codec:f,levelCodec:m,container:g,metadata:E,supplemental:v}=u,T=r[d],S=(l=this.transferData)==null||(l=l.tracks)==null?void 0:l[d],b=S!=null&&S.buffer?S:T,_=b?.pendingCodec||b?.codec,D=b?.levelCodec;T||(T=r[d]={buffer:void 0,listeners:[],codec:f,supplemental:v,container:g,levelCodec:m,metadata:E,id:h});let I=Vo(_,D),k=I?.replace(bg,"$1"),R=Vo(f,m),L=(c=R)==null?void 0:c.replace(bg,"$1");R&&I&&k!==L&&(d.slice(0,5)==="audio"&&(R=Jo(R,this.appendSource)),this.log(`switching codec ${_} to ${R}`),R!==(T.pendingCodec||T.codec)&&(T.pendingCodec=R),T.container=g,this.appendChangeType(d,g,R));}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&((i=t.audio)==null?void 0:i.id)==="main"&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks());}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{let i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}appendChangeType(e,t,i){let r=`${t};codecs=${i}`,n={label:`change-type=${r}`,execute:()=>{let a=this.tracks[e];if(a){let o=a.buffer;o!=null&&o.changeType&&(this.log(`changing ${e} sourceBuffer type to ${r}`),o.changeType(r),a.codec=i,a.container=t);}this.shiftAndExecuteNext(e);},onStart:()=>{},onComplete:()=>{},onError:a=>{this.warn(`Failed to change ${e} SourceBuffer type`,a);}};this.append(n,e,this.isPending(this.tracks[e]));}blockAudio(e){var t;let i=e.start,r=i+e.duration*.05;if(((t=this.fragmentTracker.getAppendedFrag(i,Y.MAIN))==null?void 0:t.gap)===true)return;let a={label:"block-audio",execute:()=>{var o;let d=this.tracks.video;(this.lastVideoAppendEnd>r||d!=null&&d.buffer&&ne.isBuffered(d.buffer,r)||((o=this.fragmentTracker.getAppendedFrag(r,Y.MAIN))==null?void 0:o.gap)===true)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"));},onStart:()=>{},onComplete:()=>{},onError:o=>{this.warn("Error executing block-audio operation",o);}};this.blockedAudioAppend={op:a,frag:e},this.append(a,"audio",true);}unblockAudio(){let{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op));}onBufferAppending(e,t){let{tracks:i}=this,{data:r,type:n,parent:a,frag:o,part:d,chunkMeta:l,offset:c}=t,u=l.buffering[n],{sn:h,cc:f}=o,m=self.performance.now();u.start=m;let g=o.stats.buffering,E=d?d.stats.buffering:null;g.start===0&&(g.start=m),E&&E.start===0&&(E.start=m);let v=i.audio,T=false;n==="audio"&&v?.container==="audio/mpeg"&&(T=!this.lastMpegAudioChunk||l.id===1||this.lastMpegAudioChunk.sn!==l.sn,this.lastMpegAudioChunk=l);let S=i.video,b=S?.buffer;if(b&&h!=="initSegment"){let I=d||o,k=this.blockedAudioAppend;if(n==="audio"&&a!=="main"&&!this.blockedAudioAppend&&!(S.ending||S.ended)){let L=I.start+I.duration*.05,w=b.buffered,B=this.currentOp("video");!w.length&&!B?this.blockAudio(I):!B&&!ne.isBuffered(b,L)&&this.lastVideoAppendEnd<L&&this.blockAudio(I);}else if(n==="video"){let R=I.end;if(k){let L=k.frag.start;(R>L||R<this.lastVideoAppendEnd||ne.isBuffered(b,L))&&this.unblockAudio();}this.lastVideoAppendEnd=R;}}let _=(d||o).start,D={label:`append-${n}`,execute:()=>{var I;u.executeStart=self.performance.now();let k=(I=this.tracks[n])==null?void 0:I.buffer;k&&(T?this.updateTimestampOffset(k,_,.1,n,h,f):c!==void 0&&H(c)&&this.updateTimestampOffset(k,c,1e-6,n,h,f)),this.appendExecutor(r,n);},onStart:()=>{},onComplete:()=>{let I=self.performance.now();u.executeEnd=u.end=I,g.first===0&&(g.first=I),E&&E.first===0&&(E.first=I);let k={};this.sourceBuffers.forEach(([R,L])=>{R&&(k[R]=ne.getBuffered(L));}),this.appendErrors[n]=0,n==="audio"||n==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(p.BUFFER_APPENDED,{type:n,frag:o,part:d,chunkMeta:l,parent:o.type,timeRanges:k});},onError:I=>{var k;let R={type:Q.MEDIA_ERROR,parent:o.type,details:x.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:o,part:d,chunkMeta:l,error:I,err:I,fatal:false},L=(k=this.media)==null?void 0:k.error;if(I.code===DOMException.QUOTA_EXCEEDED_ERR||I.name=="QuotaExceededError"||"quota"in I)R.details=x.BUFFER_FULL_ERROR;else if(I.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!L)R.errorAction=dr(true);else if(I.name===$p&&this.sourceBufferCount===0)R.errorAction=dr(true);else {let w=++this.appendErrors[n];this.warn(`Failed ${w}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${n}" sourceBuffer (${L||"no media error"})`),(w>=this.hls.config.appendErrorMaxRetry||L)&&(R.fatal=true);}this.hls.trigger(p.ERROR,R);}};this.log(`queuing "${n}" append sn: ${h}${d?" p: "+d.index:""} of ${o.type===Y.MAIN?"level":"track"} ${o.level} cc: ${f}`),this.append(D,n,this.isPending(this.tracks[n]));}getFlushOp(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i);},onStart:()=>{},onComplete:()=>{this.hls.trigger(p.BUFFER_FLUSHED,{type:e});},onError:r=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,r);}}}onBufferFlushing(e,t){let{type:i,startOffset:r,endOffset:n}=t;i?this.append(this.getFlushOp(i,r,n),i):this.sourceBuffers.forEach(([a])=>{a&&this.append(this.getFlushOp(a,r,n),a);});}onFragParsed(e,t){let{frag:i,part:r}=t,n=[],a=r?r.elementaryStreams:i.elementaryStreams;a[be.AUDIOVIDEO]?n.push("audiovideo"):(a[be.AUDIO]&&n.push("audio"),a[be.VIDEO]&&n.push("video"));let o=()=>{let d=self.performance.now();i.stats.buffering.end=d,r&&(r.stats.buffering.end=d);let l=r?r.stats:i.stats;this.hls.trigger(p.FRAG_BUFFERED,{frag:i,part:r,stats:l,id:i.type});};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(o,n).catch(d=>{this.warn(`Fragment buffered callback ${d}`),this.stepOperationQueue(this.sourceBufferTypes);});}onFragChanged(e,t){this.trimBuffers();}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){let t=this.tracks[e];if(t)return !t.ended||t.ending}return false})}onBufferEos(e,t){var i;this.sourceBuffers.forEach(([a])=>{if(a){let o=this.tracks[a];(!t.type||t.type===a)&&(o.ending=true,o.ended||(o.ended=true,this.log(`${a} buffer reached EOS`)));}});let r=((i=this.overrides)==null?void 0:i.endOfStream)!==false;this.sourceBufferCount>0&&!this.sourceBuffers.some(([a])=>{var o;return a&&!((o=this.tracks[a])!=null&&o.ended)})?r?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();let{mediaSource:a}=this;if(!a||a.readyState!=="open"){a&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${a.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),a.endOfStream(),this.hls.trigger(p.BUFFERED_TO_END,void 0);})):(this.tracksEnded(),this.hls.trigger(p.BUFFERED_TO_END,void 0)):t.type==="video"&&this.unblockAudio();}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(e!==null){let t=this.tracks[e];t&&(t.ending=false);}});}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration());}updateDuration(){this.blockUntilOpen(()=>{let e=this.getDurationAndRange();e&&this.updateMediaSource(e);});}onError(e,t){if(t.details===x.BUFFER_APPEND_ERROR&&t.frag){var i;let r=(i=t.errorAction)==null?void 0:i.nextAutoLevel;H(r)&&r!==t.frag.level&&this.resetAppendErrors();}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0};}trimBuffers(){let{hls:e,details:t,media:i}=this;if(!i||t===null||!this.sourceBufferCount)return;let r=e.config,n=i.currentTime,a=t.levelTargetDuration,o=t.live&&r.liveBackBufferLength!==null?r.liveBackBufferLength:r.backBufferLength;if(H(o)&&o>=0){let l=Math.max(o,a),c=Math.floor(n/a)*a-l;this.flushBackBuffer(n,a,c);}let d=r.frontBufferFlushThreshold;if(H(d)&&d>0){let l=Math.max(r.maxBufferLength,d),c=Math.max(l,a),u=Math.floor(n/a)*a+c;this.flushFrontBuffer(n,a,u);}}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([r,n])=>{if(n){let o=ne.getBuffered(n);if(o.length>0&&i>o.start(0)){var a;this.hls.trigger(p.BACK_BUFFER_REACHED,{bufferEnd:i});let d=this.tracks[r];if((a=this.details)!=null&&a.live)this.hls.trigger(p.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(d!=null&&d.ended){this.log(`Cannot flush ${r} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:r});}}});}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([r,n])=>{if(n){let a=ne.getBuffered(n),o=a.length;if(o<2)return;let d=a.start(o-1),l=a.end(o-1);if(i>d||e>=d&&e<=l)return;this.hls.trigger(p.BUFFER_FLUSHING,{startOffset:d,endOffset:1/0,type:r});}});}getDurationAndRange(){var e;let{details:t,mediaSource:i}=this;if(!t||!this.media||i?.readyState!=="open")return null;let r=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){let l=Math.max(0,t.fragmentStart),c=Math.max(l,r);return {duration:1/0,start:l,end:c}}return {duration:1/0}}let n=(e=this.overrides)==null?void 0:e.duration;if(n)return H(n)?{duration:n}:null;let a=this.media.duration,o=H(i.duration)?i.duration:0;return r>o&&r>a||!H(a)?{duration:r}:null}updateMediaSource({duration:e,start:t,end:i}){let r=this.mediaSource;!this.media||!r||r.readyState!=="open"||(r.duration!==e&&(H(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),r.duration=e),t!==void 0&&i!==void 0&&(this.log(`MediaSource duration is set to ${r.duration}. Setting seekable range to ${t}-${i}.`),r.setLiveSeekableRange(t,i)));}get tracksReady(){let e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){let{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:i}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${Ae(i)}`),this.tracksReady){var r;let n=(r=this.transferData)==null?void 0:r.tracks;n&&Object.keys(n).length?this.attachTransferred():this.createSourceBuffers();}}bufferCreated(){if(this.sourceBufferCount){let e={};this.sourceBuffers.forEach(([t,i])=>{if(t){let r=this.tracks[t];e[t]={buffer:i,container:r.container,codec:r.codec,supplemental:r.supplemental,levelCodec:r.levelCodec,id:r.id,metadata:r.metadata};}}),this.hls.trigger(p.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([t])=>{this.executeNext(t);});}else {let e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:true,error:e,reason:e.message});}}createSourceBuffers(){let{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(let n in e){let a=n,o=e[a];if(this.isPending(o)){let d=this.getTrackCodec(o,a),l=`${o.container};codecs=${d}`;o.codec=d,this.log(`creating sourceBuffer(${l})${this.currentOp(a)?" Queued":""} ${Ae(o)}`);try{let c=i.addSourceBuffer(l),u=gc(a),h=[a,c];t[u]=h,o.buffer=c;}catch(c){var r;this.error(`error while trying to add sourceBuffer: ${c.message}`),this.shiftAndExecuteNext(a),(r=this.operationQueue)==null||r.removeBlockers(),delete this.tracks[a],this.hls.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_ADD_CODEC_ERROR,fatal:false,error:c,sourceBufferName:a,mimeType:l,parent:o.id});return}this.trackSourceBuffer(a,o);}}this.bufferCreated();}getTrackCodec(e,t){let i=e.supplemental,r=e.codec;i&&(t==="video"||t==="audiovideo")&&Ln(i,"video")&&(r=JT(r,i));let n=Vo(r,e.levelCodec);return n?t.slice(0,5)==="audio"?Jo(n,this.appendSource):n:""}trackSourceBuffer(e,t){let i=t.buffer;if(!i)return;let r=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:r,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(n,a)=>{let o=a.removedRanges;o!=null&&o.length&&this.hls.trigger(p.BUFFER_FLUSHED,{type:n});});}get mediaSrc(){var e,t;let i=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return i?.src}onSBUpdateStart(e){let t=this.currentOp(e);t&&t.onStart();}onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}let i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e));}onSBUpdateError(e,t){var i;let r=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(i=this.mediaSource)==null?void 0:i.readyState}`);this.error(`${r}`,t),this.hls.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:r,fatal:false});let n=this.currentOp(e);n&&n.onError(r);}updateTimestampOffset(e,t,i,r,n,a){let o=t-e.timestampOffset;Math.abs(o)>=i&&(this.log(`Updating ${r} SourceBuffer timestampOffset to ${t} (sn: ${n} cc: ${a})`),e.timestampOffset=t);}removeExecutor(e,t,i){let{media:r,mediaSource:n}=this,a=this.tracks[e],o=a?.buffer;if(!r||!n||!o){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),this.shiftAndExecuteNext(e);return}let d=H(r.duration)?r.duration:1/0,l=H(n.duration)?n.duration:1/0,c=Math.max(0,t),u=Math.min(i,d,l);u>c&&(!a.ending||a.ended)?(a.ended=false,this.log(`Removing [${c},${u}] from the ${e} SourceBuffer`),o.remove(c,u)):this.shiftAndExecuteNext(e);}appendExecutor(e,t){let i=this.tracks[t],r=i?.buffer;if(!r)throw new du(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=false,i.ended=false,r.appendBuffer(e);}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(t=>{this.warn(`SourceBuffer blocked callback ${t}`),this.stepOperationQueue(this.sourceBufferTypes);});else try{e();}catch(t){this.warn(`Callback run without blocking ${this.operationQueue} ${t}`);}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return !!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);let{operationQueue:i}=this,r=t.map(a=>this.appendBlocker(a));return t.length>1&&this.blockedAudioAppend&&this.unblockAudio(),Promise.all(r).then(a=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes));})}stepOperationQueue(e){e.forEach(t=>{var i;let r=(i=this.tracks[t])==null?void 0:i.buffer;!r||r.updating||this.shiftAndExecuteNext(t);});}append(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i);}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e);}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e);}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,i){let r=this.tracks[e];if(!r)return;let n=r.buffer;if(!n)return;let a=i.bind(this,e);r.listeners.push({event:t,listener:a}),n.addEventListener(t,a);}removeBufferListeners(e){let t=this.tracks[e];if(!t)return;let i=t.buffer;i&&(t.listeners.forEach(r=>{i.removeEventListener(r.event,r.listener);}),t.listeners.length=0);}};function Ag(s){let e=s.querySelectorAll("source");[].slice.call(e).forEach(t=>{s.removeChild(t);});}function BS(s,e){let t=self.document.createElement("source");t.type="video/mp4",t.src=e,s.appendChild(t);}function gc(s){return s==="audio"?1:0}var uu=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&&H(this.autoLevelCapping)&&this.detectPlayerSize();}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping();}onMediaDetaching(){this.stopCapping(),this.media=null;}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}let e=this.hls.levels;if(e.length){let t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping;}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return -1;let i=t.filter((r,n)=>this.isLevelAllowed(r)&&n<=e);return this.clientRect=null,s.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize());}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0);}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0);}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio;}catch{}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return !this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return -1;let r=(o,d)=>d?o.width!==d.width||o.height!==d.height:true,n=e.length-1,a=Math.max(t,i);for(let o=0;o<e.length;o+=1){let d=e[o];if((d.width>=a||d.height>=a)&&r(d,e[o+1])){n=o;break}}return n}},GS={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},ct=GS,HS={HLS:"h"},KS=HS,Ai=class s{constructor(e,t){Array.isArray(e)&&(e=e.map(i=>i instanceof s?i:new s(i))),this.value=e,this.params=t;}},VS="Dict";function WS(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 YS(s,e,t,i){return new Error(`failed to ${s} "${WS(e)}" as ${t}`,{cause:i})}function mi(s,e,t){return YS("serialize",s,e,t)}var gl=class{constructor(e){this.description=e;}},_g="Bare Item",qS="Boolean";function jS(s){if(typeof s!="boolean")throw mi(s,qS);return s?"?1":"?0"}function zS(s){return btoa(String.fromCharCode(...s))}var QS="Byte Sequence";function XS(s){if(ArrayBuffer.isView(s)===false)throw mi(s,QS);return `:${zS(s)}:`}var ZS="Integer";function JS(s){return s<-999999999999999||999999999999999<s}function Bp(s){if(JS(s))throw mi(s,ZS);return s.toString()}function eb(s){return `@${Bp(s.getTime()/1e3)}`}function Gp(s,e){if(s<0)return -Gp(-s,e);let t=Math.pow(10,e);if(Math.abs(s*t%1-.5)<Number.EPSILON){let r=Math.floor(s*t);return (r%2===0?r:r+1)/t}else return Math.round(s*t)/t}var tb="Decimal";function ib(s){let e=Gp(s,3);if(Math.floor(Math.abs(e)).toString().length>12)throw mi(s,tb);let t=e.toString();return t.includes(".")?t:`${t}.0`}var sb="String",rb=/[\x00-\x1f\x7f]+/;function nb(s){if(rb.test(s))throw mi(s,sb);return `"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function ab(s){return s.description||s.toString().slice(7,-1)}var ob="Token";function Ig(s){let e=ab(s);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===false)throw mi(e,ob);return e}function hu(s){switch(typeof s){case "number":if(!H(s))throw mi(s,_g);return Number.isInteger(s)?Bp(s):ib(s);case "string":return nb(s);case "symbol":return Ig(s);case "boolean":return jS(s);case "object":if(s instanceof Date)return eb(s);if(s instanceof Uint8Array)return XS(s);if(s instanceof gl)return Ig(s);default:throw mi(s,_g)}}var lb="Key";function fu(s){if(/^[a-z*][a-z0-9\-_.*]*$/.test(s)===false)throw mi(s,lb);return s}function rh(s){return s==null?"":Object.entries(s).map(([e,t])=>t===true?`;${fu(e)}`:`;${fu(e)}=${hu(t)}`).join("")}function Hp(s){return s instanceof Ai?`${hu(s.value)}${rh(s.params)}`:hu(s)}function db(s){return `(${s.value.map(Hp).join(" ")})${rh(s.params)}`}function cb(s,e={whitespace:true}){if(typeof s!="object"||s==null)throw mi(s,VS);let t=s instanceof Map?s.entries():Object.entries(s),i=e?.whitespace?" ":"";return Array.from(t).map(([r,n])=>{n instanceof Ai||(n=new Ai(n));let a=fu(r);return n.value===true?a+=rh(n.params):(a+="=",Array.isArray(n.value)?a+=db(n):a+=Hp(n)),a}).join(`,${i}`)}function Kp(s,e){return cb(s,e)}var ci="CMCD-Object",we="CMCD-Request",os="CMCD-Session",Fi="CMCD-Status",ub={br:ci,ab:ci,d:ci,ot:ci,tb:ci,tpb:ci,lb:ci,tab:ci,lab:ci,url:ci,pb:we,bl:we,tbl:we,dl:we,ltc:we,mtp:we,nor:we,nrr:we,rc:we,sn:we,sta:we,su:we,ttfb:we,ttfbb:we,ttlb:we,cmsdd:we,cmsds:we,smrt:we,df:we,cs:we,ts:we,cid:os,pr:os,sf:os,sid:os,st:os,v:os,msd:os,bs:Fi,bsd:Fi,cdn:Fi,rtp:Fi,bg:Fi,pt:Fi,ec:Fi,e:Fi},hb={REQUEST:we};function fb(s){return Object.keys(s).reduce((e,t)=>{var i;return (i=s[t])===null||i===void 0||i.forEach(r=>e[r]=t),e},{})}function mb(s,e){let t={};if(!s)return t;let i=Object.keys(s),r=e?fb(e):{};return i.reduce((n,a)=>{var o;let d=ub[a]||r[a]||hb.REQUEST,l=(o=n[d])!==null&&o!==void 0?o:n[d]={};return l[a]=s[a],n},t)}function gb(s){return ["ot","sf","st","e","sta"].includes(s)}function pb(s){return typeof s=="number"?H(s):s!=null&&s!==""&&s!==false}var Vp="event";function Eb(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("/")+t.search+t.hash}var jo=s=>Math.round(s),mu=(s,e)=>Array.isArray(s)?s.map(t=>mu(t,e)):s instanceof Ai&&typeof s.value=="string"?new Ai(mu(s.value,e),s.params):(e.baseUrl&&(s=Eb(s,e.baseUrl)),e.version===1?encodeURIComponent(s):s),No=s=>jo(s/100)*100,vb=(s,e)=>{let t=s;return e.version>=2&&(s instanceof Ai&&typeof s.value=="string"?t=new Ai([s]):typeof s=="string"&&(t=[s])),mu(t,e)},Tb={br:jo,d:jo,bl:No,dl:No,mtp:No,nor:vb,rtp:No,tb:jo},Wp="request",Yp="response",nh=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],yb=["e"],Sb=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function Il(s){return Sb.test(s)}function bb(s){return nh.includes(s)||yb.includes(s)||Il(s)}var qp=["d","dl","nor","ot","rtp","su"];function Ab(s){return nh.includes(s)||qp.includes(s)||Il(s)}var _b=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];function Ib(s){return nh.includes(s)||qp.includes(s)||_b.includes(s)||Il(s)}var Lb=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function xb(s){return Lb.includes(s)||Il(s)}var Rb={[Yp]:Ib,[Vp]:bb,[Wp]:Ab};function jp(s,e={}){let t={};if(s==null||typeof s!="object")return t;let i=e.version||s.v||1,r=e.reportingMode||Wp,n=i===1?xb:Rb[r],a=Object.keys(s).filter(n),o=e.filter;typeof o=="function"&&(a=a.filter(o));let d=r===Yp||r===Vp;d&&!a.includes("ts")&&a.push("ts"),i>1&&!a.includes("v")&&a.push("v");let l=Se({},Tb,e.formatters),c={version:i,reportingMode:r,baseUrl:e.baseUrl};return a.sort().forEach(u=>{let h=s[u],f=l[u];if(typeof f=="function"&&(h=f(h,c)),u==="v"){if(i===1)return;h=i;}u=="pr"&&h===1||(d&&u==="ts"&&!H(h)&&(h=Date.now()),pb(h)&&(gb(u)&&typeof h=="string"&&(h=new gl(h)),t[u]=h));}),t}function kb(s,e={}){let t={};if(!s)return t;let i=jp(s,e),r=mb(i,e?.customHeaderMap);return Object.entries(r).reduce((n,[a,o])=>{let d=Kp(o,{whitespace:false});return d&&(n[a]=d),n},t)}function Db(s,e,t){return Se(s,kb(e,t))}var Cb="CMCD";function Mb(s,e={}){return s?Kp(jp(s,e),{whitespace:false}):""}function wb(s,e={}){if(!s)return "";let t=Mb(s,e);return encodeURIComponent(t)}function Pb(s,e={}){if(!s)return "";let t=wb(s,e);return `${Cb}=${t}`}var Lg=/CMCD=[^&#]+/;function Ob(s,e,t){let i=Pb(e,t);if(!i)return s;if(Lg.test(s))return s.replace(Lg,i);let r=s.includes("?")?"&":"?";return `${s}${r}${i}`}var gu=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:ct.MANIFEST,su:!this.initialized});}catch(n){this.hls.logger.warn("Could not generate manifest CMCD data.",n);}},this.applyFragmentData=r=>{try{let{frag:n,part:a}=r,o=this.hls.levels[n.level],d=this.getObjectType(n),l={d:(a||n).duration*1e3,ot:d};(d===ct.VIDEO||d===ct.AUDIO||d==ct.MUXED)&&(l.br=o.bitrate/1e3,l.tb=this.getTopBandwidth(d)/1e3,l.bl=this.getBufferLength(d));let c=a?this.getNextPart(a):this.getNextFrag(n);c!=null&&c.url&&c.url!==n.url&&(l.nor=c.url),this.apply(r,l);}catch(n){this.hls.logger.warn("Could not generate segment CMCD data.",n);}},this.hls=e;let t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||e.sessionId,this.cid=i.contentId,this.useHeaders=i.useHeaders===true,this.includeKeys=i.includeKeys,this.registerListeners());}registerListeners(){let e=this.hls;e.on(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=this.media=null;}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying);}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null);}onBufferCreated(e,t){var i,r;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer;}createData(){var e;return {v:1,sf:KS.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Se(t,this.createData());let i=t.ot===ct.INIT||t.ot===ct.VIDEO||t.ot===ct.MUXED;this.starved&&i&&(t.bs=true,t.su=true,this.starved=false),t.su==null&&(t.su=this.buffering);let{includeKeys:r}=this;r&&(t=Object.keys(t).reduce((a,o)=>(r.includes(o)&&(a[o]=t[o]),a),{}));let n={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),Db(e.headers,t,n)):e.url=Ob(e.url,t,n);}getNextFrag(e){var t;let i=(t=this.hls.levels[e.level])==null?void 0:t.details;if(i){let r=e.sn-i.startSN;return i.fragments[r+1]}}getNextPart(e){var t;let{index:i,fragment:r}=e,n=(t=this.hls.levels[r.level])==null||(t=t.details)==null?void 0:t.partList;if(n){let{sn:a}=r;for(let o=n.length-1;o>=0;o--){let d=n[o];if(d.index===i&&d.fragment.sn===a)return n[o+1]}}}getObjectType(e){let{type:t}=e;if(t==="subtitle")return ct.TIMED_TEXT;if(e.sn==="initSegment")return ct.INIT;if(t==="audio")return ct.AUDIO;if(t==="main")return this.hls.audioTracks.length?ct.VIDEO:ct.MUXED}getTopBandwidth(e){let t=0,i,r=this.hls;if(e===ct.AUDIO)i=r.audioTracks;else {let n=r.maxAutoLevel,a=n>-1?n+1:r.levels.length;i=r.levels.slice(0,a);}return i.forEach(n=>{n.bitrate>t&&(t=n.bitrate);}),t>0?t:NaN}getBufferLength(e){let t=this.media,i=e===ct.AUDIO?this.audioBuffer:this.videoBuffer;return !i||!t?NaN:ne.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n);}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy();}abort(){this.loader.abort();}load(n,a,o){t(n),this.loader.load(n,a,o);}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n);}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy();}abort(){this.loader.abort();}load(n,a,o){t(n),this.loader.load(n,a,o);}}}},Fb=3e5,pu=class extends ht{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=false,this.enabled=true,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners();}registerListeners(){let e=this.hls;e.on(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));}pathways(){return (this.levels||[]).reduce((e,t)=>(e.indexOf(t.pathwayId)===-1&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e);}startLoad(){if(this.started=true,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){let e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri);}}stopLoad(){this.started=false,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout();}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1);}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null;}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(i=>i!==e));}onManifestLoading(){this.stopLoad(),this.enabled=true,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null;}onManifestLoaded(e,t){let{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad());}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks;}onError(e,t){let{errorAction:i}=t;if(i?.action===Qe.SendAlternateToPenaltyBox&&i.flags===yt.MoveAllAlternatesMatchingHost){let r=this.levels,n=this._pathwayPriority,a=this.pathwayId;if(t.context){let{groupId:o,pathwayId:d,type:l}=t.context;o&&r?a=this.getPathwayForGroupId(o,l,a):d&&(a=d);}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&r&&(n=this.pathways()),n&&n.length>1&&(this.updatePathwayPriority(n),i.resolved=this.pathwayId!==a),t.details===x.BUFFER_APPEND_ERROR&&!t.fatal?i.resolved=true:i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${r&&r.length} priorities: ${Ae(n)} penalized: ${Ae(this.penalizedPathways)}`);}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i;}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this._pathwayPriority=e;let t,i=this.penalizedPathways,r=performance.now();Object.keys(i).forEach(n=>{r-i[n]>Fb&&delete i[n];});for(let n=0;n<e.length;n++){let a=e[n];if(a in i)continue;if(a===this.pathwayId)return;let o=this.hls.nextLoadLevel,d=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,vp(t),this.hls.trigger(p.LEVELS_UPDATED,{levels:t});let l=this.hls.levels[o];d&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==d.bitrate&&this.log(`Unstable Pathways change from bitrate ${d.bitrate} to ${l.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,i){let r=this.getLevelsForPathway(i).concat(this.levels||[]);for(let n=0;n<r.length;n++)if(t===ue.AUDIO_TRACK&&r[n].hasAudioGroup(e)||t===ue.SUBTITLE_TRACK&&r[n].hasSubtitleGroup(e))return r[n].pathwayId;return i}clonePathways(e){let t=this.levels;if(!t)return;let i={},r={};e.forEach(n=>{let{ID:a,"BASE-ID":o,"URI-REPLACEMENT":d}=n;if(t.some(c=>c.pathwayId===a))return;let l=this.getLevelsForPathway(o).map(c=>{let u=new De(c.attrs);u["PATHWAY-ID"]=a;let h=u.AUDIO&&`${u.AUDIO}_clone_${a}`,f=u.SUBTITLES&&`${u.SUBTITLES}_clone_${a}`;h&&(i[u.AUDIO]=h,u.AUDIO=h),f&&(r[u.SUBTITLES]=f,u.SUBTITLES=f);let m=zp(c.uri,u["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",d),g=new fs({attrs:u,audioCodec:c.audioCodec,bitrate:c.bitrate,height:c.height,name:c.name,url:m,videoCodec:c.videoCodec,width:c.width});if(c.audioGroups)for(let 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(...l),xg(this.audioTracks,i,d,a),xg(this.subtitleTracks,r,d,a);});}loadSteeringManifest(e){let t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let r;try{r=new self.URL(e);}catch{this.enabled=false,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){let c=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+c);}let n={responseType:"json",url:r.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},d={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},l={onSuccess:(c,u,h,f)=>{this.log(`Loaded steering manifest: "${r}"`);let m=c.data;if(m?.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;let{"RELOAD-URI":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||h.url),E&&this.clonePathways(E);let T={steeringManifest:m,url:r.toString()};this.hls.trigger(p.STEERING_MANIFEST_LOADED,T),v&&this.updatePathwayPriority(v);},onError:(c,u,h,f)=>{if(this.log(`Error loading steering manifest: ${c.code} ${c.text} (${u.url})`),this.stopLoad(),c.code===410){this.enabled=false,this.log(`Steering manifest ${u.url} no longer available`);return}let m=this.timeToLoad*1e3;if(c.code===429){let g=this.loader;if(typeof g?.getResponseHeader=="function"){let E=g.getResponseHeader("Retry-After");E&&(m=parseFloat(E)*1e3);}this.log(`Steering manifest ${u.url} rate limited`);return}this.scheduleRefresh(this.uri||u.url,m);},onTimeout:(c,u,h)=>{this.log(`Timeout loading steering manifest (${u.url})`),this.scheduleRefresh(this.uri||u.url);}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(n,d,l);}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var i;let r=(i=this.hls)==null?void 0:i.media;if(r&&!r.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3);},t);}};function xg(s,e,t,i){s&&Object.keys(e).forEach(r=>{let n=s.filter(a=>a.groupId===r).map(a=>{let o=Se({},a);return o.details=void 0,o.attrs=new De(o.attrs),o.url=o.attrs.URI=zp(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 zp(s,e,t,i){let{HOST:r,PARAMS:n,[t]:a}=i,o;e&&(o=a?.[e],o&&(s=o));let d=new self.URL(s);return r&&!o&&(d.host=r),n&&Object.keys(n).sort().forEach(l=>{l&&d.searchParams.set(l,n[l]);}),d.href}var pl=class s extends ht{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=s.CDMCleanupPromise?[s.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=t=>{let{initDataType:i,initData:r}=t,n=`"${t.type}" event: init data type: "${i}"`;if(this.debug(n),r!==null){if(!this.keyFormatPromise){let a=Object.keys(this.keySystemAccessPromises);a.length||(a=yn(this.config));let o=a.map(oc).filter(d=>!!d);this.keyFormatPromise=this.getKeyFormatPromise(o);}this.keyFormatPromise.then(a=>{let o=Yo(a);if(i!=="sinf"||o!==Ce.FAIRPLAY){this.log(`Ignoring "${t.type}" event with init data type: "${i}" for selected key-system ${o}`);return}let d;try{let f=Ve(new Uint8Array(r)),m=Xu(JSON.parse(f).sinf),g=zg(m);if(!g)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");d=new Uint8Array(g.subarray(8,24));}catch(f){this.warn(`${n} Failed to parse sinf: ${f}`);return}let l=Ze(d),{keyIdToKeySessionPromise:c,mediaKeySessions:u}=this,h=c[l];for(let f=0;f<u.length;f++){let m=u[f],g=m.decryptdata;if(!g.keyId)continue;let E=Ze(g.keyId);if(ol(d,g.keyId)||g.uri.replace(/-/g,"").indexOf(l)!==-1){if(h=c[E],!h)continue;if(g.pssh)break;delete c[E],g.pssh=new Uint8Array(r),g.keyId=d,h=c[l]=h.then(()=>this.generateRequestWithPreferredKeySession(m,i,r,"encrypted-event-key-match")),h.catch(v=>this.handleError(v));break}}h||this.handleError(new Error(`Key ID ${l} not encountered in playlist. Key-system sessions ${u.length}.`));}).catch(a=>this.handleError(a));}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`);},this.hls=e,this.config=e.config,this.registerListeners();}destroy(){this.onDestroying(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=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),this.hls.on(p.DESTROYING,this.onDestroying,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),this.hls.off(p.DESTROYING,this.onDestroying,this);}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:i}=this.config,r=t?.[e];if(r)return r.licenseUrl;if(e===Ce.WIDEVINE&&i)return i}getLicenseServerUrlOrThrow(e){let t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){let{drmSystems:t}=this.config,i=t?.[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`);}attemptKeySystemAccess(e){let t=this.hls.levels,i=(a,o,d)=>!!a&&d.indexOf(a)===o,r=t.map(a=>a.audioCodec).filter(i),n=t.map(a=>a.videoCodec).filter(i);return r.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{let d=l=>{let c=l.shift();this.getMediaKeysPromise(c,r,n).then(u=>a({keySystem:c,mediaKeys:u})).catch(u=>{l.length?d(l):u instanceof nt?o(u):o(new nt({type:Q.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_ACCESS,error:u,fatal:true},u.message));});};d(e);})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let r=`Configured requestMediaKeySystemAccess is not a function ${i}`;return cp===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){var r;let n=Py(e,t,i,this.config.drmSystemOptions||{}),a=this.keySystemAccessPromises[e],o=(r=a)==null?void 0:r.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${Ae(n)}`),o=this.requestMediaKeySystemAccess(e,n);let d=a=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`);}),o.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);let c=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);let u=d.mediaKeys=l.createMediaKeys().then(h=>(this.log(`Media-keys created for "${e}"`),d.hasMediaKeys=true,c.then(f=>f?this.setMediaKeysServerCertificate(h,e,f):h)));return u.catch(h=>{this.error(`Failed to create media-keys for "${e}"}: ${h}`);}),u})}return o.then(()=>a.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${Ze(e.keyId||[])} keyUri: ${e.uri}`);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=Uo(t),n="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(i,n,t.pssh.buffer,"expired");}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e);}updateKeySession(e,t){let i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyId ${Ze(e.decryptdata.keyId||[])}
|
|
1483
|
+
} (data length: ${t.byteLength})`),i.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>oc(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t,mediaKeys:i})=>this.attemptSetMediaKeys(t,i))}selectKeySystem(e){return new Promise((t,i)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:r})=>{let n=oc(r);n?t(n):i(new Error(`Unable to find format for key-system "${r}"`));}).catch(i);})}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){let t=yn(this.config),i=e.map(Yo).filter(r=>!!r&&t.indexOf(r)!==-1);return this.selectKeySystem(i)}getKeyStatus(e){let{mediaKeySessions:t}=this;for(let i=0;i<t.length;i++){let r=Nb(e,t[i]);if(r)return r}}loadKey(e){let t=e.keyInfo.decryptdata,i=Uo(t),r=this.bannedKeyIds[i];if(r||this.getKeyStatus(t)==="internal-error"){let o=Rg(r||"internal-error",t);return this.handleError(o,e.frag),Promise.reject(o)}let n=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${n}`);let a=this.keyIdToKeySessionPromise[i];if(!a){let o=this.getKeySystemForKeyPromise(t).then(({keySystem:d,mediaKeys:l})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${n}`),this.attemptSetMediaKeys(d,l).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:d,mediaKeys:l,decryptdata:t}))))).then(d=>{let l="cenc",c=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(d,l,c,"playlist-key")});return o.catch(d=>this.handleError(d,e.frag)),this.keyIdToKeySessionPromise[i]=o,o}return a.catch(o=>{if(o instanceof nt){let d=Te({},o.data);this.getKeyStatus(t)==="internal-error"&&(d.decryptdata=t);let l=new nt(d,o.message);this.handleError(l,e.frag);}}),a}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof nt){t&&(e.data.frag=t);let i=e.data.decryptdata;this.error(`${e.message}${i?` (${Ze(i.keyId||[])})`:""}`),this.hls.trigger(p.ERROR,e.data);}else this.error(e.message),this.hls.trigger(p.ERROR,{type:Q.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_KEYS,error:e,fatal:true});}getKeySystemForKeyPromise(e){let t=Uo(e),i=this.keyIdToKeySessionPromise[t];if(!i){let r=Yo(e.keyFormat),n=r?[r]:yn(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=yn(this.config)),e.length===0)throw new nt({type:Q.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:true},`Missing key-system license configuration options ${Ae({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();let i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let r=Promise.all(i).then(()=>this.media?this.media.setMediaKeys(t):new Promise((n,a)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return a(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(n).catch(a);};}));return this.mediaKeys=t,this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>i.indexOf(n)===-1);})}generateRequestWithPreferredKeySession(e,t,i,r){var n;let a=(n=this.config.drmSystems)==null||(n=n[e.keySystem])==null?void 0:n.generateRequest;if(a)try{let m=a.call(this.hls,t,i,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,i=m.initData?m.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null;}catch(m){if(this.warn(m.message),this.hls&&this.hls.config.debug)throw m}if(i===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);let o=Uo(e.decryptdata),d=e.decryptdata.uri;this.log(`Generating key-session request for "${r}" keyId: ${o} URI: ${d} (init data type: ${t} length: ${i.byteLength})`);let l=new Zu,c=e._onmessage=m=>{let g=e.mediaKeysSession;if(!g){l.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(T=>{l.eventNames().length?l.emit("error",T):this.handleError(T);}):E==="license-release"?e.keySystem===Ce.FAIRPLAY&&this.updateKeySession(e,Hc("acknowledged")).then(()=>this.removeSession(e)).catch(T=>this.handleError(T)):this.warn(`unhandled media key message type "${E}"`);},u=(m,g)=>{g.keyStatus=m;let E;m.startsWith("usable")?l.emit("resolved"):m==="internal-error"||m==="output-restricted"||m==="output-downscaled"?E=Rg(m,g.decryptdata):m==="expired"?E=new Error(`key expired (keyId: ${o})`):m==="released"?E=new Error("key released"):m==="status-pending"||this.warn(`unhandled key status change "${m}" (keyId: ${o})`),E&&(l.eventNames().length?l.emit("error",E):this.handleError(E));},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){l.emit("error",new Error("invalid state"));return}let E=this.getKeyStatuses(e);if(!Object.keys(E).some(b=>E[b]!=="status-pending"))return;if(E[o]==="expired"){this.log(`Expired key ${Ae(E)} in key-session "${e.mediaKeysSession.sessionId}"`),this.renewKeySession(e);return}let T=E[o];if(T)u(T,e);else {var S;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(S=e.keyStatusTimeouts)[o]||(S[o]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;let _=this.getKeyStatus(e.decryptdata);if(_&&_!=="status-pending")return this.log(`No status for keyId ${o} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${_} from other session.`),u(_,e);this.log(`key status for ${o} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),T="internal-error",u(T,e);},1e3)),this.log(`No status for keyId ${o} (${Ae(E)}).`);}};at(e.mediaKeysSession,"message",c),at(e.mediaKeysSession,"keystatuseschange",h);let f=new Promise((m,g)=>{l.on("error",g),l.on("resolved",m);});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${o} URI: ${d}`);}).catch(m=>{throw new nt({type:Q.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_SESSION,error:m,decryptdata:e.decryptdata,fatal:false},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>(l.removeAllListeners(),this.removeSession(e).then(()=>{throw m}))).then(()=>(l.removeAllListeners(),e))}getKeyStatuses(e){let t={};return e.mediaKeysSession.keyStatuses.forEach((i,r)=>{if(typeof r=="string"&&typeof i=="object"){let o=r;r=i,i=o;}let n="buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r);if(e.keySystem===Ce.PLAYREADY&&n.length===16){let o=Ze(n);t[o]=i,lp(n);}let a=Ze(n);i==="internal-error"&&(this.bannedKeyIds[a]=i),this.log(`key status change "${i}" for keyStatuses keyId: ${a} key-session "${e.mediaKeysSession.sessionId}"`),t[a]=i;}),t}fetchServerCertificate(e){let t=this.config,i=t.loader,r=new i(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{let d={responseType:"arraybuffer",url:n},l=t.certLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,g)=>{a(h.data);},onError:(h,f,m,g)=>{o(new nt({type:Q.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:true,networkDetails:m,response:Te({url:d.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`));},onTimeout:(h,f,m)=>{o(new nt({type:Q.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:true,networkDetails:m,response:{url:d.url,data:void 0}},`"${e}" certificate request timed out (${n})`));},onAbort:(h,f,m)=>{o(new Error("aborted"));}};r.load(d,c,u);})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((r,n)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),r(e);}).catch(a=>{n(new nt({type:Q.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 nt({type:Q.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:r,fatal:false},r.message)}))}unpackPlayReadyKeyMessage(e,t){let i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;let r=new DOMParser().parseFromString(i,"application/xml"),n=r.querySelectorAll("HttpHeader");if(n.length>0){let c;for(let u=0,h=n.length;u<h;u++){var a,o;c=n[u];let f=(a=c.querySelector("name"))==null?void 0:a.textContent,m=(o=c.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m);}}let d=r.querySelector("Challenge"),l=d?.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return Hc(atob(l))}setupLicenseXHR(e,t,i,r){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,i,r)}).catch(a=>{if(!i.decryptdata)throw a;return e.open("POST",t,true),n.call(this.hls,e,t,i,r)}).then(a=>(e.readyState||e.open("POST",t,true),{xhr:e,licenseChallenge:a||r})):(e.open("POST",t,true),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){let i=this.config.keyLoadPolicy.default;return new Promise((r,n)=>{let a=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${a}`);let o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let d=o.response;this.log(`License received ${d instanceof ArrayBuffer?d.byteLength:d}`);let l=this.config.licenseResponseCallback;if(l)try{d=l.call(this.hls,o,a,e);}catch(c){this.error(c);}r(d);}else {let d=i.errorRetry,l=d?d.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||o.status>=400&&o.status<500)n(new nt({type:Q.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:true,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else {let c=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${c} attempts left`),this.requestLicense(e,t).then(r,n);}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:d,licenseChallenge:l})=>{e.keySystem==Ce.PLAYREADY&&(l=this.unpackPlayReadyKeyMessage(d,l)),d.send(l);}).catch(n);})}onDestroying(){this.unregisterListeners(),this._clear();}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let i=t.media;this.media=i,at(i,"encrypted",this.onMediaEncrypted),at(i,"waitingforkey",this.onWaitingForKey);let r=this.mediaResolved;r?r():this.mediaKeys=i.mediaKeys;}onMediaDetached(){let e=this.media;e&&(ut(e,"encrypted",this.onMediaEncrypted),ut(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null);}_clear(){var e;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};let t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;let i=this.media,r=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,mr.clearKeyUriToKeyIdMap();let n=r.length;s.CDMCleanupPromise=Promise.all(r.map(a=>this.removeSession(a)).concat((i==null||(e=i.setMediaKeys(null))==null?void 0:e.catch(a=>{this.log(`Could not clear media keys: ${a}`),this.hls&&this.hls.trigger(p.ERROR,{type:Q.OTHER_ERROR,details:x.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:false,error:new Error(`Could not clear media keys: ${a}`)});}))||Promise.resolve())).catch(a=>{this.log(`Could not close sessions and clear media keys: ${a}`),this.hls&&this.hls.trigger(p.ERROR,{type:Q.OTHER_ERROR,details:x.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:false,error:new Error(`Could not close sessions and clear media keys: ${a}`)});}).then(()=>{n&&this.log("finished closing key sessions and clearing media keys");});}onManifestLoading(){this._clear();}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,decryptdata:r}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${Ze(r?.keyId||[])}`),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 n=this.mediaKeySessions.indexOf(e);n>-1&&this.mediaKeySessions.splice(n,1);let{keyStatusTimeouts:a}=e;a&&Object.keys(a).forEach(l=>self.clearTimeout(a[l]));let{drmSystemOptions:o}=this.config;return (Fy(o)?new Promise((l,c)=>{self.setTimeout(()=>c(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(l).catch(c);}):Promise.resolve()).catch(l=>{this.log(`Could not remove session: ${l}`),this.hls&&this.hls.trigger(p.ERROR,{type:Q.OTHER_ERROR,details:x.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:false,error:new Error(`Could not remove session: ${l}`)});}).then(()=>t.close()).catch(l=>{this.log(`Could not close session: ${l}`),this.hls&&this.hls.trigger(p.ERROR,{type:Q.OTHER_ERROR,details:x.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:false,error:new Error(`Could not close session: ${l}`)});})}return Promise.resolve()}};pl.CDMCleanupPromise=void 0;function Uo(s){if(!s)throw new Error("Could not read keyId of undefined decryptdata");if(s.keyId===null)throw new Error("keyId is null");return Ze(s.keyId)}function Nb(s,e){if(s.keyId&&e.mediaKeysSession.keyStatuses.has(s.keyId))return e.mediaKeysSession.keyStatuses.get(s.keyId);if(s.matches(e.decryptdata))return e.keyStatus}var nt=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;}};function Rg(s,e){let t=s==="output-restricted",i=t?x.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:x.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new nt({type:Q.KEY_SYSTEM_ERROR,details:i,fatal:false,decryptdata:e},t?"HDCP level output restricted":`key status changed to "${s}"`)}var Eu=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),this.hls.on(p.MEDIA_DETACHING,this.onMediaDetaching,this);}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(p.MEDIA_DETACHING,this.onMediaDetaching,this);}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=false,this.media=null;}onMediaAttaching(e,t){let i=this.hls.config;if(i.capLevelOnFPSDrop){let r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=true),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod);}}onMediaDetaching(){this.media=null;}checkFPS(e,t,i){let r=performance.now();if(t){if(this.lastTime){let n=r-this.lastTime,a=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,d=1e3*a/n,l=this.hls;if(l.trigger(p.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:i}),d>0&&a>l.config.fpsDroppedMonitoringThreshold*o){let c=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(l.autoLevelCapping===-1||l.autoLevelCapping>=c)&&(c=c-1,l.trigger(p.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:l.currentLevel}),l.autoLevelCapping=c,this.streamController.nextLevelSwitch());}}this.lastTime=r,this.lastDroppedFrames=i,this.lastDecodedFrames=t;}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames);}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount);}};function Qp(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 Xp(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){ye.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){ye.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${r}`);}}t==="disabled"&&(s.mode=t);}function or(s,e){let t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues)for(let i=s.cues.length;i--;)e&&s.cues[i].removeEventListener("enter",e),s.removeCue(s.cues[i]);t==="disabled"&&(s.mode=t);}function vu(s,e,t,i){let r=s.mode;if(r==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){let n=$b(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 Ub(s,e){if(e<=s[0].startTime)return 0;let t=s.length-1;if(e>s[t].endTime)return -1;let i=0,r=t,n;for(;i<=r;)if(n=Math.floor((r+i)/2),e<s[n].startTime)r=n-1;else if(e>s[n].startTime&&i<t)i=n+1;else return n;return s[i].startTime-e<e-s[r].startTime?i:r}function $b(s,e,t){let i=[],r=Ub(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 zo(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 Tu=class extends On{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=true,this.queuedDefaultTrack=-1,this.useTextTrackPolling=false,this.subtitlePollingInterval=-1,this._subtitleDisplay=true,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null,i=zo(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(e,t){let i=this.media;if(!i)return;let r=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,r)return;zo(i.textTracks).forEach(a=>{or(a);});}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=true;}onManifestParsed(e,t){this.tracks=t.subtitleTracks;}onSubtitleTrackLoaded(e,t){let{id:i,groupId:r,details:n}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==r){this.warn(`Subtitle track with id:${i} and group:${r} not found in active group ${a?.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Subtitle track ${i} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o);}onLevelLoading(e,t){this.switchLevel(t.level);}onLevelSwitching(e,t){this.switchLevel(t.level);}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let i=t.subtitleGroups||null,r=this.groupIds,n=this.currentTrack;if(!i||r?.length!==i?.length||i!=null&&i.some(a=>r?.indexOf(a)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;let a=this.tracks.filter(c=>!i||i.indexOf(c.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(c=>c.default)&&(this.selectDefaultTrack=false),a.forEach((c,u)=>{c.id=u;});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;let o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=false;let c=fi(o,a);if(c>-1)n=a[c];else {let u=fi(o,this.tracks);n=this.tracks[u];}}let d=this.findTrackId(n);d===-1&&n&&(d=this.findTrackId(null));let l={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${i?.join(",")}" group-id`),this.hls.trigger(p.SUBTITLE_TRACKS_UPDATED,l),d!==-1&&this.trackId===-1&&this.setSubtitleTrack(d);}}findTrackId(e){let t=this.tracksInGroup,i=this.selectDefaultTrack;for(let r=0;r<t.length;r++){let n=t[r];if(!(i&&!n.default||!i&&!e)&&(!e||us(n,e)))return r}if(e){for(let r=0;r<t.length;r++){let n=t[r];if(Fn(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){let n=t[r];if(Fn(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(au(r,e))return i}}return -1}onError(e,t){t.fatal||!t.context||t.context.type===ue.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t);}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=false,this.setSubtitleTrack(e);}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(e.id===-1)return this.setSubtitleTrack(-1),null;let t=this.allSubtitleTracks;if(this.selectDefaultTrack=false,t.length){let i=this.currentTrack;if(i&&us(e,i))return i;let r=fi(e,this.tracksInGroup);if(r>-1){let n=this.tracksInGroup[r];return this.setSubtitleTrack(r),n}else {if(i)return null;{let n=fi(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e);}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=e.id,r=e.groupId,n=this.getUrlWithDirectives(e.url,t),a=e.details,o=a?.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${n}`),this.hls.trigger(p.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:t||null,track:e});}toggleTrackModes(){let{media:e}=this;if(!e)return;let t=zo(e.textTracks),i=this.currentTrack,r;if(i&&(r=t.filter(n=>au(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||!H(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.selectDefaultTrack=false;let i=this.currentTrack,r=t[e]||null;if(this.trackId=e,this.currentTrack=r,this.toggleTrackModes(),!r){this.hls.trigger(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:d,type:l,url:c}=r;this.hls.trigger(p.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:d,type:l,url:c});let u=this.switchParams(r.url,i?.details,r.details);this.loadPlaylist(u);}};function Bb(){try{return crypto.randomUUID()}catch{try{let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(r=="x"?n:n&3|8).toString(16)})}}}function An(s){let e=5381,t=s.length;for(;t;)e=e*33^s.charCodeAt(--t);return (e>>>0).toString()}var hr=.025,El=(function(s){return s[s.Point=0]="Point",s[s.Range=1]="Range",s})({});function Gb(s,e,t){return `${s.identifier}-${t+1}-${An(e)}`}var yu=class{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=false,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:false,jump:false},this.snapOptions={out:false,in:false},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e);}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions);}reset(){var e;this.appendInPlaceStarted=false,(e=this.assetListLoader)==null||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null);}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return true;let i=this.playoutLimit;return e<=0||isNaN(i)?false:i===0?true:(((t=this.assetList[e])==null?void 0:t.startOffset)||0)>i}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){let e=this.dateRange.startTime;if(this.snapOptions.out){let t=this.dateRange.tagAnchor;if(t)return pc(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(this.startTime===0||this.snapOptions.out)return true;let e=this.dateRange.tagAnchor;if(e){let t=this.dateRange.startTime,i=pc(t,e);return t-i<.1}return false}get resumptionOffset(){let e=this.resumeOffset,t=H(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){let e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){let t=this.resumeAnchor;if(t)return pc(e,t)}return e}get appendInPlace(){return this.appendInPlaceStarted?true:this.appendInPlaceDisabled?false:!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<hr))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e;}get timelineStart(){return this._timelineStart!==null?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e;}get duration(){let e=this.playoutLimit,t;return this._duration!==null?t=this._duration:this.dateRange.duration?t=this.dateRange.duration:t=this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e;}get cue(){return this.dateRange.cue}get timelineOccupancy(){return this.dateRange.attr["X-TIMELINE-OCCUPIES"]==="RANGE"?El.Range:El.Point}get supplementsPrimary(){return this.dateRange.attr["X-TIMELINE-STYLE"]==="PRIMARY"}get contentMayVary(){return this.dateRange.attr["X-CONTENT-MAY-VARY"]!=="NO"}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||this.assetListResponse!==null}toString(){return Hb(this)}};function pc(s,e){return s-e.start<e.duration/2&&!(Math.abs(s-(e.start+e.duration))<hr)?e.start:e.start+e.duration}function Zp(s,e,t){let i=new self.URL(s,t);return i.protocol!=="data:"&&i.searchParams.set("_HLS_primary_id",e),i}function Ec(s,e){for(;(t=s.assetList[++e])!=null&&t.error;)var t;return e}function Hb(s){return `["${s.identifier}" ${s.cue.pre?"<pre>":s.cue.post?"<post>":""}${s.timelineStart.toFixed(2)}-${s.resumeTime.toFixed(2)}]`}function ar(s){let e=s.timelineStart,t=s.duration||0;return `["${s.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}var Su=class{constructor(e,t,i,r){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=false,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(p.PLAYOUT_LIMIT_REACHED,{});};let n=this.hls=new e(t);this.interstitial=i,this.assetItem=r;let a=()=>{this.hasDetails=true;};n.once(p.LEVEL_LOADED,a),n.once(p.AUDIO_TRACK_LOADED,a),n.once(p.SUBTITLE_TRACK_LOADED,a),n.on(p.MEDIA_ATTACHING,(o,{media:d})=>{this.removeMediaListeners(),this.mediaAttached=d,this.interstitial.playoutLimit&&(d.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&n.on(p.BUFFER_APPENDED,()=>{let c=this.bufferedEnd;this.reachedPlayout(c)&&(this._bufferedEosTime=c,n.trigger(p.BUFFERED_TO_END,void 0));}));});}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){let e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,true);else {let t=this.assetItem.uri;try{t=Zp(t,e.config.primarySessionId||"").href;}catch{}e.loadSource(t);}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return false;if((t=this.hls)!=null&&t.bufferedToEnd)return true;if(!e)return false;let i=Math.min(this._bufferedEosTime||1/0,this.duration),r=this.timelineOffset,n=ne.bufferInfo(e,r,0);return this.getAssetTime(n.end)>=i-.02}reachedPlayout(e){let i=this.interstitial.playoutLimit;return this.startOffset+e>=i}get destroyed(){var e;return !((e=this.hls)!=null&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return ((e=this.hls)==null?void 0:e.media)||null}get bufferedEnd(){let e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;let t=ne.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){let e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){let e=this.assetItem.duration;if(!e)return 0;let t=this.interstitial.playoutLimit;if(t){let i=t-this.startOffset;if(i>0&&i<e)return i}return e}get remaining(){let e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return ((e=this.hls)==null?void 0:e.config.timelineOffset)||0}set timelineOffset(e){let t=this.timelineOffset;if(e!==t){let i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e;}}}getAssetTime(e){let t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}removeMediaListeners(){let e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout));}bufferSnapShot(){if(this.mediaAttached){var e;(e=this.hls)!=null&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd);}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null;}attachMedia(e){var t;this.loadSource(),(t=this.hls)==null||t.attachMedia(e);}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,(e=this.hls)==null||e.detachMedia();}resumeBuffering(){var e;(e=this.hls)==null||e.resumeBuffering();}pauseBuffering(){var e;(e=this.hls)==null||e.pauseBuffering();}transferMedia(){var e;return this.bufferSnapShot(),((e=this.hls)==null?void 0:e.transferMedia())||null}resetDetails(){let e=this.hls;if(e&&this.hasDetails){e.stopLoad();let t=i=>delete i.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=false;}}on(e,t,i){var r;(r=this.hls)==null||r.on(e,t);}once(e,t,i){var r;(r=this.hls)==null||r.once(e,t);}off(e,t,i){var r;(r=this.hls)==null||r.off(e,t);}toString(){var e;return `HlsAssetPlayer: ${ar(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}},kg=.033,bu=class extends ht{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e;}destroy(){this.reset(),this.onScheduleUpdate=null;}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null;}resetErrorsInRange(e,t){return this.events?this.events.reduce((i,r)=>e<=r.startOffset&&t>r.startOffset?(delete r.error,i+1):i,0):0}get duration(){let e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);let r=this.items;if(r)for(r[i]||(t===void 0&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&(n=r[i])!=null&&n.event;){var n;i--;}return i}findItemIndexAtTime(e,t){let i=this.items;if(i)for(let r=0;r<i.length;r++){let n=i[r];if(t&&t!=="primary"&&(n=n[t]),e===n.start||e>n.start&&e<n.end)return r}return -1}findJumpRestrictedIndex(e,t){let i=this.items;if(i)for(let r=e;r<=t&&i[r];r++){let n=i[r].event;if(n!=null&&n.restrictions.jump&&!n.appendInPlace)return r}return -1}findEventIndex(e){let t=this.items;if(t)for(let r=t.length;r--;){var i;if(((i=t[r].event)==null?void 0:i.identifier)===e)return r}return -1}findAssetIndex(e,t){let i=e.assetList,r=i.length;if(r>1)for(let n=0;n<r;n++){let a=i[n];if(!a.error){let o=a.timelineStart;if(t===o||t>o&&(t<o+(a.duration||0)||n===r-1))return n}}return 0}get assetIdAtEnd(){var e;let t=(e=this.items)==null||(e=e[this.length-1])==null?void 0:e.event;if(t){let i=t.assetList,r=i[i.length-1];if(r)return r.identifier}return null}parseInterstitialDateRanges(e,t){let i=e.main.details,{dateRanges:r}=i,n=this.events,a=this.parseDateRanges(r,{url:i.url},t),o=Object.keys(r),d=n?n.filter(l=>!o.includes(l.identifier)):[];a.length&&a.sort((l,c)=>{let u=l.cue.pre,h=l.cue.post,f=c.cue.pre,m=c.cue.post;if(u&&!f)return -1;if(f&&!u||h&&!m)return 1;if(m&&!h)return -1;if(!u&&!f&&!h&&!m){let g=l.startTime,E=c.startTime;if(g!==E)return g-E}return l.dateRange.tagOrder-c.dateRange.tagOrder}),this.events=a,d.forEach(l=>{this.removeEvent(l);}),this.updateSchedule(e,d);}updateSchedule(e,t=[],i=false){let r=this.events||[];if(r.length||t.length||this.length<2){let n=this.items,a=this.parseSchedule(r,e);(i||t.length||n?.length!==a.length||a.some((d,l)=>Math.abs(d.playout.start-n[l].playout.start)>.005||Math.abs(d.playout.end-n[l].playout.end)>.005))&&(this.items=a,this.onScheduleUpdate(t,n));}}parseDateRanges(e,t,i){let r=[],n=Object.keys(e);for(let a=0;a<n.length;a++){let o=n[a],d=e[o];if(d.isInterstitial){let l=this.eventMap[o];l?l.setDateRange(d):(l=new yu(d,t),this.eventMap[o]=l,i===false&&(l.appendInPlace=i)),r.push(l);}}return r}parseSchedule(e,t){let i=[],r=t.main.details,n=r.live?1/0:r.edge,a=0;if(e=e.filter(d=>!d.error&&!(d.cue.once&&d.hasPlayed)),e.length){this.resolveOffsets(e,t);let d=0,l=0;if(e.forEach((c,u)=>{let h=c.cue.pre,f=c.cue.post,m=e[u-1]||null,g=c.appendInPlace,E=f?n:c.startOffset,v=c.duration,T=c.timelineOccupancy===El.Range?v:0,S=c.resumptionOffset,b=m?.startTime===E,_=E+c.cumulativeDuration,D=g?_+v:E+S;if(h||!f&&E<=0){let k=l;l+=T,c.timelineStart=_;let R=a;a+=v,i.push({event:c,start:_,end:D,playout:{start:R,end:a},integrated:{start:k,end:l}});}else if(E<=n){if(!b){let L=E-d;if(L>kg){let w=d,B=l;l+=L;let K=a;a+=L;let z={previousEvent:e[u-1]||null,nextEvent:c,start:w,end:w+L,playout:{start:K,end:a},integrated:{start:B,end:l}};i.push(z);}else L>0&&m&&(m.cumulativeDuration+=L,i[i.length-1].end=E);}f&&(D=_),c.timelineStart=_;let k=l;l+=T;let R=a;a+=v,i.push({event:c,start:_,end:D,playout:{start:R,end:a},integrated:{start:k,end:l}});}else return;let I=c.resumeTime;f||I>n?d=n:d=I;}),d<n){var o;let c=d,u=l,h=n-d;l+=h;let f=a;a+=h,i.push({previousEvent:((o=i[i.length-1])==null?void 0:o.event)||null,nextEvent:null,start:d,end:c+h,playout:{start:f,end:a},integrated:{start:u,end:l}});}this.setDurations(n,a,l);}else i.push({previousEvent:null,nextEvent:null,start:0,end:n,playout:{start:0,end:n},integrated:{start:0,end:n}}),this.setDurations(n,n,n);return i}setDurations(e,t,i){this.durations={primary:e,playout:t,integrated:i};}resolveOffsets(e,t){let i=t.main.details,r=i.live?1/0:i.edge,n=0,a=-1;e.forEach((o,d)=>{let l=o.cue.pre,c=o.cue.post,u=l?0:c?r:o.startTime;this.updateAssetDurations(o),a===u?o.cumulativeDuration=n:(n=0,a=u),!c&&o.snapOptions.in&&(o.resumeAnchor=ms(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=false)),!o.appendInPlace&&d+1<e.length&&e[d+1].startTime-e[d].resumeTime<kg&&(e[d+1].appendInPlace=false,e[d+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`));let f=H(o.resumeOffset)?o.resumeOffset:o.duration;n+=f;});}primaryCanResumeInPlaceAt(e,t){let i=e.resumeTime,r=e.startTime+e.resumptionOffset;return Math.abs(i-r)>hr?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${r}`),false):!Object.keys(t).some(a=>{let o=t[a].details,d=o.edge;if(i>=d)return this.log(`"${e.identifier}" resumption ${i} past ${a} playlist end ${d}`),false;let l=ms(null,o.fragments,i);if(!l)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${a} playlist (${o.fragStart}-${o.fragmentEnd})`),true;let c=a==="audio"?.175:0;return Math.abs(l.start-i)<hr+c||Math.abs(l.end-i)<hr+c?false:(this.log(`"${e.identifier}" resumption ${i} not aligned with ${a} fragment bounds (${l.start}-${l.end} sn: ${l.sn} cc: ${l.cc})`),true)})}updateAssetDurations(e){if(!e.assetListLoaded)return;let t=e.timelineStart,i=0,r=false,n=false;for(let a=0;a<e.assetList.length;a++){let o=e.assetList[a],d=t+i;o.startOffset=i,o.timelineStart=d,r||(r=o.duration===null),n||(n=!!o.error);let l=o.error?0:o.duration||0;i+=l;}r&&!n?e.duration=Math.max(i,e.duration):e.duration=i;}removeEvent(e){e.reset(),delete this.eventMap[e.identifier];}};function Gt(s){return `[${s.event?'"'+s.event.identifier+'"':"primary"}: ${s.start.toFixed(2)}-${s.end.toFixed(2)}]`}var Au=class{constructor(e){this.hls=void 0,this.hls=e;}destroy(){this.hls=null;}loadAssetList(e,t){let i=e.assetListUrl,r;try{r=Zp(i,this.hls.sessionId,e.baseUrl);}catch(h){let f=this.assignAssetListError(e,x.ASSET_LIST_LOAD_ERROR,h,i);this.hls.trigger(p.ERROR,f);return}t&&r.protocol!=="data:"&&r.searchParams.set("_HLS_start_offset",""+t);let n=this.hls.config,a=n.loader,o=new a(n),d={responseType:"json",url:r.href},l=n.interstitialAssetListLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,g)=>{let E=h.data,v=E?.ASSETS;if(!Array.isArray(v)){let T=this.assignAssetListError(e,x.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),m.url,f,g);this.hls.trigger(p.ERROR,T);return}e.assetListResponse=E,this.hls.trigger(p.ASSET_LIST_LOADED,{event:e,assetListResponse:E,networkDetails:g});},onError:(h,f,m,g)=>{let E=this.assignAssetListError(e,x.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${h.code} ${h.text} (${f.url})`),f.url,g,m);this.hls.trigger(p.ERROR,E);},onTimeout:(h,f,m)=>{let g=this.assignAssetListError(e,x.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${f.url})`),f.url,h,m);this.hls.trigger(p.ERROR,g);}};return o.load(d,c,u),this.hls.trigger(p.ASSET_LIST_LOADING,{event:e}),o}assignAssetListError(e,t,i,r,n,a){return e.error=i,{type:Q.NETWORK_ERROR,details:t,fatal:false,interstitial:e,url:r,error:i,networkDetails:a,stats:n}}};function Dg(s){var e;s==null||(e=s.play())==null||e.catch(()=>{});}function $o(s,e){return `[${s}] Advancing timeline position to ${e}`}var _u=class extends ht{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=false,this.onPlay=()=>{this.shouldPlay=true;},this.onPause=()=>{this.shouldPlay=false;},this.onSeeking=()=>{let i=this.currentTime;if(i===void 0||this.playbackDisabled||!this.schedule)return;let r=i-this.timelinePos;if(Math.abs(r)<1/7056e5)return;let a=r<=-0.01;this.timelinePos=i,this.bufferedPos=i;let o=this.playingItem;if(!o){this.checkBuffer();return}if(a&&this.schedule.resetErrorsInRange(i,i-r)&&this.updateSchedule(true),this.checkBuffer(),a&&i<o.start||i>=o.end){var d;let f=this.findItemIndex(o),m=this.schedule.findItemIndexAtTime(i);if(m===-1&&(m=f+(a?-1:1),this.log(`seeked ${a?"back ":""}to position not covered by schedule ${i} (resolving from ${f} to ${m})`)),!this.isInterstitial(o)&&(d=this.media)!=null&&d.paused&&(this.shouldPlay=false),!a&&m>f){let g=this.schedule.findJumpRestrictedIndex(f+1,m);if(g>f){this.setSchedulePosition(g);return}}this.setSchedulePosition(m);return}let l=this.playingAsset;if(!l){if(this.playingLastItem&&this.isInterstitial(o)){let f=o.event.assetList[0];f&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,f));}return}let c=l.timelineStart,u=l.duration||0;if(a&&i<c||i>=c+u){var h;(h=o.event)!=null&&h.appendInPlace&&(this.clearAssetPlayers(o.event,o),this.flushFrontBuffer(i)),this.setScheduleToAssetAtTime(i,l);}},this.onTimeupdate=()=>{let i=this.currentTime;if(i===void 0||this.playbackDisabled)return;if(i>this.timelinePos)this.timelinePos=i,i>this.bufferedPos&&this.checkBuffer();else return;let r=this.playingItem;if(!r||this.playingLastItem)return;if(i>=r.end){this.timelinePos=r.end;let o=this.findItemIndex(r);this.setSchedulePosition(o+1);}let n=this.playingAsset;if(!n)return;let a=n.timelineStart+(n.duration||0);i>=a&&this.setScheduleToAssetAtTime(i,n);},this.onScheduleUpdate=(i,r)=>{let n=this.schedule;if(!n)return;let a=this.playingItem,o=n.events||[],d=n.items||[],l=n.durations,c=i.map(g=>g.identifier),u=!!(o.length||c.length);(u||r)&&this.log(`INTERSTITIALS_UPDATED (${o.length}): ${o}
|
|
1484
|
+
Schedule: ${d.map(g=>Gt(g))} pos: ${this.timelinePos}`),c.length&&this.log(`Removed events ${c}`);let h=null,f=null;a&&(h=this.updateItem(a,this.timelinePos),this.itemsMatch(a,h)?this.playingItem=h:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);let m=this.bufferingItem;if(m&&(f=this.updateItem(m,this.bufferedPos),this.itemsMatch(m,f)?this.bufferingItem=f:m.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(m.event,null))),i.forEach(g=>{g.assetList.forEach(E=>{this.clearAssetPlayer(E.identifier,null);});}),this.playerQueue.forEach(g=>{if(g.interstitial.appendInPlace){let E=g.assetItem.timelineStart,v=g.timelineOffset-E;if(v)try{g.timelineOffset=E;}catch(T){Math.abs(v)>hr&&this.warn(`${T} ("${g.assetId}" ${g.timelineOffset}->${E})`);}}}),u||r){if(this.hls.trigger(p.INTERSTITIALS_UPDATED,{events:o.slice(0),schedule:d.slice(0),durations:l,removedIds:c}),this.isInterstitial(a)&&c.includes(a.event.identifier)){this.warn(`Interstitial "${a.event.identifier}" removed while playing`),this.primaryFallback(a.event);return}a&&this.trimInPlace(h,a),m&&f!==h&&this.trimInPlace(f,m),this.checkBuffer();}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new Au(e),this.schedule=new bu(this.onScheduleUpdate,e.logger),this.registerListeners();}registerListeners(){let e=this.hls;e&&(e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,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_UPDATED,this.onLevelUpdated,this),e.on(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(p.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(p.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(p.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(p.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(p.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(p.BUFFER_APPENDED,this.onBufferAppended,this),e.on(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(p.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(p.MEDIA_ENDED,this.onMediaEnded,this),e.on(p.ERROR,this.onError,this),e.on(p.DESTROYING,this.onDestroying,this));}unregisterListeners(){let e=this.hls;e&&(e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,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_UPDATED,this.onLevelUpdated,this),e.off(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(p.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(p.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(p.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(p.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(p.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(p.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.BUFFER_APPENDED,this.onBufferAppended,this),e.off(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(p.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(p.MEDIA_ENDED,this.onMediaEnded,this),e.off(p.ERROR,this.onError,this),e.off(p.DESTROYING,this.onDestroying,this));}startLoad(){this.resumeBuffering();}stopLoad(){this.pauseBuffering();}resumeBuffering(){var e;(e=this.getBufferingPlayer())==null||e.resumeBuffering();}pauseBuffering(){var e;(e=this.getBufferingPlayer())==null||e.pauseBuffering();}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null;}onDestroying(){let e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e);}removeMediaListeners(e){ut(e,"play",this.onPlay),ut(e,"pause",this.onPause),ut(e,"seeking",this.onSeeking),ut(e,"timeupdate",this.onTimeupdate);}onMediaAttaching(e,t){let i=this.media=t.media;at(i,"seeking",this.onSeeking),at(i,"timeupdate",this.onTimeupdate),at(i,"play",this.onPlay),at(i,"pause",this.onPause);}onMediaAttached(e,t){let i=this.effectivePlayingItem,r=this.detachedData;if(this.detachedData=null,i===null)this.checkStart();else if(!r){this.clearScheduleState();let n=this.findItemIndex(i);this.setSchedulePosition(n);}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null;}onMediaDetaching(e,t){let i=!!t.transferMedia,r=this.media;if(this.media=null,!i&&(r&&this.removeMediaListeners(r),this.detachedData)){let n=this.getBufferingPlayer();n&&(this.log(`Removing schedule state for detachedData and ${n}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,n.detachMedia()),this.shouldPlay=false;}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;let e=this,t=()=>e.bufferingItem||e.waitingItem,i=u=>u&&e.getAssetPlayer(u.identifier),r=(u,h,f,m,g)=>{if(u){let E=u[h].start,v=u.event;if(v){if(h==="playout"||v.timelineOccupancy!==El.Point){let T=i(f);T?.interstitial===v&&(E+=T.assetItem.startOffset+T[g]);}}else {let T=m==="bufferedPos"?a():e[m];E+=T-u.start;}return E}return 0},n=(u,h)=>{var f;if(u!==0&&h!=="primary"&&(f=e.schedule)!=null&&f.length){var m;let g=e.schedule.findItemIndexAtTime(u),E=(m=e.schedule.items)==null?void 0:m[g];if(E){let v=E[h].start-E.start;return u+v}}return u},a=()=>{let u=e.bufferedPos;return u===Number.MAX_VALUE?o("primary"):Math.max(u,0)},o=u=>{var h,f;return (h=e.primaryDetails)!=null&&h.live?e.primaryDetails.edge:((f=e.schedule)==null?void 0:f.durations[u])||0},d=(u,h)=>{var f,m;let g=e.effectivePlayingItem;if(g!=null&&(f=g.event)!=null&&f.restrictions.skip||!e.schedule)return;e.log(`seek to ${u} "${h}"`);let E=e.effectivePlayingItem,v=e.schedule.findItemIndexAtTime(u,h),T=(m=e.schedule.items)==null?void 0:m[v],S=e.getBufferingPlayer(),b=S?.interstitial,_=b?.appendInPlace,D=E&&e.itemsMatch(E,T);if(E&&(_||D)){let I=i(e.playingAsset),k=I?.media||e.primaryMedia;if(k){let R=h==="primary"?k.currentTime:r(E,h,e.playingAsset,"timelinePos","currentTime"),L=u-R,w=(_?R:k.currentTime)+L;if(w>=0&&(!I||_||w<=I.duration)){k.currentTime=w;return}}}if(T){let I=u;if(h!=="primary"){let R=T[h].start,L=u-R;I=T.start+L;}let k=!e.isInterstitial(T);if((!e.isInterstitial(E)||E.event.appendInPlace)&&(k||T.event.appendInPlace)){let R=e.media||(_?S?.media:null);R&&(R.currentTime=I);}else if(E){let R=e.findItemIndex(E);if(v>R){let w=e.schedule.findJumpRestrictedIndex(R+1,v);if(w>R){e.setSchedulePosition(w);return}}let L=0;if(k)e.timelinePos=I,e.checkBuffer();else {let w=T.event.assetList,B=u-(T[h]||T).start;for(let K=w.length;K--;){let z=w[K];if(z.duration&&B>=z.startOffset&&B<z.startOffset+z.duration){L=K;break}}}e.setSchedulePosition(v,L);}}},l=()=>{let u=e.effectivePlayingItem;if(e.isInterstitial(u))return u;let h=t();return e.isInterstitial(h)?h:null},c={get bufferedEnd(){let u=t(),h=e.bufferingItem;if(h&&h===u){var f;return r(h,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-h.playout.start||((f=e.bufferingAsset)==null?void 0:f.startOffset)||0}return 0},get currentTime(){let u=l(),h=e.effectivePlayingItem;return h&&h===u?r(h,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-h.playout.start:0},set currentTime(u){let h=l(),f=e.effectivePlayingItem;f&&f===h&&d(u+f.playout.start,"playout");},get duration(){let u=l();return u?u.playout.end-u.playout.start:0},get assetPlayers(){var u;let h=(u=l())==null?void 0:u.event.assetList;return h?h.map(f=>e.getAssetPlayer(f.identifier)):[]},get playingIndex(){var u;let h=(u=l())==null?void 0:u.event;return h&&e.effectivePlayingAsset?h.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return l()}};return this.manager={get events(){var u;return ((u=e.schedule)==null||(u=u.events)==null?void 0:u.slice(0))||[]},get schedule(){var u;return ((u=e.schedule)==null||(u=u.items)==null?void 0:u.slice(0))||[]},get interstitialPlayer(){return l()?c:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){let u=t();return e.findItemIndex(u)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){let u=e.effectivePlayingItem;return e.findItemIndex(u)},primary:{get bufferedEnd(){return a()},get currentTime(){let u=e.timelinePos;return u>0?u:0},set currentTime(u){d(u,"primary");},get duration(){return o("primary")},get seekableStart(){var u;return ((u=e.primaryDetails)==null?void 0:u.fragmentStart)||0}},integrated:{get bufferedEnd(){return r(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return r(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(u){d(u,"integrated");},get duration(){return o("integrated")},get seekableStart(){var u;return n(((u=e.primaryDetails)==null?void 0:u.fragmentStart)||0,"integrated")}},skip:()=>{let u=e.effectivePlayingItem,h=u?.event;if(h&&!h.restrictions.skip){let f=e.findItemIndex(u);if(h.appendInPlace){let m=u.playout.start+u.event.duration;d(m+.001,"playout");}else e.advanceAfterAssetEnded(h,f,1/0);}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;let t=this.playingItem,i=(e=this.schedule)==null?void 0:e.items;return !this.playbackStarted||!t||!i?false:this.findItemIndex(t)===i.length-1}get playbackStarted(){return this.effectivePlayingItem!==null}get currentTime(){var e,t;if(this.mediaSelection===null)return;let i=this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&!i.event.appendInPlace)return;let r=this.media;!r&&(e=this.bufferingItem)!=null&&(e=e.event)!=null&&e.appendInPlace&&(r=this.primaryMedia);let n=(t=r)==null?void 0:t.currentTime;if(!(n===void 0||!H(n)))return n}get primaryMedia(){var e;return this.media||((e=this.detachedData)==null?void 0:e.media)||null}isInterstitial(e){return !!(e!=null&&e.event)}retreiveMediaSource(e,t){let i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t);}transferMediaFromPlayer(e,t){let i=e.interstitial.appendInPlace,r=e.media;if(i&&r===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&r){this.detachedData={media:r};return}let n=e.transferMedia();this.log(`transfer MediaSource from ${e} ${Ae(n)}`),this.detachedData=n;}else t&&r&&(this.shouldPlay||(this.shouldPlay=!r.paused));}transferMediaTo(e,t){var i,r;if(e.media===t)return;let n=null,a=this.hls,o=e!==a,d=o&&e.interstitial.appendInPlace,l=(i=this.detachedData)==null?void 0:i.mediaSource,c;if(a.media)d&&(n=a.transferMedia(),this.detachedData=n),c="Primary";else if(l){let m=this.getBufferingPlayer();m?(n=m.transferMedia(),c=`${m}`):c="detached MediaSource";}else c="detached media";if(!n){if(l)n=this.detachedData,this.log(`using detachedData: MediaSource ${Ae(n)}`);else if(!this.detachedData||a.media===t){let m=this.playerQueue;m.length>1&&m.forEach(g=>{if(o&&g.interstitial.appendInPlace!==d){let E=g.interstitial;this.clearInterstitial(g.interstitial,null),E.appendInPlace=false,E.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${E}`);}}),this.hls.detachMedia(),this.detachedData={media:t};}}let u=n&&"mediaSource"in n&&((r=n.mediaSource)==null?void 0:r.readyState)!=="closed",h=u&&n?n:t;this.log(`${u?"transfering MediaSource":"attaching media"} to ${o?e:"Primary"} from ${c} (media.currentTime: ${t.currentTime})`);let f=this.schedule;if(h===n&&f){let m=o&&e.assetId===f.assetIdAtEnd;h.overrides={duration:f.duration,endOfStream:!o||m,cueRemoval:!o};}e.attachMedia(h);}onInterstitialCueEnter(){this.onTimeupdate();}checkStart(){let e=this.schedule,t=e?.events;if(!t||this.playbackDisabled||!this.media)return;this.bufferedPos===-1&&(this.bufferedPos=0);let i=this.timelinePos,r=this.effectivePlayingItem;if(i===-1){let n=this.hls.startPosition;if(this.log($o("checkStart",n)),this.timelinePos=n,t.length&&t[0].cue.pre){let a=e.findEventIndex(t[0].identifier);this.setSchedulePosition(a);}else if(n>=0||!this.primaryLive){let a=this.timelinePos=n>0?n:0,o=e.findItemIndexAtTime(a);this.setSchedulePosition(o);}}else if(r&&!this.playingItem){let n=e.findItemIndex(r);this.setSchedulePosition(n);}}advanceAssetBuffering(e,t){let i=e.event,r=i.findAssetIndex(t),n=Ec(i,r);if(!i.isAssetPastPlayoutLimit(n))this.bufferedToEvent(e,n);else if(this.schedule){var a;let o=(a=this.schedule.items)==null?void 0:a[this.findItemIndex(e)+1];o&&this.bufferedToItem(o);}}advanceAfterAssetEnded(e,t,i){let r=Ec(e,i);if(e.isAssetPastPlayoutLimit(r)){if(this.schedule){let n=this.schedule.items;if(n){let a=t+1,o=n.length;if(a>=o){this.setSchedulePosition(-1);return}let d=e.resumeTime;this.timelinePos<d&&(this.log($o("advanceAfterAssetEnded",d)),this.timelinePos=d,e.appendInPlace&&this.advanceInPlace(d),this.checkBuffer(this.bufferedPos<d)),this.setSchedulePosition(a);}}}else {if(e.appendInPlace){let n=e.assetList[r];n&&this.advanceInPlace(n.timelineStart);}this.setSchedulePosition(t,r);}}setScheduleToAssetAtTime(e,t){let i=this.schedule;if(!i)return;let r=t.parentIdentifier,n=i.getEvent(r);if(n){let a=i.findEventIndex(r),o=i.findAssetIndex(n,e);this.advanceAfterAssetEnded(n,a,o-1);}}setSchedulePosition(e,t){var i;let r=(i=this.schedule)==null?void 0:i.items;if(!r||this.playbackDisabled)return;let n=e>=0?r[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${n&&Gt(n)}) pos: ${this.timelinePos}`);let a=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(a)){let c=a.event,u=this.playingAsset,h=u?.identifier,f=h?this.getAssetPlayer(h):null;if(f&&h&&(!this.eventItemsMatch(a,n)||t!==void 0&&h!==c.assetList[t].identifier)){var d;let m=c.findAssetIndex(u);if(this.log(`INTERSTITIAL_ASSET_ENDED ${m+1}/${c.assetList.length} ${ar(u)}`),this.endedAsset=u,this.playingAsset=null,this.hls.trigger(p.INTERSTITIAL_ASSET_ENDED,{asset:u,assetListIndex:m,event:c,schedule:r.slice(0),scheduleIndex:e,player:f}),a!==this.playingItem){this.itemsMatch(a,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(c,this.findItemIndex(this.playingItem),m);return}this.retreiveMediaSource(h,n),f.media&&!((d=this.detachedData)!=null&&d.mediaSource)&&f.detachMedia();}if(!this.eventItemsMatch(a,n)&&(this.endedItem=a,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${c} ${Gt(a)}`),c.hasPlayed=true,this.hls.trigger(p.INTERSTITIAL_ENDED,{event:c,schedule:r.slice(0),scheduleIndex:e}),c.cue.once)){var l;this.updateSchedule();let m=(l=this.schedule)==null?void 0:l.items;if(n&&m){let g=this.findItemIndex(n);this.advanceSchedule(g,m,t,a,o);}return}}this.advanceSchedule(e,r,t,a,o);}advanceSchedule(e,t,i,r,n){let a=this.schedule;if(!a)return;let o=t[e]||null,d=this.primaryMedia,l=this.playerQueue;if(l.length&&l.forEach(c=>{let u=c.interstitial,h=a.findEventIndex(u.identifier);(h<e||h>e+1)&&this.clearInterstitial(u,o);}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);let c=o.event;if(i===void 0){i=a.findAssetIndex(c,this.timelinePos);let m=Ec(c,i-1);if(c.isAssetPastPlayoutLimit(m)||c.appendInPlace&&this.timelinePos===o.end){this.advanceAfterAssetEnded(c,e,i);return}i=m;}let u=this.waitingItem;this.assetsBuffered(o,d)||this.setBufferingItem(o);let h=this.preloadAssets(c,i);if(this.eventItemsMatch(o,u||r)||(this.waitingItem=o,this.log(`INTERSTITIAL_STARTED ${Gt(o)} ${c.appendInPlace?"append in place":""}`),this.hls.trigger(p.INTERSTITIAL_STARTED,{event:c,schedule:t.slice(0),scheduleIndex:e})),!c.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${c}`);return}if(c.assetListLoader&&(c.assetListLoader.destroy(),c.assetListLoader=void 0),!d){this.log(`Waiting for attachMedia to start Interstitial ${c}`);return}this.waitingItem=this.endedItem=null,this.playingItem=o;let f=c.assetList[i];if(!f){this.advanceAfterAssetEnded(c,e,i||0);return}if(h||(h=this.getAssetPlayer(f.identifier)),h===null||h.destroyed){let m=c.assetList.length;this.warn(`asset ${i+1}/${m} player destroyed ${c}`),h=this.createAssetPlayer(c,f,i),h.loadSource();}if(!this.eventItemsMatch(o,this.bufferingItem)&&c.appendInPlace&&this.isAssetBuffered(f))return;this.startAssetPlayer(h,i,t,e,d),this.shouldPlay&&Dg(h.media);}else o?(this.resumePrimary(o,e,r),this.shouldPlay&&Dg(this.hls.media)):n&&this.isInterstitial(r)&&(this.endedItem=null,this.playingItem=r,r.event.appendInPlace||this.attachPrimary(a.durations.primary,null));}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===false}get primaryDetails(){var e;return (e=this.mediaSelection)==null?void 0:e.main.details}get primaryLive(){var e;return !!((e=this.primaryDetails)!=null&&e.live)}resumePrimary(e,t,i){var r,n;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${Gt(e)}`),!((r=this.detachedData)!=null&&r.mediaSource)){let o=this.timelinePos;(o<e.start||o>=e.end)&&(o=this.getPrimaryResumption(e,t),this.log($o("resumePrimary",o)),this.timelinePos=o),this.attachPrimary(o,e);}if(!i)return;let a=(n=this.schedule)==null?void 0:n.items;a&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${Gt(e)}`),this.hls.trigger(p.INTERSTITIALS_PRIMARY_RESUMED,{schedule:a.slice(0),scheduleIndex:t}),this.checkBuffer());}getPrimaryResumption(e,t){let i=e.start;if(this.primaryLive){let r=this.primaryDetails;if(t===0)return this.hls.startPosition;if(r&&(i<r.fragmentStart||i>r.edge))return this.hls.liveSyncPosition||-1}return i}isAssetBuffered(e){let t=this.getAssetPlayer(e.identifier);return t!=null&&t.hls?t.hls.bufferedToEnd:ne.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;let r=this.primaryMedia;if(!r)return;let n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,r),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log($o("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i));}startLoadingPrimaryAt(e,t){var i;let r=this.hls;!r.loadingEnabled||!r.media||Math.abs((((i=r.mainForwardBufferInfo)==null?void 0:i.start)||r.media.currentTime)-e)>.5?r.startLoad(e,t):r.bufferingEnabled||r.resumeBuffering();}onManifestLoading(){var e;this.stopLoad(),(e=this.schedule)==null||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=false,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(p.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(p.BUFFER_CODECS,this.onBufferCodecs,this);}onLevelUpdated(e,t){if(t.level===-1||!this.schedule)return;let i=this.hls.levels[t.level];if(!i.details)return;let r=Te(Te({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=r,this.schedule.parseInterstitialDateRanges(r,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart();}onAudioTrackUpdated(e,t){let i=this.hls.audioTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=Te(Te({},this.altSelection),{},{audio:i});return}let n=Te(Te({},r),{},{audio:i});this.mediaSelection=n;}onSubtitleTrackUpdated(e,t){let i=this.hls.subtitleTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=Te(Te({},this.altSelection),{},{subtitles:i});return}let n=Te(Te({},r),{},{subtitles:i});this.mediaSelection=n;}onAudioTrackSwitching(e,t){let i=Bm(t);this.playerQueue.forEach(({hls:r})=>r&&(r.setAudioOption(t)||r.setAudioOption(i)));}onSubtitleTrackSwitch(e,t){let i=Bm(t);this.playerQueue.forEach(({hls:r})=>r&&(r.setSubtitleOption(t)||t.id!==-1&&r.setSubtitleOption(i)));}onBufferCodecs(e,t){let i=t.tracks;i&&(this.requiredTracks=i);}onBufferAppended(e,t){this.checkBuffer();}onBufferFlushed(e,t){let i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){let r=this.timelinePos;this.bufferedPos=r,this.checkBuffer();}}onBufferedToEnd(e){if(!this.schedule)return;let t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let r=0;r<t.length;r++){let n=t[r];if(n.cue.post){var i;let a=this.schedule.findEventIndex(n.identifier),o=(i=this.schedule.items)==null?void 0:i[a];this.isInterstitial(o)&&this.eventItemsMatch(o,this.bufferingItem)&&this.bufferedToItem(o,0);break}}this.bufferedPos=Number.MAX_VALUE;}}onMediaEnded(e){let t=this.playingItem;if(!this.playingLastItem&&t){let i=this.findItemIndex(t);this.setSchedulePosition(i+1);}else this.shouldPlay=false;}updateItem(e,t){var i;let r=(i=this.schedule)==null?void 0:i.items;if(e&&r){let n=this.findItemIndex(e,t);return r[n]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((n,a)=>{e.event.isAssetPastPlayoutLimit(a)&&this.clearAssetPlayer(n.identifier,null);});let i=e.end+.25,r=ne.bufferInfo(this.primaryMedia,i,0);(r.end>i||(r.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${Gt(e)} (was ${Gt(t)})`),this.attachPrimary(i,null,true),this.flushFrontBuffer(i));}}itemsMatch(e,t){return !!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var i;return !!t&&(e===t||e.event.identifier===((i=t.event)==null?void 0:i.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=false){var t;let i=this.mediaSelection;i&&((t=this.schedule)==null||t.updateSchedule(i,[],e));}checkBuffer(e){var t;let i=(t=this.schedule)==null?void 0:t.items;if(!i)return;let r=ne.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=r.len<1),this.updateBufferedPos(r.end,i,e);}updateBufferedPos(e,t,i){let r=this.schedule,n=this.bufferingItem;if(this.bufferedPos>e||!r)return;if(t.length===1&&this.itemsMatch(t[0],n)){this.bufferedPos=e;return}let a=this.playingItem,o=this.findItemIndex(a),d=r.findItemIndexAtTime(e);if(this.bufferedPos<e){var l;let c=this.findItemIndex(n),u=Math.min(c+1,t.length-1),h=t[u];if((d===-1&&n&&e>=n.end||(l=h.event)!=null&&l.appendInPlace&&e+.01>=h.start)&&(d=u),this.isInterstitial(n)){let f=n.event;if(u-o>1&&f.appendInPlace===false||f.assetList.length===0&&f.assetListLoader)return}if(this.bufferedPos=e,d>c&&d>o)this.bufferedToItem(h);else {let f=this.primaryDetails;this.primaryLive&&f&&e>f.edge-f.targetduration&&h.start<f.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0);}}else i&&a&&!this.itemsMatch(a,n)&&(d===o?this.bufferedToItem(a):d===o+1&&this.bufferedToItem(t[d]));}assetsBuffered(e,t){return e.event.assetList.length===0?false:!e.event.assetList.some(r=>{let n=this.getAssetPlayer(r.identifier);return !(n!=null&&n.bufferedInPlaceToEnd(t))})}setBufferingItem(e){let t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){let{items:r,events:n}=i;if(!r||!n)return t;let a=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));let d=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${Gt(e)}`+(t?` (${d.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(a){let l=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((c,u)=>{let h=this.getAssetPlayer(c.identifier);h&&(u===l&&h.loadSource(),h.resumeBuffering());});}else this.hls.resumeBuffering(),this.playerQueue.forEach(l=>l.pauseBuffering());this.hls.trigger(p.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:n.slice(0),schedule:r.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)});}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){let i=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(i!==null){this.bufferingAsset=null;let r=this.detachedData;r?r.mediaSource?this.attachPrimary(e.start,e,true):this.preloadPrimary(e):this.preloadPrimary(e);}}}preloadPrimary(e){let t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i);}bufferedToEvent(e,t){let i=e.event,r=i.assetList.length===0&&!i.assetListLoader,n=i.cue.once;if(r||!n){let a=this.preloadAssets(i,t);if(a!=null&&a.interstitial.appendInPlace){let o=this.primaryMedia;o&&this.bufferAssetPlayer(a,o);}}}preloadAssets(e,t){let i=e.assetUrl,r=e.assetList.length,n=r===0&&!e.assetListLoader,a=e.cue.once;if(n){let d=e.timelineStart;if(e.appendInPlace){var o;let h=this.playingItem;!this.isInterstitial(h)&&(h==null||(o=h.nextEvent)==null?void 0:o.identifier)===e.identifier&&this.flushFrontBuffer(d+.25);}let l,c=0;if(!this.playingItem&&this.primaryLive&&(c=this.hls.startPosition,c===-1&&(c=this.hls.liveSyncPosition||0)),c&&!(e.cue.pre||e.cue.post)){let h=c-d;h>0&&(l=Math.round(h*1e3)/1e3);}if(this.log(`Load interstitial asset ${t+1}/${i?1:r} ${e}${l?` live-start: ${c} start-offset: ${l}`:""}`),i)return this.createAsset(e,0,0,d,e.duration,i);let u=this.assetListLoader.loadAssetList(e,l);u&&(e.assetListLoader=u);}else if(!a&&r){for(let l=t;l<r;l++){let c=e.assetList[l],u=this.getAssetPlayerQueueIndex(c.identifier);(u===-1||this.playerQueue[u].destroyed)&&!c.error&&this.createAssetPlayer(e,c,l);}let d=e.assetList[t];if(d){let l=this.getAssetPlayer(d.identifier);return l&&l.loadSource(),l}}return null}flushFrontBuffer(e){let t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(r=>{this.hls.trigger(p.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:r});});}getAssetPlayerQueueIndex(e){let t=this.playerQueue;for(let i=0;i<t.length;i++)if(e===t[i].assetId)return i;return -1}getAssetPlayer(e){let t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){let{playerQueue:e,primaryMedia:t}=this;if(t){for(let i=0;i<e.length;i++)if(e[i].media===t)return e[i]}return null}createAsset(e,t,i,r,n,a){let o={parentIdentifier:e.identifier,identifier:Gb(e,a,t),duration:n,startOffset:i,timelineStart:r,uri:a};return this.createAssetPlayer(e,o,t)}createAssetPlayer(e,t,i){let r=this.hls,n=r.userConfig,a=n.videoPreference,o=r.loadLevelObj||r.levels[r.currentLevel];(a||o)&&(a=Se({},a),o.videoCodec&&(a.videoCodec=o.videoCodec),o.videoRange&&(a.allowedVideoRanges=[o.videoRange]));let d=r.audioTracks[r.audioTrack],l=r.subtitleTracks[r.subtitleTrack],c=0;if(this.primaryLive||e.appendInPlace){let b=this.timelinePos-t.timelineStart;if(b>1){let _=t.duration;_&&b<_&&(c=b);}}let u=t.identifier,h=Te(Te({},n),{},{maxMaxBufferLength:Math.min(180,r.config.maxMaxBufferLength),autoStartLoad:true,startFragPrefetch:true,primarySessionId:r.sessionId,assetPlayerId:u,abrEwmaDefaultEstimate:r.bandwidthEstimate,interstitialsController:void 0,startPosition:c,liveDurationInfinity:false,testBandwidth:false,videoPreference:a,audioPreference:d||n.audioPreference,subtitlePreference:l||n.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=true,t.timelineStart&&(h.timelineOffset=t.timelineStart));let f=h.cmcd;f!=null&&f.sessionId&&f.contentId&&(h.cmcd=Se({},f,{contentId:An(t.uri)})),this.getAssetPlayer(u)&&this.warn(`Duplicate date range identifier ${e} and asset ${u}`);let m=new Su(this.HlsPlayerClass,h,e,t);this.playerQueue.push(m),e.assetList[i]=t;let g=true,E=b=>{if(b.live){var _;let k=new Error(`Interstitials MUST be VOD assets ${e}`),R={fatal:true,type:Q.OTHER_ERROR,details:x.INTERSTITIAL_ASSET_ITEM_ERROR,error:k},L=((_=this.schedule)==null?void 0:_.findEventIndex(e.identifier))||-1;this.handleAssetItemError(R,e,L,i,k.message);return}let D=b.edge-b.fragmentStart,I=t.duration;(g||I===null||D>I)&&(g=false,this.log(`Interstitial asset "${u}" duration change ${I} > ${D}`),t.duration=D,this.updateSchedule());};m.on(p.LEVEL_UPDATED,(b,{details:_})=>E(_)),m.on(p.LEVEL_PTS_UPDATED,(b,{details:_})=>E(_)),m.on(p.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());let v=(b,_)=>{let D=this.getAssetPlayer(u);if(D&&_.tracks){D.off(p.BUFFER_CODECS,v),D.tracks=_.tracks;let I=this.primaryMedia;this.bufferingAsset===D.assetItem&&I&&!D.media&&this.bufferAssetPlayer(D,I);}};m.on(p.BUFFER_CODECS,v);let T=()=>{var b;let _=this.getAssetPlayer(u);if(this.log(`buffered to end of asset ${_}`),!_||!this.schedule)return;let D=this.schedule.findEventIndex(e.identifier),I=(b=this.schedule.items)==null?void 0:b[D];this.isInterstitial(I)&&this.advanceAssetBuffering(I,t);};m.on(p.BUFFERED_TO_END,T);let S=b=>()=>{if(!this.getAssetPlayer(u)||!this.schedule)return;this.shouldPlay=true;let D=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,D,b);};return m.once(p.MEDIA_ENDED,S(i)),m.once(p.PLAYOUT_LIMIT_REACHED,S(1/0)),m.on(p.ERROR,(b,_)=>{if(!this.schedule)return;let D=this.getAssetPlayer(u);if(_.details===x.BUFFER_STALLED_ERROR){if(D!=null&&D.appendInPlace){this.handleInPlaceStall(e);return}this.onTimeupdate(),this.checkBuffer(true);return}this.handleAssetItemError(_,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${_.error} ${e}`);}),m.on(p.DESTROYING,()=>{if(!this.getAssetPlayer(u)||!this.schedule)return;let _=new Error(`Asset player destroyed unexpectedly ${u}`),D={fatal:true,type:Q.OTHER_ERROR,details:x.INTERSTITIAL_ASSET_ITEM_ERROR,error:_};this.handleAssetItemError(D,e,this.schedule.findEventIndex(e.identifier),i,_.message);}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${ar(t)}`),this.hls.trigger(p.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:m}),m}clearInterstitial(e,t){this.clearAssetPlayers(e,t),e.reset();}clearAssetPlayers(e,t){e.assetList.forEach(i=>{this.clearAssetPlayer(i.identifier,t);});}resetAssetPlayer(e){let t=this.getAssetPlayerQueueIndex(e);if(t!==-1){this.log(`reset asset player "${e}" after error`);let i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails();}}clearAssetPlayer(e,t){let i=this.getAssetPlayerQueueIndex(e);if(i!==-1){let r=this.playerQueue[i];this.log(`clear ${r} toSegment: ${t&&Gt(t)}`),this.transferMediaFromPlayer(r,t),this.playerQueue.splice(i,1),r.destroy();}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[];}startAssetPlayer(e,t,i,r,n){let{interstitial:a,assetItem:o,assetId:d}=e,l=a.assetList.length,c=this.playingAsset;this.endedAsset=null,this.playingAsset=o,(!c||c.identifier!==d)&&(c&&(this.clearAssetPlayer(c.identifier,i[r]),delete c.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${ar(o)}`),this.hls.trigger(p.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:a,schedule:i.slice(0),scheduleIndex:r,player:e})),this.bufferAssetPlayer(e,n);}bufferAssetPlayer(e,t){var i,r;if(!this.schedule)return;let{interstitial:n,assetItem:a}=e,o=this.schedule.findEventIndex(n.identifier),d=(i=this.schedule.items)==null?void 0:i[o];if(!d)return;e.loadSource(),this.setBufferingItem(d),this.bufferingAsset=a;let l=this.getBufferingPlayer();if(l===e)return;let c=n.appendInPlace;if(c&&l?.interstitial.appendInPlace===false)return;let u=l?.tracks||((r=this.detachedData)==null?void 0:r.tracks)||this.requiredTracks;if(c&&a!==this.playingAsset){if(!e.tracks){this.log(`Waiting for track info before buffering ${e}`);return}if(u&&!Gg(u,e.tracks)){let h=new Error(`Asset ${ar(a)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(u)}')`),f={fatal:true,type:Q.OTHER_ERROR,details:x.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},m=n.findAssetIndex(a);this.handleAssetItemError(f,n,o,m,h.message);return}}this.transferMediaTo(e,t);}handleInPlaceStall(e){let t=this.schedule,i=this.primaryMedia;if(!t||!i)return;let r=i.currentTime,n=t.findAssetIndex(e,r),a=e.assetList[n];if(a){let o=this.getAssetPlayer(a.identifier);if(o){let d=o.currentTime||r-a.timelineStart,l=o.duration-d;if(this.warn(`Stalled at ${d} of ${d+l} in ${o} ${e} (media.currentTime: ${r})`),d&&(l/i.playbackRate<.5||o.bufferedInPlaceToEnd(i))&&o.hls){let c=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,c,n);}}}}advanceInPlace(e){let t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e);}handleAssetItemError(e,t,i,r,n){if(e.details===x.BUFFER_STALLED_ERROR)return;let a=t.assetList[r]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${a&&ar(a)} ${e.error}`),!this.schedule)return;let o=a?.identifier||"",d=this.getAssetPlayerQueueIndex(o),l=this.playerQueue[d]||null,c=this.schedule.items,u=Se({},e,{fatal:false,errorAction:dr(true),asset:a,assetListIndex:r,event:t,schedule:c,scheduleIndex:i,player:l});if(this.hls.trigger(p.INTERSTITIAL_ASSET_ERROR,u),!e.fatal)return;let h=this.playingAsset,f=this.bufferingAsset,m=new Error(n);if(a&&(this.clearAssetPlayer(o,null),a.error=m),!t.assetList.some(g=>!g.error))t.error=m;else for(let g=r;g<t.assetList.length;g++)this.resetAssetPlayer(t.assetList[g].identifier);this.updateSchedule(true),t.error?this.primaryFallback(t):h&&h.identifier===o?this.advanceAfterAssetEnded(t,i,r):f&&f.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,f);}primaryFallback(e){let t=e.timelineStart,i=this.effectivePlayingItem,r=this.timelinePos;if(i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${r} playing: ${Gt(i)} error: ${e.error}`),r===-1&&(r=this.hls.startPosition);let a=this.updateItem(i,r);this.itemsMatch(i,a)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t));}else if(r===-1){this.checkStart();return}if(!this.schedule)return;let n=this.schedule.findItemIndexAtTime(r);this.setSchedulePosition(n);}onAssetListLoaded(e,t){var i,r;let n=t.event,a=n.identifier,o=t.assetListResponse.ASSETS;if(!((i=this.schedule)!=null&&i.hasEvent(a)))return;let d=n.timelineStart,l=n.duration,c=0;o.forEach((g,E)=>{let v=parseFloat(g.DURATION);this.createAsset(n,E,c,d+c,v,g.URI),c+=v;}),n.duration=c,this.log(`Loaded asset-list with duration: ${c} (was: ${l}) ${n}`);let u=this.waitingItem,h=u?.event.identifier===a;this.updateSchedule();let f=(r=this.bufferingItem)==null?void 0:r.event;if(h){var m;let g=this.schedule.findEventIndex(a),E=(m=this.schedule.items)==null?void 0:m[g];if(E){if(!this.playingItem&&this.timelinePos>E.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==g){n.error=new Error(`Interstitial ${o.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${n}`),this.log(n.error.message),this.updateSchedule(true),this.primaryFallback(n);return}this.setBufferingItem(E);}this.setSchedulePosition(g);}else if(f?.identifier===a){let g=n.assetList[0];if(g){let E=this.getAssetPlayer(g.identifier);if(f.appendInPlace){let v=this.primaryMedia;E&&v&&this.bufferAssetPlayer(E,v);}else E&&E.loadSource();}}}onError(e,t){if(this.schedule)switch(t.details){case x.ASSET_LIST_PARSING_ERROR:case x.ASSET_LIST_LOAD_ERROR:case x.ASSET_LIST_LOAD_TIMEOUT:{let i=t.interstitial;i&&(this.updateSchedule(true),this.primaryFallback(i));break}case x.BUFFER_STALLED_ERROR:{let i=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&i.event.appendInPlace){this.handleInPlaceStall(i.event);return}this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(true);break}}}},Cg=500,Iu=class extends Dn{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",Y.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners();}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null;}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(p.LEVEL_LOADED,this.onLevelLoaded,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);}unregisterListeners(){super.unregisterListeners();let{hls:e}=this;e.off(p.LEVEL_LOADED,this.onLevelLoaded,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);}startLoad(e,t){this.stopLoad(),this.state=M.IDLE,this.setInterval(Cg),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick();}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null;}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t);}onLevelLoaded(e,t){this.mainDetails=t.details;}onSubtitleFragProcessed(e,t){let{frag:i,success:r}=t;if(this.fragContextChanged(i)||(Fe(i)&&(this.fragPrevious=i),this.state=M.IDLE),!r)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=i.start;for(let l=0;l<n.length;l++)if(o>=n[l].start&&o<=n[l].end){a=n[l];break}let d=i.start+i.duration;a?a.end=d:(a={start:o,end:d},n.push(a)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null),this.media&&this.tick();}onBufferFlushing(e,t){let{startOffset:i,endOffset:r}=t;if(i===0&&r!==Number.POSITIVE_INFINITY){let n=r-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++;}}),this.fragmentTracker.removeFragmentsInRange(i,n,Y.SUBTITLE);}}onError(e,t){let i=t.frag;i?.type===Y.SUBTITLE&&(t.details===x.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,true),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==M.STOPPED&&(this.state=M.IDLE));}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&Up(this.levels,t)){this.levels=t.map(i=>new fs(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{let r=new fs(i);return this.tracksBuffered[r.id]=[],r}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Y.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null;}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,!((i=this.levels)!=null&&i.length)||this.currentTrackId===-1){this.clearInterval();return}let r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.state!==M.STOPPED&&this.setInterval(Cg);}onSubtitleTrackLoaded(e,t){var i;let{currentTrackId:r,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}let d=n[o];if(o>=n.length||!d)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(a.live||(i=d.details)!=null&&i.live){if(a.deltaUpdateFailed)return;let u=this.mainDetails;if(!u){this.startFragRequested=false;return}let h=u.fragments[0];if(!d.details)a.hasProgramDateTime&&u.hasProgramDateTime?(dl(a,u),l=a.fragmentStart):h&&(l=h.start,Vc(a,l));else {var c;l=this.alignPlaylists(a,d.details,(c=this.levelLastLoaded)==null?void 0:c.details),l===0&&h&&(l=h.start,Vc(a,l));}u&&!this.startFragRequested&&this.setStartPosition(u,l);}d.details=a,this.levelLastLoaded=d,o===r&&(this.hls.trigger(p.SUBTITLE_TRACK_UPDATED,{details:a,id:o,groupId:t.groupId}),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===M.IDLE&&(ms(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),d.details=void 0)));}_handleFragmentLoadComplete(e){let{frag:t,payload:i}=e,r=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&r!=null&&r.key&&r.iv&&cr(r.method)){let a=performance.now();this.decrypter.decrypt(new Uint8Array(i),r.key.buffer,r.iv.buffer,Qu(r.method)).catch(o=>{throw n.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.FRAG_DECRYPT_ERROR,fatal:false,error:o,reason:o.message,frag:t}),o}).then(o=>{let d=performance.now();n.trigger(p.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:d}});}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=M.IDLE;});}}doTick(){if(!this.media){this.state=M.IDLE;return}if(this.state===M.IDLE){let{currentTrackId:e,levels:t}=this,i=t?.[e];if(!i||!t.length||!i.details||this.waitForLive(i))return;let{config:r}=this,n=this.getLoadPosition(),a=ne.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,r.maxBufferHole),{end:o,len:d}=a,l=i.details,c=this.hls.maxBufferLength+l.levelTargetDuration;if(d>c)return;let u=l.fragments,h=u.length,f=l.edge,m=null,g=this.fragPrevious;if(o<f){let T=r.maxFragLookUpTolerance,S=o>f-T?0:T;m=ms(g,u,Math.max(u[0].start,o),S),!m&&g&&g.start<u[0].start&&(m=u[0]);}else m=u[h-1];if(m=this.filterReplacedPrimary(m,i.details),!m)return;let E=m.sn-l.startSN,v=u[E-1];if(v&&v.cc===m.cc&&this.fragmentTracker.getState(v)===We.NOT_LOADED&&(m=v),this.fragmentTracker.getState(m)===We.NOT_LOADED){let T=this.mapToInitFragWhenRequired(m);T&&this.loadFragment(T,i,o);}}}loadFragment(e,t,i){Fe(e)?super.loadFragment(e,t,i):this._loadInitSegment(e,t);}get mediaBufferTimeRanges(){return new Lu(this.tracksBuffered[this.currentTrackId]||[])}},Lu=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)}};}},Kb={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},Jp=s=>String.fromCharCode(Kb[s]||s),Ht=15,Si=100,Vb={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Wb={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Yb={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},qb={25:2,26:4,29:6,30:8,31:10,27:13,28:15},jb=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],xu=class{constructor(){this.time=null,this.verboseLevel=0;}log(e,t){if(this.verboseLevel>=e){let i=typeof t=="function"?t():t;ye.log(`${this.time} [${e}] ${i}`);}}},ls=function(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t},vl=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}},Ru=class{constructor(){this.uchar=" ",this.penState=new vl;}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()}},ku=class{constructor(e){this.chars=[],this.pos=0,this.currPenState=new vl,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Si;t++)this.chars.push(new Ru);this.logger=e;}equals(e){for(let t=0;t<Si;t++)if(!this.chars[t].equals(e.chars[t]))return false;return true}copy(e){for(let t=0;t<Si;t++)this.chars[t].copy(e.chars[t]);}isEmpty(){let e=true;for(let t=0;t<Si;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>Si&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Si);}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=Jp(e);if(this.pos>=Si){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<Si;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<Si;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);}},_n=class{constructor(e){this.rows=[],this.currRow=Ht-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Ht;t++)this.rows.push(new ku(e));this.logger=e;}reset(){for(let e=0;e<Ht;e++)this.rows[e].clear();this.currRow=Ht-1;}equals(e){let t=true;for(let i=0;i<Ht;i++)if(!this.rows[i].equals(e.rows[i])){t=false;break}return t}copy(e){for(let t=0;t<Ht;t++)this.rows[t].copy(e.rows[t]);}isEmpty(){let e=true;for(let t=0;t<Ht;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 = "+Ae(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<Ht;o++)this.rows[o].clear();let n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){let o=a.rows[n].cueStartTime,d=this.logger.time;if(o!==null&&d!==null&&o<d)for(let l=0;l<this.nrRollUpRows;l++)this.rows[t-this.nrRollUpRows+l+1].copy(a.rows[n+l]);}}this.currRow=t;let i=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);i.setCursor(e.indent),e.color=i.chars[a].penState.foreground;}let r={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:false};this.setPen(r);}setBkgData(e){this.logger.log(2,()=>"bkgData = "+Ae(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<Ht;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(`
|
|
1485
|
+
`)),i}getTextAndFormat(){return this.rows}},Tl=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 _n(i),this.nonDisplayedMemory=new _n(i),this.lastOutputScreen=new _n(i),this.currRollUpRow=this.displayedMemory.rows[Ht-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[Ht-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: "+Ae(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));}},yl=class{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=Qb(),this.logger=void 0;let r=this.logger=new xu;this.channels=[null,new Tl(e,t,r),new Tl(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,()=>"["+ls([t[i],t[i+1]])+"] -> ("+ls([r,n])+")");let d=this.cmdHistory;if(r>=16&&r<=31){if(zb(r,n,d)){Bo(null,null,d),this.logger.log(3,()=>"Repeated command ("+ls([r,n])+") is dropped");continue}Bo(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 Bo(null,null,d);if(!a&&(o=this.parseChars(r,n),o)){let c=this.currentChannel;c&&c>0?this.channels[c].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?");}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+ls([r,n])+" orig: "+ls([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 ("+ls([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?Vb[e]:Yb[e]:i=a===1?Wb[e]:qb[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 '"+Jp(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 = "+ls(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=jb[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();}Bo(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 Bo(s,e,t){t.a=s,t.b=e;}function zb(s,e,t){return t.a===s&&t.b===e}function Qb(){return {a:null,b:null}}var ah=(function(){if(ll!=null&&ll.VTTCue)return self.VTTCue;let s=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,d){if(typeof d!="string"||!Array.isArray(o))return false;let l=d.toLowerCase();return ~o.indexOf(l)?l:false}function i(o){return t(s,o)}function r(o){return t(e,o)}function n(o,...d){let l=1;for(;l<arguments.length;l++){let c=arguments[l];for(let u in c)o[u]=c[u];}return o}function a(o,d,l){let c=this,u={enumerable:true};c.hasBeenReset=false;let h="",f=false,m=o,g=d,E=l,v=null,T="",S=true,b="auto",_="start",D=50,I="middle",k=50,R="middle";Object.defineProperty(c,"id",n({},u,{get:function(){return h},set:function(L){h=""+L;}})),Object.defineProperty(c,"pauseOnExit",n({},u,{get:function(){return f},set:function(L){f=!!L;}})),Object.defineProperty(c,"startTime",n({},u,{get:function(){return m},set:function(L){if(typeof L!="number")throw new TypeError("Start time must be set to a number.");m=L,this.hasBeenReset=true;}})),Object.defineProperty(c,"endTime",n({},u,{get:function(){return g},set:function(L){if(typeof L!="number")throw new TypeError("End time must be set to a number.");g=L,this.hasBeenReset=true;}})),Object.defineProperty(c,"text",n({},u,{get:function(){return E},set:function(L){E=""+L,this.hasBeenReset=true;}})),Object.defineProperty(c,"region",n({},u,{get:function(){return v},set:function(L){v=L,this.hasBeenReset=true;}})),Object.defineProperty(c,"vertical",n({},u,{get:function(){return T},set:function(L){let w=i(L);if(w===false)throw new SyntaxError("An invalid or illegal string was specified.");T=w,this.hasBeenReset=true;}})),Object.defineProperty(c,"snapToLines",n({},u,{get:function(){return S},set:function(L){S=!!L,this.hasBeenReset=true;}})),Object.defineProperty(c,"line",n({},u,{get:function(){return b},set:function(L){if(typeof L!="number"&&L!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");b=L,this.hasBeenReset=true;}})),Object.defineProperty(c,"lineAlign",n({},u,{get:function(){return _},set:function(L){let w=r(L);if(!w)throw new SyntaxError("An invalid or illegal string was specified.");_=w,this.hasBeenReset=true;}})),Object.defineProperty(c,"position",n({},u,{get:function(){return D},set:function(L){if(L<0||L>100)throw new Error("Position must be between 0 and 100.");D=L,this.hasBeenReset=true;}})),Object.defineProperty(c,"positionAlign",n({},u,{get:function(){return I},set:function(L){let w=r(L);if(!w)throw new SyntaxError("An invalid or illegal string was specified.");I=w,this.hasBeenReset=true;}})),Object.defineProperty(c,"size",n({},u,{get:function(){return k},set:function(L){if(L<0||L>100)throw new Error("Size must be between 0 and 100.");k=L,this.hasBeenReset=true;}})),Object.defineProperty(c,"align",n({},u,{get:function(){return R},set:function(L){let w=r(L);if(!w)throw new SyntaxError("An invalid or illegal string was specified.");R=w,this.hasBeenReset=true;}})),c.displayState=void 0;}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a})(),Du=class{decode(e,t){if(!e)return "";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function e0(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 Cu=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 t0(s,e,t,i){let r=i?s.split(i):[s];for(let n in r){if(typeof r[n]!="string")continue;let a=r[n].split(t);if(a.length!==2)continue;let o=a[0],d=a[1];e(o,d);}}var Mu=new ah(0,0,""),Go=Mu.align==="middle"?"middle":"center";function Xb(s,e,t){let i=s;function r(){let o=e0(s);if(o===null)throw new Error("Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,d){let l=new Cu;t0(o,function(h,f){let m;switch(h){case "region":for(let g=t.length-1;g>=0;g--)if(t[g].id===f){l.set(h,t[g].region);break}break;case "vertical":l.alt(h,f,["rl","lr"]);break;case "line":m=f.split(","),l.integer(h,m[0]),l.percent(h,m[0])&&l.set("snapToLines",false),l.alt(h,m[0],["auto"]),m.length===2&&l.alt("lineAlign",m[1],["start",Go,"end"]);break;case "position":m=f.split(","),l.percent(h,m[0]),m.length===2&&l.alt("positionAlign",m[1],["start",Go,"end","line-left","line-right","auto"]);break;case "size":l.percent(h,f);break;case "align":l.alt(h,f,["start",Go,"end","left","right"]);break}},/:/,/\s/),d.region=l.get("region",null),d.vertical=l.get("vertical","");let c=l.get("line","auto");c==="auto"&&Mu.line===-1&&(c=-1),d.line=c,d.lineAlign=l.get("lineAlign","start"),d.snapToLines=l.get("snapToLines",true),d.size=l.get("size",100),d.align=l.get("align",Go);let u=l.get("position","auto");u==="auto"&&Mu.position===50&&(u=d.align==="start"||d.align==="left"?0:d.align==="end"||d.align==="right"?100:50),d.position=u;}function a(){s=s.replace(/^\s+/,"");}if(a(),e.startTime=r(),a(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.slice(3),a(),e.endTime=r(),a(),n(s,e);}function i0(s){return s.replace(/<br(?: \/)?>/gi,`
|
|
1486
|
+
`)}var wu=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Du,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=i0(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
|
|
1511
1487
|
`;)++a;let o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
|
|
1512
|
-
`&&++a,t.buffer=n.slice(a),o}function r(n){
|
|
1488
|
+
`&&++a,t.buffer=n.slice(a),o}function r(n){t0(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 ah(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case "CUE":if(!t.cue){t.state="BADCUE";continue}try{Xb(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+=`
|
|
1513
1489
|
`),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+=`
|
|
1514
1490
|
|
|
1515
|
-
`,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}},
|
|
1491
|
+
`,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}},Zb=/\r\n|\n\r|\n|\r/g,vc=function(e,t,i=0){return e.slice(i,i+t.length)===t},Jb=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(!H(t)||!H(i)||!H(r)||!H(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*r,t+=3600*1e3*n,t};function oh(s,e,t){return An(s.toString())+An(e.toString())+An(t)}var eA=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 tA(s,e,t,i,r,n,a){let o=new wu,d=At(new Uint8Array(s)).trim().replace(Zb,`
|
|
1516
1492
|
`).split(`
|
|
1517
|
-
`),
|
|
1518
|
-
`);}),o.flush();}var
|
|
1519
|
-
`:(n=i.childNodes)!=null&&n.length?c0(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function cA(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=Ac(e,i,l)||Ac(s,i,l)||Ac(r,i,l);return d&&(o[l]=d),o},{})}function Ac(s,e,t){return s&&s.hasAttributeNS(e,t)?s.getAttributeNS(e,t):null}function Bg(s){return new Error(`Could not parse ttml timestamp ${s}`)}function _c(s,e){if(!s)return null;let t=n0(s);return t===null&&(l0.test(s)?t=uA(s,e):d0.test(s)&&(t=hA(s,e))),t}function uA(s,e){let t=l0.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 hA(s,e){let t=d0.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 cr=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;}},Fu=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=Gg(),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=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0;}initCea608Parsers(){let e=new cr(this,"textTrack1"),t=new cr(this,"textTrack2"),i=new cr(this,"textTrack3"),r=new cr(this,"textTrack4");this.cea608Parser1=new Al(1,e,t),this.cea608Parser2=new Al(3,i,r);}addCues(e,t,i,r,n){let a=false;for(let o=n.length;o--;){let l=n[o],d=fA(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,trackId:a}){let{unparsedVttFrags:o}=this;i===W.MAIN&&(this.initPTS[t.cc]={baseTime:r,timescale:n,trackId:a}),o.length&&(this.unparsedVttFrags=[],o.forEach(l=>{this.initPTS[l.frag.cc]?this.onFragLoaded(p.FRAG_LOADED,l):this.hls.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:false,frag:l.frag,error:new Error("Subtitle discontinuity domain does not match main")});}));}getExistingTrack(e,t){let{media:i}=this;if(i)for(let r=0;r<i.textTracks.length;r++){let n=i.textTracks[r];if($g(n,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e);}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:i,media:r}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)i[e]=o,dr(i[e]),t0(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,t.mediaSource||this._cleanTracks();}onMediaDetaching(e,t){let i=!!t.transferMedia;if(this.media=null,i)return;let{captionsTracks:r}=this;Object.keys(r).forEach(n=>{dr(r[n]),delete r[n];}),this.nonNativeCaptionsTracks={};}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Gg(),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++)dr(t[i]);}onSubtitleTracksUpdated(e,t){let i=t.subtitleTracks||[],r=i.some(n=>n.textCodec===Sc);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(Kp(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){let a=this.media,o=a?Zo(a.textTracks):null;if(this.tracks.forEach((l,d)=>{let c;if(o){let u=null;for(let h=0;h<o.length;h++)if(o[h]&&$g(o[h],l)){u=o[h],o[h]=null;break}u&&(c=u);}if(c)dr(c);else {let u=u0(l);c=this.createTextTrack(u,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&&this.hls.logger.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===W.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===W.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===Sc?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;Ug(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),i.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:true,frag:e});},r=>{i.logger.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?Ct(i.initSegment.data,new Uint8Array(r)).buffer:r;oA(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 u=c.message==="Missing initPTS for VTT MPEGTS";u?a.push(e):this._fallbackToIMSC1(i,r),l.logger.log(`Failed to parse VTT cue: ${c}`),!(u&&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||Ug(t,this.initPTS[e.cc],()=>{i.textCodec=Sc,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=>i0(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===W.SUBTITLE&&this.onFragLoaded(p.FRAG_LOADED,t);}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={};}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;let{frag:i,samples:r}=t;if(!(i.type===W.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let n=0;n<r.length;n++){let a=r[n].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();let o=this.extractCea608Data(a);this.cea608Parser1.addData(r[n].pts,o[0]),this.cea608Parser2.addData(r[n].pts,o[1]);}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:r,type:n}){let{media:a}=this;if(!(!a||a.currentTime<i)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(l=>yu(o[l],t,i));}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>yu(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 u0(s){return s.characteristics&&/transcribes-spoken-dialog/gi.test(s.characteristics)&&/describes-music-and-sound/gi.test(s.characteristics)?"captions":"subtitles"}function $g(s,e){return !!s&&s.kind===u0(e)&&lu(e,s)}function fA(s,e,t,i){return Math.min(e,i)-Math.max(s,t)}function Gg(){return {ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:true}}}var mA=/\s/,gA={newCue(s,e,t,i){let r=[],n,a,o,l,d,c=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(n=i.rows[h],o=true,l=0,d="",!n.isEmpty()){var u;for(let g=0;g<n.chars.length;g++)mA.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=o0(d.trim()),m=dh(e,t,f);s!=null&&(u=s.cues)!=null&&u.getCueById(m)||(a=new c(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),r.push(a));}return s&&r.length&&(r.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),r.forEach(h=>i0(s,h))),r}};function pA(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return false}var EA=/(\d+)-(\d+)\/(\d+)/,_l=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||SA,this.controller=new self.AbortController,this.stats=new xn;}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=vA(e,this.controller.signal),a=e.responseType==="arraybuffer",o=a?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:d}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=l&&H(l)?l:d,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response));},t.timeout),(Fn(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(u=>{var h;this.response=this.loader=u;let f=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=d,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response));},d-(f-r.loading.start)),!u.ok){let{status:g,statusText:E}=u;throw new Uu(E||"fetch, bad network response",g,u)}r.loading.first=f,r.total=yA(u.headers)||r.total;let m=(h=this.callbacks)==null?void 0:h.onProgress;return m&&H(t.highWaterMark)?this.loadProgressively(u,r,e,t.highWaterMark,m):a?u.arrayBuffer():e.responseType==="json"?u.json():u.text()}).then(u=>{var h,f;let m=this.response;if(!m)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);let g=u[o];g&&(r.loaded=r.total=g);let E={url:m.url,data:u,code:m.status},v=(h=this.callbacks)==null?void 0:h.onProgress;v&&!H(t.highWaterMark)&&v(r,e,u,m),(f=this.callbacks)==null||f.onSuccess(E,r,e,m);}).catch(u=>{var h;if(self.clearTimeout(this.requestTimeout),r.aborted)return;let f=u&&u.code||0,m=u?u.message:null;(h=this.callbacks)==null||h.onError({code:f,text:m},e,u?u.details:null,r);});}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null;}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,r=0,n){let a=new fl,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,i,a.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));let c=d.value,u=c.length;return t.loaded+=u,u<r||a.dataLength?(a.push(c),a.dataLength>=r&&n(t,i,a.flush().buffer,e)):n(t,i,c.buffer,e),l()}).catch(()=>Promise.reject());return l()}};function vA(s,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Se({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function TA(s){let e=EA.exec(s);if(e)return parseInt(e[2])-parseInt(e[1])+1}function yA(s){let e=s.get("Content-Range");if(e){let i=TA(e);if(H(i))return i}let t=s.get("Content-Length");if(t)return parseInt(t)}function SA(s,e){return new self.Request(s.url,e)}var Uu=class extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i;}},bA=/^age:\s*[\d.]+\s*$/im,Il=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 xn,this.retryDelay=0;}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null;}abortInternal(){let e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=true,e.abort()));}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader);}load(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal();}loadInternal(){let{config:e,context:t}=this;if(!e||!t)return;let i=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=false;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==i||this.stats.aborted))return n(i,t.url)}).catch(a=>{if(!(this.loader!==i||this.stats.aborted))return i.open("GET",t.url,true),n(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e);}).catch(a=>{var o;(o=this.callbacks)==null||o.onError({code:i.status,text:a.message},t,i,r);}):this.openAndSendXhr(i,t,e);}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,true);let r=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=i.loadPolicy;if(r)for(let o in r)e.setRequestHeader(o,r[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=n&&H(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 d=t.status,c=t.responseType==="text"?t.responseText:null;if(d>=200&&d<300){let m=c??t.response;if(m!=null){var a,o;i.loading.end=Math.max(self.performance.now(),i.loading.first);let g=t.responseType==="arraybuffer"?m.byteLength:m.length;i.loaded=i.total=g,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);let E=(a=this.callbacks)==null?void 0:a.onProgress;E&&E(i,e,m,t);let v={url:t.responseURL,data:m,code:d};(o=this.callbacks)==null||o.onSuccess(v,i,e,t);return}}let u=n.loadPolicy.errorRetry,h=i.retry,f={url:e.url,data:void 0,code:d};if(ol(u,h,false,f))this.retry(u);else {var l;ye.error(`${d} while loading ${e.url}`),(l=this.callbacks)==null||l.onError({code:d,text:t.statusText},e,t,i);}}}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(ol(e,t,true))this.retry(e);else {var i;ye.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=Xu(e,i.retry),i.retry++,ye.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&&bA.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}},AA={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},_A=Te(Te({autoStartLoad:true,startPosition:-1,defaultAudioCodec:void 0,debug:false,capLevelOnFPSDrop:false,capLevelToPlayerSize:false,ignoreDevicePixelRatio:false,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:true,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:false,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:true,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:false,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:true,workerPath:null,enableSoftwareAES:true,startLevel:void 0,startFragPrefetch:false,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:false,loader:Il,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Pc,bufferController:hu,capLevelController:fu,errorController:Fc,fpsController:Tu,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:gp,requireKeySystemAccessOnStart:false,testBandwidth:true,progressive:false,lowLatencyMode:true,cmcd:void 0,enableDateRangeMetadataCues:true,enableEmsgMetadataCues:true,enableEmsgKLVMetadata:false,enableID3MetadataCues:true,enableInterstitialPlayback:true,interstitialAppendInPlace:true,interstitialLiveLookAhead:10,useMediaCapabilities:true,preserveManualLevelOnError:false,certLoadPolicy:{default:AA},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},IA()),{},{subtitleStreamController:xu,subtitleTrackController:Su,timelineController:Fu,audioStreamController:ou,audioTrackController:du,emeController:Tl,cmcdController:Eu,contentSteeringController:vu,interstitialsController:Lu});function IA(){return {cueHandler:gA,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 LA(s,e,t){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let i=Nu(s),r=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(a=>{let o=`${a==="level"?"playlist":a}LoadPolicy`,l=e[o]===void 0,d=[];n.forEach(c=>{let u=`${a}Loading${c}`,h=e[u];if(h!==void 0&&l){d.push(u);let f=i[o].default;switch(e[o]={default:f},c){case "TimeOut":f.maxLoadTimeMs=h,f.maxTimeToFirstByteMs=h;break;case "MaxRetry":f.errorRetry.maxNumRetry=h,f.timeoutRetry.maxNumRetry=h;break;case "RetryDelay":f.errorRetry.retryDelayMs=h,f.timeoutRetry.retryDelayMs=h;break;case "MaxRetryTimeout":f.errorRetry.maxRetryDelayMs=h,f.timeoutRetry.maxRetryDelayMs=h;break}}}),d.length&&t.warn(`hls.js config: "${d.join('", "')}" setting(s) are deprecated, use "${o}": ${Ae(e[o])}`);}),Te(Te({},i),e)}function Nu(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(Nu):Object.keys(s).reduce((e,t)=>(e[t]=Nu(s[t]),e),{}):s}function xA(s,e){let t=s.loader;t!==_l&&t!==Il?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=false):pA()&&(s.loader=_l,s.progressive=true,s.enableSoftwareAES=true,e.log("[config]: Progressive streaming enabled, using FetchLoader"));}var Jo=2,RA=.1,kA=.05,DA=100,Bu=class extends ll{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=false,this.stalled=null,this.moved=false,this.seeking=false,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0;},this.onMediaWaiting=()=>{var i;(i=this.media)!=null&&i.seeking||(this.waiting=self.performance.now(),this.tick());},this.onMediaEnded=()=>{if(this.hls){var i;this.ended=((i=this.media)==null?void 0:i.currentTime)||1,this.hls.trigger(p.MEDIA_ENDED,{stalled:false});}},this.hls=e,this.fragmentTracker=t,this.registerListeners();}registerListeners(){let{hls:e}=this;e&&(e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.BUFFER_APPENDED,this.onBufferAppended,this));}unregisterListeners(){let{hls:e}=this;e&&(e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.BUFFER_APPENDED,this.onBufferAppended,this));}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0;}onMediaAttached(e,t){this.setInterval(DA),this.mediaSource=t.mediaSource;let i=this.media=t.media;at(i,"playing",this.onMediaPlaying),at(i,"waiting",this.onMediaWaiting),at(i,"ended",this.onMediaEnded);}onMediaDetaching(e,t){this.clearInterval();let{media:i}=this;i&&(ht(i,"playing",this.onMediaPlaying),ht(i,"waiting",this.onMediaWaiting),ht(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0;}onBufferAppended(e,t){this.buffered=t.timeRanges;}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;let t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t;}poll(e,t){var i,r;let n=(i=this.hls)==null?void 0:i.config;if(!n)return;let a=this.media;if(!a)return;let{seeking:o}=a,l=this.seeking&&!o,d=!this.seeking&&o,c=a.paused&&!o||a.ended||a.playbackRate===0;if(this.seeking=o,e!==t){t&&(this.ended=0),this.moved=true,o||(this.nudgeRetry=0,n.nudgeOnVideoHole&&!c&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(d||l){l&&this.stallResolved(e);return}if(c){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&a.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(p.MEDIA_ENDED,{stalled:false}));return}if(!ne.getBuffered(a).length){this.nudgeRetry=0;return}let u=ne.bufferInfo(a,e,0),h=u.nextStart||0,f=this.fragmentTracker;if(o&&f&&this.hls){let D=Hg(this.hls.inFlightFragments,e),I=u.len>Jo,k=!h||D||h-e>Jo&&!f.getPartialFragment(e);if(I||k)return;this.moved=false;}let m=(r=this.hls)==null?void 0:r.latestLevelDetails;if(!this.moved&&this.stalled!==null&&f){if(!(u.len>0)&&!h)return;let I=Math.max(h,u.start||0)-e,R=!!(m!=null&&m.live)?m.targetduration*2:Jo,L=Wo(e,f);if(I>0&&(I<=R||L)){a.paused||this._trySkipBufferHole(L);return}}let g=n.detectStallWithCurrentTimeMs,E=self.performance.now(),v=this.waiting,y=this.stalled;if(y===null)if(v>0&&E-v<g)y=this.stalled=v;else {this.stalled=E;return}let S=E-y;if(!o&&(S>=g||v)&&this.hls){var b;if(((b=this.mediaSource)==null?void 0:b.readyState)==="ended"&&!(m!=null&&m.live)&&Math.abs(e-(m?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(p.MEDIA_ENDED,{stalled:true});return}if(this._reportStall(u),!this.media||!this.hls)return}let _=ne.bufferInfo(a,e,n.maxBufferHole);this._tryFixBufferStall(_,S,e);}stallResolved(e){let t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){let i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=false,this.waiting=0,this.hls.trigger(p.STALL_RESOLVED,{});}}nudgeOnVideoHole(e,t){var i;let r=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(i=this.buffered.audio)!=null&&i.length&&r&&r.length>1&&e>r.end(0)){let n=ne.bufferedInfo(ne.timeRangesToArray(this.buffered.audio),e,0);if(n.len>1&&t>=n.start){let a=ne.timeRangesToArray(r),o=ne.bufferedInfo(a,t,0).bufferedIndex;if(o>-1&&o<a.length-1){let l=ne.bufferedInfo(a,e,0).bufferedIndex,d=a[o].end,c=a[o+1].start;if((l===-1||l>o)&&c-d<1&&e-d<2){let u=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${d} -> ${c} buffered index: ${l}`);this.warn(u.message),this.media.currentTime+=1e-6;let h=Wo(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);let f=ne.bufferInfo(this.media,e,0);this.hls.trigger(p.ERROR,{type:z.MEDIA_ERROR,details:x.BUFFER_SEEK_OVER_HOLE,fatal:false,error:u,reason:u.message,frag:h,buffer:f.len,bufferInfo:f});}}}}}_tryFixBufferStall(e,t,i){var r,n;let{fragmentTracker:a,media:o}=this,l=(r=this.hls)==null?void 0:r.config;if(!o||!a||!l)return;let d=(n=this.hls)==null?void 0:n.latestLevelDetails,c=Wo(i,a);if((c||d!=null&&d.live&&i<d.fragmentStart)&&(this._trySkipBufferHole(c)||!this.media))return;let u=e.buffered,h=this.adjacentTraversal(e,i);(u&&u.length>1&&e.len>l.maxBufferHole||e.nextStart&&(e.nextStart-i<l.maxBufferHole||h))&&(t>l.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e));}adjacentTraversal(e,t){let i=this.fragmentTracker,r=e.nextStart;if(i&&r){let n=i.getFragAtPos(t,W.MAIN),a=i.getFragAtPos(r,W.MAIN);if(n&&a)return a.sn-n.sn<2}return false}_reportStall(e){let{hls:t,media:i,stallReported:r,stalled:n}=this;if(!r&&n!==null&&i&&t){this.stallReported=true;let a=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${Ae(e)})`);this.warn(a.message),t.trigger(p.ERROR,{type:z.MEDIA_ERROR,details:x.BUFFER_STALLED_ERROR,fatal:false,error:a,buffer:e.len,bufferInfo:e,stalled:{start:n}});}}_trySkipBufferHole(e){var t;let{fragmentTracker:i,media:r}=this,n=(t=this.hls)==null?void 0:t.config;if(!r||!i||!n)return 0;let a=r.currentTime,o=ne.bufferInfo(r,a,0),l=a<o.start?o.start:o.nextStart;if(l&&this.hls){let c=o.len<=n.maxBufferHole,u=o.len>0&&o.len<1&&r.readyState<3,h=l-a;if(h>0&&(c||u)){if(h>n.maxBufferHole){let m=false;if(a===0){let g=i.getAppendedFrag(0,W.MAIN);g&&l<g.end&&(m=true);}if(!m&&e){var d;if(!((d=this.hls.loadLevelObj)!=null&&d.details)||Hg(this.hls.inFlightFragments,l))return 0;let E=false,v=e.end;for(;v<l;){let y=Wo(v,i);if(y)v+=y.duration;else {E=true;break}}if(E)return 0}}let f=Math.max(l+kA,a+RA);if(this.warn(`skipping hole, adjusting currentTime from ${a} to ${f}`),this.moved=true,r.currentTime=f,!(e!=null&&e.gap)){let m=new Error(`fragment loaded with buffer holes, seeking from ${a} to ${f}`),g={type:z.MEDIA_ERROR,details:x.BUFFER_SEEK_OVER_HOLE,fatal:false,error:m,reason:m.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?g.part=e:g.frag=e),this.hls.trigger(p.ERROR,g);}return f}}return 0}_tryNudgeBuffer(e){let{hls:t,media:i,nudgeRetry:r}=this,n=t?.config;if(!i||!n)return 0;let a=i.currentTime;if(this.nudgeRetry++,r<n.nudgeMaxRetry){let o=a+(r+1)*n.nudgeOffset,l=new Error(`Nudging 'currentTime' from ${a} to ${o}`);this.warn(l.message),i.currentTime=o,t.trigger(p.ERROR,{type:z.MEDIA_ERROR,details:x.BUFFER_NUDGE_ON_STALL,error:l,fatal:false,buffer:e.len,bufferInfo:e});}else {let o=new Error(`Playhead still not moving while enough data buffered @${a} after ${n.nudgeMaxRetry} nudges`);this.error(o.message),t.trigger(p.ERROR,{type:z.MEDIA_ERROR,details:x.BUFFER_STALLED_ERROR,error:o,fatal:true,buffer:e.len,bufferInfo:e});}}};function Hg(s,e){let t=Kg(s.main);if(t&&t.start<=e)return t;let i=Kg(s.audio);return i&&i.start<=e?i:null}function Kg(s){if(!s)return null;switch(s.state){case C.IDLE:case C.STOPPED:case C.ENDED:case C.ERROR:return null}return s.frag}function Wo(s,e){return e.getAppendedFrag(s,W.MAIN)||e.getPartialFragment(s)}var CA=.25;function $u(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Ic(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,Ae(r?Te({type:r},i):i));}return n}var Yo=(()=>{let s=$u();try{s&&new s(0,Number.POSITIVE_INFINITY,"");}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})(),Gu=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=true,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(p.EVENT_CUE_ENTER,{});},this.hls=e,this._registerListeners();}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null;}_registerListeners(){let{hls:e}=this;e&&(e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,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),e.on(p.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this));}_unregisterListeners(){let{hls:e}=this;e&&(e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,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),e.off(p.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this));}onMediaAttaching(e,t){var i;this.media=t.media,((i=t.overrides)==null?void 0:i.cueRemoval)===false&&(this.removeCues=false);}onMediaAttached(){var e;let t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t);}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.removeCues&&dr(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={});}onManifestLoading(){this.dateRangeCuesAppended={};}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let i=e[t];if(i.kind==="metadata"&&i.label==="id3")return t0(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;let{enableEmsgMetadataCues:i,enableID3MetadataCues:r}=this.hls.config;if(!i&&!r)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=$u();if(a)for(let o=0;o<n.length;o++){let l=n[o].type;if(l===At.emsg&&!i||!r)continue;let d=Mp(n[o].data),c=n[o].pts,u=c+n[o].duration;u>Yo&&(u=Yo),u-c<=0&&(u=c+CA);for(let f=0;f<d.length;f++){let m=d[f];if(!wp(m)){this.updateId3CueEnds(c,l);let g=Ic(a,c,u,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===Yo&&(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===At.audioId3&&l:r==="video"?d=c=>c.type===At.emsg&&o:d=c=>c.type===At.audioId3&&l||c.type===At.emsg&&o,yu(n,t,i,d);}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,true);}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details);}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;let{assetPlayerId:i,timelineOffset:r,enableDateRangeMetadataCues:n,interstitialsController:a}=this.hls.config;if(!n)return;let o=$u();if(i&&r&&!a){let{fragmentStart:g,fragmentEnd:E}=e,v=this.assetCue;v?(v.startTime=g,v.endTime=E):o&&(v=this.assetCue=Ic(o,g,E,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),v&&(v.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(v),v.addEventListener("enter",this.onEventCueEnter)));}if(!e.hasProgramDateTime)return;let{id3Track:l}=this,{dateRanges:d}=e,c=Object.keys(d),u=this.dateRangeCuesAppended;if(l&&t){var h;if((h=l.cues)!=null&&h.length){let g=Object.keys(u).filter(E=>!c.includes(E));for(let E=g.length;E--;){var f;let v=g[E],y=(f=u[v])==null?void 0:f.cues;delete u[v],y&&Object.keys(y).forEach(S=>{let b=y[S];if(b){b.removeEventListener("enter",this.onEventCueEnter);try{l.removeCue(b);}catch{}}});}}else u=this.dateRangeCuesAppended={};}let m=e.fragments[e.fragments.length-1];if(!(c.length===0||!H(m?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let g=0;g<c.length;g++){let E=c[g],v=d[E],y=v.startTime,S=u[E],b=S?.cues||{},_=S?.durationKnown||false,D=Yo,{duration:I,endDate:k}=v;if(k&&I!==null)D=y+I,_=true;else if(v.endOnNext&&!_){let L=c.reduce((M,$)=>{if($!==v.id){let K=d[$];if(K.class===v.class&&K.startDate>v.startDate&&(!M||v.startDate<M.startDate))return K}return M},null);L&&(D=L.startTime,_=true);}let R=Object.keys(v.attr);for(let L=0;L<R.length;L++){let M=R[L];if(!Fy(M))continue;let $=b[M];if($)_&&!(S!=null&&S.durationKnown)?$.endTime=D:Math.abs($.startTime-y)>.01&&($.startTime=y,$.endTime=D);else if(o){let K=v.attr[M];Uy(M)&&(K=qg(K));let V=Ic(o,y,D,{key:M,data:K},At.dateRange);V&&(V.id=E,this.id3Track.addCue(V),b[M]=V,a&&(M==="X-ASSET-LIST"||M==="X-ASSET-URL")&&V.addEventListener("enter",this.onEventCueEnter));}}u[E]={cues:b,dateRange:v,durationKnown:_};}}}},Hu=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=false,this.onTimeupdate=()=>{let{media:t}=this,i=this.levelDetails;if(!t||!i)return;this.currentTime=t.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:n,maxLiveSyncPlaybackRate:a}=this.config;if(!n||a===1||!i.live)return;let o=this.targetLatency;if(o===null)return;let l=r-o,d=Math.min(this.maxLatency,o+i.targetduration);if(l<d&&l>.05&&this.forwardBufferLength>1){let u=Math.min(2,Math.max(1,a)),h=Math.round(2/(1+Math.exp(-0.75*l-this.edgeStalled))*20)/20,f=Math.min(u,Math.max(1,h));this.changeMediaPlaybackRate(t,f);}else t.playbackRate!==1&&t.playbackRate!==0&&this.changeMediaPlaybackRate(t,1);},this.hls=e,this.config=e.config,this.registerListeners();}get levelDetails(){var e;return ((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){let{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;let t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let e=this.levelDetails;if(e===null||this.hls===null)return null;let{holdBack:t,partHoldBack:i,targetduration:r}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig,d=o&&i||t;(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*r);let c=r;return d+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=true;}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;let i=this.levelDetails;if(i===null)return null;let r=i.edge,n=e-t-this.edgeStalled,a=r-i.totalduration,o=r-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){let e=this.levelDetails;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;let i=e.buffered.length;return (i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null;}registerListeners(){let{hls:e}=this;e&&(e.on(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_UPDATED,this.onLevelUpdated,this),e.on(p.ERROR,this.onError,this));}unregisterListeners(){let{hls:e}=this;e&&(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_UPDATED,this.onLevelUpdated,this),e.off(p.ERROR,this.onError,this));}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate);}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null);}onManifestLoading(){this._latency=null,this.stallCount=0;}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate);}onError(e,t){var i;t.details===x.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(i=this.levelDetails)!=null&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"));}changeMediaPlaybackRate(e,t){var i,r;e.playbackRate!==t&&((i=this.hls)==null||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(r=this.targetLatency)==null?void 0:r.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t);}estimateLiveEdge(){let e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},Ku=class extends Un{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=>{let u=c.attrs,{audioCodec:h,videoCodec:f}=c;h&&(c.audioCodec=h=il(h,i)||void 0),f&&(f=c.videoCodec=ay(f));let{width:m,height:g,unknownCodecs:E}=c,v=E?.length||0;if(o||(o=!!(m&&g)),l||(l=!!f),d||(d=!!h),v||h&&!this.isAudioSupported(h)||f&&!this.isVideoSupported(f)){this.log(`Some or all CODECS not supported "${u.CODECS}"`);return}let{CODECS:y,"FRAME-RATE":S,"HDCP-LEVEL":b,"PATHWAY-ID":_,RESOLUTION:D,"VIDEO-RANGE":I}=u,R=`${`${_||"."}-`}${c.bitrate}-${D}-${S}-${y}-${I}-${b}`;if(n[R])if(n[R].uri!==c.url&&!c.attrs["PATHWAY-ID"]){let L=a[R]+=1;c.attrs["PATHWAY-ID"]=new Array(L+1).join(".");let M=this.createLevel(c);n[R]=M,r.push(M);}else n[R].addGroupId("audio",u.AUDIO),n[R].addGroupId("text",u.SUBTITLES);else {let L=this.createLevel(c);n[R]=L,a[R]=1,r.push(L);}}),this.filterAndSortMediaOptions(r,t,o,l,d);}createLevel(e){let t=new ms(e),i=e.supplemental;if(i!=null&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){let r=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(r.message),t.supportedResult=rp(r,[]);}return t}isAudioSupported(e){return Rn(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Rn(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,r,n){var a;let o=[],l=[],d=e,c=((a=t.stats)==null?void 0:a.parsing)||{};if((i||r)&&n&&(d=d.filter(({videoCodec:y,videoRange:S,width:b,height:_})=>(!!y||!!(b&&_))&&py(S))),d.length===0){Promise.resolve().then(()=>{if(this.hls){let y="no level with compatible codecs found in manifest",S=y;t.levels.length&&(S=`one or more CODECS in variant not supported: ${Ae(t.levels.map(_=>_.attrs.CODECS).filter((_,D,I)=>I.indexOf(_)===D))}`,this.warn(S),y+=` (${S})`);let b=new Error(y);this.hls.trigger(p.ERROR,{type:z.MEDIA_ERROR,details:x.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:true,url:t.url,error:b,reason:S});}}),c.end=performance.now();return}t.audioTracks&&(o=t.audioTracks.filter(y=>!y.audioCodec||this.isAudioSupported(y.audioCodec)),Vg(o)),t.subtitles&&(l=t.subtitles,Vg(l));let u=d.slice(0);d.sort((y,S)=>{if(y.attrs["HDCP-LEVEL"]!==S.attrs["HDCP-LEVEL"])return (y.attrs["HDCP-LEVEL"]||"")>(S.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&y.height!==S.height)return y.height-S.height;if(y.frameRate!==S.frameRate)return y.frameRate-S.frameRate;if(y.videoRange!==S.videoRange)return sl.indexOf(y.videoRange)-sl.indexOf(S.videoRange);if(y.videoCodec!==S.videoCodec){let b=$m(y.videoCodec),_=$m(S.videoCodec);if(b!==_)return _-b}if(y.uri===S.uri&&y.codecSet!==S.codecSet){let b=tl(y.codecSet),_=tl(S.codecSet);if(b!==_)return _-b}return y.averageBitrate!==S.averageBitrate?y.averageBitrate-S.averageBitrate:0});let h=u[0];if(this.steering&&(d=this.steering.filterParsedLevels(d),d.length!==u.length)){for(let y=0;y<u.length;y++)if(u[y].pathwayId===d[0].pathwayId){h=u[y];break}}this._levels=d;for(let y=0;y<d.length;y++)if(d[y]===h){var f;this._firstLevel=y;let S=h.bitrate,b=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${d.length} level(s) found, first bitrate: ${S}`),((f=this.hls.userConfig)==null?void 0:f.abrEwmaDefaultEstimate)===void 0){let _=Math.min(S,this.hls.config.abrEwmaDefaultEstimateMax);_>b&&b===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=_);}break}let m=n&&!r,g=this.hls.config,E=!!(g.audioStreamController&&g.audioTrackController),v={levels:d,audioTracks:o,subtitleTracks:l,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:r,altAudio:E&&!m&&o.some(y=>!!y.url)};c.end=performance.now(),this.hls.trigger(p.MANIFEST_PARSED,v);}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let c=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(p.ERROR,{type:z.OTHER_ERROR,details:x.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:c,reason:c.message}),u)return;e=Math.min(e,t.length-1);}let i=this.currentLevelIndex,r=this.currentLevel,n=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&r&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${i}${n?" with Pathway "+n:""}`);let 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;}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){let t=this.steering.pathways(),i=e.filter(r=>t.indexOf(r)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);return}this.steering.pathwayPriority=i;}}onError(e,t){t.fatal||!t.context||t.context.type===ue.LEVEL&&t.context.level===this.level&&this.checkRetry(t);}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===W.MAIN){let i=t.elementaryStreams;if(!Object.keys(i).some(n=>!!i[n]))return;let r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0);}}onLevelLoaded(e,t){var i;let{level:r,details:n}=t,a=t.levelInfo;if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=true);return}if(a===this.currentLevel||t.withoutMultiVariant){a.fragmentError===0&&(a.loadError=0);let l=a.details;l===t.details&&l.advanced&&(l=void 0),this.playlistLoaded(r,t,l);}else (i=t.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=true);}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e);}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=this.getUrlWithDirectives(e.uri,t),r=this.currentLevelIndex,n=e.attrs["PATHWAY-ID"],a=e.details,o=a?.age;this.log(`Loading level index ${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${n?" Pathway "+n:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${i}`),this.hls.trigger(p.LEVEL_LOADING,{url:i,level:r,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null});}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e);}removeLevel(e){var t;if(this._levels.length===1)return;let i=this._levels.filter((n,a)=>a!==e?true:(this.steering&&this.steering.removeLevel(n),n===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,n.details&&n.details.fragments.forEach(o=>o.level=-1)),false));Ap(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);let r=i.length-1;this._firstLevel=Math.min(this._firstLevel,r),this._startLevel&&(this._startLevel=Math.min(this._startLevel,r)),this.hls.trigger(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 Vg(s){let e={};s.forEach(t=>{let i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++;});}function h0(){return self.SourceBuffer||self.WebKitSourceBuffer}function f0(){if(!$i())return false;let e=h0();return !e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function MA(){if(!f0())return false;let s=$i();return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>s.isTypeSupported(kn(e,"video")))||["mp4a.40.2","fLaC"].some(e=>s.isTypeSupported(kn(e,"audio"))))}function wA(){var s;let e=h0();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}var PA=100,Vu=class extends Mn{constructor(e,t,i){super(e,t,i,"stream-controller",W.MAIN),this.audioCodecSwap=false,this.level=-1,this._forceStartLoad=false,this._hasEnoughToStart=false,this.altAudio=0,this.audioOnly=false,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=false,this.backtrackFragment=null,this.audioCodecSwitch=false,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick();},this.onMediaSeeked=()=>{let r=this.media,n=r?r.currentTime:null;if(n===null||!H(n)||(this.log(`Media seeked to ${n.toFixed(3)}`),!this.getBufferedFrag(n)))return;let a=this.getFwdBufferInfoAtPos(r,n,W.MAIN,0);if(a===null||a.len===0){this.warn(`Main forward buffer length at ${n} on "seeked" event ${a?a.len:"empty"})`);return}this.tick();},this.registerListeners();}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(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.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(){super.unregisterListeners();let{hls:e}=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.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.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying();}startLoad(e,t){if(this.levels){let{lastCurrentTime:i,hls:r}=this;if(this.stopLoad(),this.setInterval(PA),this.level=-1,!this.startFragRequested){let n=r.startLevel;n===-1&&(r.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=true):n=r.firstAutoLevel),r.nextLoadLevel=n,this.level=r.loadLevel,this._hasEnoughToStart=!!t;}i>0&&e===-1&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=C.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick();}else this._forceStartLoad=true,this.state=C.STOPPED;}stopLoad(){this._forceStartLoad=false,super.stopLoad();}doTick(){switch(this.state){case C.WAITING_LEVEL:{let{levels:e,level:t}=this,i=e?.[t],r=i?.details;if(r&&(!r.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(r))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:this.checkRetryDate();break}this.state===C.IDLE&&this.doTickIdle(),this.onTickEnd();}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===false&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged();}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:i,media:r}=this;if(t===null||!r&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;let n=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(i!=null&&i[n]))return;let a=i[n],o=this.getMainFwdBufferInfo();if(o===null)return;let l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){let g={};this.altAudio===2&&(g.type="video"),this.hls.trigger(p.BUFFER_EOS,g),this.state=C.ENDED;return}if(!this.buffering)return;e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;let d=a.details;if(!d||this.state===C.WAITING_LEVEL||this.waitForLive(a)){this.level=n,this.state=C.WAITING_LEVEL,this.startFragRequested=false;return}let c=o.len,u=this.getMaxBufferLength(a.maxBitrate);if(c>=u)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);let h=this.backtrackFragment?this.backtrackFragment.start:o.end,f=this.getNextFragment(h,d);if(this.couldBacktrack&&!this.fragPrevious&&f&&Fe(f)&&this.fragmentTracker.getState(f)!==We.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,h)){if(!f.gap){let E=this.audioOnly&&!this.altAudio?be.AUDIO:be.VIDEO,v=(E===be.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,E,W.MAIN);}f=this.getNextFragmentLoopLoading(f,d,o,W.MAIN,u);}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h));}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);r===We.NOT_LOADED||r===We.PARTIAL?Fe(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,i):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e);}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,W.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===2?"video":null);}onMediaAttached(e,t){super.onMediaAttached(e,t);let i=t.media;at(i,"playing",this.onMediaPlaying),at(i,"seeked",this.onMediaSeeked);}onMediaDetaching(e,t){let{media:i}=this;i&&(ht(i,"playing",this.onMediaPlaying),ht(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=false);}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.BUFFER_RESET,void 0),this.couldBacktrack=false,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=false;}onManifestParsed(e,t){let i=false,r=false;for(let n=0;n<t.levels.length;n++){let a=t.levels[n].audioCodec;a&&(i=i||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1);}this.audioCodecSwitch=i&&r&&!wA(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=false;}onLevelLoading(e,t){let{levels:i}=this;if(!i||this.state!==C.IDLE)return;let r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=C.WAITING_LEVEL);}onLevelLoaded(e,t){var i;let{levels:r,startFragRequested:n}=this,a=t.level,o=t.details,l=o.totalduration;if(!r){this.warn(`Levels were reset while loading level ${a}`);return}this.log(`Level ${a} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${l}`);let d=t.levelInfo,c=this.fragCurrent;c&&(this.state===C.FRAG_LOADING||this.state===C.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let u=0;if(o.live||(i=d.details)!=null&&i.live){var h;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;u=this.alignPlaylists(o,d.details,(h=this.levelLastLoaded)==null?void 0:h.details);}if(d.details=o,this.levelLastLoaded=d,n||this.setStartPosition(o,u),this.hls.trigger(p.LEVEL_UPDATED,{details:o,level:a}),this.state===C.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=C.IDLE;}n&&o.live&&this.synchronizeToLiveEdge(o),this.tick();}synchronizeToLiveEdge(e){let{config:t,media:i}=this;if(!i)return;let r=this.hls.liveSyncPosition,n=this.getLoadPosition(),a=e.fragmentStart,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(r!==null&&i.duration>r&&(n<r||!l)){let c=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!l&&i.readyState<4||n<o-c)&&(this._hasEnoughToStart||(this.nextLoadPosition=r),i.readyState))if(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${r.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var d;let u=ne.bufferInfo(i,r,0);if(!((d=u.buffered)!=null&&d.length)){i.currentTime=r;return}if(u.start<=n){i.currentTime=r;return}let{nextStart:f}=ne.bufferedInfo(u.buffered,n,0);f&&(i.currentTime=f);}else i.currentTime=r;}}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:r,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}let o=a[i.level];if(!o){this.warn(`Level ${i.level} not found on progress`);return}let 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,u=(t=i.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new El(this.hls,W.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=r?r.index:-1,g=m!==-1,E=new Cn(i.level,i.sn,i.stats.chunkCount,n.byteLength,m,g),v=this.initPTS[i.cc];f.push(n,u,h,d,i,r,l.totalduration,c,E,v);}onAudioTrackSwitching(e,t){let i=this.hls,r=this.altAudio!==0;if(nl(t.url,i))this.altAudio=1;else {if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState();}else this.audioOnly&&this.resetTransmuxer();if(r){this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(p.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(p.AUDIO_TRACK_SWITCHED,t);}),i.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(p.AUDIO_TRACK_SWITCHED,t);}}onAudioTrackSwitched(e,t){let i=nl(t.url,this.hls);if(i){let r=this.videoBuffer;r&&this.mediaBuffer!==r&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=r);}this.altAudio=i?2:0,this.tick();}onBufferCreated(e,t){let i=t.tracks,r,n,a=false;for(let o in i){let 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,n=i.type===W.MAIN;if(n){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===C.PARSED&&(this.state=C.IDLE);return}let o=r?r.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),Fe(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,r);}let a=this.media;a&&(!this._hasEnoughToStart&&ne.getBuffered(a).length&&(this._hasEnoughToStart=true,this.seekToStartPos()),n&&this.tick());}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=C.ERROR;return}switch(t.details){case 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(W.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)===ue.LEVEL&&(this.state=C.IDLE);break;case x.BUFFER_ADD_CODEC_ERROR:case x.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case x.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=true:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case x.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=C.IDLE,this._hasEnoughToStart||(this.startFragRequested=false,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate();}onBufferFlushed(e,{type:t}){if(t!==be.AUDIO||!this.altAudio){let i=(t===be.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,W.MAIN),this.tick());}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels;}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap;}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}let r=this.timelineOffset;r&&i&&(i+=r);let n=this.getLevelDetails(),a=ne.getBuffered(e),o=a.length?a.start(0):0,l=o-i,d=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||l>0&&(l<d||this.loadingParts&&l<2*(n?.partTarget||0)))&&(this.log(`adjusting start position by ${l} to match buffer start`),i+=l,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i);}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=true,this._doFragLoad(e,t).then(i=>{let{hls:r}=this,n=i?.frag;if(!n||this.fragContextChanged(n))return;t.fragmentError=0,this.state=C.IDLE,this.startFragRequested=false,this.bitrateTest=false;let a=n.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),r.trigger(p.FRAG_LOADED,i),n.bitrateTest=false;}).catch(i=>{this.state===C.STOPPED||this.state===C.ERROR||(this.warn(i),this.resetFragmentLoading(e));});}_handleTransmuxComplete(e){let t=this.playlistType,{hls:i}=this,{remuxResult:r,chunkMeta:n}=e,a=this.getCurrentContext(n);if(!a){this.resetWhenMissingContext(n);return}let{frag:o,part:l,level:d}=a,{video:c,text:u,id3:h,initSegment:f}=r,{details:m}=d,g=this.altAudio?void 0:r.audio;if(this.fragContextChanged(o)){this.fragmentTracker.removeFragment(o);return}if(this.state=C.PARSING,f){let E=f.tracks;if(E){let b=o.initSegment||o;if(this.unhandledEncryptionError(f,o))return;this._bufferInitSegment(d,E,b,n),i.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:t,tracks:E});}let v=f.initPTS,y=f.timescale,S=this.initPTS[o.cc];if(H(v)&&(!S||S.baseTime!==v||S.timescale!==y)){let b=f.trackId;this.initPTS[o.cc]={baseTime:v,timescale:y,trackId:b},i.trigger(p.INIT_PTS_FOUND,{frag:o,id:t,initPTS:v,timescale:y,trackId:b});}}if(c&&m){g&&c.type==="audiovideo"&&this.logMuxedErr(o);let E=m.fragments[o.sn-1-m.startSN],v=o.sn===m.startSN,y=!E||o.cc>E.cc;if(r.independent!==false){let{startPTS:S,endPTS:b,startDTS:_,endDTS:D}=c;if(l)l.elementaryStreams[c.type]={startPTS:S,endPTS:b,startDTS:_,endDTS:D};else if(c.firstKeyFrame&&c.independent&&n.id===1&&!y&&(this.couldBacktrack=true),c.dropped&&c.independent){let I=this.getMainFwdBufferInfo(),k=(I?I.end:this.getLoadPosition())+this.config.maxBufferHole,R=c.firstKeyFramePTS?c.firstKeyFramePTS:S;if(!v&&k<R-this.config.maxBufferHole&&!y){this.backtrack(o);return}else y&&(o.gap=true);o.setElementaryStreamInfo(c.type,o.start,b,o.start,D,true);}else v&&S-(m.appliedTimelineOffset||0)>Jo&&(o.gap=true);o.setElementaryStreamInfo(c.type,S,b,_,D),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(c,o,l,n,v||y);}else if(v||y)o.gap=true;else {this.backtrack(o);return}}if(g){let{startPTS:E,endPTS:v,startDTS:y,endDTS:S}=g;l&&(l.elementaryStreams[be.AUDIO]={startPTS:E,endPTS:v,startDTS:y,endDTS:S}),o.setElementaryStreamInfo(be.AUDIO,E,v,y,S),this.bufferFragmentData(g,o,l,n);}if(m&&h!=null&&h.samples.length){let E={id:t,frag:o,details:m,samples:h.samples};i.trigger(p.FRAG_PARSING_METADATA,E);}if(m&&u){let E={id:t,frag:o,details:m,samples:u.samples};i.trigger(p.FRAG_PARSING_USERDATA,E);}}logMuxedErr(e){this.warn(`${Fe(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`);}_bufferInitSegment(e,t,i,r){if(this.state!==C.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));let{audio:n,video:a,audiovideo:o}=t;if(n){let d=e.audioCodec,c=qo(n.codec,d);c==="mp4a"&&(c="mp4a.40.5");let u=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){c&&(c.indexOf("mp4a.40.5")!==-1?c="mp4a.40.2":c="mp4a.40.5");let h=n.metadata;h&&"channelCount"in h&&(h.channelCount||1)!==1&&u.indexOf("firefox")===-1&&(c="mp4a.40.5");}c&&c.indexOf("mp4a.40.5")!==-1&&u.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(c="mp4a.40.2",this.log(`Android: force audio codec to ${c}`)),d&&d!==c&&this.log(`Swapping manifest audio codec "${d}" for "${c}"`),n.levelCodec=c,n.id=W.MAIN,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${c||""}/${d||""}/${n.codec}]`),delete t.audiovideo;}if(a){a.levelCodec=e.videoCodec,a.id=W.MAIN;let d=a.codec;if(d?.length===4)switch(d){case "hvc1":case "hev1":a.codec="hvc1.1.6.L120.90";break;case "av01":a.codec="av01.0.04M.08";break;case "avc1":a.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${d}]${a.codec!==d?" parsed-corrected="+a.codec:""}${a.supplemental?" supplemental="+a.supplemental:""}`),delete t.audiovideo;}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);let l=Object.keys(t);if(l.length){if(this.hls.trigger(p.BUFFER_CODECS,t),!this.hls)return;l.forEach(d=>{let u=t[d].initSegment;u!=null&&u.byteLength&&this.hls.trigger(p.BUFFER_APPENDING,{type:d,data:u,frag:i,part:null,chunkMeta:r,parent:i.type});});}this.tickImmediate();}getMainFwdBufferInfo(){let e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,W.MAIN)}get maxBufferLength(){let{levels:e,level:t}=this,i=e?.[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=true,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=C.IDLE;}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===false){let i=e.currentTime;if(ne.isBuffered(e,i)?t=this.getAppendedFrag(i):ne.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;let r=this.fragPlaying,n=t.level;(!r||t.sn!==r.sn||r.level!==n)&&(this.fragPlaying=t,this.hls.trigger(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(){var e;if(this.fragPlaying)return this.fragPlaying;let t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return H(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;let t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(H(t)){let i=this.getLevelDetails(),r=this.currentFrag||(i?gs(null,i.fragments,t):null);if(r){let n=r.programDateTime;if(n!==null){let a=n+(t-r.start)*1e3;return new Date(a)}}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}},Wu=class extends ft{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e;}abort(e){for(let i in this.keyIdToKeyInfo){let r=this.keyIdToKeyInfo[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.keyIdToKeyInfo){let t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e];}}destroy(){this.detach();for(let e in this.keyIdToKeyInfo){let t=this.keyIdToKeyInfo[e].loader;t&&t.destroy();}this.keyIdToKeyInfo={};}createKeyLoadError(e,t=x.KEY_LOAD_ERROR,i,r,n){return new Vt({type:z.NETWORK_ERROR,details:t,fatal:false,frag:e,response:n,error:i,networkDetails:r})}loadClear(e,t,i){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let r=0,n=t.length;r<n;r++){let a=t[r];if(e.cc<=a.cc&&(!Fe(e)||!Fe(a)||e.sn<a.sn)||!i&&r==n-1)return this.emeController.selectKeySystemFormat(a).then(o=>{if(!this.emeController)return;a.setKeyFormat(o);let l=zo(o);if(l)return this.emeController.getKeySystemAccess([l])})}if(this.config.requireKeySystemAccessOnStart){let r=bn(this.config);if(r.length)return this.emeController.getKeySystemAccess(r)}}return null}load(e){return !e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,r;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);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=Lc(n),l=this.keyIdToKeyInfo[o];if((i=l)!=null&&i.decryptdata.key)return n.key=l.decryptdata.key,Promise.resolve({frag:e,keyInfo:l});if(this.emeController&&(r=l)!=null&&r.keyLoadPromise)switch(this.emeController.getKeyStatus(l.decryptdata)){case "usable":case "usable-in-future":return l.keyLoadPromise.then(c=>{let{keyInfo:u}=c;return n.key=u.decryptdata.key,{frag:e,keyInfo:u}})}switch(this.log(`${this.keyIdToKeyInfo[o]?"Rel":"L"}oading${n.keyId?" keyId: "+Ze(n.keyId):""} URI: ${n.uri} from ${e.type} ${e.level}`),l=this.keyIdToKeyInfo[o]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case "SAMPLE-AES":case "SAMPLE-AES-CENC":case "SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(l,e):this.loadKeyEME(l,e);case "AES-128":case "AES-256":case "AES-256-CTR":return this.loadKeyHTTP(l,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){var r;if(!e.decryptdata.keyId&&(r=t.initSegment)!=null&&r.data){let a=jT(t.initSegment.data);if(a.length){let o=a[0];o.some(l=>l!==0)?(this.log(`Using keyId found in init segment ${Ze(o)}`),pr.setKeyIdForUri(e.decryptdata.uri,o)):(o=pr.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${Ze(o)}`)),e.decryptdata.keyId=o;}}if(!e.decryptdata.keyId&&!Fe(t))return Promise.resolve(i);let n=this.emeController.loadKey(i);return (e.keyLoadPromise=n.then(a=>(e.mediaKeySessionContext=a,i))).catch(a=>{throw e.keyLoadPromise=null,"data"in a&&(a.data.frag=t),a})}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},u={onSuccess:(h,f,m,g)=>{let{frag:E,keyInfo:v}=m,y=Lc(v.decryptdata);if(!E.decryptdata||v!==this.keyIdToKeyInfo[y])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(h.data),E.keyLoader=null,v.loader=null,a({frag:E,keyInfo:v});},onError:(h,f,m,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,Te({url:l.url,data:void 0},h)));},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m));},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.INTERNAL_ABORTED,new Error("key loading aborted"),m));}};n.load(l,c,u);})}resetLoader(e){let{frag:t,keyInfo:i,url:r}=e,n=i.loader;t.keyLoader===n&&(t.keyLoader=null,i.loader=null);let a=Lc(i.decryptdata)||r;delete this.keyIdToKeyInfo[a],n&&n.destroy();}};function Lc(s){if(s.keyFormat!==Je.FAIRPLAY){let e=s.keyId;if(e)return Ze(e)}return s.uri}function Wg(s){let{type:e}=s;switch(e){case ue.AUDIO_TRACK:return W.AUDIO;case ue.SUBTITLE_TRACK:return W.SUBTITLE;default:return W.MAIN}}function xc(s,e){let t=s.url;return (t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var Yu=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners();}startLoad(e){}stopLoad(){this.destroyInternalLoaders();}registerListeners(){let{hls:e}=this;e.on(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),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,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),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this);}createInternalLoader(e){let t=this.hls.config,i=t.pLoader,r=t.loader,n=i||r,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e];}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e);}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders();}onManifestLoading(e,t){let{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ue.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null});}onLevelLoading(e,t){let{id:i,level:r,pathwayId:n,url:a,deliveryDirectives:o,levelInfo:l}=t;this.load({id:i,level:r,pathwayId:n,responseType:"text",type:ue.LEVEL,url:a,deliveryDirectives:o,levelOrTrack:l});}onAudioTrackLoading(e,t){let{id:i,groupId:r,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ue.AUDIO_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o});}onSubtitleTrackLoading(e,t){let{id:i,groupId:r,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ue.SUBTITLE_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o});}onLevelsUpdated(e,t){let i=this.loaders[ue.LEVEL];if(i){let r=i.context;r&&!t.levels.some(n=>n===r.levelOrTrack)&&(i.abort(),delete this.loaders[ue.LEVEL]);}}load(e){var t;let i=this.hls.config,r=this.getInternalLoader(e);if(r){let d=this.hls.logger,c=r.context;if(c&&c.levelOrTrack===e.levelOrTrack&&(c.url===e.url||c.deliveryDirectives&&!e.deliveryDirectives)){c.url===e.url?d.log(`[playlist-loader]: ignore ${e.url} ongoing request`):d.log(`[playlist-loader]: ignore ${e.url} in favor of ${c.url}`);return}d.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort();}let n;if(e.type===ue.MANIFEST?n=i.manifestLoadPolicy.default:n=Se({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),H((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===ue.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===ue.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===ue.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){let c=d.partTarget,u=d.targetduration;if(c&&u){let h=Math.max(c*3,u*.8)*1e3;n=Se({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)});}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,c,u,h)=>{let f=this.getInternalLoader(u);this.resetInternalLoader(u.type);let m=d.data;c.parsing.start=performance.now(),us.isMediaPlaylist(m)||u.type!==ue.MANIFEST?this.handleTrackOrLevelPlaylist(d,c,u,h||null,f):this.handleMasterPlaylist(d,c,u,h);},onError:(d,c,u,h)=>{this.handleNetworkError(c,u,false,d,h);},onTimeout:(d,c,u)=>{this.handleNetworkError(c,u,true,void 0,d);}};r.load(e,o,l);}checkAutostartLoad(){if(!this.hls)return;let{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t));}handleMasterPlaylist(e,t,i,r){let n=this.hls,a=e.data,o=xc(e,i),l=us.parseMasterPlaylist(a,o);if(l.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,l.playlistParsingError,r,t);return}let{contentSteering:d,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m}=l;this.variableList=m,c.forEach(y=>{let{unknownCodecs:S}=y;if(S){let{preferManagedMediaSource:b}=this.hls.config,{audioCodec:_,videoCodec:D}=y;for(let I=S.length;I--;){let k=S[I];Rn(k,"audio",b)?(y.audioCodec=_=_?`${_},${k}`:k,gr.audio[_.substring(0,4)]=2,S.splice(I,1)):Rn(k,"video",b)&&(y.videoCodec=D=D?`${D},${k}`:k,gr.video[D.substring(0,4)]=2,S.splice(I,1));}}});let{AUDIO:g=[],SUBTITLES:E,"CLOSED-CAPTIONS":v}=us.parseMasterPlaylistMedia(a,o,l);g.length&&!g.some(S=>!S.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:false,autoselect:false,forced:false,id:-1,attrs:new Ce({}),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:u,sessionKeys:h,startTimeOffset:f,variableList:m});}handleTrackOrLevelPlaylist(e,t,i,r,n){let a=this.hls,{id:o,level:l,type:d}=i,c=xc(e,i),u=H(l)?l:H(o)?o:0,h=Wg(i),f=us.parseLevelPlaylist(e.data,c,u,h,0,this.variableList);if(d===ue.MANIFEST){let m={attrs:new Ce({}),bitrate:0,details:f,name:"",url:c};f.requestScheduled=t.loading.start+yp(f,0),a.trigger(p.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:c,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null});}t.parsing.end=performance.now(),i.levelDetails=f,this.handlePlaylistLoaded(f,e,t,i,r,n);}handleManifestParsingError(e,t,i,r,n){this.hls.trigger(p.ERROR,{type:z.NETWORK_ERROR,details:x.MANIFEST_PARSING_ERROR,fatal:t.type===ue.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===ue.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===ue.AUDIO_TRACK||e.type===ue.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);this.hls.logger.warn(`[playlist-loader]: ${a}`);let l=x.UNKNOWN,d=false,c=this.getInternalLoader(e);switch(e.type){case ue.MANIFEST:l=i?x.MANIFEST_LOAD_TIMEOUT:x.MANIFEST_LOAD_ERROR,d=true;break;case ue.LEVEL:l=i?x.LEVEL_LOAD_TIMEOUT:x.LEVEL_LOAD_ERROR,d=false;break;case ue.AUDIO_TRACK:l=i?x.AUDIO_TRACK_LOAD_TIMEOUT:x.AUDIO_TRACK_LOAD_ERROR,d=false;break;case ue.SUBTITLE_TRACK:l=i?x.SUBTITLE_TRACK_LOAD_TIMEOUT:x.SUBTITLE_LOAD_ERROR,d=false;break}c&&this.resetInternalLoader(e.type);let u={type:z.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(r){let h=t?.url||e.url;u.response=Te({url:h,data:void 0},r);}this.hls.trigger(p.ERROR,u);}handlePlaylistLoaded(e,t,i,r,n,a){let o=this.hls,{type:l,level:d,levelOrTrack:c,id:u,groupId:h,deliveryDirectives:f}=r,m=xc(t,r),g=Wg(r),E=typeof r.level=="number"&&g===W.MAIN?d:void 0,v=e.playlistParsingError;if(v){if(this.hls.logger.warn(`${v} ${e.url}`),!o.config.ignorePlaylistParsingErrors){o.trigger(p.ERROR,{type:z.NETWORK_ERROR,details:x.LEVEL_PARSING_ERROR,fatal:false,url:m,error:v,reason:v.message,response:t,context:r,level:E,parent:g,networkDetails:n,stats:i});return}e.playlistParsingError=null;}if(!e.fragments.length){let y=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(p.ERROR,{type:z.NETWORK_ERROR,details:x.LEVEL_EMPTY_ERROR,fatal:false,url:m,error:y,reason:y.message,response:t,context:r,level:E,parent:g,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 ue.MANIFEST:case ue.LEVEL:if(E){if(!c)E=0;else if(c!==o.levels[E]){let y=o.levels.indexOf(c);y>-1&&(E=y);}}o.trigger(p.LEVEL_LOADED,{details:e,levelInfo:c||o.levels[0],level:E||0,id:u||0,stats:i,networkDetails:n,deliveryDirectives:f,withoutMultiVariant:l===ue.MANIFEST});break;case ue.AUDIO_TRACK:o.trigger(p.AUDIO_TRACK_LOADED,{details:e,track:c,id:u||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:f});break;case ue.SUBTITLE_TRACK:o.trigger(p.SUBTITLE_TRACK_LOADED,{details:e,track:c,id:u||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:f});break}}},pi=class s{static get version(){return wn}static isMSESupported(){return f0()}static isSupported(){return MA()}static getMediaSource(){return $i()}static get Events(){return p}static get MetadataSchema(){return At}static get ErrorTypes(){return z}static get ErrorDetails(){return x}static get DefaultConfig(){return s.defaultConfig?s.defaultConfig:_A}static set DefaultConfig(e){s.defaultConfig=e;}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new eh,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=false;let t=this.logger=UT(e.debug||false,"Hls instance",e.assetPlayerId),i=this.config=LA(s.DefaultConfig,e,t);this.userConfig=e,i.progressive&&xA(i,t);let{abrController:r,bufferController:n,capLevelController:a,errorController:o,fpsController:l}=i,d=new o(this),c=this.abrController=new r(this),u=new Uc(this),h=i.interstitialsController,f=h?this.interstitialsController=new h(this,s):null,m=this.bufferController=new n(this,u),g=this.capLevelController=new a(this),E=new l(this),v=new Yu(this),y=i.contentSteeringController,S=y?new y(this):null,b=this.levelController=new Ku(this,S),_=new Gu(this),D=new Wu(this.config,this.logger),I=this.streamController=new Vu(this,u,D),k=this.gapController=new Bu(this,u);g.setStreamController(I),E.setStreamController(I);let R=[v,b,I];f&&R.splice(1,0,f),S&&R.splice(1,0,S),this.networkControllers=R;let L=[c,m,k,g,E,_,u];this.audioTrackController=this.createController(i.audioTrackController,R);let M=i.audioStreamController;M&&R.push(this.audioStreamController=new M(this,u,D)),this.subtitleTrackController=this.createController(i.subtitleTrackController,R);let $=i.subtitleStreamController;$&&R.push(this.subtititleStreamController=new $(this,u,D)),this.createController(i.timelineController,L),D.emeController=this.emeController=this.createController(i.emeController,L),this.cmcdController=this.createController(i.cmcdController,L),this.latencyController=this.createController(Hu,L),this.coreComponents=L,R.push(d);let K=d.onErrorOut;typeof K=="function"&&this.on(p.ERROR,K,d),this.on(p.MANIFEST_LOADED,v.onManifestLoaded,v);}createController(e,t){if(e){let i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i);}once(e,t,i=this){this._emitter.once(e,t,i);}removeAllListeners(e){this._emitter.removeAllListeners(e);}off(e,t,i=this,r){this._emitter.off(e,t,i,r);}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=true;let r=e===p.ERROR;this.trigger(p.ERROR,{type:z.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(){this.logger.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){if(!e||"media"in e&&!e.media){let n=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(p.ERROR,{type:z.OTHER_ERROR,details:x.ATTACH_MEDIA_ERROR,fatal:true,error:n});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());let t="media"in e,i=t?e.media:e,r=t?e:{media:i};this._media=i,this.trigger(p.MEDIA_ATTACHING,r);}detachMedia(){this.logger.log("detachMedia"),this.trigger(p.MEDIA_DETACHING,{}),this._media=null;}transferMedia(){this._media=null;let e=this.bufferController.transferMedia();return this.trigger(p.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();let t=this.media,i=this._url,r=this._url=qu.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:true});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${r}`),t&&i&&(i!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(p.MANIFEST_LOADING,{url:e});}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=true,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),!(!this.started||!this.networkControllers));i++);}stopLoad(){this.logger.log("stopLoad"),this.started=false;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering();}));}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering();}));}get inFlightFragments(){let e={[W.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[W.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[W.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec();}recoverMediaError(){this.logger.log("recoverMediaError");let e=this._media,t=e?.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t));}removeLevel(e){this.levelController.removeLevel(e);}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=Yb()),e}get levels(){let e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch();}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch();}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e;}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e;}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e;}get startLevel(){let e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e;}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t);}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e);}get abrEwmaDefaultEstimate(){let{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated());}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){gy(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated());}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let i=e.length;for(let r=0;r<i;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this,r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,i)for(let n=r;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return r}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e;}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return ((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return ((t=this.subtitleTrackController)==null?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){let e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e);}get allSubtitleTracks(){let e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e);}get subtitleDisplay(){let e=this.subtitleTrackController;return e?e.subtitleDisplay:false}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e);}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e;}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e;}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e;}get bufferedToEnd(){var e;return !!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return ((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){let i=op(t);return np(e,i,navigator.mediaCapabilities)}};pi.defaultConfig=void 0;var g0=Symbol.for(""),OA=s=>{if(s?.r===g0)return s?._$litStatic$},ch=s=>({_$litStatic$:s,r:g0});var m0=new Map,uh=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=OA(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 u=a.join("$$lit$$");(e=m0.get(u))===void 0&&(a.raw=a,m0.set(u,e=a)),t=o;}return s(e,...t)},p0=uh(chunk2E5GLLOS_cjs.a);var w,E0,v0,kl,T0,y0,hh,S0,b0,fh,A0,_0,mh,Dl,I0,L0,x0,R0,gh,ph,Eh,Cl,k0,vh,Th,D0,yh,Ml,Sh,Bn,wl,C0,M0,w0,P0,O0,F0,U0,vr,Pl,N0,B0;exports.a=class ge extends chunkTKJYRGEU_cjs.a{constructor(){super(...arguments);chunkJHSFSCC2_cjs.e(this,w);this._controls=["play","time","seek","volume","audiotracks","fullscreen","subtitles"];this.popped=false;this._isProcessing=false;this._startedPlaying=false;this._audioTrackCount=0;this._hlsAudioTracks=[];this._hlsAudioTrackIdMap=new Map;this._intersectionObserver=new chunkBTCK3T4L_cjs.a(this,{callback:chunkJHSFSCC2_cjs.g(this,w,x0).bind(this)});this.embedController=new chunkRQN3DXJB_cjs.b(this);this._intersected=false;this._queue=[];this.languageController=new chunk5QLIDHRT_cjs.d(this);}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(" "):Array.isArray(t)?this._controls=t:this._controls=[],this.requestUpdate("controls");}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||!chunkJHSFSCC2_cjs.g(this,w,mh).call(this,"thumbnail","jpg")?null:this._poster&&this._poster=="custom"?this.embedController.embedFile(chunkJHSFSCC2_cjs.g(this,w,Dl).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(chunkJHSFSCC2_cjs.g(this,w,Dl).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(chunkJHSFSCC2_cjs.g(this,w,Dl).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?chunkJHSFSCC2_cjs.g(this,w,Cl).call(this):this._queue.push(()=>chunkJHSFSCC2_cjs.g(this,w,Cl).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.poster&&this.style.setProperty("background",`center / contain no-repeat url(${this.poster})`);}connectedCallback(){super.connectedCallback(),this.languageController.locale=this.locale||"en",this.loadTheme(),this.addEventListener("mave:video_element_ready",chunkJHSFSCC2_cjs.g(this,w,v0).bind(this));}requestUpdate(t,i){t==="locale"&&(this.languageController.locale=this.locale||"en"),super.requestUpdate(t,i);}disconnectedCallback(){super.disconnectedCallback(),this._metricsInstance?.demonitor(),chunkJHSFSCC2_cjs.g(this,w,fh).call(this),this._cleanupHlsAudioTracks?.(),this._cleanupHlsAudioTracks=void 0,this._pendingAudioTrackSetup!=null&&(cancelAnimationFrame(this._pendingAudioTrackSetup),this._pendingAudioTrackSetup=void 0),this._hlsAudioTrackIdMap.clear(),this._hlsAudioTracks=[],this._currentAudioTrackMenu=void 0,this._themeMutationObserver?.disconnect(),this._themeMutationObserver=void 0,this._themeMutationObserverRoot=void 0;}loadTheme(){this.embed&&this._themeLoaded!=this.theme&&(this.theme&&this.theme.endsWith(".js")?chunk2EIQ3VMA_cjs.a.external(this.theme):chunk2EIQ3VMA_cjs.a.get(this.theme,`${this.embedController.cdnRoot}/themes/player`),this._themeLoaded=chunk2EIQ3VMA_cjs.a.getTheme());}updateEmbed(t){this._embedObj=t,this._audioTrackCount=t.audio_tracks?.length??0,this.updateStylePoster(),chunkJHSFSCC2_cjs.g(this,w,kl).call(this),this.poster=this._embedObj.settings.poster,this.attributes.getNamedItem("color")||(this.color=this._embedObj.settings.color),this.attributes.getNamedItem("opacity")||(this.opacity=this._embedObj.settings.opacity?this._embedObj.settings.opacity:void 0),this.attributes.getNamedItem("aspect-ratio")||(this.aspect_ratio=this._embedObj.settings.aspect_ratio),this.attributes.getNamedItem("width")||(this.width=this._embedObj.settings.width),this.attributes.getNamedItem("height")||(this.height=this._embedObj.settings.height),this.attributes.getNamedItem("autoplay")||(this.autoplay=this._embedObj.settings.autoplay=="on_show"?"lazy":this._embedObj.settings.autoplay),this.attributes.getNamedItem("controls")||(this.controls=this._embedObj.settings.controls),this.attributes.getNamedItem("loop")||(this.loop=this._embedObj.settings.loop);}get styles(){let t={},i=!!this._embedObj?.subtitles?.length,r=this.subtitles==="none"||this.subtitles==="off"||!i,n=this.controls.includes("volume")||this.controls.includes("full");(this.color||this._embedObj?.settings.color)&&(t["--primary-color"]=`${this.color||this._embedObj?.settings.color}${this.opacity||this._embedObj?.settings.opacity?this._embedObj?.settings.opacity:""}`),this.aspect_ratio=="auto"||this._embedObj?.settings.aspect_ratio=="auto"&&!this.aspect_ratio?t["--aspect-ratio"]=this._embedObj?.video.aspect_ratio:t["--aspect-ratio"]=this.aspect_ratio||this._embedObj?.settings.aspect_ratio,(this.width||this._embedObj?.settings.width)&&(t["--width"]=this.width||this._embedObj?.settings.width),(this.height||this._embedObj?.settings.height)&&(t["--height"]=this.height||this._embedObj?.settings.height),!this.controls.includes("full")&&!this.controls.includes("big")&&!this.controls.includes("none")&&(t["--play-display"]=this.controls.includes("play")?"flex":"none",t["--time-display"]=this.controls.includes("time")?"flex":"none",t["--seek-bar-visibility"]=this.controls.includes("seek")?"visible":"hidden",t["--volume-display"]=this.controls.includes("volume")?"flex":"none",t["--fullscreen-display"]=this.controls.includes("fullscreen")?"flex":"none",t["--media-captions-menu-button-display"]=this.controls.includes("subtitles")?"flex":"none"),t["--playbackrate-display"]=this.controls.includes("rate")?"flex":"none",(r||this._embedObj?.created_at<1740674988&&!this.subtitles&&!this.active_subtitle)&&(t["--media-captions-menu-button-display"]="none"),this.controls.includes("full")||this._embedObj?.settings.controls=="full"&&!this.controls.includes("big")&&!this.controls.includes("none")?t["--media-control-bar-display"]="flex":t["--media-control-bar-display"]="none",this.controls.includes("big")||this._embedObj?.settings.controls=="big"&&!this.controls.includes("full")&&!this.controls.includes("none")?t["--big-button-display"]="flex":t["--big-button-display"]="none",this._embedObj?.video.audio===false?t["--media-mute-button-display"]="none":n?t["--media-mute-button-display"]="flex":t["--media-mute-button-display"]="none";let a=this._audioTrackCount??0,o=this.controls.includes("audiotracks")||this.controls.includes("full"),l=this.audioTracks??"auto",d=o&&a>1;return l==="off"?d=false:l==="on"&&(d=o&&a>0),t["--media-audio-track-menu-button-display"]=d?"flex":"none",chunkQQDH35OW_cjs.a(t)}render(){if(!this.embed)return;let t=this.querySelector('[slot="start-screen"], [data-slot="start-screen"]');return chunk2E5GLLOS_cjs.a`
|
|
1493
|
+
`),l=[],c=e?MS(e.baseTime,e.timescale):0,u="00:00.000",h=0,f=0,m,g=true;o.oncue=function(E){let v=t[i],T=t.ccOffset,S=(h-c)/9e4;if(v!=null&&v.new&&(f!==void 0?T=t.ccOffset=v.start:eA(t,i,S)),S){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}T=S-t.presentationOffset;}let b=E.endTime-E.startTime,_=St((E.startTime+T-f)*9e4,r*9e4)/9e4;E.startTime=Math.max(_,0),E.endTime=Math.max(_+b,0);let D=E.text.trim();E.text=decodeURIComponent(encodeURIComponent(D)),E.id||(E.id=oh(E.startTime,E.endTime,D)),E.endTime>0&&l.push(E);},o.onparsingerror=function(E){m=E;},o.onflush=function(){if(m){a(m);return}n(l);},d.forEach(E=>{if(g)if(vc(E,"X-TIMESTAMP-MAP=")){g=false,E.slice(16).split(",").forEach(v=>{vc(v,"LOCAL:")?u=v.slice(6):vc(v,"MPEGTS:")&&(h=parseInt(v.slice(7)));});try{f=Jb(u)/1e3;}catch(v){m=v;}return}else E===""&&(g=false);o.parse(E+`
|
|
1494
|
+
`);}),o.flush();}var Tc="stpp.ttml.im1t",s0=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,r0=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,iA={left:"start",center:"center",right:"end",start:"start",end:"end"};function Mg(s,e,t,i){let r=de(new Uint8Array(s),["mdat"]);if(r.length===0){i(new Error("Could not parse IMSC1 mdat"));return}let n=r.map(o=>At(o)),a=CS(e.baseTime,1,e.timescale);try{n.forEach(o=>t(sA(o,a)));}catch(o){i(o);}}function sA(s,e){let r=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");let n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((u,h)=>(u[h]=r.getAttribute(`ttp:${h}`)||n[h],u),{}),o=r.getAttribute("xml:space")!=="preserve",d=wg(yc(r,"styling","style")),l=wg(yc(r,"layout","region")),c=yc(r,"body","[begin]");return [].map.call(c,u=>{let h=n0(u,o);if(!h||!u.hasAttribute("begin"))return null;let f=bc(u.getAttribute("begin"),a),m=bc(u.getAttribute("dur"),a),g=bc(u.getAttribute("end"),a);if(f===null)throw Pg(u);if(g===null){if(m===null)throw Pg(u);g=f+m;}let E=new ah(f-e,g-e,h);E.id=oh(E.startTime,E.endTime,E.text);let v=l[u.getAttribute("region")],T=d[u.getAttribute("style")],S=rA(v,T,d),{textAlign:b}=S;if(b){let _=iA[b];_&&(E.lineAlign=_),E.align=b;}return Se(E,S),E}).filter(u=>u!==null)}function yc(s,e,t){let i=s.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function wg(s){return s.reduce((e,t)=>{let i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function n0(s,e){return [].slice.call(s.childNodes).reduce((t,i,r)=>{var n;return i.nodeName==="br"&&r?t+`
|
|
1495
|
+
`:(n=i.childNodes)!=null&&n.length?n0(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function rA(s,e,t){let i="http://www.w3.org/ns/ttml#styling",r=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(r=t[a]),n.reduce((o,d)=>{let l=Sc(e,i,d)||Sc(s,i,d)||Sc(r,i,d);return l&&(o[d]=l),o},{})}function Sc(s,e,t){return s&&s.hasAttributeNS(e,t)?s.getAttributeNS(e,t):null}function Pg(s){return new Error(`Could not parse ttml timestamp ${s}`)}function bc(s,e){if(!s)return null;let t=e0(s);return t===null&&(s0.test(s)?t=nA(s,e):r0.test(s)&&(t=aA(s,e))),t}function nA(s,e){let t=s0.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 aA(s,e){let t=r0.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 lr=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;}},Pu=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=Fg(),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=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0;}initCea608Parsers(){let e=new lr(this,"textTrack1"),t=new lr(this,"textTrack2"),i=new lr(this,"textTrack3"),r=new lr(this,"textTrack4");this.cea608Parser1=new yl(1,e,t),this.cea608Parser2=new yl(3,i,r);}addCues(e,t,i,r,n){let a=false;for(let o=n.length;o--;){let d=n[o],l=oA(d[0],d[1],t,i);if(l>=0&&(d[0]=Math.min(d[0],t),d[1]=Math.max(d[1],i),a=true,l/(i-t)>.5))return}if(a||n.push([t,i]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,i,r);}else {let o=this.Cues.newCue(null,t,i,r);this.hls.trigger(p.CUES_PARSED,{type:"captions",cues:o,track:e});}}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:n,trackId:a}){let{unparsedVttFrags:o}=this;i===Y.MAIN&&(this.initPTS[t.cc]={baseTime:r,timescale:n,trackId:a}),o.length&&(this.unparsedVttFrags=[],o.forEach(d=>{this.initPTS[d.frag.cc]?this.onFragLoaded(p.FRAG_LOADED,d):this.hls.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:false,frag:d.frag,error:new Error("Subtitle discontinuity domain does not match main")});}));}getExistingTrack(e,t){let{media:i}=this;if(i)for(let r=0;r<i.textTracks.length;r++){let n=i.textTracks[r];if(Og(n,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e);}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:i,media:r}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)i[e]=o,or(i[e]),Qp(i[e],r);else {let d=this.createTextTrack("captions",n,a);d&&(d[e]=true,i[e]=d);}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let i=t.label,r={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:false,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(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,t.mediaSource||this._cleanTracks();}onMediaDetaching(e,t){let i=!!t.transferMedia;if(this.media=null,i)return;let{captionsTracks:r}=this;Object.keys(r).forEach(n=>{or(r[n]),delete r[n];}),this.nonNativeCaptionsTracks={};}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Fg(),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++)or(t[i]);}onSubtitleTracksUpdated(e,t){let i=t.subtitleTracks||[],r=i.some(n=>n.textCodec===Tc);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(Up(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){let a=this.media,o=a?zo(a.textTracks):null;if(this.tracks.forEach((d,l)=>{let c;if(o){let u=null;for(let h=0;h<o.length;h++)if(o[h]&&Og(o[h],d)){u=o[h],o[h]=null;break}u&&(c=u);}if(c)or(c);else {let u=a0(d);c=this.createTextTrack(u,d.name,d.lang),c&&(c.mode="disabled");}c&&this.textTracks.push(c);}),o!=null&&o.length){let d=o.filter(l=>l!==null).map(l=>l.label);d.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${d.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`);}}else if(this.tracks.length){let a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(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===Y.MAIN){var i,r;let{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:d,sn:l}=t.frag,c=(i=(r=t.part)==null?void 0:r.index)!=null?i:-1;n&&a&&(l!==o+1||l===o&&c!==this.lastPartIndex+1||d!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=d,this.lastSn=l,this.lastPartIndex=c;}}onFragLoaded(e,t){let{frag:i,payload:r}=t;if(i.type===Y.SUBTITLE)if(r.byteLength){let n=i.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[i.level],d=this.vttCCs;d[i.cc]||(d[i.cc]={start:i.start,prevCC:this.prevCC,new:true},this.prevCC=i.cc),o&&o.textCodec===Tc?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;Mg(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),i.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:true,frag:e});},r=>{i.logger.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 d=this.hls,l=(t=i.initSegment)!=null&&t.data?Dt(i.initSegment.data,new Uint8Array(r)).buffer:r;tA(l,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,c=>{this._appendCues(c,i.level),d.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:true,frag:i});},c=>{let u=c.message==="Missing initPTS for VTT MPEGTS";u?a.push(e):this._fallbackToIMSC1(i,r),d.logger.log(`Failed to parse VTT cue: ${c}`),!(u&&o>i.cc)&&d.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:false,frag:i,error:c});});}_fallbackToIMSC1(e,t){let i=this.tracks[e.level];i.textCodec||Mg(t,this.initPTS[e.cc],()=>{i.textCodec=Tc,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=>Xp(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===Y.SUBTITLE&&this.onFragLoaded(p.FRAG_LOADED,t);}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={};}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;let{frag:i,samples:r}=t;if(!(i.type===Y.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let n=0;n<r.length;n++){let a=r[n].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();let o=this.extractCea608Data(a);this.cea608Parser1.addData(r[n].pts,o[0]),this.cea608Parser2.addData(r[n].pts,o[1]);}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:r,type:n}){let{media:a}=this;if(!(!a||a.currentTime<i)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(d=>vu(o[d],t,i));}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(d=>vu(o[d],t,r));}}}extractCea608Data(e){let t=[[],[]],i=e[0]&31,r=2;for(let n=0;n<i;n++){let a=e[r++],o=127&e[r++],d=127&e[r++];if(o===0&&d===0)continue;if((4&a)!==0){let c=3&a;(c===0||c===1)&&(t[c].push(o),t[c].push(d));}}return t}};function a0(s){return s.characteristics&&/transcribes-spoken-dialog/gi.test(s.characteristics)&&/describes-music-and-sound/gi.test(s.characteristics)?"captions":"subtitles"}function Og(s,e){return !!s&&s.kind===a0(e)&&au(e,s)}function oA(s,e,t,i){return Math.min(e,i)-Math.max(s,t)}function Fg(){return {ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:true}}}var lA=/\s/,dA={newCue(s,e,t,i){let r=[],n,a,o,d,l,c=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(n=i.rows[h],o=true,d=0,l="",!n.isEmpty()){var u;for(let g=0;g<n.chars.length;g++)lA.test(n.chars[g].uchar)&&o?d++:(l+=n.chars[g].uchar,o=false);n.cueStartTime=e,e===t&&(t+=1e-4),d>=16?d--:d++;let f=i0(l.trim()),m=oh(e,t,f);s!=null&&(u=s.cues)!=null&&u.getCueById(m)||(a=new c(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(d*8/32)*10),r.push(a));}return s&&r.length&&(r.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),r.forEach(h=>Xp(s,h))),r}};function cA(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return false}var uA=/(\d+)-(\d+)\/(\d+)/,Sl=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||gA,this.controller=new self.AbortController,this.stats=new In;}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=hA(e,this.controller.signal),a=e.responseType==="arraybuffer",o=a?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&H(d)?d:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response));},t.timeout),(Pn(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(u=>{var h;this.response=this.loader=u;let f=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response));},l-(f-r.loading.start)),!u.ok){let{status:g,statusText:E}=u;throw new Ou(E||"fetch, bad network response",g,u)}r.loading.first=f,r.total=mA(u.headers)||r.total;let m=(h=this.callbacks)==null?void 0:h.onProgress;return m&&H(t.highWaterMark)?this.loadProgressively(u,r,e,t.highWaterMark,m):a?u.arrayBuffer():e.responseType==="json"?u.json():u.text()}).then(u=>{var h,f;let m=this.response;if(!m)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);let g=u[o];g&&(r.loaded=r.total=g);let E={url:m.url,data:u,code:m.status},v=(h=this.callbacks)==null?void 0:h.onProgress;v&&!H(t.highWaterMark)&&v(r,e,u,m),(f=this.callbacks)==null||f.onSuccess(E,r,e,m);}).catch(u=>{var h;if(self.clearTimeout(this.requestTimeout),r.aborted)return;let f=u&&u.code||0,m=u?u.message:null;(h=this.callbacks)==null||h.onError({code:f,text:m},e,u?u.details:null,r);});}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null;}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,r=0,n){let a=new cl,o=e.body.getReader(),d=()=>o.read().then(l=>{if(l.done)return a.dataLength&&n(t,i,a.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));let c=l.value,u=c.length;return t.loaded+=u,u<r||a.dataLength?(a.push(c),a.dataLength>=r&&n(t,i,a.flush().buffer,e)):n(t,i,c.buffer,e),d()}).catch(()=>Promise.reject());return d()}};function hA(s,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Se({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function fA(s){let e=uA.exec(s);if(e)return parseInt(e[2])-parseInt(e[1])+1}function mA(s){let e=s.get("Content-Range");if(e){let i=fA(e);if(H(i))return i}let t=s.get("Content-Length");if(t)return parseInt(t)}function gA(s,e){return new self.Request(s.url,e)}var Ou=class extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i;}},pA=/^age:\s*[\d.]+\s*$/im,bl=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 In,this.retryDelay=0;}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null;}abortInternal(){let e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=true,e.abort()));}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader);}load(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal();}loadInternal(){let{config:e,context:t}=this;if(!e||!t)return;let i=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=false;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==i||this.stats.aborted))return n(i,t.url)}).catch(a=>{if(!(this.loader!==i||this.stats.aborted))return i.open("GET",t.url,true),n(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e);}).catch(a=>{var o;(o=this.callbacks)==null||o.onError({code:i.status,text:a.message},t,i,r);}):this.openAndSendXhr(i,t,e);}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,true);let r=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=i.loadPolicy;if(r)for(let o in r)e.setRequestHeader(o,r[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=n&&H(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send();}readystatechange(){let{context:e,loader:t,stats:i}=this;if(!e||!t)return;let r=t.readyState,n=this.config;if(!i.aborted&&r>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let l=t.status,c=t.responseType==="text"?t.responseText:null;if(l>=200&&l<300){let m=c??t.response;if(m!=null){var a,o;i.loading.end=Math.max(self.performance.now(),i.loading.first);let g=t.responseType==="arraybuffer"?m.byteLength:m.length;i.loaded=i.total=g,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);let E=(a=this.callbacks)==null?void 0:a.onProgress;E&&E(i,e,m,t);let v={url:t.responseURL,data:m,code:l};(o=this.callbacks)==null||o.onSuccess(v,i,e,t);return}}let u=n.loadPolicy.errorRetry,h=i.retry,f={url:e.url,data:void 0,code:l};if(rl(u,h,false,f))this.retry(u);else {var d;ye.error(`${l} while loading ${e.url}`),(d=this.callbacks)==null||d.onError({code:l,text:t.statusText},e,t,i);}}}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(rl(e,t,true))this.retry(e);else {var i;ye.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=zu(e,i.retry),i.retry++,ye.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&&pA.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}},EA={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},vA=Te(Te({autoStartLoad:true,startPosition:-1,defaultAudioCodec:void 0,debug:false,capLevelOnFPSDrop:false,capLevelToPlayerSize:false,ignoreDevicePixelRatio:false,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:true,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:false,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:true,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:false,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:true,workerPath:null,enableSoftwareAES:true,startLevel:void 0,startFragPrefetch:false,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:false,loader:bl,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Mc,bufferController:cu,capLevelController:uu,errorController:Pc,fpsController:Eu,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:cp,requireKeySystemAccessOnStart:false,testBandwidth:true,progressive:false,lowLatencyMode:true,cmcd:void 0,enableDateRangeMetadataCues:true,enableEmsgMetadataCues:true,enableEmsgKLVMetadata:false,enableID3MetadataCues:true,enableInterstitialPlayback:true,interstitialAppendInPlace:true,interstitialLiveLookAhead:10,useMediaCapabilities:true,preserveManualLevelOnError:false,certLoadPolicy:{default:EA},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},TA()),{},{subtitleStreamController:Iu,subtitleTrackController:Tu,timelineController:Pu,audioStreamController:nu,audioTrackController:ou,emeController:pl,cmcdController:gu,contentSteeringController:pu,interstitialsController:_u});function TA(){return {cueHandler:dA,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 yA(s,e,t){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let i=Fu(s),r=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(a=>{let o=`${a==="level"?"playlist":a}LoadPolicy`,d=e[o]===void 0,l=[];n.forEach(c=>{let u=`${a}Loading${c}`,h=e[u];if(h!==void 0&&d){l.push(u);let f=i[o].default;switch(e[o]={default:f},c){case "TimeOut":f.maxLoadTimeMs=h,f.maxTimeToFirstByteMs=h;break;case "MaxRetry":f.errorRetry.maxNumRetry=h,f.timeoutRetry.maxNumRetry=h;break;case "RetryDelay":f.errorRetry.retryDelayMs=h,f.timeoutRetry.retryDelayMs=h;break;case "MaxRetryTimeout":f.errorRetry.maxRetryDelayMs=h,f.timeoutRetry.maxRetryDelayMs=h;break}}}),l.length&&t.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${o}": ${Ae(e[o])}`);}),Te(Te({},i),e)}function Fu(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(Fu):Object.keys(s).reduce((e,t)=>(e[t]=Fu(s[t]),e),{}):s}function SA(s,e){let t=s.loader;t!==Sl&&t!==bl?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=false):cA()&&(s.loader=Sl,s.progressive=true,s.enableSoftwareAES=true,e.log("[config]: Progressive streaming enabled, using FetchLoader"));}var Qo=2,bA=.1,AA=.05,_A=100,Nu=class extends nl{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=false,this.stalled=null,this.moved=false,this.seeking=false,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0;},this.onMediaWaiting=()=>{var i;(i=this.media)!=null&&i.seeking||(this.waiting=self.performance.now(),this.tick());},this.onMediaEnded=()=>{if(this.hls){var i;this.ended=((i=this.media)==null?void 0:i.currentTime)||1,this.hls.trigger(p.MEDIA_ENDED,{stalled:false});}},this.hls=e,this.fragmentTracker=t,this.registerListeners();}registerListeners(){let{hls:e}=this;e&&(e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.BUFFER_APPENDED,this.onBufferAppended,this));}unregisterListeners(){let{hls:e}=this;e&&(e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.BUFFER_APPENDED,this.onBufferAppended,this));}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0;}onMediaAttached(e,t){this.setInterval(_A),this.mediaSource=t.mediaSource;let i=this.media=t.media;at(i,"playing",this.onMediaPlaying),at(i,"waiting",this.onMediaWaiting),at(i,"ended",this.onMediaEnded);}onMediaDetaching(e,t){this.clearInterval();let{media:i}=this;i&&(ut(i,"playing",this.onMediaPlaying),ut(i,"waiting",this.onMediaWaiting),ut(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0;}onBufferAppended(e,t){this.buffered=t.timeRanges;}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;let t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t;}poll(e,t){var i,r;let n=(i=this.hls)==null?void 0:i.config;if(!n)return;let a=this.media;if(!a)return;let{seeking:o}=a,d=this.seeking&&!o,l=!this.seeking&&o,c=a.paused&&!o||a.ended||a.playbackRate===0;if(this.seeking=o,e!==t){t&&(this.ended=0),this.moved=true,o||(this.nudgeRetry=0,n.nudgeOnVideoHole&&!c&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(l||d){d&&this.stallResolved(e);return}if(c){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&a.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(p.MEDIA_ENDED,{stalled:false}));return}if(!ne.getBuffered(a).length){this.nudgeRetry=0;return}let u=ne.bufferInfo(a,e,0),h=u.nextStart||0,f=this.fragmentTracker;if(o&&f&&this.hls){let D=Ng(this.hls.inFlightFragments,e),I=u.len>Qo,k=!h||D||h-e>Qo&&!f.getPartialFragment(e);if(I||k)return;this.moved=false;}let m=(r=this.hls)==null?void 0:r.latestLevelDetails;if(!this.moved&&this.stalled!==null&&f){if(!(u.len>0)&&!h)return;let I=Math.max(h,u.start||0)-e,R=!!(m!=null&&m.live)?m.targetduration*2:Qo,L=Ho(e,f);if(I>0&&(I<=R||L)){a.paused||this._trySkipBufferHole(L);return}}let g=n.detectStallWithCurrentTimeMs,E=self.performance.now(),v=this.waiting,T=this.stalled;if(T===null)if(v>0&&E-v<g)T=this.stalled=v;else {this.stalled=E;return}let S=E-T;if(!o&&(S>=g||v)&&this.hls){var b;if(((b=this.mediaSource)==null?void 0:b.readyState)==="ended"&&!(m!=null&&m.live)&&Math.abs(e-(m?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(p.MEDIA_ENDED,{stalled:true});return}if(this._reportStall(u),!this.media||!this.hls)return}let _=ne.bufferInfo(a,e,n.maxBufferHole);this._tryFixBufferStall(_,S,e);}stallResolved(e){let t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){let i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=false,this.waiting=0,this.hls.trigger(p.STALL_RESOLVED,{});}}nudgeOnVideoHole(e,t){var i;let r=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(i=this.buffered.audio)!=null&&i.length&&r&&r.length>1&&e>r.end(0)){let n=ne.bufferedInfo(ne.timeRangesToArray(this.buffered.audio),e,0);if(n.len>1&&t>=n.start){let a=ne.timeRangesToArray(r),o=ne.bufferedInfo(a,t,0).bufferedIndex;if(o>-1&&o<a.length-1){let d=ne.bufferedInfo(a,e,0).bufferedIndex,l=a[o].end,c=a[o+1].start;if((d===-1||d>o)&&c-l<1&&e-l<2){let u=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${l} -> ${c} buffered index: ${d}`);this.warn(u.message),this.media.currentTime+=1e-6;let h=Ho(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);let f=ne.bufferInfo(this.media,e,0);this.hls.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_SEEK_OVER_HOLE,fatal:false,error:u,reason:u.message,frag:h,buffer:f.len,bufferInfo:f});}}}}}_tryFixBufferStall(e,t,i){var r,n;let{fragmentTracker:a,media:o}=this,d=(r=this.hls)==null?void 0:r.config;if(!o||!a||!d)return;let l=(n=this.hls)==null?void 0:n.latestLevelDetails,c=Ho(i,a);if((c||l!=null&&l.live&&i<l.fragmentStart)&&(this._trySkipBufferHole(c)||!this.media))return;let u=e.buffered,h=this.adjacentTraversal(e,i);(u&&u.length>1&&e.len>d.maxBufferHole||e.nextStart&&(e.nextStart-i<d.maxBufferHole||h))&&(t>d.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e));}adjacentTraversal(e,t){let i=this.fragmentTracker,r=e.nextStart;if(i&&r){let n=i.getFragAtPos(t,Y.MAIN),a=i.getFragAtPos(r,Y.MAIN);if(n&&a)return a.sn-n.sn<2}return false}_reportStall(e){let{hls:t,media:i,stallReported:r,stalled:n}=this;if(!r&&n!==null&&i&&t){this.stallReported=true;let a=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${Ae(e)})`);this.warn(a.message),t.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_STALLED_ERROR,fatal:false,error:a,buffer:e.len,bufferInfo:e,stalled:{start:n}});}}_trySkipBufferHole(e){var t;let{fragmentTracker:i,media:r}=this,n=(t=this.hls)==null?void 0:t.config;if(!r||!i||!n)return 0;let a=r.currentTime,o=ne.bufferInfo(r,a,0),d=a<o.start?o.start:o.nextStart;if(d&&this.hls){let c=o.len<=n.maxBufferHole,u=o.len>0&&o.len<1&&r.readyState<3,h=d-a;if(h>0&&(c||u)){if(h>n.maxBufferHole){let m=false;if(a===0){let g=i.getAppendedFrag(0,Y.MAIN);g&&d<g.end&&(m=true);}if(!m&&e){var l;if(!((l=this.hls.loadLevelObj)!=null&&l.details)||Ng(this.hls.inFlightFragments,d))return 0;let E=false,v=e.end;for(;v<d;){let T=Ho(v,i);if(T)v+=T.duration;else {E=true;break}}if(E)return 0}}let f=Math.max(d+AA,a+bA);if(this.warn(`skipping hole, adjusting currentTime from ${a} to ${f}`),this.moved=true,r.currentTime=f,!(e!=null&&e.gap)){let m=new Error(`fragment loaded with buffer holes, seeking from ${a} to ${f}`),g={type:Q.MEDIA_ERROR,details:x.BUFFER_SEEK_OVER_HOLE,fatal:false,error:m,reason:m.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?g.part=e:g.frag=e),this.hls.trigger(p.ERROR,g);}return f}}return 0}_tryNudgeBuffer(e){let{hls:t,media:i,nudgeRetry:r}=this,n=t?.config;if(!i||!n)return 0;let a=i.currentTime;if(this.nudgeRetry++,r<n.nudgeMaxRetry){let o=a+(r+1)*n.nudgeOffset,d=new Error(`Nudging 'currentTime' from ${a} to ${o}`);this.warn(d.message),i.currentTime=o,t.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_NUDGE_ON_STALL,error:d,fatal:false,buffer:e.len,bufferInfo:e});}else {let o=new Error(`Playhead still not moving while enough data buffered @${a} after ${n.nudgeMaxRetry} nudges`);this.error(o.message),t.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_STALLED_ERROR,error:o,fatal:true,buffer:e.len,bufferInfo:e});}}};function Ng(s,e){let t=Ug(s.main);if(t&&t.start<=e)return t;let i=Ug(s.audio);return i&&i.start<=e?i:null}function Ug(s){if(!s)return null;switch(s.state){case M.IDLE:case M.STOPPED:case M.ENDED:case M.ERROR:return null}return s.frag}function Ho(s,e){return e.getAppendedFrag(s,Y.MAIN)||e.getPartialFragment(s)}var IA=.25;function Uu(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Ac(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,Ae(r?Te({type:r},i):i));}return n}var Ko=(()=>{let s=Uu();try{s&&new s(0,Number.POSITIVE_INFINITY,"");}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})(),$u=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=true,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(p.EVENT_CUE_ENTER,{});},this.hls=e,this._registerListeners();}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null;}_registerListeners(){let{hls:e}=this;e&&(e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,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),e.on(p.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this));}_unregisterListeners(){let{hls:e}=this;e&&(e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,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),e.off(p.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this));}onMediaAttaching(e,t){var i;this.media=t.media,((i=t.overrides)==null?void 0:i.cueRemoval)===false&&(this.removeCues=false);}onMediaAttached(){var e;let t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t);}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.removeCues&&or(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={});}onManifestLoading(){this.dateRangeCuesAppended={};}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let i=e[t];if(i.kind==="metadata"&&i.label==="id3")return Qp(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;let{enableEmsgMetadataCues:i,enableID3MetadataCues:r}=this.hls.config;if(!i&&!r)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=Uu();if(a)for(let o=0;o<n.length;o++){let d=n[o].type;if(d===bt.emsg&&!i||!r)continue;let l=xp(n[o].data),c=n[o].pts,u=c+n[o].duration;u>Ko&&(u=Ko),u-c<=0&&(u=c+IA);for(let f=0;f<l.length;f++){let m=l[f];if(!Rp(m)){this.updateId3CueEnds(c,d);let g=Ac(a,c,u,m,d);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===Ko&&(a.endTime=e);}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:r}){let{id3Track:n,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:d}}=a;if(n&&(o||d)){let l;r==="audio"?l=c=>c.type===bt.audioId3&&d:r==="video"?l=c=>c.type===bt.emsg&&o:l=c=>c.type===bt.audioId3&&d||c.type===bt.emsg&&o,vu(n,t,i,l);}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,true);}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details);}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;let{assetPlayerId:i,timelineOffset:r,enableDateRangeMetadataCues:n,interstitialsController:a}=this.hls.config;if(!n)return;let o=Uu();if(i&&r&&!a){let{fragmentStart:g,fragmentEnd:E}=e,v=this.assetCue;v?(v.startTime=g,v.endTime=E):o&&(v=this.assetCue=Ac(o,g,E,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),v&&(v.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(v),v.addEventListener("enter",this.onEventCueEnter)));}if(!e.hasProgramDateTime)return;let{id3Track:d}=this,{dateRanges:l}=e,c=Object.keys(l),u=this.dateRangeCuesAppended;if(d&&t){var h;if((h=d.cues)!=null&&h.length){let g=Object.keys(u).filter(E=>!c.includes(E));for(let E=g.length;E--;){var f;let v=g[E],T=(f=u[v])==null?void 0:f.cues;delete u[v],T&&Object.keys(T).forEach(S=>{let b=T[S];if(b){b.removeEventListener("enter",this.onEventCueEnter);try{d.removeCue(b);}catch{}}});}}else u=this.dateRangeCuesAppended={};}let m=e.fragments[e.fragments.length-1];if(!(c.length===0||!H(m?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let g=0;g<c.length;g++){let E=c[g],v=l[E],T=v.startTime,S=u[E],b=S?.cues||{},_=S?.durationKnown||false,D=Ko,{duration:I,endDate:k}=v;if(k&&I!==null)D=T+I,_=true;else if(v.endOnNext&&!_){let L=c.reduce((w,B)=>{if(B!==v.id){let K=l[B];if(K.class===v.class&&K.startDate>v.startDate&&(!w||v.startDate<w.startDate))return K}return w},null);L&&(D=L.startTime,_=true);}let R=Object.keys(v.attr);for(let L=0;L<R.length;L++){let w=R[L];if(!Dy(w))continue;let B=b[w];if(B)_&&!(S!=null&&S.durationKnown)?B.endTime=D:Math.abs(B.startTime-T)>.01&&(B.startTime=T,B.endTime=D);else if(o){let K=v.attr[w];Cy(w)&&(K=Hg(K));let V=Ac(o,T,D,{key:w,data:K},bt.dateRange);V&&(V.id=E,this.id3Track.addCue(V),b[w]=V,a&&(w==="X-ASSET-LIST"||w==="X-ASSET-URL")&&V.addEventListener("enter",this.onEventCueEnter));}}u[E]={cues:b,dateRange:v,durationKnown:_};}}}},Bu=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=false,this.onTimeupdate=()=>{let{media:t}=this,i=this.levelDetails;if(!t||!i)return;this.currentTime=t.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:n,maxLiveSyncPlaybackRate:a}=this.config;if(!n||a===1||!i.live)return;let o=this.targetLatency;if(o===null)return;let d=r-o,l=Math.min(this.maxLatency,o+i.targetduration);if(d<l&&d>.05&&this.forwardBufferLength>1){let u=Math.min(2,Math.max(1,a)),h=Math.round(2/(1+Math.exp(-0.75*d-this.edgeStalled))*20)/20,f=Math.min(u,Math.max(1,h));this.changeMediaPlaybackRate(t,f);}else t.playbackRate!==1&&t.playbackRate!==0&&this.changeMediaPlaybackRate(t,1);},this.hls=e,this.config=e.config,this.registerListeners();}get levelDetails(){var e;return ((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){let{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;let t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let e=this.levelDetails;if(e===null||this.hls===null)return null;let{holdBack:t,partHoldBack:i,targetduration:r}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,d=this.hls.userConfig,l=o&&i||t;(this._targetLatencyUpdated||d.liveSyncDuration||d.liveSyncDurationCount||l===0)&&(l=n!==void 0?n:a*r);let c=r;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=true;}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;let i=this.levelDetails;if(i===null)return null;let r=i.edge,n=e-t-this.edgeStalled,a=r-i.totalduration,o=r-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){let e=this.levelDetails;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;let i=e.buffered.length;return (i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null;}registerListeners(){let{hls:e}=this;e&&(e.on(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_UPDATED,this.onLevelUpdated,this),e.on(p.ERROR,this.onError,this));}unregisterListeners(){let{hls:e}=this;e&&(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_UPDATED,this.onLevelUpdated,this),e.off(p.ERROR,this.onError,this));}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate);}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null);}onManifestLoading(){this._latency=null,this.stallCount=0;}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate);}onError(e,t){var i;t.details===x.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(i=this.levelDetails)!=null&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"));}changeMediaPlaybackRate(e,t){var i,r;e.playbackRate!==t&&((i=this.hls)==null||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(r=this.targetLatency)==null?void 0:r.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t);}estimateLiveEdge(){let e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},Gu=class extends On{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,d=false,l=false;t.levels.forEach(c=>{let u=c.attrs,{audioCodec:h,videoCodec:f}=c;h&&(c.audioCodec=h=Jo(h,i)||void 0),f&&(f=c.videoCodec=ey(f));let{width:m,height:g,unknownCodecs:E}=c,v=E?.length||0;if(o||(o=!!(m&&g)),d||(d=!!f),l||(l=!!h),v||h&&!this.isAudioSupported(h)||f&&!this.isVideoSupported(f)){this.log(`Some or all CODECS not supported "${u.CODECS}"`);return}let{CODECS:T,"FRAME-RATE":S,"HDCP-LEVEL":b,"PATHWAY-ID":_,RESOLUTION:D,"VIDEO-RANGE":I}=u,R=`${`${_||"."}-`}${c.bitrate}-${D}-${S}-${T}-${I}-${b}`;if(n[R])if(n[R].uri!==c.url&&!c.attrs["PATHWAY-ID"]){let L=a[R]+=1;c.attrs["PATHWAY-ID"]=new Array(L+1).join(".");let w=this.createLevel(c);n[R]=w,r.push(w);}else n[R].addGroupId("audio",u.AUDIO),n[R].addGroupId("text",u.SUBTITLES);else {let L=this.createLevel(c);n[R]=L,a[R]=1,r.push(L);}}),this.filterAndSortMediaOptions(r,t,o,d,l);}createLevel(e){let t=new fs(e),i=e.supplemental;if(i!=null&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){let r=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(r.message),t.supportedResult=Jg(r,[]);}return t}isAudioSupported(e){return Ln(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Ln(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,r,n){var a;let o=[],d=[],l=e,c=((a=t.stats)==null?void 0:a.parsing)||{};if((i||r)&&n&&(l=l.filter(({videoCodec:T,videoRange:S,width:b,height:_})=>(!!T||!!(b&&_))&&cy(S))),l.length===0){Promise.resolve().then(()=>{if(this.hls){let T="no level with compatible codecs found in manifest",S=T;t.levels.length&&(S=`one or more CODECS in variant not supported: ${Ae(t.levels.map(_=>_.attrs.CODECS).filter((_,D,I)=>I.indexOf(_)===D))}`,this.warn(S),T+=` (${S})`);let b=new Error(T);this.hls.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:true,url:t.url,error:b,reason:S});}}),c.end=performance.now();return}t.audioTracks&&(o=t.audioTracks.filter(T=>!T.audioCodec||this.isAudioSupported(T.audioCodec)),$g(o)),t.subtitles&&(d=t.subtitles,$g(d));let u=l.slice(0);l.sort((T,S)=>{if(T.attrs["HDCP-LEVEL"]!==S.attrs["HDCP-LEVEL"])return (T.attrs["HDCP-LEVEL"]||"")>(S.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&T.height!==S.height)return T.height-S.height;if(T.frameRate!==S.frameRate)return T.frameRate-S.frameRate;if(T.videoRange!==S.videoRange)return el.indexOf(T.videoRange)-el.indexOf(S.videoRange);if(T.videoCodec!==S.videoCodec){let b=Om(T.videoCodec),_=Om(S.videoCodec);if(b!==_)return _-b}if(T.uri===S.uri&&T.codecSet!==S.codecSet){let b=Zo(T.codecSet),_=Zo(S.codecSet);if(b!==_)return _-b}return T.averageBitrate!==S.averageBitrate?T.averageBitrate-S.averageBitrate:0});let h=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==u.length)){for(let T=0;T<u.length;T++)if(u[T].pathwayId===l[0].pathwayId){h=u[T];break}}this._levels=l;for(let T=0;T<l.length;T++)if(l[T]===h){var f;this._firstLevel=T;let S=h.bitrate,b=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${S}`),((f=this.hls.userConfig)==null?void 0:f.abrEwmaDefaultEstimate)===void 0){let _=Math.min(S,this.hls.config.abrEwmaDefaultEstimateMax);_>b&&b===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=_);}break}let m=n&&!r,g=this.hls.config,E=!!(g.audioStreamController&&g.audioTrackController),v={levels:l,audioTracks:o,subtitleTracks:d,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:r,altAudio:E&&!m&&o.some(T=>!!T.url)};c.end=performance.now(),this.hls.trigger(p.MANIFEST_PARSED,v);}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let c=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(p.ERROR,{type:Q.OTHER_ERROR,details:x.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:c,reason:c.message}),u)return;e=Math.min(e,t.length-1);}let i=this.currentLevelIndex,r=this.currentLevel,n=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&r&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${i}${n?" with Pathway "+n:""}`);let d={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(p.LEVEL_SWITCHING,d);let l=a.details;if(!l||l.live){let c=this.switchParams(a.uri,r?.details,l);this.loadPlaylist(c);}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e);}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e;}get startLevel(){if(this._startLevel===void 0){let e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e;}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){let t=this.steering.pathways(),i=e.filter(r=>t.indexOf(r)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);return}this.steering.pathwayPriority=i;}}onError(e,t){t.fatal||!t.context||t.context.type===ue.LEVEL&&t.context.level===this.level&&this.checkRetry(t);}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===Y.MAIN){let i=t.elementaryStreams;if(!Object.keys(i).some(n=>!!i[n]))return;let r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0);}}onLevelLoaded(e,t){var i;let{level:r,details:n}=t,a=t.levelInfo;if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=true);return}if(a===this.currentLevel||t.withoutMultiVariant){a.fragmentError===0&&(a.loadError=0);let d=a.details;d===t.details&&d.advanced&&(d=void 0),this.playlistLoaded(r,t,d);}else (i=t.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=true);}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e);}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=this.getUrlWithDirectives(e.uri,t),r=this.currentLevelIndex,n=e.attrs["PATHWAY-ID"],a=e.details,o=a?.age;this.log(`Loading level index ${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${n?" Pathway "+n:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${i}`),this.hls.trigger(p.LEVEL_LOADING,{url:i,level:r,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null});}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e);}removeLevel(e){var t;if(this._levels.length===1)return;let i=this._levels.filter((n,a)=>a!==e?true:(this.steering&&this.steering.removeLevel(n),n===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,n.details&&n.details.fragments.forEach(o=>o.level=-1)),false));vp(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);let r=i.length-1;this._firstLevel=Math.min(this._firstLevel,r),this._startLevel&&(this._startLevel=Math.min(this._startLevel,r)),this.hls.trigger(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 $g(s){let e={};s.forEach(t=>{let i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++;});}function o0(){return self.SourceBuffer||self.WebKitSourceBuffer}function l0(){if(!$i())return false;let e=o0();return !e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function LA(){if(!l0())return false;let s=$i();return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>s.isTypeSupported(xn(e,"video")))||["mp4a.40.2","fLaC"].some(e=>s.isTypeSupported(xn(e,"audio"))))}function xA(){var s;let e=o0();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}var RA=100,Hu=class extends Dn{constructor(e,t,i){super(e,t,i,"stream-controller",Y.MAIN),this.audioCodecSwap=false,this.level=-1,this._forceStartLoad=false,this._hasEnoughToStart=false,this.altAudio=0,this.audioOnly=false,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=false,this.backtrackFragment=null,this.audioCodecSwitch=false,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick();},this.onMediaSeeked=()=>{let r=this.media,n=r?r.currentTime:null;if(n===null||!H(n)||(this.log(`Media seeked to ${n.toFixed(3)}`),!this.getBufferedFrag(n)))return;let a=this.getFwdBufferInfoAtPos(r,n,Y.MAIN,0);if(a===null||a.len===0){this.warn(`Main forward buffer length at ${n} on "seeked" event ${a?a.len:"empty"})`);return}this.tick();},this.registerListeners();}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(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.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(){super.unregisterListeners();let{hls:e}=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.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.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying();}startLoad(e,t){if(this.levels){let{lastCurrentTime:i,hls:r}=this;if(this.stopLoad(),this.setInterval(RA),this.level=-1,!this.startFragRequested){let n=r.startLevel;n===-1&&(r.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=true):n=r.firstAutoLevel),r.nextLoadLevel=n,this.level=r.loadLevel,this._hasEnoughToStart=!!t;}i>0&&e===-1&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=M.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick();}else this._forceStartLoad=true,this.state=M.STOPPED;}stopLoad(){this._forceStartLoad=false,super.stopLoad();}doTick(){switch(this.state){case M.WAITING_LEVEL:{let{levels:e,level:t}=this,i=e?.[t],r=i?.details;if(r&&(!r.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(r))break;this.state=M.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=M.IDLE;break}break}case M.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===M.IDLE&&this.doTickIdle(),this.onTickEnd();}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===false&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged();}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:i,media:r}=this;if(t===null||!r&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;let n=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(i!=null&&i[n]))return;let a=i[n],o=this.getMainFwdBufferInfo();if(o===null)return;let d=this.getLevelDetails();if(d&&this._streamEnded(o,d)){let g={};this.altAudio===2&&(g.type="video"),this.hls.trigger(p.BUFFER_EOS,g),this.state=M.ENDED;return}if(!this.buffering)return;e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;let l=a.details;if(!l||this.state===M.WAITING_LEVEL||this.waitForLive(a)){this.level=n,this.state=M.WAITING_LEVEL,this.startFragRequested=false;return}let c=o.len,u=this.getMaxBufferLength(a.maxBitrate);if(c>=u)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);let h=this.backtrackFragment?this.backtrackFragment.start:o.end,f=this.getNextFragment(h,l);if(this.couldBacktrack&&!this.fragPrevious&&f&&Fe(f)&&this.fragmentTracker.getState(f)!==We.OK){var m;let E=((m=this.backtrackFragment)!=null?m:f).sn-l.startSN,v=l.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,h)){if(!f.gap){let E=this.audioOnly&&!this.altAudio?be.AUDIO:be.VIDEO,v=(E===be.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,E,Y.MAIN);}f=this.getNextFragmentLoopLoading(f,l,o,Y.MAIN,u);}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h));}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);r===We.NOT_LOADED||r===We.PARTIAL?Fe(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,i):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e);}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,Y.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY);}nextLevelSwitch(){let{levels:e,media:t}=this;if(t!=null&&t.readyState){let i,r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);let n=this.getLevelDetails();if(n!=null&&n.live){let o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){let o=this.hls.nextLoadLevel,d=e[o],l=this.fragLastKbps;l&&this.fragCurrent?i=this.fragCurrent.duration*d.maxBitrate/(1e3*l)+1:i=0;}else i=0;let a=this.getBufferedFrag(t.currentTime+i);if(a){let o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();let d=o.maxStartPTS?o.maxStartPTS:o.start,l=o.duration,c=Math.max(a.end,d+Math.min(Math.max(l-this.config.maxFragLookUpTolerance,l*(this.couldBacktrack?.5:.125)),l*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY);}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case M.KEY_LOADING:case M.FRAG_LOADING:case M.FRAG_LOADING_WAITING_RETRY:case M.PARSING:case M.PARSED:this.state=M.IDLE;break}this.nextLoadPosition=this.getLoadPosition();}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio===2?"video":null);}onMediaAttached(e,t){super.onMediaAttached(e,t);let i=t.media;at(i,"playing",this.onMediaPlaying),at(i,"seeked",this.onMediaSeeked);}onMediaDetaching(e,t){let{media:i}=this;i&&(ut(i,"playing",this.onMediaPlaying),ut(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=false);}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.BUFFER_RESET,void 0),this.couldBacktrack=false,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=false;}onManifestParsed(e,t){let i=false,r=false;for(let n=0;n<t.levels.length;n++){let a=t.levels[n].audioCodec;a&&(i=i||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1);}this.audioCodecSwitch=i&&r&&!xA(),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!==M.IDLE)return;let r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=M.WAITING_LEVEL);}onLevelLoaded(e,t){var i;let{levels:r,startFragRequested:n}=this,a=t.level,o=t.details,d=o.totalduration;if(!r){this.warn(`Levels were reset while loading level ${a}`);return}this.log(`Level ${a} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${d}`);let l=t.levelInfo,c=this.fragCurrent;c&&(this.state===M.FRAG_LOADING||this.state===M.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let u=0;if(o.live||(i=l.details)!=null&&i.live){var h;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;u=this.alignPlaylists(o,l.details,(h=this.levelLastLoaded)==null?void 0:h.details);}if(l.details=o,this.levelLastLoaded=l,n||this.setStartPosition(o,u),this.hls.trigger(p.LEVEL_UPDATED,{details:o,level:a}),this.state===M.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=M.IDLE;}n&&o.live&&this.synchronizeToLiveEdge(o),this.tick();}synchronizeToLiveEdge(e){let{config:t,media:i}=this;if(!i)return;let r=this.hls.liveSyncPosition,n=this.getLoadPosition(),a=e.fragmentStart,o=e.edge,d=n>=a-t.maxFragLookUpTolerance&&n<=o;if(r!==null&&i.duration>r&&(n<r||!d)){let c=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!d&&i.readyState<4||n<o-c)&&(this._hasEnoughToStart||(this.nextLoadPosition=r),i.readyState))if(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${r.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var l;let u=ne.bufferInfo(i,r,0);if(!((l=u.buffered)!=null&&l.length)){i.currentTime=r;return}if(u.start<=n){i.currentTime=r;return}let{nextStart:f}=ne.bufferedInfo(u.buffered,n,0);f&&(i.currentTime=f);}else i.currentTime=r;}}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:r,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}let o=a[i.level];if(!o){this.warn(`Level ${i.level} not found on progress`);return}let d=o.details;if(!d){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}let l=o.videoCodec,c=d.PTSKnown||!d.live,u=(t=i.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new ml(this.hls,Y.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=r?r.index:-1,g=m!==-1,E=new kn(i.level,i.sn,i.stats.chunkCount,n.byteLength,m,g),v=this.initPTS[i.cc];f.push(n,u,h,l,i,r,d.totalduration,c,E,v);}onAudioTrackSwitching(e,t){let i=this.hls,r=this.altAudio!==0;if(il(t.url,i))this.altAudio=1;else {if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState();}else this.audioOnly&&this.resetTransmuxer();if(r){this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(p.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(p.AUDIO_TRACK_SWITCHED,t);}),i.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(p.AUDIO_TRACK_SWITCHED,t);}}onAudioTrackSwitched(e,t){let i=il(t.url,this.hls);if(i){let r=this.videoBuffer;r&&this.mediaBuffer!==r&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=r);}this.altAudio=i?2:0,this.tick();}onBufferCreated(e,t){let i=t.tracks,r,n,a=false;for(let o in i){let d=i[o];if(d.id==="main"){if(n=o,r=d,o==="video"){let l=i[o];l&&(this.videoBuffer=l.buffer);}}else a=true;}a&&r?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media;}onFragBuffered(e,t){let{frag:i,part:r}=t,n=i.type===Y.MAIN;if(n){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===M.PARSED&&(this.state=M.IDLE);return}let o=r?r.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),Fe(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,r);}let a=this.media;a&&(!this._hasEnoughToStart&&ne.getBuffered(a).length&&(this._hasEnoughToStart=true,this.seekToStartPos()),n&&this.tick());}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=M.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(Y.MAIN,t);break;case x.LEVEL_LOAD_ERROR:case x.LEVEL_LOAD_TIMEOUT:case x.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===M.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===ue.LEVEL&&(this.state=M.IDLE);break;case x.BUFFER_ADD_CODEC_ERROR:case x.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case x.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=true:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case x.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=M.IDLE,this._hasEnoughToStart||(this.startFragRequested=false,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate();}onBufferFlushed(e,{type:t}){if(t!==be.AUDIO||!this.altAudio){let i=(t===be.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,Y.MAIN),this.tick());}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels;}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap;}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}let r=this.timelineOffset;r&&i&&(i+=r);let n=this.getLevelDetails(),a=ne.getBuffered(e),o=a.length?a.start(0):0,d=o-i,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||d>0&&(d<l||this.loadingParts&&d<2*(n?.partTarget||0)))&&(this.log(`adjusting start position by ${d} to match buffer start`),i+=d,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i);}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=true,this._doFragLoad(e,t).then(i=>{let{hls:r}=this,n=i?.frag;if(!n||this.fragContextChanged(n))return;t.fragmentError=0,this.state=M.IDLE,this.startFragRequested=false,this.bitrateTest=false;let a=n.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),r.trigger(p.FRAG_LOADED,i),n.bitrateTest=false;}).catch(i=>{this.state===M.STOPPED||this.state===M.ERROR||(this.warn(i),this.resetFragmentLoading(e));});}_handleTransmuxComplete(e){let t=this.playlistType,{hls:i}=this,{remuxResult:r,chunkMeta:n}=e,a=this.getCurrentContext(n);if(!a){this.resetWhenMissingContext(n);return}let{frag:o,part:d,level:l}=a,{video:c,text:u,id3:h,initSegment:f}=r,{details:m}=l,g=this.altAudio?void 0:r.audio;if(this.fragContextChanged(o)){this.fragmentTracker.removeFragment(o);return}if(this.state=M.PARSING,f){let E=f.tracks;if(E){let b=o.initSegment||o;if(this.unhandledEncryptionError(f,o))return;this._bufferInitSegment(l,E,b,n),i.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:t,tracks:E});}let v=f.initPTS,T=f.timescale,S=this.initPTS[o.cc];if(H(v)&&(!S||S.baseTime!==v||S.timescale!==T)){let b=f.trackId;this.initPTS[o.cc]={baseTime:v,timescale:T,trackId:b},i.trigger(p.INIT_PTS_FOUND,{frag:o,id:t,initPTS:v,timescale:T,trackId:b});}}if(c&&m){g&&c.type==="audiovideo"&&this.logMuxedErr(o);let E=m.fragments[o.sn-1-m.startSN],v=o.sn===m.startSN,T=!E||o.cc>E.cc;if(r.independent!==false){let{startPTS:S,endPTS:b,startDTS:_,endDTS:D}=c;if(d)d.elementaryStreams[c.type]={startPTS:S,endPTS:b,startDTS:_,endDTS:D};else if(c.firstKeyFrame&&c.independent&&n.id===1&&!T&&(this.couldBacktrack=true),c.dropped&&c.independent){let I=this.getMainFwdBufferInfo(),k=(I?I.end:this.getLoadPosition())+this.config.maxBufferHole,R=c.firstKeyFramePTS?c.firstKeyFramePTS:S;if(!v&&k<R-this.config.maxBufferHole&&!T){this.backtrack(o);return}else T&&(o.gap=true);o.setElementaryStreamInfo(c.type,o.start,b,o.start,D,true);}else v&&S-(m.appliedTimelineOffset||0)>Qo&&(o.gap=true);o.setElementaryStreamInfo(c.type,S,b,_,D),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(c,o,d,n,v||T);}else if(v||T)o.gap=true;else {this.backtrack(o);return}}if(g){let{startPTS:E,endPTS:v,startDTS:T,endDTS:S}=g;d&&(d.elementaryStreams[be.AUDIO]={startPTS:E,endPTS:v,startDTS:T,endDTS:S}),o.setElementaryStreamInfo(be.AUDIO,E,v,T,S),this.bufferFragmentData(g,o,d,n);}if(m&&h!=null&&h.samples.length){let E={id:t,frag:o,details:m,samples:h.samples};i.trigger(p.FRAG_PARSING_METADATA,E);}if(m&&u){let E={id:t,frag:o,details:m,samples:u.samples};i.trigger(p.FRAG_PARSING_USERDATA,E);}}logMuxedErr(e){this.warn(`${Fe(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`);}_bufferInitSegment(e,t,i,r){if(this.state!==M.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,c=Vo(n.codec,l);c==="mp4a"&&(c="mp4a.40.5");let u=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){c&&(c.indexOf("mp4a.40.5")!==-1?c="mp4a.40.2":c="mp4a.40.5");let h=n.metadata;h&&"channelCount"in h&&(h.channelCount||1)!==1&&u.indexOf("firefox")===-1&&(c="mp4a.40.5");}c&&c.indexOf("mp4a.40.5")!==-1&&u.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(c="mp4a.40.2",this.log(`Android: force audio codec to ${c}`)),l&&l!==c&&this.log(`Swapping manifest audio codec "${l}" for "${c}"`),n.levelCodec=c,n.id=Y.MAIN,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${c||""}/${l||""}/${n.codec}]`),delete t.audiovideo;}if(a){a.levelCodec=e.videoCodec,a.id=Y.MAIN;let l=a.codec;if(l?.length===4)switch(l){case "hvc1":case "hev1":a.codec="hvc1.1.6.L120.90";break;case "av01":a.codec="av01.0.04M.08";break;case "avc1":a.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${l}]${a.codec!==l?" parsed-corrected="+a.codec:""}${a.supplemental?" supplemental="+a.supplemental:""}`),delete t.audiovideo;}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);let d=Object.keys(t);if(d.length){if(this.hls.trigger(p.BUFFER_CODECS,t),!this.hls)return;d.forEach(l=>{let u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(p.BUFFER_APPENDING,{type:l,data:u,frag:i,part:null,chunkMeta:r,parent:i.type});});}this.tickImmediate();}getMainFwdBufferInfo(){let e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,Y.MAIN)}get maxBufferLength(){let{levels:e,level:t}=this,i=e?.[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=true,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=M.IDLE;}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===false){let i=e.currentTime;if(ne.isBuffered(e,i)?t=this.getAppendedFrag(i):ne.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;let r=this.fragPlaying,n=t.level;(!r||t.sn!==r.sn||r.level!==n)&&(this.fragPlaying=t,this.hls.trigger(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(){var e;if(this.fragPlaying)return this.fragPlaying;let t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return H(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;let t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(H(t)){let i=this.getLevelDetails(),r=this.currentFrag||(i?ms(null,i.fragments,t):null);if(r){let n=r.programDateTime;if(n!==null){let a=n+(t-r.start)*1e3;return new Date(a)}}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}},Ku=class extends ht{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e;}abort(e){for(let i in this.keyIdToKeyInfo){let r=this.keyIdToKeyInfo[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.keyIdToKeyInfo){let t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e];}}destroy(){this.detach();for(let e in this.keyIdToKeyInfo){let t=this.keyIdToKeyInfo[e].loader;t&&t.destroy();}this.keyIdToKeyInfo={};}createKeyLoadError(e,t=x.KEY_LOAD_ERROR,i,r,n){return new Kt({type:Q.NETWORK_ERROR,details:t,fatal:false,frag:e,response:n,error:i,networkDetails:r})}loadClear(e,t,i){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let r=0,n=t.length;r<n;r++){let a=t[r];if(e.cc<=a.cc&&(!Fe(e)||!Fe(a)||e.sn<a.sn)||!i&&r==n-1)return this.emeController.selectKeySystemFormat(a).then(o=>{if(!this.emeController)return;a.setKeyFormat(o);let d=Yo(o);if(d)return this.emeController.getKeySystemAccess([d])})}if(this.config.requireKeySystemAccessOnStart){let r=yn(this.config);if(r.length)return this.emeController.getKeySystemAccess(r)}}return null}load(e){return !e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,r;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let l=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,x.KEY_LOAD_ERROR,l))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,x.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=_c(n),d=this.keyIdToKeyInfo[o];if((i=d)!=null&&i.decryptdata.key)return n.key=d.decryptdata.key,Promise.resolve({frag:e,keyInfo:d});if(this.emeController&&(r=d)!=null&&r.keyLoadPromise)switch(this.emeController.getKeyStatus(d.decryptdata)){case "usable":case "usable-in-future":return d.keyLoadPromise.then(c=>{let{keyInfo:u}=c;return n.key=u.decryptdata.key,{frag:e,keyInfo:u}})}switch(this.log(`${this.keyIdToKeyInfo[o]?"Rel":"L"}oading${n.keyId?" keyId: "+Ze(n.keyId):""} URI: ${n.uri} from ${e.type} ${e.level}`),d=this.keyIdToKeyInfo[o]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case "SAMPLE-AES":case "SAMPLE-AES-CENC":case "SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(d,e):this.loadKeyEME(d,e);case "AES-128":case "AES-256":case "AES-256-CTR":return this.loadKeyHTTP(d,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){var r;if(!e.decryptdata.keyId&&(r=t.initSegment)!=null&&r.data){let a=HT(t.initSegment.data);if(a.length){let o=a[0];o.some(d=>d!==0)?(this.log(`Using keyId found in init segment ${Ze(o)}`),mr.setKeyIdForUri(e.decryptdata.uri,o)):(o=mr.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${Ze(o)}`)),e.decryptdata.keyId=o;}}if(!e.decryptdata.keyId&&!Fe(t))return Promise.resolve(i);let n=this.emeController.loadKey(i);return (e.keyLoadPromise=n.then(a=>(e.mediaKeySessionContext=a,i))).catch(a=>{throw e.keyLoadPromise=null,"data"in a&&(a.data.frag=t),a})}return Promise.resolve(i)}loadKeyHTTP(e,t){let i=this.config,r=i.loader,n=new r(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{let d={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=i.keyLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,g)=>{let{frag:E,keyInfo:v}=m,T=_c(v.decryptdata);if(!E.decryptdata||v!==this.keyIdToKeyInfo[T])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(h.data),E.keyLoader=null,v.loader=null,a({frag:E,keyInfo:v});},onError:(h,f,m,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,Te({url:d.url,data:void 0},h)));},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m));},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.INTERNAL_ABORTED,new Error("key loading aborted"),m));}};n.load(d,c,u);})}resetLoader(e){let{frag:t,keyInfo:i,url:r}=e,n=i.loader;t.keyLoader===n&&(t.keyLoader=null,i.loader=null);let a=_c(i.decryptdata)||r;delete this.keyIdToKeyInfo[a],n&&n.destroy();}};function _c(s){if(s.keyFormat!==Je.FAIRPLAY){let e=s.keyId;if(e)return Ze(e)}return s.uri}function Bg(s){let{type:e}=s;switch(e){case ue.AUDIO_TRACK:return Y.AUDIO;case ue.SUBTITLE_TRACK:return Y.SUBTITLE;default:return Y.MAIN}}function Ic(s,e){let t=s.url;return (t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var Vu=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners();}startLoad(e){}stopLoad(){this.destroyInternalLoaders();}registerListeners(){let{hls:e}=this;e.on(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),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,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),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this);}createInternalLoader(e){let t=this.hls.config,i=t.pLoader,r=t.loader,n=i||r,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e];}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e);}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders();}onManifestLoading(e,t){let{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ue.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null});}onLevelLoading(e,t){let{id:i,level:r,pathwayId:n,url:a,deliveryDirectives:o,levelInfo:d}=t;this.load({id:i,level:r,pathwayId:n,responseType:"text",type:ue.LEVEL,url:a,deliveryDirectives:o,levelOrTrack:d});}onAudioTrackLoading(e,t){let{id:i,groupId:r,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ue.AUDIO_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o});}onSubtitleTrackLoading(e,t){let{id:i,groupId:r,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ue.SUBTITLE_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o});}onLevelsUpdated(e,t){let i=this.loaders[ue.LEVEL];if(i){let r=i.context;r&&!t.levels.some(n=>n===r.levelOrTrack)&&(i.abort(),delete this.loaders[ue.LEVEL]);}}load(e){var t;let i=this.hls.config,r=this.getInternalLoader(e);if(r){let l=this.hls.logger,c=r.context;if(c&&c.levelOrTrack===e.levelOrTrack&&(c.url===e.url||c.deliveryDirectives&&!e.deliveryDirectives)){c.url===e.url?l.log(`[playlist-loader]: ignore ${e.url} ongoing request`):l.log(`[playlist-loader]: ignore ${e.url} in favor of ${c.url}`);return}l.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort();}let n;if(e.type===ue.MANIFEST?n=i.manifestLoadPolicy.default:n=Se({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),H((t=e.deliveryDirectives)==null?void 0:t.part)){let l;if(e.type===ue.LEVEL&&e.level!==null?l=this.hls.levels[e.level].details:e.type===ue.AUDIO_TRACK&&e.id!==null?l=this.hls.audioTracks[e.id].details:e.type===ue.SUBTITLE_TRACK&&e.id!==null&&(l=this.hls.subtitleTracks[e.id].details),l){let c=l.partTarget,u=l.targetduration;if(c&&u){let h=Math.max(c*3,u*.8)*1e3;n=Se({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)});}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},d={onSuccess:(l,c,u,h)=>{let f=this.getInternalLoader(u);this.resetInternalLoader(u.type);let m=l.data;c.parsing.start=performance.now(),cs.isMediaPlaylist(m)||u.type!==ue.MANIFEST?this.handleTrackOrLevelPlaylist(l,c,u,h||null,f):this.handleMasterPlaylist(l,c,u,h);},onError:(l,c,u,h)=>{this.handleNetworkError(c,u,false,l,h);},onTimeout:(l,c,u)=>{this.handleNetworkError(c,u,true,void 0,l);}};r.load(e,o,d);}checkAutostartLoad(){if(!this.hls)return;let{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t));}handleMasterPlaylist(e,t,i,r){let n=this.hls,a=e.data,o=Ic(e,i),d=cs.parseMasterPlaylist(a,o);if(d.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,d.playlistParsingError,r,t);return}let{contentSteering:l,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m}=d;this.variableList=m,c.forEach(T=>{let{unknownCodecs:S}=T;if(S){let{preferManagedMediaSource:b}=this.hls.config,{audioCodec:_,videoCodec:D}=T;for(let I=S.length;I--;){let k=S[I];Ln(k,"audio",b)?(T.audioCodec=_=_?`${_},${k}`:k,fr.audio[_.substring(0,4)]=2,S.splice(I,1)):Ln(k,"video",b)&&(T.videoCodec=D=D?`${D},${k}`:k,fr.video[D.substring(0,4)]=2,S.splice(I,1));}}});let{AUDIO:g=[],SUBTITLES:E,"CLOSED-CAPTIONS":v}=cs.parseMasterPlaylistMedia(a,o,d);g.length&&!g.some(S=>!S.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:false,autoselect:false,forced:false,id:-1,attrs:new De({}),bitrate:0,url:""})),n.trigger(p.MANIFEST_LOADED,{levels:c,audioTracks:g,subtitles:E,captions:v,contentSteering:l,url:o,stats:t,networkDetails:r,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m});}handleTrackOrLevelPlaylist(e,t,i,r,n){let a=this.hls,{id:o,level:d,type:l}=i,c=Ic(e,i),u=H(d)?d:H(o)?o:0,h=Bg(i),f=cs.parseLevelPlaylist(e.data,c,u,h,0,this.variableList);if(l===ue.MANIFEST){let m={attrs:new De({}),bitrate:0,details:f,name:"",url:c};f.requestScheduled=t.loading.start+gp(f,0),a.trigger(p.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:c,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null});}t.parsing.end=performance.now(),i.levelDetails=f,this.handlePlaylistLoaded(f,e,t,i,r,n);}handleManifestParsingError(e,t,i,r,n){this.hls.trigger(p.ERROR,{type:Q.NETWORK_ERROR,details:x.MANIFEST_PARSING_ERROR,fatal:t.type===ue.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===ue.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===ue.AUDIO_TRACK||e.type===ue.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);this.hls.logger.warn(`[playlist-loader]: ${a}`);let d=x.UNKNOWN,l=false,c=this.getInternalLoader(e);switch(e.type){case ue.MANIFEST:d=i?x.MANIFEST_LOAD_TIMEOUT:x.MANIFEST_LOAD_ERROR,l=true;break;case ue.LEVEL:d=i?x.LEVEL_LOAD_TIMEOUT:x.LEVEL_LOAD_ERROR,l=false;break;case ue.AUDIO_TRACK:d=i?x.AUDIO_TRACK_LOAD_TIMEOUT:x.AUDIO_TRACK_LOAD_ERROR,l=false;break;case ue.SUBTITLE_TRACK:d=i?x.SUBTITLE_TRACK_LOAD_TIMEOUT:x.SUBTITLE_LOAD_ERROR,l=false;break}c&&this.resetInternalLoader(e.type);let u={type:Q.NETWORK_ERROR,details:d,fatal:l,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(r){let h=t?.url||e.url;u.response=Te({url:h,data:void 0},r);}this.hls.trigger(p.ERROR,u);}handlePlaylistLoaded(e,t,i,r,n,a){let o=this.hls,{type:d,level:l,levelOrTrack:c,id:u,groupId:h,deliveryDirectives:f}=r,m=Ic(t,r),g=Bg(r),E=typeof r.level=="number"&&g===Y.MAIN?l:void 0,v=e.playlistParsingError;if(v){if(this.hls.logger.warn(`${v} ${e.url}`),!o.config.ignorePlaylistParsingErrors){o.trigger(p.ERROR,{type:Q.NETWORK_ERROR,details:x.LEVEL_PARSING_ERROR,fatal:false,url:m,error:v,reason:v.message,response:t,context:r,level:E,parent:g,networkDetails:n,stats:i});return}e.playlistParsingError=null;}if(!e.fragments.length){let T=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(p.ERROR,{type:Q.NETWORK_ERROR,details:x.LEVEL_EMPTY_ERROR,fatal:false,url:m,error:T,reason:T.message,response:t,context:r,level:E,parent:g,networkDetails:n,stats:i});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),d){case ue.MANIFEST:case ue.LEVEL:if(E){if(!c)E=0;else if(c!==o.levels[E]){let T=o.levels.indexOf(c);T>-1&&(E=T);}}o.trigger(p.LEVEL_LOADED,{details:e,levelInfo:c||o.levels[0],level:E||0,id:u||0,stats:i,networkDetails:n,deliveryDirectives:f,withoutMultiVariant:d===ue.MANIFEST});break;case ue.AUDIO_TRACK:o.trigger(p.AUDIO_TRACK_LOADED,{details:e,track:c,id:u||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:f});break;case ue.SUBTITLE_TRACK:o.trigger(p.SUBTITLE_TRACK_LOADED,{details:e,track:c,id:u||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:f});break}}},gi=class s{static get version(){return Cn}static isMSESupported(){return l0()}static isSupported(){return LA()}static getMediaSource(){return $i()}static get Events(){return p}static get MetadataSchema(){return bt}static get ErrorTypes(){return Q}static get ErrorDetails(){return x}static get DefaultConfig(){return s.defaultConfig?s.defaultConfig:vA}static set DefaultConfig(e){s.defaultConfig=e;}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Zu,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=false;let t=this.logger=CT(e.debug||false,"Hls instance",e.assetPlayerId),i=this.config=yA(s.DefaultConfig,e,t);this.userConfig=e,i.progressive&&SA(i,t);let{abrController:r,bufferController:n,capLevelController:a,errorController:o,fpsController:d}=i,l=new o(this),c=this.abrController=new r(this),u=new Oc(this),h=i.interstitialsController,f=h?this.interstitialsController=new h(this,s):null,m=this.bufferController=new n(this,u),g=this.capLevelController=new a(this),E=new d(this),v=new Vu(this),T=i.contentSteeringController,S=T?new T(this):null,b=this.levelController=new Gu(this,S),_=new $u(this),D=new Ku(this.config,this.logger),I=this.streamController=new Hu(this,u,D),k=this.gapController=new Nu(this,u);g.setStreamController(I),E.setStreamController(I);let R=[v,b,I];f&&R.splice(1,0,f),S&&R.splice(1,0,S),this.networkControllers=R;let L=[c,m,k,g,E,_,u];this.audioTrackController=this.createController(i.audioTrackController,R);let w=i.audioStreamController;w&&R.push(this.audioStreamController=new w(this,u,D)),this.subtitleTrackController=this.createController(i.subtitleTrackController,R);let B=i.subtitleStreamController;B&&R.push(this.subtititleStreamController=new B(this,u,D)),this.createController(i.timelineController,L),D.emeController=this.emeController=this.createController(i.emeController,L),this.cmcdController=this.createController(i.cmcdController,L),this.latencyController=this.createController(Bu,L),this.coreComponents=L,R.push(l);let K=l.onErrorOut;typeof K=="function"&&this.on(p.ERROR,K,l),this.on(p.MANIFEST_LOADED,v.onManifestLoaded,v);}createController(e,t){if(e){let i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i);}once(e,t,i=this){this._emitter.once(e,t,i);}removeAllListeners(e){this._emitter.removeAllListeners(e);}off(e,t,i=this,r){this._emitter.off(e,t,i,r);}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=true;let r=e===p.ERROR;this.trigger(p.ERROR,{type:Q.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(){this.logger.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){if(!e||"media"in e&&!e.media){let n=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(p.ERROR,{type:Q.OTHER_ERROR,details:x.ATTACH_MEDIA_ERROR,fatal:true,error:n});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());let t="media"in e,i=t?e.media:e,r=t?e:{media:i};this._media=i,this.trigger(p.MEDIA_ATTACHING,r);}detachMedia(){this.logger.log("detachMedia"),this.trigger(p.MEDIA_DETACHING,{}),this._media=null;}transferMedia(){this._media=null;let e=this.bufferController.transferMedia();return this.trigger(p.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();let t=this.media,i=this._url,r=this._url=Wu.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:true});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${r}`),t&&i&&(i!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(p.MANIFEST_LOADING,{url:e});}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=true,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),!(!this.started||!this.networkControllers));i++);}stopLoad(){this.logger.log("stopLoad"),this.started=false;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering();}));}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering();}));}get inFlightFragments(){let e={[Y.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[Y.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[Y.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec();}recoverMediaError(){this.logger.log("recoverMediaError");let e=this._media,t=e?.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t));}removeLevel(e){this.levelController.removeLevel(e);}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=Bb()),e}get levels(){let e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch();}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch();}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e;}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e;}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e;}get startLevel(){let e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e;}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t);}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e);}get abrEwmaDefaultEstimate(){let{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated());}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){dy(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated());}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let i=e.length;for(let r=0;r<i;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this,r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,i)for(let n=r;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return r}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e;}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return ((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return ((t=this.subtitleTrackController)==null?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){let e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e);}get allSubtitleTracks(){let e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e);}get subtitleDisplay(){let e=this.subtitleTrackController;return e?e.subtitleDisplay:false}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e);}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e;}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e;}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e;}get bufferedToEnd(){var e;return !!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return ((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){let i=ip(t);return ep(e,i,navigator.mediaCapabilities)}};gi.defaultConfig=void 0;var c0=Symbol.for(""),kA=s=>{if(s?.r===c0)return s?._$litStatic$},lh=s=>({_$litStatic$:s,r:c0});var d0=new Map,dh=s=>(e,...t)=>{let i=t.length,r,n,a=[],o=[],d,l=0,c=false;for(;l<i;){for(d=e[l];l<i&&(n=t[l],(r=kA(n))!==void 0);)d+=r+e[++l],c=true;l!==i&&o.push(n),a.push(d),l++;}if(l===i&&a.push(e[i]),c){let u=a.join("$$lit$$");(e=d0.get(u))===void 0&&(a.raw=a,d0.set(u,e=a)),t=o;}return s(e,...t)},u0=dh(chunk2E5GLLOS_cjs.a);var C,h0,f0,Ll,m0,g0,ch,p0,E0,uh,v0,T0,hh,xl,y0,S0,b0,A0,fh,mh,gh,Rl,_0,ph,Eh,I0,vh,kl,Th,Nn,L0,yh,x0,Dl,R0,k0,D0,Cl,C0,M0,w0,P0,O0,F0,N0,pr,Ml,U0,$0;exports.a=class ge extends chunkTKJYRGEU_cjs.a{constructor(){super(...arguments);chunkJHSFSCC2_cjs.e(this,C);this._controls=["play","time","seek","volume","audiotracks","fullscreen","subtitles"];this.popped=false;this._isProcessing=false;this._startedPlaying=false;this._audioTrackCount=0;this._hlsAudioTracks=[];this._hlsAudioTrackIdMap=new Map;this._intersectionObserver=new chunkBTCK3T4L_cjs.a(this,{callback:chunkJHSFSCC2_cjs.g(this,C,b0).bind(this)});this.embedController=new chunkRQN3DXJB_cjs.b(this);this._intersected=false;this._queue=[];this.languageController=new chunk5QLIDHRT_cjs.d(this);}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(" "):Array.isArray(t)?this._controls=t:this._controls=[],this.requestUpdate("controls");}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||!chunkJHSFSCC2_cjs.g(this,C,hh).call(this,"thumbnail","jpg")?null:this._poster&&this._poster=="custom"?this.embedController.embedFile(chunkJHSFSCC2_cjs.g(this,C,xl).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(chunkJHSFSCC2_cjs.g(this,C,xl).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(chunkJHSFSCC2_cjs.g(this,C,xl).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?chunkJHSFSCC2_cjs.g(this,C,Rl).call(this):this._queue.push(()=>chunkJHSFSCC2_cjs.g(this,C,Rl).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.poster&&this.style.setProperty("background",`center / contain no-repeat url(${this.poster})`);}connectedCallback(){super.connectedCallback(),this.languageController.locale=this.locale||"en",this.loadTheme(),typeof window<"u"&&window.matchMedia&&(this._contrastQuery=window.matchMedia("(prefers-contrast: more)"),this._contrastQueryHandler=()=>{this._controlColorsKey=void 0,this._controlColors=void 0,this.requestUpdate();},this._contrastQuery.addEventListener?this._contrastQuery.addEventListener("change",this._contrastQueryHandler):this._contrastQuery.addListener&&this._contrastQuery.addListener(this._contrastQueryHandler)),this.addEventListener("mave:video_element_ready",chunkJHSFSCC2_cjs.g(this,C,f0).bind(this));}requestUpdate(t,i){t==="locale"&&(this.languageController.locale=this.locale||"en"),super.requestUpdate(t,i);}disconnectedCallback(){super.disconnectedCallback(),this._contrastQuery&&this._contrastQueryHandler&&(this._contrastQuery.removeEventListener?this._contrastQuery.removeEventListener("change",this._contrastQueryHandler):this._contrastQuery.removeListener&&this._contrastQuery.removeListener(this._contrastQueryHandler)),this._contrastQuery=void 0,this._contrastQueryHandler=void 0,this._metricsInstance?.demonitor(),chunkJHSFSCC2_cjs.g(this,C,uh).call(this),this._cleanupHlsAudioTracks?.(),this._cleanupHlsAudioTracks=void 0,this._pendingAudioTrackSetup!=null&&(cancelAnimationFrame(this._pendingAudioTrackSetup),this._pendingAudioTrackSetup=void 0),this._hlsAudioTrackIdMap.clear(),this._hlsAudioTracks=[],this._currentAudioTrackMenu=void 0,this._themeMutationObserver?.disconnect(),this._themeMutationObserver=void 0,this._themeMutationObserverRoot=void 0;}loadTheme(){this.embed&&this._themeLoaded!=this.theme&&(this.theme&&this.theme.endsWith(".js")?chunkCZUMF7SR_cjs.a.external(this.theme):chunkCZUMF7SR_cjs.a.get(this.theme,`${this.embedController.cdnRoot}/themes/player`),this._themeLoaded=chunkCZUMF7SR_cjs.a.getTheme());}updateEmbed(t){this._embedObj=t,this._audioTrackCount=t.audio_tracks?.length??0,this.updateStylePoster(),chunkJHSFSCC2_cjs.g(this,C,Ll).call(this),this.poster=this._embedObj.settings.poster,this.attributes.getNamedItem("color")||(this.color=this._embedObj.settings.color),this.attributes.getNamedItem("opacity")||(this.opacity=this._embedObj.settings.opacity?this._embedObj.settings.opacity:void 0),this.attributes.getNamedItem("aspect-ratio")||(this.aspect_ratio=this._embedObj.settings.aspect_ratio),this.attributes.getNamedItem("width")||(this.width=this._embedObj.settings.width),this.attributes.getNamedItem("height")||(this.height=this._embedObj.settings.height),this.attributes.getNamedItem("autoplay")||(this.autoplay=this._embedObj.settings.autoplay=="on_show"?"lazy":this._embedObj.settings.autoplay),this.attributes.getNamedItem("controls")||(this.controls=this._embedObj.settings.controls),this.attributes.getNamedItem("loop")||(this.loop=this._embedObj.settings.loop);}get styles(){let t={},i=!!this._embedObj?.subtitles?.length,r=this.subtitles==="none"||this.subtitles==="off"||!i,n=this.controls.includes("volume")||this.controls.includes("full"),a=this.color||this._embedObj?.settings.color,o=this.opacity||this._embedObj?.settings.opacity,d=a?`${a}${o||""}`:void 0;if(d){t["--primary-color"]=d;let f=chunkJHSFSCC2_cjs.g(this,C,L0).call(this,d);f&&(t["--mave-control-bg"]=f.bg,t["--mave-control-fg"]=f.fg,t["--mave-control-fg-muted"]=f.fgMuted,t["--mave-control-fg-weak"]=f.fgWeak,t["--media-control-background"]=f.bg,t["--media-menu-background"]=f.bg,t["--media-settings-menu-background"]=f.bg);}else chunkJHSFSCC2_cjs.g(this,C,yh).call(this)&&(t["--mave-control-bg"]="rgba(0, 0, 0, 0.85)",t["--mave-control-fg"]="rgb(255, 255, 255)",t["--mave-control-fg-muted"]="rgba(255, 255, 255, 0.85)",t["--mave-control-fg-weak"]="rgba(255, 255, 255, 0.6)");if(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";let f=this.controls.includes("subtitles")?"flex":"none";t["--media-captions-menu-button-display"]=f,t["--mave-captions-menu-button-display"]=f;}t["--playbackrate-display"]=this.controls.includes("rate")?"flex":"none",(r||this._embedObj?.created_at<1740674988&&!this.subtitles&&!this.active_subtitle)&&(t["--media-captions-menu-button-display"]="none",t["--mave-captions-menu-button-display"]="none"),this.controls.includes("full")||this._embedObj?.settings.controls=="full"&&!this.controls.includes("big")&&!this.controls.includes("none")?t["--media-control-bar-display"]="flex":t["--media-control-bar-display"]="none",this.controls.includes("big")||this._embedObj?.settings.controls=="big"&&!this.controls.includes("full")&&!this.controls.includes("none")?t["--big-button-display"]="flex":t["--big-button-display"]="none",this._embedObj?.video.audio===false?t["--media-mute-button-display"]="none":n?t["--media-mute-button-display"]="flex":t["--media-mute-button-display"]="none";let l=this._audioTrackCount??0,c=this.controls.includes("audiotracks")||this.controls.includes("full"),u=this.audioTracks??"auto",h=c&&l>1;return u==="off"?h=false:u==="on"&&(h=c&&l>0),t["--media-audio-track-menu-button-display"]=h?"flex":"none",chunkQQDH35OW_cjs.a(t)}render(){if(!this.embed)return;let t=this.querySelector('[slot="start-screen"], [data-slot="start-screen"]');return chunk2E5GLLOS_cjs.a`
|
|
1520
1496
|
<slot
|
|
1521
1497
|
name="video"
|
|
1522
1498
|
style=${chunkQQDH35OW_cjs.a({display:t&&!this._startedPlaying&&!this._isProcessing?"none":"block"})}
|
|
1523
1499
|
>
|
|
1524
|
-
${this.embedController.render({pending:()=>chunk2E5GLLOS_cjs.e,error:()=>chunkJHSFSCC2_cjs.g(this,
|
|
1500
|
+
${this.embedController.render({pending:()=>chunk2E5GLLOS_cjs.e,error:()=>chunkJHSFSCC2_cjs.g(this,C,F0).call(this),complete:i=>{if(!i)return chunkJHSFSCC2_cjs.g(this,C,O0).call(this);let r=i;return this._embedObj=r,this.updateEmbed(r),chunkJHSFSCC2_cjs.g(this,C,N0).call(this)}})}
|
|
1525
1501
|
</slot>
|
|
1526
|
-
${this._embedObj&&this._isProcessing?chunkJHSFSCC2_cjs.g(this,
|
|
1502
|
+
${this._embedObj&&this._isProcessing?chunkJHSFSCC2_cjs.g(this,C,P0).call(this,this._embedObj?.video?.status):chunk2E5GLLOS_cjs.e}
|
|
1527
1503
|
<slot name="start-screen"></slot>
|
|
1528
1504
|
<slot name="end-screen"></slot>
|
|
1529
1505
|
<slot name="hover-screen"></slot>
|
|
1530
|
-
`}};w=new WeakSet,E0=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());},v0=function(){this._videoElement?.addEventListener("webkitbeginfullscreen",()=>{this.style.setProperty("--subtitle-opacity","1");}),this._videoElement?.addEventListener("webkitendfullscreen",()=>{this.style.setProperty("--subtitle-opacity","0");});},kl=function(){if(!this._embedObj)return;let t=chunkJHSFSCC2_cjs.g(this,w,hh).call(this),i=typeof t=="string",r=!chunkJHSFSCC2_cjs.g(this,w,T0).call(this),n=chunkJHSFSCC2_cjs.g(this,w,S0).call(this,t),a=i&&chunkJHSFSCC2_cjs.g(this,w,y0).call(this);n&&r?chunkJHSFSCC2_cjs.g(this,w,b0).call(this):chunkJHSFSCC2_cjs.g(this,w,fh).call(this);let o=i&&n&&(r||a);this._isProcessing!==o&&(this._isProcessing=o,this.requestUpdate());},T0=function(){let t=this._embedObj?.video;if(!t)return false;let i=Array.isArray(t.renditions)?t.renditions:[],r=i.some(a=>a.container==="hls"&&a.type==="video"),n=i.some(a=>a.container==="mp4"&&a.type==="video");return r||n||!!t.original},y0=function(){if(this._videoElement){let i=this._videoElement.duration,r=this._videoElement.readyState;return !isFinite(i)||i<=0||r<=exports.a.METADATA_READY_STATES.HAVE_METADATA}let t=this._embedObj?.video?.duration;return typeof t=="number"?t<=0:false},hh=function(){return this._embedObj?.video?.status},S0=function(t=chunkJHSFSCC2_cjs.g(this,w,hh).call(this)){return typeof t=="string"?!["ready","playable"].includes(t):false},b0=function(){typeof window>"u"||this._processingRefreshHandle==null&&(this._processingRefreshHandle=window.setTimeout(()=>{this._processingRefreshHandle=void 0,this.embedController.refresh().catch(()=>{});},exports.a.PROCESSING_REFRESH_INTERVAL));},fh=function(){typeof window>"u"||this._processingRefreshHandle!=null&&(window.clearTimeout(this._processingRefreshHandle),this._processingRefreshHandle=void 0);},A0=function(t){let i={waiting:()=>chunk5QLIDHRT_cjs.a("waiting for video upload..."),uploading:()=>chunk5QLIDHRT_cjs.a("processing video..."),preparing:()=>chunk5QLIDHRT_cjs.a("processing video..."),playable:()=>chunk5QLIDHRT_cjs.a("processing video..."),ready:()=>chunk5QLIDHRT_cjs.a("preparing your video..."),errored:()=>chunk5QLIDHRT_cjs.a("video failed to process"),default:()=>chunk5QLIDHRT_cjs.a("preparing your video...")};return (t&&i[t]?i[t]():null)??i.default()},_0=function(){if(this.hls){try{this.hls.destroy();}catch{}this.hls=void 0;}},mh=function(t,i){return this._embedObj.poster&&this._embedObj.poster.renditions&&this._embedObj.poster.renditions.find(r=>r.container===i&&r.type===t)},Dl=function(t){let i=t=="custom_thumbnail"?"thumbnail":t,r=chunkJHSFSCC2_cjs.g(this,w,mh).call(this,i,"jpg");return r?`${i}.jpg${r&&r.date?`?e=${r.date}`:""}`:`${i}.jpg`},I0=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},L0=function(t){if(t&&t.tagName=="VIDEO"&&(chunkJHSFSCC2_cjs.d(this,w,vr)||chunkJHSFSCC2_cjs.d(this,w,Pl))){this._videoElement=t,this.dispatchEvent(new CustomEvent("mave:video_element_ready",{detail:this._videoElement,bubbles:true,composed:true})),this._intersectionObserver.observe(this._videoElement),chunkJHSFSCC2_cjs.g(this,w,kl).call(this),chunkSDKTBB4N_cjs.a.forEach(n=>{this._videoElement?.addEventListener(n,a=>{if(n=="play"&&chunkJHSFSCC2_cjs.g(this,w,R0).call(this),n=="ended"&&chunkJHSFSCC2_cjs.g(this,w,gh).call(this),n=="timeupdate"&&this._videoElement&&this._videoElement.duration-this._videoElement.currentTime<5){let o=this.querySelector('[slot="end-screen"], [data-slot="end-screen"]');if(o&&o.getAttribute("x-mave-end-shows")=="near_end"){chunkJHSFSCC2_cjs.g(this,w,gh).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(u=>u.containsEmbed(this.embed));if(c){let u=c.getNextForEmbed(this.embed);u&&this.emit(this.EVENT_TYPES.CLICK,{embedId:u.id});}}let d=this.querySelector("[name='mave-list-next-image']");if(d){let c=[...document.querySelectorAll("mave-list")].find(u=>u.containsEmbed(this.embed));if(c){let u=c.getNextForEmbed(this.embed);if(u){let h=document.createElement("mave-img");h.setAttribute("embed",u.id),h.addEventListener("click",()=>{this.emit(this.EVENT_TYPES.CLICK,{embedId:u.id}),d.innerHTML="";}),d.appendChild(h);}else d.innerHTML="";}}}}(n==="loadedmetadata"||n==="durationchange"||n==="loadeddata"||n==="emptied"||n==="waiting"||n==="stalled"||n==="error"||n==="playing"||n==="canplay"||n==="loadstart")&&chunkJHSFSCC2_cjs.g(this,w,kl).call(this),this.dispatchEvent(new CustomEvent(n,{detail:a,bubbles:true,composed:true}));});}),chunkBTCK3T4L_cjs.b.config={apiEndpoint:chunkEVKPEPYP_cjs.a.metrics.endpoint};({video_id:this._embedObj.video.id,space_id:this._embedObj.space_id});let r=/iPhone|iPad/.test(navigator.userAgent);chunkJHSFSCC2_cjs.g(this,w,_0).call(this),pi.isSupported()&&chunkJHSFSCC2_cjs.d(this,w,vr)&&!r?(this._cleanupHlsAudioTracks?.(),this._cleanupHlsAudioTracks=void 0,this._pendingAudioTrackSetup!=null&&(cancelAnimationFrame(this._pendingAudioTrackSetup),this._pendingAudioTrackSetup=void 0),this._hlsAudioTrackIdMap.clear(),this._hlsAudioTracks=[],this.hls=new pi({startLevel:chunkJHSFSCC2_cjs.g(this,w,I0).call(this),capLevelToPlayerSize:true,xhrSetup:chunkJHSFSCC2_cjs.g(this,w,E0).bind(this),maxBufferLength:20,maxBufferSize:20,backBufferLength:60}),this.hls?.loadSource(chunkJHSFSCC2_cjs.d(this,w,vr)),this.hls?.attachMedia(this._videoElement),chunkJHSFSCC2_cjs.g(this,w,Sh).call(this),chunkEVKPEPYP_cjs.a.metrics.enabled&&(this._metricsInstance=new chunkBTCK3T4L_cjs.b(this.hls,this.embed,{component:"player"}))):this._videoElement.canPlayType("application/vnd.apple.mpegurl")&&chunkJHSFSCC2_cjs.d(this,w,vr)?(this._cleanupHlsAudioTracks?.(),this._cleanupHlsAudioTracks=void 0,this._pendingAudioTrackSetup!=null&&(cancelAnimationFrame(this._pendingAudioTrackSetup),this._pendingAudioTrackSetup=void 0),this._hlsAudioTrackIdMap.clear(),this._hlsAudioTracks=[],this._videoElement.src=chunkJHSFSCC2_cjs.d(this,w,vr),chunkEVKPEPYP_cjs.a.metrics.enabled&&(this._metricsInstance=new chunkBTCK3T4L_cjs.b(this._videoElement,this.embed,{component:"player"}))):(this._cleanupHlsAudioTracks?.(),this._cleanupHlsAudioTracks=void 0,this._pendingAudioTrackSetup!=null&&(cancelAnimationFrame(this._pendingAudioTrackSetup),this._pendingAudioTrackSetup=void 0),this._hlsAudioTrackIdMap.clear(),this._hlsAudioTracks=[],chunkJHSFSCC2_cjs.d(this,w,Pl)&&(this._videoElement.src=chunkJHSFSCC2_cjs.d(this,w,Pl)),chunkEVKPEPYP_cjs.a.metrics.enabled&&(this._metricsInstance=new chunkBTCK3T4L_cjs.b(this._videoElement,this.embed,{component:"player"}))),this._queue.length&&(this._queue.forEach(n=>n()),this._queue=[]),chunkJHSFSCC2_cjs.g(this,w,Eh).call(this),chunkJHSFSCC2_cjs.g(this,w,ph).call(this);}},x0=function(t){for(let{isIntersecting:i}of t)t.length&&(t[0].target.tagName=="VIDEO"||t[0].target.tagName=="MAVE-PLAYER")&&(this._intersected=i,chunkJHSFSCC2_cjs.g(this,w,Eh).call(this));},R0=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,chunkJHSFSCC2_cjs.g(this,w,ph).call(this),this._previousControls&&(this.controls=this._previousControls,this._previousControls=void 0);let t=this.querySelector('[slot="start-screen"], [data-slot="start-screen"]');t&&((this.shadowRoot?.querySelector("slot[name='video']")).removeAttribute("style"),this.startScreenElement.style.display="none",t.style.display="none");},gh=function(){let t=this.querySelector('[slot="end-screen"], [data-slot="end-screen"]');if(t){if(t.tagName==="TEMPLATE"){let i=t,r=i.parentElement,n=document.createElement("div");for(let a of i.attributes)n.setAttribute(a.name,a.value);n.style.display="block",n.innerHTML=i.innerHTML,r?.replaceChild(n,i);}this.endScreenElement.style.display="block",t.style.display="block",this._previousControls||(this._previousControls=this.controls),this.controls="none";}},ph=function(){let t=this.querySelector('[slot="end-screen"], [data-slot="end-screen"]');t&&(this.endScreenElement.style.display="none",t.style.display="none"),this._previousControls&&(this.controls=this._previousControls,this._previousControls=void 0);},Eh=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());},Cl=function(){this._videoElement?.paused?(this._metricsInstance?.monitor(),this._videoElement?.play()):this._videoElement?.pause();},k0=function(t){let i=t.target.track,r=i.activeCues;if(i.mode=="showing"&&(this._currentTrackLanguage=i.language),!this._subtitlesText){let n=this.shadowRoot?.querySelector(`theme-${this._themeLoaded}`)?.shadowRoot?.querySelector("#subtitles_text");n&&(this._subtitlesText=n);}if(r.length){let n=r[0];this._subtitlesText.style.opacity="1",this._subtitlesText.style.transform="scale(1)",this._subtitlesText.innerHTML=n.text.replace(/\n/g,"<br>");}else this._subtitlesText.style.opacity="0",this._subtitlesText.style.transform="scale(0.99)";},vh=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)},Th=function(){return this._themeLoaded?this.shadowRoot?.querySelector(`theme-${this._themeLoaded}`)?.shadowRoot??null:null},D0=function(t){if(this._themeMutationObserverRoot===t)return;this._themeMutationObserver?.disconnect();let i=new MutationObserver(()=>{chunkJHSFSCC2_cjs.g(this,w,Ml).call(this);});i.observe(t,{childList:true,subtree:true}),this._themeMutationObserver=i,this._themeMutationObserverRoot=t;},yh=function(){let t=chunkJHSFSCC2_cjs.d(this,w,Th);return t?{menu:t.querySelector("mave-audio-track-menu"),button:t.querySelector("mave-audio-track-menu-button")}:{menu:null,button:null}},Ml=function(){this._pendingAudioTrackSetup==null&&(this._pendingAudioTrackSetup=requestAnimationFrame(()=>{this._pendingAudioTrackSetup=void 0,chunkJHSFSCC2_cjs.g(this,w,Sh).call(this);}));},Sh=function(){if(!this.hls)return;let t=chunkJHSFSCC2_cjs.d(this,w,Th);t&&chunkJHSFSCC2_cjs.g(this,w,D0).call(this,t);let{menu:i,button:r}=chunkJHSFSCC2_cjs.g(this,w,yh).call(this);if(!i||!r){chunkJHSFSCC2_cjs.g(this,w,Ml).call(this);return}if(i!==this._currentAudioTrackMenu||!this._cleanupHlsAudioTracks){this._cleanupHlsAudioTracks?.();let o=(c,u)=>{this._hlsAudioTracks=u?.audioTracks??[],chunkJHSFSCC2_cjs.g(this,w,Bn).call(this,this._hlsAudioTracks,this.hls?.audioTrack);},l=(c,u)=>{let h=u?.id??(typeof this.hls?.audioTrack=="number"?this.hls.audioTrack:void 0);chunkJHSFSCC2_cjs.g(this,w,Bn).call(this,this._hlsAudioTracks,h);},d=c=>{if(c.type!==chunkV54NMMTT_cjs.a.MEDIA_AUDIO_TRACK_REQUEST)return;let u=c.detail;if(u==null)return;let h=this._hlsAudioTrackIdMap.get(String(u));h==null||!this.hls||this.hls.audioTrack!==h&&(this.hls.audioTrack=h,chunkJHSFSCC2_cjs.g(this,w,Bn).call(this,this._hlsAudioTracks,h));};i.addEventListener(chunkV54NMMTT_cjs.a.MEDIA_AUDIO_TRACK_REQUEST,d),this.hls.on(pi.Events.AUDIO_TRACKS_UPDATED,o),this.hls.on(pi.Events.AUDIO_TRACK_SWITCHED,l),this._cleanupHlsAudioTracks=()=>{i.removeEventListener(chunkV54NMMTT_cjs.a.MEDIA_AUDIO_TRACK_REQUEST,d),this.hls?.off(pi.Events.AUDIO_TRACKS_UPDATED,o),this.hls?.off(pi.Events.AUDIO_TRACK_SWITCHED,l);},this._currentAudioTrackMenu=i,this.hls.audioTracks?.length&&(this._hlsAudioTracks=this.hls.audioTracks);}let n=(this._hlsAudioTracks&&this._hlsAudioTracks.length?this._hlsAudioTracks:this.hls.audioTracks)??[],a=typeof this.hls.audioTrack=="number"?this.hls.audioTrack:void 0;chunkJHSFSCC2_cjs.g(this,w,Bn).call(this,n,a);},Bn=function(t,i){let{menu:r,button:n}=chunkJHSFSCC2_cjs.g(this,w,yh).call(this);if(!r||!n){chunkJHSFSCC2_cjs.g(this,w,Ml).call(this);return}if(this._hlsAudioTracks=t??[],this._hlsAudioTrackIdMap.clear(),!t?.length){"tracks"in r&&(r.tracks=[],r.selected=void 0),this._audioTrackCount=0,this.requestUpdate();return}let a=t.map((l,d)=>{let c=l?.id??d,u=String(c);this._hlsAudioTrackIdMap.set(u,c);let h=l?.lang??l?.attrs?.LANGUAGE,m=(l?.name??"").trim()||typeof h=="string"&&h.trim()||`Track ${d+1}`,g=i!=null?c===i:l?.default??d===0;return {id:u,language:h,label:m,enabled:g}});!a.some(l=>l.enabled)&&a.length&&(a[0].enabled=true);let o=a.find(l=>l.enabled)??a[0];"tracks"in r&&(r.tracks=a,r.selected=o?.id),this._audioTrackCount=a.length,this.requestUpdate();},wl=function(t,{showSpinner:i=true,overlay:r=false}={}){return chunk2E5GLLOS_cjs.a`
|
|
1506
|
+
`}};C=new WeakSet,h0=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());},f0=function(){this._videoElement?.addEventListener("webkitbeginfullscreen",()=>{this.style.setProperty("--subtitle-opacity","1");}),this._videoElement?.addEventListener("webkitendfullscreen",()=>{this.style.setProperty("--subtitle-opacity","0");});},Ll=function(){if(!this._embedObj)return;let t=chunkJHSFSCC2_cjs.g(this,C,ch).call(this),i=typeof t=="string",r=!chunkJHSFSCC2_cjs.g(this,C,m0).call(this),n=chunkJHSFSCC2_cjs.g(this,C,p0).call(this,t),a=i&&chunkJHSFSCC2_cjs.g(this,C,g0).call(this);n&&r?chunkJHSFSCC2_cjs.g(this,C,E0).call(this):chunkJHSFSCC2_cjs.g(this,C,uh).call(this);let o=i&&n&&(r||a);this._isProcessing!==o&&(this._isProcessing=o,this.requestUpdate());},m0=function(){let t=this._embedObj?.video;if(!t)return false;let i=Array.isArray(t.renditions)?t.renditions:[],r=i.some(a=>a.container==="hls"&&a.type==="video"),n=i.some(a=>a.container==="mp4"&&a.type==="video");return r||n||!!t.original},g0=function(){if(this._videoElement){let i=this._videoElement.duration,r=this._videoElement.readyState;return !isFinite(i)||i<=0||r<=exports.a.METADATA_READY_STATES.HAVE_METADATA}let t=this._embedObj?.video?.duration;return typeof t=="number"?t<=0:false},ch=function(){return this._embedObj?.video?.status},p0=function(t=chunkJHSFSCC2_cjs.g(this,C,ch).call(this)){return typeof t=="string"?!["ready","playable"].includes(t):false},E0=function(){typeof window>"u"||this._processingRefreshHandle==null&&(this._processingRefreshHandle=window.setTimeout(()=>{this._processingRefreshHandle=void 0,this.embedController.refresh().catch(()=>{});},exports.a.PROCESSING_REFRESH_INTERVAL));},uh=function(){typeof window>"u"||this._processingRefreshHandle!=null&&(window.clearTimeout(this._processingRefreshHandle),this._processingRefreshHandle=void 0);},v0=function(t){let i={waiting:()=>chunk5QLIDHRT_cjs.a("waiting for video upload..."),uploading:()=>chunk5QLIDHRT_cjs.a("processing video..."),preparing:()=>chunk5QLIDHRT_cjs.a("processing video..."),playable:()=>chunk5QLIDHRT_cjs.a("processing video..."),ready:()=>chunk5QLIDHRT_cjs.a("preparing your video..."),errored:()=>chunk5QLIDHRT_cjs.a("video failed to process"),default:()=>chunk5QLIDHRT_cjs.a("preparing your video...")};return (t&&i[t]?i[t]():null)??i.default()},T0=function(){if(this.hls){try{this.hls.destroy();}catch{}this.hls=void 0;}},hh=function(t,i){return this._embedObj.poster&&this._embedObj.poster.renditions&&this._embedObj.poster.renditions.find(r=>r.container===i&&r.type===t)},xl=function(t){let i=t=="custom_thumbnail"?"thumbnail":t,r=chunkJHSFSCC2_cjs.g(this,C,hh).call(this,i,"jpg");return r?`${i}.jpg${r&&r.date?`?e=${r.date}`:""}`:`${i}.jpg`},y0=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},S0=function(t){if(t&&t.tagName=="VIDEO"&&(chunkJHSFSCC2_cjs.d(this,C,pr)||chunkJHSFSCC2_cjs.d(this,C,Ml))){this._videoElement=t,this.dispatchEvent(new CustomEvent("mave:video_element_ready",{detail:this._videoElement,bubbles:true,composed:true})),this._intersectionObserver.observe(this._videoElement),chunkJHSFSCC2_cjs.g(this,C,Ll).call(this),chunkSDKTBB4N_cjs.a.forEach(n=>{this._videoElement?.addEventListener(n,a=>{if(n=="play"&&chunkJHSFSCC2_cjs.g(this,C,A0).call(this),n=="ended"&&chunkJHSFSCC2_cjs.g(this,C,fh).call(this),n=="timeupdate"&&this._videoElement&&this._videoElement.duration-this._videoElement.currentTime<5){let o=this.querySelector('[slot="end-screen"], [data-slot="end-screen"]');if(o&&o.getAttribute("x-mave-end-shows")=="near_end"){chunkJHSFSCC2_cjs.g(this,C,fh).call(this);let d=this.querySelector("[name='mave-time-remaining']");if(d){let c=Math.floor(this._videoElement.duration-this._videoElement.currentTime);d.innerHTML=c<=0?"0":c.toString();}if(this._videoElement?.duration-this._videoElement?.currentTime<=0&&o.getAttribute("x-mave-list-trigger-next")=="true"){let c=[...document.querySelectorAll("mave-list")].find(u=>u.containsEmbed(this.embed));if(c){let u=c.getNextForEmbed(this.embed);u&&this.emit(this.EVENT_TYPES.CLICK,{embedId:u.id});}}let l=this.querySelector("[name='mave-list-next-image']");if(l){let c=[...document.querySelectorAll("mave-list")].find(u=>u.containsEmbed(this.embed));if(c){let u=c.getNextForEmbed(this.embed);if(u){let h=document.createElement("mave-img");h.setAttribute("embed",u.id),h.addEventListener("click",()=>{this.emit(this.EVENT_TYPES.CLICK,{embedId:u.id}),l.innerHTML="";}),l.appendChild(h);}else l.innerHTML="";}}}}(n==="loadedmetadata"||n==="durationchange"||n==="loadeddata"||n==="emptied"||n==="waiting"||n==="stalled"||n==="error"||n==="playing"||n==="canplay"||n==="loadstart")&&chunkJHSFSCC2_cjs.g(this,C,Ll).call(this),this.dispatchEvent(new CustomEvent(n,{detail:a,bubbles:true,composed:true}));});}),chunkBTCK3T4L_cjs.b.config={apiEndpoint:chunkEVKPEPYP_cjs.a.metrics.endpoint};({video_id:this._embedObj.video.id,space_id:this._embedObj.space_id});let r=/iPhone|iPad/.test(navigator.userAgent);chunkJHSFSCC2_cjs.g(this,C,T0).call(this),gi.isSupported()&&chunkJHSFSCC2_cjs.d(this,C,pr)&&!r?(this._cleanupHlsAudioTracks?.(),this._cleanupHlsAudioTracks=void 0,this._pendingAudioTrackSetup!=null&&(cancelAnimationFrame(this._pendingAudioTrackSetup),this._pendingAudioTrackSetup=void 0),this._hlsAudioTrackIdMap.clear(),this._hlsAudioTracks=[],this.hls=new gi({startLevel:chunkJHSFSCC2_cjs.g(this,C,y0).call(this),capLevelToPlayerSize:true,xhrSetup:chunkJHSFSCC2_cjs.g(this,C,h0).bind(this),maxBufferLength:20,maxBufferSize:20,backBufferLength:60}),this.hls?.loadSource(chunkJHSFSCC2_cjs.d(this,C,pr)),this.hls?.attachMedia(this._videoElement),chunkJHSFSCC2_cjs.g(this,C,Th).call(this),chunkEVKPEPYP_cjs.a.metrics.enabled&&(this._metricsInstance=new chunkBTCK3T4L_cjs.b(this.hls,this.embed,{component:"player"}))):this._videoElement.canPlayType("application/vnd.apple.mpegurl")&&chunkJHSFSCC2_cjs.d(this,C,pr)?(this._cleanupHlsAudioTracks?.(),this._cleanupHlsAudioTracks=void 0,this._pendingAudioTrackSetup!=null&&(cancelAnimationFrame(this._pendingAudioTrackSetup),this._pendingAudioTrackSetup=void 0),this._hlsAudioTrackIdMap.clear(),this._hlsAudioTracks=[],this._videoElement.src=chunkJHSFSCC2_cjs.d(this,C,pr),chunkEVKPEPYP_cjs.a.metrics.enabled&&(this._metricsInstance=new chunkBTCK3T4L_cjs.b(this._videoElement,this.embed,{component:"player"}))):(this._cleanupHlsAudioTracks?.(),this._cleanupHlsAudioTracks=void 0,this._pendingAudioTrackSetup!=null&&(cancelAnimationFrame(this._pendingAudioTrackSetup),this._pendingAudioTrackSetup=void 0),this._hlsAudioTrackIdMap.clear(),this._hlsAudioTracks=[],chunkJHSFSCC2_cjs.d(this,C,Ml)&&(this._videoElement.src=chunkJHSFSCC2_cjs.d(this,C,Ml)),chunkEVKPEPYP_cjs.a.metrics.enabled&&(this._metricsInstance=new chunkBTCK3T4L_cjs.b(this._videoElement,this.embed,{component:"player"}))),this._queue.length&&(this._queue.forEach(n=>n()),this._queue=[]),chunkJHSFSCC2_cjs.g(this,C,gh).call(this),chunkJHSFSCC2_cjs.g(this,C,mh).call(this);}},b0=function(t){for(let{isIntersecting:i}of t)t.length&&(t[0].target.tagName=="VIDEO"||t[0].target.tagName=="MAVE-PLAYER")&&(this._intersected=i,chunkJHSFSCC2_cjs.g(this,C,gh).call(this));},A0=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,chunkJHSFSCC2_cjs.g(this,C,mh).call(this),this._previousControls&&(this.controls=this._previousControls,this._previousControls=void 0);let t=this.querySelector('[slot="start-screen"], [data-slot="start-screen"]');t&&((this.shadowRoot?.querySelector("slot[name='video']")).removeAttribute("style"),this.startScreenElement.style.display="none",t.style.display="none");},fh=function(){let t=this.querySelector('[slot="end-screen"], [data-slot="end-screen"]');if(t){if(t.tagName==="TEMPLATE"){let i=t,r=i.parentElement,n=document.createElement("div");for(let a of i.attributes)n.setAttribute(a.name,a.value);n.style.display="block",n.innerHTML=i.innerHTML,r?.replaceChild(n,i);}this.endScreenElement.style.display="block",t.style.display="block",this._previousControls||(this._previousControls=this.controls),this.controls="none";}},mh=function(){let t=this.querySelector('[slot="end-screen"], [data-slot="end-screen"]');t&&(this.endScreenElement.style.display="none",t.style.display="none"),this._previousControls&&(this.controls=this._previousControls,this._previousControls=void 0);},gh=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());},Rl=function(){this._videoElement?.paused?(this._metricsInstance?.monitor(),this._videoElement?.play()):this._videoElement?.pause();},_0=function(t){let i=t.target.track,r=i.activeCues;if(i.mode=="showing"&&(this._currentTrackLanguage=i.language),!this._subtitlesText){let n=this.shadowRoot?.querySelector(`theme-${this._themeLoaded}`)?.shadowRoot?.querySelector("#subtitles_text");n&&(this._subtitlesText=n);}if(r.length){let n=r[0];this._subtitlesText.style.opacity="1",this._subtitlesText.style.transform="scale(1)",this._subtitlesText.innerHTML=n.text.replace(/\n/g,"<br>");}else this._subtitlesText.style.opacity="0",this._subtitlesText.style.transform="scale(0.99)";},ph=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)},Eh=function(){return this._themeLoaded?this.shadowRoot?.querySelector(`theme-${this._themeLoaded}`)?.shadowRoot??null:null},I0=function(t){if(this._themeMutationObserverRoot===t)return;this._themeMutationObserver?.disconnect();let i=new MutationObserver(()=>{chunkJHSFSCC2_cjs.g(this,C,kl).call(this);});i.observe(t,{childList:true,subtree:true}),this._themeMutationObserver=i,this._themeMutationObserverRoot=t;},vh=function(){let t=chunkJHSFSCC2_cjs.d(this,C,Eh);return t?{menu:t.querySelector("mave-audio-track-menu"),button:t.querySelector("mave-audio-track-menu-button")}:{menu:null,button:null}},kl=function(){this._pendingAudioTrackSetup==null&&(this._pendingAudioTrackSetup=requestAnimationFrame(()=>{this._pendingAudioTrackSetup=void 0,chunkJHSFSCC2_cjs.g(this,C,Th).call(this);}));},Th=function(){if(!this.hls)return;let t=chunkJHSFSCC2_cjs.d(this,C,Eh);t&&chunkJHSFSCC2_cjs.g(this,C,I0).call(this,t);let{menu:i,button:r}=chunkJHSFSCC2_cjs.g(this,C,vh).call(this);if(!i||!r){chunkJHSFSCC2_cjs.g(this,C,kl).call(this);return}if(i!==this._currentAudioTrackMenu||!this._cleanupHlsAudioTracks){this._cleanupHlsAudioTracks?.();let o=(c,u)=>{this._hlsAudioTracks=u?.audioTracks??[],chunkJHSFSCC2_cjs.g(this,C,Nn).call(this,this._hlsAudioTracks,this.hls?.audioTrack);},d=(c,u)=>{let h=u?.id??(typeof this.hls?.audioTrack=="number"?this.hls.audioTrack:void 0);chunkJHSFSCC2_cjs.g(this,C,Nn).call(this,this._hlsAudioTracks,h);},l=c=>{if(c.type!==chunk474VILDO_cjs.a.MEDIA_AUDIO_TRACK_REQUEST)return;let u=c.detail;if(u==null)return;let h=this._hlsAudioTrackIdMap.get(String(u));h==null||!this.hls||this.hls.audioTrack!==h&&(this.hls.audioTrack=h,chunkJHSFSCC2_cjs.g(this,C,Nn).call(this,this._hlsAudioTracks,h));};i.addEventListener(chunk474VILDO_cjs.a.MEDIA_AUDIO_TRACK_REQUEST,l),this.hls.on(gi.Events.AUDIO_TRACKS_UPDATED,o),this.hls.on(gi.Events.AUDIO_TRACK_SWITCHED,d),this._cleanupHlsAudioTracks=()=>{i.removeEventListener(chunk474VILDO_cjs.a.MEDIA_AUDIO_TRACK_REQUEST,l),this.hls?.off(gi.Events.AUDIO_TRACKS_UPDATED,o),this.hls?.off(gi.Events.AUDIO_TRACK_SWITCHED,d);},this._currentAudioTrackMenu=i,this.hls.audioTracks?.length&&(this._hlsAudioTracks=this.hls.audioTracks);}let n=(this._hlsAudioTracks&&this._hlsAudioTracks.length?this._hlsAudioTracks:this.hls.audioTracks)??[],a=typeof this.hls.audioTrack=="number"?this.hls.audioTrack:void 0;chunkJHSFSCC2_cjs.g(this,C,Nn).call(this,n,a);},Nn=function(t,i){let{menu:r,button:n}=chunkJHSFSCC2_cjs.g(this,C,vh).call(this);if(!r||!n){chunkJHSFSCC2_cjs.g(this,C,kl).call(this);return}if(this._hlsAudioTracks=t??[],this._hlsAudioTrackIdMap.clear(),!t?.length){"tracks"in r&&(r.tracks=[],r.selected=void 0),this._audioTrackCount=0,this.requestUpdate();return}let a=t.map((d,l)=>{let c=d?.id??l,u=String(c);this._hlsAudioTrackIdMap.set(u,c);let h=d?.lang??d?.attrs?.LANGUAGE,m=(d?.name??"").trim()||typeof h=="string"&&h.trim()||`Track ${l+1}`,g=i!=null?c===i:d?.default??l===0;return {id:u,language:h,label:m,enabled:g}});!a.some(d=>d.enabled)&&a.length&&(a[0].enabled=true);let o=a.find(d=>d.enabled)??a[0];"tracks"in r&&(r.tracks=a,r.selected=o?.id),this._audioTrackCount=a.length,this.requestUpdate();},L0=function(t){if(!t)return;let i=chunkJHSFSCC2_cjs.g(this,C,yh).call(this),r=`${t}|${i?"more":"default"}`;if(this._controlColorsKey===r&&this._controlColors)return this._controlColors;let n=chunkJHSFSCC2_cjs.g(this,C,x0).call(this,t);if(!n)return;let a=i?.85:.6,o=Math.max(n.a??1,a),d=`rgba(${n.r}, ${n.g}, ${n.b}, ${o.toFixed(3)})`,l=chunkJHSFSCC2_cjs.g(this,C,k0).call(this,n.r,n.g,n.b),c=`rgb(${l.r}, ${l.g}, ${l.b})`,u=i?.78:.55,h=i?.55:.3,f=`rgba(${l.r}, ${l.g}, ${l.b}, ${u})`,m=`rgba(${l.r}, ${l.g}, ${l.b}, ${h})`,g={bg:d,fg:c,fgMuted:f,fgWeak:m};return this._controlColorsKey=r,this._controlColors=g,g},yh=function(){return this._contrastQuery?this._contrastQuery.matches:typeof window>"u"||!window.matchMedia?false:window.matchMedia("(prefers-contrast: more)").matches},x0=function(t){if(typeof document>"u"||!document.body)return;let i=document.createElement("span");i.style.color=t,i.style.position="absolute",i.style.left="-9999px",i.style.top="-9999px",i.style.opacity="0",i.style.pointerEvents="none",document.body.appendChild(i);let r=getComputedStyle(i).color;i.remove();let n=r.match(/rgba?\((.+)\)/);if(!n)return;let o=n[1].replace("/"," ").trim().split(/[\s,]+/).filter(Boolean);if(o.length<3)return;let d=chunkJHSFSCC2_cjs.g(this,C,Dl).call(this,o[0]),l=chunkJHSFSCC2_cjs.g(this,C,Dl).call(this,o[1]),c=chunkJHSFSCC2_cjs.g(this,C,Dl).call(this,o[2]),u=o[3]?chunkJHSFSCC2_cjs.g(this,C,R0).call(this,o[3]):1;if(![d,l,c,u].some(h=>Number.isNaN(h)))return {r:d,g:l,b:c,a:u}},Dl=function(t){let i=t.trim();return i.endsWith("%")?Math.round(parseFloat(i)/100*255):Math.round(parseFloat(i))},R0=function(t){let i=t.trim(),r=i.endsWith("%")?parseFloat(i)/100:parseFloat(i);return Number.isNaN(r)?1:Math.min(1,Math.max(0,r))},k0=function(t,i,r){let n=chunkJHSFSCC2_cjs.g(this,C,D0).call(this,t,i,r),a=1.05/(n+.05);return (n+.05)/.05>=a?{r:0,g:0,b:0,a:1}:{r:255,g:255,b:255,a:1}},D0=function(t,i,r){let n=l=>{let c=l/255;return c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4)},a=n(t),o=n(i),d=n(r);return .2126*a+.7152*o+.0722*d},Cl=function(t,{showSpinner:i=true,overlay:r=false}={}){return chunk2E5GLLOS_cjs.a`
|
|
1531
1507
|
<div
|
|
1532
1508
|
class=${r?"processing-wrapper processing-wrapper--overlay":"processing-wrapper"}
|
|
1533
|
-
style=${chunkQQDH35OW_cjs.a(chunkJHSFSCC2_cjs.g(this,
|
|
1509
|
+
style=${chunkQQDH35OW_cjs.a(chunkJHSFSCC2_cjs.g(this,C,M0).call(this,r))}
|
|
1534
1510
|
>
|
|
1535
1511
|
<div
|
|
1536
1512
|
class="processing-state"
|
|
1537
|
-
style=${chunkQQDH35OW_cjs.a(chunkJHSFSCC2_cjs.g(this,
|
|
1513
|
+
style=${chunkQQDH35OW_cjs.a(chunkJHSFSCC2_cjs.g(this,C,C0).call(this))}
|
|
1538
1514
|
>
|
|
1539
1515
|
${i?chunk2E5GLLOS_cjs.a`<div class="processing-state__spinner" aria-hidden="true"></div>`:chunk2E5GLLOS_cjs.e}
|
|
1540
1516
|
<span class="processing-state__text">${t}</span>
|
|
1541
1517
|
</div>
|
|
1542
1518
|
</div>
|
|
1543
|
-
`},C0=function(){let t={},i=this.poster;return i&&(t.backgroundImage=`linear-gradient(rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0.65)), url(${i})`),t},M0=function(t=false){if(t)return {};let i={width:"100%"},r=this.width??this._embedObj?.settings.width,n=this.height??this._embedObj?.settings.height;r&&r!=="auto"&&(i.width=r),n&&n!=="auto"?i.height=n:i.minHeight="200px";let a=chunkJHSFSCC2_cjs.g(this,
|
|
1519
|
+
`},C0=function(){let t={},i=this.poster;return i&&(t.backgroundImage=`linear-gradient(rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0.65)), url(${i})`),t},M0=function(t=false){if(t)return {};let i={width:"100%"},r=this.width??this._embedObj?.settings.width,n=this.height??this._embedObj?.settings.height;r&&r!=="auto"&&(i.width=r),n&&n!=="auto"?i.height=n:i.minHeight="200px";let a=chunkJHSFSCC2_cjs.g(this,C,w0).call(this);return a&&(i["aspect-ratio"]=a),i},w0=function(){return this.aspect_ratio&&this.aspect_ratio!=="auto"?this.aspect_ratio:this._embedObj?.settings.aspect_ratio&&this._embedObj.settings.aspect_ratio!=="auto"?this._embedObj.settings.aspect_ratio:this._embedObj?.video?.aspect_ratio?this._embedObj.video.aspect_ratio:"16 / 9"},P0=function(t){let i=t!=="errored";return chunkJHSFSCC2_cjs.g(this,C,Cl).call(this,chunkJHSFSCC2_cjs.g(this,C,v0).call(this,t),{showSpinner:i,overlay:true})},O0=function(){return chunkJHSFSCC2_cjs.g(this,C,Cl).call(this,chunk5QLIDHRT_cjs.a("loading video..."))},F0=function(){return chunkJHSFSCC2_cjs.g(this,C,Cl).call(this,chunk5QLIDHRT_cjs.a("unable to load this video"),{showSpinner:false})},N0=function(){return this._embedObj?u0`<theme-${lh(this._themeLoaded)} style=${this.styles}>
|
|
1544
1520
|
<video
|
|
1545
|
-
@click=${chunkJHSFSCC2_cjs.g(this,
|
|
1521
|
+
@click=${chunkJHSFSCC2_cjs.g(this,C,Rl)}
|
|
1546
1522
|
playsinline
|
|
1547
1523
|
?loop=${this.loop||this._embedObj.settings.loop}
|
|
1548
1524
|
poster=${this.poster}
|
|
1549
|
-
${chunkBTCK3T4L_cjs.c(chunkJHSFSCC2_cjs.g(this,
|
|
1525
|
+
${chunkBTCK3T4L_cjs.c(chunkJHSFSCC2_cjs.g(this,C,S0))}
|
|
1550
1526
|
slot="media"
|
|
1551
1527
|
crossorigin="anonymous"
|
|
1552
1528
|
>
|
|
1553
|
-
${chunkJHSFSCC2_cjs.d(this,
|
|
1529
|
+
${chunkJHSFSCC2_cjs.d(this,C,$0)} ${chunkJHSFSCC2_cjs.d(this,C,U0)}
|
|
1554
1530
|
</video>
|
|
1555
|
-
</theme-${
|
|
1556
|
-
<track mode="hidden" @cuechange=${chunkJHSFSCC2_cjs.g(this,
|
|
1557
|
-
`})}}
|
|
1531
|
+
</theme-${lh(this._themeLoaded)}>`:chunk2E5GLLOS_cjs.e},pr=function(){let t=chunkJHSFSCC2_cjs.g(this,C,ph).call(this,"hls");if(t){let i=new URLSearchParams;return i.append("quality",t.size),this.embedController.embedFile("playlist.m3u8",i)}},Ml=function(){let t=chunkJHSFSCC2_cjs.g(this,C,ph).call(this,"mp4");return t?this.embedController.embedFile(`h264_${t?.size}.mp4`):this._embedObj.video.original},U0=function(){if(this._embedObj.subtitles.length>0){let t=this.shadowRoot?.querySelector(`theme-${this._themeLoaded}`)?.shadowRoot?.querySelector("media-captions-menu");return t&&new MutationObserver(r=>{r.forEach(()=>{this._subtitlesText&&t.getAttribute("mediasubtitlesshowing")&&(this._subtitlesText.style.opacity="0");});}).observe(t,{attributes:true}),this._embedObj.subtitles.map(i=>{if(this.subtitles&&this.subtitles.includes(i.language)||this.active_subtitle&&this.active_subtitle==i.language||this.subtitles=="all"||(this.subtitles=="original"||this.active_subtitle=="original")&&this._embedObj.video.language==i.language||!this.subtitles)return chunk2E5GLLOS_cjs.a`
|
|
1532
|
+
<track mode="hidden" @cuechange=${chunkJHSFSCC2_cjs.g(this,C,_0)} label=${i.label} kind="subtitles" srclang=${i.language} src=${i.path}></track>
|
|
1533
|
+
`})}},$0=function(){return chunk2E5GLLOS_cjs.a`<track
|
|
1558
1534
|
label="thumbnails"
|
|
1559
1535
|
default
|
|
1560
1536
|
kind="metadata"
|