@vouchfor/embeds 0.0.0-experiment.1b80037 → 0.0.0-experiment.254513d
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/es/components/Embed/controllers/fetcher.d.ts +6 -6
- package/dist/es/components/Embed/index.d.ts +4 -5
- package/dist/es/embeds.js +62 -66
- package/dist/es/embeds.js.map +1 -1
- package/dist/iife/embeds.iife.js +153 -154
- package/dist/iife/embeds.iife.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Embed/Embed.stories.ts +4 -17
- package/src/components/Embed/controllers/fetcher.ts +4 -4
- package/src/components/Embed/index.ts +3 -9
package/dist/iife/embeds.iife.js
CHANGED
@@ -1,146 +1,89 @@
|
|
1
|
-
var embeds=function(
|
1
|
+
var embeds=function(mt){"use strict";var Iy=Object.defineProperty;var Py=(mt,Ee,de)=>Ee in mt?Iy(mt,Ee,{enumerable:!0,configurable:!0,writable:!0,value:de}):mt[Ee]=de;var ec=(mt,Ee,de)=>(Py(mt,typeof Ee!="symbol"?Ee+"":Ee,de),de);function Ee(r,t){for(var e=0;e<t.length;e++){const i=t[e];if(typeof i!="string"&&!Array.isArray(i)){for(const s in i)if(s!=="default"&&!(s in r)){const n=Object.getOwnPropertyDescriptor(i,s);n&&Object.defineProperty(r,s,n.get?n:{enumerable:!0,get:()=>i[s]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}/**
|
2
2
|
* @license
|
3
3
|
* Copyright 2019 Google LLC
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
5
|
-
*/const
|
5
|
+
*/const de=window,Nr=de.ShadowRoot&&(de.ShadyCSS===void 0||de.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ur=Symbol(),Ya=new WeakMap;let Xa=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Ur)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(Nr&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=Ya.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Ya.set(e,t))}return t}toString(){return this.cssText}};const Hi=r=>new Xa(typeof r=="string"?r:r+"",void 0,Ur),Mt=(r,...t)=>{const e=r.length===1?r[0]:t.reduce((i,s,n)=>i+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+r[n+1],r[0]);return new Xa(e,r,Ur)},nc=(r,t)=>{Nr?r.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet):t.forEach(e=>{const i=document.createElement("style"),s=de.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,r.appendChild(i)})},qa=Nr?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return Hi(e)})(r):r;/**
|
6
6
|
* @license
|
7
7
|
* Copyright 2017 Google LLC
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
9
|
-
*/var
|
9
|
+
*/var Br;const xs=window,Za=xs.trustedTypes,ac=Za?Za.emptyScript:"",Ja=xs.reactiveElementPolyfillSupport,Hr={toAttribute(r,t){switch(t){case Boolean:r=r?ac:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},Qa=(r,t)=>t!==r&&(t==t||r==r),Gr={attribute:!0,type:String,converter:Hr,reflect:!1,hasChanged:Qa},Vr="finalized";let ui=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;this.finalize(),((e=this.h)!==null&&e!==void 0?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach((e,i)=>{const s=this._$Ep(i,e);s!==void 0&&(this._$Ev.set(s,i),t.push(s))}),t}static createProperty(t,e=Gr){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const n=this[t];this[e]=s,this.requestUpdate(t,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Gr}static finalize(){if(this.hasOwnProperty(Vr))return!1;this[Vr]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,i=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const s of i)this.createProperty(s,e[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)e.unshift(qa(s))}else t!==void 0&&e.push(qa(t));return e}static _$Ep(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(e=>e(this))}addController(t){var e,i;((e=this._$ES)!==null&&e!==void 0?e:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((i=t.hostConnected)===null||i===void 0||i.call(t))}removeController(t){var e;(e=this._$ES)===null||e===void 0||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])})}createRenderRoot(){var t;const e=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return nc(e,this.constructor.elementStyles),e}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(e=>{var i;return(i=e.hostConnected)===null||i===void 0?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(e=>{var i;return(i=e.hostDisconnected)===null||i===void 0?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=Gr){var s;const n=this.constructor._$Ep(t,i);if(n!==void 0&&i.reflect===!0){const a=(((s=i.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?i.converter:Hr).toAttribute(e,i.type);this._$El=t,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(t,e){var i;const s=this.constructor,n=s._$Ev.get(t);if(n!==void 0&&this._$El!==n){const a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((i=a.converter)===null||i===void 0?void 0:i.fromAttribute)!==void 0?a.converter:Hr;this._$El=n,this[n]=o.fromAttribute(e,a.type),this._$El=null}}requestUpdate(t,e,i){let s=!0;t!==void 0&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||Qa)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,i))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(i)):this._$Ek()}catch(s){throw e=!1,this._$Ek(),s}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;(e=this._$ES)===null||e===void 0||e.forEach(i=>{var s;return(s=i.hostUpdated)===null||s===void 0?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((e,i)=>this._$EO(i,this[i],e)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};ui[Vr]=!0,ui.elementProperties=new Map,ui.elementStyles=[],ui.shadowRootOptions={mode:"open"},Ja==null||Ja({ReactiveElement:ui}),((Br=xs.reactiveElementVersions)!==null&&Br!==void 0?Br:xs.reactiveElementVersions=[]).push("1.6.2");/**
|
10
10
|
* @license
|
11
11
|
* Copyright 2017 Google LLC
|
12
12
|
* SPDX-License-Identifier: BSD-3-Clause
|
13
|
-
*/var
|
14
|
-
\f\r]`,Vi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,
|
15
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),so=/'/g,
|
13
|
+
*/var jr;const ks=window,fi=ks.trustedTypes,_a=fi?fi.createPolicy("lit-html",{createHTML:r=>r}):void 0,zr="$lit$",Ce=`lit$${(Math.random()+"").slice(9)}$`,$a="?"+Ce,oc=`<${$a}>`,Ke=document,Ds=()=>Ke.createComment(""),Gi=r=>r===null||typeof r!="object"&&typeof r!="function",to=Array.isArray,lc=r=>to(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",Kr=`[
|
14
|
+
\f\r]`,Vi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,eo=/-->/g,io=/>/g,We=RegExp(`>|${Kr}(?:([^\\s"'>=/]+)(${Kr}*=${Kr}*(?:[^
|
15
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),so=/'/g,ro=/"/g,no=/^(?:script|style|textarea|title)$/i,ji=Symbol.for("lit-noChange"),ft=Symbol.for("lit-nothing"),ao=new WeakMap,Ye=Ke.createTreeWalker(Ke,129,null,!1);function oo(r,t){if(!Array.isArray(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return _a!==void 0?_a.createHTML(t):t}const hc=(r,t)=>{const e=r.length-1,i=[];let s,n=t===2?"<svg>":"",a=Vi;for(let o=0;o<e;o++){const l=r[o];let h,d,c=-1,u=0;for(;u<l.length&&(a.lastIndex=u,d=a.exec(l),d!==null);)u=a.lastIndex,a===Vi?d[1]==="!--"?a=eo:d[1]!==void 0?a=io:d[2]!==void 0?(no.test(d[2])&&(s=RegExp("</"+d[2],"g")),a=We):d[3]!==void 0&&(a=We):a===We?d[0]===">"?(a=s??Vi,c=-1):d[1]===void 0?c=-2:(c=a.lastIndex-d[2].length,h=d[1],a=d[3]===void 0?We:d[3]==='"'?ro:so):a===ro||a===so?a=We:a===eo||a===io?a=Vi:(a=We,s=void 0);const f=a===We&&r[o+1].startsWith("/>")?" ":"";n+=a===Vi?l+oc:c>=0?(i.push(h),l.slice(0,c)+zr+l.slice(c)+Ce+f):l+Ce+(c===-2?(i.push(void 0),o):f)}return[oo(r,n+(r[e]||"<?>")+(t===2?"</svg>":"")),i]};let Wr=class ic{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let n=0,a=0;const o=t.length-1,l=this.parts,[h,d]=hc(t,e);if(this.el=ic.createElement(h,i),Ye.currentNode=this.el.content,e===2){const c=this.el.content,u=c.firstChild;u.remove(),c.append(...u.childNodes)}for(;(s=Ye.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes()){const c=[];for(const u of s.getAttributeNames())if(u.endsWith(zr)||u.startsWith(Ce)){const f=d[a++];if(c.push(u),f!==void 0){const p=s.getAttribute(f.toLowerCase()+zr).split(Ce),g=/([.?@])?(.*)/.exec(f);l.push({type:1,index:n,name:g[2],strings:p,ctor:g[1]==="."?cc:g[1]==="?"?fc:g[1]==="@"?pc:Cs})}else l.push({type:6,index:n})}for(const u of c)s.removeAttribute(u)}if(no.test(s.tagName)){const c=s.textContent.split(Ce),u=c.length-1;if(u>0){s.textContent=fi?fi.emptyScript:"";for(let f=0;f<u;f++)s.append(c[f],Ds()),Ye.nextNode(),l.push({type:2,index:++n});s.append(c[u],Ds())}}}else if(s.nodeType===8)if(s.data===$a)l.push({type:2,index:n});else{let c=-1;for(;(c=s.data.indexOf(Ce,c+1))!==-1;)l.push({type:7,index:n}),c+=Ce.length-1}n++}}static createElement(t,e){const i=Ke.createElement("template");return i.innerHTML=t,i}};function pi(r,t,e=r,i){var s,n,a,o;if(t===ji)return t;let l=i!==void 0?(s=e._$Co)===null||s===void 0?void 0:s[i]:e._$Cl;const h=Gi(t)?void 0:t._$litDirective$;return(l==null?void 0:l.constructor)!==h&&((n=l==null?void 0:l._$AO)===null||n===void 0||n.call(l,!1),h===void 0?l=void 0:(l=new h(r),l._$AT(r,e,i)),i!==void 0?((a=(o=e)._$Co)!==null&&a!==void 0?a:o._$Co=[])[i]=l:e._$Cl=l),l!==void 0&&(t=pi(r,l._$AS(r,t.values),l,i)),t}let dc=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:i},parts:s}=this._$AD,n=((e=t==null?void 0:t.creationScope)!==null&&e!==void 0?e:Ke).importNode(i,!0);Ye.currentNode=n;let a=Ye.nextNode(),o=0,l=0,h=s[0];for(;h!==void 0;){if(o===h.index){let d;h.type===2?d=new lo(a,a.nextSibling,this,t):h.type===1?d=new h.ctor(a,h.name,h.strings,this,t):h.type===6&&(d=new gc(a,this,t)),this._$AV.push(d),h=s[++l]}o!==(h==null?void 0:h.index)&&(a=Ye.nextNode(),o++)}return Ye.currentNode=Ke,n}v(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},lo=class sc{constructor(t,e,i,s){var n;this.type=2,this._$AH=ft,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cp=(n=s==null?void 0:s.isConnected)===null||n===void 0||n}get _$AU(){var t,e;return(e=(t=this._$AM)===null||t===void 0?void 0:t._$AU)!==null&&e!==void 0?e:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=pi(this,t,e),Gi(t)?t===ft||t==null||t===""?(this._$AH!==ft&&this._$AR(),this._$AH=ft):t!==this._$AH&&t!==ji&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):lc(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==ft&&Gi(this._$AH)?this._$AA.nextSibling.data=t:this.$(Ke.createTextNode(t)),this._$AH=t}g(t){var e;const{values:i,_$litType$:s}=t,n=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=Wr.createElement(oo(s.h,s.h[0]),this.options)),s);if(((e=this._$AH)===null||e===void 0?void 0:e._$AD)===n)this._$AH.v(i);else{const a=new dc(n,this),o=a.u(this.options);a.v(i),this.$(o),this._$AH=a}}_$AC(t){let e=ao.get(t.strings);return e===void 0&&ao.set(t.strings,e=new Wr(t)),e}T(t){to(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const n of t)s===e.length?e.push(i=new sc(this.k(Ds()),this.k(Ds()),this,this.options)):i=e[s],i._$AI(n),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)===null||i===void 0||i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cp=t,(e=this._$AP)===null||e===void 0||e.call(this,t))}},Cs=class{constructor(t,e,i,s,n){this.type=1,this._$AH=ft,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=n,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ft}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const n=this.strings;let a=!1;if(n===void 0)t=pi(this,t,e,0),a=!Gi(t)||t!==this._$AH&&t!==ji,a&&(this._$AH=t);else{const o=t;let l,h;for(t=n[0],l=0;l<n.length-1;l++)h=pi(this,o[i+l],e,l),h===ji&&(h=this._$AH[l]),a||(a=!Gi(h)||h!==this._$AH[l]),h===ft?t=ft:t!==ft&&(t+=(h??"")+n[l+1]),this._$AH[l]=h}a&&!s&&this.j(t)}j(t){t===ft?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},cc=class extends Cs{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===ft?void 0:t}};const uc=fi?fi.emptyScript:"";let fc=class extends Cs{constructor(){super(...arguments),this.type=4}j(t){t&&t!==ft?this.element.setAttribute(this.name,uc):this.element.removeAttribute(this.name)}},pc=class extends Cs{constructor(t,e,i,s,n){super(t,e,i,s,n),this.type=5}_$AI(t,e=this){var i;if((t=(i=pi(this,t,e,0))!==null&&i!==void 0?i:ft)===ji)return;const s=this._$AH,n=t===ft&&s!==ft||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,a=t!==ft&&(s===ft||n);n&&this.element.removeEventListener(this.name,this,s),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;typeof this._$AH=="function"?this._$AH.call((i=(e=this.options)===null||e===void 0?void 0:e.host)!==null&&i!==void 0?i:this.element,t):this._$AH.handleEvent(t)}},gc=class{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){pi(this,t)}};const ho=ks.litHtmlPolyfillSupport;ho==null||ho(Wr,lo),((jr=ks.litHtmlVersions)!==null&&jr!==void 0?jr:ks.litHtmlVersions=[]).push("2.8.0");/**
|
16
16
|
* @license
|
17
17
|
* Copyright 2017 Google LLC
|
18
18
|
* SPDX-License-Identifier: BSD-3-Clause
|
19
|
-
*/var
|
20
|
-
\f\r]`,Wi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,
|
21
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),
|
19
|
+
*/var Yr;const Is=window,gi=Is.trustedTypes,co=gi?gi.createPolicy("lit-html",{createHTML:r=>r}):void 0,Ps="$lit$",we=`lit$${(Math.random()+"").slice(9)}$`,Xr="?"+we,mc=`<${Xr}>`,Xe=document,zi=()=>Xe.createComment(""),Ki=r=>r===null||typeof r!="object"&&typeof r!="function",uo=Array.isArray,fo=r=>uo(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",qr=`[
|
20
|
+
\f\r]`,Wi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,po=/-->/g,go=/>/g,qe=RegExp(`>|${qr}(?:([^\\s"'>=/]+)(${qr}*=${qr}*(?:[^
|
21
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),mo=/'/g,vo=/"/g,yo=/^(?:script|style|textarea|title)$/i,vc=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),_=vc(1),se=Symbol.for("lit-noChange"),pt=Symbol.for("lit-nothing"),bo=new WeakMap,Ze=Xe.createTreeWalker(Xe,129,null,!1),Ao=(r,t)=>{const e=r.length-1,i=[];let s,n=t===2?"<svg>":"",a=Wi;for(let l=0;l<e;l++){const h=r[l];let d,c,u=-1,f=0;for(;f<h.length&&(a.lastIndex=f,c=a.exec(h),c!==null);)f=a.lastIndex,a===Wi?c[1]==="!--"?a=po:c[1]!==void 0?a=go:c[2]!==void 0?(yo.test(c[2])&&(s=RegExp("</"+c[2],"g")),a=qe):c[3]!==void 0&&(a=qe):a===qe?c[0]===">"?(a=s??Wi,u=-1):c[1]===void 0?u=-2:(u=a.lastIndex-c[2].length,d=c[1],a=c[3]===void 0?qe:c[3]==='"'?vo:mo):a===vo||a===mo?a=qe:a===po||a===go?a=Wi:(a=qe,s=void 0);const p=a===qe&&r[l+1].startsWith("/>")?" ":"";n+=a===Wi?h+mc:u>=0?(i.push(d),h.slice(0,u)+Ps+h.slice(u)+we+p):h+we+(u===-2?(i.push(void 0),l):p)}const o=n+(r[e]||"<?>")+(t===2?"</svg>":"");if(!Array.isArray(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return[co!==void 0?co.createHTML(o):o,i]};let Zr=class rc{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let n=0,a=0;const o=t.length-1,l=this.parts,[h,d]=Ao(t,e);if(this.el=rc.createElement(h,i),Ze.currentNode=this.el.content,e===2){const c=this.el.content,u=c.firstChild;u.remove(),c.append(...u.childNodes)}for(;(s=Ze.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes()){const c=[];for(const u of s.getAttributeNames())if(u.endsWith(Ps)||u.startsWith(we)){const f=d[a++];if(c.push(u),f!==void 0){const p=s.getAttribute(f.toLowerCase()+Ps).split(we),g=/([.?@])?(.*)/.exec(f);l.push({type:1,index:n,name:g[2],strings:p,ctor:g[1]==="."?Eo:g[1]==="?"?wo:g[1]==="@"?So:Yi})}else l.push({type:6,index:n})}for(const u of c)s.removeAttribute(u)}if(yo.test(s.tagName)){const c=s.textContent.split(we),u=c.length-1;if(u>0){s.textContent=gi?gi.emptyScript:"";for(let f=0;f<u;f++)s.append(c[f],zi()),Ze.nextNode(),l.push({type:2,index:++n});s.append(c[u],zi())}}}else if(s.nodeType===8)if(s.data===Xr)l.push({type:2,index:n});else{let c=-1;for(;(c=s.data.indexOf(we,c+1))!==-1;)l.push({type:7,index:n}),c+=we.length-1}n++}}static createElement(t,e){const i=Xe.createElement("template");return i.innerHTML=t,i}};function Je(r,t,e=r,i){var s,n,a,o;if(t===se)return t;let l=i!==void 0?(s=e._$Co)===null||s===void 0?void 0:s[i]:e._$Cl;const h=Ki(t)?void 0:t._$litDirective$;return(l==null?void 0:l.constructor)!==h&&((n=l==null?void 0:l._$AO)===null||n===void 0||n.call(l,!1),h===void 0?l=void 0:(l=new h(r),l._$AT(r,e,i)),i!==void 0?((a=(o=e)._$Co)!==null&&a!==void 0?a:o._$Co=[])[i]=l:e._$Cl=l),l!==void 0&&(t=Je(r,l._$AS(r,t.values),l,i)),t}let To=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:i},parts:s}=this._$AD,n=((e=t==null?void 0:t.creationScope)!==null&&e!==void 0?e:Xe).importNode(i,!0);Ze.currentNode=n;let a=Ze.nextNode(),o=0,l=0,h=s[0];for(;h!==void 0;){if(o===h.index){let d;h.type===2?d=new mi(a,a.nextSibling,this,t):h.type===1?d=new h.ctor(a,h.name,h.strings,this,t):h.type===6&&(d=new Lo(a,this,t)),this._$AV.push(d),h=s[++l]}o!==(h==null?void 0:h.index)&&(a=Ze.nextNode(),o++)}return Ze.currentNode=Xe,n}v(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}};class mi{constructor(t,e,i,s){var n;this.type=2,this._$AH=pt,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cp=(n=s==null?void 0:s.isConnected)===null||n===void 0||n}get _$AU(){var t,e;return(e=(t=this._$AM)===null||t===void 0?void 0:t._$AU)!==null&&e!==void 0?e:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Je(this,t,e),Ki(t)?t===pt||t==null||t===""?(this._$AH!==pt&&this._$AR(),this._$AH=pt):t!==this._$AH&&t!==se&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):fo(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==pt&&Ki(this._$AH)?this._$AA.nextSibling.data=t:this.$(Xe.createTextNode(t)),this._$AH=t}g(t){var e;const{values:i,_$litType$:s}=t,n=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=Zr.createElement(s.h,this.options)),s);if(((e=this._$AH)===null||e===void 0?void 0:e._$AD)===n)this._$AH.v(i);else{const a=new To(n,this),o=a.u(this.options);a.v(i),this.$(o),this._$AH=a}}_$AC(t){let e=bo.get(t.strings);return e===void 0&&bo.set(t.strings,e=new Zr(t)),e}T(t){uo(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const n of t)s===e.length?e.push(i=new mi(this.k(zi()),this.k(zi()),this,this.options)):i=e[s],i._$AI(n),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)===null||i===void 0||i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cp=t,(e=this._$AP)===null||e===void 0||e.call(this,t))}}class Yi{constructor(t,e,i,s,n){this.type=1,this._$AH=pt,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=n,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=pt}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const n=this.strings;let a=!1;if(n===void 0)t=Je(this,t,e,0),a=!Ki(t)||t!==this._$AH&&t!==se,a&&(this._$AH=t);else{const o=t;let l,h;for(t=n[0],l=0;l<n.length-1;l++)h=Je(this,o[i+l],e,l),h===se&&(h=this._$AH[l]),a||(a=!Ki(h)||h!==this._$AH[l]),h===pt?t=pt:t!==pt&&(t+=(h??"")+n[l+1]),this._$AH[l]=h}a&&!s&&this.j(t)}j(t){t===pt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let Eo=class extends Yi{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===pt?void 0:t}};const yc=gi?gi.emptyScript:"";let wo=class extends Yi{constructor(){super(...arguments),this.type=4}j(t){t&&t!==pt?this.element.setAttribute(this.name,yc):this.element.removeAttribute(this.name)}};class So extends Yi{constructor(t,e,i,s,n){super(t,e,i,s,n),this.type=5}_$AI(t,e=this){var i;if((t=(i=Je(this,t,e,0))!==null&&i!==void 0?i:pt)===se)return;const s=this._$AH,n=t===pt&&s!==pt||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,a=t!==pt&&(s===pt||n);n&&this.element.removeEventListener(this.name,this,s),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;typeof this._$AH=="function"?this._$AH.call((i=(e=this.options)===null||e===void 0?void 0:e.host)!==null&&i!==void 0?i:this.element,t):this._$AH.handleEvent(t)}}class Lo{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Je(this,t)}}const bc={O:Ps,P:we,A:Xr,C:1,M:Ao,L:To,D:fo,R:Je,I:mi,V:Yi,H:wo,N:So,U:Eo,F:Lo},Ro=Is.litHtmlPolyfillSupport;Ro==null||Ro(Zr,mi),((Yr=Is.litHtmlVersions)!==null&&Yr!==void 0?Yr:Is.litHtmlVersions=[]).push("2.7.4");const Ac=(r,t,e)=>{var i,s;const n=(i=e==null?void 0:e.renderBefore)!==null&&i!==void 0?i:t;let a=n._$litPart$;if(a===void 0){const o=(s=e==null?void 0:e.renderBefore)!==null&&s!==void 0?s:null;n._$litPart$=a=new mi(t.insertBefore(zi(),o),o,void 0,e??{})}return a._$AI(r),a};/**
|
22
22
|
* @license
|
23
23
|
* Copyright 2017 Google LLC
|
24
24
|
* SPDX-License-Identifier: BSD-3-Clause
|
25
|
-
*/var
|
25
|
+
*/var Jr,Qr;let vi=class extends ui{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return(t=(e=this.renderOptions).renderBefore)!==null&&t!==void 0||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Ac(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!1)}render(){return se}};vi.finalized=!0,vi._$litElement$=!0,(Jr=globalThis.litElementHydrateSupport)===null||Jr===void 0||Jr.call(globalThis,{LitElement:vi});const xo=globalThis.litElementPolyfillSupport;xo==null||xo({LitElement:vi}),((Qr=globalThis.litElementVersions)!==null&&Qr!==void 0?Qr:globalThis.litElementVersions=[]).push("3.3.2");/**
|
26
26
|
* @license
|
27
27
|
* Copyright 2017 Google LLC
|
28
28
|
* SPDX-License-Identifier: BSD-3-Clause
|
29
|
-
*/const Tc=
|
29
|
+
*/const Tc=r=>t=>typeof t=="function"?((e,i)=>(customElements.define(e,i),i))(r,t):((e,i)=>{const{kind:s,elements:n}=i;return{kind:s,elements:n,finisher(a){customElements.define(e,a)}}})(r,t);/**
|
30
30
|
* @license
|
31
31
|
* Copyright 2017 Google LLC
|
32
32
|
* SPDX-License-Identifier: BSD-3-Clause
|
33
|
-
*/const Ec=(
|
33
|
+
*/const Ec=(r,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(e){e.createProperty(t.key,r)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){typeof t.initializer=="function"&&(this[t.key]=t.initializer.call(this))},finisher(e){e.createProperty(t.key,r)}},wc=(r,t,e)=>{t.constructor.createProperty(e,r)};function j(r){return(t,e)=>e!==void 0?wc(r,t,e):Ec(r,t)}/**
|
34
34
|
* @license
|
35
35
|
* Copyright 2017 Google LLC
|
36
36
|
* SPDX-License-Identifier: BSD-3-Clause
|
37
|
-
*/function Bt(
|
37
|
+
*/function Bt(r){return j({...r,state:!0})}/**
|
38
38
|
* @license
|
39
39
|
* Copyright 2021 Google LLC
|
40
40
|
* SPDX-License-Identifier: BSD-3-Clause
|
41
|
-
*/var
|
41
|
+
*/var _r;((_r=window.HTMLSlotElement)===null||_r===void 0?void 0:_r.prototype.assignedElements)!=null;/**
|
42
42
|
* @license
|
43
43
|
* Copyright 2018 Google LLC
|
44
44
|
* SPDX-License-Identifier: BSD-3-Clause
|
45
|
-
*/const
|
45
|
+
*/const ko=r=>r??ft;/**
|
46
46
|
* @license
|
47
47
|
* Copyright 2020 Google LLC
|
48
48
|
* SPDX-License-Identifier: BSD-3-Clause
|
49
|
-
*/const Sc=
|
49
|
+
*/const Sc=r=>r.strings===void 0;/**
|
50
50
|
* @license
|
51
51
|
* Copyright 2017 Google LLC
|
52
52
|
* SPDX-License-Identifier: BSD-3-Clause
|
53
|
-
*/const Lc={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Rc=
|
53
|
+
*/const Lc={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Rc=r=>(...t)=>({_$litDirective$:r,values:t});let xc=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
|
54
54
|
* @license
|
55
55
|
* Copyright 2017 Google LLC
|
56
56
|
* SPDX-License-Identifier: BSD-3-Clause
|
57
|
-
*/const Xi=(
|
57
|
+
*/const Xi=(r,t)=>{var e,i;const s=r._$AN;if(s===void 0)return!1;for(const n of s)(i=(e=n)._$AO)===null||i===void 0||i.call(e,t,!1),Xi(n,t);return!0},Os=r=>{let t,e;do{if((t=r._$AM)===void 0)break;e=t._$AN,e.delete(r),r=t}while((e==null?void 0:e.size)===0)},Do=r=>{for(let t;t=r._$AM;r=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(r))break;e.add(r),Cc(t)}};function kc(r){this._$AN!==void 0?(Os(this),this._$AM=r,Do(this)):this._$AM=r}function Dc(r,t=!1,e=0){const i=this._$AH,s=this._$AN;if(s!==void 0&&s.size!==0)if(t)if(Array.isArray(i))for(let n=e;n<i.length;n++)Xi(i[n],!1),Os(i[n]);else i!=null&&(Xi(i,!1),Os(i));else Xi(this,r)}const Cc=r=>{var t,e,i,s;r.type==Lc.CHILD&&((t=(i=r)._$AP)!==null&&t!==void 0||(i._$AP=Dc),(e=(s=r)._$AQ)!==null&&e!==void 0||(s._$AQ=kc))};let Ic=class extends xc{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),Do(this),this.isConnected=t._$AU}_$AO(t,e=!0){var i,s;t!==this.isConnected&&(this.isConnected=t,t?(i=this.reconnected)===null||i===void 0||i.call(this):(s=this.disconnected)===null||s===void 0||s.call(this)),e&&(Xi(this,t),Os(this))}setValue(t){if(Sc(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};/**
|
58
58
|
* @license
|
59
59
|
* Copyright 2020 Google LLC
|
60
60
|
* SPDX-License-Identifier: BSD-3-Clause
|
61
|
-
*/const Co=()=>new Pc;let Pc=class{};const
|
61
|
+
*/const Co=()=>new Pc;let Pc=class{};const $r=new WeakMap,Io=Rc(class extends Ic{render(r){return ft}update(r,[t]){var e;const i=t!==this.G;return i&&this.G!==void 0&&this.ot(void 0),(i||this.rt!==this.lt)&&(this.G=t,this.dt=(e=r.options)===null||e===void 0?void 0:e.host,this.ot(this.lt=r.element)),ft}ot(r){var t;if(typeof this.G=="function"){const e=(t=this.dt)!==null&&t!==void 0?t:globalThis;let i=$r.get(e);i===void 0&&(i=new WeakMap,$r.set(e,i)),i.get(this.G)!==void 0&&this.G.call(this.dt,void 0),i.set(this.G,r),r!==void 0&&this.G.call(this.dt,r)}else this.G.value=r}get rt(){var r,t,e;return typeof this.G=="function"?(t=$r.get((r=this.dt)!==null&&r!==void 0?r:globalThis))===null||t===void 0?void 0:t.get(this.G):(e=this.G)===null||e===void 0?void 0:e.value}disconnected(){this.rt===this.lt&&this.ot(void 0)}reconnected(){this.ot(this.lt)}});function Oc(r,t,e){function i(s){e.dispatchEvent(new CustomEvent(s.type,s))}return t.addEventListener(r,i),()=>{t.removeEventListener(r,i)}}class Mc{constructor(t,e){this._events=[],this._cleanup=[],this._forwardElementRef=Co(),this.host=t,this._events=e,t.addController(this)}register(){return Io(this._forwardElementRef)}hostConnected(){requestAnimationFrame(()=>{this._events.forEach(t=>{this._forwardElementRef.value&&this._cleanup.push(Oc(t,this._forwardElementRef.value,this.host))})})}hostDisconnected(){this._cleanup.forEach(t=>{t()}),this._cleanup=[]}}/**
|
62
62
|
* @license
|
63
63
|
* Copyright 2019 Google LLC
|
64
64
|
* SPDX-License-Identifier: BSD-3-Clause
|
65
|
-
*/const
|
65
|
+
*/const Ms=globalThis,tn=Ms.ShadowRoot&&(Ms.ShadyCSS===void 0||Ms.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Po=Symbol(),Oo=new WeakMap;let Fc=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Po)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(tn&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=Oo.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Oo.set(e,t))}return t}toString(){return this.cssText}};const Nc=r=>new Fc(typeof r=="string"?r:r+"",void 0,Po),Uc=(r,t)=>{if(tn)r.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=Ms.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,r.appendChild(i)}},Mo=tn?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return Nc(e)})(r):r;/**
|
66
66
|
* @license
|
67
67
|
* Copyright 2017 Google LLC
|
68
68
|
* SPDX-License-Identifier: BSD-3-Clause
|
69
|
-
*/const{is:Bc,defineProperty:Hc,getOwnPropertyDescriptor:Gc,getOwnPropertyNames:Vc,getOwnPropertySymbols:jc,getPrototypeOf:zc}=Object,Ie=globalThis,Fo=Ie.trustedTypes,Kc=Fo?Fo.emptyScript:"",
|
69
|
+
*/const{is:Bc,defineProperty:Hc,getOwnPropertyDescriptor:Gc,getOwnPropertyNames:Vc,getOwnPropertySymbols:jc,getPrototypeOf:zc}=Object,Ie=globalThis,Fo=Ie.trustedTypes,Kc=Fo?Fo.emptyScript:"",en=Ie.reactiveElementPolyfillSupport,qi=(r,t)=>r,sn={toAttribute(r,t){switch(t){case Boolean:r=r?Kc:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},rn=(r,t)=>!Bc(r,t),No={attribute:!0,type:String,converter:sn,reflect:!1,hasChanged:rn};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Ie.litPropertyMetadata??(Ie.litPropertyMetadata=new WeakMap);class Zi extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=No){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);s!==void 0&&Hc(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:n}=Gc(this.prototype,t)??{get(){return this[e]},set(a){this[e]=a}};return{get(){return s==null?void 0:s.call(this)},set(a){const o=s==null?void 0:s.call(this);n.call(this,a),this.requestUpdate(t,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??No}static _$Ei(){if(this.hasOwnProperty(qi("elementProperties")))return;const t=zc(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(qi("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(qi("properties"))){const e=this.properties,i=[...Vc(e),...jc(e)];for(const s of i)this.createProperty(s,e[s])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,s]of e)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const s=this._$Eu(e,i);s!==void 0&&this._$Eh.set(s,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)e.unshift(Mo(s))}else t!==void 0&&e.push(Mo(t));return e}static _$Eu(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$Eg=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$ES??(this._$ES=[])).push(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$ES)==null||e.splice(this._$ES.indexOf(t)>>>0,1)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Uc(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)==null||t.forEach(e=>{var i;return(i=e.hostDisconnected)==null?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){var n;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const a=(((n=i.converter)==null?void 0:n.toAttribute)!==void 0?i.converter:sn).toAttribute(e,i.type);this._$Em=t,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$Em=null}}_$AK(t,e){var n;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const a=i.getPropertyOptions(s),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((n=a.converter)==null?void 0:n.fromAttribute)!==void 0?a.converter:sn;this._$Em=s,this[s]=o.fromAttribute(e,a.type),this._$Em=null}}requestUpdate(t,e,i,s=!1,n){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??rn)(s?n:this[t],e))return;this.C(t,e,i)}this.isUpdatePending===!1&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this._$Ep){for(const[n,a]of this._$Ep)this[n]=a;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[n,a]of s)a.wrapped!==!0||this._$AL.has(n)||this[n]===void 0||this.C(n,this[n],a)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$ES)==null||i.forEach(s=>{var n;return(n=s.hostUpdate)==null?void 0:n.call(s)}),this.update(e)):this._$ET()}catch(s){throw t=!1,this._$ET(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$ES)==null||e.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EO(e,this[e]))),this._$ET()}updated(t){}firstUpdated(t){}}Zi.elementStyles=[],Zi.shadowRootOptions={mode:"open"},Zi[qi("elementProperties")]=new Map,Zi[qi("finalized")]=new Map,en==null||en({ReactiveElement:Zi}),(Ie.reactiveElementVersions??(Ie.reactiveElementVersions=[])).push("2.0.0");/**
|
70
70
|
* @license
|
71
71
|
* Copyright 2017 Google LLC
|
72
72
|
* SPDX-License-Identifier: BSD-3-Clause
|
73
|
-
*/const Wc=Symbol();let Uo=class{get taskComplete(){return this.t||(this.status===1?this.t=new Promise((t,e)=>{this.i=t,this.o=e}):this.status===3?this.t=Promise.reject(this.h):this.t=Promise.resolve(this.l)),this.t}constructor(t,e,i){var n;this.u=0,this.status=0,(this.p=t).addController(this);const r=typeof e=="object"?e:{task:e,args:i};this._=r.task,this.v=r.args,this.j=r.argsEqual??Yc,this.m=r.onComplete,this.g=r.onError,this.autoRun=r.autoRun??!0,"initialValue"in r&&(this.l=r.initialValue,this.status=2,this.k=(n=this.A)==null?void 0:n.call(this))}hostUpdate(){this.autoRun===!0&&this.O()}hostUpdated(){this.autoRun==="afterUpdate"&&this.O()}A(){if(this.v===void 0)return;const t=this.v();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async O(){const t=this.A(),e=this.k;this.k=t,t===e||t===void 0||e!==void 0&&this.j(e,t)||await this.run(t)}async run(t){var a,o,l,h,d;let e,i;t??(t=this.A()),this.k=t,this.status===1?(a=this.T)==null||a.abort():(this.t=void 0,this.i=void 0,this.o=void 0),this.status=1,this.autoRun==="afterUpdate"?queueMicrotask(()=>this.p.requestUpdate()):this.p.requestUpdate();const r=++this.u;this.T=new AbortController;let n=!1;try{e=await this._(t,{signal:this.T.signal})}catch(c){n=!0,i=c}if(this.u===r){if(e===Wc)this.status=0;else{if(n===!1){try{(o=this.m)==null||o.call(this,e)}catch{}this.status=2,(l=this.i)==null||l.call(this,e)}else{try{(h=this.g)==null||h.call(this,i)}catch{}this.status=3,(d=this.o)==null||d.call(this,i)}this.l=e,this.h=i}this.p.requestUpdate()}}abort(t){var e;this.status===1&&((e=this.T)==null||e.abort(t))}get value(){return this.l}get error(){return this.h}render(t){var e,i,r,n;switch(this.status){case 0:return(e=t.initial)==null?void 0:e.call(t);case 1:return(i=t.pending)==null?void 0:i.call(t);case 2:return(r=t.complete)==null?void 0:r.call(t,this.value);case 3:return(n=t.error)==null?void 0:n.call(t,this.error);default:throw Error("Unexpected status: "+this.status)}}};const Yc=(s,t)=>s===t||s.length===t.length&&s.every((e,i)=>!nn(e,t[i])),an="https://vouchfor.com",Xc="https://d2rxhdlm2q91uk.cloudfront.net",qc="https://d1ix11aj5kfygl.cloudfront.net",Zc="https://d157jlwnudd93d.cloudfront.net",Jc="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",Qc="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",_c="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",$c="http://localhost:6060/v1",tu="https://embed-staging.vouchfor.com/v1",eu="https://embed.vouchfor.com/v1",iu="https://dev.vouchfor.com",ru="https://staging.vouchfor.com",su="https://app.vouchfor.com";function Fr(s){if(!["dev","staging","prod"].includes(s))throw new Error(`Unknown environment: ${s}`);if(s==="dev")return{marketingUrl:an,videoUrl:Xc,publicApiUrl:Jc,embedApiUrl:$c,publicRecorderUrl:iu};if(s==="staging")return{marketingUrl:an,videoUrl:qc,publicApiUrl:Qc,embedApiUrl:tu,publicRecorderUrl:ru};if(s==="prod")return{marketingUrl:an,videoUrl:Zc,publicApiUrl:_c,embedApiUrl:eu,publicRecorderUrl:su}}class nu{constructor(t){this._fetching=!1,this._vouch=null,this._template=null,this.host=t,new Uo(this.host,async([e,i,r,n,a])=>{var o,l,h,d;try{if(this.vouch=null,this.template=null,r){const c=await this.getTemplate(e,i,a);this.vouch=r,this.template=((l=(o=r==null?void 0:r.settings)==null?void 0:o.template)==null?void 0:l.instance)??c}else if(n){this.fetching=!0;const[c,u]=await Promise.all([this.getVouch(e,i,n),this.getTemplate(e,i,a)]);this.vouch=c,this.template=((d=(h=c==null?void 0:c.settings)==null?void 0:h.template)==null?void 0:d.instance)??u}}finally{this.fetching=!1}},()=>[t.env,t.apiKey,t.data,t.vouchId,t.templateId])}set fetching(t){this._fetching!==t&&(this._fetching=t,this.host.requestUpdate())}get fetching(){return this._fetching}set vouch(t){this._vouch!==t&&(this._vouch=t,this.host.requestUpdate())}get vouch(){return this._vouch}set template(t){this._template!==t&&(this._template=t,this.host.requestUpdate())}get template(){return this._template}async getVouch(t,e,i){const{embedApiUrl:r}=Fr(t);return i?fetch(`${r}/vouches/${i}`,{method:"GET",headers:[["X-Api-Key",e]]}).then(n=>n.json()):null}async getTemplate(t,e,i){const{embedApiUrl:r}=Fr(t);return i?fetch(`${r}/templates/${i}`,{method:"GET",headers:[["X-Api-Key",e]]}).then(n=>n.json()):null}}let Nr;const au=new Uint8Array(16);function ou(){if(!Nr&&(Nr=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Nr))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Nr(au)}const kt=[];for(let s=0;s<256;++s)kt.push((s+256).toString(16).slice(1));function lu(s,t=0){return kt[s[t+0]]+kt[s[t+1]]+kt[s[t+2]]+kt[s[t+3]]+"-"+kt[s[t+4]]+kt[s[t+5]]+"-"+kt[s[t+6]]+kt[s[t+7]]+"-"+kt[s[t+8]]+kt[s[t+9]]+"-"+kt[s[t+10]]+kt[s[t+11]]+kt[s[t+12]]+kt[s[t+13]]+kt[s[t+14]]+kt[s[t+15]]}const Bo={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ji(s,t,e){if(Bo.randomUUID&&!t&&!s)return Bo.randomUUID();s=s||{};const i=s.random||(s.rng||ou)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let r=0;r<16;++r)t[e+r]=i[r];return t}return lu(i)}const hu=2e3;class du{constructor(t){this._tabId=void 0,this._clientId=void 0,this._visitorId=void 0,this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamedTime={},this._streamedPrevTimestamp={},this._createVisitor=e=>{var r,n;const{publicApiUrl:i}=Fr(this.host.env);return(n=(r=window.localStorage)==null?void 0:r.setItem)==null||n.call(r,"vouch-uid-visitor",e),navigator.sendBeacon(`${i}/api/visitor`,JSON.stringify({visitorId:e})),e},this._getReportingMetadata=()=>{var n,a;const[e,i]=((a=(n=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:n.split)==null?void 0:a.call(n,"/"))??[],r={};return[...new URLSearchParams(location.search).entries()].forEach(([o,l])=>{if(/utm/.test(o)){const h=o.toLowerCase().replace(/[-_][a-z0-9]/g,d=>d.slice(-1).toUpperCase());r[h]=l}}),{source:"media_player",time:new Date,region:i,country:e,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,...r}},this._sendTrackingEvent=(e,i)=>{const{publicApiUrl:r}=Fr(this.host.env),{client:n,tab:a,request:o,visitor:l}=this._getUids();navigator.sendBeacon(`${r}/api/events`,JSON.stringify({event:e,payload:i,context:{"x-uid-client":n,"x-uid-tab":a,"x-uid-request":o,"x-uid-visitor":l,"x-reporting-metadata":this._getReportingMetadata()}}))},this._handleVouchLoaded=({detail:e})=>{e&&(this._hasLoaded[e]||(this._sendTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{const e=this._findVouchId();e&&(this._hasPlayed||(this._sendTrackingEvent("VIDEO_PLAYED",{vouchId:e,streamStart:this.host.currentTime}),this._hasPlayed=!0))},this._handleVideoPlay=({detail:{id:e,node:i}})=>{const r=this._findVouchId();r&&(this._answersViewed[e]||(this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED",{vouchId:r,answerId:e}),this._answersViewed[e]=!0),this._streamedTime[e]=i.currentTime,this._streamedPrevTimestamp[e]=Date.now())},this._handleVideoTimeUpdate=({detail:{id:e,node:i}})=>{var a,o;const r=this._findVouchId();if(!r)return;const n=Date.now();!this.host.paused&&e===((o=(a=this.host.scene)==null?void 0:a.video)==null?void 0:o.id)&&n-this._streamedPrevTimestamp[e]>hu&&(this._sendTrackingEvent("VIDEO_STREAMED",{vouchId:r,answerId:e,streamStart:this._streamedTime[e],streamEnd:i.currentTime}),this._streamedTime[e]=i.currentTime,this._streamedPrevTimestamp[e]=n)},this._handleVideoPause=({detail:{id:e,node:i}})=>{const r=this._findVouchId();r&&(this._sendTrackingEvent("VIDEO_STREAMED",{vouchId:r,answerId:e,streamStart:this._streamedTime[e],streamEnd:i.currentTime}),delete this._streamedTime[e],delete this._streamedPrevTimestamp[e])},this.host=t,t.addController(this)}_findVouchId(){if(this.host.data)return"uuid"in this.host.data?this.host.data.uuid:this.host.data.id}_getUids(){var n,a,o,l,h,d,c,u,f,p,g,m;if(typeof window>"u")return{client:null,tab:null,request:Ji()};const t=this._visitorId||((a=(n=window.localStorage)==null?void 0:n.getItem)==null?void 0:a.call(n,"vouch-uid-visitor"))||this._createVisitor(Ji()),e=this._clientId||((l=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:l.call(o,"vouch-uid-client"))||Ji(),i=this._tabId||((d=(h=window.sessionStorage)==null?void 0:h.getItem)==null?void 0:d.call(h,"vouch-uid-tab"))||Ji(),r=Ji();return t!==this._visitorId&&(this._visitorId=t,(u=(c=window.localStorage)==null?void 0:c.setItem)==null||u.call(c,"vouch-uid-visitor",t)),e!==this._clientId&&(this._clientId=e,(p=(f=window.localStorage)==null?void 0:f.setItem)==null||p.call(f,"vouch-uid-client",e)),i!==this._tabId&&(this._tabId=i,(m=(g=window.sessionStorage)==null?void 0:g.setItem)==null||m.call(g,"vouch-uid-tab",i)),{client:e,tab:i,request:r,visitor:t}}hostConnected(){requestAnimationFrame(()=>{var t,e,i,r;this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.addEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.addEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.addEventListener("video:pause",this._handleVideoPause),(r=this.host.mediaPlayer)==null||r.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,i,r;this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.removeEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.removeEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.removeEventListener("video:pause",this._handleVideoPause),(r=this.host.mediaPlayer)==null||r.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}var Ho=new Function("return this")().Promise,on=!1;try{on=new Function("return (async function(){}).constructor")()}catch(s){if(!(s instanceof SyntaxError))throw s}function Go(s,t){return Object.prototype.hasOwnProperty.call(s,t)}function Qi(s,t,e){for(var i in t)Go(t,i)&&(t[i]!=null&&typeof t[i]=="object"&&(i==="storage"||i==="prefixes")&&!e?s[i]=Qi({},t[i]):s[i]=t[i]);return s}function cu(s,t,e,i){var r,n;return typeof t.autoTrim=="string"?r=n=t.autoTrim:Array.isArray(t.autoTrim)&&(r=t.autoTrim[1],n=t.autoTrim[0]),(e||e===!1)&&(r=e),(i||i===!1)&&(n=i),r==="slurp"&&n==="slurp"?s.trim():(r==="_"||r==="slurp"?String.prototype.trimLeft?s=s.trimLeft():s=s.replace(/^[\s\uFEFF\xA0]+/,""):(r==="-"||r==="nl")&&(s=s.replace(/^(?:\n|\r|\r\n)/,"")),n==="_"||n==="slurp"?String.prototype.trimRight?s=s.trimRight():s=s.replace(/[\s\uFEFF\xA0]+$/,""):(n==="-"||n==="nl")&&(s=s.replace(/(?:\n|\r|\r\n)$/,"")),s)}var Ur=function(){function s(t){this.cache=t}return s.prototype.define=function(t,e){this.cache[t]=e},s.prototype.get=function(t){return this.cache[t]},s.prototype.remove=function(t){delete this.cache[t]},s.prototype.reset=function(){this.cache={}},s.prototype.load=function(t){Qi(this.cache,t,!0)},s}();function uu(s,t){Object.setPrototypeOf?Object.setPrototypeOf(s,t):s.__proto__=t}function Dt(s){var t=new Error(s);return uu(t,Dt.prototype),t}Dt.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});function Pe(s,t,e){var i=t.slice(0,e).split(/\n/),r=i.length,n=i[r-1].length+1;throw s+=" at line "+r+" col "+n+`:
|
73
|
+
*/const Wc=Symbol();let Uo=class{get taskComplete(){return this.t||(this.status===1?this.t=new Promise((t,e)=>{this.i=t,this.o=e}):this.status===3?this.t=Promise.reject(this.h):this.t=Promise.resolve(this.l)),this.t}constructor(t,e,i){var n;this.u=0,this.status=0,(this.p=t).addController(this);const s=typeof e=="object"?e:{task:e,args:i};this._=s.task,this.v=s.args,this.j=s.argsEqual??Yc,this.m=s.onComplete,this.g=s.onError,this.autoRun=s.autoRun??!0,"initialValue"in s&&(this.l=s.initialValue,this.status=2,this.k=(n=this.A)==null?void 0:n.call(this))}hostUpdate(){this.autoRun===!0&&this.O()}hostUpdated(){this.autoRun==="afterUpdate"&&this.O()}A(){if(this.v===void 0)return;const t=this.v();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async O(){const t=this.A(),e=this.k;this.k=t,t===e||t===void 0||e!==void 0&&this.j(e,t)||await this.run(t)}async run(t){var a,o,l,h,d;let e,i;t??(t=this.A()),this.k=t,this.status===1?(a=this.T)==null||a.abort():(this.t=void 0,this.i=void 0,this.o=void 0),this.status=1,this.autoRun==="afterUpdate"?queueMicrotask(()=>this.p.requestUpdate()):this.p.requestUpdate();const s=++this.u;this.T=new AbortController;let n=!1;try{e=await this._(t,{signal:this.T.signal})}catch(c){n=!0,i=c}if(this.u===s){if(e===Wc)this.status=0;else{if(n===!1){try{(o=this.m)==null||o.call(this,e)}catch{}this.status=2,(l=this.i)==null||l.call(this,e)}else{try{(h=this.g)==null||h.call(this,i)}catch{}this.status=3,(d=this.o)==null||d.call(this,i)}this.l=e,this.h=i}this.p.requestUpdate()}}abort(t){var e;this.status===1&&((e=this.T)==null||e.abort(t))}get value(){return this.l}get error(){return this.h}render(t){var e,i,s,n;switch(this.status){case 0:return(e=t.initial)==null?void 0:e.call(t);case 1:return(i=t.pending)==null?void 0:i.call(t);case 2:return(s=t.complete)==null?void 0:s.call(t,this.value);case 3:return(n=t.error)==null?void 0:n.call(t,this.error);default:throw Error("Unexpected status: "+this.status)}}};const Yc=(r,t)=>r===t||r.length===t.length&&r.every((e,i)=>!rn(e,t[i])),nn="https://vouchfor.com",Xc="https://d2rxhdlm2q91uk.cloudfront.net",qc="https://d1ix11aj5kfygl.cloudfront.net",Zc="https://d157jlwnudd93d.cloudfront.net",Jc="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",Qc="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",_c="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",$c="http://localhost:6060/v1",tu="https://embed-staging.vouchfor.com/v1",eu="https://embed.vouchfor.com/v1",iu="https://dev.vouchfor.com",su="https://staging.vouchfor.com",ru="https://app.vouchfor.com";function Fs(r){if(!["dev","staging","prod"].includes(r))throw new Error(`Unknown environment: ${r}`);if(r==="dev")return{marketingUrl:nn,videoUrl:Xc,publicApiUrl:Jc,embedApiUrl:$c,publicRecorderUrl:iu};if(r==="staging")return{marketingUrl:nn,videoUrl:qc,publicApiUrl:Qc,embedApiUrl:tu,publicRecorderUrl:su};if(r==="prod")return{marketingUrl:nn,videoUrl:Zc,publicApiUrl:_c,embedApiUrl:eu,publicRecorderUrl:ru}}class nu{constructor(t){this._fetching=!1,this.host=t,new Uo(this.host,async([e,i,s,n,a])=>{var o,l,h,d;try{if(this.vouch=void 0,this.template=void 0,s){const c=await this.getTemplate(e,i,a);this.vouch=s,this.template=((l=(o=s==null?void 0:s.settings)==null?void 0:o.template)==null?void 0:l.instance)??c}else if(n){this.fetching=!0;const[c,u]=await Promise.all([this.getVouch(e,i,n),this.getTemplate(e,i,a)]);this.vouch=c,this.template=((d=(h=c==null?void 0:c.settings)==null?void 0:h.template)==null?void 0:d.instance)??u}}finally{this.fetching=!1}},()=>[t.env,t.apiKey,t.data,t.vouchId,t.templateId])}set fetching(t){this._fetching!==t&&(this._fetching=t,this.host.requestUpdate())}get fetching(){return this._fetching}set vouch(t){this._vouch!==t&&(this._vouch=t,this.host.requestUpdate())}get vouch(){return this._vouch}set template(t){this._template!==t&&(this._template=t,this.host.requestUpdate())}get template(){return this._template}async getVouch(t,e,i){const{embedApiUrl:s}=Fs(t);return i?fetch(`${s}/vouches/${i}`,{method:"GET",headers:[["X-Api-Key",e]]}).then(n=>n.json()):null}async getTemplate(t,e,i){const{embedApiUrl:s}=Fs(t);return i?fetch(`${s}/templates/${i}`,{method:"GET",headers:[["X-Api-Key",e]]}).then(n=>n.json()):null}}let Ns;const au=new Uint8Array(16);function ou(){if(!Ns&&(Ns=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ns))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ns(au)}const kt=[];for(let r=0;r<256;++r)kt.push((r+256).toString(16).slice(1));function lu(r,t=0){return kt[r[t+0]]+kt[r[t+1]]+kt[r[t+2]]+kt[r[t+3]]+"-"+kt[r[t+4]]+kt[r[t+5]]+"-"+kt[r[t+6]]+kt[r[t+7]]+"-"+kt[r[t+8]]+kt[r[t+9]]+"-"+kt[r[t+10]]+kt[r[t+11]]+kt[r[t+12]]+kt[r[t+13]]+kt[r[t+14]]+kt[r[t+15]]}const Bo={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ji(r,t,e){if(Bo.randomUUID&&!t&&!r)return Bo.randomUUID();r=r||{};const i=r.random||(r.rng||ou)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let s=0;s<16;++s)t[e+s]=i[s];return t}return lu(i)}const hu=2e3;class du{constructor(t){this._tabId=void 0,this._clientId=void 0,this._visitorId=void 0,this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamedTime={},this._streamedPrevTimestamp={},this._createVisitor=e=>{var s,n;const{publicApiUrl:i}=Fs(this.host.env);return(n=(s=window.localStorage)==null?void 0:s.setItem)==null||n.call(s,"vouch-uid-visitor",e),navigator.sendBeacon(`${i}/api/visitor`,JSON.stringify({visitorId:e})),e},this._getReportingMetadata=()=>{var n,a;const[e,i]=((a=(n=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:n.split)==null?void 0:a.call(n,"/"))??[],s={};return[...new URLSearchParams(location.search).entries()].forEach(([o,l])=>{if(/utm/.test(o)){const h=o.toLowerCase().replace(/[-_][a-z0-9]/g,d=>d.slice(-1).toUpperCase());s[h]=l}}),{source:"media_player",time:new Date,region:i,country:e,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,...s}},this._sendTrackingEvent=(e,i)=>{const{publicApiUrl:s}=Fs(this.host.env),{client:n,tab:a,request:o,visitor:l}=this._getUids();navigator.sendBeacon(`${s}/api/events`,JSON.stringify({event:e,payload:i,context:{"x-uid-client":n,"x-uid-tab":a,"x-uid-request":o,"x-uid-visitor":l,"x-reporting-metadata":this._getReportingMetadata()}}))},this._handleVouchLoaded=({detail:e})=>{e&&(this._hasLoaded[e]||(this._sendTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{const e=this._findVouchId();e&&(this._hasPlayed||(this._sendTrackingEvent("VIDEO_PLAYED",{vouchId:e,streamStart:this.host.currentTime}),this._hasPlayed=!0))},this._handleVideoPlay=({detail:{id:e,node:i}})=>{const s=this._findVouchId();s&&(this._answersViewed[e]||(this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED",{vouchId:s,answerId:e}),this._answersViewed[e]=!0),this._streamedTime[e]=i.currentTime,this._streamedPrevTimestamp[e]=Date.now())},this._handleVideoTimeUpdate=({detail:{id:e,node:i}})=>{var a,o;const s=this._findVouchId();if(!s)return;const n=Date.now();!this.host.paused&&e===((o=(a=this.host.scene)==null?void 0:a.video)==null?void 0:o.id)&&n-this._streamedPrevTimestamp[e]>hu&&(this._sendTrackingEvent("VIDEO_STREAMED",{vouchId:s,answerId:e,streamStart:this._streamedTime[e],streamEnd:i.currentTime}),this._streamedTime[e]=i.currentTime,this._streamedPrevTimestamp[e]=n)},this._handleVideoPause=({detail:{id:e,node:i}})=>{const s=this._findVouchId();s&&(this._sendTrackingEvent("VIDEO_STREAMED",{vouchId:s,answerId:e,streamStart:this._streamedTime[e],streamEnd:i.currentTime}),delete this._streamedTime[e],delete this._streamedPrevTimestamp[e])},this.host=t,t.addController(this)}_findVouchId(){if(this.host.data)return"uuid"in this.host.data?this.host.data.uuid:this.host.data.id}_getUids(){var n,a,o,l,h,d,c,u,f,p,g,m;if(typeof window>"u")return{client:null,tab:null,request:Ji()};const t=this._visitorId||((a=(n=window.localStorage)==null?void 0:n.getItem)==null?void 0:a.call(n,"vouch-uid-visitor"))||this._createVisitor(Ji()),e=this._clientId||((l=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:l.call(o,"vouch-uid-client"))||Ji(),i=this._tabId||((d=(h=window.sessionStorage)==null?void 0:h.getItem)==null?void 0:d.call(h,"vouch-uid-tab"))||Ji(),s=Ji();return t!==this._visitorId&&(this._visitorId=t,(u=(c=window.localStorage)==null?void 0:c.setItem)==null||u.call(c,"vouch-uid-visitor",t)),e!==this._clientId&&(this._clientId=e,(p=(f=window.localStorage)==null?void 0:f.setItem)==null||p.call(f,"vouch-uid-client",e)),i!==this._tabId&&(this._tabId=i,(m=(g=window.sessionStorage)==null?void 0:g.setItem)==null||m.call(g,"vouch-uid-tab",i)),{client:e,tab:i,request:s,visitor:t}}hostConnected(){requestAnimationFrame(()=>{var t,e,i,s;this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.addEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.addEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.addEventListener("video:pause",this._handleVideoPause),(s=this.host.mediaPlayer)==null||s.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,i,s;this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.removeEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.removeEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.removeEventListener("video:pause",this._handleVideoPause),(s=this.host.mediaPlayer)==null||s.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}var Ho=new Function("return this")().Promise,an=!1;try{an=new Function("return (async function(){}).constructor")()}catch(r){if(!(r instanceof SyntaxError))throw r}function Go(r,t){return Object.prototype.hasOwnProperty.call(r,t)}function Qi(r,t,e){for(var i in t)Go(t,i)&&(t[i]!=null&&typeof t[i]=="object"&&(i==="storage"||i==="prefixes")&&!e?r[i]=Qi({},t[i]):r[i]=t[i]);return r}function cu(r,t,e,i){var s,n;return typeof t.autoTrim=="string"?s=n=t.autoTrim:Array.isArray(t.autoTrim)&&(s=t.autoTrim[1],n=t.autoTrim[0]),(e||e===!1)&&(s=e),(i||i===!1)&&(n=i),s==="slurp"&&n==="slurp"?r.trim():(s==="_"||s==="slurp"?String.prototype.trimLeft?r=r.trimLeft():r=r.replace(/^[\s\uFEFF\xA0]+/,""):(s==="-"||s==="nl")&&(r=r.replace(/^(?:\n|\r|\r\n)/,"")),n==="_"||n==="slurp"?String.prototype.trimRight?r=r.trimRight():r=r.replace(/[\s\uFEFF\xA0]+$/,""):(n==="-"||n==="nl")&&(r=r.replace(/(?:\n|\r|\r\n)$/,"")),r)}var Us=function(){function r(t){this.cache=t}return r.prototype.define=function(t,e){this.cache[t]=e},r.prototype.get=function(t){return this.cache[t]},r.prototype.remove=function(t){delete this.cache[t]},r.prototype.reset=function(){this.cache={}},r.prototype.load=function(t){Qi(this.cache,t,!0)},r}();function uu(r,t){Object.setPrototypeOf?Object.setPrototypeOf(r,t):r.__proto__=t}function Dt(r){var t=new Error(r);return uu(t,Dt.prototype),t}Dt.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});function Pe(r,t,e){var i=t.slice(0,e).split(/\n/),s=i.length,n=i[s-1].length+1;throw r+=" at line "+s+" col "+n+`:
|
74
74
|
|
75
|
-
`+t.split(/\n/)[
|
76
|
-
`+Array(n).join(" ")+"^",Dt(
|
77
|
-
`).replace(/^\s+|\s+$/gm,"")),
|
78
|
-
`)}}return
|
75
|
+
`+t.split(/\n/)[s-1]+`
|
76
|
+
`+Array(n).join(" ")+"^",Dt(r)}var Oe=/^async +/,Bs=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,Hs=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,Gs=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,Vo=/[.*+\-?^${}()|[\]\\]/g;function Vs(r){return Vo.test(r)?r.replace(Vo,"\\$&"):r}function fu(r,t){t.rmWhitespace&&(r=r.replace(/[\r\n]+/g,`
|
77
|
+
`).replace(/^\s+|\s+$/gm,"")),Bs.lastIndex=0,Hs.lastIndex=0,Gs.lastIndex=0;var e=t.prefixes,i=[e.h,e.b,e.i,e.r,e.c,e.e].reduce(function(f,p){return f&&p?f+"|"+Vs(p):p?Vs(p):f},""),s=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+Vs(t.tags[1])+")","g"),n=new RegExp("([^]*?)"+Vs(t.tags[0])+"(-|_)?\\s*("+i+")?\\s*","g"),a=0,o=!1;function l(f,p){var g={f:[]},m=0,b="c";p==="h"||p==="b"||p==="c"?b="n":p==="r"&&(g.raw=!0,p="i");function A(W){var w=r.slice(a,W),I=w.trim();if(b==="f")I==="safe"?g.raw=!0:t.async&&Oe.test(I)?(I=I.replace(Oe,""),g.f.push([I,"",!0])):g.f.push([I,""]);else if(b==="fp")g.f[g.f.length-1][1]+=I;else if(b==="err"){if(I){var B=w.search(/\S/);Pe("invalid syntax",r,a+B)}}else g[b]=I;a=W+1}s.lastIndex=a;for(var T;(T=s.exec(r))!==null;){var y=T[1],E=T[2],S=T[3],L=T[4],D=T[5],k=T.index;if(y)y==="("?(m===0&&(b==="n"?(A(k),b="p"):b==="f"&&(A(k),b="fp")),m++):y===")"?(m--,m===0&&b!=="c"&&(A(k),b="err")):m===0&&y==="|"?(A(k),b="f"):y==="=>"&&(A(k),a+=1,b="res");else if(E){if(E==="/*"){var x=r.indexOf("*/",s.lastIndex);x===-1&&Pe("unclosed comment",r,T.index),s.lastIndex=x+2}else if(E==="'"){Hs.lastIndex=T.index;var F=Hs.exec(r);F?s.lastIndex=Hs.lastIndex:Pe("unclosed string",r,T.index)}else if(E==='"'){Gs.lastIndex=T.index;var O=Gs.exec(r);O?s.lastIndex=Gs.lastIndex:Pe("unclosed string",r,T.index)}else if(E==="`"){Bs.lastIndex=T.index;var G=Bs.exec(r);G?s.lastIndex=Bs.lastIndex:Pe("unclosed string",r,T.index)}}else if(S)return A(k),a=k+T[0].length,n.lastIndex=a,o=D,L&&p==="h"&&(p="s"),g.t=p,g}return Pe("unclosed tag",r,f),g}function h(f,p){f.b=[],f.d=[];var g=!1,m=[];function b(G,W){G&&(G=cu(G,t,o,W),G&&(G=G.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),m.push(G)))}for(var A;(A=n.exec(r))!==null;){var T=A[1],y=A[2],E=A[3]||"",S;for(var L in e)if(e[L]===E){S=L;break}b(T,y),a=A.index+A[0].length,S||Pe("unrecognized tag type: "+E,r,a);var D=l(A.index,S),k=D.t;if(k==="h"){var x=D.n||"";t.async&&Oe.test(x)&&(D.a=!0,D.n=x.replace(Oe,"")),D=h(D),m.push(D)}else if(k==="c"){if(f.n===D.n)return g?(g.d=m,f.b.push(g)):f.d=m,f;Pe("Helper start and end don't match",r,A.index+A[0].length)}else if(k==="b"){g?(g.d=m,f.b.push(g)):f.d=m;var F=D.n||"";t.async&&Oe.test(F)&&(D.a=!0,D.n=F.replace(Oe,"")),g=D,m=[]}else if(k==="s"){var O=D.n||"";t.async&&Oe.test(O)&&(D.a=!0,D.n=O.replace(Oe,"")),m.push(D)}else m.push(D)}if(p)b(r.slice(a,r.length),!1),f.d=m;else throw Dt('unclosed helper "'+f.n+'"');return f}var d=h({f:[]},!0);if(t.plugins)for(var c=0;c<t.plugins.length;c++){var u=t.plugins[c];u.processAST&&(d.d=u.processAST(d.d,t))}return d.d}function jo(r,t){var e=fu(r,t),i="var tR='';"+(t.useWith?"with("+t.varName+"||{}){":"")+Qe(e,t)+"if(cb){cb(null,tR)} return tR"+(t.useWith?"}":"");if(t.plugins)for(var s=0;s<t.plugins.length;s++){var n=t.plugins[s];n.processFnString&&(i=n.processFnString(i,t))}return i}function on(r,t){for(var e=0;e<t.length;e++){var i=t[e][0],s=t[e][1],n=t[e][2];r=(n?"await ":"")+"c.l('F','"+i+"')("+r,s&&(r+=","+s),r+=")"}return r}function zo(r,t,e,i,s,n){var a="{exec:"+(s?"async ":"")+Ko(e,t,r)+",params:["+i+"]";return n&&(a+=",name:'"+n+"'"),s&&(a+=",async:true"),a+="}",a}function pu(r,t){for(var e="[",i=0;i<r.length;i++){var s=r[i];e+=zo(t,s.res||"",s.d,s.p||"",s.a,s.n),i<r.length&&(e+=",")}return e+="]",e}function Ko(r,t,e){return"function("+t+"){var tR='';"+Qe(r,e)+"return tR}"}function Qe(r,t){var e=0,i=r.length,s="";for(e;e<i;e++){var n=r[e];if(typeof n=="string"){var a=n;s+="tR+='"+a+"';"}else{var o=n.t,l=n.c||"",h=n.f,d=n.n||"",c=n.p||"",u=n.res||"",f=n.b,p=!!n.a;if(o==="i"){t.defaultFilter&&(l="c.l('F','"+t.defaultFilter+"')("+l+")");var g=on(l,h);!n.raw&&t.autoEscape&&(g="c.l('F','e')("+g+")"),s+="tR+="+g+";"}else if(o==="h")if(t.storage.nativeHelpers.get(d))s+=t.storage.nativeHelpers.get(d)(n,t);else{var m=(p?"await ":"")+"c.l('H','"+d+"')("+zo(t,u,n.d,c,p);f?m+=","+pu(f,t):m+=",[]",m+=",c)",s+="tR+="+on(m,h)+";"}else o==="s"?s+="tR+="+on((p?"await ":"")+"c.l('H','"+d+"')({params:["+c+"]},[],c)",h)+";":o==="e"&&(s+=l+`
|
78
|
+
`)}}return s}function _e(r,t,e,i){if(t&&t.length>0)throw Dt((i?"Native":"")+"Helper '"+r+"' doesn't accept blocks");if(e&&e.length>0)throw Dt((i?"Native":"")+"Helper '"+r+"' doesn't accept filters")}function Wo(r,t,e,i,s){e(r[t],t).then(function(n){i+=n,t===r.length-1?s(i):Wo(r,t+1,e,i,s)})}function Yo(r,t,e,i,s,n){i(t[e],r[t[e]]).then(function(a){s+=a,e===t.length-1?n(s):Yo(r,t,e+1,i,s,n)})}var gu={"&":"&","<":"<",">":">",'"':""","'":"'"};function mu(r){return gu[r]}function vu(r){var t=String(r);return/[&<>"']/.test(t)?t.replace(/[&<>"']/g,mu):t}var yu=new Us({}),_i=new Us({each:function(r,t){var e="",i=r.params[0];if(_e("each",t,!1),r.async)return new Promise(function(n){Wo(i,0,r.exec,e,n)});for(var s=0;s<i.length;s++)e+=r.exec(i[s],s);return e},foreach:function(r,t){var e=r.params[0];if(_e("foreach",t,!1),r.async)return new Promise(function(n){Yo(e,Object.keys(e),0,r.exec,"",n)});var i="";for(var s in e)Go(e,s)&&(i+=r.exec(s,e[s]));return i},include:function(r,t,e){_e("include",t,!1);var i=e.storage.templates.get(r.params[0]);if(!i)throw Dt('Could not fetch template "'+r.params[0]+'"');return i(r.params[1],e)},extends:function(r,t,e){var i=r.params[1]||{};i.content=r.exec();for(var s=0;s<t.length;s++){var n=t[s];i[n.name]=n.exec()}var a=e.storage.templates.get(r.params[0]);if(!a)throw Dt('Could not fetch template "'+r.params[0]+'"');return a(i,e)},useScope:function(r,t){return _e("useScope",t,!1),r.exec(r.params[0])}}),bu=new Us({if:function(r,t){_e("if",!1,r.f,!0);var e="if("+r.p+"){"+Qe(r.d,t)+"}";if(r.b)for(var i=0;i<r.b.length;i++){var s=r.b[i];s.n==="else"?e+="else{"+Qe(s.d,t)+"}":s.n==="elif"&&(e+="else if("+s.p+"){"+Qe(s.d,t)+"}")}return e},try:function(r,t){if(_e("try",!1,r.f,!0),!r.b||r.b.length!==1||r.b[0].n!=="catch")throw Dt("native helper 'try' only accepts 1 block, 'catch'");var e="try{"+Qe(r.d,t)+"}",i=r.b[0];return e+="catch"+(i.res?"("+i.res+")":"")+"{"+Qe(i.d,t)+"}",e},block:function(r,t){_e("block",r.b,r.f,!0);var e="if(!"+t.varName+"["+r.p+"]){tR+=("+Ko(r.d,"",t)+")()}else{tR+="+t.varName+"["+r.p+"]}";return e}}),js=new Us({e:vu}),ln={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(r,t){if(r==="H"){var e=this.storage.helpers.get(t);if(e)return e;throw Dt("Can't find helper '"+t+"'")}else if(r==="F"){var i=this.storage.filters.get(t);if(i)return i;throw Dt("Can't find filter '"+t+"'")}},async:!1,storage:{helpers:_i,nativeHelpers:bu,filters:js,templates:yu},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};ln.l.bind(ln);function $i(r,t){var e={};return Qi(e,ln),t&&Qi(e,t),r&&Qi(e,r),e.l.bind(e),e}function hn(r,t){var e=$i(t||{}),i=Function;if(e.async)if(an)i=an;else throw Dt("This environment doesn't support async/await");try{return new i(e.varName,"c","cb",jo(r,e))}catch(s){throw s instanceof SyntaxError?Dt(`Bad template syntax
|
79
79
|
|
80
|
-
`+
|
81
|
-
`+Array(
|
82
|
-
`+jo(
|
83
|
-
`)===0?U.substr(1,U.length):U}).forEach(function(U){var H=U.split(":"),
|
80
|
+
`+s.message+`
|
81
|
+
`+Array(s.message.length+1).join("=")+`
|
82
|
+
`+jo(r,e)):s}}var dn=require("fs"),cn=require("path"),Au=/^\uFEFF/;function un(r,t,e){var i=cn.resolve(e?t:cn.dirname(t),r),s=cn.extname(r);return s||(i+=".sqrl"),i}function Tu(r,t){var e,i,s=t.views,n=/^[A-Za-z]+:\\|^\//.exec(r);if(n&&n.length)e=un(r.replace(/^\/*/,""),t.root||"/",!0);else if(t.filename&&(i=un(r,t.filename),dn.existsSync(i)&&(e=i)),e||Array.isArray(s)&&s.some(function(a){return i=un(r,a,!0),dn.existsSync(i)})&&(e=i),!e)throw Dt('Could not find the include file "'+r+'"');return e}function Xo(r){return dn.readFileSync(r).toString().replace(Au,"")}function Eu(r,t){var e=$i(t),i=Xo(r);try{var s=hn(i,e);return e.storage.templates.define(e.filename,s),s}catch{throw Dt("Loading file: "+r+" failed")}}function wu(r){var t=r.filename;if(r.cache){var e=r.storage.templates.get(t);return e||Eu(t,r)}return hn(Xo(t),r)}function qo(r,t){var e=$i({filename:Tu(r,t)},t);return wu(e)}function Su(r,t,e){if(t&&t.length>0)throw Dt("Helper 'includeFile' doesn't accept blocks");return qo(r.params[0],e)(r.params[1],e)}function Lu(r,t,e){var i=r.params[1]||{};i.content=r.exec();for(var s=0;s<t.length;s++){var n=t[s];i[n.name]=n.exec()}return qo(r.params[0],e)(i,e)}function fn(r,t){var e;return t.cache&&t.name&&t.storage.templates.get(t.name)?t.storage.templates.get(t.name):(typeof r=="function"?e=r:e=hn(r,t),t.cache&&t.name&&t.storage.templates.define(t.name,e),e)}function Ru(r,t,e,i){var s=$i(e||{});if(s.async){var n;if(i)try{fn(r,s)(t,s,i)}catch(a){return i(a)}else{if(typeof Ho=="function")return new Ho(function(a,o){try{n=fn(r,s)(t,s),a(n)}catch(l){o(l)}});throw Dt("Please provide a callback function, this env doesn't support Promises")}}else return fn(r,s)(t,s)}_i.define("includeFile",Su),_i.define("extendsFile",Lu);var pn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function gn(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var mn={exports:{}};(function(r,t){var e=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof pn<"u"&&pn,i=function(){function n(){this.fetch=!1,this.DOMException=e.DOMException}return n.prototype=e,new n}();(function(n){(function(a){var o=typeof n<"u"&&n||typeof self<"u"&&self||typeof o<"u"&&o,l={searchParams:"URLSearchParams"in o,iterable:"Symbol"in o&&"iterator"in Symbol,blob:"FileReader"in o&&"Blob"in o&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in o,arrayBuffer:"ArrayBuffer"in o};function h(w){return w&&DataView.prototype.isPrototypeOf(w)}if(l.arrayBuffer)var d=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(w){return w&&d.indexOf(Object.prototype.toString.call(w))>-1};function u(w){if(typeof w!="string"&&(w=String(w)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(w)||w==="")throw new TypeError('Invalid character in header field name: "'+w+'"');return w.toLowerCase()}function f(w){return typeof w!="string"&&(w=String(w)),w}function p(w){var I={next:function(){var B=w.shift();return{done:B===void 0,value:B}}};return l.iterable&&(I[Symbol.iterator]=function(){return I}),I}function g(w){this.map={},w instanceof g?w.forEach(function(I,B){this.append(B,I)},this):Array.isArray(w)?w.forEach(function(I){this.append(I[0],I[1])},this):w&&Object.getOwnPropertyNames(w).forEach(function(I){this.append(I,w[I])},this)}g.prototype.append=function(w,I){w=u(w),I=f(I);var B=this.map[w];this.map[w]=B?B+", "+I:I},g.prototype.delete=function(w){delete this.map[u(w)]},g.prototype.get=function(w){return w=u(w),this.has(w)?this.map[w]:null},g.prototype.has=function(w){return this.map.hasOwnProperty(u(w))},g.prototype.set=function(w,I){this.map[u(w)]=f(I)},g.prototype.forEach=function(w,I){for(var B in this.map)this.map.hasOwnProperty(B)&&w.call(I,this.map[B],B,this)},g.prototype.keys=function(){var w=[];return this.forEach(function(I,B){w.push(B)}),p(w)},g.prototype.values=function(){var w=[];return this.forEach(function(I){w.push(I)}),p(w)},g.prototype.entries=function(){var w=[];return this.forEach(function(I,B){w.push([B,I])}),p(w)},l.iterable&&(g.prototype[Symbol.iterator]=g.prototype.entries);function m(w){if(w.bodyUsed)return Promise.reject(new TypeError("Already read"));w.bodyUsed=!0}function b(w){return new Promise(function(I,B){w.onload=function(){I(w.result)},w.onerror=function(){B(w.error)}})}function A(w){var I=new FileReader,B=b(I);return I.readAsArrayBuffer(w),B}function T(w){var I=new FileReader,B=b(I);return I.readAsText(w),B}function y(w){for(var I=new Uint8Array(w),B=new Array(I.length),U=0;U<I.length;U++)B[U]=String.fromCharCode(I[U]);return B.join("")}function E(w){if(w.slice)return w.slice(0);var I=new Uint8Array(w.byteLength);return I.set(new Uint8Array(w)),I.buffer}function S(){return this.bodyUsed=!1,this._initBody=function(w){this.bodyUsed=this.bodyUsed,this._bodyInit=w,w?typeof w=="string"?this._bodyText=w:l.blob&&Blob.prototype.isPrototypeOf(w)?this._bodyBlob=w:l.formData&&FormData.prototype.isPrototypeOf(w)?this._bodyFormData=w:l.searchParams&&URLSearchParams.prototype.isPrototypeOf(w)?this._bodyText=w.toString():l.arrayBuffer&&l.blob&&h(w)?(this._bodyArrayBuffer=E(w.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):l.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(w)||c(w))?this._bodyArrayBuffer=E(w):this._bodyText=w=Object.prototype.toString.call(w):this._bodyText="",this.headers.get("content-type")||(typeof w=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):l.searchParams&&URLSearchParams.prototype.isPrototypeOf(w)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},l.blob&&(this.blob=function(){var w=m(this);if(w)return w;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var w=m(this);return w||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(A)}),this.text=function(){var w=m(this);if(w)return w;if(this._bodyBlob)return T(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(y(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},l.formData&&(this.formData=function(){return this.text().then(x)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function D(w){var I=w.toUpperCase();return L.indexOf(I)>-1?I:w}function k(w,I){if(!(this instanceof k))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');I=I||{};var B=I.body;if(w instanceof k){if(w.bodyUsed)throw new TypeError("Already read");this.url=w.url,this.credentials=w.credentials,I.headers||(this.headers=new g(w.headers)),this.method=w.method,this.mode=w.mode,this.signal=w.signal,!B&&w._bodyInit!=null&&(B=w._bodyInit,w.bodyUsed=!0)}else this.url=String(w);if(this.credentials=I.credentials||this.credentials||"same-origin",(I.headers||!this.headers)&&(this.headers=new g(I.headers)),this.method=D(I.method||this.method||"GET"),this.mode=I.mode||this.mode||null,this.signal=I.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&B)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(B),(this.method==="GET"||this.method==="HEAD")&&(I.cache==="no-store"||I.cache==="no-cache")){var U=/([?&])_=[^&]*/;if(U.test(this.url))this.url=this.url.replace(U,"$1_="+new Date().getTime());else{var H=/\?/;this.url+=(H.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}k.prototype.clone=function(){return new k(this,{body:this._bodyInit})};function x(w){var I=new FormData;return w.trim().split("&").forEach(function(B){if(B){var U=B.split("="),H=U.shift().replace(/\+/g," "),V=U.join("=").replace(/\+/g," ");I.append(decodeURIComponent(H),decodeURIComponent(V))}}),I}function F(w){var I=new g,B=w.replace(/\r?\n[\t ]+/g," ");return B.split("\r").map(function(U){return U.indexOf(`
|
83
|
+
`)===0?U.substr(1,U.length):U}).forEach(function(U){var H=U.split(":"),V=H.shift().trim();if(V){var J=H.join(":").trim();I.append(V,J)}}),I}S.call(k.prototype);function O(w,I){if(!(this instanceof O))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');I||(I={}),this.type="default",this.status=I.status===void 0?200:I.status,this.ok=this.status>=200&&this.status<300,this.statusText=I.statusText===void 0?"":""+I.statusText,this.headers=new g(I.headers),this.url=I.url||"",this._initBody(w)}S.call(O.prototype),O.prototype.clone=function(){return new O(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new g(this.headers),url:this.url})},O.error=function(){var w=new O(null,{status:0,statusText:""});return w.type="error",w};var G=[301,302,303,307,308];O.redirect=function(w,I){if(G.indexOf(I)===-1)throw new RangeError("Invalid status code");return new O(null,{status:I,headers:{location:w}})},a.DOMException=o.DOMException;try{new a.DOMException}catch{a.DOMException=function(I,B){this.message=I,this.name=B;var U=Error(I);this.stack=U.stack},a.DOMException.prototype=Object.create(Error.prototype),a.DOMException.prototype.constructor=a.DOMException}function W(w,I){return new Promise(function(B,U){var H=new k(w,I);if(H.signal&&H.signal.aborted)return U(new a.DOMException("Aborted","AbortError"));var V=new XMLHttpRequest;function J(){V.abort()}V.onload=function(){var Q={status:V.status,statusText:V.statusText,headers:F(V.getAllResponseHeaders()||"")};Q.url="responseURL"in V?V.responseURL:Q.headers.get("X-Request-URL");var rt="response"in V?V.response:V.responseText;setTimeout(function(){B(new O(rt,Q))},0)},V.onerror=function(){setTimeout(function(){U(new TypeError("Network request failed"))},0)},V.ontimeout=function(){setTimeout(function(){U(new TypeError("Network request failed"))},0)},V.onabort=function(){setTimeout(function(){U(new a.DOMException("Aborted","AbortError"))},0)};function $(Q){try{return Q===""&&o.location.href?o.location.href:Q}catch{return Q}}V.open(H.method,$(H.url),!0),H.credentials==="include"?V.withCredentials=!0:H.credentials==="omit"&&(V.withCredentials=!1),"responseType"in V&&(l.blob?V.responseType="blob":l.arrayBuffer&&H.headers.get("Content-Type")&&H.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(V.responseType="arraybuffer")),I&&typeof I.headers=="object"&&!(I.headers instanceof g)?Object.getOwnPropertyNames(I.headers).forEach(function(Q){V.setRequestHeader(Q,f(I.headers[Q]))}):H.headers.forEach(function(Q,rt){V.setRequestHeader(rt,Q)}),H.signal&&(H.signal.addEventListener("abort",J),V.onreadystatechange=function(){V.readyState===4&&H.signal.removeEventListener("abort",J)}),V.send(typeof H._bodyInit>"u"?null:H._bodyInit)})}return W.polyfill=!0,o.fetch||(o.fetch=W,o.Headers=g,o.Request=k,o.Response=O),a.Headers=g,a.Request=k,a.Response=O,a.fetch=W,a})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var s=e.fetch?e:i;t=s.fetch,t.default=s.fetch,t.fetch=s.fetch,t.Headers=s.Headers,t.Request=s.Request,t.Response=s.Response,r.exports=t})(mn,mn.exports);var xu=mn.exports;const ku=gn(xu);function Du({canvas:r,scenes:t,currentTime:e}){if(t&&r){const i=t.scenes.filter(({start:n,duration:a})=>e>=n&&e<=n+a);if(i.length<=0)return;const s=r.getContext("2d");if(s){const n=t.transitionDuration,a=Math.max(...t.scenes.map(({start:o,duration:l})=>o+l));s.globalCompositeOperation="lighter",s.clearRect(0,0,r.width,r.height),i.forEach(({start:o,duration:l,draw:h,transitionCanvas:d})=>{s.globalAlpha=1,d.width=d.height=0,d.width=r.width,d.height=r.height;const c=d.getContext("2d");if(c){const u=o+l,f=o===0,p=u===a;h({currentTime:e,canvas:d,context:c}),!f&&e>=o&&e<=o+n/2?s.globalAlpha=Math.max(0,Math.min(1,(e-o)/(n/2))):!p&&e>=u-n/2&&e<=u&&(s.globalAlpha=Math.max(0,Math.min(1,(u-e)/(n/2)))),s.drawImage(d,0,0,r.width,r.height)}})}}}function Cu(r){if(typeof r=="string"){const[t,e]=r.split(":");return Math.min(parseFloat(t),parseFloat(e))}return r}function Iu(r){if(typeof r=="string"){const[t,e]=r.split(":"),i=parseFloat(t),s=parseFloat(e);return i/s}return r}function ts({resolution:r,aspectRatio:t}){const e=Cu(r),i=Iu(t),s=i>=1,n=Math.min(s?e*i:e/i,e),a=Math.max(s?e*i:e/i,e);return{resolution:e,aspectRatio:i,height:s?n:a,width:s?a:n}}function Pu({format:r,resolution:t,aspectRatio:e,videoResolution:i,videoAspectRatio:s}){const{height:n,width:a}=ts({resolution:t,aspectRatio:e}),{height:o,width:l}=ts({resolution:i,aspectRatio:s}),h=e>s;let d=1;if(r==="letterbox"||r==="letterbox-video")d=h?n/o:a/l;else if(r==="squarebox"){const g=Math.min(n,a);d=l>=o?g/o:g/l}else(r==="crop"||r==="crop-top")&&(d=h?a/l:n/o);const c=a/d,u=n/d,f=(l-c)/2;let p=(o-u)/2;return r==="crop-top"&&(p=Math.min(0,p)),{sx:f,sy:p,sWidth:c,sHeight:u,scale:d}}function zs({source:r,sx:t,sy:e,sw:i,sh:s,dx:n,dy:a,dw:o,dh:l}){const h=(r==null?void 0:r.naturalWidth)??(r==null?void 0:r.videoWidth)??(r==null?void 0:r.width),d=(r==null?void 0:r.naturalHeight)??(r==null?void 0:r.videoHeight)??(r==null?void 0:r.height);t=t??0,e=e??0,i=i??h,s=s??d,i<0&&(t+=i,i=Math.abs(i)),s<0&&(e+=s,s=Math.abs(s)),o<0&&(n+=o,o=Math.abs(o)),l<0&&(a+=l,l=Math.abs(l));const c=Math.max(t,0),u=Math.min(t+i,h),f=Math.max(e,0),p=Math.min(e+s,d),g=o/i,m=l/s;return[r,c,f,u-c,p-f,t<0?n-t*g:n,e<0?a-e*m:a,(u-c)*g,(p-f)*m]}function Ou({context:r,source:t,format:e="letterbox",videoResolution:i,videoAspectRatio:s,posX:n,posY:a,width:o,height:l,offscreenCanvas:h}){const{sx:d,sy:c,sWidth:u,sHeight:f,scale:p}=Pu({resolution:Math.min(o,l),aspectRatio:o/l,format:e,videoResolution:i,videoAspectRatio:s}),g=h&&typeof r.filter<"u";if(e==="letterbox"||e==="squarebox"||e==="letterbox-video"&&!g){if(d<0){const y=Math.abs(d)*p;r.fillStyle="black",r.beginPath(),r.rect(n,a,y,l),r.rect(n+o-y,a,y,l),r.fill(),r.closePath()}if(c<0){const y=Math.abs(c)*p;r.fillStyle="black",r.beginPath(),r.rect(n,a,o,y),r.rect(n,a+l-y,o,y),r.fill(),r.closePath()}}if(e==="letterbox-video"&&g){const{width:y,height:E}=ts({resolution:i,aspectRatio:s});h.width=y,h.height=E;const S=h.getContext("2d",{alpha:!1});if(S==null||S.drawImage(t,0,0,y,E),S){r.save(),r.globalCompositeOperation="destination-out",r.fillRect(n,a,o,l);const L=zs({source:h,sx:d,sy:c,sw:u,sh:f,dx:n,dy:a,dw:o,dh:l});r.globalCompositeOperation="source-over",r.drawImage(...L),S.save();const D=1.3,k=-(y*D-y)/2,x=-(E*D-E)/2;if(S.filter="blur(40px) brightness(20%)",S.translate(k,x),S.scale(D,D),S.drawImage(h,0,0,y,E),S.restore(),r.globalCompositeOperation="destination-over",d<0){const F=o/s,O=l/F,G=zs({source:h,sy:(1-O)*E/2,sh:O*E,dx:n,dy:a,dw:o,dh:l});r.drawImage(...G)}if(c<0){const F=l*s,O=o/F,G=zs({source:h,sx:(1-O)*y/2,sw:O*y,dx:n,dy:a,dw:o,dh:l});r.drawImage(...G)}r.restore()}}else{const y=zs({source:t,sx:d,sy:c,sw:u,sh:f,dx:n,dy:a,dw:o,dh:l});r.drawImage(...y)}const m=d*-1*p,b=c*-1*p,A=o-m*2,T=l-b*2;return{dx:m,dy:b,dw:A,dh:T}}const Mu=/\d{0,2}:?\d{2}:\d{2}\.\d{3}\s-->\s\d{0,2}:?\d{2}:\d{2}\.\d{3}\s{1,2}.*/g,Fu=/\d{0,2}:?\d{2}:\d{2}\.\d{3}/g;function Zo(r){if(!r)return[];const t=r.match(Mu);return t?t==null?void 0:t.map(e=>{const[i,s]=e.replace(`\r
|
84
84
|
`,`
|
85
85
|
`).split(`
|
86
|
-
`),[n,a]=i.match(Fu)||[];return{start:n,end:a,text:r}}):[]}function Kr(s){const[t,e,i]=s.split(":");return i?parseInt(t)*60*60+parseInt(e)*60+parseFloat(i):parseInt(t)*60+parseInt(e)}function Nu({canvas:s,dx:t,dy:e,dw:i,dh:r,time:n,vttCaptions:a}){if(a){const o=Zo(a).find(({start:l,end:h})=>l&&h&&n>=Kr(l)&&n<Kr(h));if(o){const l=s.getContext("2d");if(l){const h=Math.min(i,r);let d=[""];const c=i*.9,u=h*.05;l.font=`${u}px Roobert, Dejavu Sans, sans-serif`,l.textBaseline="middle",o.text.split(" ").forEach(f=>{const p=d.length-1,g=l.measureText(d[p]).width,m=l.measureText(` ${f}`).width;g+m<c?d[p]=`${d[p]} ${f}`:d=[...d,f]}),d.forEach((f,p)=>{const g=f.trim(),m=l.measureText(g),b=t+(i-m.width)/2,A=e+(r*.85-(u+h*.04)*(d.length-1-p)),T=u*.8,y=u/1.5,w=t+(i-m.width-y)/2,S=A-T,L=m.width+y,C=T*2,k=l.globalAlpha;l.save(),l.globalAlpha=.8*k,l.fillStyle="#000000",l.beginPath(),l.roundRect(w,S,L,C,h*.01),l.fill(),l.closePath(),l.globalAlpha=k,l.fillStyle="#FFFFFF",l.fillText(g,b,A),l.restore()})}}}}const Se=1.8;function er(s){return typeof s=="number"?{top:s,right:s,bottom:s,left:s}:{top:0,right:0,bottom:0,left:0,...s}}function Uu(s,t=1){return typeof s=="number"?{topLeft:s*t,topRight:s*t,bottomRight:s*t,bottomLeft:s*t}:{topLeft:((s==null?void 0:s.topLeft)??0)*t,topRight:((s==null?void 0:s.topRight)??0)*t,bottomRight:((s==null?void 0:s.bottomRight)??0)*t,bottomLeft:((s==null?void 0:s.bottomLeft)??0)*t}}function Wr(s,t){return typeof s=="number"?s:typeof s=="function"?s(t):null}function Yr(s,t){const{w:e,gap:i=0,padding:r=0,direction:n="column",elements:a}=s,{right:o,left:l}=er(r);if(e){const h=Wr(e,t);if(h)return h}if(a){const h=a.length;if(n==="row")return o+l+i*(h-1)+a.reduce((d,c)=>d+=Yr(c,t),0);if(n==="column"){let d=0;return a.forEach(c=>{const u=o+l+Yr(c,t);u>d&&(d=u)}),d}}return 0}function Bu(s,t,e){const{w:i=0,gap:r=0,padding:n=0,direction:a="column"}=s,{right:o,left:l}=er(n),h=t.length,d=t.reduce((u,f)=>{const{w:p}=f;if(p){const g=Wr(p,e);if(g)return u+=g}return p==="auto"?u+=Yr(f,e):u},0),c=t.filter(({w:u})=>u==="fill").length;return t.reduce((u,f)=>{const{w:p}=f,g=i-o-l,m=Math.min(g,Yr(f,e));if(p==="fill"){if(a==="row"){const b=(i-d-o-l-r*(h-1))/c;return u=[...u,b]}if(a==="column")return u=[...u,g]}return u=[...u,m]},[])}function Xr(s,t){const{h:e,gap:i=0,padding:r=0,direction:n="column",elements:a}=s,{top:o,bottom:l}=er(r);if(e){const h=Wr(e,t);if(h)return h}if(a){const h=a.length;if(n==="row"){let d=0;return a.forEach(c=>{const u=o+l+Xr(c,t);u>d&&(d=u)}),d}if(n==="column")return o+l+i*(h-1)+a.reduce((d,c)=>d+=Xr(c,t),0)}return 0}function Hu(s,t,e){const{h:i=0,gap:r=0,padding:n=0,direction:a="column"}=s,{top:o,bottom:l}=er(n),h=t.length,d=t.reduce((u,f)=>{const{h:p}=f;if(p){const g=Wr(p,e);if(g)return u+=g}return p==="auto"?u+=Xr(f,e):u},0),c=t.filter(({h:u})=>u==="fill").length;return t.reduce((u,f)=>{const{h:p}=f,g=i-o-l,m=Math.min(g,Xr(f,e));if(p==="fill"){if(a==="row")return u=[...u,g];if(a==="column"){const b=(i-d-o-l-r*(h-1))/c;return u=[...u,b]}}return u=[...u,m]},[])}function Jo({canvas:s,offscreenCanvas:t,debug:e=!1,origin:{x:i=0,y:r=0,w:n=s.width,h:a=s.height}={},parent:o,elements:l=[]}){const h=Math.min(n,a)/1080,d={x:0,y:0,w:n/h,h:a/h,gap:0,padding:0,direction:"column",align:"start",justify:"start",...o},{x:c,y:u,w:f,h:p,gap:g,padding:m,direction:b,align:A,justify:T}=d,{top:y,right:w,bottom:S,left:L}=er(m);l.map((C,k)=>{const x=s.getContext("2d",{alpha:!1});if(x){const N=l.length,{x:O,y:V,radius:W,elements:E=[],draw:I}=C,{topLeft:B,topRight:U,bottomRight:H,bottomLeft:j}=Uu(W,h),J=Bu(d,l,{context:x}),[$,Q,st]=J.reduce((Tt,Ot,qt)=>(qt<k&&(Tt[0]=Tt[0]+=Ot),qt>k&&(Tt[1]=Tt[1]+=Ot),Tt[2]=Tt[2]+=Ot,Tt),[0,0,0]),tt=J[k],Pt=Hu(d,l,{context:x,width:tt}),[Lt,yt,Te]=Pt.reduce((Tt,Ot,qt)=>(qt<k&&(Tt[0]=Tt[0]+=Ot),qt>k&&(Tt[1]=Tt[1]+=Ot),Tt[2]=Tt[2]+=Ot,Tt),[0,0,0]),bt=Pt[k],je={"row|start|start":L+$+g*k,"row|center|start":L+$+g*k,"row|end|start":L+$+g*k,"row|start|center":f/2-st/2-g*(N-1)/2+$+g*k,"row|center|center":f/2-st/2-g*(N-1)/2+$+g*k,"row|end|center":f/2-st/2-g*(N-1)/2+$+g*k,"row|start|end":f-w-tt-Q-g*(N-k),"row|center|end":f-w-tt-Q-g*(N-k),"row|end|end":f-w-tt-Q-g*(N-k),"column|start|start":L,"column|center|start":f/2-tt/2,"column|end|start":f-w-tt-Q,"column|start|center":L,"column|center|center":f/2-tt/2,"column|end|center":f-w-tt-Q,"column|start|end":L,"column|center|end":f/2-tt/2,"column|end|end":f-w-tt-Q},Ni={"row|start|start":y,"row|center|start":p/2-bt/2,"row|end|start":p-S-bt-yt,"row|start|center":y,"row|center|center":p/2-bt/2,"row|end|center":p-S-bt-yt,"row|start|end":y,"row|center|end":p/2-bt/2,"row|end|end":p-S-bt-yt,"column|start|start":y+Lt+g*k,"column|center|start":y+Lt+g*k,"column|end|start":y+Lt+g*k,"column|start|center":p/2-Te/2-g*(N-1)/2+Lt+g*k,"column|center|center":p/2-Te/2-g*(N-1)+Lt+g*k,"column|end|center":p/2-Te/2-g*(N-1)+Lt+g*k,"column|start|end":p-S-bt-yt-g*(N-k),"column|center|end":p-S-bt-yt-g*(N-k),"column|end|end":p-S-bt-yt-g*(N-k)},ze=c+(O??je[`${b}|${A}|${T}`]),hi=u+(V??Ni[`${b}|${A}|${T}`]),At=i+ze*h,vt=r+hi*h,Xt=tt*h,ut=bt*h;I&&(x.save(),W&&(x.beginPath(),x.moveTo(At+Math.min(ut/Se,B),vt),x.lineTo(At+Xt-Math.min(ut/Se,U),vt),x.quadraticCurveTo(At+Xt,vt,At+Xt,vt+Math.min(ut/Se,U)),x.lineTo(At+Xt,vt+ut-Math.min(ut/Se,H)),x.quadraticCurveTo(At+Xt,vt+ut,At+Xt-Math.min(ut/Se,H),vt+ut),x.lineTo(At+Math.min(ut/Se,j),vt+ut),x.quadraticCurveTo(At,vt+ut,At,vt+ut-Math.min(ut/Se,j)),x.lineTo(At,vt+Math.min(ut/Se,B)),x.quadraticCurveTo(At,vt,At+Math.min(ut/Se,B),vt),x.closePath(),e&&(x.strokeStyle="blue",x.stroke()),x.clip()),I({scale:h,canvas:s,context:x,offscreenCanvas:t,dx:At,dy:vt,dw:Xt,dh:ut}),e&&(x.strokeStyle="red",x.strokeRect(At,vt,Xt,ut)),x.restore()),Jo({canvas:s,offscreenCanvas:t,debug:e,origin:{x:i,y:r,w:n,h:a},parent:{...C,x:ze,y:hi,w:tt,h:bt},elements:E})}})}function Gu(s){return Jo(s)}function qr({context:s,node:t,maxW:e=1/0}){const i=(t.value??"").split(" ");return i.slice(1).reduce((r,n)=>{const a=`${r[r.length-1].text} ${n}`.trim(),o=s.measureText(a);return o.width>e?r=[...r,{text:n,metrics:s.measureText(n)}]:r[r.length-1]={text:a,metrics:o},r},[{text:i[0],metrics:s.measureText(i[0])}])}function Qo(s){const{visible:t=!0,node:e}=s,i=[...(e==null?void 0:e.elements)??[],...(s==null?void 0:s.elements)??[]];return t?e&&e.type!=="box"?!!e.value:i==null?void 0:i.some(r=>Qo(r)):!1}function _o(s=!1,t,e){return t.map(i=>{const{node:r}=i;if(Qo(i))return{...i,...(r==null?void 0:r.type)==="text"&&r.value?{w:r.fill?"fill":({context:n})=>r&&r.type==="text"&&r.value?(n.font=r.font,n.textBaseline="top",Math.ceil(n.measureText(r.value).width)):0,h:r.fill?"fill":({width:n,context:a})=>{var o,l;if(r&&r.type==="text"){const h=/(?<value>\d+\.?\d*)/,d=parseFloat(((l=(o=r.font.match(h))==null?void 0:o.groups)==null?void 0:l.value)??"0");return r.wrap?qr({context:a,node:r,maxW:n}).length*d:d}return 0}}:{},...(r==null?void 0:r.type)==="image"&&r.image&&r.size?{w:()=>{var n,a,o,l;const h=((n=r.image)==null?void 0:n.naturalWidth)??r.image.width,d=((a=r.image)==null?void 0:a.naturalHeight)??r.image.height,c=h/d,u=(o=r.size)==null?void 0:o.w,f=((l=r.size)==null?void 0:l.h)??0;return u??(c>=1?f:f*c)},h:()=>{var n,a,o,l;const h=((n=r.image)==null?void 0:n.naturalWidth)??r.image.width,d=((a=r.image)==null?void 0:a.naturalHeight)??r.image.height,c=h/d,u=((o=r.size)==null?void 0:o.w)??0;return((l=r.size)==null?void 0:l.h)??(c<1?u:u*c)}}:{},elements:i.elements?_o(s,i.elements,e):void 0,draw:({canvas:n,offscreenCanvas:a,context:o,dx:l,dy:h,dw:d,dh:c,scale:u})=>{var f,p,g,m,b,A,T;if(r){const{type:y,from:w=0,to:S=1/0}=r;if(e>=w&&e<=S){if(o.save(),e&&S-.3333333333333333<=e&&(o.globalAlpha=1-(.16666666666666666-(S-e))/.16666666666666666),y==="box"&&(o.fillStyle=r.background,o.fillRect(l,h,d,c)),y==="text"&&r.value){const L=/(?<value>\d+\.?\d*)/;let C=0;const k=parseFloat(((p=(f=r.font.match(L))==null?void 0:f.groups)==null?void 0:p.value)??"0")*u;if(r.fill){const{minSize:x,maxSize:N}=r.fill;C=x*u,o.font=r.font.replace(L,C.toString());const O=10*u;let V=0,W=qr({context:o,node:r,maxW:d});for(;C+O<N*u&&(W.length+1)*(C+O)<c;)if(C+=O,o.font=r.font.replace(L,C.toString()),W=qr({context:o,node:r,maxW:d}),V=W.reduce((E,I)=>(I.metrics.width>E&&(E=I.metrics.width),E),0),V>d){C-=O;break}o.font=r.font.replace(L,C.toString())}else C=k,o.font=r.font.replace(L,k.toString());o.textBaseline="top",o.fillStyle=r.color,r.wrap?qr({context:o,node:r,maxW:d}).forEach((x,N)=>{o.fillText(x.text,l,h+C*N)}):o.fillText(r.value,l,h)}if(y==="image"&&r.image&&o.drawImage(r.image,l,h,d,c),y==="video"&&((g=r.video)!=null&&g.node||(m=r.video)!=null&&m.getSource)){const L=((A=(b=r.video)==null?void 0:b.getSource)==null?void 0:A.call(b,e))??r.video.node,C=(L==null?void 0:L.videoWidth)??(L==null?void 0:L.naturalWidth)??(L==null?void 0:L.width),k=(L==null?void 0:L.videoHeight)??(L==null?void 0:L.naturalHeight)??(L==null?void 0:L.height);if(C&&k){const{resolution:x,aspectRatio:N}=tr({resolution:Math.min(C,k),aspectRatio:C/k}),{dx:O,dy:V,dw:W,dh:E}=Ou({offscreenCanvas:a,context:o,source:L,format:r.format??"letterbox",videoResolution:x,videoAspectRatio:N,posX:l,posY:h,width:d,height:c});r.elements&&$o({time:e,canvas:n,offscreenCanvas:a,origin:{x:Math.max(l,l+O),y:Math.max(h,h+V),w:Math.min(d,W),h:Math.min(c,E)},elements:r.elements})}}if(y==="gradient"&&r.value){const L=o.createLinearGradient(l+d,h,l+d,h+c);(T=r.value)==null||T.forEach(C=>{L.addColorStop(C.percent,C.color)}),o.fillStyle=L,o.fillRect(l,h,d,c)}o.restore()}}}}}).filter(Boolean)}function $o({debug:s,time:t,elements:e,...i}){return Gu({...i,debug:s,elements:_o(s,e,t)})}async function Vu(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>$d);return new s.Image}return new Image}async function ju(s){return new Promise(t=>{Vu().then(e=>{e.onload=()=>{t(e)},e.onerror=()=>{t(null)},e.src=s})})}async function yn({element:s},t){var e,i,r;let n={...s};const{node:a}=s;if((a==null?void 0:a.type)==="video"&&((e=a==null?void 0:a.value)!=null&&e.src||(i=a==null?void 0:a.value)!=null&&i.playlist)&&(n={...n,node:{...a,video:await t(a.value)}}),(a==null?void 0:a.type)==="image"&&a.value){const o=await ju(a.value);o&&(n={...n,node:{...a,image:o}})}return n.node&&(r=s.node)!=null&&r.elements&&(n.node.elements=await Promise.all(s.node.elements.map(o=>yn({element:o},t)))),s.elements&&(n.elements=await Promise.all(s.elements.map(o=>yn({element:o},t)))),n}async function tl(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>$d),t=new s.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function zu(s){var t;try{if((t=await ku(s,{method:"HEAD"}))!=null&&t.ok)return s}catch{return}}async function Ku({sources:s}){let t=null;if(s){const e=s.filter(Boolean).map(i=>zu(i));t=(await Promise.all(e)).find(Boolean)}return t}jr.define("stringify",s=>JSON.stringify(s)),jr.define("nullify",s=>typeof s>"u"?null:s),jr.define("filter",(s,t)=>{if(!t)return s;if(!Array.isArray(s))throw new Error("Data for filter must be an array");return s.filter((e,i)=>t.includes(i))}),_i.define("parse",s=>{const t=s.params[0];return typeof t=="string"?`"${t.replace(/\n/g,"\\n")}"`:typeof t>"u"?null:t}),_i.define("resolve-source",async s=>{const{sources:t}=s.params[0]??{},e=t==null?void 0:t.filter(Boolean),i=e==null?void 0:e.find(a=>a.includes("blob:")),r=e==null?void 0:e.find(a=>!a.includes("http")),n=i??r??await Ku({sources:t});return n?`"${n}"`:"null"});const Zr=(s,t,e)=>Ru(s,t,$i({autoEscape:!1,defaultFilter:"nullify",async:!0,asyncHelpers:["resolve-source"],...e}));function bn(s=[]){var t;for(const e of s)return((t=e==null?void 0:e.node)==null?void 0:t.type)==="video"?e.node:bn(e==null?void 0:e.elements)}async function el({data:s,template:t},e){var i;const r=(await Promise.all(t.template.content.map(async({scenes:a,root:o})=>(await Promise.all(a.map(async({layout:l,duration:h,data:d,options:c})=>{const u={...t.options,...s,intro:t.intro,outro:t.outro};async function f(p){var g,m;const b=d?JSON.parse(await Zr(d,{...u,root:p})):{},A=c?JSON.parse(await Zr(c,u)):{},T=(g=t.template.layouts.find(L=>L.name===l))==null?void 0:g.tree,y=JSON.parse(await Zr(T,{...b,...A})),w=await Promise.all(y.flatMap(L=>yn({element:L},e))),S=(m=bn(w))==null?void 0:m.video;return{duration:h??(S==null?void 0:S.duration)??0,captions:S==null?void 0:S.captions,elements:w}}if(o){const p=JSON.parse(await Zr(o,u));return Array.isArray(p)?await Promise.all(p.map(async g=>await f(g))):f(p)}return f(s)}))).flatMap(l=>l).filter(l=>l.duration>0)))).flatMap(a=>a),n=((i=t.meta)==null?void 0:i.transitionDuration)??1/3;return{scenes:await Promise.all(r.map(async({duration:a,captions:o,elements:l},h)=>{var d,c;const u=await tl(),f=await tl(),p=r.reduce((b,A,T)=>(T<h&&(b+=A.duration-n/2),b),0),g=({canvas:b,currentTime:A})=>{$o({canvas:b,elements:l,offscreenCanvas:u,time:A}),o&&Nu({canvas:b,time:A,dx:0,dy:0,dw:b.width,dh:b.height,vttCaptions:o})},m=bn(l);return{draw:g,duration:a,transitionCanvas:f,start:p,video:m==null?void 0:m.video,audio:{duration:a,src:(d=m==null?void 0:m.value)==null?void 0:d.src,start:(c=m==null?void 0:m.video)==null?void 0:c.start}}})),transitionDuration:n}}/**
|
87
|
-
* @license
|
88
|
-
* Copyright 2017 Google LLC
|
89
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
90
|
-
*/const yi={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},bi=s=>(...t)=>({_$litDirective$:s,values:t});let ir=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
|
91
|
-
* @license
|
92
|
-
* Copyright 2018 Google LLC
|
93
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
94
|
-
*/const ht=bi(class extends ir{constructor(s){var t;if(super(s),s.type!==yi.ATTRIBUTE||s.name!=="class"||((t=s.strings)===null||t===void 0?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(s){return" "+Object.keys(s).filter(t=>s[t]).join(" ")+" "}update(s,[t]){var e,i;if(this.it===void 0){this.it=new Set,s.strings!==void 0&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter(n=>n!=="")));for(const n in t)t[n]&&!(!((e=this.nt)===null||e===void 0)&&e.has(n))&&this.it.add(n);return this.render(t)}const r=s.element.classList;this.it.forEach(n=>{n in t||(r.remove(n),this.it.delete(n))});for(const n in t){const a=!!t[n];a===this.it.has(n)||!((i=this.nt)===null||i===void 0)&&i.has(n)||(a?(r.add(n),this.it.add(n)):(r.remove(n),this.it.delete(n)))}return re}});/**
|
95
|
-
* @license
|
96
|
-
* Copyright 2018 Google LLC
|
97
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
98
|
-
*/const rr=s=>s??gt;/**
|
99
|
-
* @license
|
100
|
-
* Copyright 2020 Google LLC
|
101
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
102
|
-
*/const{I:Wu}=bc,Yu=s=>s.strings===void 0,il=()=>document.createComment(""),sr=(s,t,e)=>{var i;const r=s._$AA.parentNode,n=t===void 0?s._$AB:t._$AA;if(e===void 0){const a=r.insertBefore(il(),n),o=r.insertBefore(il(),n);e=new Wu(a,o,s,s.options)}else{const a=e._$AB.nextSibling,o=e._$AM,l=o!==s;if(l){let h;(i=e._$AQ)===null||i===void 0||i.call(e,s),e._$AM=s,e._$AP!==void 0&&(h=s._$AU)!==o._$AU&&e._$AP(h)}if(a!==n||l){let h=e._$AA;for(;h!==a;){const d=h.nextSibling;r.insertBefore(h,n),h=d}}}return e},$e=(s,t,e=s)=>(s._$AI(t,e),s),Xu={},qu=(s,t=Xu)=>s._$AH=t,Zu=s=>s._$AH,An=s=>{var t;(t=s._$AP)===null||t===void 0||t.call(s,!1,!0);let e=s._$AA;const i=s._$AB.nextSibling;for(;e!==i;){const r=e.nextSibling;e.remove(),e=r}};/**
|
103
|
-
* @license
|
104
|
-
* Copyright 2017 Google LLC
|
105
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
106
|
-
*/const nr=(s,t)=>{var e,i;const r=s._$AN;if(r===void 0)return!1;for(const n of r)(i=(e=n)._$AO)===null||i===void 0||i.call(e,t,!1),nr(n,t);return!0},Jr=s=>{let t,e;do{if((t=s._$AM)===void 0)break;e=t._$AN,e.delete(s),s=t}while((e==null?void 0:e.size)===0)},rl=s=>{for(let t;t=s._$AM;s=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(s))break;e.add(s),_u(t)}};function Ju(s){this._$AN!==void 0?(Jr(this),this._$AM=s,rl(this)):this._$AM=s}function Qu(s,t=!1,e=0){const i=this._$AH,r=this._$AN;if(r!==void 0&&r.size!==0)if(t)if(Array.isArray(i))for(let n=e;n<i.length;n++)nr(i[n],!1),Jr(i[n]);else i!=null&&(nr(i,!1),Jr(i));else nr(this,s)}const _u=s=>{var t,e,i,r;s.type==yi.CHILD&&((t=(i=s)._$AP)!==null&&t!==void 0||(i._$AP=Qu),(e=(r=s)._$AQ)!==null&&e!==void 0||(r._$AQ=Ju))};let sl=class extends ir{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),rl(this),this.isConnected=t._$AU}_$AO(t,e=!0){var i,r;t!==this.isConnected&&(this.isConnected=t,t?(i=this.reconnected)===null||i===void 0||i.call(this):(r=this.disconnected)===null||r===void 0||r.call(this)),e&&(nr(this,t),Jr(this))}setValue(t){if(Yu(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};/**
|
107
|
-
* @license
|
108
|
-
* Copyright 2020 Google LLC
|
109
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
110
|
-
*/const se=()=>new $u;let $u=class{};const Tn=new WeakMap,ne=bi(class extends sl{render(s){return gt}update(s,[t]){var e;const i=t!==this.G;return i&&this.G!==void 0&&this.ot(void 0),(i||this.rt!==this.lt)&&(this.G=t,this.ct=(e=s.options)===null||e===void 0?void 0:e.host,this.ot(this.lt=s.element)),gt}ot(s){var t;if(typeof this.G=="function"){const e=(t=this.ct)!==null&&t!==void 0?t:globalThis;let i=Tn.get(e);i===void 0&&(i=new WeakMap,Tn.set(e,i)),i.get(this.G)!==void 0&&this.G.call(this.ct,void 0),i.set(this.G,s),s!==void 0&&this.G.call(this.ct,s)}else this.G.value=s}get rt(){var s,t,e;return typeof this.G=="function"?(t=Tn.get((s=this.ct)!==null&&s!==void 0?s:globalThis))===null||t===void 0?void 0:t.get(this.G):(e=this.G)===null||e===void 0?void 0:e.value}disconnected(){this.rt===this.lt&&this.ot(void 0)}reconnected(){this.ot(this.lt)}});var tf=ar;ar.flatten=ar,ar.unflatten=ol;function nl(s){return s&&s.constructor&&typeof s.constructor.isBuffer=="function"&&s.constructor.isBuffer(s)}function al(s){return s}function ar(s,t){t=t||{};const e=t.delimiter||".",i=t.maxDepth,r=t.transformKey||al,n={};function a(o,l,h){h=h||1,Object.keys(o).forEach(function(d){const c=o[d],u=t.safe&&Array.isArray(c),f=Object.prototype.toString.call(c),p=nl(c),g=f==="[object Object]"||f==="[object Array]",m=l?l+e+r(d):r(d);if(!u&&!p&&g&&Object.keys(c).length&&(!t.maxDepth||h<i))return a(c,m,h+1);n[m]=c})}return a(s),n}function ol(s,t){t=t||{};const e=t.delimiter||".",i=t.overwrite||!1,r=t.transformKey||al,n={};if(nl(s)||Object.prototype.toString.call(s)!=="[object Object]")return s;function o(d){const c=Number(d);return isNaN(c)||d.indexOf(".")!==-1||t.object?d:c}function l(d,c,u){return Object.keys(u).reduce(function(f,p){return f[d+e+p]=u[p],f},c)}function h(d){const c=Object.prototype.toString.call(d),u=c==="[object Array]",f=c==="[object Object]";if(d){if(u)return!d.length;if(f)return!Object.keys(d).length}else return!0}return s=Object.keys(s).reduce(function(d,c){const u=Object.prototype.toString.call(s[c]);return!(u==="[object Object]"||u==="[object Array]")||h(s[c])?(d[c]=s[c],d):l(c,d,ar(s[c],t))},{}),Object.keys(s).forEach(function(d){const c=d.split(e).map(r);let u=o(c.shift()),f=o(c[0]),p=n;for(;f!==void 0;){if(u==="__proto__")return;const g=Object.prototype.toString.call(p[u]),m=g==="[object Object]"||g==="[object Array]";if(!i&&!m&&typeof p[u]<"u")return;(i&&!m||!i&&p[u]==null)&&(p[u]=typeof f=="number"&&!t.object?[]:{}),p=p[u],c.length>0&&(u=o(c.shift()),f=o(c[0]))}p[u]=ol(s[d],t)}),n}const ef=mn(tf);/**
|
111
|
-
* @license
|
112
|
-
* Copyright 2017 Google LLC
|
113
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
114
|
-
*/const ll=(s,t,e)=>{const i=new Map;for(let r=t;r<=e;r++)i.set(s[r],r);return i},hl=bi(class extends ir{constructor(s){if(super(s),s.type!==yi.CHILD)throw Error("repeat() can only be used in text expressions")}dt(s,t,e){let i;e===void 0?e=t:t!==void 0&&(i=t);const r=[],n=[];let a=0;for(const o of s)r[a]=i?i(o,a):a,n[a]=e(o,a),a++;return{values:n,keys:r}}render(s,t,e){return this.dt(s,t,e).values}update(s,[t,e,i]){var r;const n=Zu(s),{values:a,keys:o}=this.dt(t,e,i);if(!Array.isArray(n))return this.ht=o,a;const l=(r=this.ht)!==null&&r!==void 0?r:this.ht=[],h=[];let d,c,u=0,f=n.length-1,p=0,g=a.length-1;for(;u<=f&&p<=g;)if(n[u]===null)u++;else if(n[f]===null)f--;else if(l[u]===o[p])h[p]=$e(n[u],a[p]),u++,p++;else if(l[f]===o[g])h[g]=$e(n[f],a[g]),f--,g--;else if(l[u]===o[g])h[g]=$e(n[u],a[g]),sr(s,h[g+1],n[u]),u++,g--;else if(l[f]===o[p])h[p]=$e(n[f],a[p]),sr(s,n[u],n[f]),f--,p++;else if(d===void 0&&(d=ll(o,p,g),c=ll(l,u,f)),d.has(l[u]))if(d.has(l[f])){const m=c.get(o[p]),b=m!==void 0?n[m]:null;if(b===null){const A=sr(s,n[u]);$e(A,a[p]),h[p]=A}else h[p]=$e(b,a[p]),sr(s,n[u],b),n[m]=null;p++}else An(n[f]),f--;else An(n[u]),u++;for(;p<=g;){const m=sr(s,h[g+1]);$e(m,a[p]),h[p++]=m}for(;u<=f;){const m=n[u++];m!==null&&An(m)}return this.ht=o,qu(s,h),re}});var Gt="top",Jt="bottom",Qt="right",Vt="left",En="auto",or=[Gt,Jt,Qt,Vt],Ai="start",lr="end",rf="clippingParents",dl="viewport",hr="popper",sf="reference",cl=or.reduce(function(s,t){return s.concat([t+"-"+Ai,t+"-"+lr])},[]),ul=[].concat(or,[En]).reduce(function(s,t){return s.concat([t,t+"-"+Ai,t+"-"+lr])},[]),nf="beforeRead",af="read",of="afterRead",lf="beforeMain",hf="main",df="afterMain",cf="beforeWrite",uf="write",ff="afterWrite",pf=[nf,af,of,lf,hf,df,cf,uf,ff];function ue(s){return s?(s.nodeName||"").toLowerCase():null}function Zt(s){if(s==null)return window;if(s.toString()!=="[object Window]"){var t=s.ownerDocument;return t&&t.defaultView||window}return s}function ti(s){var t=Zt(s).Element;return s instanceof t||s instanceof Element}function _t(s){var t=Zt(s).HTMLElement;return s instanceof t||s instanceof HTMLElement}function wn(s){if(typeof ShadowRoot>"u")return!1;var t=Zt(s).ShadowRoot;return s instanceof t||s instanceof ShadowRoot}function gf(s){var t=s.state;Object.keys(t.elements).forEach(function(e){var i=t.styles[e]||{},r=t.attributes[e]||{},n=t.elements[e];!_t(n)||!ue(n)||(Object.assign(n.style,i),Object.keys(r).forEach(function(a){var o=r[a];o===!1?n.removeAttribute(a):n.setAttribute(a,o===!0?"":o)}))})}function mf(s){var t=s.state,e={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,e.popper),t.styles=e,t.elements.arrow&&Object.assign(t.elements.arrow.style,e.arrow),function(){Object.keys(t.elements).forEach(function(i){var r=t.elements[i],n=t.attributes[i]||{},a=Object.keys(t.styles.hasOwnProperty(i)?t.styles[i]:e[i]),o=a.reduce(function(l,h){return l[h]="",l},{});!_t(r)||!ue(r)||(Object.assign(r.style,o),Object.keys(n).forEach(function(l){r.removeAttribute(l)}))})}}const fl={name:"applyStyles",enabled:!0,phase:"write",fn:gf,effect:mf,requires:["computeStyles"]};function fe(s){return s.split("-")[0]}var ei=Math.max,Qr=Math.min,Ti=Math.round;function Sn(){var s=navigator.userAgentData;return s!=null&&s.brands&&Array.isArray(s.brands)?s.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function pl(){return!/^((?!chrome|android).)*safari/i.test(Sn())}function Ei(s,t,e){t===void 0&&(t=!1),e===void 0&&(e=!1);var i=s.getBoundingClientRect(),r=1,n=1;t&&_t(s)&&(r=s.offsetWidth>0&&Ti(i.width)/s.offsetWidth||1,n=s.offsetHeight>0&&Ti(i.height)/s.offsetHeight||1);var a=ti(s)?Zt(s):window,o=a.visualViewport,l=!pl()&&e,h=(i.left+(l&&o?o.offsetLeft:0))/r,d=(i.top+(l&&o?o.offsetTop:0))/n,c=i.width/r,u=i.height/n;return{width:c,height:u,top:d,right:h+c,bottom:d+u,left:h,x:h,y:d}}function Ln(s){var t=Ei(s),e=s.offsetWidth,i=s.offsetHeight;return Math.abs(t.width-e)<=1&&(e=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:s.offsetLeft,y:s.offsetTop,width:e,height:i}}function gl(s,t){var e=t.getRootNode&&t.getRootNode();if(s.contains(t))return!0;if(e&&wn(e)){var i=t;do{if(i&&s.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function Le(s){return Zt(s).getComputedStyle(s)}function vf(s){return["table","td","th"].indexOf(ue(s))>=0}function Me(s){return((ti(s)?s.ownerDocument:s.document)||window.document).documentElement}function _r(s){return ue(s)==="html"?s:s.assignedSlot||s.parentNode||(wn(s)?s.host:null)||Me(s)}function ml(s){return!_t(s)||Le(s).position==="fixed"?null:s.offsetParent}function yf(s){var t=/firefox/i.test(Sn()),e=/Trident/i.test(Sn());if(e&&_t(s)){var i=Le(s);if(i.position==="fixed")return null}var r=_r(s);for(wn(r)&&(r=r.host);_t(r)&&["html","body"].indexOf(ue(r))<0;){var n=Le(r);if(n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].indexOf(n.willChange)!==-1||t&&n.willChange==="filter"||t&&n.filter&&n.filter!=="none")return r;r=r.parentNode}return null}function dr(s){for(var t=Zt(s),e=ml(s);e&&vf(e)&&Le(e).position==="static";)e=ml(e);return e&&(ue(e)==="html"||ue(e)==="body"&&Le(e).position==="static")?t:e||yf(s)||t}function Rn(s){return["top","bottom"].indexOf(s)>=0?"x":"y"}function cr(s,t,e){return ei(s,Qr(t,e))}function bf(s,t,e){var i=cr(s,t,e);return i>e?e:i}function vl(){return{top:0,right:0,bottom:0,left:0}}function yl(s){return Object.assign({},vl(),s)}function bl(s,t){return t.reduce(function(e,i){return e[i]=s,e},{})}var Af=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,yl(typeof t!="number"?t:bl(t,or))};function Tf(s){var t,e=s.state,i=s.name,r=s.options,n=e.elements.arrow,a=e.modifiersData.popperOffsets,o=fe(e.placement),l=Rn(o),h=[Vt,Qt].indexOf(o)>=0,d=h?"height":"width";if(!(!n||!a)){var c=Af(r.padding,e),u=Ln(n),f=l==="y"?Gt:Vt,p=l==="y"?Jt:Qt,g=e.rects.reference[d]+e.rects.reference[l]-a[l]-e.rects.popper[d],m=a[l]-e.rects.reference[l],b=dr(n),A=b?l==="y"?b.clientHeight||0:b.clientWidth||0:0,T=g/2-m/2,y=c[f],w=A-u[d]-c[p],S=A/2-u[d]/2+T,L=cr(y,S,w),C=l;e.modifiersData[i]=(t={},t[C]=L,t.centerOffset=L-S,t)}}function Ef(s){var t=s.state,e=s.options,i=e.element,r=i===void 0?"[data-popper-arrow]":i;r!=null&&(typeof r=="string"&&(r=t.elements.popper.querySelector(r),!r)||gl(t.elements.popper,r)&&(t.elements.arrow=r))}const wf={name:"arrow",enabled:!0,phase:"main",fn:Tf,effect:Ef,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function wi(s){return s.split("-")[1]}var Sf={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Lf(s,t){var e=s.x,i=s.y,r=t.devicePixelRatio||1;return{x:Ti(e*r)/r||0,y:Ti(i*r)/r||0}}function Al(s){var t,e=s.popper,i=s.popperRect,r=s.placement,n=s.variation,a=s.offsets,o=s.position,l=s.gpuAcceleration,h=s.adaptive,d=s.roundOffsets,c=s.isFixed,u=a.x,f=u===void 0?0:u,p=a.y,g=p===void 0?0:p,m=typeof d=="function"?d({x:f,y:g}):{x:f,y:g};f=m.x,g=m.y;var b=a.hasOwnProperty("x"),A=a.hasOwnProperty("y"),T=Vt,y=Gt,w=window;if(h){var S=dr(e),L="clientHeight",C="clientWidth";if(S===Zt(e)&&(S=Me(e),Le(S).position!=="static"&&o==="absolute"&&(L="scrollHeight",C="scrollWidth")),S=S,r===Gt||(r===Vt||r===Qt)&&n===lr){y=Jt;var k=c&&S===w&&w.visualViewport?w.visualViewport.height:S[L];g-=k-i.height,g*=l?1:-1}if(r===Vt||(r===Gt||r===Jt)&&n===lr){T=Qt;var x=c&&S===w&&w.visualViewport?w.visualViewport.width:S[C];f-=x-i.width,f*=l?1:-1}}var N=Object.assign({position:o},h&&Sf),O=d===!0?Lf({x:f,y:g},Zt(e)):{x:f,y:g};if(f=O.x,g=O.y,l){var V;return Object.assign({},N,(V={},V[y]=A?"0":"",V[T]=b?"0":"",V.transform=(w.devicePixelRatio||1)<=1?"translate("+f+"px, "+g+"px)":"translate3d("+f+"px, "+g+"px, 0)",V))}return Object.assign({},N,(t={},t[y]=A?g+"px":"",t[T]=b?f+"px":"",t.transform="",t))}function Rf(s){var t=s.state,e=s.options,i=e.gpuAcceleration,r=i===void 0?!0:i,n=e.adaptive,a=n===void 0?!0:n,o=e.roundOffsets,l=o===void 0?!0:o,h={placement:fe(t.placement),variation:wi(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:r,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,Al(Object.assign({},h,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:a,roundOffsets:l})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,Al(Object.assign({},h,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const xf={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Rf,data:{}};var $r={passive:!0};function kf(s){var t=s.state,e=s.instance,i=s.options,r=i.scroll,n=r===void 0?!0:r,a=i.resize,o=a===void 0?!0:a,l=Zt(t.elements.popper),h=[].concat(t.scrollParents.reference,t.scrollParents.popper);return n&&h.forEach(function(d){d.addEventListener("scroll",e.update,$r)}),o&&l.addEventListener("resize",e.update,$r),function(){n&&h.forEach(function(d){d.removeEventListener("scroll",e.update,$r)}),o&&l.removeEventListener("resize",e.update,$r)}}const Df={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:kf,data:{}};var Cf={left:"right",right:"left",bottom:"top",top:"bottom"};function ts(s){return s.replace(/left|right|bottom|top/g,function(t){return Cf[t]})}var If={start:"end",end:"start"};function Tl(s){return s.replace(/start|end/g,function(t){return If[t]})}function xn(s){var t=Zt(s),e=t.pageXOffset,i=t.pageYOffset;return{scrollLeft:e,scrollTop:i}}function kn(s){return Ei(Me(s)).left+xn(s).scrollLeft}function Pf(s,t){var e=Zt(s),i=Me(s),r=e.visualViewport,n=i.clientWidth,a=i.clientHeight,o=0,l=0;if(r){n=r.width,a=r.height;var h=pl();(h||!h&&t==="fixed")&&(o=r.offsetLeft,l=r.offsetTop)}return{width:n,height:a,x:o+kn(s),y:l}}function Of(s){var t,e=Me(s),i=xn(s),r=(t=s.ownerDocument)==null?void 0:t.body,n=ei(e.scrollWidth,e.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),a=ei(e.scrollHeight,e.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),o=-i.scrollLeft+kn(s),l=-i.scrollTop;return Le(r||e).direction==="rtl"&&(o+=ei(e.clientWidth,r?r.clientWidth:0)-n),{width:n,height:a,x:o,y:l}}function Dn(s){var t=Le(s),e=t.overflow,i=t.overflowX,r=t.overflowY;return/auto|scroll|overlay|hidden/.test(e+r+i)}function El(s){return["html","body","#document"].indexOf(ue(s))>=0?s.ownerDocument.body:_t(s)&&Dn(s)?s:El(_r(s))}function ur(s,t){var e;t===void 0&&(t=[]);var i=El(s),r=i===((e=s.ownerDocument)==null?void 0:e.body),n=Zt(i),a=r?[n].concat(n.visualViewport||[],Dn(i)?i:[]):i,o=t.concat(a);return r?o:o.concat(ur(_r(a)))}function Cn(s){return Object.assign({},s,{left:s.x,top:s.y,right:s.x+s.width,bottom:s.y+s.height})}function Mf(s,t){var e=Ei(s,!1,t==="fixed");return e.top=e.top+s.clientTop,e.left=e.left+s.clientLeft,e.bottom=e.top+s.clientHeight,e.right=e.left+s.clientWidth,e.width=s.clientWidth,e.height=s.clientHeight,e.x=e.left,e.y=e.top,e}function wl(s,t,e){return t===dl?Cn(Pf(s,e)):ti(t)?Mf(t,e):Cn(Of(Me(s)))}function Ff(s){var t=ur(_r(s)),e=["absolute","fixed"].indexOf(Le(s).position)>=0,i=e&&_t(s)?dr(s):s;return ti(i)?t.filter(function(r){return ti(r)&&gl(r,i)&&ue(r)!=="body"}):[]}function Nf(s,t,e,i){var r=t==="clippingParents"?Ff(s):[].concat(t),n=[].concat(r,[e]),a=n[0],o=n.reduce(function(l,h){var d=wl(s,h,i);return l.top=ei(d.top,l.top),l.right=Qr(d.right,l.right),l.bottom=Qr(d.bottom,l.bottom),l.left=ei(d.left,l.left),l},wl(s,a,i));return o.width=o.right-o.left,o.height=o.bottom-o.top,o.x=o.left,o.y=o.top,o}function Sl(s){var t=s.reference,e=s.element,i=s.placement,r=i?fe(i):null,n=i?wi(i):null,a=t.x+t.width/2-e.width/2,o=t.y+t.height/2-e.height/2,l;switch(r){case Gt:l={x:a,y:t.y-e.height};break;case Jt:l={x:a,y:t.y+t.height};break;case Qt:l={x:t.x+t.width,y:o};break;case Vt:l={x:t.x-e.width,y:o};break;default:l={x:t.x,y:t.y}}var h=r?Rn(r):null;if(h!=null){var d=h==="y"?"height":"width";switch(n){case Ai:l[h]=l[h]-(t[d]/2-e[d]/2);break;case lr:l[h]=l[h]+(t[d]/2-e[d]/2);break}}return l}function fr(s,t){t===void 0&&(t={});var e=t,i=e.placement,r=i===void 0?s.placement:i,n=e.strategy,a=n===void 0?s.strategy:n,o=e.boundary,l=o===void 0?rf:o,h=e.rootBoundary,d=h===void 0?dl:h,c=e.elementContext,u=c===void 0?hr:c,f=e.altBoundary,p=f===void 0?!1:f,g=e.padding,m=g===void 0?0:g,b=yl(typeof m!="number"?m:bl(m,or)),A=u===hr?sf:hr,T=s.rects.popper,y=s.elements[p?A:u],w=Nf(ti(y)?y:y.contextElement||Me(s.elements.popper),l,d,a),S=Ei(s.elements.reference),L=Sl({reference:S,element:T,strategy:"absolute",placement:r}),C=Cn(Object.assign({},T,L)),k=u===hr?C:S,x={top:w.top-k.top+b.top,bottom:k.bottom-w.bottom+b.bottom,left:w.left-k.left+b.left,right:k.right-w.right+b.right},N=s.modifiersData.offset;if(u===hr&&N){var O=N[r];Object.keys(x).forEach(function(V){var W=[Qt,Jt].indexOf(V)>=0?1:-1,E=[Gt,Jt].indexOf(V)>=0?"y":"x";x[V]+=O[E]*W})}return x}function Uf(s,t){t===void 0&&(t={});var e=t,i=e.placement,r=e.boundary,n=e.rootBoundary,a=e.padding,o=e.flipVariations,l=e.allowedAutoPlacements,h=l===void 0?ul:l,d=wi(i),c=d?o?cl:cl.filter(function(p){return wi(p)===d}):or,u=c.filter(function(p){return h.indexOf(p)>=0});u.length===0&&(u=c);var f=u.reduce(function(p,g){return p[g]=fr(s,{placement:g,boundary:r,rootBoundary:n,padding:a})[fe(g)],p},{});return Object.keys(f).sort(function(p,g){return f[p]-f[g]})}function Bf(s){if(fe(s)===En)return[];var t=ts(s);return[Tl(s),t,Tl(t)]}function Hf(s){var t=s.state,e=s.options,i=s.name;if(!t.modifiersData[i]._skip){for(var r=e.mainAxis,n=r===void 0?!0:r,a=e.altAxis,o=a===void 0?!0:a,l=e.fallbackPlacements,h=e.padding,d=e.boundary,c=e.rootBoundary,u=e.altBoundary,f=e.flipVariations,p=f===void 0?!0:f,g=e.allowedAutoPlacements,m=t.options.placement,b=fe(m),A=b===m,T=l||(A||!p?[ts(m)]:Bf(m)),y=[m].concat(T).reduce(function(st,tt){return st.concat(fe(tt)===En?Uf(t,{placement:tt,boundary:d,rootBoundary:c,padding:h,flipVariations:p,allowedAutoPlacements:g}):tt)},[]),w=t.rects.reference,S=t.rects.popper,L=new Map,C=!0,k=y[0],x=0;x<y.length;x++){var N=y[x],O=fe(N),V=wi(N)===Ai,W=[Gt,Jt].indexOf(O)>=0,E=W?"width":"height",I=fr(t,{placement:N,boundary:d,rootBoundary:c,altBoundary:u,padding:h}),B=W?V?Qt:Vt:V?Jt:Gt;w[E]>S[E]&&(B=ts(B));var U=ts(B),H=[];if(n&&H.push(I[O]<=0),o&&H.push(I[B]<=0,I[U]<=0),H.every(function(st){return st})){k=N,C=!1;break}L.set(N,H)}if(C)for(var j=p?3:1,J=function(tt){var Pt=y.find(function(Lt){var yt=L.get(Lt);if(yt)return yt.slice(0,tt).every(function(Te){return Te})});if(Pt)return k=Pt,"break"},$=j;$>0;$--){var Q=J($);if(Q==="break")break}t.placement!==k&&(t.modifiersData[i]._skip=!0,t.placement=k,t.reset=!0)}}const Gf={name:"flip",enabled:!0,phase:"main",fn:Hf,requiresIfExists:["offset"],data:{_skip:!1}};function Ll(s,t,e){return e===void 0&&(e={x:0,y:0}),{top:s.top-t.height-e.y,right:s.right-t.width+e.x,bottom:s.bottom-t.height+e.y,left:s.left-t.width-e.x}}function Rl(s){return[Gt,Qt,Jt,Vt].some(function(t){return s[t]>=0})}function Vf(s){var t=s.state,e=s.name,i=t.rects.reference,r=t.rects.popper,n=t.modifiersData.preventOverflow,a=fr(t,{elementContext:"reference"}),o=fr(t,{altBoundary:!0}),l=Ll(a,i),h=Ll(o,r,n),d=Rl(l),c=Rl(h);t.modifiersData[e]={referenceClippingOffsets:l,popperEscapeOffsets:h,isReferenceHidden:d,hasPopperEscaped:c},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":c})}const jf={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Vf};function zf(s,t,e){var i=fe(s),r=[Vt,Gt].indexOf(i)>=0?-1:1,n=typeof e=="function"?e(Object.assign({},t,{placement:s})):e,a=n[0],o=n[1];return a=a||0,o=(o||0)*r,[Vt,Qt].indexOf(i)>=0?{x:o,y:a}:{x:a,y:o}}function Kf(s){var t=s.state,e=s.options,i=s.name,r=e.offset,n=r===void 0?[0,0]:r,a=ul.reduce(function(d,c){return d[c]=zf(c,t.rects,n),d},{}),o=a[t.placement],l=o.x,h=o.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=h),t.modifiersData[i]=a}const Wf={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Kf};function Yf(s){var t=s.state,e=s.name;t.modifiersData[e]=Sl({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const Xf={name:"popperOffsets",enabled:!0,phase:"read",fn:Yf,data:{}};function qf(s){return s==="x"?"y":"x"}function Zf(s){var t=s.state,e=s.options,i=s.name,r=e.mainAxis,n=r===void 0?!0:r,a=e.altAxis,o=a===void 0?!1:a,l=e.boundary,h=e.rootBoundary,d=e.altBoundary,c=e.padding,u=e.tether,f=u===void 0?!0:u,p=e.tetherOffset,g=p===void 0?0:p,m=fr(t,{boundary:l,rootBoundary:h,padding:c,altBoundary:d}),b=fe(t.placement),A=wi(t.placement),T=!A,y=Rn(b),w=qf(y),S=t.modifiersData.popperOffsets,L=t.rects.reference,C=t.rects.popper,k=typeof g=="function"?g(Object.assign({},t.rects,{placement:t.placement})):g,x=typeof k=="number"?{mainAxis:k,altAxis:k}:Object.assign({mainAxis:0,altAxis:0},k),N=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,O={x:0,y:0};if(S){if(n){var V,W=y==="y"?Gt:Vt,E=y==="y"?Jt:Qt,I=y==="y"?"height":"width",B=S[y],U=B+m[W],H=B-m[E],j=f?-C[I]/2:0,J=A===Ai?L[I]:C[I],$=A===Ai?-C[I]:-L[I],Q=t.elements.arrow,st=f&&Q?Ln(Q):{width:0,height:0},tt=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:vl(),Pt=tt[W],Lt=tt[E],yt=cr(0,L[I],st[I]),Te=T?L[I]/2-j-yt-Pt-x.mainAxis:J-yt-Pt-x.mainAxis,bt=T?-L[I]/2+j+yt+Lt+x.mainAxis:$+yt+Lt+x.mainAxis,je=t.elements.arrow&&dr(t.elements.arrow),Ni=je?y==="y"?je.clientTop||0:je.clientLeft||0:0,ze=(V=N==null?void 0:N[y])!=null?V:0,hi=B+Te-ze-Ni,At=B+bt-ze,vt=cr(f?Qr(U,hi):U,B,f?ei(H,At):H);S[y]=vt,O[y]=vt-B}if(o){var Xt,ut=y==="x"?Gt:Vt,Tt=y==="x"?Jt:Qt,Ot=S[w],qt=w==="y"?"height":"width",Lr=Ot+m[ut],di=Ot-m[Tt],Rr=[Gt,Vt].indexOf(b)!==-1,Cs=(Xt=N==null?void 0:N[w])!=null?Xt:0,Is=Rr?Lr:Ot-L[qt]-C[qt]-Cs+x.altAxis,Ps=Rr?Ot+L[qt]+C[qt]-Cs-x.altAxis:di,Os=f&&Rr?bf(Is,Ot,Ps):cr(f?Is:Lr,Ot,f?Ps:di);S[w]=Os,O[w]=Os-Ot}t.modifiersData[i]=O}}const Jf={name:"preventOverflow",enabled:!0,phase:"main",fn:Zf,requiresIfExists:["offset"]};function Qf(s){return{scrollLeft:s.scrollLeft,scrollTop:s.scrollTop}}function _f(s){return s===Zt(s)||!_t(s)?xn(s):Qf(s)}function $f(s){var t=s.getBoundingClientRect(),e=Ti(t.width)/s.offsetWidth||1,i=Ti(t.height)/s.offsetHeight||1;return e!==1||i!==1}function tp(s,t,e){e===void 0&&(e=!1);var i=_t(t),r=_t(t)&&$f(t),n=Me(t),a=Ei(s,r,e),o={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(i||!i&&!e)&&((ue(t)!=="body"||Dn(n))&&(o=_f(t)),_t(t)?(l=Ei(t,!0),l.x+=t.clientLeft,l.y+=t.clientTop):n&&(l.x=kn(n))),{x:a.left+o.scrollLeft-l.x,y:a.top+o.scrollTop-l.y,width:a.width,height:a.height}}function ep(s){var t=new Map,e=new Set,i=[];s.forEach(function(n){t.set(n.name,n)});function r(n){e.add(n.name);var a=[].concat(n.requires||[],n.requiresIfExists||[]);a.forEach(function(o){if(!e.has(o)){var l=t.get(o);l&&r(l)}}),i.push(n)}return s.forEach(function(n){e.has(n.name)||r(n)}),i}function ip(s){var t=ep(s);return pf.reduce(function(e,i){return e.concat(t.filter(function(r){return r.phase===i}))},[])}function rp(s){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(s())})})),t}}function sp(s){var t=s.reduce(function(e,i){var r=e[i.name];return e[i.name]=r?Object.assign({},r,i,{options:Object.assign({},r.options,i.options),data:Object.assign({},r.data,i.data)}):i,e},{});return Object.keys(t).map(function(e){return t[e]})}var xl={placement:"bottom",modifiers:[],strategy:"absolute"};function kl(){for(var s=arguments.length,t=new Array(s),e=0;e<s;e++)t[e]=arguments[e];return!t.some(function(i){return!(i&&typeof i.getBoundingClientRect=="function")})}function np(s){s===void 0&&(s={});var t=s,e=t.defaultModifiers,i=e===void 0?[]:e,r=t.defaultOptions,n=r===void 0?xl:r;return function(o,l,h){h===void 0&&(h=n);var d={placement:"bottom",orderedModifiers:[],options:Object.assign({},xl,n),modifiersData:{},elements:{reference:o,popper:l},attributes:{},styles:{}},c=[],u=!1,f={state:d,setOptions:function(b){var A=typeof b=="function"?b(d.options):b;g(),d.options=Object.assign({},n,d.options,A),d.scrollParents={reference:ti(o)?ur(o):o.contextElement?ur(o.contextElement):[],popper:ur(l)};var T=ip(sp([].concat(i,d.options.modifiers)));return d.orderedModifiers=T.filter(function(y){return y.enabled}),p(),f.update()},forceUpdate:function(){if(!u){var b=d.elements,A=b.reference,T=b.popper;if(kl(A,T)){d.rects={reference:tp(A,dr(T),d.options.strategy==="fixed"),popper:Ln(T)},d.reset=!1,d.placement=d.options.placement,d.orderedModifiers.forEach(function(x){return d.modifiersData[x.name]=Object.assign({},x.data)});for(var y=0;y<d.orderedModifiers.length;y++){if(d.reset===!0){d.reset=!1,y=-1;continue}var w=d.orderedModifiers[y],S=w.fn,L=w.options,C=L===void 0?{}:L,k=w.name;typeof S=="function"&&(d=S({state:d,options:C,name:k,instance:f})||d)}}}},update:rp(function(){return new Promise(function(m){f.forceUpdate(),m(d)})}),destroy:function(){g(),u=!0}};if(!kl(o,l))return f;f.setOptions(h).then(function(m){!u&&h.onFirstUpdate&&h.onFirstUpdate(m)});function p(){d.orderedModifiers.forEach(function(m){var b=m.name,A=m.options,T=A===void 0?{}:A,y=m.effect;if(typeof y=="function"){var w=y({state:d,name:b,instance:f,options:T}),S=function(){};c.push(w||S)}})}function g(){c.forEach(function(m){return m()}),c=[]}return f}}var ap=[Df,Xf,xf,fl,Wf,Gf,Jf,wf,jf],op=np({defaultModifiers:ap}),lp="tippy-box",Dl="tippy-content",hp="tippy-backdrop",Cl="tippy-arrow",Il="tippy-svg-arrow",ii={passive:!0,capture:!0},Pl=function(){return document.body};function In(s,t,e){if(Array.isArray(s)){var i=s[t];return i??(Array.isArray(e)?e[t]:e)}return s}function Pn(s,t){var e={}.toString.call(s);return e.indexOf("[object")===0&&e.indexOf(t+"]")>-1}function Ol(s,t){return typeof s=="function"?s.apply(void 0,t):s}function Ml(s,t){if(t===0)return s;var e;return function(i){clearTimeout(e),e=setTimeout(function(){s(i)},t)}}function dp(s){return s.split(/\s+/).filter(Boolean)}function Si(s){return[].concat(s)}function Fl(s,t){s.indexOf(t)===-1&&s.push(t)}function cp(s){return s.filter(function(t,e){return s.indexOf(t)===e})}function up(s){return s.split("-")[0]}function es(s){return[].slice.call(s)}function Nl(s){return Object.keys(s).reduce(function(t,e){return s[e]!==void 0&&(t[e]=s[e]),t},{})}function pr(){return document.createElement("div")}function is(s){return["Element","Fragment"].some(function(t){return Pn(s,t)})}function fp(s){return Pn(s,"NodeList")}function pp(s){return Pn(s,"MouseEvent")}function gp(s){return!!(s&&s._tippy&&s._tippy.reference===s)}function mp(s){return is(s)?[s]:fp(s)?es(s):Array.isArray(s)?s:es(document.querySelectorAll(s))}function On(s,t){s.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function Ul(s,t){s.forEach(function(e){e&&e.setAttribute("data-state",t)})}function vp(s){var t,e=Si(s),i=e[0];return i!=null&&(t=i.ownerDocument)!=null&&t.body?i.ownerDocument:document}function yp(s,t){var e=t.clientX,i=t.clientY;return s.every(function(r){var n=r.popperRect,a=r.popperState,o=r.props,l=o.interactiveBorder,h=up(a.placement),d=a.modifiersData.offset;if(!d)return!0;var c=h==="bottom"?d.top.y:0,u=h==="top"?d.bottom.y:0,f=h==="right"?d.left.x:0,p=h==="left"?d.right.x:0,g=n.top-i+c>l,m=i-n.bottom-u>l,b=n.left-e+f>l,A=e-n.right-p>l;return g||m||b||A})}function Mn(s,t,e){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(r){s[i](r,e)})}function Bl(s,t){for(var e=t;e;){var i;if(s.contains(e))return!0;e=e.getRootNode==null||(i=e.getRootNode())==null?void 0:i.host}return!1}var pe={isTouch:!1},Hl=0;function bp(){pe.isTouch||(pe.isTouch=!0,window.performance&&document.addEventListener("mousemove",Gl))}function Gl(){var s=performance.now();s-Hl<20&&(pe.isTouch=!1,document.removeEventListener("mousemove",Gl)),Hl=s}function Ap(){var s=document.activeElement;if(gp(s)){var t=s._tippy;s.blur&&!t.state.isVisible&&s.blur()}}function Tp(){document.addEventListener("touchstart",bp,ii),window.addEventListener("blur",Ap)}var Ep=typeof window<"u"&&typeof document<"u",wp=Ep?!!window.msCrypto:!1,Sp={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},Lp={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},ae=Object.assign({appendTo:Pl,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},Sp,Lp),Rp=Object.keys(ae),xp=function(t){var e=Object.keys(t);e.forEach(function(i){ae[i]=t[i]})};function Vl(s){var t=s.plugins||[],e=t.reduce(function(i,r){var n=r.name,a=r.defaultValue;if(n){var o;i[n]=s[n]!==void 0?s[n]:(o=ae[n])!=null?o:a}return i},{});return Object.assign({},s,e)}function kp(s,t){var e=t?Object.keys(Vl(Object.assign({},ae,{plugins:t}))):Rp,i=e.reduce(function(r,n){var a=(s.getAttribute("data-tippy-"+n)||"").trim();if(!a)return r;if(n==="content")r[n]=a;else try{r[n]=JSON.parse(a)}catch{r[n]=a}return r},{});return i}function jl(s,t){var e=Object.assign({},t,{content:Ol(t.content,[s])},t.ignoreAttributes?{}:kp(s,t.plugins));return e.aria=Object.assign({},ae.aria,e.aria),e.aria={expanded:e.aria.expanded==="auto"?t.interactive:e.aria.expanded,content:e.aria.content==="auto"?t.interactive?null:"describedby":e.aria.content},e}var Dp=function(){return"innerHTML"};function Fn(s,t){s[Dp()]=t}function zl(s){var t=pr();return s===!0?t.className=Cl:(t.className=Il,is(s)?t.appendChild(s):Fn(t,s)),t}function Kl(s,t){is(t.content)?(Fn(s,""),s.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?Fn(s,t.content):s.textContent=t.content)}function Nn(s){var t=s.firstElementChild,e=es(t.children);return{box:t,content:e.find(function(i){return i.classList.contains(Dl)}),arrow:e.find(function(i){return i.classList.contains(Cl)||i.classList.contains(Il)}),backdrop:e.find(function(i){return i.classList.contains(hp)})}}function Wl(s){var t=pr(),e=pr();e.className=lp,e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var i=pr();i.className=Dl,i.setAttribute("data-state","hidden"),Kl(i,s.props),t.appendChild(e),e.appendChild(i),r(s.props,s.props);function r(n,a){var o=Nn(t),l=o.box,h=o.content,d=o.arrow;a.theme?l.setAttribute("data-theme",a.theme):l.removeAttribute("data-theme"),typeof a.animation=="string"?l.setAttribute("data-animation",a.animation):l.removeAttribute("data-animation"),a.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth=typeof a.maxWidth=="number"?a.maxWidth+"px":a.maxWidth,a.role?l.setAttribute("role",a.role):l.removeAttribute("role"),(n.content!==a.content||n.allowHTML!==a.allowHTML)&&Kl(h,s.props),a.arrow?d?n.arrow!==a.arrow&&(l.removeChild(d),l.appendChild(zl(a.arrow))):l.appendChild(zl(a.arrow)):d&&l.removeChild(d)}return{popper:t,onUpdate:r}}Wl.$$tippy=!0;var Cp=1,rs=[],Un=[];function Ip(s,t){var e=jl(s,Object.assign({},ae,Vl(Nl(t)))),i,r,n,a=!1,o=!1,l=!1,h=!1,d,c,u,f=[],p=Ml(hi,e.interactiveDebounce),g,m=Cp++,b=null,A=cp(e.plugins),T={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},y={id:m,reference:s,popper:pr(),popperInstance:b,props:e,state:T,plugins:A,clearDelayTimeouts:Is,setProps:Ps,setContent:Os,show:Ly,hide:Ry,hideWithInteractivity:xy,enable:Rr,disable:Cs,unmount:ky,destroy:Dy};if(!e.render)return y;var w=e.render(y),S=w.popper,L=w.onUpdate;S.setAttribute("data-tippy-root",""),S.id="tippy-"+y.id,y.popper=S,s._tippy=y,S._tippy=y;var C=A.map(function(M){return M.fn(y)}),k=s.hasAttribute("aria-expanded");return je(),j(),B(),U("onCreate",[y]),e.showOnCreate&&Lr(),S.addEventListener("mouseenter",function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()}),S.addEventListener("mouseleave",function(){y.props.interactive&&y.props.trigger.indexOf("mouseenter")>=0&&W().addEventListener("mousemove",p)}),y;function x(){var M=y.props.touch;return Array.isArray(M)?M:[M,0]}function N(){return x()[0]==="hold"}function O(){var M;return!!((M=y.props.render)!=null&&M.$$tippy)}function V(){return g||s}function W(){var M=V().parentNode;return M?vp(M):document}function E(){return Nn(S)}function I(M){return y.state.isMounted&&!y.state.isVisible||pe.isTouch||d&&d.type==="focus"?0:In(y.props.delay,M?0:1,ae.delay)}function B(M){M===void 0&&(M=!1),S.style.pointerEvents=y.props.interactive&&!M?"":"none",S.style.zIndex=""+y.props.zIndex}function U(M,z,Z){if(Z===void 0&&(Z=!0),C.forEach(function(it){it[M]&&it[M].apply(it,z)}),Z){var nt;(nt=y.props)[M].apply(nt,z)}}function H(){var M=y.props.aria;if(M.content){var z="aria-"+M.content,Z=S.id,nt=Si(y.props.triggerTarget||s);nt.forEach(function(it){var Ht=it.getAttribute(z);if(y.state.isVisible)it.setAttribute(z,Ht?Ht+" "+Z:Z);else{var ie=Ht&&Ht.replace(Z,"").trim();ie?it.setAttribute(z,ie):it.removeAttribute(z)}})}}function j(){if(!(k||!y.props.aria.expanded)){var M=Si(y.props.triggerTarget||s);M.forEach(function(z){y.props.interactive?z.setAttribute("aria-expanded",y.state.isVisible&&z===V()?"true":"false"):z.removeAttribute("aria-expanded")})}}function J(){W().removeEventListener("mousemove",p),rs=rs.filter(function(M){return M!==p})}function $(M){if(!(pe.isTouch&&(l||M.type==="mousedown"))){var z=M.composedPath&&M.composedPath()[0]||M.target;if(!(y.props.interactive&&Bl(S,z))){if(Si(y.props.triggerTarget||s).some(function(Z){return Bl(Z,z)})){if(pe.isTouch||y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else U("onClickOutside",[y,M]);y.props.hideOnClick===!0&&(y.clearDelayTimeouts(),y.hide(),o=!0,setTimeout(function(){o=!1}),y.state.isMounted||Pt())}}}function Q(){l=!0}function st(){l=!1}function tt(){var M=W();M.addEventListener("mousedown",$,!0),M.addEventListener("touchend",$,ii),M.addEventListener("touchstart",st,ii),M.addEventListener("touchmove",Q,ii)}function Pt(){var M=W();M.removeEventListener("mousedown",$,!0),M.removeEventListener("touchend",$,ii),M.removeEventListener("touchstart",st,ii),M.removeEventListener("touchmove",Q,ii)}function Lt(M,z){Te(M,function(){!y.state.isVisible&&S.parentNode&&S.parentNode.contains(S)&&z()})}function yt(M,z){Te(M,z)}function Te(M,z){var Z=E().box;function nt(it){it.target===Z&&(Mn(Z,"remove",nt),z())}if(M===0)return z();Mn(Z,"remove",c),Mn(Z,"add",nt),c=nt}function bt(M,z,Z){Z===void 0&&(Z=!1);var nt=Si(y.props.triggerTarget||s);nt.forEach(function(it){it.addEventListener(M,z,Z),f.push({node:it,eventType:M,handler:z,options:Z})})}function je(){N()&&(bt("touchstart",ze,{passive:!0}),bt("touchend",At,{passive:!0})),dp(y.props.trigger).forEach(function(M){if(M!=="manual")switch(bt(M,ze),M){case"mouseenter":bt("mouseleave",At);break;case"focus":bt(wp?"focusout":"blur",vt);break;case"focusin":bt("focusout",vt);break}})}function Ni(){f.forEach(function(M){var z=M.node,Z=M.eventType,nt=M.handler,it=M.options;z.removeEventListener(Z,nt,it)}),f=[]}function ze(M){var z,Z=!1;if(!(!y.state.isEnabled||Xt(M)||o)){var nt=((z=d)==null?void 0:z.type)==="focus";d=M,g=M.currentTarget,j(),!y.state.isVisible&&pp(M)&&rs.forEach(function(it){return it(M)}),M.type==="click"&&(y.props.trigger.indexOf("mouseenter")<0||a)&&y.props.hideOnClick!==!1&&y.state.isVisible?Z=!0:Lr(M),M.type==="click"&&(a=!Z),Z&&!nt&&di(M)}}function hi(M){var z=M.target,Z=V().contains(z)||S.contains(z);if(!(M.type==="mousemove"&&Z)){var nt=qt().concat(S).map(function(it){var Ht,ie=it._tippy,Ui=(Ht=ie.popperInstance)==null?void 0:Ht.state;return Ui?{popperRect:it.getBoundingClientRect(),popperState:Ui,props:e}:null}).filter(Boolean);yp(nt,M)&&(J(),di(M))}}function At(M){var z=Xt(M)||y.props.trigger.indexOf("click")>=0&&a;if(!z){if(y.props.interactive){y.hideWithInteractivity(M);return}di(M)}}function vt(M){y.props.trigger.indexOf("focusin")<0&&M.target!==V()||y.props.interactive&&M.relatedTarget&&S.contains(M.relatedTarget)||di(M)}function Xt(M){return pe.isTouch?N()!==M.type.indexOf("touch")>=0:!1}function ut(){Tt();var M=y.props,z=M.popperOptions,Z=M.placement,nt=M.offset,it=M.getReferenceClientRect,Ht=M.moveTransition,ie=O()?Nn(S).arrow:null,Ui=it?{getBoundingClientRect:it,contextElement:it.contextElement||V()}:s,tc={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Ms){var Bi=Ms.state;if(O()){var Cy=E(),Ya=Cy.box;["placement","reference-hidden","escaped"].forEach(function(Fs){Fs==="placement"?Ya.setAttribute("data-placement",Bi.placement):Bi.attributes.popper["data-popper-"+Fs]?Ya.setAttribute("data-"+Fs,""):Ya.removeAttribute("data-"+Fs)}),Bi.attributes.popper={}}}},ci=[{name:"offset",options:{offset:nt}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!Ht}},tc];O()&&ie&&ci.push({name:"arrow",options:{element:ie,padding:3}}),ci.push.apply(ci,(z==null?void 0:z.modifiers)||[]),y.popperInstance=op(Ui,S,Object.assign({},z,{placement:Z,onFirstUpdate:u,modifiers:ci}))}function Tt(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function Ot(){var M=y.props.appendTo,z,Z=V();y.props.interactive&&M===Pl||M==="parent"?z=Z.parentNode:z=Ol(M,[Z]),z.contains(S)||z.appendChild(S),y.state.isMounted=!0,ut()}function qt(){return es(S.querySelectorAll("[data-tippy-root]"))}function Lr(M){y.clearDelayTimeouts(),M&&U("onTrigger",[y,M]),tt();var z=I(!0),Z=x(),nt=Z[0],it=Z[1];pe.isTouch&&nt==="hold"&&it&&(z=it),z?i=setTimeout(function(){y.show()},z):y.show()}function di(M){if(y.clearDelayTimeouts(),U("onUntrigger",[y,M]),!y.state.isVisible){Pt();return}if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(M.type)>=0&&a)){var z=I(!1);z?r=setTimeout(function(){y.state.isVisible&&y.hide()},z):n=requestAnimationFrame(function(){y.hide()})}}function Rr(){y.state.isEnabled=!0}function Cs(){y.hide(),y.state.isEnabled=!1}function Is(){clearTimeout(i),clearTimeout(r),cancelAnimationFrame(n)}function Ps(M){if(!y.state.isDestroyed){U("onBeforeUpdate",[y,M]),Ni();var z=y.props,Z=jl(s,Object.assign({},z,Nl(M),{ignoreAttributes:!0}));y.props=Z,je(),z.interactiveDebounce!==Z.interactiveDebounce&&(J(),p=Ml(hi,Z.interactiveDebounce)),z.triggerTarget&&!Z.triggerTarget?Si(z.triggerTarget).forEach(function(nt){nt.removeAttribute("aria-expanded")}):Z.triggerTarget&&s.removeAttribute("aria-expanded"),j(),B(),L&&L(z,Z),y.popperInstance&&(ut(),qt().forEach(function(nt){requestAnimationFrame(nt._tippy.popperInstance.forceUpdate)})),U("onAfterUpdate",[y,M])}}function Os(M){y.setProps({content:M})}function Ly(){var M=y.state.isVisible,z=y.state.isDestroyed,Z=!y.state.isEnabled,nt=pe.isTouch&&!y.props.touch,it=In(y.props.duration,0,ae.duration);if(!(M||z||Z||nt)&&!V().hasAttribute("disabled")&&(U("onShow",[y],!1),y.props.onShow(y)!==!1)){if(y.state.isVisible=!0,O()&&(S.style.visibility="visible"),B(),tt(),y.state.isMounted||(S.style.transition="none"),O()){var Ht=E(),ie=Ht.box,Ui=Ht.content;On([ie,Ui],0)}u=function(){var ci;if(!(!y.state.isVisible||h)){if(h=!0,S.offsetHeight,S.style.transition=y.props.moveTransition,O()&&y.props.animation){var Wa=E(),Ms=Wa.box,Bi=Wa.content;On([Ms,Bi],it),Ul([Ms,Bi],"visible")}H(),j(),Fl(Un,y),(ci=y.popperInstance)==null||ci.forceUpdate(),U("onMount",[y]),y.props.animation&&O()&&yt(it,function(){y.state.isShown=!0,U("onShown",[y])})}},Ot()}}function Ry(){var M=!y.state.isVisible,z=y.state.isDestroyed,Z=!y.state.isEnabled,nt=In(y.props.duration,1,ae.duration);if(!(M||z||Z)&&(U("onHide",[y],!1),y.props.onHide(y)!==!1)){if(y.state.isVisible=!1,y.state.isShown=!1,h=!1,a=!1,O()&&(S.style.visibility="hidden"),J(),Pt(),B(!0),O()){var it=E(),Ht=it.box,ie=it.content;y.props.animation&&(On([Ht,ie],nt),Ul([Ht,ie],"hidden"))}H(),j(),y.props.animation?O()&&Lt(nt,y.unmount):y.unmount()}}function xy(M){W().addEventListener("mousemove",p),Fl(rs,p),p(M)}function ky(){y.state.isVisible&&y.hide(),y.state.isMounted&&(Tt(),qt().forEach(function(M){M._tippy.unmount()}),S.parentNode&&S.parentNode.removeChild(S),Un=Un.filter(function(M){return M!==y}),y.state.isMounted=!1,U("onHidden",[y]))}function Dy(){y.state.isDestroyed||(y.clearDelayTimeouts(),y.unmount(),Ni(),delete s._tippy,y.state.isDestroyed=!0,U("onDestroy",[y]))}}function ri(s,t){t===void 0&&(t={});var e=ae.plugins.concat(t.plugins||[]);Tp();var i=Object.assign({},t,{plugins:e}),r=mp(s),n=r.reduce(function(a,o){var l=o&&Ip(o,i);return l&&a.push(l),a},[]);return is(s)?n[0]:n}ri.defaultProps=ae,ri.setDefaultProps=xp,ri.currentInput=pe,Object.assign({},fl,{effect:function(t){var e=t.state,i={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(e.elements.popper.style,i.popper),e.styles=i,e.elements.arrow&&Object.assign(e.elements.arrow.style,i.arrow)}}),ri.setDefaultProps({render:Wl});/**
|
115
|
-
* @license
|
116
|
-
* Copyright 2018 Google LLC
|
117
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
118
|
-
*/const Yl="important",Pp=" !"+Yl,Op=bi(class extends ir{constructor(s){var t;if(super(s),s.type!==yi.ATTRIBUTE||s.name!=="style"||((t=s.strings)===null||t===void 0?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(s){return Object.keys(s).reduce((t,e)=>{const i=s[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(s,[t]){const{style:e}=s.element;if(this.ut===void 0){this.ut=new Set;for(const i in t)this.ut.add(i);return this.render(t)}this.ut.forEach(i=>{t[i]==null&&(this.ut.delete(i),i.includes("-")?e.removeProperty(i):e[i]="")});for(const i in t){const r=t[i];if(r!=null){this.ut.add(i);const n=typeof r=="string"&&r.endsWith(Pp);i.includes("-")||n?e.setProperty(i,n?r.slice(0,-11):r,n?Yl:""):e[i]=r}}return re}}),Mp=5;class Fp{constructor(t){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._fakeBufferSegments=[],this._canvas=se(),this._controls=se(),this.host=t}set activeScenes(t){if(t!==this._activeScenes){const e=t[0],i=this._activeScenes[0];this._activeScenes=t,e!==i&&(this.host.dispatchEvent(new CustomEvent("scenechange",{detail:t[0]})),this.host.requestUpdate())}}get activeScenes(){return this._activeScenes}set currentTime(t){var e,i,r,n,a;const o=Math.min(this.host.duration,Math.max(0,t));this._currentTime=o,this.activeScenes=((e=this.host.scenes)==null?void 0:e.filter(({start:d,duration:c})=>o>=d&&o<=d+c))??[],this._upcomingScenes=((i=this.host.scenes)==null?void 0:i.filter(({start:d})=>o>=d-Mp&&o<d))??[],this.loadScenes(),this.syncVideoState(),(r=this._controls.value)==null||r.setAttribute("currentTime",o.toString());const l=this.activeScenes[0],h=Zo((n=l==null?void 0:l.video)==null?void 0:n.captions);this.caption=((a=h.find(({start:d,end:c})=>{var u;const f=o-l.start+(((u=l.video)==null?void 0:u.start)??0);return d&&c&&f>=Kr(d)&&f<=Kr(c)}))==null?void 0:a.text)??"",this.draw(o),!this.host.paused&&!this.host.loading&&!this.host.processing&&!this.host.waiting&&!this.host.stalled&&this.host.dispatchEvent(new CustomEvent("timeupdate",{detail:o}))}get currentTime(){return this._currentTime}set fakeBufferSegments(t){t!==this._fakeBufferSegments&&(this._fakeBufferSegments=t,this.host.requestUpdate())}get fakeBufferSegments(){return this._fakeBufferSegments}set caption(t){t!==this._caption&&(this._caption=t,this.host.requestUpdate())}get caption(){return this._caption}canvas(){return ne(this._canvas)}controls(){return ne(this._controls)}loadScenes(){var t;let e=this.fakeBufferSegments;(t=this.host.scenes)==null||t.forEach(i=>{var r,n;const{start:a,duration:o,video:l}=i,h=this.activeScenes.includes(i),d=(this._upcomingScenes.includes(i)||h)&&(this.host.currentTime>0||this.host.preload==="auto"||!this.host.paused);if(l){const{id:c,hls:u,node:f,start:p,duration:g}=l,m=this.host.videoState[c];f&&m&&(f.currentTime>=p+g||f.ended||d&&(u?(r=u.startLoadOnce)==null||r.call(u,f.currentTime):m.initialised||(n=f.startLoadOnce)==null||n.call(f)))}else if(d){const c={start:Math.max(0,a/this.host.duration*100),end:Math.min((a+o)/this.host.duration*100,100)};this.fakeBufferSegments.find(({start:u})=>u===c.start)||(e=[...e,c])}}),this.fakeBufferSegments=e}syncVideoState(){var t;(t=this.host.scenes)==null||t.forEach(e=>{if(e.video){const{id:i,node:r}=e.video,n=this.host.videoState[i],a=this.activeScenes.includes(e);if(r&&n)if(a&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(r.paused&&n.initialised)return r.play()}else r.paused||r.pause()}})}draw(t=this.currentTime){var e,i;this.host.sceneConfig&&this._canvas.value&&((i=(e=this.host).compilation)==null||i.call(e,{currentTime:t,scenes:this.host.sceneConfig,canvas:this._canvas.value}))}clear(){var t;const e=this._canvas.value;(t=e==null?void 0:e.getContext("2d"))==null||t.clearRect(0,0,e.width,e.height)}}function Np(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Xl={exports:{}};(function(s,t){(function(e){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,h,d){if(d=d||{},l=l.trim(),h=h.trim(),!h){if(!d.alwaysNormalize)return l;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");return c.path=o.normalizePath(c.path),o.buildURLFromParts(c)}var u=o.parseURL(h);if(!u)throw new Error("Error trying to parse relative URL.");if(u.scheme)return d.alwaysNormalize?(u.path=o.normalizePath(u.path),o.buildURLFromParts(u)):h;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 p=r.exec(f.path);f.netLoc=p[1],f.path=p[2]}f.netLoc&&!f.path&&(f.path="/");var g={scheme:f.scheme,netLoc:u.netLoc,path:null,params:u.params,query:u.query,fragment:u.fragment};if(!u.netLoc&&(g.netLoc=f.netLoc,u.path[0]!=="/"))if(!u.path)g.path=f.path,u.params||(g.params=f.params,u.query||(g.query=f.query));else{var m=f.path,b=m.substring(0,m.lastIndexOf("/")+1)+u.path;g.path=o.normalizePath(b)}return g.path===null&&(g.path=d.alwaysNormalize?o.normalizePath(u.path):u.path),o.buildURLFromParts(g)},parseURL:function(l){var h=i.exec(l);return h?{scheme:h[1]||"",netLoc:h[2]||"",path:h[3]||"",params:h[4]||"",query:h[5]||"",fragment:h[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})()})(Xl);var Bn=Xl.exports;function ql(s,t){var e=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),e.push.apply(e,i)}return e}function jt(s){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?ql(Object(e),!0).forEach(function(i){Up(s,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):ql(Object(e)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(e,i))})}return s}function Up(s,t,e){return t=Hp(t),t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}function Et(){return Et=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(s[i]=e[i])}return s},Et.apply(this,arguments)}function Bp(s,t){if(typeof s!="object"||s===null)return s;var e=s[Symbol.toPrimitive];if(e!==void 0){var i=e.call(s,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(s)}function Hp(s){var t=Bp(s,"string");return typeof t=="symbol"?t:String(t)}const K=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)};let v=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.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}({}),Y=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}({}),P=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.UNKNOWN="unknown",s}({});const si=function(){},Hn={trace:si,debug:si,log:si,warn:si,info:si,error:si};let gr=Hn;function Gp(s){const t=self.console[s];return t?t.bind(self.console,`[${s}] >`):si}function Vp(s,...t){t.forEach(function(e){gr[e]=s[e]?s[e].bind(s):Gp(e)})}function jp(s,t){if(self.console&&s===!0||typeof s=="object"){Vp(s,"debug","log","info","warn","error");try{gr.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch{gr=Hn}}else gr=Hn}const R=gr,zp=/^(\d+)x(\d+)$/,Zl=/(.+?)=(".*?"|.*?)(?:,|$)/g;class dt{constructor(t){typeof t=="string"&&(t=dt.parseAttrList(t));for(const e in t)t.hasOwnProperty(e)&&(e.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(e)),this[e]=t[e])}decimalInteger(t){const e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(t){if(this[t]){let e=(this[t]||"0x").slice(2);e=(e.length&1?"0":"")+e;const i=new Uint8Array(e.length/2);for(let r=0;r<e.length/2;r++)i[r]=parseInt(e.slice(r*2,r*2+2),16);return i}else return null}hexadecimalIntegerAsNumber(t){const e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const i=this[t];return i?parseFloat(i):e}enumeratedString(t){return this[t]}bool(t){return this[t]==="YES"}decimalResolution(t){const e=zp.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const i={},r='"';for(Zl.lastIndex=0;(e=Zl.exec(t))!==null;){let n=e[2];n.indexOf(r)===0&&n.lastIndexOf(r)===n.length-1&&(n=n.slice(1,-1));const a=e[1].trim();i[a]=n}return i}}function Kp(s){return s!=="ID"&&s!=="CLASS"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function Wp(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}class Jl{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){const i=e.attr;for(const r in i)if(Object.prototype.hasOwnProperty.call(t,r)&&t[r]!==i[r]){R.warn(`DATERANGE tag attribute: "${r}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=r;break}t=Et(new dt({}),i,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const i=new Date(this.attr["END-DATE"]);K(i.getTime())&&(this._endDate=i)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const t=this.duration;return t!==null?new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(K(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&K(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class ss{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var at={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Ql{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[at.AUDIO]:null,[at.VIDEO]:null,[at.AUDIOVIDEO]:null},this.baseurl=t}setByteRange(t,e){const i=t.split("@",2),r=[];i.length===1?r[0]=e?e.byteRangeEndOffset:0:r[0]=parseInt(i[1]),r[1]=parseInt(i[0])+r[0],this._byteRange=r}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Bn.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class Gn extends Ql{constructor(t,e){super(e),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new ss,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=t}get decryptdata(){const{levelkeys:t}=this;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{const i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!K(this.programDateTime))return null;const t=K(this.duration)?this.duration:0;return this.programDateTime+t*1e3}get encrypted(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){const e=Object.keys(this.levelkeys),i=e.length;if(i>1||i===1&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(t){if(this.levelkeys){const e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}}abortRequests(){var t,e;(t=this.loader)==null||t.abort(),(e=this.keyLoader)==null||e.abort()}setElementaryStreamInfo(t,e,i,r,n,a=!1){const{elementaryStreams:o}=this,l=o[t];if(!l){o[t]={startPTS:e,endPTS:i,startDTS:r,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,e),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,r),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[at.AUDIO]=null,t[at.VIDEO]=null,t[at.AUDIOVIDEO]=null}}class Yp extends Ql{constructor(t,e,i,r,n){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new ss,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=r;const a=t.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(){const{elementaryStreams:t}=this;return!!(t.audio||t.video||t.audiovideo)}}const Xp=10;class qp{constructor(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}reloaded(t){if(!t){this.advanced=!0,this.updated=!0;return}const e=this.lastPartSn-t.lastPartSn,i=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!i||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||e===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(t.misses*.6):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?K(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Xp}get drift(){const t=this.driftEndTime-this.driftStartTime;return t>0?(this.driftEnd-this.driftStart)*1e3/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return(t=this.fragments)!=null&&t.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function Vn(s){return Uint8Array.from(atob(s),t=>t.charCodeAt(0))}function Zp(s){const t=_l(s).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e}function Jp(s){const t=function(e,i,r){const n=e[i];e[i]=e[r],e[r]=n};t(s,0,3),t(s,1,2),t(s,4,5),t(s,6,7)}function Qp(s){const t=s.split(":");let e=null;if(t[0]==="data"&&t.length===2){const i=t[1].split(";"),r=i[i.length-1].split(",");if(r.length===2){const n=r[0]==="base64",a=r[1];n?(i.splice(-1,1),e=Vn(a)):e=Zp(a)}}return e}function _l(s){return Uint8Array.from(unescape(encodeURIComponent(s)),t=>t.charCodeAt(0))}var ct={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},zt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function $l(s){switch(s){case zt.FAIRPLAY:return ct.FAIRPLAY;case zt.PLAYREADY:return ct.PLAYREADY;case zt.WIDEVINE:return ct.WIDEVINE;case zt.CLEARKEY:return ct.CLEARKEY}}var th={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function _p(s){if(s===th.WIDEVINE)return ct.WIDEVINE}function eh(s){switch(s){case ct.FAIRPLAY:return zt.FAIRPLAY;case ct.PLAYREADY:return zt.PLAYREADY;case ct.WIDEVINE:return zt.WIDEVINE;case ct.CLEARKEY:return zt.CLEARKEY}}function jn(s){const{drmSystems:t,widevineLicenseUrl:e}=s,i=t?[ct.FAIRPLAY,ct.WIDEVINE,ct.PLAYREADY,ct.CLEARKEY].filter(r=>!!t[r]):[];return!i[ct.WIDEVINE]&&e&&i.push(ct.WIDEVINE),i}const ih=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function $p(s,t,e,i){let r;switch(s){case ct.FAIRPLAY:r=["cenc","sinf"];break;case ct.WIDEVINE:case ct.PLAYREADY:r=["cenc"];break;case ct.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return tg(r,t,e,i)}function tg(s,t,e,i){return[{initDataTypes:s,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(r=>({contentType:`audio/mp4; codecs="${r}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:e.map(r=>({contentType:`video/mp4; codecs="${r}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function ni(s,t,e){return Uint8Array.prototype.slice?s.slice(t,e):new Uint8Array(Array.prototype.slice.call(s,t,e))}const zn=(s,t)=>t+10<=s.length&&s[t]===73&&s[t+1]===68&&s[t+2]===51&&s[t+3]<255&&s[t+4]<255&&s[t+6]<128&&s[t+7]<128&&s[t+8]<128&&s[t+9]<128,rh=(s,t)=>t+10<=s.length&&s[t]===51&&s[t+1]===68&&s[t+2]===73&&s[t+3]<255&&s[t+4]<255&&s[t+6]<128&&s[t+7]<128&&s[t+8]<128&&s[t+9]<128,ns=(s,t)=>{const e=t;let i=0;for(;zn(s,t);){i+=10;const r=as(s,t+6);i+=r,rh(s,t+10)&&(i+=10),t+=i}if(i>0)return s.subarray(e,e+i)},as=(s,t)=>{let e=0;return e=(s[t]&127)<<21,e|=(s[t+1]&127)<<14,e|=(s[t+2]&127)<<7,e|=s[t+3]&127,e},eg=(s,t)=>zn(s,t)&&as(s,t+6)+10<=s.length-t,ig=s=>{const t=nh(s);for(let e=0;e<t.length;e++){const i=t[e];if(sh(i))return lg(i)}},sh=s=>s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp",rg=s=>{const t=String.fromCharCode(s[0],s[1],s[2],s[3]),e=as(s,4),i=10;return{type:t,size:e,data:s.subarray(i,i+e)}},nh=s=>{let t=0;const e=[];for(;zn(s,t);){const i=as(s,t+6);t+=10;const r=t+i;for(;t+8<r;){const n=rg(s.subarray(t)),a=sg(n);a&&e.push(a),t+=n.size+10}rh(s,t)&&(t+=10)}return e},sg=s=>s.type==="PRIV"?ng(s):s.type[0]==="W"?og(s):ag(s),ng=s=>{if(s.size<2)return;const t=ge(s.data,!0),e=new Uint8Array(s.data.subarray(t.length+1));return{key:s.type,info:t,data:e.buffer}},ag=s=>{if(s.size<2)return;if(s.type==="TXXX"){let e=1;const i=ge(s.data.subarray(e),!0);e+=i.length+1;const r=ge(s.data.subarray(e));return{key:s.type,info:i,data:r}}const t=ge(s.data.subarray(1));return{key:s.type,data:t}},og=s=>{if(s.type==="WXXX"){if(s.size<2)return;let e=1;const i=ge(s.data.subarray(e),!0);e+=i.length+1;const r=ge(s.data.subarray(e));return{key:s.type,info:i,data:r}}const t=ge(s.data);return{key:s.type,data:t}},lg=s=>{if(s.data.byteLength===8){const t=new Uint8Array(s.data),e=t[3]&1;let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,e&&(i+=4772185884e-2),Math.round(i)}},ge=(s,t=!1)=>{const e=hg();if(e){const h=e.decode(s);if(t){const d=h.indexOf("\0");return d!==-1?h.substring(0,d):h}return h.replace(/\0/g,"")}const i=s.length;let r,n,a,o="",l=0;for(;l<i;){if(r=s[l++],r===0&&t)return o;if(!(r===0||r===3))switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(r);break;case 12:case 13:n=s[l++],o+=String.fromCharCode((r&31)<<6|n&63);break;case 14:n=s[l++],a=s[l++],o+=String.fromCharCode((r&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o};let Kn;function hg(){return!Kn&&typeof self.TextDecoder<"u"&&(Kn=new self.TextDecoder("utf-8")),Kn}const me={hexDump:function(s){let t="";for(let e=0;e<s.length;e++){let i=s[e].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},os=Math.pow(2,32)-1,dg=[].push,ah={video:1,audio:2,id3:3,text:4};function Ct(s){return String.fromCharCode.apply(null,s)}function oh(s,t){const e=s[t]<<8|s[t+1];return e<0?65536+e:e}function q(s,t){const e=lh(s,t);return e<0?4294967296+e:e}function lh(s,t){return s[t]<<24|s[t+1]<<16|s[t+2]<<8|s[t+3]}function Wn(s,t,e){s[t]=e>>24,s[t+1]=e>>16&255,s[t+2]=e>>8&255,s[t+3]=e&255}function et(s,t){const e=[];if(!t.length)return e;const i=s.byteLength;for(let r=0;r<i;){const n=q(s,r),a=Ct(s.subarray(r+4,r+8)),o=n>1?r+n:i;if(a===t[0])if(t.length===1)e.push(s.subarray(r+8,o));else{const l=et(s.subarray(r+8,o),t.slice(1));l.length&&dg.apply(e,l)}r=o}return e}function cg(s){const t=[],e=s[0];let i=8;const r=q(s,i);i+=4;const n=0,a=0;e===0?i+=8:i+=16,i+=2;let o=s.length+a;const l=oh(s,i);i+=2;for(let h=0;h<l;h++){let d=i;const c=q(s,d);d+=4;const u=c&2147483647;if((c&2147483648)>>>31===1)return R.warn("SIDX has hierarchical references (not supported)"),null;const f=q(s,d);d+=4,t.push({referenceSize:u,subsegmentDuration:f,info:{duration:f/r,start:o,end:o+u-1}}),o+=u,d+=4,i=d}return{earliestPresentationTime:n,timescale:r,version:e,referencesCount:l,references:t}}function hh(s){const t=[],e=et(s,["moov","trak"]);for(let i=0;i<e.length;i++){const r=e[i],n=et(r,["tkhd"])[0];if(n){let a=n[0],o=a===0?12:20;const l=q(n,o),h=et(r,["mdia","mdhd"])[0];if(h){a=h[0],o=a===0?12:20;const d=q(h,o),c=et(r,["mdia","hdlr"])[0];if(c){const u=Ct(c.subarray(8,12)),f={soun:at.AUDIO,vide:at.VIDEO}[u];if(f){const p=et(r,["mdia","minf","stbl","stsd"])[0];let g;p&&(g=Ct(p.subarray(12,16))),t[l]={timescale:d,type:f},t[f]={timescale:d,id:l,codec:g}}}}}}return et(s,["moov","mvex","trex"]).forEach(i=>{const r=q(i,4),n=t[r];n&&(n.default={duration:q(i,12),flags:q(i,20)})}),t}function ug(s,t){if(!s||!t)return s;const e=t.keyId;return e&&t.isCommonEncryption&&et(s,["moov","trak"]).forEach(i=>{const r=et(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let n=et(r,["enca"]);const a=n.length>0;a||(n=et(r,["encv"])),n.forEach(o=>{const l=a?o.subarray(28):o.subarray(78);et(l,["sinf"]).forEach(h=>{const d=dh(h);if(d){const c=d.subarray(8,24);c.some(u=>u!==0)||(R.log(`[eme] Patching keyId in 'enc${a?"a":"v"}>sinf>>tenc' box: ${me.hexDump(c)} -> ${me.hexDump(e)}`),d.set(e,8))}})})}),s}function dh(s){const t=et(s,["schm"])[0];if(t){const e=Ct(t.subarray(4,8));if(e==="cbcs"||e==="cenc")return et(s,["schi","tenc"])[0]}return R.error("[eme] missing 'schm' box"),null}function fg(s,t){return et(t,["moof","traf"]).reduce((e,i)=>{const r=et(i,["tfdt"])[0],n=r[0],a=et(i,["tfhd"]).reduce((o,l)=>{const h=q(l,4),d=s[h];if(d){let c=q(r,4);if(n===1){if(c===os)return R.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;c*=os+1,c+=q(r,8)}const u=d.timescale||9e4,f=c/u;if(isFinite(f)&&(o===null||f<o))return f}return o},null);return a!==null&&isFinite(a)&&(e===null||a<e)?a:e},null)}function pg(s,t){let e=0,i=0,r=0;const n=et(s,["moof","traf"]);for(let a=0;a<n.length;a++){const o=n[a],l=et(o,["tfhd"])[0],h=q(l,4),d=t[h];if(!d)continue;const c=d.default,u=q(l,0)|(c==null?void 0:c.flags);let f=c==null?void 0:c.duration;u&8&&(u&2?f=q(l,12):f=q(l,8));const p=d.timescale||9e4,g=et(o,["trun"]);for(let m=0;m<g.length;m++){if(e=gg(g[m]),!e&&f){const b=q(g[m],4);e=f*b}d.type===at.VIDEO?i+=e/p:d.type===at.AUDIO&&(r+=e/p)}}if(i===0&&r===0){let a=0;const o=et(s,["sidx"]);for(let l=0;l<o.length;l++){const h=cg(o[l]);h!=null&&h.references&&(a+=h.references.reduce((d,c)=>d+c.info.duration||0,0))}return a}return i||r}function gg(s){const t=q(s,0);let e=8;t&1&&(e+=4),t&4&&(e+=4);let i=0;const r=q(s,4);for(let n=0;n<r;n++){if(t&256){const a=q(s,e);i+=a,e+=4}t&512&&(e+=4),t&1024&&(e+=4),t&2048&&(e+=4)}return i}function mg(s,t,e){et(t,["moof","traf"]).forEach(i=>{et(i,["tfhd"]).forEach(r=>{const n=q(r,4),a=s[n];if(!a)return;const o=a.timescale||9e4;et(i,["tfdt"]).forEach(l=>{const h=l[0];let d=q(l,4);if(h===0)d-=e*o,d=Math.max(d,0),Wn(l,4,d);else{d*=Math.pow(2,32),d+=q(l,8),d-=e*o,d=Math.max(d,0);const c=Math.floor(d/(os+1)),u=Math.floor(d%(os+1));Wn(l,4,c),Wn(l,8,u)}})})})}function vg(s){const t={valid:null,remainder:null},e=et(s,["moof"]);if(e){if(e.length<2)return t.remainder=s,t}else return t;const i=e[e.length-1];return t.valid=ni(s,0,i.byteOffset-8),t.remainder=ni(s,i.byteOffset-8),t}function ai(s,t){const e=new Uint8Array(s.length+t.length);return e.set(s),e.set(t,s.length),e}function ch(s,t){const e=[],i=t.samples,r=t.timescale,n=t.id;let a=!1;return et(i,["moof"]).map(o=>{const l=o.byteOffset-8;et(o,["traf"]).map(h=>{const d=et(h,["tfdt"]).map(c=>{const u=c[0];let f=q(c,4);return u===1&&(f*=Math.pow(2,32),f+=q(c,8)),f/r})[0];return d!==void 0&&(s=d),et(h,["tfhd"]).map(c=>{const u=q(c,4),f=q(c,0)&16777215,p=(f&1)!==0,g=(f&2)!==0,m=(f&8)!==0;let b=0;const A=(f&16)!==0;let T=0;const y=(f&32)!==0;let w=8;u===n&&(p&&(w+=8),g&&(w+=4),m&&(b=q(c,w),w+=4),A&&(T=q(c,w),w+=4),y&&(w+=4),t.type==="video"&&(a=yg(t.codec)),et(h,["trun"]).map(S=>{const L=S[0],C=q(S,0)&16777215,k=(C&1)!==0;let x=0;const N=(C&4)!==0,O=(C&256)!==0;let V=0;const W=(C&512)!==0;let E=0;const I=(C&1024)!==0,B=(C&2048)!==0;let U=0;const H=q(S,4);let j=8;k&&(x=q(S,j),j+=4),N&&(j+=4);let J=x+l;for(let $=0;$<H;$++){if(O?(V=q(S,j),j+=4):V=b,W?(E=q(S,j),j+=4):E=T,I&&(j+=4),B&&(L===0?U=q(S,j):U=lh(S,j),j+=4),t.type===at.VIDEO){let Q=0;for(;Q<E;){const st=q(i,J);if(J+=4,bg(a,i[J])){const tt=i.subarray(J,J+st);uh(tt,a?2:1,s+U/r,e)}J+=st,Q+=st+4}}s+=V/r}}))})})}),e}function yg(s){if(!s)return!1;const t=s.indexOf("."),e=t<0?s:s.substring(0,t);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function bg(s,t){if(s){const e=t>>1&63;return e===39||e===40}else return(t&31)===6}function uh(s,t,e,i){const r=fh(s);let n=0;n+=t;let a=0,o=0,l=!1,h=0;for(;n<r.length;){a=0;do{if(n>=r.length)break;h=r[n++],a+=h}while(h===255);o=0;do{if(n>=r.length)break;h=r[n++],o+=h}while(h===255);const d=r.length-n;if(!l&&a===4&&n<r.length){if(l=!0,r[n++]===181){const c=oh(r,n);if(n+=2,c===49){const u=q(r,n);if(n+=4,u===1195456820){const f=r[n++];if(f===3){const p=r[n++],g=31&p,m=64&p,b=m?2+g*3:0,A=new Uint8Array(b);if(m){A[0]=p;for(let T=1;T<b;T++)A[T]=r[n++]}i.push({type:f,payloadType:a,pts:e,bytes:A})}}}}}else if(a===5&&o<d){if(l=!0,o>16){const c=[];for(let p=0;p<16;p++){const g=r[n++].toString(16);c.push(g.length==1?"0"+g:g),(p===3||p===5||p===7||p===9)&&c.push("-")}const u=o-16,f=new Uint8Array(u);for(let p=0;p<u;p++)f[p]=r[n++];i.push({payloadType:a,pts:e,uuid:c.join(""),userData:ge(f),userDataBytes:f})}}else if(o<d)n+=o;else if(o>d)break}}function fh(s){const t=s.byteLength,e=[];let i=1;for(;i<t-2;)s[i]===0&&s[i+1]===0&&s[i+2]===3?(e.push(i+2),i+=2):i++;if(e.length===0)return s;const r=t-e.length,n=new Uint8Array(r);let a=0;for(i=0;i<r;a++,i++)a===e[0]&&(a++,e.shift()),n[i]=s[a];return n}function Ag(s){const t=s[0];let e="",i="",r=0,n=0,a=0,o=0,l=0,h=0;if(t===0){for(;Ct(s.subarray(h,h+1))!=="\0";)e+=Ct(s.subarray(h,h+1)),h+=1;for(e+=Ct(s.subarray(h,h+1)),h+=1;Ct(s.subarray(h,h+1))!=="\0";)i+=Ct(s.subarray(h,h+1)),h+=1;i+=Ct(s.subarray(h,h+1)),h+=1,r=q(s,12),n=q(s,16),o=q(s,20),l=q(s,24),h=28}else if(t===1){h+=4,r=q(s,h),h+=4;const c=q(s,h);h+=4;const u=q(s,h);for(h+=4,a=4294967296*c+u,Number.isSafeInteger(a)||(a=Number.MAX_SAFE_INTEGER,R.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=q(s,h),h+=4,l=q(s,h),h+=4;Ct(s.subarray(h,h+1))!=="\0";)e+=Ct(s.subarray(h,h+1)),h+=1;for(e+=Ct(s.subarray(h,h+1)),h+=1;Ct(s.subarray(h,h+1))!=="\0";)i+=Ct(s.subarray(h,h+1)),h+=1;i+=Ct(s.subarray(h,h+1)),h+=1}const d=s.subarray(h,s.byteLength);return{schemeIdUri:e,value:i,timeScale:r,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:d}}function Tg(s,...t){const e=t.length;let i=8,r=e;for(;r--;)i+=t[r].byteLength;const 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<e;r++)n.set(t[r],i),i+=t[r].byteLength;return n}function Eg(s,t,e){if(s.byteLength!==16)throw new RangeError("Invalid system id");let i,r;if(t){i=1,r=new Uint8Array(t.length*16);for(let o=0;o<t.length;o++){const l=t[o];if(l.byteLength!==16)throw new RangeError("Invalid key");r.set(l,o*16)}}else i=0,r=new Uint8Array;let n;i>0?(n=new Uint8Array(4),t.length>0&&new DataView(n.buffer).setUint32(0,t.length,!1)):n=new Uint8Array;const a=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(a.buffer).setUint32(0,e.byteLength,!1),Tg([112,115,115,104],new Uint8Array([i,0,0,0]),s,n,r,a,e||new Uint8Array)}function wg(s){if(!(s instanceof ArrayBuffer)||s.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},e=new DataView(s),i=e.getUint32(0);if(s.byteLength!==i&&i>44||e.getUint32(4)!==1886614376||(t.version=e.getUint32(8)>>>24,t.version>1))return null;t.systemId=me.hexDump(new Uint8Array(s,12,16));const r=e.getUint32(28);if(t.version===0){if(i-32<r)return null;t.data=new Uint8Array(s,32,r)}else if(t.version===1){t.kids=[];for(let n=0;n<r;n++)t.kids.push(new Uint8Array(s,32+n*16,16))}return t}let ls={};class mr{static clearKeyUriToKeyIdMap(){ls={}}constructor(t,e,i,r=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=e,this.keyFormat=i,this.keyFormatVersions=r,this.iv=n,this.encrypted=t?t!=="NONE":!1,this.isCommonEncryption=this.encrypted&&t!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case zt.FAIRPLAY:case zt.WIDEVINE:case zt.PLAYREADY:case zt.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(t){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof t!="number"&&(this.method==="AES-128"&&!this.iv&&R.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const i=Sg(t);return new mr(this.method,this.uri,"identity",this.keyFormatVersions,i)}const e=Qp(this.uri);if(e)switch(this.keyFormat){case zt.WIDEVINE:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case zt.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Eg(i,null,e);const r=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),n=String.fromCharCode.apply(null,Array.from(r)),a=n.substring(n.indexOf("<"),n.length),o=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(o){const l=o.childNodes[0]?o.childNodes[0].nodeValue:o.getAttribute("VALUE");if(l){const h=Vn(l).subarray(0,16);Jp(h),this.keyId=h}}break}default:{let i=e.subarray(0,16);if(i.length!==16){const r=new Uint8Array(16);r.set(i,16-i.length),i=r}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=ls[this.uri];if(!i){const r=Object.keys(ls).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,r),ls[this.uri]=i}this.keyId=i}return this}}function Sg(s){const t=new Uint8Array(16);for(let e=12;e<16;e++)t[e]=s>>8*(15-e)&255;return t}const ph=/\{\$([a-zA-Z0-9-_]+)\}/g;function gh(s){return ph.test(s)}function Kt(s,t,e){if(s.variableList!==null||s.hasVariableRefs)for(let i=e.length;i--;){const r=e[i],n=t[r];n&&(t[r]=Yn(s,n))}}function Yn(s,t){if(s.variableList!==null||s.hasVariableRefs){const e=s.variableList;return t.replace(ph,i=>{const r=i.substring(2,i.length-1),n=e==null?void 0:e[r];return n===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),i):n})}return t}function mh(s,t,e){let i=s.variableList;i||(s.variableList=i={});let r,n;if("QUERYPARAM"in t){r=t.QUERYPARAM;try{const a=new self.URL(e).searchParams;if(a.has(r))n=a.get(r);else throw new Error(`"${r}" does not match any query parameter in URI: "${e}"`)}catch(a){s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else r=t.NAME,n=t.VALUE;r in i?s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):i[r]=n||""}function Lg(s,t,e){const i=t.IMPORT;if(e&&i in e){let r=s.variableList;r||(s.variableList=r={}),r[i]=e[i]}else s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function hs(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const Rg={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},vh=hs();function xg(s,t){const e=Rg[t];return!!e&&e[s.slice(0,4)]===!0}function Xn(s,t){var e;return(e=vh==null?void 0:vh.isTypeSupported(`${t||"video"}/mp4;codecs="${s}"`))!=null?e:!1}const yh=/#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,bh=/#EXT-X-MEDIA:(.*)/g,kg=/^#EXT(?:INF|-X-TARGETDURATION):/m,Ah=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Dg=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class oe{static findGroup(t,e){for(let i=0;i<t.length;i++){const r=t[i];if(r.id===e)return r}}static convertAVC1ToAVCOTI(t){const e=t.split(".");if(e.length>2){let i=e.shift()+".";return i+=parseInt(e.shift()).toString(16),i+=("000"+parseInt(e.shift()).toString(16)).slice(-4),i}return t}static resolve(t,e){return Bn.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return kg.test(t)}static parseMasterPlaylist(t,e){const i=gh(t),r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];yh.lastIndex=0;let a;for(;(a=yh.exec(t))!=null;)if(a[1]){var o;const h=new dt(a[1]);Kt(r,h,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const d=Yn(r,a[2]),c={attrs:h,bitrate:h.decimalInteger("AVERAGE-BANDWIDTH")||h.decimalInteger("BANDWIDTH"),name:h.NAME,url:oe.resolve(d,e)},u=h.decimalResolution("RESOLUTION");u&&(c.width=u.width,c.height=u.height),Cg((h.CODECS||"").split(/[ ,]+/).filter(f=>f),c),c.videoCodec&&c.videoCodec.indexOf("avc1")!==-1&&(c.videoCodec=oe.convertAVC1ToAVCOTI(c.videoCodec)),(o=c.unknownCodecs)!=null&&o.length||n.push(c),r.levels.push(c)}else if(a[3]){const h=a[3],d=a[4];switch(h){case"SESSION-DATA":{const c=new dt(d);Kt(r,c,["DATA-ID","LANGUAGE","VALUE","URI"]);const u=c["DATA-ID"];u&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[u]=c);break}case"SESSION-KEY":{const c=Th(d,e,r);c.encrypted&&c.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(c)):R.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${d}"`);break}case"DEFINE":{{const c=new dt(d);Kt(r,c,["NAME","VALUE","QUERYPARAM"]),mh(r,c,e)}break}case"CONTENT-STEERING":{const c=new dt(d);Kt(r,c,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:oe.resolve(c["SERVER-URI"],e),pathwayId:c["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=Eh(d);break}}}const 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(t,e,i){let r;const n={},a=i.levels,o={AUDIO:a.map(h=>({id:h.attrs.AUDIO,audioCodec:h.audioCodec})),SUBTITLES:a.map(h=>({id:h.attrs.SUBTITLES,textCodec:h.textCodec})),"CLOSED-CAPTIONS":[]};let l=0;for(bh.lastIndex=0;(r=bh.exec(t))!==null;){const h=new dt(r[1]),d=h.TYPE;if(d){const c=o[d],u=n[d]||[];n[d]=u,Kt(i,h,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const f={attrs:h,bitrate:0,id:l++,groupId:h["GROUP-ID"]||"",instreamId:h["INSTREAM-ID"],name:h.NAME||h.LANGUAGE||"",type:d,default:h.bool("DEFAULT"),autoselect:h.bool("AUTOSELECT"),forced:h.bool("FORCED"),lang:h.LANGUAGE,url:h.URI?oe.resolve(h.URI,e):""};if(c!=null&&c.length){const p=oe.findGroup(c,f.groupId)||c[0];wh(f,p,"audioCodec"),wh(f,p,"textCodec")}u.push(f)}}return n}static parseLevelPlaylist(t,e,i,r,n,a){const o=new qp(e),l=o.fragments;let h=null,d=0,c=0,u=0,f=0,p=null,g=new Gn(r,e),m,b,A,T=-1,y=!1;for(Ah.lastIndex=0,o.m3u8=t,o.hasVariableRefs=gh(t);(m=Ah.exec(t))!==null;){y&&(y=!1,g=new Gn(r,e),g.start=u,g.sn=d,g.cc=f,g.level=i,h&&(g.initSegment=h,g.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null));const C=m[1];if(C){g.duration=parseFloat(C);const k=(" "+m[2]).slice(1);g.title=k||null,g.tagList.push(k?["INF",C,k]:["INF",C])}else if(m[3]){if(K(g.duration)){g.start=u,A&&Rh(g,A,o),g.sn=d,g.level=i,g.cc=f,g.urlId=n,l.push(g);const k=(" "+m[3]).slice(1);g.relurl=Yn(o,k),Sh(g,p),p=g,u+=g.duration,d++,c=0,y=!0}}else if(m[4]){const k=(" "+m[4]).slice(1);p?g.setByteRange(k,p):g.setByteRange(k)}else if(m[5])g.rawProgramDateTime=(" "+m[5]).slice(1),g.tagList.push(["PROGRAM-DATE-TIME",g.rawProgramDateTime]),T===-1&&(T=l.length);else{if(m=m[0].match(Dg),!m){R.warn("No matches on slow regex match for level playlist!");continue}for(b=1;b<m.length&&!(typeof m[b]<"u");b++);const k=(" "+m[b]).slice(1),x=(" "+m[b+1]).slice(1),N=m[b+2]?(" "+m[b+2]).slice(1):"";switch(k){case"PLAYLIST-TYPE":o.type=x.toUpperCase();break;case"MEDIA-SEQUENCE":d=o.startSN=parseInt(x);break;case"SKIP":{const O=new dt(x);Kt(o,O,["RECENTLY-REMOVED-DATERANGES"]);const V=O.decimalInteger("SKIPPED-SEGMENTS");if(K(V)){o.skippedSegments=V;for(let E=V;E--;)l.unshift(null);d+=V}const W=O.enumeratedString("RECENTLY-REMOVED-DATERANGES");W&&(o.recentlyRemovedDateranges=W.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(x),1);break;case"VERSION":o.version=parseInt(x);break;case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(x||N)&&g.tagList.push(N?[x,N]:[x]);break;case"DISCONTINUITY":f++,g.tagList.push(["DIS"]);break;case"GAP":g.gap=!0,g.tagList.push([k]);break;case"BITRATE":g.tagList.push([k,x]);break;case"DATERANGE":{const O=new dt(x);Kt(o,O,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Kt(o,O,O.clientAttrs);const V=new Jl(O,o.dateRanges[O.ID]);V.isValid||o.skippedSegments?o.dateRanges[V.id]=V:R.warn(`Ignoring invalid DATERANGE tag: "${x}"`),g.tagList.push(["EXT-X-DATERANGE",x]);break}case"DEFINE":{{const O=new dt(x);Kt(o,O,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in O?Lg(o,O,a):mh(o,O,e)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(x);break;case"KEY":{const O=Th(x,e,o);if(O.isSupported()){if(O.method==="NONE"){A=void 0;break}A||(A={}),A[O.keyFormat]&&(A=Et({},A)),A[O.keyFormat]=O}else R.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${x}"`);break}case"START":o.startTimeOffset=Eh(x);break;case"MAP":{const O=new dt(x);if(Kt(o,O,["BYTERANGE","URI"]),g.duration){const V=new Gn(r,e);Lh(V,O,i,A),h=V,g.initSegment=h,h.rawProgramDateTime&&!g.rawProgramDateTime&&(g.rawProgramDateTime=h.rawProgramDateTime)}else Lh(g,O,i,A),h=g,y=!0;break}case"SERVER-CONTROL":{const O=new dt(x);o.canBlockReload=O.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=O.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&O.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=O.optionalFloat("PART-HOLD-BACK",0),o.holdBack=O.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const O=new dt(x);o.partTarget=O.decimalFloatingPoint("PART-TARGET");break}case"PART":{let O=o.partList;O||(O=o.partList=[]);const V=c>0?O[O.length-1]:void 0,W=c++,E=new dt(x);Kt(o,E,["BYTERANGE","URI"]);const I=new Yp(E,g,e,W,V);O.push(I),g.duration+=I.duration;break}case"PRELOAD-HINT":{const O=new dt(x);Kt(o,O,["URI"]),o.preloadHint=O;break}case"RENDITION-REPORT":{const O=new dt(x);Kt(o,O,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(O);break}default:R.warn(`line parsed but not handled: ${m}`);break}}}p&&!p.relurl?(l.pop(),u-=p.duration,o.partList&&(o.fragmentHint=p)):o.partList&&(Sh(g,p),g.cc=f,o.fragmentHint=g,A&&Rh(g,A,o));const w=l.length,S=l[0],L=l[w-1];if(u+=o.skippedSegments*o.targetduration,u>0&&w&&L){o.averagetargetduration=u/w;const C=L.sn;o.endSN=C!=="initSegment"?C:0,o.live||(L.endList=!0),S&&(o.startCC=S.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(u+=o.fragmentHint.duration),o.totalduration=u,o.endCC=f,T>0&&Ig(l,T),o}}function Th(s,t,e){var i,r;const n=new dt(s);Kt(e,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const a=(i=n.METHOD)!=null?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),h=n.KEYFORMATVERSIONS,d=(r=n.KEYFORMAT)!=null?r:"identity";o&&n.IV&&!l&&R.error(`Invalid IV: ${n.IV}`);const c=o?oe.resolve(o,t):"",u=(h||"1").split("/").map(Number).filter(Number.isFinite);return new mr(a,c,d,u,l)}function Eh(s){const t=new dt(s).decimalFloatingPoint("TIME-OFFSET");return K(t)?t:null}function Cg(s,t){["video","audio","text"].forEach(e=>{const i=s.filter(r=>xg(r,e));if(i.length){const r=i.filter(n=>n.lastIndexOf("avc1",0)===0||n.lastIndexOf("mp4a",0)===0);t[`${e}Codec`]=r.length>0?r[0]:i[0],s=s.filter(n=>i.indexOf(n)===-1)}}),t.unknownCodecs=s}function wh(s,t,e){const i=t[e];i&&(s[e]=i)}function Ig(s,t){let e=s[t];for(let i=t;i--;){const r=s[i];if(!r)return;r.programDateTime=e.programDateTime-r.duration*1e3,e=r}}function Sh(s,t){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):t!=null&&t.programDateTime&&(s.programDateTime=t.endProgramDateTime),K(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function Lh(s,t,e,i){s.relurl=t.URI,t.BYTERANGE&&s.setByteRange(t.BYTERANGE),s.level=e,s.sn="initSegment",i&&(s.levelkeys=i),s.initSegment=null}function Rh(s,t,e){s.levelkeys=t;const{encryptedFragments:i}=e;(!i.length||i[i.length-1].levelkeys!==t)&&Object.keys(t).some(r=>t[r].isCommonEncryption)&&i.push(s)}var rt={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},X={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function xh(s){const{type:t}=s;switch(t){case rt.AUDIO_TRACK:return X.AUDIO;case rt.SUBTITLE_TRACK:return X.SUBTITLE;default:return X.MAIN}}function qn(s,t){let e=s.url;return(e===void 0||e.indexOf("data:")===0)&&(e=t.url),e}class Pg{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:t}=this;t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.LEVEL_LOADING,this.onLevelLoading,this),t.on(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.LEVEL_LOADING,this.onLevelLoading,this),t.off(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,i=e.pLoader,r=e.loader,n=i||r,a=new n(e);return this.loaders[t.type]=a,a}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){const{url:i}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:rt.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(t,e){const{id:i,level:r,url:n,deliveryDirectives:a}=e;this.load({id:i,level:r,responseType:"text",type:rt.LEVEL,url:n,deliveryDirectives:a})}onAudioTrackLoading(t,e){const{id:i,groupId:r,url:n,deliveryDirectives:a}=e;this.load({id:i,groupId:r,level:null,responseType:"text",type:rt.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(t,e){const{id:i,groupId:r,url:n,deliveryDirectives:a}=e;this.load({id:i,groupId:r,level:null,responseType:"text",type:rt.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(t){var e;const i=this.hls.config;let r=this.getInternalLoader(t);if(r){const h=r.context;if(h&&h.url===t.url){R.trace("[playlist-loader]: playlist request ongoing");return}R.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),r.abort()}let n;if(t.type===rt.MANIFEST?n=i.manifestLoadPolicy.default:n=Et({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(t),(e=t.deliveryDirectives)!=null&&e.part){let h;if(t.type===rt.LEVEL&&t.level!==null?h=this.hls.levels[t.level].details:t.type===rt.AUDIO_TRACK&&t.id!==null?h=this.hls.audioTracks[t.id].details:t.type===rt.SUBTITLE_TRACK&&t.id!==null&&(h=this.hls.subtitleTracks[t.id].details),h){const d=h.partTarget,c=h.targetduration;if(d&&c){const u=Math.max(d*3,c*.8)*1e3;n=Et({},n,{maxTimeToFirstByteMs:Math.min(u,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(u,n.maxTimeToFirstByteMs)})}}}const 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:(h,d,c,u)=>{const f=this.getInternalLoader(c);this.resetInternalLoader(c.type);const p=h.data;if(p.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(h,c,new Error("no EXTM3U delimiter"),u||null,d);return}d.parsing.start=performance.now(),oe.isMediaPlaylist(p)?this.handleTrackOrLevelPlaylist(h,d,c,u||null,f):this.handleMasterPlaylist(h,d,c,u)},onError:(h,d,c,u)=>{this.handleNetworkError(d,c,!1,h,u)},onTimeout:(h,d,c)=>{this.handleNetworkError(d,c,!0,void 0,h)}};r.load(t,o,l)}handleMasterPlaylist(t,e,i,r){const n=this.hls,a=t.data,o=qn(t,i),l=oe.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(t,i,l.playlistParsingError,r,e);return}const{contentSteering:h,levels:d,sessionData:c,sessionKeys:u,startTimeOffset:f,variableList:p}=l;this.variableList=p;const{AUDIO:g=[],SUBTITLES:m,"CLOSED-CAPTIONS":b}=oe.parseMasterPlaylistMedia(a,o,l);g.length&&!g.some(A=>!A.url)&&d[0].audioCodec&&!d[0].attrs.AUDIO&&(R.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:!1,autoselect:!1,forced:!1,id:-1,attrs:new dt({}),bitrate:0,url:""})),n.trigger(v.MANIFEST_LOADED,{levels:d,audioTracks:g,subtitles:m,captions:b,contentSteering:h,url:o,stats:e,networkDetails:r,sessionData:c,sessionKeys:u,startTimeOffset:f,variableList:p})}handleTrackOrLevelPlaylist(t,e,i,r,n){const a=this.hls,{id:o,level:l,type:h}=i,d=qn(t,i),c=K(o)?o:0,u=K(l)?l:c,f=xh(i),p=oe.parseLevelPlaylist(t.data,d,u,f,c,this.variableList);if(h===rt.MANIFEST){const g={attrs:new dt({}),bitrate:0,details:p,name:"",url:d};a.trigger(v.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:d,stats:e,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),i.levelDetails=p,this.handlePlaylistLoaded(p,t,e,i,r,n)}handleManifestParsingError(t,e,i,r,n){this.hls.trigger(v.ERROR,{type:Y.NETWORK_ERROR,details:P.MANIFEST_PARSING_ERROR,fatal:e.type===rt.MANIFEST,url:t.url,err:i,error:i,reason:i.message,response:t,context:e,networkDetails:r,stats:n})}handleNetworkError(t,e,i=!1,r,n){let a=`A network ${i?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${t.type}`;t.type===rt.LEVEL?a+=`: ${t.level} id: ${t.id}`:(t.type===rt.AUDIO_TRACK||t.type===rt.SUBTITLE_TRACK)&&(a+=` id: ${t.id} group-id: "${t.groupId}"`);const o=new Error(a);R.warn(`[playlist-loader]: ${a}`);let l=P.UNKNOWN,h=!1;const d=this.getInternalLoader(t);switch(t.type){case rt.MANIFEST:l=i?P.MANIFEST_LOAD_TIMEOUT:P.MANIFEST_LOAD_ERROR,h=!0;break;case rt.LEVEL:l=i?P.LEVEL_LOAD_TIMEOUT:P.LEVEL_LOAD_ERROR,h=!1;break;case rt.AUDIO_TRACK:l=i?P.AUDIO_TRACK_LOAD_TIMEOUT:P.AUDIO_TRACK_LOAD_ERROR,h=!1;break;case rt.SUBTITLE_TRACK:l=i?P.SUBTITLE_TRACK_LOAD_TIMEOUT:P.SUBTITLE_LOAD_ERROR,h=!1;break}d&&this.resetInternalLoader(t.type);const c={type:Y.NETWORK_ERROR,details:l,fatal:h,url:t.url,loader:d,context:t,error:o,networkDetails:e,stats:n};if(r){const u=(e==null?void 0:e.url)||t.url;c.response=jt({url:u,data:void 0},r)}this.hls.trigger(v.ERROR,c)}handlePlaylistLoaded(t,e,i,r,n,a){const o=this.hls,{type:l,level:h,id:d,groupId:c,deliveryDirectives:u}=r,f=qn(e,r),p=xh(r),g=typeof r.level=="number"&&p===X.MAIN?h:void 0;if(!t.fragments.length){const b=new Error("No Segments found in Playlist");o.trigger(v.ERROR,{type:Y.NETWORK_ERROR,details:P.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:b,reason:b.message,response:e,context:r,level:g,parent:p,networkDetails:n,stats:i});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const m=t.playlistParsingError;if(m){o.trigger(v.ERROR,{type:Y.NETWORK_ERROR,details:P.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:m,reason:m.message,response:e,context:r,level:g,parent:p,networkDetails:n,stats:i});return}switch(t.live&&a&&(a.getCacheAge&&(t.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),l){case rt.MANIFEST:case rt.LEVEL:o.trigger(v.LEVEL_LOADED,{details:t,level:g||0,id:d||0,stats:i,networkDetails:n,deliveryDirectives:u});break;case rt.AUDIO_TRACK:o.trigger(v.AUDIO_TRACK_LOADED,{details:t,id:d||0,groupId:c||"",stats:i,networkDetails:n,deliveryDirectives:u});break;case rt.SUBTITLE_TRACK:o.trigger(v.SUBTITLE_TRACK_LOADED,{details:t,id:d||0,groupId:c||"",stats:i,networkDetails:n,deliveryDirectives:u});break}}}function kh(s,t){let e;try{e=new Event("addtrack")}catch{e=document.createEvent("Event"),e.initEvent("addtrack",!1,!1)}e.track=s,t.dispatchEvent(e)}function Dh(s,t){const e=s.mode;if(e==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(t.id))try{if(s.addCue(t),!s.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){R.debug(`[texttrack-utils]: ${i}`);try{const r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,s.addCue(r)}catch(r){R.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${r}`)}}e==="disabled"&&(s.mode=e)}function Li(s){const t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues)for(let e=s.cues.length;e--;)s.removeCue(s.cues[e]);t==="disabled"&&(s.mode=t)}function Zn(s,t,e,i){const r=s.mode;if(r==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){const n=Mg(s.cues,t,e);for(let a=0;a<n.length;a++)(!i||i(n[a]))&&s.removeCue(n[a])}r==="disabled"&&(s.mode=r)}function Og(s,t){if(t<s[0].startTime)return 0;const e=s.length-1;if(t>s[e].endTime)return-1;let i=0,r=e;for(;i<=r;){const n=Math.floor((r+i)/2);if(t<s[n].startTime)r=n-1;else if(t>s[n].startTime&&i<e)i=n+1;else return n}return s[i].startTime-t<t-s[r].startTime?i:r}function Mg(s,t,e){const i=[],r=Og(s,t);if(r>-1)for(let n=r,a=s.length;n<a;n++){const o=s[n];if(o.startTime>=t&&o.endTime<=e)i.push(o);else if(o.startTime>e)return i}return i}var le={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const Fg=.25;function Jn(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const ds=(()=>{const s=Jn();try{new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Qn(s,t){return s.getTime()/1e3-t}function Ng(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class Ug{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:t}=this;t.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(v.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(Li(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const e=this.getID3Track(t.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;e<t.length;e++){const i=t[e];if(i.kind==="metadata"&&i.label==="id3")return kh(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:r}}}=this;if(!i&&!r)return;const{samples:n}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=Jn();for(let o=0;o<n.length;o++){const l=n[o].type;if(l===le.emsg&&!i||!r)continue;const h=nh(n[o].data);if(h){const d=n[o].pts;let c=d+n[o].duration;c>ds&&(c=ds),c-d<=0&&(c=d+Fg);for(let u=0;u<h.length;u++){const f=h[u];if(!sh(f)){this.updateId3CueEnds(d,l);const p=new a(d,c,"");p.value=f,l&&(p.type=l),this.id3Track.addCue(p)}}}}}updateId3CueEnds(t,e){var i;const r=(i=this.id3Track)==null?void 0:i.cues;if(r)for(let n=r.length;n--;){const a=r[n];a.type===e&&a.startTime<t&&a.endTime===ds&&(a.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:i,type:r}){const{id3Track:n,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let h;r==="audio"?h=d=>d.type===le.audioId3&&l:r==="video"?h=d=>d.type===le.emsg&&o:h=d=>d.type===le.audioId3&&l||d.type===le.emsg&&o,Zn(n,e,i,h)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:r}=this,{dateRanges:n}=e,a=Object.keys(n);if(r){const d=Object.keys(i).filter(c=>!a.includes(c));for(let c=d.length;c--;){const u=d[c];Object.keys(i[u].cues).forEach(f=>{r.removeCue(i[u].cues[f])}),delete i[u]}}const o=e.fragments[e.fragments.length-1];if(a.length===0||!K(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=o.programDateTime/1e3-o.start,h=Jn();for(let d=0;d<a.length;d++){const c=a[d],u=n[c],f=i[c],p=(f==null?void 0:f.cues)||{};let g=(f==null?void 0:f.durationKnown)||!1;const m=Qn(u.startDate,l);let b=ds;const A=u.endDate;if(A)b=Qn(A,l),g=!0;else if(u.endOnNext&&!g){const y=a.reduce((w,S)=>{const L=n[S];return L.class===u.class&&L.id!==S&&L.startDate>u.startDate&&w.push(L),w},[]).sort((w,S)=>w.startDate.getTime()-S.startDate.getTime())[0];y&&(b=Qn(y.startDate,l),g=!0)}const T=Object.keys(u.attr);for(let y=0;y<T.length;y++){const w=T[y];if(!Kp(w))continue;let S=p[w];if(S)g&&!f.durationKnown&&(S.endTime=b);else{let L=u.attr[w];S=new h(m,b,""),Wp(w)&&(L=Ng(L)),S.value={key:w,data:L},S.type=le.dateRange,S.id=c,this.id3Track.addCue(S),p[w]=S}}i[c]={cues:p,dateRange:u,durationKnown:g}}}}class Bg{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:t,levelDetails:e}=this;return t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){const{levelDetails:t}=this;if(t===null)return null;const{holdBack:e,partHoldBack:i,targetduration:r}=t,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig;let h=o&&i||e;(l.liveSyncDuration||l.liveSyncDurationCount||h===0)&&(h=n!==void 0?n:a*r);const d=r,c=1;return h+Math.min(this.stallCount*c,d)}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency,i=this.levelDetails;if(t===null||e===null||i===null)return null;const r=i.edge,n=t-e-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(){const{levelDetails:t}=this;return t===null?1:t.drift}get edgeStalled(){const{levelDetails:t}=this;if(t===null)return 0;const e=(this.config.lowLatencyMode&&t.partTarget||t.targetduration)*3;return Math.max(t.age-e,0)}get forwardBufferLength(){const{media:t,levelDetails:e}=this;if(!t||!e)return 0;const i=t.buffered.length;return(i?t.buffered.end(i-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(v.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(v.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(t,{details:e}){this.levelDetails=e,e.advanced&&this.timeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){var i;e.details===P.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&R.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:t,levelDetails:e}=this;if(!t||!e)return;this.currentTime=t.currentTime;const i=this.computeLatency();if(i===null)return;this._latency=i;const{lowLatencyMode:r,maxLiveSyncPlaybackRate:n}=this.config;if(!r||n===1)return;const a=this.targetLatency;if(a===null)return;const o=i-a,l=Math.min(this.maxLatency,a+e.targetduration),h=o<l;if(e.live&&h&&o>.05&&this.forwardBufferLength>1){const d=Math.min(2,Math.max(1,n)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;t.playbackRate=Math.min(d,Math.max(1,c))}else t.playbackRate!==1&&t.playbackRate!==0&&(t.playbackRate=1)}estimateLiveEdge(){const{levelDetails:t}=this;return t===null?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return t===null?null:t-this.currentTime}}const _n=["NONE","TYPE-0","TYPE-1",null];var vr={No:"",Yes:"YES",v2:"v2"};function Hg(s,t){const{canSkipUntil:e,canSkipDateRanges:i,endSN:r}=s,n=t!==void 0?t-r:0;return e&&n<e?i?vr.v2:vr.Yes:vr.No}class Ch{constructor(t,e,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=i}addDirectives(t){const e=new self.URL(t);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class yr{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(e=>e).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(t){const e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}get audioGroupId(){var t;return(t=this.audioGroupIds)==null?void 0:t[this.urlId]}get textGroupId(){var t;return(t=this.textGroupIds)==null?void 0:t[this.urlId]}addFallback(t){this.url.push(t.url),this._attrs.push(t.attrs)}}function $n(s,t){const e=t.startPTS;if(K(e)){let i=0,r;t.sn>s.sn?(i=e-s.start,r=s):(i=s.start-e,r=t),r.duration!==i&&(r.duration=i)}else t.sn>s.sn?s.cc===t.cc&&s.minEndPTS?t.start=s.start+(s.minEndPTS-s.start):t.start=s.start+s.duration:t.start=Math.max(s.start-t.duration,0)}function Ih(s,t,e,i,r,n){i-e<=0&&(R.warn("Fragment should have a positive duration",t),i=e+t.duration,n=r+t.duration);let a=e,o=i;const l=t.startPTS,h=t.endPTS;if(K(l)){const g=Math.abs(l-e);K(t.deltaPTS)?t.deltaPTS=Math.max(g,t.deltaPTS):t.deltaPTS=g,a=Math.max(e,l),e=Math.min(e,l),r=Math.min(r,t.startDTS),o=Math.min(i,h),i=Math.max(i,h),n=Math.max(n,t.endDTS)}const d=e-t.start;t.start!==0&&(t.start=e),t.duration=i-t.start,t.startPTS=e,t.maxStartPTS=a,t.startDTS=r,t.endPTS=i,t.minEndPTS=o,t.endDTS=n;const c=t.sn;if(!s||c<s.startSN||c>s.endSN)return 0;let u;const f=c-s.startSN,p=s.fragments;for(p[f]=t,u=f;u>0;u--)$n(p[u],p[u-1]);for(u=f;u<p.length-1;u++)$n(p[u],p[u+1]);return s.fragmentHint&&$n(p[p.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,d}function Gg(s,t){let e=null;const i=s.fragments;for(let l=i.length-1;l>=0;l--){const h=i[l].initSegment;if(h){e=h;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let r=0,n;if(zg(s,t,(l,h)=>{l.relurl&&(r=l.cc-h.cc),K(l.startPTS)&&K(l.endPTS)&&(h.start=h.startPTS=l.startPTS,h.startDTS=l.startDTS,h.maxStartPTS=l.maxStartPTS,h.endPTS=l.endPTS,h.endDTS=l.endDTS,h.minEndPTS=l.minEndPTS,h.duration=l.endPTS-l.startPTS,h.duration&&(n=h),t.PTSKnown=t.alignedSliding=!0),h.elementaryStreams=l.elementaryStreams,h.loader=l.loader,h.stats=l.stats,h.urlId=l.urlId,l.initSegment&&(h.initSegment=l.initSegment,e=l.initSegment)}),e&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach(l=>{var h;(!l.initSegment||l.initSegment.relurl===((h=e)==null?void 0:h.relurl))&&(l.initSegment=e)}),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(l=>!l),t.deltaUpdateFailed){R.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=t.skippedSegments;l--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=Vg(s.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const a=t.fragments;if(r){R.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=r}t.skippedSegments&&(t.startCC=t.fragments[0].cc),jg(s.partList,t.partList,(l,h)=>{h.elementaryStreams=l.elementaryStreams,h.stats=l.stats}),n?Ih(t,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):Ph(s,t),a.length&&(t.totalduration=t.edge-a[0].start),t.driftStartTime=s.driftStartTime,t.driftStart=s.driftStart;const o=t.advancedDateTime;if(t.advanced&&o){const l=t.edge;t.driftStart||(t.driftStartTime=o,t.driftStart=l),t.driftEndTime=o,t.driftEnd=l}else t.driftEndTime=s.driftEndTime,t.driftEnd=s.driftEnd,t.advancedDateTime=s.advancedDateTime}function Vg(s,t,e){const i=Et({},s);return e&&e.forEach(r=>{delete i[r]}),Object.keys(t).forEach(r=>{const n=new Jl(t[r].attr,i[r]);n.isValid?i[r]=n:R.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[r].attr)}"`)}),i}function jg(s,t,e){if(s&&t){let i=0;for(let r=0,n=s.length;r<=n;r++){const a=s[r],o=t[r+i];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?e(a,o):i--}}}function zg(s,t,e){const i=t.skippedSegments,r=Math.max(s.startSN,t.startSN)-t.startSN,n=(s.fragmentHint?1:0)+(i?t.endSN:Math.min(s.endSN,t.endSN))-t.startSN,a=t.startSN-s.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments;for(let h=r;h<=n;h++){const d=l[a+h];let c=o[h];i&&!c&&h<i&&(c=t.fragments[h]=d),d&&c&&e(d,c)}}function Ph(s,t){const e=t.startSN+t.skippedSegments-s.startSN,i=s.fragments;e<0||e>=i.length||ta(t,i[e].start)}function ta(s,t){if(t){const e=s.fragments;for(let i=s.skippedSegments;i<e.length;i++)e[i].start+=t;s.fragmentHint&&(s.fragmentHint.start+=t)}}function Kg(s,t=1/0){let e=1e3*s.targetduration;if(s.updated){const i=s.fragments,r=4;if(i.length&&e*r>t){const n=i[i.length-1].duration*1e3;n<e&&(e=n)}}else e/=2;return Math.round(e)}function Wg(s,t,e){if(!(s!=null&&s.details))return null;const i=s.details;let r=i.fragments[t-i.startSN];return r||(r=i.fragmentHint,r&&r.sn===t)?r:t<i.startSN&&e&&e.sn===t?e:null}function Oh(s,t,e){var i;return s!=null&&s.details?Mh((i=s.details)==null?void 0:i.partList,t,e):null}function Mh(s,t,e){if(s)for(let i=s.length;i--;){const r=s[i];if(r.index===e&&r.fragment.sn===t)return r}return null}function cs(s){switch(s.details){case P.FRAG_LOAD_TIMEOUT:case P.KEY_LOAD_TIMEOUT:case P.LEVEL_LOAD_TIMEOUT:case P.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Fh(s,t){const e=cs(t);return s.default[`${e?"timeout":"error"}Retry`]}function ea(s,t){const e=s.backoff==="linear"?1:Math.pow(2,t);return Math.min(e*s.retryDelayMs,s.maxRetryDelayMs)}function Nh(s){return jt(jt({},s),{errorRetry:null,timeoutRetry:null})}function us(s,t,e,i){return!!s&&t<s.maxNumRetry&&(Yg(i)||!!e)}function Yg(s){return s===0&&navigator.onLine===!1||!!s&&(s<400||s>499)}const Uh={search:function(s,t){let e=0,i=s.length-1,r=null,n=null;for(;e<=i;){r=(e+i)/2|0,n=s[r];const a=t(n);if(a>0)e=r+1;else if(a<0)i=r-1;else return n}return null}};function Xg(s,t,e){if(t===null||!Array.isArray(s)||!s.length||!K(t))return null;const i=s[0].programDateTime;if(t<(i||0))return null;const r=s[s.length-1].endProgramDateTime;if(t>=(r||0))return null;e=e||0;for(let n=0;n<s.length;++n){const a=s[n];if(qg(t,e,a))return a}return null}function br(s,t,e=0,i=0){let r=null;if(s?r=t[s.sn-t[0].sn+1]||null:e===0&&t[0].start===0&&(r=t[0]),r&&ia(e,i,r)===0)return r;const n=Uh.search(t,ia.bind(null,e,i));return n&&(n!==s||!r)?n:r}function ia(s=0,t=0,e){if(e.start<=s&&e.start+e.duration>s)return 0;const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-i<=s?1:e.start-i>s&&e.start?-1:0}function qg(s,t,e){const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0))*1e3;return(e.endProgramDateTime||0)-i>s}function Zg(s,t){return Uh.search(s,e=>e.cc<t?1:e.cc>t?-1:0)}const Jg=3e5;var Ft={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},$t={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class Qg{constructor(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=R.log.bind(R,"[info]:"),this.warn=R.warn.bind(R,"[warning]:"),this.error=R.error.bind(R,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(v.ERROR,this.onError,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(v.ERROR,this.onError,this),t.off(v.ERROR,this.onErrorOut,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){this.playlistError=0}stopLoad(){}getVariantLevelIndex(t){return(t==null?void 0:t.type)===X.MAIN?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var i,r;if(e.fatal)return;const n=this.hls,a=e.context;switch(e.details){case P.FRAG_LOAD_ERROR:case P.FRAG_LOAD_TIMEOUT:case P.KEY_LOAD_ERROR:case P.KEY_LOAD_TIMEOUT:e.errorAction=this.getFragRetryOrSwitchAction(e);return;case P.FRAG_PARSING_ERROR:if((i=e.frag)!=null&&i.gap){e.errorAction={action:Ft.DoNothing,flags:$t.None};return}case P.FRAG_GAP:case P.FRAG_DECRYPT_ERROR:{e.errorAction=this.getFragRetryOrSwitchAction(e),e.errorAction.action=Ft.SendAlternateToPenaltyBox;return}case P.LEVEL_EMPTY_ERROR:case P.LEVEL_PARSING_ERROR:{var o,l;const h=e.parent===X.MAIN?e.level:n.loadLevel;e.details===P.LEVEL_EMPTY_ERROR&&(o=e.context)!=null&&(l=o.levelDetails)!=null&&l.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,h):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,h))}return;case P.LEVEL_LOAD_ERROR:case P.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,a.level));return;case P.AUDIO_TRACK_LOAD_ERROR:case P.AUDIO_TRACK_LOAD_TIMEOUT:case P.SUBTITLE_LOAD_ERROR:case P.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){const h=n.levels[n.loadLevel];if(h&&(a.type===rt.AUDIO_TRACK&&a.groupId===h.audioGroupId||a.type===rt.SUBTITLE_TRACK&&a.groupId===h.textGroupId)){e.errorAction=this.getPlaylistRetryOrSwitchAction(e,n.loadLevel),e.errorAction.action=Ft.SendAlternateToPenaltyBox,e.errorAction.flags=$t.MoveAllAlternatesMatchingHost;return}}return;case P.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const h=n.levels[n.loadLevel],d=h==null?void 0:h.attrs["HDCP-LEVEL"];d&&(e.errorAction={action:Ft.SendAlternateToPenaltyBox,flags:$t.MoveAllAlternatesMatchingHDCP,hdcpLevel:d})}return;case P.BUFFER_ADD_CODEC_ERROR:case P.REMUX_ALLOC_ERROR:e.errorAction=this.getLevelSwitchAction(e,(r=e.level)!=null?r:n.loadLevel);return;case P.INTERNAL_EXCEPTION:case P.BUFFER_APPENDING_ERROR:case P.BUFFER_APPEND_ERROR:case P.BUFFER_FULL_ERROR:case P.LEVEL_SWITCH_ERROR:case P.BUFFER_STALLED_ERROR:case P.BUFFER_SEEK_OVER_HOLE:case P.BUFFER_NUDGE_ON_STALL:e.errorAction={action:Ft.DoNothing,flags:$t.None};return}if(e.type===Y.KEY_SYSTEM_ERROR){const h=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,h);return}}getPlaylistRetryOrSwitchAction(t,e){var i;const r=this.hls,n=Fh(r.config.playlistLoadPolicy,t),a=this.playlistError++,o=(i=t.response)==null?void 0:i.code;if(us(n,a,cs(t),o))return{action:Ft.RetryRequest,flags:$t.None,retryConfig:n,retryCount:a};const l=this.getLevelSwitchAction(t,e);return n&&(l.retryConfig=n,l.retryCount=a),l}getFragRetryOrSwitchAction(t){const e=this.hls,i=this.getVariantLevelIndex(t.frag),r=e.levels[i],{fragLoadPolicy:n,keyLoadPolicy:a}=e.config,o=Fh(t.details.startsWith("key")?a:n,t),l=e.levels.reduce((c,u)=>c+u.fragmentError,0);if(r){var h;t.details!==P.FRAG_GAP&&r.fragmentError++;const c=(h=t.response)==null?void 0:h.code;if(us(o,l,cs(t),c))return{action:Ft.RetryRequest,flags:$t.None,retryConfig:o,retryCount:l}}const d=this.getLevelSwitchAction(t,i);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(t,e){const i=this.hls;e==null&&(e=i.loadLevel);const r=this.hls.levels[e];if(r&&(r.loadError++,i.autoLevelEnabled)){var n,a;let o=-1;const{levels:l,loadLevel:h,minAutoLevel:d,maxAutoLevel:c}=i,u=(n=t.frag)==null?void 0:n.type,{type:f,groupId:p}=(a=t.context)!=null?a:{};for(let g=l.length;g--;){const m=(g+h)%l.length;if(m!==h&&m>=d&&m<=c&&l[m].loadError===0){const b=l[m];if(t.details===P.FRAG_GAP&&t.frag){const A=l[m].details;if(A){const T=br(t.frag,A.fragments,t.frag.start);if(T!=null&&T.gap)continue}}else if(f===rt.AUDIO_TRACK&&p===b.audioGroupId||f===rt.SUBTITLE_TRACK&&p===b.textGroupId||u===X.AUDIO&&r.audioGroupId===b.audioGroupId||u===X.SUBTITLE&&r.textGroupId===b.textGroupId)continue;o=m;break}}if(o>-1&&i.loadLevel!==o)return t.levelRetry=!0,this.playlistError=0,{action:Ft.SendAlternateToPenaltyBox,flags:$t.None,nextAutoLevel:o}}return{action:Ft.SendAlternateToPenaltyBox,flags:$t.MoveAllAlternatesMatchingHost}}onErrorOut(t,e){var i;switch((i=e.errorAction)==null?void 0:i.action){case Ft.DoNothing:break;case Ft.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),!e.errorAction.resolved&&e.details!==P.FRAG_GAP&&(e.fatal=!0);break}if(e.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(t){const e=this.hls,i=t.errorAction;if(!i)return;const{flags:r,hdcpLevel:n,nextAutoLevel:a}=i;switch(r){case $t.None:this.switchLevel(t,a);break;case $t.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(t));break;case $t.MoveAllAlternatesMatchingHDCP:n&&(e.maxHdcpLevel=_n[_n.indexOf(n)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(t,a)}switchLevel(t,e){e!==void 0&&t.errorAction&&(this.warn(`switching to level ${e} after ${t.details}`),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(t){const{hls:e,penalizedRenditions:i}=this,r=t.parent===X.MAIN?t.level:e.loadLevel,n=e.levels[r],a=n.url.length,o=t.frag?t.frag.urlId:n.urlId;n.urlId===o&&(!t.frag||n.details)&&this.penalizeRendition(n,t);for(let l=1;l<a;l++){const h=(o+l)%a,d=i[h];if(!d||_g(d,t,i[o]))return this.warn(`Switching to Redundant Stream ${h+1}/${a}: "${n.url[h]}" after ${t.details}`),this.playlistError=0,e.levels.forEach(c=>{c.urlId=h}),e.nextLoadLevel=r,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:i}=this,r=i[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};r.lastErrorPerfMs=performance.now(),r.errors.push(e),r.details=t.details,i[t.urlId]=r}}function _g(s,t,e){if(performance.now()-s.lastErrorPerfMs>Jg)return!0;const i=s.details;if(t.details===P.FRAG_GAP&&i&&t.frag){const r=t.frag.start,n=br(null,i.fragments,r);if(n&&!n.gap)return!0}if(e&&s.errors.length<e.errors.length){const r=s.errors[s.errors.length-1];if(i&&r.frag&&t.frag&&Math.abs(r.frag.start-t.frag.start)>i.targetduration*3)return!0}return!1}class ra{constructor(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=R.log.bind(R,`${e}:`),this.warn=R.warn.bind(R,`${e}:`),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,e){const i=e==null?void 0:e.renditionReports;if(i){let r=-1;for(let n=0;n<i.length;n++){const a=i[n];let o;try{o=new self.URL(a.URI,e.url).href}catch(l){R.warn(`Could not construct new URL for Rendition Report: ${l}`),o=a.URI||""}if(o===t){r=n;break}else o===t.substring(0,o.length)&&(r=n)}if(r!==-1){const n=i[r],a=parseInt(n["LAST-MSN"])||(e==null?void 0:e.lastPartSn);let o=parseInt(n["LAST-PART"])||(e==null?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){const l=Math.min(e.age-e.partTarget,e.targetduration);o>=0&&l>e.partTarget&&(o+=1)}return new Ch(a,o>=0?o:void 0,vr.No)}}}loadPlaylist(t){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}shouldReloadPlaylist(t){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(t)}playlistLoaded(t,e,i){const{details:r,stats:n}=e,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(r.advancedDateTime=Date.now()-o,r.live||i!=null&&i.live){if(r.reloaded(i),i&&this.log(`live playlist ${t} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),i&&r.fragments.length>0&&Gg(i,r),!this.canLoad||!r.live)return;let l,h,d;if(r.canBlockReload&&r.endSN&&r.advanced){const m=this.hls.config.lowLatencyMode,b=r.lastPartSn,A=r.endSN,T=r.lastPartIndex,y=T!==-1,w=b===A,S=m?0:T;y?(h=w?A+1:b,d=w?S:T+1):h=A+1;const L=r.age,C=L+r.ageHeader;let k=Math.min(C-r.partTarget,r.targetduration*1.5);if(k>0){if(i&&k>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${k} with playlist age: ${r.age}`),k=0;else{const x=Math.floor(k/r.targetduration);if(h+=x,d!==void 0){const N=Math.round(k%r.targetduration/r.partTarget);d+=N}this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${L.toFixed(2)}s goal: ${k} skip sn ${x} to part ${d}`)}r.tuneInGoal=k}if(l=this.getDeliveryDirectives(r,e.deliveryDirectives,h,d),m||!w){this.loadPlaylist(l);return}}else(r.canBlockReload||r.canSkipUntil)&&(l=this.getDeliveryDirectives(r,e.deliveryDirectives,h,d));const c=this.hls.mainForwardBufferInfo,u=c?c.end-c.len:0,f=(r.edge-u)*1e3,p=Kg(r,f);r.updated&&a>this.requestScheduled+p&&(this.requestScheduled=n.loading.start),h!==void 0&&r.canBlockReload?this.requestScheduled=n.loading.first+p-(r.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+p<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=p);let g=this.requestScheduled-a;g=Math.max(0,g),this.log(`reload live playlist ${t} in ${Math.round(g)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),g)}else this.clearTimer()}getDeliveryDirectives(t,e,i,r){let n=Hg(t,i);return e!=null&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,r=e.part,n=vr.No),new Ch(i,r,n)}checkRetry(t){const e=t.details,i=cs(t),r=t.errorAction,{action:n,retryCount:a=0,retryConfig:o}=r||{},l=!!r&&!!o&&(n===Ft.RetryRequest||!r.resolved&&n===Ft.SendAlternateToPenaltyBox);if(l){var h;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(i&&(h=t.context)!=null&&h.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const d=ea(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),d),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${e}" in ${d}ms`)}t.levelRetry=!0,r.resolved=!0}return l}}let sa;class $g extends ra{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(v.LEVEL_LOADED,this.onLevelLoaded,this),t.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(v.FRAG_LOADED,this.onFragLoaded,this),t.on(v.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(v.LEVEL_LOADED,this.onLevelLoaded,this),t.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(v.FRAG_LOADED,this.onFragLoaded,this),t.off(v.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const i=[],r={};let n;e.levels.forEach(a=>{var o;const l=a.attrs;((o=a.audioCodec)==null?void 0:o.indexOf("mp4a.40.34"))!==-1&&(sa||(sa=/chrome|firefox/i.test(navigator.userAgent)),sa&&(a.audioCodec=void 0));const{AUDIO:h,CODECS:d,"FRAME-RATE":c,"PATHWAY-ID":u,RESOLUTION:f,SUBTITLES:p}=l,g=`${`${u||"."}-`}${a.bitrate}-${f}-${c}-${d}`;n=r[g],n?n.addFallback(a):(n=new yr(a),r[g]=n,i.push(n)),fs(n,"audio",h),fs(n,"text",p)}),this.filterAndSortMediaOptions(i,e)}filterAndSortMediaOptions(t,e){let i=[],r=[],n=!1,a=!1,o=!1,l=t.filter(({audioCodec:f,videoCodec:p,width:g,height:m,unknownCodecs:b})=>(n||(n=!!(g&&m)),a||(a=!!p),o||(o=!!f),!(b!=null&&b.length)&&(!f||Xn(f,"audio"))&&(!p||Xn(p,"video"))));if((n||a)&&o&&(l=l.filter(({videoCodec:f,width:p,height:g})=>!!f||!!(p&&g))),l.length===0){Promise.resolve().then(()=>{if(this.hls){const f=new Error("no level with compatible codecs found in manifest");this.hls.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:f,reason:f.message})}});return}e.audioTracks&&(i=e.audioTracks.filter(f=>!f.audioCodec||Xn(f.audioCodec,"audio")),Bh(i)),e.subtitles&&(r=e.subtitles,Bh(r));const h=l.slice(0);l.sort((f,p)=>f.attrs["HDCP-LEVEL"]!==p.attrs["HDCP-LEVEL"]?(f.attrs["HDCP-LEVEL"]||"")>(p.attrs["HDCP-LEVEL"]||"")?1:-1:f.bitrate!==p.bitrate?f.bitrate-p.bitrate:f.attrs["FRAME-RATE"]!==p.attrs["FRAME-RATE"]?f.attrs.decimalFloatingPoint("FRAME-RATE")-p.attrs.decimalFloatingPoint("FRAME-RATE"):f.attrs.SCORE!==p.attrs.SCORE?f.attrs.decimalFloatingPoint("SCORE")-p.attrs.decimalFloatingPoint("SCORE"):n&&f.height!==p.height?f.height-p.height:0);let d=h[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==h.length)){for(let f=0;f<h.length;f++)if(h[f].pathwayId===l[0].pathwayId){d=h[f];break}}this._levels=l;for(let f=0;f<l.length;f++)if(l[f]===d){this._firstLevel=f,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${d.bitrate}`);break}const c=o&&!a,u={levels:l,audioTracks:i,subtitleTracks:r,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:o,video:a,altAudio:!c&&i.some(f=>!!f.url)};this.hls.trigger(v.MANIFEST_PARSED,u),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(t){const e=this._levels;if(e.length===0)return;if(t<0||t>=e.length){const d=new Error("invalid level idx"),c=t<0;if(this.hls.trigger(v.ERROR,{type:Y.OTHER_ERROR,details:P.LEVEL_SWITCH_ERROR,level:t,fatal:c,error:d,reason:d.message}),c)return;t=Math.min(t,e.length-1)}const i=this.currentLevelIndex,r=this.currentLevel,n=r?r.attrs["PATHWAY-ID"]:void 0,a=e[t],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=a,i===t&&a.details&&r&&n===o)return;this.log(`Switching to level ${t}${o?" with Pathway "+o:""} from level ${i}${n?" with Pathway "+n:""}`);const l=Et({},a,{level:t,maxBitrate:a.maxBitrate,attrs:a.attrs,uri:a.uri,urlId:a.urlId});delete l._attrs,delete l._urlId,this.hls.trigger(v.LEVEL_SWITCHING,l);const h=a.details;if(!h||h.live){const d=this.switchParams(a.uri,r==null?void 0:r.details);this.loadPlaylist(d)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){if(this._startLevel===void 0){const t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}else return this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){e.fatal||!e.context||e.context.type===rt.LEVEL&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){if(e!==void 0&&e.type===X.MAIN){const i=this._levels[e.level];i!==void 0&&(i.loadError=0)}}onLevelLoaded(t,e){var i;const{level:r,details:n}=e,a=this._levels[r];if(!a){var o;this.warn(`Invalid level index ${r}`),(o=e.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}r===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(r,e,a.details)):(i=e.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const i=this.currentLevel;if(!i)return;const r=this.hls.audioTracks[e.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==r){let n=-1;for(let a=0;a<i.audioGroupIds.length;a++)if(i.audioGroupIds[a]===r){n=a;break}n!==-1&&n!==i.urlId&&(i.urlId=n,this.canLoad&&this.startLoad())}}loadPlaylist(t){super.loadPlaylist();const e=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){const r=i.urlId;let n=i.uri;if(t)try{n=t.addDirectives(n)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}const a=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${e}${(t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""} with${a?" Pathway "+a:""} URI ${r+1}/${i.url.length} ${n}`),this.clearTimer(),this.hls.trigger(v.LEVEL_LOADING,{url:n,level:e,id:r,deliveryDirectives:t||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}removeLevel(t,e){const i=(n,a)=>a!==e,r=this._levels.filter((n,a)=>a!==t?!0:n.url.length>1&&e!==void 0?(n.url=n.url.filter(i),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(i)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(i)),n.urlId=0,!0):(this.steering&&this.steering.removeLevel(n),!1));this.hls.trigger(v.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(t,{levels:e}){e.forEach((i,r)=>{const{details:n}=i;n!=null&&n.fragments&&n.fragments.forEach(a=>{a.level=r})}),this._levels=e}}function fs(s,t,e){e&&(t==="audio"?(s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds[s.url.length-1]=e):t==="text"&&(s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds[s.url.length-1]=e))}function Bh(s){const t={};s.forEach(e=>{const i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}var Rt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class tm{constructor(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(v.BUFFER_APPENDED,this.onBufferAppended,this),t.on(v.FRAG_BUFFERED,this.onFragBuffered,this),t.on(v.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(v.BUFFER_APPENDED,this.onBufferAppended,this),t.off(v.FRAG_BUFFERED,this.onFragBuffered,this),t.off(v.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const i=this.activePartLists[e];if(i)for(let r=i.length;r--;){const n=i[r];if(!n)break;const a=n.end;if(n.start<=t&&a!==null&&t<=a)return n}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:i}=this,r=Object.keys(i);for(let n=r.length;n--;){const a=i[r[n]];if((a==null?void 0:a.body.type)===e&&a.buffered){const o=a.body;if(o.start<=t&&t<=o.end)return o}}return null}detectEvictedFragments(t,e,i,r){this.timeRanges&&(this.timeRanges[t]=e);const n=(r==null?void 0:r.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===i&&this.removeFragment(o.body);return}const l=o.range[t];l&&l.time.some(h=>{const d=!this.isTimeBuffered(h.startPTS,h.endPTS,e);return d&&this.removeFragment(o.body),d})})}detectPartialFragments(t){const e=this.timeRanges,{frag:i,part:r}=t;if(!e||i.sn==="initSegment")return;const n=Ri(i),a=this.fragments[n];if(!a||a.buffered&&i.gap)return;const o=!i.relurl;Object.keys(e).forEach(l=>{const h=i.elementaryStreams[l];if(!h)return;const d=e[l],c=o||h.partial===!0;a.range[l]=this.getBufferedTimes(i,r,c,d)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=i.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),ps(a)||this.removeParts(i.sn-1,i.type)):this.removeFragment(a.body)}removeParts(t,e){const i=this.activePartLists[e];i&&(this.activePartLists[e]=i.filter(r=>r.fragment.sn>=t))}fragBuffered(t,e){const i=Ri(t);let r=this.fragments[i];!r&&e&&(r=this.fragments[i]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,r.buffered=!0)}getBufferedTimes(t,e,i,r){const n={time:[],partial:i},a=t.start,o=t.end,l=t.minEndPTS||o,h=t.maxStartPTS||a;for(let d=0;d<r.length;d++){const c=r.start(d)-this.bufferPadding,u=r.end(d)+this.bufferPadding;if(h>=c&&l<=u){n.time.push({startPTS:Math.max(a,r.start(d)),endPTS:Math.min(o,r.end(d))});break}else if(a<u&&o>c)n.partial=!0,n.time.push({startPTS:Math.max(a,r.start(d)),endPTS:Math.min(o,r.end(d))});else if(o<=c)break}return n}getPartialFragment(t){let e=null,i,r,n,a=0;const{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(h=>{const d=l[h];d&&ps(d)&&(r=d.body.start-o,n=d.body.end+o,t>=r&&t<=n&&(i=Math.min(t-r,n-t),a<=i&&(e=d.body,a=i)))}),e}isEndListAppended(t){const e=this.endListFragments[t];return e!==void 0&&(e.buffered||ps(e))}getState(t){const e=Ri(t),i=this.fragments[e];return i?i.buffered?ps(i)?Rt.PARTIAL:Rt.OK:Rt.APPENDING:Rt.NOT_LOADED}isTimeBuffered(t,e,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,t>=r&&e<=n)return!0;if(e<=r)return!1}return!1}onFragLoaded(t,e){const{frag:i,part:r}=e;if(i.sn==="initSegment"||i.bitrateTest)return;const n=r?null:e,a=Ri(i);this.fragments[a]={body:i,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:i,part:r,timeRanges:n}=e;if(i.sn==="initSegment")return;const a=i.type;if(r){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(r)}this.timeRanges=n,Object.keys(n).forEach(o=>{const l=n[o];this.detectEvictedFragments(o,l,a,r)})}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=Ri(t);return!!this.fragments[e]}hasParts(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)}removeFragmentsInRange(t,e,i,r,n){r&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o)return;const l=o.body;l.type!==i||r&&!l.gap||l.start<e&&l.end>t&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(t){const e=Ri(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const i=this.activePartLists[t.type];if(i){const r=t.sn;this.activePartLists[t.type]=i.filter(n=>n.fragment.sn!==r)}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function ps(s){var t,e,i;return s.buffered&&(s.body.gap||((t=s.range.video)==null?void 0:t.partial)||((e=s.range.audio)==null?void 0:e.partial)||((i=s.range.audiovideo)==null?void 0:i.partial))}function Ri(s){return`${s.type}_${s.level}_${s.urlId}_${s.sn}`}const Hh=Math.pow(2,17);class em{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const i=t.url;if(!i)return Promise.reject(new Re({type:Y.NETWORK_ERROR,details:P.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const r=this.config,n=r.fLoader,a=r.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),t.gap)if(t.tagList.some(f=>f[0]==="GAP")){l(Vh(t));return}else t.gap=!1;const h=this.loader=t.loader=n?new n(r):new a(r),d=Gh(t),c=Nh(r.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:Hh};t.stats=h.stats,h.load(d,u,{onSuccess:(f,p,g,m)=>{this.resetLoader(t,h);let b=f.data;g.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(b.slice(0,16)),b=b.slice(16)),o({frag:t,part:null,payload:b,networkDetails:m})},onError:(f,p,g,m)=>{this.resetLoader(t,h),l(new Re({type:Y.NETWORK_ERROR,details:P.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:jt({url:i,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:g,stats:m}))},onAbort:(f,p,g)=>{this.resetLoader(t,h),l(new Re({type:Y.NETWORK_ERROR,details:P.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:g,stats:f}))},onTimeout:(f,p,g)=>{this.resetLoader(t,h),l(new Re({type:Y.NETWORK_ERROR,details:P.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:g,stats:f}))},onProgress:(f,p,g,m)=>{e&&e({frag:t,part:null,payload:g,networkDetails:m})}})})}loadPart(t,e,i){this.abort();const r=this.config,n=r.fLoader,a=r.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap){l(Vh(t,e));return}const h=this.loader=t.loader=n?new n(r):new a(r),d=Gh(t,e),c=Nh(r.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Hh};e.stats=h.stats,h.load(d,u,{onSuccess:(f,p,g,m)=>{this.resetLoader(t,h),this.updateStatsFromPart(t,e);const b={frag:t,part:e,payload:f.data,networkDetails:m};i(b),o(b)},onError:(f,p,g,m)=>{this.resetLoader(t,h),l(new Re({type:Y.NETWORK_ERROR,details:P.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:jt({url:d.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:g,stats:m}))},onAbort:(f,p,g)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,h),l(new Re({type:Y.NETWORK_ERROR,details:P.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:g,stats:f}))},onTimeout:(f,p,g)=>{this.resetLoader(t,h),l(new Re({type:Y.NETWORK_ERROR,details:P.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:g,stats:f}))}})})}updateStatsFromPart(t,e){const i=t.stats,r=e.stats,n=r.total;if(i.loaded+=r.loaded,n){const l=Math.round(t.duration/e.duration),h=Math.min(Math.round(i.loaded/n),l),d=(l-h)*Math.round(i.loaded/h);i.total=i.loaded+d}else i.total=Math.max(i.loaded,i.total);const 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(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function Gh(s,t=null){const e=t||s,i={frag:s,part:t,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},r=e.byteRangeStartOffset,n=e.byteRangeEndOffset;if(K(r)&&K(n)){var a;let o=r,l=n;if(s.sn==="initSegment"&&((a=s.decryptdata)==null?void 0:a.method)==="AES-128"){const h=n-r;h%16&&(l=n+(16-h%16)),r!==0&&(i.resetIV=!0,o=r-16)}i.rangeStart=o,i.rangeEnd=l}return i}function Vh(s,t){const e=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:Y.MEDIA_ERROR,details:P.FRAG_GAP,fatal:!1,frag:s,error:e,networkDetails:null};return t&&(i.part=t),(t||s).stats.aborted=!0,new Re(i)}class Re extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class im{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const e in this.keyUriToKeyInfo){const i=this.keyUriToKeyInfo[e].loader;if(i){if(t&&t!==i.context.frag.type)return;i.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=P.KEY_LOAD_ERROR,i,r,n){return new Re({type:Y.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:n,error:i,networkDetails:r})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:r}=t;for(let n=0;n<e.length;n++){const a=e[n];if(r<=a.cc&&(i==="initSegment"||a.sn==="initSegment"||i<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(e=>this.loadInternal(t,e)):this.loadInternal(t)}loadInternal(t,e){var i,r;e&&t.setKeyFormat(e);const n=t.decryptdata;if(!n){const h=new Error(e?`Expected frag.decryptdata to be defined after setting format ${e}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,P.KEY_LOAD_ERROR,h))}const a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(t,P.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((i=o)!=null&&i.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:t,keyInfo:o});if((r=o)!=null&&r.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(h=>(n.key=h.keyInfo.decryptdata.key,{frag:t,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,t):this.loadKeyEME(o,t);case"AES-128":return this.loadKeyHTTP(o,t);default:return Promise.reject(this.createKeyLoadError(t,P.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(t,e){const i={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const r=this.emeController.loadKey(i);if(r)return(t.keyLoadPromise=r.then(n=>(t.mediaKeySessionContext=n,i))).catch(n=>{throw t.keyLoadPromise=null,n})}return Promise.resolve(i)}loadKeyHTTP(t,e){const i=this.config,r=i.loader,n=new r(i);return e.keyLoader=t.loader=n,t.keyLoadPromise=new Promise((a,o)=>{const l={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},h=i.keyLoadPolicy.default,d={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(u,f,p,g)=>{const{frag:m,keyInfo:b,url:A}=p;if(!m.decryptdata||b!==this.keyUriToKeyInfo[A])return o(this.createKeyLoadError(m,P.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),g));b.decryptdata.key=m.decryptdata.key=new Uint8Array(u.data),m.keyLoader=null,b.loader=null,a({frag:m,keyInfo:b})},onError:(u,f,p,g)=>{this.resetLoader(f),o(this.createKeyLoadError(e,P.KEY_LOAD_ERROR,new Error(`HTTP Error ${u.code} loading key ${u.text}`),p,jt({url:l.url,data:void 0},u)))},onTimeout:(u,f,p)=>{this.resetLoader(f),o(this.createKeyLoadError(e,P.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),p))},onAbort:(u,f,p)=>{this.resetLoader(f),o(this.createKeyLoadError(e,P.INTERNAL_ABORTED,new Error("key loading aborted"),p))}};n.load(l,d,c)})}resetLoader(t){const{frag:e,keyInfo:i,url:r}=t,n=i.loader;e.keyLoader===n&&(e.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[r],n&&n.destroy()}}class rm{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}const sm={length:0,start:()=>0,end:()=>0};class lt{static isBuffered(t,e){try{if(t){const i=lt.getBuffered(t);for(let r=0;r<i.length;r++)if(e>=i.start(r)&&e<=i.end(r))return!0}}catch{}return!1}static bufferInfo(t,e,i){try{if(t){const r=lt.getBuffered(t),n=[];let a;for(a=0;a<r.length;a++)n.push({start:r.start(a),end:r.end(a)});return this.bufferedInfo(n,e,i)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}}static bufferedInfo(t,e,i){e=Math.max(0,e),t.sort(function(h,d){return h.start-d.start||d.end-h.end});let r=[];if(i)for(let h=0;h<t.length;h++){const d=r.length;if(d){const c=r[d-1].end;t[h].start-c<i?t[h].end>c&&(r[d-1].end=t[h].end):r.push(t[h])}else r.push(t[h])}else r=t;let n=0,a,o=e,l=e;for(let h=0;h<r.length;h++){const d=r[h].start,c=r[h].end;if(e+i>=d&&e<c)o=d,l=c,n=l-e;else if(e+i<d){a=d;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(t){try{return t.buffered}catch(e){return R.log("failed to get media.buffered",e),sm}}}class na{constructor(t,e,i,r=0,n=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=gs(),this.buffering={audio:gs(),video:gs(),audiovideo:gs()},this.level=t,this.sn=e,this.id=i,this.size=r,this.part=n,this.partial=a}}function gs(){return{start:0,executeStart:0,executeEnd:0,end:0}}function jh(s,t){let e=null;for(let i=0,r=s.length;i<r;i++){const n=s[i];if(n&&n.cc===t){e=n;break}}return e}function nm(s,t,e){return!!(t.details&&(e.endCC>e.startCC||s&&s.cc<e.startCC))}function am(s,t,e=0){const i=s.fragments,r=t.fragments;if(!r.length||!i.length){R.log("No fragments to align");return}const n=jh(i,r[0].cc);if(!n||n&&!n.startPTS){R.log("No frag in previous level to align on");return}return n}function zh(s,t){if(s){const e=s.start+t;s.start=s.startPTS=e,s.endPTS=e+s.duration}}function aa(s,t){const e=t.fragments;for(let i=0,r=e.length;i<r;i++)zh(e[i],s);t.fragmentHint&&zh(t.fragmentHint,s),t.alignedSliding=!0}function om(s,t,e){t&&(lm(s,e,t),!e.alignedSliding&&t.details&&hm(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&Ph(t.details,e))}function lm(s,t,e){if(nm(s,e,t)){const i=am(e.details,t);i&&K(i.start)&&(R.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),aa(i.start,t))}}function hm(s,t){if(!t.fragments.length||!s.hasProgramDateTime||!t.hasProgramDateTime)return;const e=t.fragments[0].programDateTime,i=s.fragments[0].programDateTime,r=(i-e)/1e3+t.fragments[0].start;r&&K(r)&&(R.log(`Adjusting PTS using programDateTime delta ${i-e}ms, sliding:${r.toFixed(3)} ${s.url} `),aa(r,s))}function Kh(s,t){if(!s.hasProgramDateTime||!t.hasProgramDateTime)return;const e=s.fragments,i=t.fragments;if(!e.length||!i.length)return;const r=Math.round(i.length/2)-1,n=i[r],a=jh(e,n.cc)||e[Math.round(e.length/2)-1],o=n.programDateTime,l=a.programDateTime;if(o===null||l===null)return;const h=(l-o)/1e3-(a.start-n.start);aa(h,s)}class dm{constructor(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}decrypt(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)}}class cm{constructor(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function um(s){const t=s.byteLength,e=t&&new DataView(s.buffer).getUint8(t-1);return e?ni(s,0,t-e):s}class fm{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_(t){const e=new DataView(t),i=new Uint32Array(4);for(let r=0;r<4;r++)i[r]=e.getUint32(r*4);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,r=i[0],n=i[1],a=i[2],o=i[3],l=this.invSubMix,h=l[0],d=l[1],c=l[2],u=l[3],f=new Uint32Array(256);let p=0,g=0,m=0;for(m=0;m<256;m++)m<128?f[m]=m<<1:f[m]=m<<1^283;for(m=0;m<256;m++){let b=g^g<<1^g<<2^g<<3^g<<4;b=b>>>8^b&255^99,t[p]=b,e[b]=p;const A=f[p],T=f[A],y=f[T];let w=f[b]*257^b*16843008;r[p]=w<<24|w>>>8,n[p]=w<<16|w>>>16,a[p]=w<<8|w>>>24,o[p]=w,w=y*16843009^T*65537^A*257^p*16843008,h[b]=w<<24|w>>>8,d[b]=w<<16|w>>>16,c[b]=w<<8|w>>>24,u[b]=w,p?(p=A^f[f[f[y^A]]],g^=f[f[g]]):p=g=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let i=!0,r=0;for(;r<e.length&&i;)i=e[r]===this.key[r],r++;if(i)return;this.key=e;const n=this.keySize=e.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);const a=this.ksRows=(n+6+1)*4;let o,l;const h=this.keySchedule=new Uint32Array(a),d=this.invKeySchedule=new Uint32Array(a),c=this.sBox,u=this.rcon,f=this.invSubMix,p=f[0],g=f[1],m=f[2],b=f[3];let A,T;for(o=0;o<a;o++){if(o<n){A=h[o]=e[o];continue}T=A,o%n===0?(T=T<<8|T>>>24,T=c[T>>>24]<<24|c[T>>>16&255]<<16|c[T>>>8&255]<<8|c[T&255],T^=u[o/n|0]<<24):n>6&&o%n===4&&(T=c[T>>>24]<<24|c[T>>>16&255]<<16|c[T>>>8&255]<<8|c[T&255]),h[o]=A=(h[o-n]^T)>>>0}for(l=0;l<a;l++)o=a-l,l&3?T=h[o]:T=h[o-4],l<4||o<=4?d[l]=T:d[l]=p[c[T>>>24]]^g[c[T>>>16&255]]^m[c[T>>>8&255]]^b[c[T&255]],d[l]=d[l]>>>0}networkToHostOrderSwap(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24}decrypt(t,e,i){const r=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],h=o[1],d=o[2],c=o[3],u=this.uint8ArrayToUint32Array_(i);let f=u[0],p=u[1],g=u[2],m=u[3];const b=new Int32Array(t),A=new Int32Array(b.length);let T,y,w,S,L,C,k,x,N,O,V,W,E,I;const B=this.networkToHostOrderSwap;for(;e<b.length;){for(N=B(b[e]),O=B(b[e+1]),V=B(b[e+2]),W=B(b[e+3]),L=N^n[0],C=W^n[1],k=V^n[2],x=O^n[3],E=4,I=1;I<r;I++)T=l[L>>>24]^h[C>>16&255]^d[k>>8&255]^c[x&255]^n[E],y=l[C>>>24]^h[k>>16&255]^d[x>>8&255]^c[L&255]^n[E+1],w=l[k>>>24]^h[x>>16&255]^d[L>>8&255]^c[C&255]^n[E+2],S=l[x>>>24]^h[L>>16&255]^d[C>>8&255]^c[k&255]^n[E+3],L=T,C=y,k=w,x=S,E=E+4;T=a[L>>>24]<<24^a[C>>16&255]<<16^a[k>>8&255]<<8^a[x&255]^n[E],y=a[C>>>24]<<24^a[k>>16&255]<<16^a[x>>8&255]<<8^a[L&255]^n[E+1],w=a[k>>>24]<<24^a[x>>16&255]<<16^a[L>>8&255]<<8^a[C&255]^n[E+2],S=a[x>>>24]<<24^a[L>>16&255]<<16^a[C>>8&255]<<8^a[k&255]^n[E+3],A[e]=B(T^f),A[e+1]=B(S^p),A[e+2]=B(w^g),A[e+3]=B(y^m),f=N,p=O,g=V,m=W,e=e+4}return A.buffer}}const pm=16;class oa{constructor(t,{removePKCS7Padding:e=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=e,e)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}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(){const{currentResult:t,remainderData:e}=this;if(!t||e)return this.reset(),null;const i=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?um(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(t,e,i){return this.useSoftware?new Promise((r,n)=>{this.softwareDecrypt(new Uint8Array(t),e,i);const a=this.flush();a?r(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,i)}softwareDecrypt(t,e,i){const{currentIV:r,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(t=ai(a,t),this.remainderData=null);const o=this.getValidChunk(t);if(!o.length)return null;r&&(i=r);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new fm),l.expandKey(e);const h=n;return this.currentResult=l.decrypt(o.buffer,0,i),this.currentIV=ni(o,-16).buffer,h||null}webCryptoDecrypt(t,e,i){const r=this.subtle;return(this.key!==e||!this.fastAesKey)&&(this.key=e,this.fastAesKey=new cm(r,e)),this.fastAesKey.expandKey().then(n=>r?(this.logOnce("WebCrypto AES decrypt"),new dm(r,new Uint8Array(i)).decrypt(t.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(R.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(t,e,i)))}onWebCryptoError(t,e,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,i);const r=this.flush();if(r)return r.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const i=t.length-t.length%pm;return i!==t.length&&(e=ni(t,0,i),this.remainderData=ni(t,i)),e}logOnce(t){this.logEnabled&&(R.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const gm={toString:function(s){let t="";const e=s.length;for(let i=0;i<e;i++)t+=`[${s.start(i).toFixed(3)}-${s.end(i).toFixed(3)}]`;return t}},F={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"};class la extends rm{constructor(t,e,i,r,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=F.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=r,this.log=R.log.bind(R,`${r}:`),this.warn=R.warn.bind(R,`${r}:`),this.hls=t,this.fragmentLoader=new em(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new oa(t.config),t.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=F.STOPPED}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;const i=e.partList;if(i!=null&&i.length){const n=i[i.length-1];return lt.isBuffered(this.media,n.start+n.duration/2)}const r=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(r)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var t;return(t=this.levels[this.levelLastLoaded])==null?void 0:t.details}}onMediaAttached(t,e){const i=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);const r=this.config;this.levels&&r.autoStartLoad&&this.state===F.STOPPED&&this.startLoad(r.startPosition)}onMediaDetaching(){const t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:t,fragCurrent:e,media:i,mediaBuffer:r,state:n}=this,a=i?i.currentTime:0,o=lt.bufferInfo(r||i,a,t.maxBufferHole);if(this.log(`media seeking to ${K(a)?a.toFixed(3):a}, state: ${n}`),this.state===F.ENDED)this.resetLoadingState();else if(e){const l=t.maxFragLookUpTolerance,h=e.start-l,d=e.start+e.duration+l;if(!o.len||d<o.start||h>o.end){const c=a>d;(a<h||c)&&(c&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=F.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(t,e,i){this._loadFragForPlayback(t,e,i)}_loadFragForPlayback(t,e,i){const r=n=>{if(this.fragContextChanged(t)){this.warn(`Fragment ${t.sn}${n.part?" p: "+n.part.index:""} of level ${t.level} was dropped during download.`),this.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(t,e,i,r).then(n=>{if(!n)return;const a=this.state;if(this.fragContextChanged(t)){(a===F.FRAG_LOADING||!this.fragCurrent&&a===F.PARSING)&&(this.fragmentTracker.removeFragment(t),this.state=F.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(v.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===F.STOPPED||this.state===F.ERROR||(this.warn(n),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===Rt.APPENDING){const r=t.type,n=this.getFwdBufferInfo(this.mediaBuffer,r),a=Math.max(t.duration,n?n.len:this.config.maxBufferLength);this.reduceMaxBufferLength(a)&&i.removeFragment(t)}else((e=this.mediaBuffer)==null?void 0:e.buffered.length)===0?i.removeAllFragments():i.hasParts(t.type)&&(i.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),i.getState(t)===Rt.PARTIAL&&i.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const e=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)}flushMainBuffer(t,e,i=null){if(!(t-e))return;const r={startOffset:t,endOffset:e,type:i};this.hls.trigger(v.BUFFER_FLUSHING,r)}_loadInitSegment(t,e){this._doFragLoad(t,e).then(i=>{if(!i||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:r}=this,{payload:n}=i,a=t.decryptdata;if(n&&n.byteLength>0&&a&&a.key&&a.iv&&a.method==="AES-128"){const o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw r.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:t}),l}).then(l=>{const h=self.performance.now();return r.trigger(v.FRAG_DECRYPTED,{frag:t,payload:l,stats:{tstart:o,tdecrypt:h}}),i.payload=l,i})}return i}).then(i=>{const{fragCurrent:r,hls:n,levels:a}=this;if(!a)throw new Error("init load aborted, missing levels");const o=t.stats;this.state=F.IDLE,e.fragmentError=0,t.data=new Uint8Array(i.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),i.frag===r&&n.trigger(v.FRAG_BUFFERED,{stats:o,frag:r,part:null,id:t.type}),this.tick()}).catch(i=>{this.state===F.STOPPED||this.state===F.ERROR||(this.warn(i),this.resetFragmentLoading(t))})}fragContextChanged(t){const{fragCurrent:e}=this;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId}fragBufferedComplete(t,e){var i,r,n,a;const o=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===X.MAIN?"level":"track"} ${t.level} (frag:[${((i=t.startPTS)!=null?i:NaN).toFixed(3)}-${((r=t.endPTS)!=null?r:NaN).toFixed(3)}] > buffer:${o?gm.toString(lt.getBuffered(o)):"(detached)"})`),this.state=F.IDLE,o&&(!this.loadedmetadata&&t.type==X.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:i,part:r,partsLoaded:n}=t,a=!n||n.length===0||n.some(l=>!l),o=new na(i.level,i.sn,i.stats.chunkCount+1,0,r?r.index:-1,!a);e.flush(o)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,i=null,r){var n;const a=e==null?void 0:e.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(t.encrypted&&!((n=t.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${t.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${t.level}`),this.state=F.KEY_LOADING,this.fragCurrent=t,o=this.keyLoader.load(t).then(d=>{if(!this.fragContextChanged(d.frag))return this.hls.trigger(v.KEY_LOADED,d),this.state===F.KEY_LOADING&&(this.state=F.IDLE),d}),this.hls.trigger(v.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(t,a.encryptedFragments),i=Math.max(t.start,i||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){const d=a.partList;if(d&&r){i>t.end&&a.fragmentHint&&(t=a.fragmentHint);const c=this.getNextPart(d,t,i);if(c>-1){const u=d[c];this.log(`Loading part sn: ${t.sn} p: ${u.index} cc: ${t.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${c}-${d.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=u.start+u.duration,this.state=F.FRAG_LOADING;let f;return o?f=o.then(p=>!p||this.fragContextChanged(p.frag)?null:this.doFragPartsLoad(t,u,e,r)).catch(p=>this.handleFragLoadError(p)):f=this.doFragPartsLoad(t,u,e,r).catch(p=>this.handleFragLoadError(p)),this.hls.trigger(v.FRAG_LOADING,{frag:t,part:u,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!t.url||this.loadedEndOfParts(d,i))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),K(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=F.FRAG_LOADING;const l=this.config.progressive;let h;return l&&o?h=o.then(d=>!d||this.fragContextChanged(d==null?void 0:d.frag)?null:this.fragmentLoader.load(t,r)).catch(d=>this.handleFragLoadError(d)):h=Promise.all([this.fragmentLoader.load(t,l?r:void 0),o]).then(([d])=>(!l&&d&&r&&r(d),d)).catch(d=>this.handleFragLoadError(d)),this.hls.trigger(v.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):h}doFragPartsLoad(t,e,i,r){return new Promise((n,a)=>{var o;const l=[],h=(o=i.details)==null?void 0:o.partList,d=c=>{this.fragmentLoader.loadPart(t,c,r).then(u=>{l[c.index]=u;const f=u.part;this.hls.trigger(v.FRAG_LOADED,u);const p=Oh(i,t.sn,c.index+1)||Mh(h,t.sn,c.index+1);if(p)d(p);else return n({frag:t,part:f,partsLoaded:l})}).catch(a)};d(e)})}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===P.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(v.ERROR,e)}else this.hls.trigger(v.ERROR,{type:Y.OTHER_ERROR,details:P.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==F.PARSING){!this.fragCurrent&&this.state!==F.STOPPED&&this.state!==F.ERROR&&(this.state=F.IDLE);return}const{frag:i,part:r,level:n}=e,a=self.performance.now();i.stats.parsing.end=a,r&&(r.stats.parsing.end=a),this.updateLevelTiming(i,r,n,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:i}=this,{level:r,sn:n,part:a}=t;if(!(e!=null&&e[r]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${r}. The current chunk will not be buffered.`),null;const o=e[r],l=a>-1?Oh(o,n,a):null,h=l?l.fragment:Wg(o,n,i);return h?(i&&i!==h&&(h.stats=i.stats),{frag:h,part:l,level:o}):null}bufferFragmentData(t,e,i,r,n){var a;if(!t||this.state!==F.PARSING)return;const{data1:o,data2:l}=t;let h=o;if(o&&l&&(h=ai(o,l)),!((a=h)!=null&&a.length))return;const d={type:t.type,frag:e,part:i,chunkMeta:r,parent:e.type,data:h};if(this.hls.trigger(v.BUFFER_APPENDING,d),t.dropped&&t.independent&&!i){if(n)return;this.flushBufferGap(e)}}flushBufferGap(t){const e=this.media;if(!e)return;if(!lt.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}const i=e.currentTime,r=lt.bufferInfo(e,i,0),n=t.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(t.start-a,r.end-a),i+a);t.start-o>a&&this.flushMainBuffer(o,t.start)}getFwdBufferInfo(t,e){const i=this.getLoadPosition();return K(i)?this.getFwdBufferInfoAtPos(t,i,e):null}getFwdBufferInfoAtPos(t,e,i){const{config:{maxBufferHole:r}}=this,n=lt.bufferInfo(t,e,r);if(n.len===0&&n.nextStart!==void 0){const a=this.fragmentTracker.getBufferedFrag(e,i);if(a&&n.nextStart<a.end)return lt.bufferInfo(t,e,Math.max(n.nextStart,r))}return n}getMaxBufferLength(t){const{config:e}=this;let i;return t?i=Math.max(8*e.maxBufferSize/t,e.maxBufferLength):i=e.maxBufferLength,Math.min(i,e.maxMaxBufferLength)}reduceMaxBufferLength(t){const e=this.config,i=t||e.maxBufferLength;return e.maxMaxBufferLength>=i?(e.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${e.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(t,e=X.MAIN){const i=this.fragmentTracker.getAppendedFrag(t,X.MAIN);return i&&"fragment"in i?i.fragment:i}getNextFragment(t,e){const i=e.fragments,r=i.length;if(!r)return null;const{config:n}=this,a=i[0].start;let o;if(e.live){const l=n.initialLiveManifestSize;if(r<l)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${l})`),null;!e.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(o=this.getInitialLiveFragment(e,i),this.startPosition=o?this.hls.liveSyncPosition||o.start:t)}else t<=a&&(o=i[0]);if(!o){const l=n.lowLatencyMode?e.partEnd:e.fragmentEnd;o=this.getFragmentAtPosition(t,l,e)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(t,e){const i=this.fragmentTracker.getState(t);return(i===Rt.OK||i===Rt.PARTIAL&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,i,r,n){const a=t.gap,o=this.getNextFragment(this.nextLoadPosition,e);if(o===null)return o;if(t=o,a&&t&&!t.gap&&i.nextStart){const l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,r);if(l!==null&&i.len+l.len>=n)return this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${t.sn}`),null}return t}mapToInitFragWhenRequired(t){return t!=null&&t.initSegment&&!(t!=null&&t.initSegment.data)&&!this.bitrateTest?t.initSegment:t}getNextPart(t,e,i){let r=-1,n=!1,a=!0;for(let o=0,l=t.length;o<l;o++){const h=t[o];if(a=a&&!h.independent,r>-1&&i<h.start)break;const d=h.loaded;d?r=-1:(n||h.independent||a)&&h.fragment===e&&(r=o),n=d}return r}loadedEndOfParts(t,e){const i=t[t.length-1];return i&&e>i.start&&i.loaded}getInitialLiveFragment(t,e){const i=this.fragPrevious;let r=null;if(i){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),r=Xg(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){const n=i.sn+1;if(n>=t.startSN&&n<=t.endSN){const a=e[n-t.startSN];i.cc===a.cc&&(r=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}r||(r=Zg(e,i.cc),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`))}}else{const n=this.hls.liveSyncPosition;n!==null&&(r=this.getFragmentAtPosition(n,this.bitrateTest?t.fragmentEnd:t.edge,t))}return r}getFragmentAtPosition(t,e,i){const{config:r}=this;let{fragPrevious:n}=this,{fragments:a,endSN:o}=i;const{fragmentHint:l}=i,h=r.maxFragLookUpTolerance,d=i.partList,c=!!(r.lowLatencyMode&&d!=null&&d.length&&l);c&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let u;if(t<e){const f=t>e-h?0:h;u=br(n,a,t,f)}else u=a[a.length-1];if(u){const f=u.sn-i.startSN,p=this.fragmentTracker.getState(u);if((p===Rt.OK||p===Rt.PARTIAL&&u.gap)&&(n=u),n&&u.sn===n.sn&&(!c||d[0].fragment.sn>u.sn)&&n&&u.level===n.level){const g=a[f+1];u.sn<o&&this.fragmentTracker.getState(g)!==Rt.OK?u=g:u=null}}return u}synchronizeToLiveEdge(t){const{config:e,media:i}=this;if(!i)return;const r=this.hls.liveSyncPosition,n=i.currentTime,a=t.fragments[0].start,o=t.edge,l=n>=a-e.maxFragLookUpTolerance&&n<=o;if(r!==null&&i.duration>r&&(n<r||!l)){const h=e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!l&&i.readyState<4||n<o-h)&&(this.loadedmetadata||(this.nextLoadPosition=r),i.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${r.toFixed(3)}`),i.currentTime=r))}}alignPlaylists(t,e){const{levels:i,levelLastLoaded:r,fragPrevious:n}=this,a=r!==null?i[r]:null,o=t.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;const l=t.fragments[0].start,h=!e,d=t.alignedSliding&&K(l);if(h||!d&&!l){om(n,a,t);const c=t.fragments[0].start;return this.log(`Live playlist sliding: ${c.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} prev-sn: ${n?n.sn:"na"} fragments: ${o}`),c}return l}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*3)}setStartPosition(t,e){let i=this.startPosition;if(i<e&&(i=-1),i===-1||this.lastCurrentTime===-1){const r=this.startTimeOffset!==null,n=r?this.startTimeOffset:t.startTimeOffset;n!==null&&K(n)?(i=e+n,n<0&&(i+=t.totalduration),i=Math.min(Math.max(e,i),e+t.totalduration),this.log(`Start time offset ${n} found in ${r?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):t.live?i=this.hls.liveSyncPosition||e:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}getLoadPosition(){const{media:t}=this;let e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e}handleFragLoadAborted(t,e){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn(`Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==F.FRAG_LOADING_WAITING_RETRY)&&(this.state=F.IDLE)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const c=this.getCurrentContext(e.chunkMeta);c&&(e.frag=c.frag)}const i=e.frag;if(!i||i.type!==t||!this.levels)return;if(this.fragContextChanged(i)){var r;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(r=this.fragCurrent)==null?void 0:r.url}`);return}const n=e.details===P.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);const a=e.errorAction,{action:o,retryCount:l=0,retryConfig:h}=a||{};if(a&&o===Ft.RetryRequest&&h){var d;this.resetStartWhenNotLoaded((d=this.levelLastLoaded)!=null?d:i.level);const c=ea(h,l);this.warn(`Fragment ${i.sn} of ${t} ${i.level} errored with ${e.details}, retrying loading ${l+1}/${h.maxNumRetry} in ${c}ms`),a.resolved=!0,this.retryDate=self.performance.now()+c,this.state=F.FRAG_LOADING_WAITING_RETRY}else h&&a?(this.resetFragmentErrors(t),l<h.maxNumRetry?n||(a.resolved=!0):R.warn(`${e.details} reached or exceeded max retry (${l})`)):(a==null?void 0:a.action)===Ft.SendAlternateToPenaltyBox?this.state=F.WAITING_LEVEL:this.state=F.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===F.PARSING||this.state===F.PARSED){const e=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,e),r=i&&i.len>.5;r&&this.reduceMaxBufferLength(i.len);const n=!r;return n&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${e} buffer`),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(t){t===X.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==F.STOPPED&&(this.state=F.IDLE)}afterBufferFlushed(t,e,i){if(!t)return;const r=lt.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,r,i),this.state===F.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=F.IDLE}resetStartWhenNotLoaded(t){if(!this.loadedmetadata){this.startFragRequested=!1;const e=this.levels?this.levels[t].details:null;e!=null&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){var e;this.warn(`The loading context changed while buffering fragment ${t.sn} of level ${t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((e=this.levelLastLoaded)!=null?e:t.level),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,e,i,r){var n;const a=i.details;if(!a){this.warn("level.details undefined");return}if(Object.keys(t.elementaryStreams).reduce((o,l)=>{const h=t.elementaryStreams[l];if(h){const d=h.endPTS-h.startPTS;if(d<=0)return this.warn(`Could not parse fragment ${t.sn} ${l} duration reliably (${d})`),o||!1;const c=r?0:Ih(a,t,h.startPTS,h.endPTS,h.startDTS,h.endDTS);return this.hls.trigger(v.LEVEL_PTS_UPDATED,{details:a,level:i,drift:c,type:l,frag:t,start:h.startPTS,end:h.endPTS}),!0}return o},!1))i.fragmentError=0;else if(((n=this.transmuxer)==null?void 0:n.error)===null){const o=new Error(`Found no media in fragment ${t.sn} of level ${t.level} resetting transmuxer to fallback to playlist timing`);if(i.fragmentError===0&&(i.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(o.message),this.hls.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:t,reason:`Found no media in msn ${t.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=F.PARSED,this.hls.trigger(v.FRAG_PARSED,{frag:t,part:e})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){if(t.event==="demuxerWorker"){var e,i,r;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((e=(i=this.levelLastLoaded)!=null?i:(r=this.fragCurrent)==null?void 0:r.level)!=null?e:0),this.resetLoadingState()}}set state(t){const e=this._state;e!==t&&(this._state=t,this.log(`${e}->${t}`))}get state(){return this._state}}function Wh(){return self.SourceBuffer||self.WebKitSourceBuffer}function mm(){const s=hs();if(!s)return!1;const t=Wh(),e=s&&typeof s.isTypeSupported=="function"&&s.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function";return!!e&&!!i}function vm(){var s;const t=Wh();return typeof(t==null||(s=t.prototype)==null?void 0:s.changeType)=="function"}function ym(){return typeof __HLS_WORKER_BUNDLE__=="function"}function bm(){const s=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(s);return{worker:new self.Worker(t),objectURL:t}}function Am(s){const t=new self.URL(s,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}function ve(s="",t=9e4){return{type:s,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class Yh{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(t,e,i,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,i){}demux(t,e){this.cachedData&&(t=ai(this.cachedData,t),this.cachedData=null);let i=ns(t,0),r=i?i.length:0,n;const a=this._audioTrack,o=this._id3Track,l=i?ig(i):void 0,h=t.length;for((this.basePTS===null||this.frameIndex===0&&K(l))&&(this.basePTS=Tm(l,e,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:le.audioId3,duration:Number.POSITIVE_INFINITY});r<h;){if(this.canParse(t,r)){const d=this.appendFrame(a,t,r);d?(this.frameIndex++,this.lastPTS=d.sample.pts,r+=d.length,n=r):r=h}else eg(t,r)?(i=ns(t,r),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:le.audioId3,duration:Number.POSITIVE_INFINITY}),r+=i.length,n=r):r++;if(r===h&&n!==h){const d=ni(t,n);this.cachedData?this.cachedData=ai(this.cachedData,d):this.cachedData=d}}return{audioTrack:a,videoTrack:ve(),id3Track:o,textTrack:ve()}}demuxSampleAes(t,e,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(t){const e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:ve(),id3Track:this._id3Track,textTrack:ve()}}destroy(){}}const Tm=(s,t,e)=>{if(K(s))return s*90;const i=e?e.baseTime*9e4/e.timescale:0;return t*9e4+i};function Em(s,t,e,i){let r,n,a,o;const l=navigator.userAgent.toLowerCase(),h=i,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((t[e+2]&192)>>>6)+1;const c=(t[e+2]&60)>>>2;if(c>d.length-1){s.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${c}`});return}return a=(t[e+2]&1)<<2,a|=(t[e+3]&192)>>>6,R.log(`manifest codec:${i}, ADTS type:${r}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(r=5,o=new Array(4),n=c-3):(r=2,o=new Array(2),n=c):l.indexOf("android")!==-1?(r=2,o=new Array(2),n=c):(r=5,o=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&c>=6?n=c-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(c>=6&&a===1||/vivaldi/i.test(l))||!i&&a===1)&&(r=2,o=new Array(2)),n=c)),o[0]=r<<3,o[0]|=(c&14)>>1,o[1]|=(c&1)<<7,o[1]|=a<<3,r===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:d[c],channelCount:a,codec:"mp4a.40."+r,manifestCodec:h}}function Xh(s,t){return s[t]===255&&(s[t+1]&246)===240}function qh(s,t){return s[t+1]&1?7:9}function ha(s,t){return(s[t+3]&3)<<11|s[t+4]<<3|(s[t+5]&224)>>>5}function wm(s,t){return t+5<s.length}function ms(s,t){return t+1<s.length&&Xh(s,t)}function Sm(s,t){return wm(s,t)&&Xh(s,t)&&ha(s,t)<=s.length-t}function Lm(s,t){if(ms(s,t)){const e=qh(s,t);if(t+e>=s.length)return!1;const i=ha(s,t);if(i<=e)return!1;const r=t+i;return r===s.length||ms(s,r)}return!1}function Zh(s,t,e,i,r){if(!s.samplerate){const n=Em(t,e,i,r);if(!n)return;s.config=n.config,s.samplerate=n.samplerate,s.channelCount=n.channelCount,s.codec=n.codec,s.manifestCodec=n.manifestCodec,R.log(`parsed codec:${s.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function Jh(s){return 9216e4/s}function Rm(s,t){const e=qh(s,t);if(t+e<=s.length){const i=ha(s,t)-e;if(i>0)return{headerLength:e,frameLength:i}}}function Qh(s,t,e,i,r){const n=Jh(s.samplerate),a=i+r*n,o=Rm(t,e);let l;if(o){const{frameLength:d,headerLength:c}=o,u=c+d,f=Math.max(0,e+u-t.length);f?(l=new Uint8Array(u-c),l.set(t.subarray(e+c,t.length),0)):l=t.subarray(e+c,e+u);const p={unit:l,pts:a};return f||s.samples.push(p),{sample:p,length:u,missing:f}}const h=t.length-e;return l=new Uint8Array(h),l.set(t.subarray(e,t.length),0),{sample:{unit:l,pts:a},length:h,missing:-1}}class xm extends Yh{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,i,r){super.resetInitSegment(t,e,i,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:r,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(ns(t,0)||[]).length;for(let i=t.length;e<i;e++)if(Lm(t,e))return R.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return Sm(t,e)}appendFrame(t,e,i){Zh(t,this.observer,e,i,t.manifestCodec);const r=Qh(t,e,i,this.basePTS,this.frameIndex);if(r&&r.missing===0)return r}}const km=/\/emsg[-/]ID3/i;class Dm{constructor(t,e){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=e}resetTimeStamp(){}resetInitSegment(t,e,i,r){const n=this.videoTrack=ve("video",1),a=this.audioTrack=ve("audio",1),o=this.txtTrack=ve("text",1);if(this.id3Track=ve("id3",1),this.timeOffset=0,!(t!=null&&t.byteLength))return;const l=hh(t);if(l.video){const{id:h,timescale:d,codec:c}=l.video;n.id=h,n.timescale=o.timescale=d,n.codec=c}if(l.audio){const{id:h,timescale:d,codec:c}=l.audio;a.id=h,a.timescale=d,a.codec=c}o.id=ah.text,n.sampleDuration=0,n.duration=a.duration=r}resetContiguity(){this.remainderData=null}static probe(t){return t=t.length>16384?t.subarray(0,16384):t,et(t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let i=t;const r=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=ai(this.remainderData,t));const o=vg(i);this.remainderData=o.remainder,r.samples=o.valid||new Uint8Array}else r.samples=i;const a=this.extractID3Track(r,e);return n.samples=ch(e,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,i=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const r=this.extractID3Track(e,this.timeOffset);return i.samples=ch(t,e),{videoTrack:e,audioTrack:ve(),id3Track:r,textTrack:ve()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const r=et(t.samples,["emsg"]);r&&r.forEach(n=>{const a=Ag(n);if(km.test(a.schemeIdUri)){const o=K(a.presentationTime)?a.presentationTime/a.timeScale:e+a.presentationTimeDelta/a.timeScale;let l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);const h=a.payload;i.samples.push({data:h,len:h.byteLength,dts:o,pts:o,type:le.emsg,duration:l})}})}return i}demuxSampleAes(t,e,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}let vs=null;const Cm=[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],Im=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Pm=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Om=[0,1,1,4];function _h(s,t,e,i,r){if(e+24>t.length)return;const n=$h(t,e);if(n&&e+n.frameLength<=t.length){const a=n.samplesPerFrame*9e4/n.sampleRate,o=i+r*a,l={unit:t.subarray(e,e+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 $h(s,t){const e=s[t+1]>>3&3,i=s[t+1]>>1&3,r=s[t+2]>>4&15,n=s[t+2]>>2&3;if(e!==1&&r!==0&&r!==15&&n!==3){const a=s[t+2]>>1&1,o=s[t+3]>>6,l=e===3?3-i:i===3?3:4,h=Cm[l*14+r-1]*1e3,d=Im[(e===3?0:e===2?1:2)*3+n],c=o===3?1:2,u=Pm[e][i],f=Om[i],p=u*8*f,g=Math.floor(u*h/d+a)*f;if(vs===null){const m=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);vs=m?parseInt(m[1]):0}return vs&&vs<=87&&i===2&&h>=224e3&&o===0&&(s[t+3]=s[t+3]|128),{sampleRate:d,channelCount:c,frameLength:g,samplesPerFrame:p}}}function da(s,t){return s[t]===255&&(s[t+1]&224)===224&&(s[t+1]&6)!==0}function td(s,t){return t+1<s.length&&da(s,t)}function Mm(s,t){return da(s,t)&&4<=s.length-t}function Fm(s,t){if(t+1<s.length&&da(s,t)){const e=$h(s,t);let i=4;e!=null&&e.frameLength&&(i=e.frameLength);const r=t+i;return r===s.length||td(s,r)}return!1}class ed{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const t=this.data,e=this.bytesAvailable,i=t.byteLength-e,r=new Uint8Array(4),n=Math.min(4,e);if(n===0)throw new Error("no bytes available");r.set(t.subarray(i,i+n)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(t){let e;t=Math.min(t,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,e=t>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let e=Math.min(this.bitsAvailable,t);const i=this.word>>>32-e;if(t>32&&R.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return e=t-e,e>0&&this.bitsAvailable?i<<e|this.readBits(e):i}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(this.word&2147483648>>>t)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(t){let e=8,i=8,r;for(let n=0;n<t;n++)i!==0&&(r=this.readEG(),i=(e+r+256)%256),e=i===0?e:i}readSPS(){let t=0,e=0,i=0,r=0,n,a,o;const l=this.readUByte.bind(this),h=this.readBits.bind(this),d=this.readUEG.bind(this),c=this.readBoolean.bind(this),u=this.skipBits.bind(this),f=this.skipEG.bind(this),p=this.skipUEG.bind(this),g=this.skipScalingList.bind(this);l();const m=l();if(h(5),u(3),l(),p(),m===100||m===110||m===122||m===244||m===44||m===83||m===86||m===118||m===128){const S=d();if(S===3&&u(1),p(),p(),u(1),c())for(a=S!==3?8:12,o=0;o<a;o++)c()&&(o<6?g(16):g(64))}p();const b=d();if(b===0)d();else if(b===1)for(u(1),f(),f(),n=d(),o=0;o<n;o++)f();p(),u(1);const A=d(),T=d(),y=h(1);y===0&&u(1),u(1),c()&&(t=d(),e=d(),i=d(),r=d());let w=[1,1];if(c()&&c())switch(l()){case 1:w=[1,1];break;case 2:w=[12,11];break;case 3:w=[10,11];break;case 4:w=[16,11];break;case 5:w=[40,33];break;case 6:w=[24,11];break;case 7:w=[20,11];break;case 8:w=[32,11];break;case 9:w=[80,33];break;case 10:w=[18,11];break;case 11:w=[15,11];break;case 12:w=[64,33];break;case 13:w=[160,99];break;case 14:w=[4,3];break;case 15:w=[3,2];break;case 16:w=[2,1];break;case 255:{w=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((A+1)*16-t*2-e*2),height:(2-y)*(T+1)*16-(y?2:4)*(i+r),pixelRatio:w}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Nm{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new oa(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,i){const r=t[e].unit;if(r.length<=16)return;const n=r.subarray(16,r.length-r.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{const l=new Uint8Array(o);r.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,i)})}decryptAacSamples(t,e,i){for(;;e++){if(e>=t.length){i();return}if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(t){const e=Math.floor((t.length-48)/160)*16+16,i=new Int8Array(e);let r=0;for(let n=32;n<t.length-16;n+=160,r+=16)i.set(t.subarray(n,n+16),r);return i}getAvcDecryptedUnit(t,e){const i=new Uint8Array(e);let r=0;for(let n=32;n<t.length-16;n+=160,r+=16)t.set(i.subarray(r,r+16),n);return t}decryptAvcSample(t,e,i,r,n){const a=fh(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(t,e,i+1,r)})}decryptAvcSamples(t,e,i,r){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length){r();return}const n=t[e].units;for(;!(i>=n.length);i++){const a=n[i];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(t,e,i,r,a),!this.decrypter.isSync()))return}}}}const Nt=188;class Fe{constructor(t,e,i){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=i}static probe(t){const e=Fe.syncOffset(t);return e>0&&R.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),e!==-1}static syncOffset(t){const e=t.length;let i=Math.min(Nt*5,t.length-Nt)+1,r=0;for(;r<i;){let n=!1,a=-1,o=0;for(let l=r;l<e;l+=Nt)if(t[l]===71){if(o++,a===-1&&(a=l,a!==0&&(i=Math.min(a+Nt*99,t.length-Nt)+1)),n||(n=ca(t,l)===0),n&&o>1&&(a===0&&o>2||l+Nt>i))return a}else{if(o)return-1;break}r++}return-1}static createTrack(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:ah[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}}resetInitSegment(t,e,i,r){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Fe.createTrack("video"),this._audioTrack=Fe.createTrack("audio",r),this._id3Track=Fe.createTrack("id3"),this._txtTrack=Fe.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=i,this._duration=r}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_avcTrack:e,_id3Track:i}=this;t&&(t.pesData=null),e&&(e.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(t,e,i=!1,r=!1){i||(this.sampleAes=null);let n;const a=this._avcTrack,o=this._audioTrack,l=this._id3Track,h=this._txtTrack;let d=a.pid,c=a.pesData,u=o.pid,f=l.pid,p=o.pesData,g=l.pesData,m=null,b=this.pmtParsed,A=this._pmtId,T=t.length;if(this.remainderData&&(t=ai(this.remainderData,t),T=t.length,this.remainderData=null),T<Nt&&!r)return this.remainderData=t,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:h};const y=Math.max(0,Fe.syncOffset(t));T-=(T-y)%Nt,T<t.byteLength&&!r&&(this.remainderData=new Uint8Array(t.buffer,T,t.buffer.byteLength-T));let w=0;for(let L=y;L<T;L+=Nt)if(t[L]===71){const C=!!(t[L+1]&64),k=ca(t,L),x=(t[L+3]&48)>>4;let N;if(x>1){if(N=L+5+t[L+4],N===L+Nt)continue}else N=L+4;switch(k){case d:C&&(c&&(n=xi(c))&&this.parseAVCPES(a,h,n,!1),c={data:[],size:0}),c&&(c.data.push(t.subarray(N,L+Nt)),c.size+=L+Nt-N);break;case u:if(C){if(p&&(n=xi(p)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break}p={data:[],size:0}}p&&(p.data.push(t.subarray(N,L+Nt)),p.size+=L+Nt-N);break;case f:C&&(g&&(n=xi(g))&&this.parseID3PES(l,n),g={data:[],size:0}),g&&(g.data.push(t.subarray(N,L+Nt)),g.size+=L+Nt-N);break;case 0:C&&(N+=t[N]+1),A=this._pmtId=Um(t,N);break;case A:{C&&(N+=t[N]+1);const O=Bm(t,N,this.typeSupported,i);d=O.avc,d>0&&(a.pid=d),u=O.audio,u>0&&(o.pid=u,o.segmentCodec=O.segmentCodec),f=O.id3,f>0&&(l.pid=f),m!==null&&!b&&(R.warn(`MPEG-TS PMT found at ${L} after unknown PID '${m}'. Backtracking to sync byte @${y} to parse all TS packets.`),m=null,L=y-188),b=this.pmtParsed=!0;break}case 17:case 8191:break;default:m=k;break}}else w++;if(w>0){const L=new Error(`Found ${w} TS packet/s that do not start with 0x47`);this.observer.emit(v.ERROR,v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,fatal:!1,error:L,reason:L.message})}a.pesData=c,o.pesData=p,l.pesData=g;const S={audioTrack:o,videoTrack:a,id3Track:l,textTrack:h};return r&&this.extractRemainingSamples(S),S}flush(){const{remainderData:t}=this;this.remainderData=null;let e;return t?e=this.demux(t,-1,!1,!0):e={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(t){const{audioTrack:e,videoTrack:i,id3Track:r,textTrack:n}=t,a=i.pesData,o=e.pesData,l=r.pesData;let h;if(a&&(h=xi(a))?(this.parseAVCPES(i,n,h,!0),i.pesData=null):i.pesData=a,o&&(h=xi(o))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,h);break;case"mp3":this.parseMPEGPES(e,h);break}e.pesData=null}else o!=null&&o.size&&R.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=o;l&&(h=xi(l))?(this.parseID3PES(r,h),r.pesData=null):r.pesData=l}demuxSampleAes(t,e,i){const r=this.demux(t,i,!0,!this.config.progressive),n=this.sampleAes=new Nm(this.observer,this.config,e);return this.decrypt(r,n)}decrypt(t,e){return new Promise(i=>{const{audioTrack:r,videoTrack:n}=t;r.samples&&r.segmentCodec==="aac"?e.decryptAacSamples(r.samples,0,()=>{n.samples?e.decryptAvcSamples(n.samples,0,0,()=>{i(t)}):i(t)}):n.samples&&e.decryptAvcSamples(n.samples,0,0,()=>{i(t)})})}destroy(){this._duration=0}parseAVCPES(t,e,i,r){const n=this.parseAVCNALu(t,i.data);let a=this.avcSample,o,l=!1;i.data=null,a&&n.length&&!t.audFound&&(Ar(a,t),a=this.avcSample=ys(!1,i.pts,i.dts,"")),n.forEach(h=>{var d;switch(h.type){case 1:{let u=!1;o=!0;const f=h.data;if(l&&f.length>4){const p=new ed(f).readSliceType();(p===2||p===4||p===7||p===9)&&(u=!0)}if(u){var c;(c=a)!=null&&c.frame&&!a.key&&(Ar(a,t),a=this.avcSample=null)}a||(a=this.avcSample=ys(!0,i.pts,i.dts,"")),a.frame=!0,a.key=u;break}case 5:o=!0,(d=a)!=null&&d.frame&&!a.key&&(Ar(a,t),a=this.avcSample=null),a||(a=this.avcSample=ys(!0,i.pts,i.dts,"")),a.key=!0,a.frame=!0;break;case 6:{o=!0,uh(h.data,1,i.pts,e.samples);break}case 7:if(o=!0,l=!0,!t.sps){const u=h.data,f=new ed(u).readSPS();t.width=f.width,t.height=f.height,t.pixelRatio=f.pixelRatio,t.sps=[u],t.duration=this._duration;const p=u.subarray(1,4);let g="avc1.";for(let m=0;m<3;m++){let b=p[m].toString(16);b.length<2&&(b="0"+b),g+=b}t.codec=g}break;case 8:o=!0,t.pps||(t.pps=[h.data]);break;case 9:o=!1,t.audFound=!0,a&&Ar(a,t),a=this.avcSample=ys(!1,i.pts,i.dts,"");break;case 12:o=!0;break;default:o=!1,a&&(a.debug+="unknown NAL "+h.type+" ");break}a&&o&&a.units.push(h)}),r&&a&&(Ar(a,t),this.avcSample=null)}getLastNalUnit(t){var e;let i=this.avcSample,r;if((!i||i.units.length===0)&&(i=t[t.length-1]),(e=i)!=null&&e.units){const n=i.units;r=n[n.length-1]}return r}parseAVCNALu(t,e){const i=e.byteLength;let r=t.naluState||0;const n=r,a=[];let o=0,l,h,d,c=-1,u=0;for(r===-1&&(c=0,u=e[0]&31,r=0,o=1);o<i;){if(l=e[o++],!r){r=l?0:1;continue}if(r===1){r=l?0:2;continue}if(!l)r=3;else if(l===1){if(c>=0){const f={data:e.subarray(c,o-r-1),type:u};a.push(f)}else{const f=this.getLastNalUnit(t.samples);if(f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),h=o-r-1,h>0)){const p=new Uint8Array(f.data.byteLength+h);p.set(f.data,0),p.set(e.subarray(0,h),f.data.byteLength),f.data=p,f.state=0}}o<i?(d=e[o]&31,c=o,u=d,r=0):r=-1}else r=0}if(c>=0&&r>=0){const f={data:e.subarray(c,i),type:u,state:r};a.push(f)}if(a.length===0){const f=this.getLastNalUnit(t.samples);if(f){const p=new Uint8Array(f.data.byteLength+e.byteLength);p.set(f.data,0),p.set(e,f.data.byteLength),f.data=p}}return t.naluState=r,a}parseAACPES(t,e){let i=0;const r=this.aacOverFlow;let n=e.data;if(r){this.aacOverFlow=null;const c=r.missing,u=r.sample.unit.byteLength;if(c===-1){const f=new Uint8Array(u+n.byteLength);f.set(r.sample.unit,0),f.set(n,u),n=f}else{const f=u-c;r.sample.unit.set(n.subarray(0,c),f),t.samples.push(r.sample),i=r.missing}}let a,o;for(a=i,o=n.length;a<o-1&&!ms(n,a);a++);if(a!==i){let c;const u=a<o-1;u?c=`AAC PES did not start with ADTS header,offset:${a}`:c="No ADTS header found in AAC PES";const f=new Error(c);if(R.warn(`parsing error: ${c}`),this.observer.emit(v.ERROR,v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,fatal:!1,levelRetry:u,error:f,reason:c}),!u)return}Zh(t,this.observer,n,a,this.audioCodec);let l;if(e.pts!==void 0)l=e.pts;else if(r){const c=Jh(t.samplerate);l=r.sample.pts+c}else{R.warn("[tsdemuxer]: AAC PES unknown PTS");return}let h=0,d;for(;a<o;)if(d=Qh(t,n,a,l,h),a+=d.length,d.missing){this.aacOverFlow=d;break}else for(h++;a<o-1&&!ms(n,a);a++);}parseMPEGPES(t,e){const i=e.data,r=i.length;let n=0,a=0;const o=e.pts;if(o===void 0){R.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<r;)if(td(i,a)){const l=_h(t,i,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseID3PES(t,e){if(e.pts===void 0){R.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=Et({},e,{type:this._avcTrack?le.emsg:le.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function ys(s,t,e,i){return{key:s,frame:!1,pts:t,dts:e,units:[],debug:i,length:0}}function ca(s,t){return((s[t+1]&31)<<8)+s[t+2]}function Um(s,t){return(s[t+10]&31)<<8|s[t+11]}function Bm(s,t,e,i){const r={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=(s[t+1]&15)<<8|s[t+2],a=t+3+n-4,o=(s[t+10]&15)<<8|s[t+11];for(t+=12+o;t<a;){const l=ca(s,t);switch(s[t]){case 207:if(!i){R.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:r.audio===-1&&(r.audio=l);break;case 21:r.id3===-1&&(r.id3=l);break;case 219:if(!i){R.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:r.avc===-1&&(r.avc=l);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?R.log("MPEG audio found, not supported in this browser"):r.audio===-1&&(r.audio=l,r.segmentCodec="mp3");break;case 36:R.warn("Unsupported HEVC stream type found");break}t+=((s[t+3]&15)<<8|s[t+4])+5}return r}function xi(s){let t=0,e,i,r,n,a;const o=s.data;if(!s||s.size===0)return null;for(;o[0].length<19&&o.length>1;){const l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(e=o[0],(e[0]<<16)+(e[1]<<8)+e[2]===1){if(i=(e[4]<<8)+e[5],i&&i>s.size-6)return null;const l=e[7];l&192&&(n=(e[9]&14)*536870912+(e[10]&255)*4194304+(e[11]&254)*16384+(e[12]&255)*128+(e[13]&254)/2,l&64?(a=(e[14]&14)*536870912+(e[15]&255)*4194304+(e[16]&254)*16384+(e[17]&255)*128+(e[18]&254)/2,n-a>54e5&&(R.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),r=e[8];let h=r+9;if(s.size<=h)return null;s.size-=h;const d=new Uint8Array(s.size);for(let c=0,u=o.length;c<u;c++){e=o[c];let f=e.byteLength;if(h)if(h>f){h-=f;continue}else e=e.subarray(h),f-=h,h=0;d.set(e,t),t+=f}return i&&(i-=r+3),{data:d,pts:n,dts:a,len:i}}return null}function Ar(s,t){if(s.units.length&&s.frame){if(s.pts===void 0){const e=t.samples,i=e.length;if(i){const r=e[i-1];s.pts=r.pts,s.dts=r.dts}else{t.dropped++;return}}t.samples.push(s)}s.debug.length&&R.log(s.pts+"/"+s.dts+":"+s.debug)}class Hm extends Yh{resetInitSegment(t,e,i,r){super.resetInitSegment(t,e,i,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:r,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(ns(t,0)||[]).length;for(let i=t.length;e<i;e++)if(Fm(t,e))return R.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return Mm(t,e)}appendFrame(t,e,i){if(this.basePTS!==null)return _h(t,e,i,this.basePTS,this.frameIndex)}}class id{static getSilentFrame(t,e){switch(t){case"mp4a.40.2":if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===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(e===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(e===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(e===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(e===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}}}const Ne=Math.pow(2,32)-1;class D{static init(){D.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let t;for(t in D.types)D.types.hasOwnProperty(t)&&(D.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const e=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]);D.HDLR_TYPES={video:e,audio:i};const 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]);D.STTS=D.STSC=D.STCO=n,D.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),D.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),D.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),D.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);D.FTYP=D.box(D.types.ftyp,a,l,a,o),D.DINF=D.box(D.types.dinf,D.box(D.types.dref,r))}static box(t,...e){let i=8,r=e.length;const n=r;for(;r--;)i+=e[r].byteLength;const 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(t,4),r=0,i=8;r<n;r++)a.set(e[r],i),i+=e[r].byteLength;return a}static hdlr(t){return D.box(D.types.hdlr,D.HDLR_TYPES[t])}static mdat(t){return D.box(D.types.mdat,t)}static mdhd(t,e){e*=t;const i=Math.floor(e/(Ne+1)),r=Math.floor(e%(Ne+1));return D.box(D.types.mdhd,new Uint8Array([1,0,0,0,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,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(t){return D.box(D.types.mdia,D.mdhd(t.timescale,t.duration),D.hdlr(t.type),D.minf(t))}static mfhd(t){return D.box(D.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]))}static minf(t){return t.type==="audio"?D.box(D.types.minf,D.box(D.types.smhd,D.SMHD),D.DINF,D.stbl(t)):D.box(D.types.minf,D.box(D.types.vmhd,D.VMHD),D.DINF,D.stbl(t))}static moof(t,e,i){return D.box(D.types.moof,D.mfhd(t),D.traf(i,e))}static moov(t){let e=t.length;const i=[];for(;e--;)i[e]=D.trak(t[e]);return D.box.apply(null,[D.types.moov,D.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(D.mvex(t)))}static mvex(t){let e=t.length;const i=[];for(;e--;)i[e]=D.trex(t[e]);return D.box.apply(null,[D.types.mvex,...i])}static mvhd(t,e){e*=t;const i=Math.floor(e/(Ne+1)),r=Math.floor(e%(Ne+1)),n=new Uint8Array([1,0,0,0,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,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 D.box(D.types.mvhd,n)}static sdtp(t){const e=t.samples||[],i=new Uint8Array(4+e.length);let r,n;for(r=0;r<e.length;r++)n=e[r].flags,i[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return D.box(D.types.sdtp,i)}static stbl(t){return D.box(D.types.stbl,D.stsd(t),D.box(D.types.stts,D.STTS),D.box(D.types.stsc,D.STSC),D.box(D.types.stsz,D.STSZ),D.box(D.types.stco,D.STCO))}static avc1(t){let e=[],i=[],r,n,a;for(r=0;r<t.sps.length;r++)n=t.sps[r],a=n.byteLength,e.push(a>>>8&255),e.push(a&255),e=e.concat(Array.prototype.slice.call(n));for(r=0;r<t.pps.length;r++)n=t.pps[r],a=n.byteLength,i.push(a>>>8&255),i.push(a&255),i=i.concat(Array.prototype.slice.call(n));const o=D.box(D.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|t.sps.length].concat(e).concat([t.pps.length]).concat(i))),l=t.width,h=t.height,d=t.pixelRatio[0],c=t.pixelRatio[1];return D.box(D.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,h>>8&255,h&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,D.box(D.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),D.box(D.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,d&255,c>>24,c>>16&255,c>>8&255,c&255])))}static esds(t){const e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))}static mp4a(t){const e=t.samplerate;return D.box(D.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]),D.box(D.types.esds,D.esds(t)))}static mp3(t){const e=t.samplerate;return D.box(D.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]))}static stsd(t){return t.type==="audio"?t.segmentCodec==="mp3"&&t.codec==="mp3"?D.box(D.types.stsd,D.STSD,D.mp3(t)):D.box(D.types.stsd,D.STSD,D.mp4a(t)):D.box(D.types.stsd,D.STSD,D.avc1(t))}static tkhd(t){const e=t.id,i=t.duration*t.timescale,r=t.width,n=t.height,a=Math.floor(i/(Ne+1)),o=Math.floor(i%(Ne+1));return D.box(D.types.tkhd,new Uint8Array([1,0,0,7,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,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(t,e){const i=D.sdtp(t),r=t.id,n=Math.floor(e/(Ne+1)),a=Math.floor(e%(Ne+1));return D.box(D.types.traf,D.box(D.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),D.box(D.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])),D.trun(t,i.length+16+20+8+16+8+8),i)}static trak(t){return t.duration=t.duration||4294967295,D.box(D.types.trak,D.tkhd(t),D.mdia(t))}static trex(t){const e=t.id;return D.box(D.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){const i=t.samples||[],r=i.length,n=12+16*r,a=new Uint8Array(n);let o,l,h,d,c,u;for(e+=8+n,a.set([t.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),o=0;o<r;o++)l=i[o],h=l.duration,d=l.size,c=l.flags,u=l.cts,a.set([h>>>24&255,h>>>16&255,h>>>8&255,h&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,c.degradPrio&61440,c.degradPrio&15,u>>>24&255,u>>>16&255,u>>>8&255,u&255],12+16*o);return D.box(D.types.trun,a)}static initSegment(t){D.types||D.init();const e=D.moov(t),i=new Uint8Array(D.FTYP.byteLength+e.byteLength);return i.set(D.FTYP),i.set(e,D.FTYP.byteLength),i}}D.types=void 0,D.HDLR_TYPES=void 0,D.STTS=void 0,D.STSC=void 0,D.STCO=void 0,D.STSZ=void 0,D.VMHD=void 0,D.SMHD=void 0,D.STSD=void 0,D.FTYP=void 0,D.DINF=void 0;const rd=9e4;function ua(s,t,e=1,i=!1){const r=s*t*e;return i?Math.round(r):r}function Gm(s,t,e=1,i=!1){return ua(s,t,1/e,i)}function Tr(s,t=!1){return ua(s,1e3,1/rd,t)}function Vm(s,t=1){return ua(s,rd,1/t)}const jm=10*1e3,sd=1024,zm=1152;let bs=null,fa=null;class pa{constructor(t,e,i,r=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=i,this.ISGenerated=!1,bs===null){const n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);bs=n?parseInt(n[1]):0}if(fa===null){const n=navigator.userAgent.match(/Safari\/(\d+)/i);fa=n?parseInt(n[1]):0}}destroy(){}resetTimeStamp(t){R.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){R.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){R.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const i=t.reduce((r,n)=>{const a=n.pts-r;return a<-4294967296?(e=!0,te(r,n.pts)):a>0?r:n.pts},t[0].pts);return e&&R.debug("PTS rollover detected"),i}remux(t,e,i,r,n,a,o,l){let h,d,c,u,f,p,g=n,m=n;const b=t.pid>-1,A=e.pid>-1,T=e.samples.length,y=t.samples.length>0,w=o&&T>0||T>1;if((!b||y)&&(!A||w)||this.ISGenerated||o){this.ISGenerated||(c=this.generateIS(t,e,n,a));const S=this.isVideoContiguous;let L=-1,C;if(w&&(L=Km(e.samples),!S&&this.config.forceKeyFrameOnDiscontinuity))if(p=!0,L>0){R.warn(`[mp4-remuxer]: Dropped ${L} out of ${T} video samples due to a missing keyframe`);const k=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(L),e.dropped+=L,m+=(e.samples[0].pts-k)/e.inputTimeScale,C=m}else L===-1&&(R.warn(`[mp4-remuxer]: No keyframe found out of ${T} video samples`),p=!1);if(this.ISGenerated){if(y&&w){const k=this.getVideoStartPts(e.samples),x=(te(t.samples[0].pts,k)-k)/e.inputTimeScale;g+=Math.max(0,x),m+=Math.max(0,-x)}if(y){if(t.samplerate||(R.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(t,e,n,a)),d=this.remuxAudio(t,g,this.isAudioContiguous,a,A||w||l===X.AUDIO?m:void 0),w){const k=d?d.endPTS-d.startPTS:0;e.inputTimeScale||(R.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(t,e,n,a)),h=this.remuxVideo(e,m,S,k)}}else w&&(h=this.remuxVideo(e,m,S,0));h&&(h.firstKeyFrame=L,h.independent=L!==-1,h.firstKeyFramePTS=C)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(f=nd(i,n,this._initPTS,this._initDTS)),r.samples.length&&(u=ad(r,n,this._initPTS))),{audio:d,video:h,initSegment:c,independent:p,text:u,id3:f}}generateIS(t,e,i,r){const n=t.samples,a=e.samples,o=this.typeSupported,l={},h=this._initPTS;let d=!h||r,c="audio/mp4",u,f,p;if(d&&(u=f=1/0),t.config&&n.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":o.mpeg?(c="audio/mpeg",t.codec=""):o.mp3&&(t.codec="mp3");break}l.audio={id:"audio",container:c,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):D.initSegment([t]),metadata:{channelCount:t.channelCount}},d&&(p=t.inputTimeScale,!h||p!==h.timescale?u=f=n[0].pts-Math.round(p*i):d=!1)}if(e.sps&&e.pps&&a.length&&(e.timescale=e.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:D.initSegment([e]),metadata:{width:e.width,height:e.height}},d))if(p=e.inputTimeScale,!h||p!==h.timescale){const g=this.getVideoStartPts(a),m=Math.round(p*i);f=Math.min(f,te(a[0].dts,g)-m),u=Math.min(u,g-m)}else d=!1;if(Object.keys(l).length)return this.ISGenerated=!0,d?(this._initPTS={baseTime:u,timescale:p},this._initDTS={baseTime:f,timescale:p}):u=p=void 0,{tracks:l,initPTS:u,timescale:p}}remuxVideo(t,e,i,r){const n=t.inputTimeScale,a=t.samples,o=[],l=a.length,h=this._initPTS;let d=this.nextAvcDts,c=8,u=this.videoSampleDuration,f,p,g=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,b=!1;if(!i||d===null){const U=e*n,H=a[0].pts-te(a[0].dts,a[0].pts);d=U-H}const A=h.baseTime*n/h.timescale;for(let U=0;U<l;U++){const H=a[U];H.pts=te(H.pts-A,d),H.dts=te(H.dts-A,d),H.dts<a[U>0?U-1:U].dts&&(b=!0)}b&&a.sort(function(U,H){const j=U.dts-H.dts,J=U.pts-H.pts;return j||J}),f=a[0].dts,p=a[a.length-1].dts;const T=p-f,y=T?Math.round(T/(l-1)):u||t.inputTimeScale/30;if(i){const U=f-d,H=U>y,j=U<-1;if((H||j)&&(H?R.warn(`AVC: ${Tr(U,!0)} ms (${U}dts) hole between fragments detected, filling it`):R.warn(`AVC: ${Tr(-U,!0)} ms (${U}dts) overlapping between fragments detected`),!j||d>=a[0].pts)){f=d;const J=a[0].pts-U;a[0].dts=f,a[0].pts=J,R.log(`Video: First PTS/DTS adjusted: ${Tr(J,!0)}/${Tr(f,!0)}, delta: ${Tr(U,!0)} ms`)}}f=Math.max(0,f);let w=0,S=0;for(let U=0;U<l;U++){const H=a[U],j=H.units,J=j.length;let $=0;for(let Q=0;Q<J;Q++)$+=j[Q].data.length;S+=$,w+=J,H.length=$,H.dts=Math.max(H.dts,f),g=Math.min(H.pts,g),m=Math.max(H.pts,m)}p=a[l-1].dts;const L=S+4*w+8;let C;try{C=new Uint8Array(L)}catch(U){this.observer.emit(v.ERROR,v.ERROR,{type:Y.MUX_ERROR,details:P.REMUX_ALLOC_ERROR,fatal:!1,error:U,bytes:L,reason:`fail allocating video mdat ${L}`});return}const k=new DataView(C.buffer);k.setUint32(0,L),C.set(D.types.mdat,4);let x=!1,N=Number.POSITIVE_INFINITY,O=Number.POSITIVE_INFINITY,V=Number.NEGATIVE_INFINITY,W=Number.NEGATIVE_INFINITY;for(let U=0;U<l;U++){const H=a[U],j=H.units;let J=0;for(let st=0,tt=j.length;st<tt;st++){const Pt=j[st],Lt=Pt.data,yt=Pt.data.byteLength;k.setUint32(c,yt),c+=4,C.set(Lt,c),c+=yt,J+=4+yt}let $;if(U<l-1)u=a[U+1].dts-H.dts,$=a[U+1].pts-H.pts;else{const st=this.config,tt=U>0?H.dts-a[U-1].dts:y;if($=U>0?H.pts-a[U-1].pts:y,st.stretchShortVideoTrack&&this.nextAudioPts!==null){const Pt=Math.floor(st.maxBufferHole*n),Lt=(r?g+r*n:this.nextAudioPts)-H.pts;Lt>Pt?(u=Lt-tt,u<0?u=tt:x=!0,R.log(`[mp4-remuxer]: It is approximately ${Lt/90} ms to the next segment; using duration ${u/90} ms for the last video frame.`)):u=tt}else u=tt}const Q=Math.round(H.pts-H.dts);N=Math.min(N,u),V=Math.max(V,u),O=Math.min(O,$),W=Math.max(W,$),o.push(new od(H.key,u,J,Q))}if(o.length){if(bs){if(bs<70){const U=o[0].flags;U.dependsOn=2,U.isNonSync=0}}else if(fa&&W-O<V-N&&y/V<.025&&o[0].cts===0){R.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let U=f;for(let H=0,j=o.length;H<j;H++){const J=U+o[H].duration,$=U+o[H].cts;if(H<j-1){const Q=J+o[H+1].cts;o[H].duration=Q-$}else o[H].duration=H?o[H-1].duration:y;o[H].cts=0,U=J}}}u=x||!u?y:u,this.nextAvcDts=d=p+u,this.videoSampleDuration=u,this.isVideoContiguous=!0;const E=D.moof(t.sequenceNumber++,f,Et({},t,{samples:o})),I="video",B={data1:E,data2:C,startPTS:g/n,endPTS:(m+u)/n,startDTS:f/n,endDTS:d/n,type:I,hasAudio:!1,hasVideo:!0,nb:o.length,dropped:t.dropped};return t.samples=[],t.dropped=0,B}remuxAudio(t,e,i,r,n){const a=t.inputTimeScale,o=t.samplerate?t.samplerate:a,l=a/o,h=t.segmentCodec==="aac"?sd:zm,d=h*l,c=this._initPTS,u=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],p=n!==void 0;let g=t.samples,m=u?0:8,b=this.nextAudioPts||-1;const A=e*a,T=c.baseTime*a/c.timescale;if(this.isAudioContiguous=i=i||g.length&&b>0&&(r&&Math.abs(A-b)<9e3||Math.abs(te(g[0].pts-T,A)-b)<20*d),g.forEach(function(E){E.pts=te(E.pts-T,A)}),!i||b<0){if(g=g.filter(E=>E.pts>=0),!g.length)return;n===0?b=0:r&&!p?b=Math.max(0,A):b=g[0].pts}if(t.segmentCodec==="aac"){const E=this.config.maxAudioFramesDrift;for(let I=0,B=b;I<g.length;I++){const U=g[I],H=U.pts,j=H-B,J=Math.abs(1e3*j/a);if(j<=-E*d&&p)I===0&&(R.warn(`Audio frame @ ${(H/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*j/a)} ms.`),this.nextAudioPts=b=B=H);else if(j>=E*d&&J<jm&&p){let $=Math.round(j/d);B=H-$*d,B<0&&($--,B+=d),I===0&&(this.nextAudioPts=b=B),R.warn(`[mp4-remuxer]: Injecting ${$} audio frame @ ${(B/a).toFixed(3)}s due to ${Math.round(1e3*j/a)} ms gap.`);for(let Q=0;Q<$;Q++){const st=Math.max(B,0);let tt=id.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);tt||(R.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),tt=U.unit.subarray()),g.splice(I,0,{unit:tt,pts:st}),B+=d,I++}}U.pts=B,B+=d}}let y=null,w=null,S,L=0,C=g.length;for(;C--;)L+=g[C].unit.byteLength;for(let E=0,I=g.length;E<I;E++){const B=g[E],U=B.unit;let H=B.pts;if(w!==null){const J=f[E-1];J.duration=Math.round((H-w)/l)}else if(i&&t.segmentCodec==="aac"&&(H=b),y=H,L>0){L+=m;try{S=new Uint8Array(L)}catch(J){this.observer.emit(v.ERROR,v.ERROR,{type:Y.MUX_ERROR,details:P.REMUX_ALLOC_ERROR,fatal:!1,error:J,bytes:L,reason:`fail allocating audio mdat ${L}`});return}u||(new DataView(S.buffer).setUint32(0,L),S.set(D.types.mdat,4))}else return;S.set(U,m);const j=U.byteLength;m+=j,f.push(new od(!0,h,j,0)),w=H}const k=f.length;if(!k)return;const x=f[f.length-1];this.nextAudioPts=b=w+l*x.duration;const N=u?new Uint8Array(0):D.moof(t.sequenceNumber++,y/l,Et({},t,{samples:f}));t.samples=[];const O=y/a,V=b/a,W={data1:N,data2:S,startPTS:O,endPTS:V,startDTS:O,endDTS:V,type:"audio",hasAudio:!0,hasVideo:!1,nb:k};return this.isAudioContiguous=!0,W}remuxEmptyAudio(t,e,i,r){const n=t.inputTimeScale,a=t.samplerate?t.samplerate:n,o=n/a,l=this.nextAudioPts,h=this._initDTS,d=h.baseTime*9e4/h.timescale,c=(l!==null?l:r.startDTS*n)+d,u=r.endDTS*n+d,f=o*sd,p=Math.ceil((u-c)/f),g=id.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(R.warn("[mp4-remuxer]: remux empty Audio"),!g){R.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const m=[];for(let b=0;b<p;b++){const A=c+b*f;m.push({unit:g,pts:A,dts:A})}return t.samples=m,this.remuxAudio(t,e,i,!1)}}function te(s,t){let e;if(t===null)return s;for(t<s?e=-8589934592:e=8589934592;Math.abs(s-t)>4294967296;)s+=e;return s}function Km(s){for(let t=0;t<s.length;t++)if(s[t].key)return t;return-1}function nd(s,t,e,i){const r=s.samples.length;if(!r)return;const n=s.inputTimeScale;for(let o=0;o<r;o++){const l=s.samples[o];l.pts=te(l.pts-e.baseTime*n/e.timescale,t*n)/n,l.dts=te(l.dts-i.baseTime*n/i.timescale,t*n)/n}const a=s.samples;return s.samples=[],{samples:a}}function ad(s,t,e){const i=s.samples.length;if(!i)return;const r=s.inputTimeScale;for(let a=0;a<i;a++){const o=s.samples[a];o.pts=te(o.pts-e.baseTime*r/e.timescale,t*r)/r}s.samples.sort((a,o)=>a.pts-o.pts);const n=s.samples;return s.samples=[],{samples:n}}class od{constructor(t,e,i,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=i,this.cts=r,this.flags=new Wm(t)}}class Wm{constructor(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}}class Ym{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,i,r){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(ug(t,r)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:i}=this;if(!(t!=null&&t.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const r=this.initData=hh(t);e||(e=ld(r.audio,at.AUDIO)),i||(i=ld(r.video,at.VIDEO));const n={};r.audio&&r.video?n.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:r.audio?n.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:r.video?n.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:R.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(t,e,i,r,n,a){var o,l;let{initPTS:h,lastEndTime:d}=this;const c={audio:void 0,video:void 0,text:r,id3:i,initSegment:void 0};K(d)||(d=this.lastEndTime=n||0);const u=e.samples;if(!(u!=null&&u.length))return c;const f={initPTS:void 0,timescale:1};let p=this.initData;if((o=p)!=null&&o.length||(this.generateInitSegment(u),p=this.initData),!((l=p)!=null&&l.length))return R.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const g=pg(u,p),m=fg(p,u),b=m===null?n:m;(Xm(h,b,n,g)||f.timescale!==h.timescale&&a)&&(f.initPTS=b-n,h&&h.timescale===1&&R.warn(`Adjusting initPTS by ${f.initPTS-h.baseTime}`),this.initPTS=h={baseTime:f.initPTS,timescale:1});const A=t?b-h.baseTime/h.timescale:d,T=A+g;mg(p,u,h.baseTime/h.timescale),g>0?this.lastEndTime=T:(R.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const y=!!p.audio,w=!!p.video;let S="";y&&(S+="audio"),w&&(S+="video");const L={data1:u,startPTS:A,startDTS:A,endPTS:T,endDTS:T,type:S,hasAudio:y,hasVideo:w,nb:1,dropped:0};return c.audio=L.type==="audio"?L:void 0,c.video=L.type!=="audio"?L:void 0,c.initSegment=f,c.id3=nd(i,n,h,h),r.samples.length&&(c.text=ad(r,n,h)),c}}function Xm(s,t,e,i){if(s===null)return!0;const r=Math.max(i,1),n=t-s.baseTime/s.timescale;return Math.abs(n-e)>r}function ld(s,t){const e=s==null?void 0:s.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||t===at.VIDEO?"avc1.42e01e":"mp4a.40.5"}let xe;try{xe=self.performance.now.bind(self.performance)}catch{R.debug("Unable to use Performance API on this environment"),xe=typeof self<"u"&&self.Date.now}const ga=[{demux:Dm,remux:Ym},{demux:Fe,remux:pa},{demux:xm,remux:pa},{demux:Hm,remux:pa}];class hd{constructor(t,e,i,r,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=i,this.vendor=r,this.id=n}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,i,r){const n=i.transmuxing;n.executeStart=xe();let a=new Uint8Array(t);const{currentTransmuxState:o,transmuxConfig:l}=this;r&&(this.currentTransmuxState=r);const{contiguous:h,discontinuity:d,trackSwitch:c,accurateTimeOffset:u,timeOffset:f,initSegmentChange:p}=r||o,{audioCodec:g,videoCodec:m,defaultInitPts:b,duration:A,initSegmentData:T}=l,y=qm(a,e);if(y&&y.method==="AES-128"){const C=this.getDecrypter();if(C.isSync()){let k=C.softwareDecrypt(a,y.key.buffer,y.iv.buffer);if(i.part>-1&&(k=C.flush()),!k)return n.executeEnd=xe(),ma(i);a=new Uint8Array(k)}else return this.decryptionPromise=C.webCryptoDecrypt(a,y.key.buffer,y.iv.buffer).then(k=>{const x=this.push(k,null,i);return this.decryptionPromise=null,x}),this.decryptionPromise}const w=this.needsProbing(d,c);if(w){const C=this.configureTransmuxer(a);if(C)return R.warn(`[transmuxer] ${C.message}`),this.observer.emit(v.ERROR,v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,fatal:!1,error:C,reason:C.message}),n.executeEnd=xe(),ma(i)}(d||c||p||w)&&this.resetInitSegment(T,g,m,A,e),(d||p||w)&&this.resetInitialTimestamp(b),h||this.resetContiguity();const S=this.transmux(a,y,f,u,i),L=this.currentTransmuxState;return L.contiguous=!0,L.discontinuity=!1,L.trackSwitch=!1,n.executeEnd=xe(),S}flush(t){const e=t.transmuxing;e.executeStart=xe();const{decrypter:i,currentTransmuxState:r,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(t));const a=[],{timeOffset:o}=r;if(i){const c=i.flush();c&&a.push(this.push(c,null,t))}const{demuxer:l,remuxer:h}=this;if(!l||!h)return e.executeEnd=xe(),[ma(t)];const d=l.flush(o);return As(d)?d.then(c=>(this.flushRemux(a,c,t),a)):(this.flushRemux(a,d,t),a)}flushRemux(t,e,i){const{audioTrack:r,videoTrack:n,id3Track:a,textTrack:o}=e,{accurateTimeOffset:l,timeOffset:h}=this.currentTransmuxState;R.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const d=this.remuxer.remux(r,n,a,o,h,l,!0,this.id);t.push({remuxResult:d,chunkMeta:i}),i.transmuxing.executeEnd=xe()}resetInitialTimestamp(t){const{demuxer:e,remuxer:i}=this;!e||!i||(e.resetTimeStamp(t),i.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;!t||!e||(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,i,r,n){const{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(t,e,i,r),o.resetInitSegment(t,e,i,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,i,r,n){let a;return e&&e.method==="SAMPLE-AES"?a=this.transmuxSampleAes(t,e,i,r,n):a=this.transmuxUnencrypted(t,i,r,n),a}transmuxUnencrypted(t,e,i,r){const{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,e,i,!1,this.id),chunkMeta:r}}transmuxSampleAes(t,e,i,r,n){return this.demuxer.demuxSampleAes(t,e,i).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,i,r,!1,this.id),chunkMeta:n}))}configureTransmuxer(t){const{config:e,observer:i,typeSupported:r,vendor:n}=this;let a;for(let c=0,u=ga.length;c<u;c++)if(ga[c].demux.probe(t)){a=ga[c];break}if(!a)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,l=this.remuxer,h=a.remux,d=a.demux;(!l||!(l instanceof h))&&(this.remuxer=new h(i,e,r,n)),(!o||!(o instanceof d))&&(this.demuxer=new d(i,e,r),this.probe=d.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new oa(this.config)),t}}function qm(s,t){let e=null;return s.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(e=t),e}const ma=s=>({remuxResult:{},chunkMeta:s});function As(s){return"then"in s&&s.then instanceof Function}class Zm{constructor(t,e,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=t,this.videoCodec=e,this.initSegmentData=i,this.duration=r,this.defaultInitPts=n||null}}class Jm{constructor(t,e,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=t,this.contiguous=e,this.accurateTimeOffset=i,this.trackSwitch=r,this.timeOffset=n,this.initSegmentChange=a}}var dd={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function r(l,h,d){this.fn=l,this.context=h,this.once=d||!1}function n(l,h,d,c,u){if(typeof d!="function")throw new TypeError("The listener must be a function");var f=new r(d,c||l,u),p=e?e+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,l._eventsCount++),l}function a(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],h,d;if(this._eventsCount===0)return l;for(d in h=this._events)t.call(h,d)&&l.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(h)):l},o.prototype.listeners=function(l){var h=e?e+l:l,d=this._events[h];if(!d)return[];if(d.fn)return[d.fn];for(var c=0,u=d.length,f=new Array(u);c<u;c++)f[c]=d[c].fn;return f},o.prototype.listenerCount=function(l){var h=e?e+l:l,d=this._events[h];return d?d.fn?1:d.length:0},o.prototype.emit=function(l,h,d,c,u,f){var p=e?e+l:l;if(!this._events[p])return!1;var g=this._events[p],m=arguments.length,b,A;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),m){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,h),!0;case 3:return g.fn.call(g.context,h,d),!0;case 4:return g.fn.call(g.context,h,d,c),!0;case 5:return g.fn.call(g.context,h,d,c,u),!0;case 6:return g.fn.call(g.context,h,d,c,u,f),!0}for(A=1,b=new Array(m-1);A<m;A++)b[A-1]=arguments[A];g.fn.apply(g.context,b)}else{var T=g.length,y;for(A=0;A<T;A++)switch(g[A].once&&this.removeListener(l,g[A].fn,void 0,!0),m){case 1:g[A].fn.call(g[A].context);break;case 2:g[A].fn.call(g[A].context,h);break;case 3:g[A].fn.call(g[A].context,h,d);break;case 4:g[A].fn.call(g[A].context,h,d,c);break;default:if(!b)for(y=1,b=new Array(m-1);y<m;y++)b[y-1]=arguments[y];g[A].fn.apply(g[A].context,b)}}return!0},o.prototype.on=function(l,h,d){return n(this,l,h,d,!1)},o.prototype.once=function(l,h,d){return n(this,l,h,d,!0)},o.prototype.removeListener=function(l,h,d,c){var u=e?e+l:l;if(!this._events[u])return this;if(!h)return a(this,u),this;var f=this._events[u];if(f.fn)f.fn===h&&(!c||f.once)&&(!d||f.context===d)&&a(this,u);else{for(var p=0,g=[],m=f.length;p<m;p++)(f[p].fn!==h||c&&!f[p].once||d&&f[p].context!==d)&&g.push(f[p]);g.length?this._events[u]=g.length===1?g[0]:g:a(this,u)}return this},o.prototype.removeAllListeners=function(l){var h;return l?(h=e?e+l:l,this._events[h]&&a(this,h)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,s.exports=o})(dd);var Qm=dd.exports,va=Np(Qm);const ya=hs()||{isTypeSupported:()=>!1};class cd{constructor(t,e,i,r){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const n=t.config;this.hls=t,this.id=e,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=i,this.onFlush=r;const a=(h,d)=>{d=d||{},d.frag=this.frag,d.id=this.id,h===v.ERROR&&(this.error=d.error),this.hls.trigger(h,d)};this.observer=new va,this.observer.on(v.FRAG_DECRYPTED,a),this.observer.on(v.ERROR,a);const o={mp4:ya.isTypeSupported("video/mp4"),mpeg:ya.isTypeSupported("audio/mpeg"),mp3:ya.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(n.workerPath||ym())){try{n.workerPath?(R.log(`loading Web Worker ${n.workerPath} for "${e}"`),this.workerContext=Am(n.workerPath)):(R.log(`injecting Web Worker for "${e}"`),this.workerContext=bm()),this.onwmsg=d=>this.onWorkerMessage(d);const{worker:h}=this.workerContext;h.addEventListener("message",this.onwmsg),h.onerror=d=>{const c=new Error(`${d.message} (${d.filename}:${d.lineno})`);n.enableWorker=!1,R.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(v.ERROR,{type:Y.OTHER_ERROR,details:P.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:c})},h.postMessage({cmd:"init",typeSupported:o,vendor:l,id:e,config:JSON.stringify(n)})}catch(h){R.warn(`Error setting up "${e}" Web Worker, fallback to inline`,h),this.resetWorker(),this.error=null,this.transmuxer=new hd(this.observer,o,n,l,e)}return}this.transmuxer=new hd(this.observer,o,n,l,e)}resetWorker(){if(this.workerContext){const{worker:t,objectURL:e}=this.workerContext;e&&self.URL.revokeObjectURL(e),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,i,r,n,a,o,l,h,d){var c,u;h.transmuxing.start=self.performance.now();const{transmuxer:f}=this,p=a?a.start:n.start,g=n.decryptdata,m=this.frag,b=!(m&&n.cc===m.cc),A=!(m&&h.level===m.level),T=m?h.sn-m.sn:-1,y=this.part?h.part-this.part.index:-1,w=T===0&&h.id>1&&h.id===(m==null?void 0:m.stats.chunkCount),S=!A&&(T===1||T===0&&(y===1||w&&y<=0)),L=self.performance.now();(A||T||n.stats.parsing.start===0)&&(n.stats.parsing.start=L),a&&(y||!S)&&(a.stats.parsing.start=L);const C=!(m&&((c=n.initSegment)==null?void 0:c.url)===((u=m.initSegment)==null?void 0:u.url)),k=new Jm(b,S,l,A,p,C);if(!S||b||C){R.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${h.sn} p: ${h.part} level: ${h.level} id: ${h.id}
|
119
|
-
discontinuity: ${b}
|
120
|
-
trackSwitch: ${A}
|
121
|
-
contiguous: ${S}
|
122
|
-
accurateTimeOffset: ${l}
|
123
|
-
timeOffset: ${p}
|
124
|
-
initSegmentChange: ${C}`);const x=new Zm(i,r,e,o,d);this.configureTransmuxer(x)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:g,chunkMeta:h,state:k},t instanceof ArrayBuffer?[t]:[]);else if(f){const x=f.push(t,g,h,k);As(x)?(f.async=!0,x.then(N=>{this.handleTransmuxComplete(N)}).catch(N=>{this.transmuxerError(N,h,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(x))}}flush(t){t.transmuxing.start=self.performance.now();const{transmuxer:e}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(e){let i=e.flush(t);As(i)||e.async?(As(i)||(i=Promise.resolve(i)),i.then(r=>{this.handleFlushResult(r,t)}).catch(r=>{this.transmuxerError(r,t,"transmuxer-interface flush error")})):this.handleFlushResult(i,t)}}transmuxerError(t,e,i){this.hls&&(this.error=t,this.hls.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:i}))}handleFlushResult(t,e){t.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(e)}onWorkerMessage(t){const e=t.data,i=this.hls;switch(e.event){case"init":{var r;const n=(r=this.workerContext)==null?void 0:r.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(e.data);break}case"flush":{this.onFlush(e.data);break}case"workerLog":R[e.data.logType]&&R[e.data.logType](e.data.message);break;default:{e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,i.trigger(e.event,e.data);break}}}configureTransmuxer(t){const{transmuxer:e}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)}handleTransmuxComplete(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)}}const _m=250,ba=2,$m=.1,tv=.05;class ev{constructor(t,e,i,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=i,this.hls=r}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:i,media:r,stalled:n}=this;if(r===null)return;const{currentTime:a,seeking:o}=r,l=this.seeking&&!o,h=!this.seeking&&o;if(this.seeking=o,a!==t){if(this.moved=!0,n!==null){if(this.stallReported){const b=self.performance.now()-n;R.warn(`playback not stuck anymore @${a}, after ${Math.round(b)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(h||l){this.stalled=null;return}if(r.paused&&!o||r.ended||r.playbackRate===0||!lt.getBuffered(r).length)return;const d=lt.bufferInfo(r,a,0),c=d.len>0,u=d.nextStart||0;if(!c&&!u)return;if(o){const b=d.len>ba,A=!u||e&&e.start<=a||u-a>ba&&!this.fragmentTracker.getPartialFragment(a);if(b||A)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var f;const b=Math.max(u,d.start||0)-a,A=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,T=!(A==null||(f=A.details)==null)&&f.live?A.details.targetduration*2:ba,y=this.fragmentTracker.getPartialFragment(a);if(b>0&&(b<=T||y)){this._trySkipBufferHole(y);return}}const p=self.performance.now();if(n===null){this.stalled=p;return}const g=p-n;if(!o&&g>=_m&&(this._reportStall(d),!this.media))return;const m=lt.bufferInfo(r,a,i.maxBufferHole);this._tryFixBufferStall(m,g)}_tryFixBufferStall(t,e){const{config:i,fragmentTracker:r,media:n}=this;if(n===null)return;const a=n.currentTime,o=r.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(t.len>i.maxBufferHole||t.nextStart&&t.nextStart-a<i.maxBufferHole)&&e>i.highBufferWatchdogPeriod*1e3&&(R.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:i,stallReported:r}=this;if(!r&&i){this.stallReported=!0;const n=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(t)})`);R.warn(n.message),e.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:i,media:r}=this;if(r===null)return 0;const n=r.currentTime,a=lt.bufferInfo(r,n,0),o=n<a.start?a.start:a.nextStart;if(o){const l=a.len<=e.maxBufferHole,h=a.len>0&&a.len<1&&r.readyState<3,d=o-n;if(d>0&&(l||h)){if(d>e.maxBufferHole){const{fragmentTracker:u}=this;let f=!1;if(n===0){const p=u.getAppendedFrag(0,X.MAIN);p&&o<p.end&&(f=!0)}if(!f){const p=t||u.getAppendedFrag(n,X.MAIN);if(p){let g=!1,m=p.end;for(;m<o;){const b=u.getPartialFragment(m);if(b)m+=b.duration;else{g=!0;break}}if(g)return 0}}}const c=Math.max(o+tv,n+$m);if(R.warn(`skipping hole, adjusting currentTime from ${n} to ${c}`),this.moved=!0,this.stalled=null,r.currentTime=c,t&&!t.gap){const u=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${c}`);i.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:u,reason:u.message,frag:t})}return c}}return 0}_tryNudgeBuffer(){const{config:t,hls:e,media:i,nudgeRetry:r}=this;if(i===null)return;const n=i.currentTime;if(this.nudgeRetry++,r<t.nudgeMaxRetry){const a=n+(r+1)*t.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);R.warn(o.message),i.currentTime=a,e.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const a=new Error(`Playhead still not moving while enough data buffered @${n} after ${t.nudgeMaxRetry} nudges`);R.error(a.message),e.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}}const iv=100;class rv extends la{constructor(t,e,i){super(t,e,i,"[stream-controller]",X.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.MANIFEST_PARSED,this.onManifestParsed,this),t.on(v.LEVEL_LOADING,this.onLevelLoading,this),t.on(v.LEVEL_LOADED,this.onLevelLoaded,this),t.on(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(v.ERROR,this.onError,this),t.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(v.BUFFER_CREATED,this.onBufferCreated,this),t.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.MANIFEST_PARSED,this.onManifestParsed,this),t.off(v.LEVEL_LOADED,this.onLevelLoaded,this),t.off(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(v.ERROR,this.onError,this),t.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(v.BUFFER_CREATED,this.onBufferCreated,this),t.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(t){if(this.levels){const{lastCurrentTime:e,hls:i}=this;if(this.stopLoad(),this.setInterval(iv),this.level=-1,!this.startFragRequested){let r=i.startLevel;r===-1&&(i.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=i.nextAutoLevel),this.level=i.nextLoadLevel=r,this.loadedmetadata=!1}e>0&&t===-1&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=F.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=F.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case F.WAITING_LEVEL:{var t;const{levels:i,level:r}=this,n=i==null||(t=i[r])==null?void 0:t.details;if(n&&(!n.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(n))break;this.state=F.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=F.IDLE;break}break}case F.FRAG_LOADING_WAITING_RETRY:{var e;const i=self.performance.now(),r=this.retryDate;(!r||i>=r||(e=this.media)!=null&&e.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=F.IDLE)}break}this.state===F.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:i,media:r}=this,{config:n,nextLoadLevel:a}=t;if(e===null||!r&&(this.startFragRequested||!n.startFragPrefetch)||this.altAudio&&this.audioOnly||!(i!=null&&i[a]))return;const o=i[a],l=this.getMainFwdBufferInfo();if(l===null)return;const h=this.getLevelDetails();if(h&&this._streamEnded(l,h)){const m={};this.altAudio&&(m.type="video"),this.hls.trigger(v.BUFFER_EOS,m),this.state=F.ENDED;return}t.loadLevel!==a&&t.manualLevel===-1&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=t.nextLoadLevel=a;const d=o.details;if(!d||this.state===F.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a){this.level=a,this.state=F.WAITING_LEVEL;return}const c=l.len,u=this.getMaxBufferLength(o.maxBitrate);if(c>=u)return;this.backtrackFragment&&this.backtrackFragment.start>l.end&&(this.backtrackFragment=null);const f=this.backtrackFragment?this.backtrackFragment.start:l.end;let p=this.getNextFragment(f,d);if(this.couldBacktrack&&!this.fragPrevious&&p&&p.sn!=="initSegment"&&this.fragmentTracker.getState(p)!==Rt.OK){var g;const m=((g=this.backtrackFragment)!=null?g:p).sn-d.startSN,b=d.fragments[m-1];b&&p.cc===b.cc&&(p=b,this.fragmentTracker.removeFragment(b))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,f)){if(!p.gap){const m=this.audioOnly&&!this.altAudio?at.AUDIO:at.VIDEO,b=(m===at.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;b&&this.afterBufferFlushed(b,m,X.MAIN)}p=this.getNextFragmentLoopLoading(p,d,l,X.MAIN,u)}p&&(p.initSegment&&!p.initSegment.data&&!this.bitrateTest&&(p=p.initSegment),this.loadFragment(p,o,f))}loadFragment(t,e,i){const r=this.fragmentTracker.getState(t);this.fragCurrent=t,r===Rt.NOT_LOADED||r===Rt.PARTIAL?t.sn==="initSegment"?this._loadInitSegment(t,e):this.bitrateTest?(this.log(`Fragment ${t.sn} of level ${t.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(t,e)):(this.startFragRequested=!0,super.loadFragment(t,e,i)):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,X.MAIN)}followingBufferedFrag(t){return t?this.getBufferedFrag(t.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:t,media:e}=this;if(e!=null&&e.readyState){let i;const r=this.getAppendedFrag(e.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);const n=this.getLevelDetails();if(n!=null&&n.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!e.paused&&t){const o=this.hls.nextLoadLevel,l=t[o],h=this.fragLastKbps;h&&this.fragCurrent?i=this.fragCurrent.duration*l.maxBitrate/(1e3*h)+1:i=0}else i=0;const a=this.getBufferedFrag(e.currentTime+i);if(a){const o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();const l=o.maxStartPTS?o.maxStartPTS:o.start,h=o.duration,d=Math.max(a.end,l+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*.5),h*.75));this.flushMainBuffer(d,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case F.KEY_LOADING:case F.FRAG_LOADING:case F.FRAG_LOADING_WAITING_RETRY:case F.PARSING:case F.PARSED:this.state=F.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,e){super.flushMainBuffer(t,e,this.altAudio?"video":null)}onMediaAttached(t,e){super.onMediaAttached(t,e);const i=e.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new ev(this.config,i,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:t}=this;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const t=this.media,e=t?t.currentTime:null;K(e)&&this.log(`Media seeked to ${e.toFixed(3)}`);const i=this.getMainFwdBufferInfo();if(i===null||i.len===0){this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(v.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(t,e){let i=!1,r=!1,n;e.levels.forEach(a=>{n=a.audioCodec,n&&(n.indexOf("mp4a.40.2")!==-1&&(i=!0),n.indexOf("mp4a.40.5")!==-1&&(r=!0))}),this.audioCodecSwitch=i&&r&&!vm(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1}onLevelLoading(t,e){const{levels:i}=this;if(!i||this.state!==F.IDLE)return;const r=i[e.level];(!r.details||r.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(r.details))&&(this.state=F.WAITING_LEVEL)}onLevelLoaded(t,e){var i;const{levels:r}=this,n=e.level,a=e.details,o=a.totalduration;if(!r){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=r[n],h=this.fragCurrent;h&&(this.state===F.FRAG_LOADING||this.state===F.FRAG_LOADING_WAITING_RETRY)&&(h.level!==e.level||h.urlId!==l.urlId)&&h.loader&&this.abortCurrentFrag();let d=0;if(a.live||(i=l.details)!=null&&i.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;d=this.alignPlaylists(a,l.details)}if(l.details=a,this.levelLastLoaded=n,this.hls.trigger(v.LEVEL_UPDATED,{details:a,level:n}),this.state===F.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=F.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,d),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:r,payload:n}=t,{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}const o=a[i.level],l=o.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const h=o.videoCodec,d=l.PTSKnown||!l.live,c=(e=i.initSegment)==null?void 0:e.data,u=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new cd(this.hls,X.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),p=r?r.index:-1,g=p!==-1,m=new na(i.level,i.sn,i.stats.chunkCount,n.byteLength,p,g),b=this.initPTS[i.cc];f.push(n,c,u,h,i,r,l.totalduration,d,m,b)}onAudioTrackSwitching(t,e){const i=this.altAudio;if(!e.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const n=this.fragCurrent;n&&(this.log("Switching to main audio track, cancel main fragment load"),n.abortRequests(),this.fragmentTracker.removeFragment(n)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const r=this.hls;i&&(r.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),r.trigger(v.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const i=e.id,r=!!this.hls.audioTracks[i].url;if(r){const n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=r,this.tick()}onBufferCreated(t,e){const i=e.tracks;let r,n,a=!1;for(const o in i){const l=i[o];if(l.id==="main"){if(n=o,r=l,o==="video"){const h=i[o];h&&(this.videoBuffer=h.buffer)}}else a=!0}a&&r?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:i,part:r}=e;if(i&&i.type!==X.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===F.PARSED&&(this.state=F.IDLE);return}const n=r?r.stats:i.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,r)}onError(t,e){var i;if(e.fatal){this.state=F.ERROR;return}switch(e.details){case P.FRAG_GAP:case P.FRAG_PARSING_ERROR:case P.FRAG_DECRYPT_ERROR:case P.FRAG_LOAD_ERROR:case P.FRAG_LOAD_TIMEOUT:case P.KEY_LOAD_ERROR:case P.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(X.MAIN,e);break;case P.LEVEL_LOAD_ERROR:case P.LEVEL_LOAD_TIMEOUT:case P.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===F.WAITING_LEVEL&&((i=e.context)==null?void 0:i.type)===rt.LEVEL&&(this.state=F.IDLE);break;case P.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="main")return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case P.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}checkBuffer(){const{media:t,gapController:e}=this;if(!(!t||!e||!t.readyState)){if(this.loadedmetadata||!lt.getBuffered(t).length){const i=this.state!==F.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=F.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==at.AUDIO||this.audioOnly&&!this.altAudio){const i=(e===at.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,e,X.MAIN)}}onLevelsUpdated(t,e){this.levels=e.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:t}=this;if(!t)return;const e=t.currentTime;let i=this.startPosition;if(i>=0&&e<i){if(t.seeking){this.log(`could not seek to ${i}, already seeking at ${e}`);return}const r=lt.getBuffered(t),n=(r.length?r.start(0):0)-i;n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${n} to match buffer start`),i+=n,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${e}`),t.currentTime=i}}_getAudioCodec(t){let e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e.indexOf("mp4a.40.5")!==-1?e="mp4a.40.2":e="mp4a.40.5"),e}_loadBitrateTestFrag(t,e){t.bitrateTest=!0,this._doFragLoad(t,e).then(i=>{const{hls:r}=this;if(!i||this.fragContextChanged(t))return;e.fragmentError=0,this.state=F.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const n=t.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),r.trigger(v.FRAG_LOADED,i),t.bitrateTest=!1})}_handleTransmuxComplete(t){var e;const i="main",{hls:r}=this,{remuxResult:n,chunkMeta:a}=t,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:h,level:d}=o,{video:c,text:u,id3:f,initSegment:p}=n,{details:g}=d,m=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=F.PARSING,p){if(p!=null&&p.tracks){const T=l.initSegment||l;this._bufferInitSegment(d,p.tracks,T,a),r.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:i,tracks:p.tracks})}const b=p.initPTS,A=p.timescale;K(b)&&(this.initPTS[l.cc]={baseTime:b,timescale:A},r.trigger(v.INIT_PTS_FOUND,{frag:l,id:i,initPTS:b,timescale:A}))}if(c&&g&&l.sn!=="initSegment"){const b=g.fragments[l.sn-1-g.startSN],A=l.sn===g.startSN,T=!b||l.cc>b.cc;if(n.independent!==!1){const{startPTS:y,endPTS:w,startDTS:S,endDTS:L}=c;if(h)h.elementaryStreams[c.type]={startPTS:y,endPTS:w,startDTS:S,endDTS:L};else if(c.firstKeyFrame&&c.independent&&a.id===1&&!T&&(this.couldBacktrack=!0),c.dropped&&c.independent){const C=this.getMainFwdBufferInfo(),k=(C?C.end:this.getLoadPosition())+this.config.maxBufferHole,x=c.firstKeyFramePTS?c.firstKeyFramePTS:y;if(!A&&k<x-this.config.maxBufferHole&&!T){this.backtrack(l);return}else T&&(l.gap=!0);l.setElementaryStreamInfo(c.type,l.start,w,l.start,L,!0)}l.setElementaryStreamInfo(c.type,y,w,S,L),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(c,l,h,a,A||T)}else if(A||T)l.gap=!0;else{this.backtrack(l);return}}if(m){const{startPTS:b,endPTS:A,startDTS:T,endDTS:y}=m;h&&(h.elementaryStreams[at.AUDIO]={startPTS:b,endPTS:A,startDTS:T,endDTS:y}),l.setElementaryStreamInfo(at.AUDIO,b,A,T,y),this.bufferFragmentData(m,l,h,a)}if(g&&f!=null&&(e=f.samples)!=null&&e.length){const b={id:i,frag:l,details:g,samples:f.samples};r.trigger(v.FRAG_PARSING_METADATA,b)}if(g&&u){const b={id:i,frag:l,details:g,samples:u.samples};r.trigger(v.FRAG_PARSING_USERDATA,b)}}_bufferInitSegment(t,e,i,r){if(this.state!==F.PARSING)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;const{audio:n,video:a,audiovideo:o}=e;if(n){let l=t.audioCodec;const h=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),n.metadata.channelCount!==1&&h.indexOf("firefox")===-1&&(l="mp4a.40.5")),h.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),t.audioCodec&&t.audioCodec!==l&&this.log(`Swapping manifest audio codec "${t.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${t.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=t.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${t.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${t.attrs.CODECS||""}/${o.codec}]`),this.hls.trigger(v.BUFFER_CODECS,e),Object.keys(e).forEach(l=>{const h=e[l].initSegment;h!=null&&h.byteLength&&this.hls.trigger(v.BUFFER_APPENDING,{type:l,data:h,frag:i,part:null,chunkMeta:r,parent:i.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,X.MAIN)}backtrack(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=F.IDLE}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&t.seeking===!1){const i=t.currentTime;if(lt.isBuffered(t,i)?e=this.getAppendedFrag(i):lt.isBuffered(t,i+.1)&&(e=this.getAppendedFrag(i+.1)),e){this.backtrackFragment=null;const r=this.fragPlaying,n=e.level;(!r||e.sn!==r.sn||r.level!==n||e.urlId!==r.urlId)&&(this.fragPlaying=e,this.hls.trigger(v.FRAG_CHANGED,{frag:e}),(!r||r.level!==n)&&this.hls.trigger(v.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const t=this.nextBufferedFrag;return t?t.level:-1}get currentFrag(){const t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}get currentProgramDateTime(){const t=this.media;if(t){const e=t.currentTime,i=this.currentFrag;if(i&&K(e)&&K(i.programDateTime)){const r=i.programDateTime+(e-i.start)*1e3;return new Date(r)}}return null}get currentLevel(){const t=this.currentFrag;return t?t.level:-1}get nextBufferedFrag(){const t=this.currentFrag;return t?this.followingBufferedFrag(t):null}get forceStartLoad(){return this._forceStartLoad}}class ki{constructor(t,e=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=i}sample(t,e){const i=Math.pow(this.alpha_,t);this.estimate_=e*(1-i)+i*this.estimate_,this.totalWeight_+=t}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_}}class sv{constructor(t,e,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 ki(t),this.fast_=new ki(e),this.defaultTTFB_=r,this.ttfb_=new ki(t)}update(t,e){const{slow_:i,fast_:r,ttfb_:n}=this;i.halfLife!==t&&(this.slow_=new ki(t,i.getEstimate(),i.getTotalWeight())),r.halfLife!==e&&(this.fast_=new ki(e,r.getEstimate(),r.getTotalWeight())),n.halfLife!==t&&(this.ttfb_=new ki(t,n.getEstimate(),n.getTotalWeight()))}sample(t,e){t=Math.max(t,this.minDelayMs_);const i=8*e,r=t/1e3,n=i/r;this.fast_.sample(r,n),this.slow_.sample(r,n)}sampleTTFB(t){const e=t/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(i,Math.max(t,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}class nv{constructor(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;const e=t.config;this.bwEstimator=new sv(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(v.FRAG_LOADING,this.onFragLoading,this),t.on(v.FRAG_LOADED,this.onFragLoaded,this),t.on(v.FRAG_BUFFERED,this.onFragBuffered,this),t.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(v.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:t}=this;t.off(v.FRAG_LOADING,this.onFragLoading,this),t.off(v.FRAG_LOADED,this.onFragLoaded,this),t.off(v.FRAG_BUFFERED,this.onFragBuffered,this),t.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(v.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(t,e){var i;const r=e.frag;this.ignoreFragment(r)||(this.fragCurrent=r,this.partCurrent=(i=e.part)!=null?i:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(t,e){this.clearTimer()}getTimeToLoadFrag(t,e,i,r){const n=t+i/e,a=r?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(t,e){const i=this.hls.config,{total:r,bwEstimate:n}=e.stats;K(r)&&K(n)&&(this.lastLevelLoadSec=8*r/n),e.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:t,partCurrent:e,hls:i}=this,{autoLevelEnabled:r,media:n}=i;if(!t||!n)return;const a=performance.now(),o=e?e.stats:t.stats,l=e?e.duration:t.duration,h=a-o.loading.start;if(o.aborted||o.loaded&&o.loaded===o.total||t.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!r||n.paused||!n.playbackRate||!n.readyState)return;const d=i.mainForwardBufferInfo;if(d===null)return;const c=this.bwEstimator.getEstimateTTFB(),u=Math.abs(n.playbackRate);if(h<=Math.max(c,1e3*(l/(u*2))))return;const f=d.len/u;if(f>=2*l/u)return;const p=o.loading.first?o.loading.first-o.loading.start:-1,g=o.loaded&&p>-1,m=this.bwEstimator.getEstimate(),{levels:b,minAutoLevel:A}=i,T=b[t.level],y=o.total||Math.max(o.loaded,Math.round(l*T.maxBitrate/8));let w=h-p;w<1&&g&&(w=Math.min(h,o.loaded*8/m));const S=g?o.loaded*1e3/w:0,L=S?(y-o.loaded)/S:y*8/m+c/1e3;if(L<=f)return;const C=S?S*8:m;let k=Number.POSITIVE_INFINITY,x;for(x=t.level-1;x>A;x--){const N=b[x].maxBitrate;if(k=this.getTimeToLoadFrag(c/1e3,C,l*N,!b[x].details),k<f)break}k>=L||k>l*10||(i.nextLoadLevel=x,g?this.bwEstimator.sample(h-Math.min(c,p),o.loaded):this.bwEstimator.sampleTTFB(h),this.clearTimer(),R.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;
|
125
|
-
Time to underbuffer: ${f.toFixed(3)} s
|
126
|
-
Estimated load time for current fragment: ${L.toFixed(3)} s
|
127
|
-
Estimated load time for down switch fragment: ${k.toFixed(3)} s
|
128
|
-
TTFB estimate: ${p}
|
129
|
-
Current BW estimate: ${K(m)?(m/1024).toFixed(3):"Unknown"} Kb/s
|
130
|
-
New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
|
131
|
-
Aborting and switching to level ${x}`),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),i.trigger(v.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:o}))}onFragLoaded(t,{frag:e,part:i}){const r=i?i.stats:e.stats;if(e.type===X.MAIN&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(e)){if(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const n=i?i.duration:e.duration,a=this.hls.levels[e.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(e.bitrateTest){const n={stats:r,frag:e,part:i,id:e.type};this.onFragBuffered(v.FRAG_BUFFERED,n),e.bitrateTest=!1}}}onFragBuffered(t,e){const{frag:i,part:r}=e,n=r!=null&&r.stats.loaded?r.stats:i.stats;if(n.aborted||this.ignoreFragment(i))return;const 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.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==X.MAIN||t.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const t=this._nextAutoLevel,e=this.bwEstimator;if(t!==-1&&!e.canEstimate())return t;let i=this.getNextABRAutoLevel();if(t!==-1){const r=this.hls.levels;if(r.length>Math.max(t,i)&&r[t].loadError<=r[i].loadError)return t}return t!==-1&&(i=Math.min(t,i)),i}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:i}=this,{maxAutoLevel:r,config:n,minAutoLevel:a,media:o}=i,l=e?e.duration:t?t.duration:0,h=o&&o.playbackRate!==0?Math.abs(o.playbackRate):1,d=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,c=i.mainForwardBufferInfo,u=(c?c.len:0)/h;let f=this.findBestLevel(d,a,r,u,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(f>=0)return f;R.trace(`[abr] ${u?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let p=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay,g=n.abrBandWidthFactor,m=n.abrBandWidthUpFactor;if(!u){const b=this.bitrateTestDelay;b&&(p=(l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay)-b,R.trace(`[abr] bitrate test took ${Math.round(1e3*b)}ms, set first fragment max fetchDuration to ${Math.round(1e3*p)} ms`),g=m=1)}return f=this.findBestLevel(d,a,r,u+p,g,m),Math.max(f,0)}findBestLevel(t,e,i,r,n,a){var o;const{fragCurrent:l,partCurrent:h,lastLoadedFragLevel:d}=this,{levels:c}=this.hls,u=c[d],f=!!(u!=null&&(o=u.details)!=null&&o.live),p=u==null?void 0:u.codecSet,g=h?h.duration:l?l.duration:0,m=this.bwEstimator.getEstimateTTFB()/1e3;let b=e,A=-1;for(let T=i;T>=e;T--){const y=c[T];if(!y||p&&y.codecSet!==p){y&&(b=Math.min(T,b),A=Math.max(T,A));continue}A!==-1&&R.trace(`[abr] Skipped level(s) ${b}-${A} with CODECS:"${c[A].attrs.CODECS}"; not compatible with "${u.attrs.CODECS}"`);const w=y.details,S=(h?w==null?void 0:w.partTarget:w==null?void 0:w.averagetargetduration)||g;let L;T<=d?L=n*t:L=a*t;const C=c[T].maxBitrate,k=this.getTimeToLoadFrag(m,L,C*S,w===void 0);if(R.trace(`[abr] level:${T} adjustedbw-bitrate:${Math.round(L-C)} avgDuration:${S.toFixed(1)} maxFetchDuration:${r.toFixed(1)} fetchDuration:${k.toFixed(1)}`),L>C&&(k===0||!K(k)||f&&!this.bitrateTestDelay||k<r))return T}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}}class ud{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:e}=this;let i;if(t.length)t.length===1?i=t[0]:i=av(t,e);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function av(s,t){const e=new Uint8Array(t);let i=0;for(let r=0;r<s.length;r++){const n=s[r];e.set(n,i),i+=n.length}return e}const fd=100;class ov extends la{constructor(t,e,i){super(t,e,i,"[audio-stream-controller]",X.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:t}=this;t.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.LEVEL_LOADED,this.onLevelLoaded,this),t.on(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(v.ERROR,this.onError,this),t.on(v.BUFFER_RESET,this.onBufferReset,this),t.on(v.BUFFER_CREATED,this.onBufferCreated,this),t.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.LEVEL_LOADED,this.onLevelLoaded,this),t.off(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(v.ERROR,this.onError,this),t.off(v.BUFFER_RESET,this.onBufferReset,this),t.off(v.BUFFER_CREATED,this.onBufferCreated,this),t.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(t,{frag:e,id:i,initPTS:r,timescale:n}){if(i==="main"){const a=e.cc;this.initPTS[e.cc]={baseTime:r,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${r}`),this.videoTrackCC=a,this.state===F.WAITING_INIT_PTS&&this.tick()}}startLoad(t){if(!this.levels){this.startPosition=t,this.state=F.STOPPED;return}const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(fd),e>0&&t===-1?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=F.IDLE):(this.loadedmetadata=!1,this.state=F.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case F.IDLE:this.doTickIdle();break;case F.WAITING_TRACK:{var t;const{levels:i,trackId:r}=this,n=i==null||(t=i[r])==null?void 0:t.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=F.WAITING_INIT_PTS}break}case F.FRAG_LOADING_WAITING_RETRY:{var e;const i=performance.now(),r=this.retryDate;(!r||i>=r||(e=this.media)!=null&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=F.IDLE);break}case F.WAITING_INIT_PTS:{const i=this.waitingData;if(i){const{frag:r,part:n,cache:a,complete:o}=i;if(this.initPTS[r.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=F.FRAG_LOADING;const l=a.flush(),h={frag:r,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(h),o&&super._handleFragmentLoadComplete(h)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${r.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const l=this.getLoadPosition(),h=lt.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);ia(h.end,this.config.maxFragLookUpTolerance,r)<0&&(this.log(`Waiting fragment cc (${r.cc}) @ ${r.start} cancelled because another fragment at ${h.end} is needed`),this.clearWaitingFragment())}}else this.state=F.IDLE}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=F.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:t}=this;t!=null&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){const{hls:t,levels:e,media:i,trackId:r}=this,n=t.config;if(!(e!=null&&e[r])||!i&&(this.startFragRequested||!n.startFragPrefetch))return;const a=e[r],o=a.details;if(!o||o.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(o)){this.state=F.WAITING_TRACK;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,at.AUDIO,X.AUDIO));const h=this.getFwdBufferInfo(l,X.AUDIO);if(h===null)return;const{bufferedTrack:d,switchingTrack:c}=this;if(!c&&this._streamEnded(h,o)){t.trigger(v.BUFFER_EOS,{type:"audio"}),this.state=F.ENDED;return}const u=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,X.MAIN),f=h.len,p=this.getMaxBufferLength(u==null?void 0:u.len);if(f>=p&&!c)return;const g=o.fragments[0].start;let m=h.end;if(c&&i){const y=this.getLoadPosition();d&&c.attrs!==d.attrs&&(m=y),o.PTSKnown&&y<g&&(h.end>g||h.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=g+.05)}let b=this.getNextFragment(m,o),A=!1;if(b&&this.isLoopLoading(b,m)&&(A=!!b.gap,b=this.getNextFragmentLoopLoading(b,o,h,X.MAIN,p)),!b){this.bufferFlushed=!0;return}const T=u&&b.start>u.end+o.targetduration;if(T||!(u!=null&&u.len)&&h.len){const y=this.getAppendedFrag(b.start,X.MAIN);if(y===null||(A||(A=!!y.gap||!!T&&u.len===0),T&&!A||A&&h.nextStart&&h.nextStart<y.end))return}this.loadFragment(b,a,m)}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.min(Math.max(e,t),this.config.maxMaxBufferLength):e}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(t,{audioTracks:e}){this.resetTransmuxer(),this.levels=e.map(i=>new yr(i))}onAudioTrackSwitching(t,e){const i=!!e.url;this.trackId=e.id;const{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),i?this.setInterval(fd):this.resetTransmuxer(),i?(this.switchingTrack=e,this.state=F.IDLE):(this.switchingTrack=null,this.bufferedTrack=e,this.state=F.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(t,e){this.mainDetails=e.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(v.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,e){var i;if(this.mainDetails==null){this.cachedTrackLoadedData=e;return}const{levels:r}=this,{details:n,id:a}=e;if(!r){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const o=r[a];let l=0;if(n.live||(i=o.details)!=null&&i.live){this.checkLiveUpdate(n);const h=this.mainDetails;if(n.deltaUpdateFailed||!h)return;!o.details&&n.hasProgramDateTime&&h.hasProgramDateTime?(Kh(n,h),l=n.fragments[0].start):l=this.alignPlaylists(n,o.details)}o.details=n,this.levelLastLoaded=a,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(o.details,l),this.state===F.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=F.IDLE),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:r,payload:n}=t,{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}const h=l[o];if(!h){this.warn("Audio track is undefined on fragment load progress");return}const d=h.details;if(!d){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const c=a.defaultAudioCodec||h.audioCodec||"mp4a.40.2";let u=this.transmuxer;u||(u=this.transmuxer=new cd(this.hls,X.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const f=this.initPTS[i.cc],p=(e=i.initSegment)==null?void 0:e.data;if(f!==void 0){const g=r?r.index:-1,m=g!==-1,b=new na(i.level,i.sn,i.stats.chunkCount,n.byteLength,g,m);u.push(n,p,c,"",i,r,d.totalduration,!1,b,f)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${d.startSN} ,${d.endSN}],track ${o}`);const{cache:g}=this.waitingData=this.waitingData||{frag:i,part:r,cache:new ud,complete:!1};g.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=F.WAITING_INIT_PTS}}_handleFragmentLoadComplete(t){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){const i=e.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){const{frag:i,part:r}=e;if(i.type!==X.AUDIO){if(!this.loadedmetadata&&i.type===X.MAIN){const n=this.videoBuffer||this.media;n&<.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(i.sn!=="initSegment"){this.fragPrevious=i;const n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(v.AUDIO_TRACK_SWITCHED,jt({},n)))}this.fragBufferedComplete(i,r)}onError(t,e){var i;if(e.fatal){this.state=F.ERROR;return}switch(e.details){case P.FRAG_GAP:case P.FRAG_PARSING_ERROR:case P.FRAG_DECRYPT_ERROR:case P.FRAG_LOAD_ERROR:case P.FRAG_LOAD_TIMEOUT:case P.KEY_LOAD_ERROR:case P.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(X.AUDIO,e);break;case P.AUDIO_TRACK_LOAD_ERROR:case P.AUDIO_TRACK_LOAD_TIMEOUT:case P.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===F.WAITING_TRACK&&((i=e.context)==null?void 0:i.type)===rt.AUDIO_TRACK&&(this.state=F.IDLE);break;case P.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="audio")return;this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case P.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}onBufferFlushed(t,{type:e}){e===at.AUDIO&&(this.bufferFlushed=!0,this.state===F.ENDED&&(this.state=F.IDLE))}_handleTransmuxComplete(t){var e;const i="audio",{hls:r}=this,{remuxResult:n,chunkMeta:a}=t,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:h,level:d}=o,{details:c}=d,{audio:u,text:f,id3:p,initSegment:g}=n;if(this.fragContextChanged(l)||!c){this.fragmentTracker.removeFragment(l);return}if(this.state=F.PARSING,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),g!=null&&g.tracks){const m=l.initSegment||l;this._bufferInitSegment(g.tracks,m,a),r.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:m,id:i,tracks:g.tracks})}if(u){const{startPTS:m,endPTS:b,startDTS:A,endDTS:T}=u;h&&(h.elementaryStreams[at.AUDIO]={startPTS:m,endPTS:b,startDTS:A,endDTS:T}),l.setElementaryStreamInfo(at.AUDIO,m,b,A,T),this.bufferFragmentData(u,l,h,a)}if(p!=null&&(e=p.samples)!=null&&e.length){const m=Et({id:i,frag:l,details:c},p);r.trigger(v.FRAG_PARSING_METADATA,m)}if(f){const m=Et({id:i,frag:l,details:c},f);r.trigger(v.FRAG_PARSING_USERDATA,m)}}_bufferInitSegment(t,e,i){if(this.state!==F.PARSING)return;t.video&&delete t.video;const r=t.audio;if(!r)return;r.levelCodec=r.codec,r.id="audio",this.log(`Init audio buffer, container:${r.container}, codecs[parsed]=[${r.codec}]`),this.hls.trigger(v.BUFFER_CODECS,t);const n=r.initSegment;if(n!=null&&n.byteLength){const a={type:"audio",frag:e,part:null,chunkMeta:i,parent:e.type,data:n};this.hls.trigger(v.BUFFER_APPENDING,a)}this.tick()}loadFragment(t,e,i){const r=this.fragmentTracker.getState(t);if(this.fragCurrent=t,this.switchingTrack||r===Rt.NOT_LOADED||r===Rt.PARTIAL){var n;t.sn==="initSegment"?this._loadInitSegment(t,e):(n=e.details)!=null&&n.live&&!this.initPTS[t.cc]?(this.log(`Waiting for video PTS in continuity counter ${t.cc} of live stream before loading audio fragment ${t.sn} of level ${this.trackId}`),this.state=F.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(t,e,i))}else this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){const{hls:e,media:i,bufferedTrack:r}=this,n=r==null?void 0:r.attrs,a=t.attrs;i&&n&&(n.CHANNELS!==a.CHANNELS||n.NAME!==a.NAME||n.LANGUAGE!==a.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(v.AUDIO_TRACK_SWITCHED,jt({},t))}}class lv extends ra{constructor(t){super(t,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.MANIFEST_PARSED,this.onManifestParsed,this),t.on(v.LEVEL_LOADING,this.onLevelLoading,this),t.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.MANIFEST_PARSED,this.onManifestParsed,this),t.off(v.LEVEL_LOADING,this.onLevelLoading,this),t.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(v.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){const{id:i,groupId:r,details:n}=e,a=this.tracksInGroup[i];if(!a||a.groupId!==r){this.warn(`Track with id:${i} and group:${r} not found in active group ${a.groupId}`);return}const o=a.details;a.details=e.details,this.log(`audio-track ${i} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,o)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!(e!=null&&e.audioGroupIds))return;const i=e.audioGroupIds[e.urlId];if(this.groupId!==i){this.groupId=i||null;const r=this.tracks.filter(a=>!i||a.groupId===i);this.selectDefaultTrack&&!r.some(a=>a.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=r;const n={audioTracks:r};this.log(`Updating audio tracks, ${r.length} track(s) found in group:${i}`),this.hls.trigger(v.AUDIO_TRACKS_UPDATED,n),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(t,e){e.fatal||!e.context||e.context.type===rt.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(e))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioTrack(t){const e=this.tracksInGroup;if(t<0||t>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();const i=this.currentTrack;e[this.trackId];const r=e[t],{groupId:n,name:a}=r;if(this.log(`Switching to audio-track ${t} "${a}" lang:${r.lang} group:${n}`),this.trackId=t,this.currentTrack=r,this.selectDefaultTrack=!1,this.hls.trigger(v.AUDIO_TRACK_SWITCHING,jt({},r)),r.details&&!r.details.live)return;const o=this.switchParams(r.url,i==null?void 0:i.details);this.loadPlaylist(o)}selectInitialTrack(){const t=this.tracksInGroup,e=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(e!==-1)this.setAudioTrack(e);else{const i=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${t.length}`);this.warn(i.message),this.hls.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const r=e[i];if((!this.selectDefaultTrack||r.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]!==void 0&&t.attrs["STABLE-RENDITION-ID"]===r.attrs["STABLE-RENDITION-ID"]||t.name===r.name&&t.lang===r.lang))return r.id}return-1}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const i=e.id,r=e.groupId;let n=e.url;if(t)try{n=t.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${i} "${e.name}" lang:${e.lang} group:${r}`),this.clearTimer(),this.hls.trigger(v.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:t||null})}}}function pd(s,t){if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(!hv(s[e].attrs,t[e].attrs))return!1;return!0}function hv(s,t){const e=s["STABLE-RENDITION-ID"];return e?e===t["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>s[i]!==t[i])}const gd=500;class dv extends la{constructor(t,e,i){super(t,e,i,"[subtitle-stream-controller]",X.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:t}=this;t.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.LEVEL_LOADED,this.onLevelLoaded,this),t.on(v.ERROR,this.onError,this),t.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.LEVEL_LOADED,this.onLevelLoaded,this),t.off(v.ERROR,this.onError,this),t.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=F.IDLE,this.setInterval(gd),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(t,e){this.mainDetails=e.details}onSubtitleFragProcessed(t,e){const{frag:i,success:r}=e;if(this.fragPrevious=i,this.state=F.IDLE,!r)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a;const o=i.start;for(let h=0;h<n.length;h++)if(o>=n[h].start&&o<=n[h].end){a=n[h];break}const l=i.start+i.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(i)}onBufferFlushing(t,e){const{startOffset:i,endOffset:r}=e;if(i===0&&r!==Number.POSITIVE_INFINITY){const n=r-1;if(n<=0)return;e.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,X.SUBTITLE)}}onFragBuffered(t,e){if(!this.loadedmetadata&&e.frag.type===X.MAIN){var i;(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)}}onError(t,e){const i=e.frag;(i==null?void 0:i.type)===X.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==F.STOPPED&&(this.state=F.IDLE))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){if(pd(this.levels,e)){this.levels=e.map(i=>new yr(i));return}this.tracksBuffered=[],this.levels=e.map(i=>{const r=new yr(i);return this.tracksBuffered[r.id]=[],r}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,X.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(t,e){if(this.currentTrackId=e.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}const i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(gd)}onSubtitleTrackLoaded(t,e){var i;const{details:r,id:n}=e,{currentTrackId:a,levels:o}=this;if(!o.length)return;const l=o[a];if(n>=o.length||n!==a||!l)return;this.mediaBuffer=this.mediaBufferTimeRanges;let h=0;if(r.live||(i=l.details)!=null&&i.live){const d=this.mainDetails;if(r.deltaUpdateFailed||!d)return;const c=d.fragments[0];l.details?(h=this.alignPlaylists(r,l.details),h===0&&c&&(h=c.start,ta(r,h))):r.hasProgramDateTime&&d.hasProgramDateTime?(Kh(r,d),h=r.fragments[0].start):c&&(h=c.start,ta(r,h))}l.details=r,this.levelLastLoaded=n,!this.startFragRequested&&(this.mainDetails||!r.live)&&this.setStartPosition(l.details,h),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===F.IDLE&&(br(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0))}_handleFragmentLoadComplete(t){const{frag:e,payload:i}=t,r=e.decryptdata,n=this.hls;if(!this.fragContextChanged(e)&&i&&i.byteLength>0&&r&&r.key&&r.iv&&r.method==="AES-128"){const a=performance.now();this.decrypter.decrypt(new Uint8Array(i),r.key.buffer,r.iv.buffer).catch(o=>{throw n.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:e}),o}).then(o=>{const l=performance.now();n.trigger(v.FRAG_DECRYPTED,{frag:e,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=F.IDLE})}}doTick(){if(!this.media){this.state=F.IDLE;return}if(this.state===F.IDLE){const{currentTrackId:t,levels:e}=this,i=e[t];if(!e.length||!i||!i.details)return;const{config:r}=this,n=this.getLoadPosition(),a=lt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,r.maxBufferHole),{end:o,len:l}=a,h=this.getFwdBufferInfo(this.media,X.MAIN),d=i.details,c=this.getMaxBufferLength(h==null?void 0:h.len)+d.levelTargetDuration;if(l>c)return;const u=d.fragments,f=u.length,p=d.edge;let g=null;const m=this.fragPrevious;if(o<p){const b=r.maxFragLookUpTolerance,A=o>p-b?0:b;g=br(m,u,Math.max(u[0].start,o),A),!g&&m&&m.start<u[0].start&&(g=u[0])}else g=u[f-1];if(!g)return;if(g=this.mapToInitFragWhenRequired(g),g.sn!=="initSegment"){const b=g.sn-d.startSN,A=u[b-1];A&&A.cc===g.cc&&this.fragmentTracker.getState(A)===Rt.NOT_LOADED&&(g=A)}this.fragmentTracker.getState(g)===Rt.NOT_LOADED&&this.loadFragment(g,i,o)}}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.max(e,t):e}loadFragment(t,e,i){this.fragCurrent=t,t.sn==="initSegment"?this._loadInitSegment(t,e):(this.startFragRequested=!0,super.loadFragment(t,e,i))}get mediaBufferTimeRanges(){return new cv(this.tracksBuffered[this.currentTrackId]||[])}}class cv{constructor(t){this.buffered=void 0;const e=(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 t[r][i]};this.buffered={get length(){return t.length},end(i){return e("end",i,t.length)},start(i){return e("start",i,t.length)}}}}class uv extends ra{constructor(t){super(t,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:t}=this;t.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.MANIFEST_PARSED,this.onManifestParsed,this),t.on(v.LEVEL_LOADING,this.onLevelLoading,this),t.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.MANIFEST_PARSED,this.onManifestParsed,this),t.off(v.LEVEL_LOADING,this.onLevelLoading,this),t.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(v.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.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(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)}onMediaDetaching(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Aa(this.media.textTracks).forEach(t=>{Li(t)}),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){const{id:i,details:r}=e,{trackId:n}=this,a=this.tracksInGroup[n];if(!a){this.warn(`Invalid subtitle track id ${i}`);return}const o=a.details;a.details=e.details,this.log(`subtitle track ${i} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,o)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!(e!=null&&e.textGroupIds))return;const i=e.textGroupIds[e.urlId],r=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){const n=this.tracks.filter(l=>!i||l.groupId===i);this.tracksInGroup=n;const a=this.findTrackId(r==null?void 0:r.name)||this.findTrackId();this.groupId=i||null;const o={subtitleTracks:n};this.log(`Updating subtitle tracks, ${n.length} track(s) found in "${i}" group-id`),this.hls.trigger(v.SUBTITLE_TRACKS_UPDATED,o),a!==-1&&this.setSubtitleTrack(a,r)}else this.shouldReloadPlaylist(r)&&this.setSubtitleTrack(this.trackId,r)}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const r=e[i];if((!this.selectDefaultTrack||r.default)&&(!t||t===r.name))return r.id}return-1}onError(t,e){e.fatal||!e.context||e.context.type===rt.SUBTITLE_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.checkRetry(e)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(t){this.selectDefaultTrack=!1;const e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const i=e.id,r=e.groupId;let n=e.url;if(t)try{n=t.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(v.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:t||null})}}toggleTrackModes(t){const{media:e,trackId:i}=this;if(!e)return;const r=Aa(e.textTracks),n=r.filter(o=>o.groupId===this.groupId);if(t===-1)[].slice.call(r).forEach(o=>{o.mode="disabled"});else{const o=n[i];o&&(o.mode="disabled")}const a=n[t];a&&(a.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(t,e){var i;const r=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=t;return}if(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(t===-1||(i=r[t])!=null&&i.details)||t<-1||t>=r.length)return;this.clearTimer();const n=r[t];if(this.log(`Switching to subtitle-track ${t}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:"")),this.trackId=t,n){const{id:a,groupId:o="",name:l,type:h,url:d}=n;this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:h,url:d});const c=this.switchParams(n.url,e==null?void 0:e.details);this.loadPlaylist(c)}else this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:t})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=-1;const e=Aa(this.media.textTracks);for(let i=0;i<e.length;i++)if(e[i].mode==="hidden")t=i;else if(e[i].mode==="showing"){t=i;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}}function Aa(s){const t=[];for(let e=0;e<s.length;e++){const i=s[e];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&t.push(s[e])}return t}class fv{constructor(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}append(t,e){const i=this.queues[e];i.push(t),i.length===1&&this.buffers[e]&&this.executeNext(e)}insertAbort(t,e){this.queues[e].unshift(t),this.executeNext(e)}appendBlocker(t){let e;const i=new Promise(n=>{e=n}),r={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(r,t),i}executeNext(t){const{buffers:e,queues:i}=this,r=e[t],n=i[t];if(n.length){const a=n[0];try{a.execute()}catch(o){R.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),a.onError(o),r!=null&&r.updating||(n.shift(),this.executeNext(t))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const md=hs(),vd=/([ha]vc.)(?:\.[^.,]+)+/;class pv{constructor(t){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{const{media:e,mediaSource:i}=this;R.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(v.MEDIA_ATTACHED,{media:e})),i&&i.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{R.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{R.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:i}=this;e&&e.src!==i&&R.error(`Media element src was set while attaching MediaSource (${i} > ${e.src})`)},this.hls=t,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){const{hls:t}=this;t.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.MANIFEST_PARSED,this.onManifestParsed,this),t.on(v.BUFFER_RESET,this.onBufferReset,this),t.on(v.BUFFER_APPENDING,this.onBufferAppending,this),t.on(v.BUFFER_CODECS,this.onBufferCodecs,this),t.on(v.BUFFER_EOS,this.onBufferEos,this),t.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(v.FRAG_PARSED,this.onFragParsed,this),t.on(v.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:t}=this;t.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.MANIFEST_PARSED,this.onManifestParsed,this),t.off(v.BUFFER_RESET,this.onBufferReset,this),t.off(v.BUFFER_APPENDING,this.onBufferAppending,this),t.off(v.BUFFER_CODECS,this.onBufferCodecs,this),t.off(v.BUFFER_EOS,this.onBufferEos,this),t.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(v.FRAG_PARSED,this.onFragParsed,this),t.off(v.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new fv(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,e){let i=2;(e.audio&&!e.video||!e.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,R.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const i=this.media=e.media;if(i&&md){const r=this.mediaSource=new md;r.addEventListener("sourceopen",this._onMediaSourceOpen),r.addEventListener("sourceended",this._onMediaSourceEnded),r.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(r),this._objectUrl=i.src,i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:i}=this;if(e){if(R.log("[buffer-controller]: media source detaching"),e.readyState==="open")try{e.endOfStream()}catch(r){R.warn(`[buffer-controller]: onMediaDetaching: ${r.message} while calling endOfStream`)}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),i&&self.URL.revokeObjectURL(i),t.src===i?(t.removeAttribute("src"),t.load()):R.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(v.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(t=>{const e=this.sourceBuffer[t];try{e&&(this.removeBufferListeners(t),this.mediaSource&&this.mediaSource.removeSourceBuffer(e),this.sourceBuffer[t]=void 0)}catch(i){R.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,i)}}),this._initSourceBuffer()}onBufferCodecs(t,e){const i=this.getSourceBufferTypes().length;Object.keys(e).forEach(r=>{if(i){const n=this.tracks[r];if(n&&typeof n.buffer.changeType=="function"){const{id:a,codec:o,levelCodec:l,container:h,metadata:d}=e[r],c=(n.levelCodec||n.codec).replace(vd,"$1"),u=(l||o).replace(vd,"$1");if(c!==u){const f=`${h};codecs=${l||o}`;this.appendChangeType(r,f),R.log(`[buffer-controller]: switching codec ${c} to ${u}`),this.tracks[r]={buffer:n.buffer,codec:o,container:h,levelCodec:l,metadata:d,id:a}}}}else this.pendingTracks[r]=e[r]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(t,e){const{operationQueue:i}=this,r={execute:()=>{const n=this.sourceBuffer[t];n&&(R.log(`[buffer-controller]: changing ${t} sourceBuffer type to ${e}`),n.changeType(e)),i.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:n=>{R.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,n)}};i.append(r,t)}onBufferAppending(t,e){const{hls:i,operationQueue:r,tracks:n}=this,{data:a,type:o,frag:l,part:h,chunkMeta:d}=e,c=d.buffering[o],u=self.performance.now();c.start=u;const f=l.stats.buffering,p=h?h.stats.buffering:null;f.start===0&&(f.start=u),p&&p.start===0&&(p.start=u);const g=n.audio;let m=!1;o==="audio"&&(g==null?void 0:g.container)==="audio/mpeg"&&(m=!this.lastMpegAudioChunk||d.id===1||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);const b=l.start,A={execute:()=>{if(c.executeStart=self.performance.now(),m){const T=this.sourceBuffer[o];if(T){const y=b-T.timestampOffset;Math.abs(y)>=.1&&(R.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${b} (delta: ${y}) sn: ${l.sn})`),T.timestampOffset=b)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{const T=self.performance.now();c.executeEnd=c.end=T,f.first===0&&(f.first=T),p&&p.first===0&&(p.first=T);const{sourceBuffer:y}=this,w={};for(const S in y)w[S]=lt.getBuffered(y[S]);this.appendError=0,this.hls.trigger(v.BUFFER_APPENDED,{type:o,frag:l,part:h,chunkMeta:d,parent:l.type,timeRanges:w})},onError:T=>{R.error(`[buffer-controller]: Error encountered while trying to append to the ${o} SourceBuffer`,T);const y={type:Y.MEDIA_ERROR,parent:l.type,details:P.BUFFER_APPEND_ERROR,frag:l,part:h,chunkMeta:d,error:T,err:T,fatal:!1};T.code===DOMException.QUOTA_EXCEEDED_ERR?y.details=P.BUFFER_FULL_ERROR:(this.appendError++,y.details=P.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(R.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),y.fatal=!0)),i.trigger(v.ERROR,y)}};r.append(A,o)}onBufferFlushing(t,e){const{operationQueue:i}=this,r=n=>({execute:this.removeExecutor.bind(this,n,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(v.BUFFER_FLUSHED,{type:n})},onError:a=>{R.warn(`[buffer-controller]: Failed to remove from ${n} SourceBuffer`,a)}});e.type?i.append(r(e.type),e.type):this.getSourceBufferTypes().forEach(n=>{i.append(r(n),n)})}onFragParsed(t,e){const{frag:i,part:r}=e,n=[],a=r?r.elementaryStreams:i.elementaryStreams;a[at.AUDIOVIDEO]?n.push("audiovideo"):(a[at.AUDIO]&&n.push("audio"),a[at.VIDEO]&&n.push("video"));const o=()=>{const l=self.performance.now();i.stats.buffering.end=l,r&&(r.stats.buffering.end=l);const h=r?r.stats:i.stats;this.hls.trigger(v.FRAG_BUFFERED,{frag:i,part:r,stats:h,id:i.type})};n.length===0&&R.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(o,n)}onFragChanged(t,e){this.flushBackBuffer()}onBufferEos(t,e){this.getSourceBufferTypes().reduce((i,r)=>{const n=this.sourceBuffer[r];return n&&(!e.type||e.type===r)&&(n.ending=!0,n.ended||(n.ended=!0,R.log(`[buffer-controller]: ${r} sourceBuffer now EOS`))),i&&!!(!n||n.ended)},!0)&&(R.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(r=>{const n=this.sourceBuffer[r];n&&(n.ending=!1)});const{mediaSource:i}=this;if(!i||i.readyState!=="open"){i&&R.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${i.readyState}`);return}R.log("[buffer-controller]: Calling mediaSource.endOfStream()"),i.endOfStream()}))}onLevelUpdated(t,{details:e}){e.fragments.length&&(this.details=e,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:t,details:e,media:i,sourceBuffer:r}=this;if(!i||e===null)return;const n=this.getSourceBufferTypes();if(!n.length)return;const a=e.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(!K(a)||a<0)return;const o=i.currentTime,l=e.levelTargetDuration,h=Math.max(a,l),d=Math.floor(o/l)*l-h;n.forEach(c=>{const u=r[c];if(u){const f=lt.getBuffered(u);if(f.length>0&&d>f.start(0)){if(t.trigger(v.BACK_BUFFER_REACHED,{bufferEnd:d}),e.live)t.trigger(v.LIVE_BACK_BUFFER_REACHED,{bufferEnd:d});else if(u.ended&&f.end(f.length-1)-o<l*2){R.info(`[buffer-controller]: Cannot flush ${c} back buffer while SourceBuffer is in ended state`);return}t.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:d,type:c})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:t,hls:e,media:i,mediaSource:r}=this,n=t.fragments[0].start+t.totalduration,a=i.duration,o=K(r.duration)?r.duration:0;t.live&&e.config.liveDurationInfinity?(R.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(t)):(n>o&&n>a||!K(a))&&(R.log(`[buffer-controller]: Updating Media Source duration to ${n.toFixed(3)}`),r.duration=n)}updateSeekableRange(t){const e=this.mediaSource,i=t.fragments;if(i.length&&t.live&&e!=null&&e.setLiveSeekableRange){const r=Math.max(0,i[0].start),n=Math.max(r,r+t.totalduration);e.setLiveSeekableRange(r,n)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:i}=this,r=Object.keys(i).length;if(r&&!t||r===2){this.createSourceBuffers(i),this.pendingTracks={};const n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(v.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{e.executeNext(a)});else{const a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(t){const{sourceBuffer:e,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const r in t)if(!e[r]){const n=t[r];if(!n)throw Error(`source buffer exists for track ${r}, however track does not`);const a=n.levelCodec||n.codec,o=`${n.container};codecs=${a}`;R.log(`[buffer-controller]: creating sourceBuffer(${o})`);try{const l=e[r]=i.addSourceBuffer(o),h=r;this.addBufferListener(h,"updatestart",this._onSBUpdateStart),this.addBufferListener(h,"updateend",this._onSBUpdateEnd),this.addBufferListener(h,"error",this._onSBUpdateError),this.tracks[r]={buffer:l,codec:a,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(l){R.error(`[buffer-controller]: error while trying to add sourceBuffer: ${l.message}`),this.hls.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:o})}}}_onSBUpdateStart(t){const{operationQueue:e}=this;e.current(t).onStart()}_onSBUpdateEnd(t){const{operationQueue:e}=this;e.current(t).onComplete(),e.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){const i=new Error(`${t} SourceBuffer error`);R.error(`[buffer-controller]: ${i}`,e),this.hls.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.BUFFER_APPENDING_ERROR,error:i,fatal:!1});const r=this.operationQueue.current(t);r&&r.onError(e)}removeExecutor(t,e,i){const{media:r,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[t];if(!r||!n||!l){R.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(t);return}const h=K(r.duration)?r.duration:1/0,d=K(n.duration)?n.duration:1/0,c=Math.max(0,e),u=Math.min(i,h,d);u>c&&!l.ending?(l.ended=!1,R.log(`[buffer-controller]: Removing [${c},${u}] from the ${t} SourceBuffer`),l.remove(c,u)):a.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:i,sourceBuffer:r}=this,n=r[e];if(!n){R.warn(`[buffer-controller]: Attempting to append to the ${e} SourceBuffer, but it does not exist`),i.shiftAndExecuteNext(e);return}n.ended=!1,n.appendBuffer(t)}blockBuffers(t,e=this.getSourceBufferTypes()){if(!e.length){R.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);return}const{operationQueue:i}=this,r=e.map(n=>i.appendBlocker(n));Promise.all(r).then(()=>{t(),e.forEach(n=>{const a=this.sourceBuffer[n];a!=null&&a.updating||i.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,i){const r=this.sourceBuffer[t];if(!r)return;const n=i.bind(this,t);this.listeners[t].push({event:e,listener:n}),r.addEventListener(e,n)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach(i=>{e.removeEventListener(i.event,i.listener)})}}const yd={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},bd=function(s){let t=s;return yd.hasOwnProperty(s)&&(t=yd[s]),String.fromCharCode(t)},he=15,ke=100,gv={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},mv={17:2,18:4,21:6,22:8,23:10,19:13,20:15},vv={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},yv={25:2,26:4,29:6,30:8,31:10,27:13,28:15},bv=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Av{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const i=typeof e=="function"?e():e;R.log(`${this.time} [${t}] ${i}`)}}}const oi=function(s){const t=[];for(let e=0;e<s.length;e++)t.push(s[e].toString(16));return t};class Ad{constructor(t,e,i,r,n){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=e||!1,this.italics=i||!1,this.background=r||"black",this.flash=n||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(t){const e=["foreground","underline","italics","background","flash"];for(let i=0;i<e.length;i++){const r=e[i];t.hasOwnProperty(r)&&(this[r]=t[r])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash}copy(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class Tv{constructor(t,e,i,r,n,a){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new Ad(e,i,r,n,a)}reset(){this.uchar=" ",this.penState.reset()}setChar(t,e){this.uchar=t,this.penState.copy(e)}setPenState(t){this.penState.copy(t)}equals(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)}copy(t){this.uchar=t.uchar,this.penState.copy(t.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class Ev{constructor(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let e=0;e<ke;e++)this.chars.push(new Tv);this.logger=t,this.pos=0,this.currPenState=new Ad}equals(t){let e=!0;for(let i=0;i<ke;i++)if(!this.chars[i].equals(t.chars[i])){e=!1;break}return e}copy(t){for(let e=0;e<ke;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<ke;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t}setCursor(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>ke&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ke)}moveCursor(t){const e=this.pos+t;if(t>1)for(let i=this.pos+1;i<e+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(e)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(t){t>=144&&this.backSpace();const e=bd(t);if(this.pos>=ke){this.logger.log(0,()=>"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1)}clearFromPos(t){let e;for(e=t;e<ke;e++)this.chars[e].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const t=[];let e=!0;for(let i=0;i<ke;i++){const r=this.chars[i].uchar;r!==" "&&(e=!1),t.push(r)}return e?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)}}class Ta{constructor(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let e=0;e<he;e++)this.rows.push(new Ev(t));this.logger=t,this.currRow=he-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let t=0;t<he;t++)this.rows[t].clear();this.currRow=he-1}equals(t){let e=!0;for(let i=0;i<he;i++)if(!this.rows[i].equals(t.rows[i])){e=!1;break}return e}copy(t){for(let e=0;e<he;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<he;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(t){this.rows[this.currRow].insertChar(t)}setPen(t){this.rows[this.currRow].setPenStyles(t)}moveCursor(t){this.rows[this.currRow].moveCursor(t)}setCursor(t){this.logger.log(2,"setCursor: "+t),this.rows[this.currRow].setCursor(t)}setPAC(t){this.logger.log(2,()=>"pacData = "+JSON.stringify(t));let e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(let o=0;o<he;o++)this.rows[o].clear();const n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){const o=a.rows[n].cueStartTime,l=this.logger.time;if(o&&l!==null&&o<l)for(let h=0;h<this.nrRollUpRows;h++)this.rows[e-this.nrRollUpRows+h+1].copy(a.rows[n+h])}}this.currRow=e;const i=this.rows[this.currRow];if(t.indent!==null){const n=t.indent,a=Math.max(n-1,0);i.setCursor(t.indent),t.color=i.chars[a].penState.foreground}const r={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(r)}setBkgData(t){this.logger.log(2,()=>"bkgData = "+JSON.stringify(t)),this.backSpace(),this.setPen(t),this.insertChar(32)}setRollUpRows(t){this.nrRollUpRows=t}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(2,"Rolling up")}getDisplayText(t){t=t||!1;const e=[];let i="",r=-1;for(let n=0;n<he;n++){const a=this.rows[n].getTextString();a&&(r=n+1,t?e.push("Row "+r+": '"+a+"'"):e.push(a.trim()))}return e.length>0&&(t?i="["+e.join(" | ")+"]":i=e.join(`
|
132
|
-
`)),i}getTextAndFormat(){return this.rows}}class Td{constructor(t,e,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=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new Ta(i),this.nonDisplayedMemory=new Ta(i),this.lastOutputScreen=new Ta(i),this.currRollUpRow=this.displayedMemory.rows[he-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[he-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(t){this.outputFilter=t}setPAC(t){this.writeScreen.setPAC(t)}setBkgData(t){this.writeScreen.setBkgData(t)}setMode(t){t!==this.mode&&(this.mode=t,this.logger.log(2,()=>"MODE="+t),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=t)}insertChars(t){for(let i=0;i<t.length;i++)this.writeScreen.insertChar(t[i]);const e=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>e+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)}ccMIDROW(t){const e={flash:!1};if(e.underline=t%2===1,e.italics=t>=46,e.italics)e.foreground="white";else{const i=Math.floor(t/2)-16,r=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=r[i]}this.logger.log(2,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)}outputDataUpdate(t=!1){const e=this.logger.time;e!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=e:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))}}class Ed{constructor(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const r=new Av;this.channels=[null,new Td(t,e,r),new Td(t+1,i,r)],this.cmdHistory=Sd(),this.logger=r}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let i,r,n,a=!1;this.logger.time=t;for(let o=0;o<e.length;o+=2)if(r=e[o]&127,n=e[o+1]&127,!(r===0&&n===0)){if(this.logger.log(3,"["+oi([e[o],e[o+1]])+"] -> ("+oi([r,n])+")"),i=this.parseCmd(r,n),i||(i=this.parseMidrow(r,n)),i||(i=this.parsePAC(r,n)),i||(i=this.parseBackgroundAttributes(r,n)),!i&&(a=this.parseChars(r,n),a)){const l=this.currentChannel;l&&l>0?this.channels[l].insertChars(a):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!i&&!a&&this.logger.log(2,"Couldn't parse cleaned data "+oi([r,n])+" orig: "+oi([e[o],e[o+1]]))}}parseCmd(t,e){const{cmdHistory:i}=this,r=(t===20||t===28||t===21||t===29)&&e>=32&&e<=47,n=(t===23||t===31)&&e>=33&&e<=35;if(!(r||n))return!1;if(wd(t,e,i))return Di(null,null,i),this.logger.log(3,"Repeated command ("+oi([t,e])+") is dropped"),!0;const a=t===20||t===21||t===23?1:2,o=this.channels[a];return t===20||t===21||t===28||t===29?e===32?o.ccRCL():e===33?o.ccBS():e===34?o.ccAOF():e===35?o.ccAON():e===36?o.ccDER():e===37?o.ccRU(2):e===38?o.ccRU(3):e===39?o.ccRU(4):e===40?o.ccFON():e===41?o.ccRDC():e===42?o.ccTR():e===43?o.ccRTD():e===44?o.ccEDM():e===45?o.ccCR():e===46?o.ccENM():e===47&&o.ccEOC():o.ccTO(e-32),Di(t,e,i),this.currentChannel=a,!0}parseMidrow(t,e){let i=0;if((t===17||t===25)&&e>=32&&e<=47){if(t===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const r=this.channels[i];return r?(r.ccMIDROW(e),this.logger.log(3,"MIDROW ("+oi([t,e])+")"),!0):!1}return!1}parsePAC(t,e){let i;const r=this.cmdHistory,n=(t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127,a=(t===16||t===24)&&e>=64&&e<=95;if(!(n||a))return!1;if(wd(t,e,r))return Di(null,null,r),!0;const o=t<=23?1:2;e>=64&&e<=95?i=o===1?gv[t]:vv[t]:i=o===1?mv[t]:yv[t];const l=this.channels[o];return l?(l.setPAC(this.interpretPAC(i,e)),Di(t,e,r),this.currentChannel=o,!0):!1}interpretPAC(t,e){let i;const r={color:null,italics:!1,indent:null,underline:!1,row:t};return e>95?i=e-96:i=e-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=!0,r.color="white"):r.indent=Math.floor((i-16)/2)*4,r}parseChars(t,e){let i,r=null,n=null;if(t>=25?(i=2,n=t-8):(i=1,n=t),n>=17&&n<=19){let a;n===17?a=e+80:n===18?a=e+112:a=e+144,this.logger.log(2,"Special char '"+bd(a)+"' in channel "+i),r=[a]}else t>=32&&t<=127&&(r=e===0?[t]:[t,e]);if(r){const a=oi(r);this.logger.log(3,"Char codes = "+a.join(",")),Di(t,e,this.cmdHistory)}return r}parseBackgroundAttributes(t,e){const i=(t===16||t===24)&&e>=32&&e<=47,r=(t===23||t===31)&&e>=45&&e<=47;if(!(i||r))return!1;let n;const a={};t===16||t===24?(n=Math.floor((e-32)/2),a.background=bv[n],e%2===1&&(a.background=a.background+"_semi")):e===45?a.background="transparent":(a.foreground="black",e===47&&(a.underline=!0));const o=t<=23?1:2;return this.channels[o].setBkgData(a),Di(t,e,this.cmdHistory),!0}reset(){for(let t=0;t<Object.keys(this.channels).length;t++){const e=this.channels[t];e&&e.reset()}this.cmdHistory=Sd()}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const i=this.channels[e];i&&i.cueSplitAtTime(t)}}}function Di(s,t,e){e.a=s,e.b=t}function wd(s,t,e){return e.a===s&&e.b===t}function Sd(){return{a:null,b:null}}class Ts{constructor(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(t,e,i){(this.startTime===null||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Ea=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const s=["","lr","rl"],t=["start","middle","end","left","right"];function e(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;const h=l.toLowerCase();return~o.indexOf(h)?h:!1}function i(o){return e(s,o)}function r(o){return e(t,o)}function n(o,...l){let h=1;for(;h<arguments.length;h++){const d=arguments[h];for(const c in d)o[c]=d[c]}return o}function a(o,l,h){const d=this,c={enumerable:!0};d.hasBeenReset=!1;let u="",f=!1,p=o,g=l,m=h,b=null,A="",T=!0,y="auto",w="start",S=50,L="middle",C=50,k="middle";Object.defineProperty(d,"id",n({},c,{get:function(){return u},set:function(x){u=""+x}})),Object.defineProperty(d,"pauseOnExit",n({},c,{get:function(){return f},set:function(x){f=!!x}})),Object.defineProperty(d,"startTime",n({},c,{get:function(){return p},set:function(x){if(typeof x!="number")throw new TypeError("Start time must be set to a number.");p=x,this.hasBeenReset=!0}})),Object.defineProperty(d,"endTime",n({},c,{get:function(){return g},set:function(x){if(typeof x!="number")throw new TypeError("End time must be set to a number.");g=x,this.hasBeenReset=!0}})),Object.defineProperty(d,"text",n({},c,{get:function(){return m},set:function(x){m=""+x,this.hasBeenReset=!0}})),Object.defineProperty(d,"region",n({},c,{get:function(){return b},set:function(x){b=x,this.hasBeenReset=!0}})),Object.defineProperty(d,"vertical",n({},c,{get:function(){return A},set:function(x){const N=i(x);if(N===!1)throw new SyntaxError("An invalid or illegal string was specified.");A=N,this.hasBeenReset=!0}})),Object.defineProperty(d,"snapToLines",n({},c,{get:function(){return T},set:function(x){T=!!x,this.hasBeenReset=!0}})),Object.defineProperty(d,"line",n({},c,{get:function(){return y},set:function(x){if(typeof x!="number"&&x!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");y=x,this.hasBeenReset=!0}})),Object.defineProperty(d,"lineAlign",n({},c,{get:function(){return w},set:function(x){const N=r(x);if(!N)throw new SyntaxError("An invalid or illegal string was specified.");w=N,this.hasBeenReset=!0}})),Object.defineProperty(d,"position",n({},c,{get:function(){return S},set:function(x){if(x<0||x>100)throw new Error("Position must be between 0 and 100.");S=x,this.hasBeenReset=!0}})),Object.defineProperty(d,"positionAlign",n({},c,{get:function(){return L},set:function(x){const N=r(x);if(!N)throw new SyntaxError("An invalid or illegal string was specified.");L=N,this.hasBeenReset=!0}})),Object.defineProperty(d,"size",n({},c,{get:function(){return C},set:function(x){if(x<0||x>100)throw new Error("Size must be between 0 and 100.");C=x,this.hasBeenReset=!0}})),Object.defineProperty(d,"align",n({},c,{get:function(){return k},set:function(x){const N=r(x);if(!N)throw new SyntaxError("An invalid or illegal string was specified.");k=N,this.hasBeenReset=!0}})),d.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}();class wv{decode(t,e){if(!t)return"";if(typeof t!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function Ld(s){function t(i,r,n,a){return(i|0)*3600+(r|0)*60+(n|0)+parseFloat(a||0)}const e=s.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?t(e[2],e[3],0,e[4]):t(e[1],e[2],e[3],e[4]):null}class Sv{constructor(){this.values=Object.create(null)}set(t,e){!this.get(t)&&e!==""&&(this.values[t]=e)}get(t,e,i){return i?this.has(t)?this.values[t]:e[i]:this.has(t)?this.values[t]:e}has(t){return t in this.values}alt(t,e,i){for(let r=0;r<i.length;++r)if(e===i[r]){this.set(t,e);break}}integer(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))}percent(t,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){const i=parseFloat(e);if(i>=0&&i<=100)return this.set(t,i),!0}return!1}}function Rd(s,t,e,i){const r=i?s.split(i):[s];for(const n in r){if(typeof r[n]!="string")continue;const a=r[n].split(e);if(a.length!==2)continue;const o=a[0],l=a[1];t(o,l)}}const wa=new Ea(0,0,""),Es=wa.align==="middle"?"middle":"center";function Lv(s,t,e){const i=s;function r(){const o=Ld(s);if(o===null)throw new Error("Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){const h=new Sv;Rd(o,function(u,f){let p;switch(u){case"region":for(let g=e.length-1;g>=0;g--)if(e[g].id===f){h.set(u,e[g].region);break}break;case"vertical":h.alt(u,f,["rl","lr"]);break;case"line":p=f.split(","),h.integer(u,p[0]),h.percent(u,p[0])&&h.set("snapToLines",!1),h.alt(u,p[0],["auto"]),p.length===2&&h.alt("lineAlign",p[1],["start",Es,"end"]);break;case"position":p=f.split(","),h.percent(u,p[0]),p.length===2&&h.alt("positionAlign",p[1],["start",Es,"end","line-left","line-right","auto"]);break;case"size":h.percent(u,f);break;case"align":h.alt(u,f,["start",Es,"end","left","right"]);break}},/:/,/\s/),l.region=h.get("region",null),l.vertical=h.get("vertical","");let d=h.get("line","auto");d==="auto"&&wa.line===-1&&(d=-1),l.line=d,l.lineAlign=h.get("lineAlign","start"),l.snapToLines=h.get("snapToLines",!0),l.size=h.get("size",100),l.align=h.get("align",Es);let c=h.get("position","auto");c==="auto"&&wa.position===50&&(c=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=c}function a(){s=s.replace(/^\s+/,"")}if(a(),t.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(),t.endTime=r(),a(),n(s,t)}function xd(s){return s.replace(/<br(?: \/)?>/gi,`
|
133
|
-
`)}class Rv{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new wv,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const e=this;t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));function i(){let n=e.buffer,a=0;for(n=xd(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
|
134
|
-
`;)++a;const o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
|
135
|
-
`&&++a,e.buffer=n.slice(a),o}function r(n){Rd(n,function(a,o){},/:/)}try{let n="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;n=i();const o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");e.state="HEADER"}let a=!1;for(;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(a?a=!1:n=i(),e.state){case"HEADER":/:/.test(n)?r(n):n||(e.state="ID");continue;case"NOTE":n||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){e.state="NOTE";break}if(!n)continue;if(e.cue=new Ea(0,0,""),e.state="CUE",n.indexOf("-->")===-1){e.cue.id=n;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{Lv(n,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{const o=n.indexOf("-->")!==-1;if(!n||o&&(a=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
|
136
|
-
`),e.cue.text+=n}continue;case"BADCUE":n||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const t=this;try{if((t.cue||t.state==="HEADER")&&(t.buffer+=`
|
137
|
-
|
138
|
-
`,t.parse()),t.state==="INITIAL"||t.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){t.onparsingerror&&t.onparsingerror(e)}return t.onflush&&t.onflush(),this}}const xv=/\r\n|\n\r|\n|\r/g,Sa=function(s,t,e=0){return s.slice(e,e+t.length)===t},kv=function(s){let t=parseInt(s.slice(-3));const e=parseInt(s.slice(-6,-4)),i=parseInt(s.slice(-9,-7)),r=s.length>9?parseInt(s.substring(0,s.indexOf(":"))):0;if(!K(t)||!K(e)||!K(i)||!K(r))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${s}`);return t+=1e3*e,t+=60*1e3*i,t+=60*60*1e3*r,t},La=function(s){let t=5381,e=s.length;for(;e;)t=t*33^s.charCodeAt(--e);return(t>>>0).toString()};function Ra(s,t,e){return La(s.toString())+La(t.toString())+La(e)}const Dv=function(s,t,e){let i=s[t],r=s[i.prevCC];if(!r||!r.new&&i.new){s.ccOffset=s.presentationOffset=i.start,i.new=!1;return}for(;(n=r)!=null&&n.new;){var n;s.ccOffset+=i.start-r.start,i.new=!1,i=r,r=s[i.prevCC]}s.presentationOffset=e};function Cv(s,t,e,i,r,n,a){const o=new Rv,l=ge(new Uint8Array(s)).trim().replace(xv,`
|
139
|
-
`).split(`
|
140
|
-
`),h=[],d=t?Vm(t.baseTime,t.timescale):0;let c="00:00.000",u=0,f=0,p,g=!0;o.oncue=function(m){const b=e[i];let A=e.ccOffset;const T=(u-d)/9e4;if(b!=null&&b.new&&(f!==void 0?A=e.ccOffset=b.start:Dv(e,i,T)),T){if(!t){p=new Error("Missing initPTS for VTT MPEGTS");return}A=T-e.presentationOffset}const y=m.endTime-m.startTime,w=te((m.startTime+A-f)*9e4,r*9e4)/9e4;m.startTime=Math.max(w,0),m.endTime=Math.max(w+y,0);const S=m.text.trim();m.text=decodeURIComponent(encodeURIComponent(S)),m.id||(m.id=Ra(m.startTime,m.endTime,S)),m.endTime>0&&h.push(m)},o.onparsingerror=function(m){p=m},o.onflush=function(){if(p){a(p);return}n(h)},l.forEach(m=>{if(g)if(Sa(m,"X-TIMESTAMP-MAP=")){g=!1,m.slice(16).split(",").forEach(b=>{Sa(b,"LOCAL:")?c=b.slice(6):Sa(b,"MPEGTS:")&&(u=parseInt(b.slice(7)))});try{f=kv(c)/1e3}catch(b){p=b}return}else m===""&&(g=!1);o.parse(m+`
|
141
|
-
`)}),o.flush()}const xa="stpp.ttml.im1t",kd=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Dd=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Iv={left:"start",center:"center",right:"end",start:"start",end:"end"};function Cd(s,t,e,i){const r=et(new Uint8Array(s),["mdat"]);if(r.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const n=r.map(o=>ge(o)),a=Gm(t.baseTime,1,t.timescale);try{n.forEach(o=>e(Pv(o,a)))}catch(o){i(o)}}function Pv(s,t){const e=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("tt")[0];if(!e)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},r=Object.keys(i).reduce((h,d)=>(h[d]=e.getAttribute(`ttp:${d}`)||i[d],h),{}),n=e.getAttribute("xml:space")!=="preserve",a=Id(ka(e,"styling","style")),o=Id(ka(e,"layout","region")),l=ka(e,"body","[begin]");return[].map.call(l,h=>{const d=Pd(h,n);if(!d||!h.hasAttribute("begin"))return null;const c=Ca(h.getAttribute("begin"),r),u=Ca(h.getAttribute("dur"),r);let f=Ca(h.getAttribute("end"),r);if(c===null)throw Od(h);if(f===null){if(u===null)throw Od(h);f=c+u}const p=new Ea(c-t,f-t,d);p.id=Ra(p.startTime,p.endTime,p.text);const g=o[h.getAttribute("region")],m=a[h.getAttribute("style")],b=Ov(g,m,a),{textAlign:A}=b;if(A){const T=Iv[A];T&&(p.lineAlign=T),p.align=A}return Et(p,b),p}).filter(h=>h!==null)}function ka(s,t,e){const i=s.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(e)):[]}function Id(s){return s.reduce((t,e)=>{const i=e.getAttribute("xml:id");return i&&(t[i]=e),t},{})}function Pd(s,t){return[].slice.call(s.childNodes).reduce((e,i,r)=>{var n;return i.nodeName==="br"&&r?e+`
|
142
|
-
`:(n=i.childNodes)!=null&&n.length?Pd(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function Ov(s,t,e){const i="http://www.w3.org/ns/ttml#styling";let r=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return a&&e.hasOwnProperty(a)&&(r=e[a]),n.reduce((o,l)=>{const h=Da(t,i,l)||Da(s,i,l)||Da(r,i,l);return h&&(o[l]=h),o},{})}function Da(s,t,e){return s&&s.hasAttributeNS(t,e)?s.getAttributeNS(t,e):null}function Od(s){return new Error(`Could not parse ttml timestamp ${s}`)}function Ca(s,t){if(!s)return null;let e=Ld(s);return e===null&&(kd.test(s)?e=Mv(s,t):Dd.test(s)&&(e=Fv(s,t))),e}function Mv(s,t){const e=kd.exec(s),i=(e[4]|0)+(e[5]|0)/t.subFrameRate;return(e[1]|0)*3600+(e[2]|0)*60+(e[3]|0)+i/t.frameRate}function Fv(s,t){const e=Dd.exec(s),i=Number(e[1]);switch(e[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}class Nv{constructor(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Md(),this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.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}},this.config.enableCEA708Captions){const e=new Ts(this,"textTrack1"),i=new Ts(this,"textTrack2"),r=new Ts(this,"textTrack3"),n=new Ts(this,"textTrack4");this.cea608Parser1=new Ed(1,e,i),this.cea608Parser2=new Ed(3,r,n)}t.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(v.FRAG_LOADING,this.onFragLoading,this),t.on(v.FRAG_LOADED,this.onFragLoaded,this),t.on(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(v.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(v.FRAG_LOADING,this.onFragLoading,this),t.off(v.FRAG_LOADED,this.onFragLoaded,this),t.off(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(v.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(t,e,i,r,n){let a=!1;for(let o=n.length;o--;){const l=n[o],h=Bv(l[0],l[1],e,i);if(h>=0&&(l[0]=Math.min(l[0],e),l[1]=Math.max(l[1],i),a=!0,h/(i-e)>.5))return}if(a||n.push([e,i]),this.config.renderTextTracksNatively){const o=this.captionsTracks[t];this.Cues.newCue(o,e,i,r)}else{const o=this.Cues.newCue(null,e,i,r);this.hls.trigger(v.CUES_PARSED,{type:"captions",cues:o,track:t})}}onInitPtsFound(t,{frag:e,id:i,initPTS:r,timescale:n}){const{unparsedVttFrags:a}=this;i==="main"&&(this.initPTS[e.cc]={baseTime:r,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(v.FRAG_LOADED,o)}))}getExistingTrack(t){const{media:e}=this;if(e)for(let i=0;i<e.textTracks.length;i++){const r=e.textTracks[i];if(r[t])return r}return null}createCaptionsTrack(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)}createNativeTrack(t){if(this.captionsTracks[t])return;const{captionsProperties:e,captionsTracks:i,media:r}=this,{label:n,languageCode:a}=e[t],o=this.getExistingTrack(t);if(o)i[t]=o,Li(i[t]),kh(i[t],r);else{const l=this.createTextTrack("captions",n,a);l&&(l[t]=!0,i[t]=l)}}createNonNativeTrack(t){if(this.nonNativeCaptionsTracks[t])return;const e=this.captionsProperties[t];if(!e)return;const i=e.label,r={_id:t,label:i,kind:"captions",default:e.media?!!e.media.default:!1,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=r,this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(t,e,i){const r=this.media;if(r)return r.addTextTrack(t,e,i)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:t}=this;Object.keys(t).forEach(e=>{Li(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Md(),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(){const{media:t}=this;if(!t)return;const e=t.textTracks;if(e)for(let i=0;i<e.length;i++)Li(e[i])}onSubtitleTracksUpdated(t,e){const i=e.subtitleTracks||[],r=i.some(n=>n.textCodec===xa);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(pd(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const n=this.media?this.media.textTracks:null;this.tracks.forEach((a,o)=>{let l;if(n&&o<n.length){let h=null;for(let d=0;d<n.length;d++)if(Uv(n[d],a)){h=n[d];break}h&&(l=h)}if(l)Li(l);else{const h=this._captionsOrSubtitlesFromCharacteristics(a);l=this.createTextTrack(h,a.name,a.lang),l&&(l.mode="disabled")}l&&(l.groupId=a.groupId,this.textTracks.push(l))})}else if(this.tracks.length){const n=this.tracks.map(a=>({label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}));this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:n})}}}_captionsOrSubtitlesFromCharacteristics(t){if(t.attrs.CHARACTERISTICS){const e=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(e&&i)return"captions"}return"subtitles"}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach(i=>{const r=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!r)return;const n=`textTrack${r[1]}`,a=this.captionsProperties[n];a&&(a.label=i.name,i.lang&&(a.languageCode=i.lang),a.media=i)})}closedCaptionsForLevel(t){const e=this.hls.levels[t.level];return e==null?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){const{cea608Parser1:i,cea608Parser2:r,lastSn:n,lastPartIndex:a}=this;if(!(!this.enabled||!(i&&r))&&e.frag.type===X.MAIN){var o,l;const h=e.frag.sn,d=(o=e==null||(l=e.part)==null?void 0:l.index)!=null?o:-1;h===n+1||h===n&&d===a+1||(i.reset(),r.reset()),this.lastSn=h,this.lastPartIndex=d}}onFragLoaded(t,e){const{frag:i,payload:r}=e;if(i.type===X.SUBTITLE)if(r.byteLength){const n=i.decryptdata,a="stats"in e;if(n==null||!n.encrypted||a){const o=this.tracks[i.level],l=this.vttCCs;l[i.cc]||(l[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===xa?this._parseIMSC1(i,r):this._parseVTTs(e)}}else this.hls.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const i=this.hls;Cd(e,this.initPTS[t.cc],r=>{this._appendCues(r,t.level),i.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},r=>{R.log(`Failed to parse IMSC1: ${r}`),i.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:r})})}_parseVTTs(t){var e;const{frag:i,payload:r}=t,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[i.cc]&&o===-1){a.push(t);return}const l=this.hls,h=(e=i.initSegment)!=null&&e.data?ai(i.initSegment.data,new Uint8Array(r)):r;Cv(h,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,d=>{this._appendCues(d,i.level),l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},d=>{const c=d.message==="Missing initPTS for VTT MPEGTS";c?a.push(t):this._fallbackToIMSC1(i,r),R.log(`Failed to parse VTT cue: ${d}`),!(c&&o>i.cc)&&l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:d})})}_fallbackToIMSC1(t,e){const i=this.tracks[t.level];i.textCodec||Cd(e,this.initPTS[t.cc],()=>{i.textCodec=xa,this._parseIMSC1(t,e)},()=>{i.textCodec="wvtt"})}_appendCues(t,e){const i=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[e];if(!r||r.mode==="disabled")return;t.forEach(n=>Dh(r,n))}else{const r=this.tracks[e];if(!r)return;const n=r.default?"default":"subtitles"+e;i.trigger(v.CUES_PARSED,{type:"subtitles",cues:t,track:n})}}onFragDecrypted(t,e){const{frag:i}=e;i.type===X.SUBTITLE&&this.onFragLoaded(v.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){const{cea608Parser1:i,cea608Parser2:r}=this;if(!this.enabled||!(i&&r))return;const{frag:n,samples:a}=e;if(!(n.type===X.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){const l=a[o].bytes;if(l){const h=this.extractCea608Data(l);i.addData(a[o].pts,h[0]),r.addData(a[o].pts,h[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:i,endOffsetSubtitles:r,type:n}){const{media:a}=this;if(!(!a||a.currentTime<i)){if(!n||n==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(l=>Zn(o[l],e,i))}if(this.config.renderTextTracksNatively&&e===0&&r!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(l=>Zn(o[l],e,r))}}}extractCea608Data(t){const e=[[],[]],i=t[0]&31;let r=2;for(let n=0;n<i;n++){const a=t[r++],o=127&t[r++],l=127&t[r++];if(!(o===0&&l===0)&&4&a){const h=3&a;(h===0||h===1)&&(e[h].push(o),e[h].push(l))}}return e}}function Uv(s,t){return!!s&&s.label===t.name&&!(s.textTrack1||s.textTrack2)}function Bv(s,t,e,i){return Math.min(t,i)-Math.max(s,e)}function Md(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class Ia{constructor(t){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=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(t){this.streamController=t}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:t}=this;t.on(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(v.MANIFEST_PARSED,this.onManifestParsed,this),t.on(v.BUFFER_CODECS,this.onBufferCodecs,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(v.MANIFEST_PARSED,this.onManifestParsed,this),t.off(v.BUFFER_CODECS,this.onBufferCodecs,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const i=this.hls.levels[e.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null}onManifestParsed(t,e){const i=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,i.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onBufferCodecs(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const t=this.hls.levels;if(t.length){const e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}}getMaxLevel(t){const e=this.hls.levels;if(!e.length)return-1;const i=e.filter((r,n)=>this.isLevelAllowed(r)&&n<=t);return this.clientRect=null,Ia.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),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;const t=this.media,e={width:0,height:0};if(t){const i=t.getBoundingClientRect();e.width=i.width,e.height=i.height,!e.width&&!e.height&&(e.width=i.right-i.left||t.width||0,e.height=i.bottom-i.top||t.height||0)}return this.clientRect=e,e}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch{}return t}isLevelAllowed(t){return!this.restrictedLevels.some(e=>t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height)}static getMaxLevelByMediaSize(t,e,i){if(!(t!=null&&t.length))return-1;const r=(a,o)=>o?a.width!==o.width||a.height!==o.height:!0;let n=t.length-1;for(let a=0;a<t.length;a+=1){const o=t[a];if((o.width>=e||o.height>=i)&&r(o,t[a+1])){n=a;break}}return n}}class Hv{constructor(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const i=this.hls.config;if(i.capLevelOnFPSDrop){const r=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,i){const r=performance.now();if(e){if(this.lastTime){const n=r-this.lastTime,a=i-this.lastDroppedFrames,o=e-this.lastDecodedFrames,l=1e3*a/n,h=this.hls;if(h.trigger(v.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:i}),l>0&&a>h.config.fpsDroppedMonitoringThreshold*o){let d=h.currentLevel;R.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(h.autoLevelCapping===-1||h.autoLevelCapping>=d)&&(d=d-1,h.trigger(v.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:h.currentLevel}),h.autoLevelCapping=d,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=i,this.lastDecodedFrames=e}}checkFPSInterval(){const t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){const e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}}const ws="[eme]";class Ci{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=Ci.CDMCleanupPromise?[Ci.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=R.debug.bind(R,ws),this.log=R.log.bind(R,ws),this.warn=R.warn.bind(R,ws),this.error=R.error.bind(R,ws),this.hls=t,this.config=t.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:i}=this.config,r=e[t];if(r)return r.licenseUrl;if(t===ct.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${t}"`)}getServerCertificateUrl(t){const{drmSystems:e}=this.config,i=e[t];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const e=this.hls.levels,i=(a,o,l)=>!!a&&l.indexOf(a)===o,r=e.map(a=>a.audioCodec).filter(i),n=e.map(a=>a.videoCodec).filter(i);return r.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{const l=h=>{const d=h.shift();this.getMediaKeysPromise(d,r,n).then(c=>a({keySystem:d,mediaKeys:c})).catch(c=>{h.length?l(h):c instanceof ee?o(c):o(new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_NO_ACCESS,error:c,fatal:!0},c.message))})};l(t)})}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let r=`Configured requestMediaKeySystemAccess is not a function ${i}`;return ih===null&&self.location.protocol==="http:"&&(r=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(r))}return i(t,e)}getMediaKeysPromise(t,e,i){const r=$p(t,e,i,this.config.drmSystemOptions),n=this.keySystemAccessPromises[t];let a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${t}" key-system access with config: ${JSON.stringify(r)}`),a=this.requestMediaKeySystemAccess(t,r);const o=this.keySystemAccessPromises[t]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${t}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const h=this.fetchServerCertificate(t);return this.log(`Create media-keys for "${t}"`),o.mediaKeys=l.createMediaKeys().then(d=>(this.log(`Media-keys created for "${t}"`),h.then(c=>c?this.setMediaKeysServerCertificate(d,t,c):d))),o.mediaKeys.catch(d=>{this.error(`Failed to create media-keys for "${t}"}: ${d}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:i}){this.log(`Creating key-system session "${e}" keyId: ${me.hexDump(t.keyId||[])}`);const r=i.createSession(),n={decryptdata:t,keySystem:e,mediaKeys:i,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const i=this.createMediaKeySessionContext(t),r=this.getKeyIdString(e),n="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(i,n,e.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)}getKeyIdString(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(t.keyId===null)throw new Error("keyId is null");return me.hexDump(t.keyId)}updateKeySession(t,e){var i;const r=t.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyID ${me.hexDump(((i=t.decryptdata)==null?void 0:i.keyId)||[])}
|
143
|
-
} (data length: ${e&&e.byteLength})`),r.update(e)}selectKeySystemFormat(t){const e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${t.sn} ${t.type}: ${t.level}) key formats ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise}getKeyFormatPromise(t){return new Promise((e,i)=>{const r=jn(this.config),n=t.map($l).filter(a=>!!a&&r.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{const o=eh(a);o?e(o):i(new Error(`Unable to find format for key-system "${a}"`))}).catch(i)})}loadKey(t){const e=t.keyInfo.decryptdata,i=this.getKeyIdString(e),r=`(keyId: ${i} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${r}`);let n=this.keyIdToKeySessionPromise[i];return n||(n=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(e).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${r}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();const l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:e}),h="cenc";return this.generateRequestWithPreferredKeySession(l,h,e.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof ee?this.hls.trigger(v.ERROR,t.data):this.hls.trigger(v.ERROR,{type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const r=$l(t.keyFormat),n=r?[r]:jn(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=jn(this.config)),t.length===0)throw new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(t)}_onMediaEncrypted(t){const{initDataType:e,initData:i}=t;if(this.debug(`"${t.type}" event: init data type: "${e}"`),i===null)return;let r,n;if(e==="sinf"&&this.config.drmSystems[ct.FAIRPLAY]){const d=Ct(new Uint8Array(i));try{const c=Vn(JSON.parse(d).sinf),u=dh(new Uint8Array(c));if(!u)return;r=u.subarray(8,24),n=ct.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const d=wg(i);if(d===null)return;d.version===0&&d.systemId===th.WIDEVINE&&d.data&&(r=d.data.subarray(8,24)),n=_p(d.systemId)}if(!n||!r)return;const a=me.hexDump(r),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this;let h=o[a];for(let d=0;d<l.length;d++){const c=l[d],u=c.decryptdata;if(u.pssh||!u.keyId)continue;const f=me.hexDump(u.keyId);if(a===f||u.uri.replace(/-/g,"").indexOf(a)!==-1){h=o[f],delete o[f],u.pssh=new Uint8Array(i),u.keyId=r,h=o[a]=h.then(()=>this.generateRequestWithPreferredKeySession(c,e,i,"encrypted-event-key-match"));break}}h||(h=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:d,mediaKeys:c})=>{var u;this.throwIfDestroyed();const f=new mr("ISO-23001-7",a,(u=eh(d))!=null?u:"");return f.pssh=new Uint8Array(i),f.keyId=r,this.attemptSetMediaKeys(d,c).then(()=>{this.throwIfDestroyed();const p=this.createMediaKeySessionContext({decryptdata:f,keySystem:d,mediaKeys:c});return this.generateRequestWithPreferredKeySession(p,e,i,"encrypted-event-no-match")})})),h.catch(d=>this.handleError(d))}_onWaitingForKey(t){this.log(`"${t.type}" event`)}attemptSetMediaKeys(t,e){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const r=Promise.all(i).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(e)});return this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${t}"`),i.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>i.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(t,e,i,r){var n,a;const o=(n=this.config.drmSystems)==null||(a=n[t.keySystem])==null?void 0:a.generateRequest;if(o)try{const u=o.call(this.hls,e,i,t);if(!u)throw new Error("Invalid response from configured generateRequest filter");e=u.initDataType,i=t.decryptdata.pssh=u.initData?new Uint8Array(u.initData):null}catch(u){var l;if(this.warn(u.message),(l=this.hls)!=null&&l.config.debug)throw u}if(i===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(t);const h=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${r}": ${h} (init data type: ${e} length: ${i?i.byteLength:null})`);const d=new va;t.mediaKeysSession.onmessage=u=>{const f=t.mediaKeysSession;if(!f){d.emit("error",new Error("invalid state"));return}const{messageType:p,message:g}=u;this.log(`"${p}" message event for session "${f.sessionId}" message size: ${g.byteLength}`),p==="license-request"||p==="license-renewal"?this.renewLicense(t,g).catch(m=>{this.handleError(m),d.emit("error",m)}):p==="license-release"?t.keySystem===ct.FAIRPLAY&&(this.updateKeySession(t,_l("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${p}"`)},t.mediaKeysSession.onkeystatuseschange=u=>{if(!t.mediaKeysSession){d.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(t);const f=t.keyStatus;d.emit("keyStatus",f),f==="expired"&&(this.warn(`${t.keySystem} expired for key ${h}`),this.renewKeySession(t))};const c=new Promise((u,f)=>{d.on("error",f),d.on("keyStatus",p=>{p.startsWith("usable")?u():p==="output-restricted"?f(new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):p==="internal-error"?f(new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${p}"`)):p==="expired"?f(new Error("key expired while generating request")):this.warn(`unhandled key status change "${p}"`)})});return t.mediaKeysSession.generateRequest(e,i).then(()=>{var u;this.log(`Request generated for key-session "${(u=t.mediaKeysSession)==null?void 0:u.sessionId}" keyId: ${h}`)}).catch(u=>{throw new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_NO_SESSION,error:u,fatal:!1},`Error generating key-session request: ${u}`)}).then(()=>c).catch(u=>{throw d.removeAllListeners(),this.removeSession(t),u}).then(()=>(d.removeAllListeners(),t))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach((e,i)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${me.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${me.hexDump(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e})}fetchServerCertificate(t){const e=this.config,i=e.loader,r=new i(e),n=this.getServerCertificateUrl(t);return n?(this.log(`Fetching serverCertificate for "${t}"`),new Promise((a,o)=>{const l={responseType:"arraybuffer",url:n},h=e.certLoadPolicy.default,d={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(u,f,p,g)=>{a(u.data)},onError:(u,f,p,g)=>{o(new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:p,response:jt({url:l.url,data:void 0},u)},`"${t}" certificate request failed (${n}). Status: ${u.code} (${u.text})`))},onTimeout:(u,f,p)=>{o(new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:p,response:{url:l.url,data:void 0}},`"${t}" certificate request timed out (${n})`))},onAbort:(u,f,p)=>{o(new Error("aborted"))}};r.load(l,d,c)})):Promise.resolve()}setMediaKeysServerCertificate(t,e,i){return new Promise((r,n)=>{t.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${e}"`),r(t)}).catch(a=>{n(new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then(i=>this.updateKeySession(t,new Uint8Array(i)).catch(r=>{throw new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:r,fatal:!0},r.message)}))}setupLicenseXHR(t,e,i,r){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return n.call(this.hls,t,e,i,r)}).catch(a=>{if(!i.decryptdata)throw a;return t.open("POST",e,!0),n.call(this.hls,t,e,i,r)}).then(a=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:a||r})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:r}))}requestLicense(t,e){const i=this.config.keyLoadPolicy.default;return new Promise((r,n)=>{const a=this.getLicenseServerUrl(t.keySystem);this.log(`Sending license request to URL: ${a}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!t.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}`);const h=this.config.licenseResponseCallback;if(h)try{l=h.call(this.hls,o,a,t)}catch(d){this.error(d)}r(l)}else{const l=i.errorRetry,h=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>h||o.status>=400&&o.status<500)n(new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{const d=h-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${d} attempts left`),this.requestLicense(t,e).then(r,n)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=o,this.setupLicenseXHR(o,a,t,e).then(({xhr:l,licenseChallenge:h})=>{l.send(h)})})}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const i=e.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const t=this.media,e=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},mr.clearKeyUriToKeyIdMap();const i=e.length;Ci.CDMCleanupPromise=Promise.all(e.map(r=>this.removeSession(r)).concat(t==null?void 0:t.setMediaKeys(null).catch(r=>{this.log(`Could not clear media keys: ${r}. media.src: ${t==null?void 0:t.src}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)}).catch(r=>{this.log(`Could not close sessions and clear media keys: ${r}. media.src: ${t==null?void 0:t.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(t,{sessionKeys:e}){if(!(!e||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=e.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(t){const{mediaKeysSession:e,licenseXhr:i}=t;if(e){this.log(`Remove licenses and keys and close session ${e.sessionId}`),e.onmessage=null,e.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(t);return r>-1&&this.mediaKeySessions.splice(r,1),e.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>e.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}}Ci.CDMCleanupPromise=void 0;class ee extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),this.data=t,t.err=t.error}}const Gv=1;var Wt={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const Vv="h";class Ue{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=r=>{try{this.apply(r,{ot:Wt.MANIFEST,su:!this.initialized})}catch(n){R.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=r=>{try{const n=r.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===Wt.VIDEO||o===Wt.AUDIO||o==Wt.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(r,l)}catch(n){R.warn("Could not generate segment CMCD data.",n)}},this.hls=t;const e=this.config=t.config,{cmcd:i}=e;i!=null&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||Ue.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}registerListeners(){const t=this.hls;t.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(v.MEDIA_DETACHED,this.onMediaDetached,this),t.on(v.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(v.MEDIA_DETACHED,this.onMediaDetached,this),t.off(v.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(t,e){this.media=e.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(t,e){var i,r;this.audioBuffer=(i=e.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(r=e.tracks.video)==null?void 0:r.buffer}createData(){var t;return{v:Gv,sf:Vv,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){Et(e,this.createData());const i=e.ot===Wt.INIT||e.ot===Wt.VIDEO||e.ot===Wt.MUXED;if(this.starved&&i&&(e.bs=!0,e.su=!0,this.starved=!1),e.su==null&&(e.su=this.buffering),this.useHeaders){const r=Ue.toHeaders(e);if(!Object.keys(r).length)return;t.headers||(t.headers={}),Et(t.headers,r)}else{const r=Ue.toQuery(e);if(!r)return;t.url=Ue.appendQueryToUri(t.url,r)}}getObjectType(t){const{type:e}=t;if(e==="subtitle")return Wt.TIMED_TEXT;if(t.sn==="initSegment")return Wt.INIT;if(e==="audio")return Wt.AUDIO;if(e==="main")return this.hls.audioTracks.length?Wt.VIDEO:Wt.MUXED}getTopBandwidth(t){let e=0,i;const r=this.hls;if(t===Wt.AUDIO)i=r.audioTracks;else{const n=r.maxAutoLevel,a=n>-1?n+1:r.levels.length;i=r.levels.slice(0,a)}for(const n of i)n.bitrate>e&&(e=n.bitrate);return e>0?e:NaN}getBufferLength(t){const e=this.hls.media,i=t===Wt.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!e?NaN:lt.bufferInfo(i,e.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,i=t||this.config.loader;return class{constructor(r){this.loader=void 0,this.loader=new i(r)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(r,n,a){e(r),this.loader.load(r,n,a)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,i=t||this.config.loader;return class{constructor(r){this.loader=void 0,this.loader=new i(r)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(r,n,a){e(r),this.loader.load(r,n,a)}}}static uuid(){const t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}static serialize(t){const e=[],i=l=>!Number.isNaN(l)&&l!=null&&l!==""&&l!==!1,r=l=>Math.round(l),n=l=>r(l/100)*100,a={br:r,d:r,bl:n,dl:n,mtp:n,nor:l=>encodeURIComponent(l),rtp:n,tb:r},o=Object.keys(t||{}).sort();for(const l of o){let h=t[l];if(!i(h)||l==="v"&&h===1||l=="pr"&&h===1)continue;const d=a[l];d&&(h=d(h));const c=typeof h;let u;l==="ot"||l==="sf"||l==="st"?u=`${l}=${h}`:c==="boolean"?u=l:c==="number"?u=`${l}=${h}`:u=`${l}=${JSON.stringify(h)}`,e.push(u)}return e.join(",")}static toHeaders(t){const e=Object.keys(t),i={},r=["Object","Request","Session","Status"],n=[{},{},{},{}],a={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const o of e){const l=a[o]!=null?a[o]:1;n[l][o]=t[o]}for(let o=0;o<n.length;o++){const l=Ue.serialize(n[o]);l&&(i[`CMCD-${r[o]}`]=l)}return i}static toQuery(t){return`CMCD=${encodeURIComponent(Ue.serialize(t))}`}static appendQueryToUri(t,e){if(!e)return t;const i=t.includes("?")?"&":"?";return`${t}${i}${e}`}}const jv=3e5;class zv{constructor(t){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=t,this.log=R.log.bind(R,"[content-steering]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(v.MANIFEST_PARSED,this.onManifestParsed,this),t.on(v.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(v.MANIFEST_PARSED,this.onManifestParsed,this),t.off(v.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const t=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,t)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){const e=this.levels;e&&(this.levels=e.filter(i=>i!==t))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(t,e){const{contentSteering:i}=e;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:i}=e;if((i==null?void 0:i.action)===Ft.SendAlternateToPenaltyBox&&i.flags===$t.MoveAllAlternatesMatchingHost){let r=this.pathwayPriority;const n=this.pathwayId;this.penalizedPathways[n]||(this.penalizedPathways[n]=performance.now()),!r&&this.levels&&(r=this.levels.reduce((a,o)=>(a.indexOf(o.pathwayId)===-1&&a.push(o.pathwayId),a),[])),r&&r.length>1&&(this.updatePathwayPriority(r),i.resolved=this.pathwayId!==n)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);if(e.length===0){const i=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),e=this.getLevelsForPathway(i),this.pathwayId=i}return e.length!==t.length?(this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e):t}getLevelsForPathway(t){return this.levels===null?[]:this.levels.filter(e=>t===e.pathwayId)}updatePathwayPriority(t){this.pathwayPriority=t;let e;const i=this.penalizedPathways,r=performance.now();Object.keys(i).forEach(n=>{r-i[n]>jv&&delete i[n]});for(let n=0;n<t.length;n++){const a=t[n];if(i[a])continue;if(a===this.pathwayId)return;const o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(e=this.getLevelsForPathway(a),e.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,this.hls.trigger(v.LEVELS_UPDATED,{levels:e});const h=this.hls.levels[o];l&&h&&this.levels&&(h.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&h.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${h.bitrate}`),this.hls.nextLoadLevel=o);break}}}clonePathways(t){const e=this.levels;if(!e)return;const i={},r={};t.forEach(n=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(e.some(d=>d.pathwayId===a))return;const h=this.getLevelsForPathway(o).map(d=>{const c=Et({},d);c.details=void 0,c.url=Nd(d.uri,d.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l);const u=new dt(d.attrs);u["PATHWAY-ID"]=a;const f=u.AUDIO&&`${u.AUDIO}_clone_${a}`,p=u.SUBTITLES&&`${u.SUBTITLES}_clone_${a}`;f&&(i[u.AUDIO]=f,u.AUDIO=f),p&&(r[u.SUBTITLES]=p,u.SUBTITLES=p),c.attrs=u;const g=new yr(c);return fs(g,"audio",f),fs(g,"text",p),g});e.push(...h),Fd(this.audioTracks,i,l,a),Fd(this.subtitleTracks,r,l,a)})}loadSteeringManifest(t){const e=this.hls.config,i=e.loader;this.loader&&this.loader.destroy(),this.loader=new i(e);let r;try{r=new self.URL(t)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${t}`);return}if(r.protocol!=="data:"){const d=(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+d)}const n={responseType:"json",url:r.href},a=e.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},h={onSuccess:(d,c,u,f)=>{this.log(`Loaded steering manifest: "${r}"`);const p=d.data;if(p.VERSION!==1){this.log(`Steering VERSION ${p.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=p.TTL;const{"RELOAD-URI":g,"PATHWAY-CLONES":m,"PATHWAY-PRIORITY":b}=p;if(g)try{this.uri=new self.URL(g,r).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${g}`);return}this.scheduleRefresh(this.uri||u.url),m&&this.clonePathways(m),b&&this.updatePathwayPriority(b)},onError:(d,c,u,f)=>{if(this.log(`Error loading steering manifest: ${d.code} ${d.text} (${c.url})`),this.stopLoad(),d.code===410){this.enabled=!1,this.log(`Steering manifest ${c.url} no longer available`);return}let p=this.timeToLoad*1e3;if(d.code===429){const g=this.loader;if(typeof(g==null?void 0:g.getResponseHeader)=="function"){const m=g.getResponseHeader("Retry-After");m&&(p=parseFloat(m)*1e3)}this.log(`Steering manifest ${c.url} rate limited`);return}this.scheduleRefresh(this.uri||c.url,p)},onTimeout:(d,c,u)=>{this.log(`Timeout loading steering manifest (${c.url})`),this.scheduleRefresh(this.uri||c.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(n,l,h)}scheduleRefresh(t,e=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(t)},e)}}function Fd(s,t,e,i){s&&Object.keys(t).forEach(r=>{const n=s.filter(a=>a.groupId===r).map(a=>{const o=Et({},a);return o.details=void 0,o.attrs=new dt(o.attrs),o.url=o.attrs.URI=Nd(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),o.groupId=o.attrs["GROUP-ID"]=t[r],o.attrs["PATHWAY-ID"]=i,o});s.push(...n)})}function Nd(s,t,e,i){const{HOST:r,PARAMS:n,[e]:a}=i;let o;t&&(o=a==null?void 0:a[t],o&&(s=o));const l=new self.URL(s);return r&&!o&&(l.host=r),n&&Object.keys(n).sort().forEach(h=>{h&&l.searchParams.set(h,n[h])}),l.href}const Kv=/^age:\s*[\d.]+\s*$/im;class Ud{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new ss,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,e,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t)return;const i=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!this.stats.aborted)return n(i,e.url)}).catch(a=>(i.open("GET",e.url,!0),n(i,e.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,e,t)}).catch(a=>{this.callbacks.onError({code:i.status,text:a.message},e,i,r)}):this.openAndSendXhr(i,e,t)}openAndSendXhr(t,e,i){t.readyState||t.open("GET",e.url,!0);const r=this.context.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=i.loadPolicy;if(r)for(const o in r)t.setRequestHeader(o,r[o]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),i.timeout=n&&K(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:i}=this;if(!t||!e)return;const r=e.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),e.onreadystatechange=null,e.onprogress=null;const a=e.status,o=e.responseType!=="text";if(a>=200&&a<300&&(o&&e.response||e.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const l=o?e.response:e.responseText,h=e.responseType==="arraybuffer"?l.byteLength:l.length;if(i.loaded=i.total=h,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;const d=this.callbacks.onProgress;if(d&&d(i,t,l,e),!this.callbacks)return;const c={url:e.responseURL,data:l,code:a};this.callbacks.onSuccess(c,i,t,e)}else{const l=n.loadPolicy.errorRetry,h=i.retry;us(l,h,!1,a)?this.retry(l):(R.error(`${a} while loading ${t.url}`),this.callbacks.onError({code:a,text:e.statusText},t,e,i))}}}loadtimeout(){var t;const e=(t=this.config)==null?void 0:t.loadPolicy.timeoutRetry,i=this.stats.retry;if(us(e,i,!0))this.retry(e);else{R.warn(`timeout while loading ${this.context.url}`);const r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:i}=this;this.retryDelay=ea(t,i.retry),i.retry++,R.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${e.url}, retrying ${i.retry}/${t.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(t){const e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;if(this.loader&&Kv.test(this.loader.getAllResponseHeaders())){const e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}function Wv(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const Yv=/(\d+)-(\d+)\/(\d+)/;class Bd{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||Jv,this.controller=new self.AbortController,this.stats=new ss}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const t=this.response;t!=null&&t.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(t,e,i){const r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const n=Xv(t,this.controller.signal),a=i.onProgress,o=t.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:h,maxLoadTimeMs:d}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=i,this.request=this.fetchSetup(t,n),self.clearTimeout(this.requestTimeout),e.timeout=h&&K(h)?h:d,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(r,t,this.response)},e.timeout),self.fetch(this.request).then(c=>{this.response=this.loader=c;const u=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=d,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(r,t,this.response)},d-(u-r.loading.start)),!c.ok){const{status:f,statusText:p}=c;throw new Qv(p||"fetch, bad network response",f,c)}return r.loading.first=u,r.total=Zv(c.headers)||r.total,a&&K(e.highWaterMark)?this.loadProgressively(c,r,t,e.highWaterMark,a):o?c.arrayBuffer():t.responseType==="json"?c.json():c.text()}).then(c=>{const{response:u}=this;self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const f=c[l];f&&(r.loaded=r.total=f);const p={url:u.url,data:c,code:u.status};a&&!K(e.highWaterMark)&&a(r,t,c,u),i.onSuccess(p,r,t,u)}).catch(c=>{if(self.clearTimeout(this.requestTimeout),r.aborted)return;const u=c&&c.code||0,f=c?c.message:null;i.onError({code:u,text:f},t,c?c.details:null,r)})}getCacheAge(){let t=null;if(this.response){const e=this.response.headers.get("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,e,i,r=0,n){const a=new ud,o=t.body.getReader(),l=()=>o.read().then(h=>{if(h.done)return a.dataLength&&n(e,i,a.flush(),t),Promise.resolve(new ArrayBuffer(0));const d=h.value,c=d.length;return e.loaded+=c,c<r||a.dataLength?(a.push(d),a.dataLength>=r&&n(e,i,a.flush(),t)):n(e,i,d,t),l()}).catch(()=>Promise.reject());return l()}}function Xv(s,t){const e={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(Et({},s.headers))};return s.rangeEnd&&e.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),e}function qv(s){const t=Yv.exec(s);if(t)return parseInt(t[2])-parseInt(t[1])+1}function Zv(s){const t=s.get("Content-Range");if(t){const i=qv(t);if(K(i))return i}const e=s.get("Content-Length");if(e)return parseInt(e)}function Jv(s,t){return new self.Request(s.url,t)}class Qv extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const _v=/\s/,$v={newCue(s,t,e,i){const r=[];let n,a,o,l,h;const d=self.VTTCue||self.TextTrackCue;for(let u=0;u<i.rows.length;u++)if(n=i.rows[u],o=!0,l=0,h="",!n.isEmpty()){var c;for(let g=0;g<n.chars.length;g++)_v.test(n.chars[g].uchar)&&o?l++:(h+=n.chars[g].uchar,o=!1);n.cueStartTime=t,t===e&&(e+=1e-4),l>=16?l--:l++;const f=xd(h.trim()),p=Ra(t,e,f);s!=null&&(c=s.cues)!=null&&c.getCueById(p)||(a=new d(t,e,f),a.id=p,a.line=u+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),r.push(a))}return s&&r.length&&(r.sort((u,f)=>u.line==="auto"||f.line==="auto"?0:u.line>8&&f.line>8?f.line-u.line:u.line-f.line),r.forEach(u=>Dh(s,u))),r}},t0={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},e0=jt(jt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Ud,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:nv,bufferController:pv,capLevelController:Ia,errorController:Qg,fpsController:Hv,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:ih,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:t0},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},i0()),{},{subtitleStreamController:dv,subtitleTrackController:uv,timelineController:Nv,audioStreamController:ov,audioTrackController:lv,emeController:Ci,cmcdController:Ue,contentSteeringController:zv});function i0(){return{cueHandler:$v,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function r0(s,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(t.liveMaxLatencyDurationCount!==void 0&&(t.liveSyncDurationCount===void 0||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(t.liveMaxLatencyDuration!==void 0&&(t.liveSyncDuration===void 0||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const e=Pa(s),i=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(n=>{const a=`${n==="level"?"playlist":n}LoadPolicy`,o=t[a]===void 0,l=[];r.forEach(h=>{const d=`${n}Loading${h}`,c=t[d];if(c!==void 0&&o){l.push(d);const u=e[a].default;switch(t[a]={default:u},h){case"TimeOut":u.maxLoadTimeMs=c,u.maxTimeToFirstByteMs=c;break;case"MaxRetry":u.errorRetry.maxNumRetry=c,u.timeoutRetry.maxNumRetry=c;break;case"RetryDelay":u.errorRetry.retryDelayMs=c,u.timeoutRetry.retryDelayMs=c;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=c,u.timeoutRetry.maxRetryDelayMs=c;break}}}),l.length&&R.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(t[a])}`)}),jt(jt({},e),t)}function Pa(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(Pa):Object.keys(s).reduce((t,e)=>(t[e]=Pa(s[e]),t),{}):s}function s0(s){const t=s.loader;t!==Bd&&t!==Ud?(R.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):Wv()&&(s.loader=Bd,s.progressive=!0,s.enableSoftwareAES=!0,R.log("[config]: Progressive streaming enabled, using FetchLoader"))}class De{static get version(){return"1.4.12"}static isSupported(){return mm()}static get Events(){return v}static get ErrorTypes(){return Y}static get ErrorDetails(){return P}static get DefaultConfig(){return De.defaultConfig?De.defaultConfig:e0}static set DefaultConfig(t){De.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new va,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,jp(t.debug||!1,"Hls instance");const e=this.config=r0(De.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&s0(e);const{abrController:i,bufferController:r,capLevelController:n,errorController:a,fpsController:o}=e,l=new a(this),h=this.abrController=new i(this),d=this.bufferController=new r(this),c=this.capLevelController=new n(this),u=new o(this),f=new Pg(this),p=new Ug(this),g=e.contentSteeringController,m=g?new g(this):null,b=this.levelController=new $g(this,m),A=new tm(this),T=new im(this.config),y=this.streamController=new rv(this,A,T);c.setStreamController(y),u.setStreamController(y);const w=[f,b,y];m&&w.splice(1,0,m),this.networkControllers=w;const S=[h,d,c,u,p,A];this.audioTrackController=this.createController(e.audioTrackController,w);const L=e.audioStreamController;L&&w.push(new L(this,A,T)),this.subtitleTrackController=this.createController(e.subtitleTrackController,w);const C=e.subtitleStreamController;C&&w.push(new C(this,A,T)),this.createController(e.timelineController,S),T.emeController=this.emeController=this.createController(e.emeController,S),this.cmcdController=this.createController(e.cmcdController,S),this.latencyController=this.createController(Bg,S),this.coreComponents=S,w.push(l);const k=l.onErrorOut;typeof k=="function"&&this.on(v.ERROR,k,l)}createController(t,e){if(t){const i=new t(this);return e&&e.push(i),i}return null}on(t,e,i=this){this._emitter.on(t,e,i)}once(t,e,i=this){this._emitter.once(t,e,i)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,i=this,r){this._emitter.off(t,e,i,r)}listeners(t){return this._emitter.listeners(t)}emit(t,e,i){return this._emitter.emit(t,e,i)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(i){R.error("An internal error happened while handling event "+t+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(v.ERROR,{type:Y.OTHER_ERROR,details:P.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){R.log("destroy"),this.trigger(v.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;const t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){R.log("attachMedia"),this._media=t,this.trigger(v.MEDIA_ATTACHING,{media:t})}detachMedia(){R.log("detachMedia"),this.trigger(v.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,i=this.url,r=this.url=Bn.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});R.log(`loadSource:${r}`),e&&i&&(i!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(v.MANIFEST_LOADING,{url:t})}startLoad(t=-1){R.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){R.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){R.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){R.log("recoverMediaError");const t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t,e=0){this.levelController.removeLevel(t,e)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){R.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){R.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){R.log(`set loadLevel:${t}`),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){R.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){R.log(`set startLevel:${t}`),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){const e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(R.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){_n.indexOf(t)>-1&&(this._maxHdcpLevel=t)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:e}}=this;if(!t)return 0;const i=t.length;for(let r=0;r<i;r++)if(t[r].maxBitrate>=e)return r;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:i}=this;let r;if(e===-1&&t&&t.length?r=t.length-1:r=e,i)for(let n=r;n--;){const a=t[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return r}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const e=this.audioTrackController;e&&(e.audioTrack=t)}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return t?t.subtitleDisplay:!1}set subtitleDisplay(t){const e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}De.defaultConfig=void 0;function n0(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function a0(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}async function Hd(s){return s.duration===1/0?new Promise(t=>{s.currentTime=Number.MAX_SAFE_INTEGER,s.ontimeupdate=()=>{s.ontimeupdate=null,t(s.duration),s.currentTime=0}}):s.duration}class o0{constructor(t){this._duration=0,this._processing=!1,this._scenes=null,this._videos={},this._videoState={},this._resolveVideo=e=>{const{id:i,src:r,playlist:n,duration:a,captions:o,startOffset:l,endOffset:h}=e;return new Promise(d=>{let c=null;const u=document.createElement("video");if(u.playsInline=!0,u.muted=!0,u.loop=!1,u.volume=this.host.volume,u.playbackRate=this.host.playbackRate,n&&!n0()&&De.isSupported()){let f=!1;c=new De({autoStartLoad:!0,xhrSetup:p=>{const{open:g}=p,m=n.split("?")[1];p.open=function(b,A,T){A.toString().includes("?")||(A+="?"+m),g.apply(this,[b,A,T])}}}),c.loadSource(n),c.attachMedia(u),c.startLoadOnce=(p=-1)=>{c&&!f&&(c.startLoad(p),f=!0)},c.on(De.Events.LEVEL_LOADED,async()=>{f||c==null||c.stopLoad();const p=a??await Hd(u),g=(1-((e==null?void 0:e.endOffset)??0))*p;d({id:i,hls:c,duration:g,captions:o,node:u,start:(l??0)*p})})}else{u.src=r;let f=!1;if(u.startLoadOnce=()=>{f||(u.preload="auto",u.load(),f=!0)},a){u.preload="none";const p=(1-(h??0))*a;d({id:i,hls:c,duration:p,captions:o,node:u,start:(l??0)*a})}else{u.preload="metadata";const p=async()=>{const g=await Hd(u),m=(1-(h??0))*g;d({id:i,hls:c,duration:m,captions:o,node:u,start:(l??0)*g}),u.removeEventListener("loadedmetadata",p)};u.addEventListener("loadedmetadata",p)}}})},this._handleLoadedData=(e,i)=>()=>{const r=this.videoState[e];r!=null&&r.initialised||(this.videoState={...this.videoState,[e]:{...r,initialised:!0,waiting:!1,buffered:(r==null?void 0:r.buffered)??[]}},this.setVideosCurrentTime(this.host.currentTime),this.host.dispatchEvent(new CustomEvent("video:loadeddata",{detail:{id:e,node:i}})))},this._handleWaiting=e=>()=>{const i=this.videoState[e];i!=null&&i.initialised&&!(i!=null&&i.waiting)&&(this.videoState={...this.videoState,[e]:{...i,waiting:!0}})},this._handleCanPlay=e=>()=>{const i=this.videoState[e];i!=null&&i.initialised&&i!=null&&i.waiting&&(this.videoState={...this.videoState,[e]:{...i,waiting:!1}})},this._handleProgress=(e,i)=>()=>{var r;const n=i==null?void 0:i.buffered,a=[],{start:o,video:l}=((r=this.scenes)==null?void 0:r.scenes.find(({video:h})=>e===(h==null?void 0:h.id)))??{};if(i&&n&&l&&typeof o<"u"){for(let d=0;d<n.length;d++){const c=n.start(d),u=n.end(d);Math.max(c,l.start)<=Math.min(u,l.start+l.duration)&&a.push({start:Math.max(0,(Math.max(c-l.start,0)+o)/this.host.duration*100),end:Math.min((Math.min(u-l.start,l.duration)+o)/this.host.duration*100,100)})}const h=this.videoState[e];this.videoState={...this.videoState,[e]:{...h,buffered:a}}}},this._handleSeeked=(e,i)=>()=>{const r=this.videoState[e];r!=null&&r.initialised&&(this.host.draw(),this.host.dispatchEvent(new CustomEvent("video:seeked",{detail:{id:e,node:i}})))},this._handlePlay=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:play",{detail:{id:e,node:i}}))},this._handlePlaying=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:playing",{detail:{id:e,node:i}}))},this._handlePause=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:pause",{detail:{id:e,node:i}}))},this._handleStalled=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:stalled",{detail:{id:e,node:i}}))},this._handleTimeUpdate=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:timeupdate",{detail:{id:e,node:i}}))},this._handleEnded=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:ended",{detail:{id:e,node:i}}))},this._handleError=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:error",{detail:{id:e,node:i}}))},this.host=t,this.host.addController(this)}set processing(t){t!==this._processing&&(this._processing=t,this.host.requestUpdate())}get processing(){return this._processing}set duration(t){!isNaN(t)&&t!==this._duration&&(this._duration=t,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(t){this._scenes=t,this.host.requestUpdate()}get scenes(){return this._scenes}set videos(t){this._videos=t,this.host.requestUpdate()}get videos(){return this._videos}set videoState(t){this._videoState=t,this.host.requestUpdate()}get videoState(){return this._videoState}_setupTask(){new Uo(this.host,async([t,e,i,r])=>{try{if((i||t)&&e){if(this.host.reset(),this.processing=!0,Object.keys(this.videos??{}).forEach(a=>{if(this.videos){const{hls:o,node:l}=this.videos[a];o==null||o.destroy(),l.src=""}}),i){let a=null;if(r)try{a=await(await fetch(r,{method:"GET"})).text()}catch{this.host.dispatchEvent(new ErrorEvent("error",new Error("Track failed to fetch")))}const o=i.includes(".m3u8")?"playlist":"video";this.scenes=await el({template:e,data:{questions:{items:[{answer:{id:"source",media:{[o]:i},captions:{current:a}}}]}}},this._resolveVideo)}else this.scenes=await el({data:t,template:e},this._resolveVideo);const n={loadeddata:this._handleLoadedData,waiting:this._handleWaiting,canplay:this._handleCanPlay,progress:this._handleProgress,seeked:this._handleSeeked,play:this._handlePlay,playing:this._handlePlaying,pause:this._handlePause,stalled:this._handleStalled,timeupdate:this._handleTimeUpdate,ended:this._handleEnded,error:this._handleError};this.videos=this.scenes.scenes.reduce((a,{video:o})=>{if(o){const{id:l,node:h}=o,d=Object.keys(n).reduce((c,u)=>{const f=u,p=n[f](l,h);return c[f]=p,h.addEventListener(u,p),c},{});a[o.id]={...o,listeners:d}}return a},{}),this.videoState=this.scenes.scenes.reduce((a,{video:o})=>(o&&(a[o.id]={initialised:!1,waiting:!0,buffered:[]}),a),{}),this.duration=Math.max(0,...this.scenes.scenes.map(({start:a,duration:o})=>a+o)),this.host.reset(this.host.currentTime,!this.host.paused),this.host.autoplay&&this.host.play()}}catch(n){console.log(n),this.scenes=null,this.duration=0,this.host.dispatchEvent(new ErrorEvent("error",new Error("Failed to create scenes")))}finally{this.processing=!1}},()=>[this.host.data,this.host.template,this.host.src,this.host.track])}_setVideoCurrentTime({time:t,scene:e}){const{start:i,video:r}=e;if(r&&r.node&&typeof i<"u"){const n=t-i;r.node.currentTime=Math.max(r.start,Math.min(r.start+r.duration,n+r.start))}}setVideosCurrentTime(t){var e;(e=this.scenes)==null||e.scenes.forEach(i=>{this._setVideoCurrentTime({time:t,scene:i})})}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(t=>{var e,i;(e=this.videos)!=null&&e[t]&&((i=this.videos[t].hls)==null||i.destroy(),this.videos[t].node.pause(),Object.keys(this.videos[t].listeners).forEach(r=>{var n;if((n=this.videos)!=null&&n[t]){const a=this.videos[t].listeners[r];this.videos[t].node.removeEventListener(r,a)}}),delete this.videos[t])}),this.videos={}}}const l0={template:{layouts:[{name:"basic",tree:`[
|
86
|
+
`),[n,a]=i.match(Fu)||[];return{start:n,end:a,text:s}}):[]}function Ks(r){const[t,e,i]=r.split(":");return i?parseInt(t)*60*60+parseInt(e)*60+parseFloat(i):parseInt(t)*60+parseInt(e)}function Nu({canvas:r,dx:t,dy:e,dw:i,dh:s,time:n,vttCaptions:a}){if(a){const o=Zo(a).find(({start:l,end:h})=>l&&h&&n>=Ks(l)&&n<Ks(h));if(o){const l=r.getContext("2d");if(l){const h=Math.min(i,s);let d=[""];const c=i*.9,u=h*.05;l.font=`${u}px Roobert, Dejavu Sans, sans-serif`,l.textBaseline="middle",o.text.split(" ").forEach(f=>{const p=d.length-1,g=l.measureText(d[p]).width,m=l.measureText(` ${f}`).width;g+m<c?d[p]=`${d[p]} ${f}`:d=[...d,f]}),d.forEach((f,p)=>{const g=f.trim(),m=l.measureText(g),b=t+(i-m.width)/2,A=e+(s*.85-(u+h*.04)*(d.length-1-p)),T=u*.8,y=u/1.5,E=t+(i-m.width-y)/2,S=A-T,L=m.width+y,D=T*2,k=l.globalAlpha;l.save(),l.globalAlpha=.8*k,l.fillStyle="#000000",l.beginPath(),l.roundRect(E,S,L,D,h*.01),l.fill(),l.closePath(),l.globalAlpha=k,l.fillStyle="#FFFFFF",l.fillText(g,b,A),l.restore()})}}}}const Se=1.8;function es(r){return typeof r=="number"?{top:r,right:r,bottom:r,left:r}:{top:0,right:0,bottom:0,left:0,...r}}function Uu(r,t=1){return typeof r=="number"?{topLeft:r*t,topRight:r*t,bottomRight:r*t,bottomLeft:r*t}:{topLeft:((r==null?void 0:r.topLeft)??0)*t,topRight:((r==null?void 0:r.topRight)??0)*t,bottomRight:((r==null?void 0:r.bottomRight)??0)*t,bottomLeft:((r==null?void 0:r.bottomLeft)??0)*t}}function Ws(r,t){return typeof r=="number"?r:typeof r=="function"?r(t):null}function Ys(r,t){const{w:e,gap:i=0,padding:s=0,direction:n="column",elements:a}=r,{right:o,left:l}=es(s);if(e){const h=Ws(e,t);if(h)return h}if(a){const h=a.length;if(n==="row")return o+l+i*(h-1)+a.reduce((d,c)=>d+=Ys(c,t),0);if(n==="column"){let d=0;return a.forEach(c=>{const u=o+l+Ys(c,t);u>d&&(d=u)}),d}}return 0}function Bu(r,t,e){const{w:i=0,gap:s=0,padding:n=0,direction:a="column"}=r,{right:o,left:l}=es(n),h=t.length,d=t.reduce((u,f)=>{const{w:p}=f;if(p){const g=Ws(p,e);if(g)return u+=g}return p==="auto"?u+=Ys(f,e):u},0),c=t.filter(({w:u})=>u==="fill").length;return t.reduce((u,f)=>{const{w:p}=f,g=i-o-l,m=Math.min(g,Ys(f,e));if(p==="fill"){if(a==="row"){const b=(i-d-o-l-s*(h-1))/c;return u=[...u,b]}if(a==="column")return u=[...u,g]}return u=[...u,m]},[])}function Xs(r,t){const{h:e,gap:i=0,padding:s=0,direction:n="column",elements:a}=r,{top:o,bottom:l}=es(s);if(e){const h=Ws(e,t);if(h)return h}if(a){const h=a.length;if(n==="row"){let d=0;return a.forEach(c=>{const u=o+l+Xs(c,t);u>d&&(d=u)}),d}if(n==="column")return o+l+i*(h-1)+a.reduce((d,c)=>d+=Xs(c,t),0)}return 0}function Hu(r,t,e){const{h:i=0,gap:s=0,padding:n=0,direction:a="column"}=r,{top:o,bottom:l}=es(n),h=t.length,d=t.reduce((u,f)=>{const{h:p}=f;if(p){const g=Ws(p,e);if(g)return u+=g}return p==="auto"?u+=Xs(f,e):u},0),c=t.filter(({h:u})=>u==="fill").length;return t.reduce((u,f)=>{const{h:p}=f,g=i-o-l,m=Math.min(g,Xs(f,e));if(p==="fill"){if(a==="row")return u=[...u,g];if(a==="column"){const b=(i-d-o-l-s*(h-1))/c;return u=[...u,b]}}return u=[...u,m]},[])}function Jo({canvas:r,offscreenCanvas:t,debug:e=!1,origin:{x:i=0,y:s=0,w:n=r.width,h:a=r.height}={},parent:o,elements:l=[]}){const h=Math.min(n,a)/1080,d={x:0,y:0,w:n/h,h:a/h,gap:0,padding:0,direction:"column",align:"start",justify:"start",...o},{x:c,y:u,w:f,h:p,gap:g,padding:m,direction:b,align:A,justify:T}=d,{top:y,right:E,bottom:S,left:L}=es(m);l.map((D,k)=>{const x=r.getContext("2d",{alpha:!1});if(x){const F=l.length,{x:O,y:G,radius:W,elements:w=[],draw:I}=D,{topLeft:B,topRight:U,bottomRight:H,bottomLeft:V}=Uu(W,h),J=Bu(d,l,{context:x}),[$,Q,rt]=J.reduce((Tt,Ot,qt)=>(qt<k&&(Tt[0]=Tt[0]+=Ot),qt>k&&(Tt[1]=Tt[1]+=Ot),Tt[2]=Tt[2]+=Ot,Tt),[0,0,0]),tt=J[k],Pt=Hu(d,l,{context:x,width:tt}),[St,yt,Te]=Pt.reduce((Tt,Ot,qt)=>(qt<k&&(Tt[0]=Tt[0]+=Ot),qt>k&&(Tt[1]=Tt[1]+=Ot),Tt[2]=Tt[2]+=Ot,Tt),[0,0,0]),bt=Pt[k],je={"row|start|start":L+$+g*k,"row|center|start":L+$+g*k,"row|end|start":L+$+g*k,"row|start|center":f/2-rt/2-g*(F-1)/2+$+g*k,"row|center|center":f/2-rt/2-g*(F-1)/2+$+g*k,"row|end|center":f/2-rt/2-g*(F-1)/2+$+g*k,"row|start|end":f-E-tt-Q-g*(F-k),"row|center|end":f-E-tt-Q-g*(F-k),"row|end|end":f-E-tt-Q-g*(F-k),"column|start|start":L,"column|center|start":f/2-tt/2,"column|end|start":f-E-tt-Q,"column|start|center":L,"column|center|center":f/2-tt/2,"column|end|center":f-E-tt-Q,"column|start|end":L,"column|center|end":f/2-tt/2,"column|end|end":f-E-tt-Q},Ni={"row|start|start":y,"row|center|start":p/2-bt/2,"row|end|start":p-S-bt-yt,"row|start|center":y,"row|center|center":p/2-bt/2,"row|end|center":p-S-bt-yt,"row|start|end":y,"row|center|end":p/2-bt/2,"row|end|end":p-S-bt-yt,"column|start|start":y+St+g*k,"column|center|start":y+St+g*k,"column|end|start":y+St+g*k,"column|start|center":p/2-Te/2-g*(F-1)/2+St+g*k,"column|center|center":p/2-Te/2-g*(F-1)+St+g*k,"column|end|center":p/2-Te/2-g*(F-1)+St+g*k,"column|start|end":p-S-bt-yt-g*(F-k),"column|center|end":p-S-bt-yt-g*(F-k),"column|end|end":p-S-bt-yt-g*(F-k)},ze=c+(O??je[`${b}|${A}|${T}`]),hi=u+(G??Ni[`${b}|${A}|${T}`]),At=i+ze*h,gt=s+hi*h,Xt=tt*h,ut=bt*h;I&&(x.save(),W&&(x.beginPath(),x.moveTo(At+Math.min(ut/Se,B),gt),x.lineTo(At+Xt-Math.min(ut/Se,U),gt),x.quadraticCurveTo(At+Xt,gt,At+Xt,gt+Math.min(ut/Se,U)),x.lineTo(At+Xt,gt+ut-Math.min(ut/Se,H)),x.quadraticCurveTo(At+Xt,gt+ut,At+Xt-Math.min(ut/Se,H),gt+ut),x.lineTo(At+Math.min(ut/Se,V),gt+ut),x.quadraticCurveTo(At,gt+ut,At,gt+ut-Math.min(ut/Se,V)),x.lineTo(At,gt+Math.min(ut/Se,B)),x.quadraticCurveTo(At,gt,At+Math.min(ut/Se,B),gt),x.closePath(),e&&(x.strokeStyle="blue",x.stroke()),x.clip()),I({scale:h,canvas:r,context:x,offscreenCanvas:t,dx:At,dy:gt,dw:Xt,dh:ut}),e&&(x.strokeStyle="red",x.strokeRect(At,gt,Xt,ut)),x.restore()),Jo({canvas:r,offscreenCanvas:t,debug:e,origin:{x:i,y:s,w:n,h:a},parent:{...D,x:ze,y:hi,w:tt,h:bt},elements:w})}})}function Gu(r){return Jo(r)}function qs({context:r,node:t,maxW:e=1/0}){const i=(t.value??"").split(" ");return i.slice(1).reduce((s,n)=>{const a=`${s[s.length-1].text} ${n}`.trim(),o=r.measureText(a);return o.width>e?s=[...s,{text:n,metrics:r.measureText(n)}]:s[s.length-1]={text:a,metrics:o},s},[{text:i[0],metrics:r.measureText(i[0])}])}function Qo(r){const{visible:t=!0,node:e}=r,i=[...(e==null?void 0:e.elements)??[],...(r==null?void 0:r.elements)??[]];return t?e&&e.type!=="box"?!!e.value:i==null?void 0:i.some(s=>Qo(s)):!1}function _o(r=!1,t,e){return t.map(i=>{const{node:s}=i;if(Qo(i))return{...i,...(s==null?void 0:s.type)==="text"&&s.value?{w:s.fill?"fill":({context:n})=>s&&s.type==="text"&&s.value?(n.font=s.font,n.textBaseline="top",Math.ceil(n.measureText(s.value).width)):0,h:s.fill?"fill":({width:n,context:a})=>{var o,l;if(s&&s.type==="text"){const h=/(?<value>\d+\.?\d*)/,d=parseFloat(((l=(o=s.font.match(h))==null?void 0:o.groups)==null?void 0:l.value)??"0");return s.wrap?qs({context:a,node:s,maxW:n}).length*d:d}return 0}}:{},...(s==null?void 0:s.type)==="image"&&s.image&&s.size?{w:()=>{var n,a,o,l;const h=((n=s.image)==null?void 0:n.naturalWidth)??s.image.width,d=((a=s.image)==null?void 0:a.naturalHeight)??s.image.height,c=h/d,u=(o=s.size)==null?void 0:o.w,f=((l=s.size)==null?void 0:l.h)??0;return u??(c>=1?f:f*c)},h:()=>{var n,a,o,l;const h=((n=s.image)==null?void 0:n.naturalWidth)??s.image.width,d=((a=s.image)==null?void 0:a.naturalHeight)??s.image.height,c=h/d,u=((o=s.size)==null?void 0:o.w)??0;return((l=s.size)==null?void 0:l.h)??(c<1?u:u*c)}}:{},elements:i.elements?_o(r,i.elements,e):void 0,draw:({canvas:n,offscreenCanvas:a,context:o,dx:l,dy:h,dw:d,dh:c,scale:u})=>{var f,p,g,m,b,A,T;if(s){const{type:y,from:E=0,to:S=1/0}=s;if(e>=E&&e<=S){if(o.save(),e&&S-.3333333333333333<=e&&(o.globalAlpha=1-(.16666666666666666-(S-e))/.16666666666666666),y==="box"&&(o.fillStyle=s.background,o.fillRect(l,h,d,c)),y==="text"&&s.value){const L=/(?<value>\d+\.?\d*)/;let D=0;const k=parseFloat(((p=(f=s.font.match(L))==null?void 0:f.groups)==null?void 0:p.value)??"0")*u;if(s.fill){const{minSize:x,maxSize:F}=s.fill;D=x*u,o.font=s.font.replace(L,D.toString());const O=10*u;let G=0,W=qs({context:o,node:s,maxW:d});for(;D+O<F*u&&(W.length+1)*(D+O)<c;)if(D+=O,o.font=s.font.replace(L,D.toString()),W=qs({context:o,node:s,maxW:d}),G=W.reduce((w,I)=>(I.metrics.width>w&&(w=I.metrics.width),w),0),G>d){D-=O;break}o.font=s.font.replace(L,D.toString())}else D=k,o.font=s.font.replace(L,k.toString());o.textBaseline="top",o.fillStyle=s.color,s.wrap?qs({context:o,node:s,maxW:d}).forEach((x,F)=>{o.fillText(x.text,l,h+D*F)}):o.fillText(s.value,l,h)}if(y==="image"&&s.image&&o.drawImage(s.image,l,h,d,c),y==="video"&&((g=s.video)!=null&&g.node||(m=s.video)!=null&&m.getSource)){const L=((A=(b=s.video)==null?void 0:b.getSource)==null?void 0:A.call(b,e))??s.video.node,D=(L==null?void 0:L.videoWidth)??(L==null?void 0:L.naturalWidth)??(L==null?void 0:L.width),k=(L==null?void 0:L.videoHeight)??(L==null?void 0:L.naturalHeight)??(L==null?void 0:L.height);if(D&&k){const{resolution:x,aspectRatio:F}=ts({resolution:Math.min(D,k),aspectRatio:D/k}),{dx:O,dy:G,dw:W,dh:w}=Ou({offscreenCanvas:a,context:o,source:L,format:s.format??"letterbox",videoResolution:x,videoAspectRatio:F,posX:l,posY:h,width:d,height:c});s.elements&&$o({time:e,canvas:n,offscreenCanvas:a,origin:{x:Math.max(l,l+O),y:Math.max(h,h+G),w:Math.min(d,W),h:Math.min(c,w)},elements:s.elements})}}if(y==="gradient"&&s.value){const L=o.createLinearGradient(l+d,h,l+d,h+c);(T=s.value)==null||T.forEach(D=>{L.addColorStop(D.percent,D.color)}),o.fillStyle=L,o.fillRect(l,h,d,c)}o.restore()}}}}}).filter(Boolean)}function $o({debug:r,time:t,elements:e,...i}){return Gu({...i,debug:r,elements:_o(r,e,t)})}const Vu={template:{layouts:[{name:"basic",tree:`[
|
144
87
|
{
|
145
88
|
"w": "fill",
|
146
89
|
"h": "fill",
|
@@ -154,7 +97,7 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
154
97
|
"duration": {{@ parse(it.duration) /}},
|
155
98
|
"startOffset": {{@ parse(it.startOffset) /}},
|
156
99
|
"endOffset": {{@ parse(it.endOffset) /}},
|
157
|
-
"captions": {{@ parse(it.captions /}}
|
100
|
+
"captions": {{@ parse(it.captions) /}}
|
158
101
|
}
|
159
102
|
}
|
160
103
|
}
|
@@ -185,7 +128,64 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
185
128
|
"startOffset": {{@ parse(it.root?.answer?.settings?.startOffset) /}},
|
186
129
|
"endOffset": {{@ parse(it.root?.answer?.settings?.endOffset) /}},
|
187
130
|
"captions": {{@ parse(it.root?.answer?.captions?.current) /}}
|
188
|
-
}`}],root:"{{ it.outro?.questions?.items | stringify }}"}]},meta:{transitionDuration:1/3}};function
|
131
|
+
}`}],root:"{{ it.outro?.questions?.items | stringify }}"}]},meta:{transitionDuration:1/3}};async function ju(){if(typeof window>"u"){const r=await Promise.resolve().then(()=>$d);return new r.Image}return new Image}async function zu(r){return new Promise(t=>{ju().then(e=>{e.onload=()=>{t(e)},e.onerror=()=>{t(null)},e.src=r})})}async function vn({element:r},t){var e,i,s;let n={...r};const{node:a}=r;if((a==null?void 0:a.type)==="video"&&((e=a==null?void 0:a.value)!=null&&e.src||(i=a==null?void 0:a.value)!=null&&i.playlist)&&(n={...n,node:{...a,video:await t(a.value)}}),(a==null?void 0:a.type)==="image"&&a.value){const o=await zu(a.value);o&&(n={...n,node:{...a,image:o}})}return n.node&&(s=r.node)!=null&&s.elements&&(n.node.elements=await Promise.all(r.node.elements.map(o=>vn({element:o},t)))),r.elements&&(n.elements=await Promise.all(r.elements.map(o=>vn({element:o},t)))),n}async function tl(){if(typeof window>"u"){const r=await Promise.resolve().then(()=>$d),t=new r.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function Ku(r){var t;try{if((t=await ku(r,{method:"HEAD"}))!=null&&t.ok)return r}catch{return}}async function Wu({sources:r}){let t=null;if(r){const e=r.filter(Boolean).map(i=>Ku(i));t=(await Promise.all(e)).find(Boolean)}return t}js.define("stringify",r=>JSON.stringify(r)),js.define("nullify",r=>typeof r>"u"?null:r),js.define("filter",(r,t)=>{if(!t)return r;if(!Array.isArray(r))throw new Error("Data for filter must be an array");return r.filter((e,i)=>t.includes(i))}),_i.define("parse",r=>{const t=r.params[0];return typeof t=="string"?`"${t.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}"`:typeof t>"u"?null:t}),_i.define("resolve-source",async r=>{const{sources:t}=r.params[0]??{},e=t==null?void 0:t.filter(Boolean),i=e==null?void 0:e.find(a=>a.includes("blob:")),s=e==null?void 0:e.find(a=>!a.includes("http")),n=i??s??await Wu({sources:t});return n?`"${n}"`:"null"});const Zs=(r,t,e)=>Ru(r,t,$i({autoEscape:!1,defaultFilter:"nullify",async:!0,asyncHelpers:["resolve-source"],...e}));function yn(r=[]){var t;for(const e of r)return((t=e==null?void 0:e.node)==null?void 0:t.type)==="video"?e.node:yn(e==null?void 0:e.elements)}async function el({data:r,template:t=Vu,burnCaptions:e=!1},i){var s,n,a;const o=(await Promise.all(t.template.content.map(async({scenes:u,root:f})=>(await Promise.all(u.map(async({layout:p,duration:g,data:m,options:b})=>{const A={...t.options,...r,intro:t.intro,outro:t.outro};async function T(y){var E,S;const L=m?JSON.parse(await Zs(m,{...A,root:y})):{},D=b?JSON.parse(await Zs(b,A)):{},k=(E=t.template.layouts.find(G=>G.name===p))==null?void 0:E.tree,x=JSON.parse(await Zs(k,{...L,...D})),F=await Promise.all(x.flatMap(G=>vn({element:G},i))),O=(S=yn(F))==null?void 0:S.video;return{duration:g??(O==null?void 0:O.duration)??0,captions:O==null?void 0:O.captions,elements:F}}if(f){const y=JSON.parse(await Zs(f,A));return Array.isArray(y)?await Promise.all(y.map(async E=>await T(E))):T(y)}return T(r)}))).flatMap(p=>p).filter(p=>p.duration>0)))).flatMap(u=>u),l=((s=t.meta)==null?void 0:s.frameRate)??30,h=((n=t.meta)==null?void 0:n.resolution)??720,d=((a=t.meta)==null?void 0:a.transitionDuration)??1/3,c=await Promise.all(o.map(async({duration:u,captions:f,elements:p},g)=>{var m,b;const A=await tl(),T=await tl(),y=o.reduce((L,D,k)=>(k<g&&(L+=D.duration-d/2),L),0),E=({canvas:L,currentTime:D})=>{$o({canvas:L,elements:p,offscreenCanvas:A,time:D}),f&&e&&Nu({canvas:L,time:D,dx:0,dy:0,dw:L.width,dh:L.height,vttCaptions:f})},S=yn(p);return{draw:E,duration:u,transitionCanvas:T,start:y,video:S==null?void 0:S.video,audio:{duration:u,src:(m=S==null?void 0:S.value)==null?void 0:m.src,start:(b=S==null?void 0:S.video)==null?void 0:b.start}}}));return{scenes:c,frameRate:l,resolution:h,transitionDuration:d,duration:Math.max(0,...c.map(({start:u,duration:f})=>u+f))}}/**
|
132
|
+
* @license
|
133
|
+
* Copyright 2017 Google LLC
|
134
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
135
|
+
*/const yi={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},bi=r=>(...t)=>({_$litDirective$:r,values:t});let is=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
|
136
|
+
* @license
|
137
|
+
* Copyright 2018 Google LLC
|
138
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
139
|
+
*/const ht=bi(class extends is{constructor(r){var t;if(super(r),r.type!==yi.ATTRIBUTE||r.name!=="class"||((t=r.strings)===null||t===void 0?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(r){return" "+Object.keys(r).filter(t=>r[t]).join(" ")+" "}update(r,[t]){var e,i;if(this.it===void 0){this.it=new Set,r.strings!==void 0&&(this.nt=new Set(r.strings.join(" ").split(/\s/).filter(n=>n!=="")));for(const n in t)t[n]&&!(!((e=this.nt)===null||e===void 0)&&e.has(n))&&this.it.add(n);return this.render(t)}const s=r.element.classList;this.it.forEach(n=>{n in t||(s.remove(n),this.it.delete(n))});for(const n in t){const a=!!t[n];a===this.it.has(n)||!((i=this.nt)===null||i===void 0)&&i.has(n)||(a?(s.add(n),this.it.add(n)):(s.remove(n),this.it.delete(n)))}return se}});/**
|
140
|
+
* @license
|
141
|
+
* Copyright 2018 Google LLC
|
142
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
143
|
+
*/const ss=r=>r??pt;/**
|
144
|
+
* @license
|
145
|
+
* Copyright 2020 Google LLC
|
146
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
147
|
+
*/const{I:Yu}=bc,Xu=r=>r.strings===void 0,il=()=>document.createComment(""),rs=(r,t,e)=>{var i;const s=r._$AA.parentNode,n=t===void 0?r._$AB:t._$AA;if(e===void 0){const a=s.insertBefore(il(),n),o=s.insertBefore(il(),n);e=new Yu(a,o,r,r.options)}else{const a=e._$AB.nextSibling,o=e._$AM,l=o!==r;if(l){let h;(i=e._$AQ)===null||i===void 0||i.call(e,r),e._$AM=r,e._$AP!==void 0&&(h=r._$AU)!==o._$AU&&e._$AP(h)}if(a!==n||l){let h=e._$AA;for(;h!==a;){const d=h.nextSibling;s.insertBefore(h,n),h=d}}}return e},$e=(r,t,e=r)=>(r._$AI(t,e),r),qu={},Zu=(r,t=qu)=>r._$AH=t,Ju=r=>r._$AH,bn=r=>{var t;(t=r._$AP)===null||t===void 0||t.call(r,!1,!0);let e=r._$AA;const i=r._$AB.nextSibling;for(;e!==i;){const s=e.nextSibling;e.remove(),e=s}};/**
|
148
|
+
* @license
|
149
|
+
* Copyright 2017 Google LLC
|
150
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
151
|
+
*/const ns=(r,t)=>{var e,i;const s=r._$AN;if(s===void 0)return!1;for(const n of s)(i=(e=n)._$AO)===null||i===void 0||i.call(e,t,!1),ns(n,t);return!0},Js=r=>{let t,e;do{if((t=r._$AM)===void 0)break;e=t._$AN,e.delete(r),r=t}while((e==null?void 0:e.size)===0)},sl=r=>{for(let t;t=r._$AM;r=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(r))break;e.add(r),$u(t)}};function Qu(r){this._$AN!==void 0?(Js(this),this._$AM=r,sl(this)):this._$AM=r}function _u(r,t=!1,e=0){const i=this._$AH,s=this._$AN;if(s!==void 0&&s.size!==0)if(t)if(Array.isArray(i))for(let n=e;n<i.length;n++)ns(i[n],!1),Js(i[n]);else i!=null&&(ns(i,!1),Js(i));else ns(this,r)}const $u=r=>{var t,e,i,s;r.type==yi.CHILD&&((t=(i=r)._$AP)!==null&&t!==void 0||(i._$AP=_u),(e=(s=r)._$AQ)!==null&&e!==void 0||(s._$AQ=Qu))};let rl=class extends is{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),sl(this),this.isConnected=t._$AU}_$AO(t,e=!0){var i,s;t!==this.isConnected&&(this.isConnected=t,t?(i=this.reconnected)===null||i===void 0||i.call(this):(s=this.disconnected)===null||s===void 0||s.call(this)),e&&(ns(this,t),Js(this))}setValue(t){if(Xu(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};/**
|
152
|
+
* @license
|
153
|
+
* Copyright 2020 Google LLC
|
154
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
155
|
+
*/const re=()=>new tf;let tf=class{};const An=new WeakMap,ne=bi(class extends rl{render(r){return pt}update(r,[t]){var e;const i=t!==this.G;return i&&this.G!==void 0&&this.ot(void 0),(i||this.rt!==this.lt)&&(this.G=t,this.ct=(e=r.options)===null||e===void 0?void 0:e.host,this.ot(this.lt=r.element)),pt}ot(r){var t;if(typeof this.G=="function"){const e=(t=this.ct)!==null&&t!==void 0?t:globalThis;let i=An.get(e);i===void 0&&(i=new WeakMap,An.set(e,i)),i.get(this.G)!==void 0&&this.G.call(this.ct,void 0),i.set(this.G,r),r!==void 0&&this.G.call(this.ct,r)}else this.G.value=r}get rt(){var r,t,e;return typeof this.G=="function"?(t=An.get((r=this.ct)!==null&&r!==void 0?r:globalThis))===null||t===void 0?void 0:t.get(this.G):(e=this.G)===null||e===void 0?void 0:e.value}disconnected(){this.rt===this.lt&&this.ot(void 0)}reconnected(){this.ot(this.lt)}});var ef=as;as.flatten=as,as.unflatten=ol;function nl(r){return r&&r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function al(r){return r}function as(r,t){t=t||{};const e=t.delimiter||".",i=t.maxDepth,s=t.transformKey||al,n={};function a(o,l,h){h=h||1,Object.keys(o).forEach(function(d){const c=o[d],u=t.safe&&Array.isArray(c),f=Object.prototype.toString.call(c),p=nl(c),g=f==="[object Object]"||f==="[object Array]",m=l?l+e+s(d):s(d);if(!u&&!p&&g&&Object.keys(c).length&&(!t.maxDepth||h<i))return a(c,m,h+1);n[m]=c})}return a(r),n}function ol(r,t){t=t||{};const e=t.delimiter||".",i=t.overwrite||!1,s=t.transformKey||al,n={};if(nl(r)||Object.prototype.toString.call(r)!=="[object Object]")return r;function o(d){const c=Number(d);return isNaN(c)||d.indexOf(".")!==-1||t.object?d:c}function l(d,c,u){return Object.keys(u).reduce(function(f,p){return f[d+e+p]=u[p],f},c)}function h(d){const c=Object.prototype.toString.call(d),u=c==="[object Array]",f=c==="[object Object]";if(d){if(u)return!d.length;if(f)return!Object.keys(d).length}else return!0}return r=Object.keys(r).reduce(function(d,c){const u=Object.prototype.toString.call(r[c]);return!(u==="[object Object]"||u==="[object Array]")||h(r[c])?(d[c]=r[c],d):l(c,d,as(r[c],t))},{}),Object.keys(r).forEach(function(d){const c=d.split(e).map(s);let u=o(c.shift()),f=o(c[0]),p=n;for(;f!==void 0;){if(u==="__proto__")return;const g=Object.prototype.toString.call(p[u]),m=g==="[object Object]"||g==="[object Array]";if(!i&&!m&&typeof p[u]<"u")return;(i&&!m||!i&&p[u]==null)&&(p[u]=typeof f=="number"&&!t.object?[]:{}),p=p[u],c.length>0&&(u=o(c.shift()),f=o(c[0]))}p[u]=ol(r[d],t)}),n}const sf=gn(ef);/**
|
156
|
+
* @license
|
157
|
+
* Copyright 2017 Google LLC
|
158
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
159
|
+
*/const ll=(r,t,e)=>{const i=new Map;for(let s=t;s<=e;s++)i.set(r[s],s);return i},hl=bi(class extends is{constructor(r){if(super(r),r.type!==yi.CHILD)throw Error("repeat() can only be used in text expressions")}dt(r,t,e){let i;e===void 0?e=t:t!==void 0&&(i=t);const s=[],n=[];let a=0;for(const o of r)s[a]=i?i(o,a):a,n[a]=e(o,a),a++;return{values:n,keys:s}}render(r,t,e){return this.dt(r,t,e).values}update(r,[t,e,i]){var s;const n=Ju(r),{values:a,keys:o}=this.dt(t,e,i);if(!Array.isArray(n))return this.ht=o,a;const l=(s=this.ht)!==null&&s!==void 0?s:this.ht=[],h=[];let d,c,u=0,f=n.length-1,p=0,g=a.length-1;for(;u<=f&&p<=g;)if(n[u]===null)u++;else if(n[f]===null)f--;else if(l[u]===o[p])h[p]=$e(n[u],a[p]),u++,p++;else if(l[f]===o[g])h[g]=$e(n[f],a[g]),f--,g--;else if(l[u]===o[g])h[g]=$e(n[u],a[g]),rs(r,h[g+1],n[u]),u++,g--;else if(l[f]===o[p])h[p]=$e(n[f],a[p]),rs(r,n[u],n[f]),f--,p++;else if(d===void 0&&(d=ll(o,p,g),c=ll(l,u,f)),d.has(l[u]))if(d.has(l[f])){const m=c.get(o[p]),b=m!==void 0?n[m]:null;if(b===null){const A=rs(r,n[u]);$e(A,a[p]),h[p]=A}else h[p]=$e(b,a[p]),rs(r,n[u],b),n[m]=null;p++}else bn(n[f]),f--;else bn(n[u]),u++;for(;p<=g;){const m=rs(r,h[g+1]);$e(m,a[p]),h[p++]=m}for(;u<=f;){const m=n[u++];m!==null&&bn(m)}return this.ht=o,Zu(r,h),se}});var Gt="top",Jt="bottom",Qt="right",Vt="left",Tn="auto",os=[Gt,Jt,Qt,Vt],Ai="start",ls="end",rf="clippingParents",dl="viewport",hs="popper",nf="reference",cl=os.reduce(function(r,t){return r.concat([t+"-"+Ai,t+"-"+ls])},[]),ul=[].concat(os,[Tn]).reduce(function(r,t){return r.concat([t,t+"-"+Ai,t+"-"+ls])},[]),af="beforeRead",of="read",lf="afterRead",hf="beforeMain",df="main",cf="afterMain",uf="beforeWrite",ff="write",pf="afterWrite",gf=[af,of,lf,hf,df,cf,uf,ff,pf];function ce(r){return r?(r.nodeName||"").toLowerCase():null}function Zt(r){if(r==null)return window;if(r.toString()!=="[object Window]"){var t=r.ownerDocument;return t&&t.defaultView||window}return r}function ti(r){var t=Zt(r).Element;return r instanceof t||r instanceof Element}function _t(r){var t=Zt(r).HTMLElement;return r instanceof t||r instanceof HTMLElement}function En(r){if(typeof ShadowRoot>"u")return!1;var t=Zt(r).ShadowRoot;return r instanceof t||r instanceof ShadowRoot}function mf(r){var t=r.state;Object.keys(t.elements).forEach(function(e){var i=t.styles[e]||{},s=t.attributes[e]||{},n=t.elements[e];!_t(n)||!ce(n)||(Object.assign(n.style,i),Object.keys(s).forEach(function(a){var o=s[a];o===!1?n.removeAttribute(a):n.setAttribute(a,o===!0?"":o)}))})}function vf(r){var t=r.state,e={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,e.popper),t.styles=e,t.elements.arrow&&Object.assign(t.elements.arrow.style,e.arrow),function(){Object.keys(t.elements).forEach(function(i){var s=t.elements[i],n=t.attributes[i]||{},a=Object.keys(t.styles.hasOwnProperty(i)?t.styles[i]:e[i]),o=a.reduce(function(l,h){return l[h]="",l},{});!_t(s)||!ce(s)||(Object.assign(s.style,o),Object.keys(n).forEach(function(l){s.removeAttribute(l)}))})}}const fl={name:"applyStyles",enabled:!0,phase:"write",fn:mf,effect:vf,requires:["computeStyles"]};function ue(r){return r.split("-")[0]}var ei=Math.max,Qs=Math.min,Ti=Math.round;function wn(){var r=navigator.userAgentData;return r!=null&&r.brands&&Array.isArray(r.brands)?r.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function pl(){return!/^((?!chrome|android).)*safari/i.test(wn())}function Ei(r,t,e){t===void 0&&(t=!1),e===void 0&&(e=!1);var i=r.getBoundingClientRect(),s=1,n=1;t&&_t(r)&&(s=r.offsetWidth>0&&Ti(i.width)/r.offsetWidth||1,n=r.offsetHeight>0&&Ti(i.height)/r.offsetHeight||1);var a=ti(r)?Zt(r):window,o=a.visualViewport,l=!pl()&&e,h=(i.left+(l&&o?o.offsetLeft:0))/s,d=(i.top+(l&&o?o.offsetTop:0))/n,c=i.width/s,u=i.height/n;return{width:c,height:u,top:d,right:h+c,bottom:d+u,left:h,x:h,y:d}}function Sn(r){var t=Ei(r),e=r.offsetWidth,i=r.offsetHeight;return Math.abs(t.width-e)<=1&&(e=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:r.offsetLeft,y:r.offsetTop,width:e,height:i}}function gl(r,t){var e=t.getRootNode&&t.getRootNode();if(r.contains(t))return!0;if(e&&En(e)){var i=t;do{if(i&&r.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function Le(r){return Zt(r).getComputedStyle(r)}function yf(r){return["table","td","th"].indexOf(ce(r))>=0}function Me(r){return((ti(r)?r.ownerDocument:r.document)||window.document).documentElement}function _s(r){return ce(r)==="html"?r:r.assignedSlot||r.parentNode||(En(r)?r.host:null)||Me(r)}function ml(r){return!_t(r)||Le(r).position==="fixed"?null:r.offsetParent}function bf(r){var t=/firefox/i.test(wn()),e=/Trident/i.test(wn());if(e&&_t(r)){var i=Le(r);if(i.position==="fixed")return null}var s=_s(r);for(En(s)&&(s=s.host);_t(s)&&["html","body"].indexOf(ce(s))<0;){var n=Le(s);if(n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].indexOf(n.willChange)!==-1||t&&n.willChange==="filter"||t&&n.filter&&n.filter!=="none")return s;s=s.parentNode}return null}function ds(r){for(var t=Zt(r),e=ml(r);e&&yf(e)&&Le(e).position==="static";)e=ml(e);return e&&(ce(e)==="html"||ce(e)==="body"&&Le(e).position==="static")?t:e||bf(r)||t}function Ln(r){return["top","bottom"].indexOf(r)>=0?"x":"y"}function cs(r,t,e){return ei(r,Qs(t,e))}function Af(r,t,e){var i=cs(r,t,e);return i>e?e:i}function vl(){return{top:0,right:0,bottom:0,left:0}}function yl(r){return Object.assign({},vl(),r)}function bl(r,t){return t.reduce(function(e,i){return e[i]=r,e},{})}var Tf=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,yl(typeof t!="number"?t:bl(t,os))};function Ef(r){var t,e=r.state,i=r.name,s=r.options,n=e.elements.arrow,a=e.modifiersData.popperOffsets,o=ue(e.placement),l=Ln(o),h=[Vt,Qt].indexOf(o)>=0,d=h?"height":"width";if(!(!n||!a)){var c=Tf(s.padding,e),u=Sn(n),f=l==="y"?Gt:Vt,p=l==="y"?Jt:Qt,g=e.rects.reference[d]+e.rects.reference[l]-a[l]-e.rects.popper[d],m=a[l]-e.rects.reference[l],b=ds(n),A=b?l==="y"?b.clientHeight||0:b.clientWidth||0:0,T=g/2-m/2,y=c[f],E=A-u[d]-c[p],S=A/2-u[d]/2+T,L=cs(y,S,E),D=l;e.modifiersData[i]=(t={},t[D]=L,t.centerOffset=L-S,t)}}function wf(r){var t=r.state,e=r.options,i=e.element,s=i===void 0?"[data-popper-arrow]":i;s!=null&&(typeof s=="string"&&(s=t.elements.popper.querySelector(s),!s)||gl(t.elements.popper,s)&&(t.elements.arrow=s))}const Sf={name:"arrow",enabled:!0,phase:"main",fn:Ef,effect:wf,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function wi(r){return r.split("-")[1]}var Lf={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Rf(r,t){var e=r.x,i=r.y,s=t.devicePixelRatio||1;return{x:Ti(e*s)/s||0,y:Ti(i*s)/s||0}}function Al(r){var t,e=r.popper,i=r.popperRect,s=r.placement,n=r.variation,a=r.offsets,o=r.position,l=r.gpuAcceleration,h=r.adaptive,d=r.roundOffsets,c=r.isFixed,u=a.x,f=u===void 0?0:u,p=a.y,g=p===void 0?0:p,m=typeof d=="function"?d({x:f,y:g}):{x:f,y:g};f=m.x,g=m.y;var b=a.hasOwnProperty("x"),A=a.hasOwnProperty("y"),T=Vt,y=Gt,E=window;if(h){var S=ds(e),L="clientHeight",D="clientWidth";if(S===Zt(e)&&(S=Me(e),Le(S).position!=="static"&&o==="absolute"&&(L="scrollHeight",D="scrollWidth")),S=S,s===Gt||(s===Vt||s===Qt)&&n===ls){y=Jt;var k=c&&S===E&&E.visualViewport?E.visualViewport.height:S[L];g-=k-i.height,g*=l?1:-1}if(s===Vt||(s===Gt||s===Jt)&&n===ls){T=Qt;var x=c&&S===E&&E.visualViewport?E.visualViewport.width:S[D];f-=x-i.width,f*=l?1:-1}}var F=Object.assign({position:o},h&&Lf),O=d===!0?Rf({x:f,y:g},Zt(e)):{x:f,y:g};if(f=O.x,g=O.y,l){var G;return Object.assign({},F,(G={},G[y]=A?"0":"",G[T]=b?"0":"",G.transform=(E.devicePixelRatio||1)<=1?"translate("+f+"px, "+g+"px)":"translate3d("+f+"px, "+g+"px, 0)",G))}return Object.assign({},F,(t={},t[y]=A?g+"px":"",t[T]=b?f+"px":"",t.transform="",t))}function xf(r){var t=r.state,e=r.options,i=e.gpuAcceleration,s=i===void 0?!0:i,n=e.adaptive,a=n===void 0?!0:n,o=e.roundOffsets,l=o===void 0?!0:o,h={placement:ue(t.placement),variation:wi(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:s,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,Al(Object.assign({},h,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:a,roundOffsets:l})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,Al(Object.assign({},h,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const kf={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:xf,data:{}};var $s={passive:!0};function Df(r){var t=r.state,e=r.instance,i=r.options,s=i.scroll,n=s===void 0?!0:s,a=i.resize,o=a===void 0?!0:a,l=Zt(t.elements.popper),h=[].concat(t.scrollParents.reference,t.scrollParents.popper);return n&&h.forEach(function(d){d.addEventListener("scroll",e.update,$s)}),o&&l.addEventListener("resize",e.update,$s),function(){n&&h.forEach(function(d){d.removeEventListener("scroll",e.update,$s)}),o&&l.removeEventListener("resize",e.update,$s)}}const Cf={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Df,data:{}};var If={left:"right",right:"left",bottom:"top",top:"bottom"};function tr(r){return r.replace(/left|right|bottom|top/g,function(t){return If[t]})}var Pf={start:"end",end:"start"};function Tl(r){return r.replace(/start|end/g,function(t){return Pf[t]})}function Rn(r){var t=Zt(r),e=t.pageXOffset,i=t.pageYOffset;return{scrollLeft:e,scrollTop:i}}function xn(r){return Ei(Me(r)).left+Rn(r).scrollLeft}function Of(r,t){var e=Zt(r),i=Me(r),s=e.visualViewport,n=i.clientWidth,a=i.clientHeight,o=0,l=0;if(s){n=s.width,a=s.height;var h=pl();(h||!h&&t==="fixed")&&(o=s.offsetLeft,l=s.offsetTop)}return{width:n,height:a,x:o+xn(r),y:l}}function Mf(r){var t,e=Me(r),i=Rn(r),s=(t=r.ownerDocument)==null?void 0:t.body,n=ei(e.scrollWidth,e.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),a=ei(e.scrollHeight,e.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),o=-i.scrollLeft+xn(r),l=-i.scrollTop;return Le(s||e).direction==="rtl"&&(o+=ei(e.clientWidth,s?s.clientWidth:0)-n),{width:n,height:a,x:o,y:l}}function kn(r){var t=Le(r),e=t.overflow,i=t.overflowX,s=t.overflowY;return/auto|scroll|overlay|hidden/.test(e+s+i)}function El(r){return["html","body","#document"].indexOf(ce(r))>=0?r.ownerDocument.body:_t(r)&&kn(r)?r:El(_s(r))}function us(r,t){var e;t===void 0&&(t=[]);var i=El(r),s=i===((e=r.ownerDocument)==null?void 0:e.body),n=Zt(i),a=s?[n].concat(n.visualViewport||[],kn(i)?i:[]):i,o=t.concat(a);return s?o:o.concat(us(_s(a)))}function Dn(r){return Object.assign({},r,{left:r.x,top:r.y,right:r.x+r.width,bottom:r.y+r.height})}function Ff(r,t){var e=Ei(r,!1,t==="fixed");return e.top=e.top+r.clientTop,e.left=e.left+r.clientLeft,e.bottom=e.top+r.clientHeight,e.right=e.left+r.clientWidth,e.width=r.clientWidth,e.height=r.clientHeight,e.x=e.left,e.y=e.top,e}function wl(r,t,e){return t===dl?Dn(Of(r,e)):ti(t)?Ff(t,e):Dn(Mf(Me(r)))}function Nf(r){var t=us(_s(r)),e=["absolute","fixed"].indexOf(Le(r).position)>=0,i=e&&_t(r)?ds(r):r;return ti(i)?t.filter(function(s){return ti(s)&&gl(s,i)&&ce(s)!=="body"}):[]}function Uf(r,t,e,i){var s=t==="clippingParents"?Nf(r):[].concat(t),n=[].concat(s,[e]),a=n[0],o=n.reduce(function(l,h){var d=wl(r,h,i);return l.top=ei(d.top,l.top),l.right=Qs(d.right,l.right),l.bottom=Qs(d.bottom,l.bottom),l.left=ei(d.left,l.left),l},wl(r,a,i));return o.width=o.right-o.left,o.height=o.bottom-o.top,o.x=o.left,o.y=o.top,o}function Sl(r){var t=r.reference,e=r.element,i=r.placement,s=i?ue(i):null,n=i?wi(i):null,a=t.x+t.width/2-e.width/2,o=t.y+t.height/2-e.height/2,l;switch(s){case Gt:l={x:a,y:t.y-e.height};break;case Jt:l={x:a,y:t.y+t.height};break;case Qt:l={x:t.x+t.width,y:o};break;case Vt:l={x:t.x-e.width,y:o};break;default:l={x:t.x,y:t.y}}var h=s?Ln(s):null;if(h!=null){var d=h==="y"?"height":"width";switch(n){case Ai:l[h]=l[h]-(t[d]/2-e[d]/2);break;case ls:l[h]=l[h]+(t[d]/2-e[d]/2);break}}return l}function fs(r,t){t===void 0&&(t={});var e=t,i=e.placement,s=i===void 0?r.placement:i,n=e.strategy,a=n===void 0?r.strategy:n,o=e.boundary,l=o===void 0?rf:o,h=e.rootBoundary,d=h===void 0?dl:h,c=e.elementContext,u=c===void 0?hs:c,f=e.altBoundary,p=f===void 0?!1:f,g=e.padding,m=g===void 0?0:g,b=yl(typeof m!="number"?m:bl(m,os)),A=u===hs?nf:hs,T=r.rects.popper,y=r.elements[p?A:u],E=Uf(ti(y)?y:y.contextElement||Me(r.elements.popper),l,d,a),S=Ei(r.elements.reference),L=Sl({reference:S,element:T,strategy:"absolute",placement:s}),D=Dn(Object.assign({},T,L)),k=u===hs?D:S,x={top:E.top-k.top+b.top,bottom:k.bottom-E.bottom+b.bottom,left:E.left-k.left+b.left,right:k.right-E.right+b.right},F=r.modifiersData.offset;if(u===hs&&F){var O=F[s];Object.keys(x).forEach(function(G){var W=[Qt,Jt].indexOf(G)>=0?1:-1,w=[Gt,Jt].indexOf(G)>=0?"y":"x";x[G]+=O[w]*W})}return x}function Bf(r,t){t===void 0&&(t={});var e=t,i=e.placement,s=e.boundary,n=e.rootBoundary,a=e.padding,o=e.flipVariations,l=e.allowedAutoPlacements,h=l===void 0?ul:l,d=wi(i),c=d?o?cl:cl.filter(function(p){return wi(p)===d}):os,u=c.filter(function(p){return h.indexOf(p)>=0});u.length===0&&(u=c);var f=u.reduce(function(p,g){return p[g]=fs(r,{placement:g,boundary:s,rootBoundary:n,padding:a})[ue(g)],p},{});return Object.keys(f).sort(function(p,g){return f[p]-f[g]})}function Hf(r){if(ue(r)===Tn)return[];var t=tr(r);return[Tl(r),t,Tl(t)]}function Gf(r){var t=r.state,e=r.options,i=r.name;if(!t.modifiersData[i]._skip){for(var s=e.mainAxis,n=s===void 0?!0:s,a=e.altAxis,o=a===void 0?!0:a,l=e.fallbackPlacements,h=e.padding,d=e.boundary,c=e.rootBoundary,u=e.altBoundary,f=e.flipVariations,p=f===void 0?!0:f,g=e.allowedAutoPlacements,m=t.options.placement,b=ue(m),A=b===m,T=l||(A||!p?[tr(m)]:Hf(m)),y=[m].concat(T).reduce(function(rt,tt){return rt.concat(ue(tt)===Tn?Bf(t,{placement:tt,boundary:d,rootBoundary:c,padding:h,flipVariations:p,allowedAutoPlacements:g}):tt)},[]),E=t.rects.reference,S=t.rects.popper,L=new Map,D=!0,k=y[0],x=0;x<y.length;x++){var F=y[x],O=ue(F),G=wi(F)===Ai,W=[Gt,Jt].indexOf(O)>=0,w=W?"width":"height",I=fs(t,{placement:F,boundary:d,rootBoundary:c,altBoundary:u,padding:h}),B=W?G?Qt:Vt:G?Jt:Gt;E[w]>S[w]&&(B=tr(B));var U=tr(B),H=[];if(n&&H.push(I[O]<=0),o&&H.push(I[B]<=0,I[U]<=0),H.every(function(rt){return rt})){k=F,D=!1;break}L.set(F,H)}if(D)for(var V=p?3:1,J=function(tt){var Pt=y.find(function(St){var yt=L.get(St);if(yt)return yt.slice(0,tt).every(function(Te){return Te})});if(Pt)return k=Pt,"break"},$=V;$>0;$--){var Q=J($);if(Q==="break")break}t.placement!==k&&(t.modifiersData[i]._skip=!0,t.placement=k,t.reset=!0)}}const Vf={name:"flip",enabled:!0,phase:"main",fn:Gf,requiresIfExists:["offset"],data:{_skip:!1}};function Ll(r,t,e){return e===void 0&&(e={x:0,y:0}),{top:r.top-t.height-e.y,right:r.right-t.width+e.x,bottom:r.bottom-t.height+e.y,left:r.left-t.width-e.x}}function Rl(r){return[Gt,Qt,Jt,Vt].some(function(t){return r[t]>=0})}function jf(r){var t=r.state,e=r.name,i=t.rects.reference,s=t.rects.popper,n=t.modifiersData.preventOverflow,a=fs(t,{elementContext:"reference"}),o=fs(t,{altBoundary:!0}),l=Ll(a,i),h=Ll(o,s,n),d=Rl(l),c=Rl(h);t.modifiersData[e]={referenceClippingOffsets:l,popperEscapeOffsets:h,isReferenceHidden:d,hasPopperEscaped:c},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":c})}const zf={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:jf};function Kf(r,t,e){var i=ue(r),s=[Vt,Gt].indexOf(i)>=0?-1:1,n=typeof e=="function"?e(Object.assign({},t,{placement:r})):e,a=n[0],o=n[1];return a=a||0,o=(o||0)*s,[Vt,Qt].indexOf(i)>=0?{x:o,y:a}:{x:a,y:o}}function Wf(r){var t=r.state,e=r.options,i=r.name,s=e.offset,n=s===void 0?[0,0]:s,a=ul.reduce(function(d,c){return d[c]=Kf(c,t.rects,n),d},{}),o=a[t.placement],l=o.x,h=o.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=h),t.modifiersData[i]=a}const Yf={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Wf};function Xf(r){var t=r.state,e=r.name;t.modifiersData[e]=Sl({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const qf={name:"popperOffsets",enabled:!0,phase:"read",fn:Xf,data:{}};function Zf(r){return r==="x"?"y":"x"}function Jf(r){var t=r.state,e=r.options,i=r.name,s=e.mainAxis,n=s===void 0?!0:s,a=e.altAxis,o=a===void 0?!1:a,l=e.boundary,h=e.rootBoundary,d=e.altBoundary,c=e.padding,u=e.tether,f=u===void 0?!0:u,p=e.tetherOffset,g=p===void 0?0:p,m=fs(t,{boundary:l,rootBoundary:h,padding:c,altBoundary:d}),b=ue(t.placement),A=wi(t.placement),T=!A,y=Ln(b),E=Zf(y),S=t.modifiersData.popperOffsets,L=t.rects.reference,D=t.rects.popper,k=typeof g=="function"?g(Object.assign({},t.rects,{placement:t.placement})):g,x=typeof k=="number"?{mainAxis:k,altAxis:k}:Object.assign({mainAxis:0,altAxis:0},k),F=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,O={x:0,y:0};if(S){if(n){var G,W=y==="y"?Gt:Vt,w=y==="y"?Jt:Qt,I=y==="y"?"height":"width",B=S[y],U=B+m[W],H=B-m[w],V=f?-D[I]/2:0,J=A===Ai?L[I]:D[I],$=A===Ai?-D[I]:-L[I],Q=t.elements.arrow,rt=f&&Q?Sn(Q):{width:0,height:0},tt=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:vl(),Pt=tt[W],St=tt[w],yt=cs(0,L[I],rt[I]),Te=T?L[I]/2-V-yt-Pt-x.mainAxis:J-yt-Pt-x.mainAxis,bt=T?-L[I]/2+V+yt+St+x.mainAxis:$+yt+St+x.mainAxis,je=t.elements.arrow&&ds(t.elements.arrow),Ni=je?y==="y"?je.clientTop||0:je.clientLeft||0:0,ze=(G=F==null?void 0:F[y])!=null?G:0,hi=B+Te-ze-Ni,At=B+bt-ze,gt=cs(f?Qs(U,hi):U,B,f?ei(H,At):H);S[y]=gt,O[y]=gt-B}if(o){var Xt,ut=y==="x"?Gt:Vt,Tt=y==="x"?Jt:Qt,Ot=S[E],qt=E==="y"?"height":"width",Ls=Ot+m[ut],di=Ot-m[Tt],Rs=[Gt,Vt].indexOf(b)!==-1,Cr=(Xt=F==null?void 0:F[E])!=null?Xt:0,Ir=Rs?Ls:Ot-L[qt]-D[qt]-Cr+x.altAxis,Pr=Rs?Ot+L[qt]+D[qt]-Cr-x.altAxis:di,Or=f&&Rs?Af(Ir,Ot,Pr):cs(f?Ir:Ls,Ot,f?Pr:di);S[E]=Or,O[E]=Or-Ot}t.modifiersData[i]=O}}const Qf={name:"preventOverflow",enabled:!0,phase:"main",fn:Jf,requiresIfExists:["offset"]};function _f(r){return{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}}function $f(r){return r===Zt(r)||!_t(r)?Rn(r):_f(r)}function tp(r){var t=r.getBoundingClientRect(),e=Ti(t.width)/r.offsetWidth||1,i=Ti(t.height)/r.offsetHeight||1;return e!==1||i!==1}function ep(r,t,e){e===void 0&&(e=!1);var i=_t(t),s=_t(t)&&tp(t),n=Me(t),a=Ei(r,s,e),o={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(i||!i&&!e)&&((ce(t)!=="body"||kn(n))&&(o=$f(t)),_t(t)?(l=Ei(t,!0),l.x+=t.clientLeft,l.y+=t.clientTop):n&&(l.x=xn(n))),{x:a.left+o.scrollLeft-l.x,y:a.top+o.scrollTop-l.y,width:a.width,height:a.height}}function ip(r){var t=new Map,e=new Set,i=[];r.forEach(function(n){t.set(n.name,n)});function s(n){e.add(n.name);var a=[].concat(n.requires||[],n.requiresIfExists||[]);a.forEach(function(o){if(!e.has(o)){var l=t.get(o);l&&s(l)}}),i.push(n)}return r.forEach(function(n){e.has(n.name)||s(n)}),i}function sp(r){var t=ip(r);return gf.reduce(function(e,i){return e.concat(t.filter(function(s){return s.phase===i}))},[])}function rp(r){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(r())})})),t}}function np(r){var t=r.reduce(function(e,i){var s=e[i.name];return e[i.name]=s?Object.assign({},s,i,{options:Object.assign({},s.options,i.options),data:Object.assign({},s.data,i.data)}):i,e},{});return Object.keys(t).map(function(e){return t[e]})}var xl={placement:"bottom",modifiers:[],strategy:"absolute"};function kl(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];return!t.some(function(i){return!(i&&typeof i.getBoundingClientRect=="function")})}function ap(r){r===void 0&&(r={});var t=r,e=t.defaultModifiers,i=e===void 0?[]:e,s=t.defaultOptions,n=s===void 0?xl:s;return function(o,l,h){h===void 0&&(h=n);var d={placement:"bottom",orderedModifiers:[],options:Object.assign({},xl,n),modifiersData:{},elements:{reference:o,popper:l},attributes:{},styles:{}},c=[],u=!1,f={state:d,setOptions:function(b){var A=typeof b=="function"?b(d.options):b;g(),d.options=Object.assign({},n,d.options,A),d.scrollParents={reference:ti(o)?us(o):o.contextElement?us(o.contextElement):[],popper:us(l)};var T=sp(np([].concat(i,d.options.modifiers)));return d.orderedModifiers=T.filter(function(y){return y.enabled}),p(),f.update()},forceUpdate:function(){if(!u){var b=d.elements,A=b.reference,T=b.popper;if(kl(A,T)){d.rects={reference:ep(A,ds(T),d.options.strategy==="fixed"),popper:Sn(T)},d.reset=!1,d.placement=d.options.placement,d.orderedModifiers.forEach(function(x){return d.modifiersData[x.name]=Object.assign({},x.data)});for(var y=0;y<d.orderedModifiers.length;y++){if(d.reset===!0){d.reset=!1,y=-1;continue}var E=d.orderedModifiers[y],S=E.fn,L=E.options,D=L===void 0?{}:L,k=E.name;typeof S=="function"&&(d=S({state:d,options:D,name:k,instance:f})||d)}}}},update:rp(function(){return new Promise(function(m){f.forceUpdate(),m(d)})}),destroy:function(){g(),u=!0}};if(!kl(o,l))return f;f.setOptions(h).then(function(m){!u&&h.onFirstUpdate&&h.onFirstUpdate(m)});function p(){d.orderedModifiers.forEach(function(m){var b=m.name,A=m.options,T=A===void 0?{}:A,y=m.effect;if(typeof y=="function"){var E=y({state:d,name:b,instance:f,options:T}),S=function(){};c.push(E||S)}})}function g(){c.forEach(function(m){return m()}),c=[]}return f}}var op=[Cf,qf,kf,fl,Yf,Vf,Qf,Sf,zf],lp=ap({defaultModifiers:op}),hp="tippy-box",Dl="tippy-content",dp="tippy-backdrop",Cl="tippy-arrow",Il="tippy-svg-arrow",ii={passive:!0,capture:!0},Pl=function(){return document.body};function Cn(r,t,e){if(Array.isArray(r)){var i=r[t];return i??(Array.isArray(e)?e[t]:e)}return r}function In(r,t){var e={}.toString.call(r);return e.indexOf("[object")===0&&e.indexOf(t+"]")>-1}function Ol(r,t){return typeof r=="function"?r.apply(void 0,t):r}function Ml(r,t){if(t===0)return r;var e;return function(i){clearTimeout(e),e=setTimeout(function(){r(i)},t)}}function cp(r){return r.split(/\s+/).filter(Boolean)}function Si(r){return[].concat(r)}function Fl(r,t){r.indexOf(t)===-1&&r.push(t)}function up(r){return r.filter(function(t,e){return r.indexOf(t)===e})}function fp(r){return r.split("-")[0]}function er(r){return[].slice.call(r)}function Nl(r){return Object.keys(r).reduce(function(t,e){return r[e]!==void 0&&(t[e]=r[e]),t},{})}function ps(){return document.createElement("div")}function ir(r){return["Element","Fragment"].some(function(t){return In(r,t)})}function pp(r){return In(r,"NodeList")}function gp(r){return In(r,"MouseEvent")}function mp(r){return!!(r&&r._tippy&&r._tippy.reference===r)}function vp(r){return ir(r)?[r]:pp(r)?er(r):Array.isArray(r)?r:er(document.querySelectorAll(r))}function Pn(r,t){r.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function Ul(r,t){r.forEach(function(e){e&&e.setAttribute("data-state",t)})}function yp(r){var t,e=Si(r),i=e[0];return i!=null&&(t=i.ownerDocument)!=null&&t.body?i.ownerDocument:document}function bp(r,t){var e=t.clientX,i=t.clientY;return r.every(function(s){var n=s.popperRect,a=s.popperState,o=s.props,l=o.interactiveBorder,h=fp(a.placement),d=a.modifiersData.offset;if(!d)return!0;var c=h==="bottom"?d.top.y:0,u=h==="top"?d.bottom.y:0,f=h==="right"?d.left.x:0,p=h==="left"?d.right.x:0,g=n.top-i+c>l,m=i-n.bottom-u>l,b=n.left-e+f>l,A=e-n.right-p>l;return g||m||b||A})}function On(r,t,e){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(s){r[i](s,e)})}function Bl(r,t){for(var e=t;e;){var i;if(r.contains(e))return!0;e=e.getRootNode==null||(i=e.getRootNode())==null?void 0:i.host}return!1}var fe={isTouch:!1},Hl=0;function Ap(){fe.isTouch||(fe.isTouch=!0,window.performance&&document.addEventListener("mousemove",Gl))}function Gl(){var r=performance.now();r-Hl<20&&(fe.isTouch=!1,document.removeEventListener("mousemove",Gl)),Hl=r}function Tp(){var r=document.activeElement;if(mp(r)){var t=r._tippy;r.blur&&!t.state.isVisible&&r.blur()}}function Ep(){document.addEventListener("touchstart",Ap,ii),window.addEventListener("blur",Tp)}var wp=typeof window<"u"&&typeof document<"u",Sp=wp?!!window.msCrypto:!1,Lp={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},Rp={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},ae=Object.assign({appendTo:Pl,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},Lp,Rp),xp=Object.keys(ae),kp=function(t){var e=Object.keys(t);e.forEach(function(i){ae[i]=t[i]})};function Vl(r){var t=r.plugins||[],e=t.reduce(function(i,s){var n=s.name,a=s.defaultValue;if(n){var o;i[n]=r[n]!==void 0?r[n]:(o=ae[n])!=null?o:a}return i},{});return Object.assign({},r,e)}function Dp(r,t){var e=t?Object.keys(Vl(Object.assign({},ae,{plugins:t}))):xp,i=e.reduce(function(s,n){var a=(r.getAttribute("data-tippy-"+n)||"").trim();if(!a)return s;if(n==="content")s[n]=a;else try{s[n]=JSON.parse(a)}catch{s[n]=a}return s},{});return i}function jl(r,t){var e=Object.assign({},t,{content:Ol(t.content,[r])},t.ignoreAttributes?{}:Dp(r,t.plugins));return e.aria=Object.assign({},ae.aria,e.aria),e.aria={expanded:e.aria.expanded==="auto"?t.interactive:e.aria.expanded,content:e.aria.content==="auto"?t.interactive?null:"describedby":e.aria.content},e}var Cp=function(){return"innerHTML"};function Mn(r,t){r[Cp()]=t}function zl(r){var t=ps();return r===!0?t.className=Cl:(t.className=Il,ir(r)?t.appendChild(r):Mn(t,r)),t}function Kl(r,t){ir(t.content)?(Mn(r,""),r.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?Mn(r,t.content):r.textContent=t.content)}function Fn(r){var t=r.firstElementChild,e=er(t.children);return{box:t,content:e.find(function(i){return i.classList.contains(Dl)}),arrow:e.find(function(i){return i.classList.contains(Cl)||i.classList.contains(Il)}),backdrop:e.find(function(i){return i.classList.contains(dp)})}}function Wl(r){var t=ps(),e=ps();e.className=hp,e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var i=ps();i.className=Dl,i.setAttribute("data-state","hidden"),Kl(i,r.props),t.appendChild(e),e.appendChild(i),s(r.props,r.props);function s(n,a){var o=Fn(t),l=o.box,h=o.content,d=o.arrow;a.theme?l.setAttribute("data-theme",a.theme):l.removeAttribute("data-theme"),typeof a.animation=="string"?l.setAttribute("data-animation",a.animation):l.removeAttribute("data-animation"),a.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth=typeof a.maxWidth=="number"?a.maxWidth+"px":a.maxWidth,a.role?l.setAttribute("role",a.role):l.removeAttribute("role"),(n.content!==a.content||n.allowHTML!==a.allowHTML)&&Kl(h,r.props),a.arrow?d?n.arrow!==a.arrow&&(l.removeChild(d),l.appendChild(zl(a.arrow))):l.appendChild(zl(a.arrow)):d&&l.removeChild(d)}return{popper:t,onUpdate:s}}Wl.$$tippy=!0;var Ip=1,sr=[],Nn=[];function Pp(r,t){var e=jl(r,Object.assign({},ae,Vl(Nl(t)))),i,s,n,a=!1,o=!1,l=!1,h=!1,d,c,u,f=[],p=Ml(hi,e.interactiveDebounce),g,m=Ip++,b=null,A=up(e.plugins),T={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},y={id:m,reference:r,popper:ps(),popperInstance:b,props:e,state:T,plugins:A,clearDelayTimeouts:Ir,setProps:Pr,setContent:Or,show:Ly,hide:Ry,hideWithInteractivity:xy,enable:Rs,disable:Cr,unmount:ky,destroy:Dy};if(!e.render)return y;var E=e.render(y),S=E.popper,L=E.onUpdate;S.setAttribute("data-tippy-root",""),S.id="tippy-"+y.id,y.popper=S,r._tippy=y,S._tippy=y;var D=A.map(function(M){return M.fn(y)}),k=r.hasAttribute("aria-expanded");return je(),V(),B(),U("onCreate",[y]),e.showOnCreate&&Ls(),S.addEventListener("mouseenter",function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()}),S.addEventListener("mouseleave",function(){y.props.interactive&&y.props.trigger.indexOf("mouseenter")>=0&&W().addEventListener("mousemove",p)}),y;function x(){var M=y.props.touch;return Array.isArray(M)?M:[M,0]}function F(){return x()[0]==="hold"}function O(){var M;return!!((M=y.props.render)!=null&&M.$$tippy)}function G(){return g||r}function W(){var M=G().parentNode;return M?yp(M):document}function w(){return Fn(S)}function I(M){return y.state.isMounted&&!y.state.isVisible||fe.isTouch||d&&d.type==="focus"?0:Cn(y.props.delay,M?0:1,ae.delay)}function B(M){M===void 0&&(M=!1),S.style.pointerEvents=y.props.interactive&&!M?"":"none",S.style.zIndex=""+y.props.zIndex}function U(M,z,Z){if(Z===void 0&&(Z=!0),D.forEach(function(it){it[M]&&it[M].apply(it,z)}),Z){var nt;(nt=y.props)[M].apply(nt,z)}}function H(){var M=y.props.aria;if(M.content){var z="aria-"+M.content,Z=S.id,nt=Si(y.props.triggerTarget||r);nt.forEach(function(it){var Ht=it.getAttribute(z);if(y.state.isVisible)it.setAttribute(z,Ht?Ht+" "+Z:Z);else{var ie=Ht&&Ht.replace(Z,"").trim();ie?it.setAttribute(z,ie):it.removeAttribute(z)}})}}function V(){if(!(k||!y.props.aria.expanded)){var M=Si(y.props.triggerTarget||r);M.forEach(function(z){y.props.interactive?z.setAttribute("aria-expanded",y.state.isVisible&&z===G()?"true":"false"):z.removeAttribute("aria-expanded")})}}function J(){W().removeEventListener("mousemove",p),sr=sr.filter(function(M){return M!==p})}function $(M){if(!(fe.isTouch&&(l||M.type==="mousedown"))){var z=M.composedPath&&M.composedPath()[0]||M.target;if(!(y.props.interactive&&Bl(S,z))){if(Si(y.props.triggerTarget||r).some(function(Z){return Bl(Z,z)})){if(fe.isTouch||y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else U("onClickOutside",[y,M]);y.props.hideOnClick===!0&&(y.clearDelayTimeouts(),y.hide(),o=!0,setTimeout(function(){o=!1}),y.state.isMounted||Pt())}}}function Q(){l=!0}function rt(){l=!1}function tt(){var M=W();M.addEventListener("mousedown",$,!0),M.addEventListener("touchend",$,ii),M.addEventListener("touchstart",rt,ii),M.addEventListener("touchmove",Q,ii)}function Pt(){var M=W();M.removeEventListener("mousedown",$,!0),M.removeEventListener("touchend",$,ii),M.removeEventListener("touchstart",rt,ii),M.removeEventListener("touchmove",Q,ii)}function St(M,z){Te(M,function(){!y.state.isVisible&&S.parentNode&&S.parentNode.contains(S)&&z()})}function yt(M,z){Te(M,z)}function Te(M,z){var Z=w().box;function nt(it){it.target===Z&&(On(Z,"remove",nt),z())}if(M===0)return z();On(Z,"remove",c),On(Z,"add",nt),c=nt}function bt(M,z,Z){Z===void 0&&(Z=!1);var nt=Si(y.props.triggerTarget||r);nt.forEach(function(it){it.addEventListener(M,z,Z),f.push({node:it,eventType:M,handler:z,options:Z})})}function je(){F()&&(bt("touchstart",ze,{passive:!0}),bt("touchend",At,{passive:!0})),cp(y.props.trigger).forEach(function(M){if(M!=="manual")switch(bt(M,ze),M){case"mouseenter":bt("mouseleave",At);break;case"focus":bt(Sp?"focusout":"blur",gt);break;case"focusin":bt("focusout",gt);break}})}function Ni(){f.forEach(function(M){var z=M.node,Z=M.eventType,nt=M.handler,it=M.options;z.removeEventListener(Z,nt,it)}),f=[]}function ze(M){var z,Z=!1;if(!(!y.state.isEnabled||Xt(M)||o)){var nt=((z=d)==null?void 0:z.type)==="focus";d=M,g=M.currentTarget,V(),!y.state.isVisible&&gp(M)&&sr.forEach(function(it){return it(M)}),M.type==="click"&&(y.props.trigger.indexOf("mouseenter")<0||a)&&y.props.hideOnClick!==!1&&y.state.isVisible?Z=!0:Ls(M),M.type==="click"&&(a=!Z),Z&&!nt&&di(M)}}function hi(M){var z=M.target,Z=G().contains(z)||S.contains(z);if(!(M.type==="mousemove"&&Z)){var nt=qt().concat(S).map(function(it){var Ht,ie=it._tippy,Ui=(Ht=ie.popperInstance)==null?void 0:Ht.state;return Ui?{popperRect:it.getBoundingClientRect(),popperState:Ui,props:e}:null}).filter(Boolean);bp(nt,M)&&(J(),di(M))}}function At(M){var z=Xt(M)||y.props.trigger.indexOf("click")>=0&&a;if(!z){if(y.props.interactive){y.hideWithInteractivity(M);return}di(M)}}function gt(M){y.props.trigger.indexOf("focusin")<0&&M.target!==G()||y.props.interactive&&M.relatedTarget&&S.contains(M.relatedTarget)||di(M)}function Xt(M){return fe.isTouch?F()!==M.type.indexOf("touch")>=0:!1}function ut(){Tt();var M=y.props,z=M.popperOptions,Z=M.placement,nt=M.offset,it=M.getReferenceClientRect,Ht=M.moveTransition,ie=O()?Fn(S).arrow:null,Ui=it?{getBoundingClientRect:it,contextElement:it.contextElement||G()}:r,tc={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Mr){var Bi=Mr.state;if(O()){var Cy=w(),Wa=Cy.box;["placement","reference-hidden","escaped"].forEach(function(Fr){Fr==="placement"?Wa.setAttribute("data-placement",Bi.placement):Bi.attributes.popper["data-popper-"+Fr]?Wa.setAttribute("data-"+Fr,""):Wa.removeAttribute("data-"+Fr)}),Bi.attributes.popper={}}}},ci=[{name:"offset",options:{offset:nt}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!Ht}},tc];O()&&ie&&ci.push({name:"arrow",options:{element:ie,padding:3}}),ci.push.apply(ci,(z==null?void 0:z.modifiers)||[]),y.popperInstance=lp(Ui,S,Object.assign({},z,{placement:Z,onFirstUpdate:u,modifiers:ci}))}function Tt(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function Ot(){var M=y.props.appendTo,z,Z=G();y.props.interactive&&M===Pl||M==="parent"?z=Z.parentNode:z=Ol(M,[Z]),z.contains(S)||z.appendChild(S),y.state.isMounted=!0,ut()}function qt(){return er(S.querySelectorAll("[data-tippy-root]"))}function Ls(M){y.clearDelayTimeouts(),M&&U("onTrigger",[y,M]),tt();var z=I(!0),Z=x(),nt=Z[0],it=Z[1];fe.isTouch&&nt==="hold"&&it&&(z=it),z?i=setTimeout(function(){y.show()},z):y.show()}function di(M){if(y.clearDelayTimeouts(),U("onUntrigger",[y,M]),!y.state.isVisible){Pt();return}if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(M.type)>=0&&a)){var z=I(!1);z?s=setTimeout(function(){y.state.isVisible&&y.hide()},z):n=requestAnimationFrame(function(){y.hide()})}}function Rs(){y.state.isEnabled=!0}function Cr(){y.hide(),y.state.isEnabled=!1}function Ir(){clearTimeout(i),clearTimeout(s),cancelAnimationFrame(n)}function Pr(M){if(!y.state.isDestroyed){U("onBeforeUpdate",[y,M]),Ni();var z=y.props,Z=jl(r,Object.assign({},z,Nl(M),{ignoreAttributes:!0}));y.props=Z,je(),z.interactiveDebounce!==Z.interactiveDebounce&&(J(),p=Ml(hi,Z.interactiveDebounce)),z.triggerTarget&&!Z.triggerTarget?Si(z.triggerTarget).forEach(function(nt){nt.removeAttribute("aria-expanded")}):Z.triggerTarget&&r.removeAttribute("aria-expanded"),V(),B(),L&&L(z,Z),y.popperInstance&&(ut(),qt().forEach(function(nt){requestAnimationFrame(nt._tippy.popperInstance.forceUpdate)})),U("onAfterUpdate",[y,M])}}function Or(M){y.setProps({content:M})}function Ly(){var M=y.state.isVisible,z=y.state.isDestroyed,Z=!y.state.isEnabled,nt=fe.isTouch&&!y.props.touch,it=Cn(y.props.duration,0,ae.duration);if(!(M||z||Z||nt)&&!G().hasAttribute("disabled")&&(U("onShow",[y],!1),y.props.onShow(y)!==!1)){if(y.state.isVisible=!0,O()&&(S.style.visibility="visible"),B(),tt(),y.state.isMounted||(S.style.transition="none"),O()){var Ht=w(),ie=Ht.box,Ui=Ht.content;Pn([ie,Ui],0)}u=function(){var ci;if(!(!y.state.isVisible||h)){if(h=!0,S.offsetHeight,S.style.transition=y.props.moveTransition,O()&&y.props.animation){var Ka=w(),Mr=Ka.box,Bi=Ka.content;Pn([Mr,Bi],it),Ul([Mr,Bi],"visible")}H(),V(),Fl(Nn,y),(ci=y.popperInstance)==null||ci.forceUpdate(),U("onMount",[y]),y.props.animation&&O()&&yt(it,function(){y.state.isShown=!0,U("onShown",[y])})}},Ot()}}function Ry(){var M=!y.state.isVisible,z=y.state.isDestroyed,Z=!y.state.isEnabled,nt=Cn(y.props.duration,1,ae.duration);if(!(M||z||Z)&&(U("onHide",[y],!1),y.props.onHide(y)!==!1)){if(y.state.isVisible=!1,y.state.isShown=!1,h=!1,a=!1,O()&&(S.style.visibility="hidden"),J(),Pt(),B(!0),O()){var it=w(),Ht=it.box,ie=it.content;y.props.animation&&(Pn([Ht,ie],nt),Ul([Ht,ie],"hidden"))}H(),V(),y.props.animation?O()&&St(nt,y.unmount):y.unmount()}}function xy(M){W().addEventListener("mousemove",p),Fl(sr,p),p(M)}function ky(){y.state.isVisible&&y.hide(),y.state.isMounted&&(Tt(),qt().forEach(function(M){M._tippy.unmount()}),S.parentNode&&S.parentNode.removeChild(S),Nn=Nn.filter(function(M){return M!==y}),y.state.isMounted=!1,U("onHidden",[y]))}function Dy(){y.state.isDestroyed||(y.clearDelayTimeouts(),y.unmount(),Ni(),delete r._tippy,y.state.isDestroyed=!0,U("onDestroy",[y]))}}function si(r,t){t===void 0&&(t={});var e=ae.plugins.concat(t.plugins||[]);Ep();var i=Object.assign({},t,{plugins:e}),s=vp(r),n=s.reduce(function(a,o){var l=o&&Pp(o,i);return l&&a.push(l),a},[]);return ir(r)?n[0]:n}si.defaultProps=ae,si.setDefaultProps=kp,si.currentInput=fe,Object.assign({},fl,{effect:function(t){var e=t.state,i={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(e.elements.popper.style,i.popper),e.styles=i,e.elements.arrow&&Object.assign(e.elements.arrow.style,i.arrow)}}),si.setDefaultProps({render:Wl});/**
|
160
|
+
* @license
|
161
|
+
* Copyright 2018 Google LLC
|
162
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
163
|
+
*/const Yl="important",Op=" !"+Yl,Mp=bi(class extends is{constructor(r){var t;if(super(r),r.type!==yi.ATTRIBUTE||r.name!=="style"||((t=r.strings)===null||t===void 0?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(r){return Object.keys(r).reduce((t,e)=>{const i=r[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(r,[t]){const{style:e}=r.element;if(this.ut===void 0){this.ut=new Set;for(const i in t)this.ut.add(i);return this.render(t)}this.ut.forEach(i=>{t[i]==null&&(this.ut.delete(i),i.includes("-")?e.removeProperty(i):e[i]="")});for(const i in t){const s=t[i];if(s!=null){this.ut.add(i);const n=typeof s=="string"&&s.endsWith(Op);i.includes("-")||n?e.setProperty(i,n?s.slice(0,-11):s,n?Yl:""):e[i]=s}}return se}}),Fp=5;class Np{constructor(t){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._fakeBufferSegments=[],this._canvas=re(),this._controls=re(),this.host=t}set activeScenes(t){if(t!==this._activeScenes){const e=t[0],i=this._activeScenes[0];this._activeScenes=t,e!==i&&(this.host.dispatchEvent(new CustomEvent("scenechange",{detail:t[0]})),this.host.requestUpdate())}}get activeScenes(){return this._activeScenes}set currentTime(t){var e,i,s,n,a;const o=Math.min(this.host.duration,Math.max(0,t));this._currentTime=o,this.activeScenes=((e=this.host.scenes)==null?void 0:e.filter(({start:d,duration:c})=>o>=d&&o<=d+c))??[],this._upcomingScenes=((i=this.host.scenes)==null?void 0:i.filter(({start:d})=>o>=d-Fp&&o<d))??[],this.loadScenes(),this.syncVideoState(),(s=this._controls.value)==null||s.setAttribute("currentTime",o.toString());const l=this.activeScenes[0],h=Zo((n=l==null?void 0:l.video)==null?void 0:n.captions);this.caption=((a=h.find(({start:d,end:c})=>{var u;const f=o-l.start+(((u=l.video)==null?void 0:u.start)??0);return d&&c&&f>=Ks(d)&&f<=Ks(c)}))==null?void 0:a.text)??"",this.draw(o),!this.host.paused&&!this.host.loading&&!this.host.processing&&!this.host.waiting&&!this.host.stalled&&this.host.dispatchEvent(new CustomEvent("timeupdate",{detail:o}))}get currentTime(){return this._currentTime}set fakeBufferSegments(t){t!==this._fakeBufferSegments&&(this._fakeBufferSegments=t,this.host.requestUpdate())}get fakeBufferSegments(){return this._fakeBufferSegments}set caption(t){t!==this._caption&&(this._caption=t,this.host.requestUpdate())}get caption(){return this._caption}canvas(){return ne(this._canvas)}controls(){return ne(this._controls)}loadScenes(){var t;let e=this.fakeBufferSegments;(t=this.host.scenes)==null||t.forEach(i=>{var s,n;const{start:a,duration:o,video:l}=i,h=this.activeScenes.includes(i),d=(this._upcomingScenes.includes(i)||h)&&(this.host.currentTime>0||this.host.preload==="auto"||!this.host.paused);if(l){const{id:c,hls:u,node:f,start:p,duration:g}=l,m=this.host.videoState[c];f&&m&&(f.currentTime>=p+g||f.ended||d&&(u?(s=u.startLoadOnce)==null||s.call(u,f.currentTime):m.initialised||(n=f.startLoadOnce)==null||n.call(f)))}else if(d){const c={start:Math.max(0,a/this.host.duration*100),end:Math.min((a+o)/this.host.duration*100,100)};this.fakeBufferSegments.find(({start:u})=>u===c.start)||(e=[...e,c])}}),this.fakeBufferSegments=e}syncVideoState(){var t;(t=this.host.scenes)==null||t.forEach(e=>{if(e.video){const{id:i,node:s}=e.video,n=this.host.videoState[i],a=this.activeScenes.includes(e);if(s&&n)if(a&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(s.paused&&n.initialised)return s.play()}else s.paused||s.pause()}})}draw(t=this.currentTime){var e,i;this.host.sceneConfig&&this._canvas.value&&((i=(e=this.host).compilation)==null||i.call(e,{currentTime:t,scenes:this.host.sceneConfig,canvas:this._canvas.value}))}clear(){var t;const e=this._canvas.value;(t=e==null?void 0:e.getContext("2d"))==null||t.clearRect(0,0,e.width,e.height)}}function Up(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Xl={exports:{}};(function(r,t){(function(e){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,h,d){if(d=d||{},l=l.trim(),h=h.trim(),!h){if(!d.alwaysNormalize)return l;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");return c.path=o.normalizePath(c.path),o.buildURLFromParts(c)}var u=o.parseURL(h);if(!u)throw new Error("Error trying to parse relative URL.");if(u.scheme)return d.alwaysNormalize?(u.path=o.normalizePath(u.path),o.buildURLFromParts(u)):h;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 p=s.exec(f.path);f.netLoc=p[1],f.path=p[2]}f.netLoc&&!f.path&&(f.path="/");var g={scheme:f.scheme,netLoc:u.netLoc,path:null,params:u.params,query:u.query,fragment:u.fragment};if(!u.netLoc&&(g.netLoc=f.netLoc,u.path[0]!=="/"))if(!u.path)g.path=f.path,u.params||(g.params=f.params,u.query||(g.query=f.query));else{var m=f.path,b=m.substring(0,m.lastIndexOf("/")+1)+u.path;g.path=o.normalizePath(b)}return g.path===null&&(g.path=d.alwaysNormalize?o.normalizePath(u.path):u.path),o.buildURLFromParts(g)},parseURL:function(l){var h=i.exec(l);return h?{scheme:h[1]||"",netLoc:h[2]||"",path:h[3]||"",params:h[4]||"",query:h[5]||"",fragment:h[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}};r.exports=o})()})(Xl);var Un=Xl.exports;function ql(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),e.push.apply(e,i)}return e}function jt(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?ql(Object(e),!0).forEach(function(i){Bp(r,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):ql(Object(e)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i))})}return r}function Bp(r,t,e){return t=Gp(t),t in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function Et(){return Et=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},Et.apply(this,arguments)}function Hp(r,t){if(typeof r!="object"||r===null)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var i=e.call(r,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function Gp(r){var t=Hp(r,"string");return typeof t=="symbol"?t:String(t)}const K=Number.isFinite||function(r){return typeof r=="number"&&isFinite(r)};let v=function(r){return r.MEDIA_ATTACHING="hlsMediaAttaching",r.MEDIA_ATTACHED="hlsMediaAttached",r.MEDIA_DETACHING="hlsMediaDetaching",r.MEDIA_DETACHED="hlsMediaDetached",r.BUFFER_RESET="hlsBufferReset",r.BUFFER_CODECS="hlsBufferCodecs",r.BUFFER_CREATED="hlsBufferCreated",r.BUFFER_APPENDING="hlsBufferAppending",r.BUFFER_APPENDED="hlsBufferAppended",r.BUFFER_EOS="hlsBufferEos",r.BUFFER_FLUSHING="hlsBufferFlushing",r.BUFFER_FLUSHED="hlsBufferFlushed",r.MANIFEST_LOADING="hlsManifestLoading",r.MANIFEST_LOADED="hlsManifestLoaded",r.MANIFEST_PARSED="hlsManifestParsed",r.LEVEL_SWITCHING="hlsLevelSwitching",r.LEVEL_SWITCHED="hlsLevelSwitched",r.LEVEL_LOADING="hlsLevelLoading",r.LEVEL_LOADED="hlsLevelLoaded",r.LEVEL_UPDATED="hlsLevelUpdated",r.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",r.LEVELS_UPDATED="hlsLevelsUpdated",r.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",r.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",r.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",r.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",r.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",r.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",r.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",r.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",r.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",r.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",r.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",r.CUES_PARSED="hlsCuesParsed",r.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",r.INIT_PTS_FOUND="hlsInitPtsFound",r.FRAG_LOADING="hlsFragLoading",r.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",r.FRAG_LOADED="hlsFragLoaded",r.FRAG_DECRYPTED="hlsFragDecrypted",r.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",r.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",r.FRAG_PARSING_METADATA="hlsFragParsingMetadata",r.FRAG_PARSED="hlsFragParsed",r.FRAG_BUFFERED="hlsFragBuffered",r.FRAG_CHANGED="hlsFragChanged",r.FPS_DROP="hlsFpsDrop",r.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",r.ERROR="hlsError",r.DESTROYING="hlsDestroying",r.KEY_LOADING="hlsKeyLoading",r.KEY_LOADED="hlsKeyLoaded",r.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",r.BACK_BUFFER_REACHED="hlsBackBufferReached",r}({}),Y=function(r){return r.NETWORK_ERROR="networkError",r.MEDIA_ERROR="mediaError",r.KEY_SYSTEM_ERROR="keySystemError",r.MUX_ERROR="muxError",r.OTHER_ERROR="otherError",r}({}),P=function(r){return r.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",r.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",r.KEY_SYSTEM_NO_SESSION="keySystemNoSession",r.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",r.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",r.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",r.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",r.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",r.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",r.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",r.MANIFEST_LOAD_ERROR="manifestLoadError",r.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",r.MANIFEST_PARSING_ERROR="manifestParsingError",r.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",r.LEVEL_EMPTY_ERROR="levelEmptyError",r.LEVEL_LOAD_ERROR="levelLoadError",r.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",r.LEVEL_PARSING_ERROR="levelParsingError",r.LEVEL_SWITCH_ERROR="levelSwitchError",r.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",r.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",r.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",r.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",r.FRAG_LOAD_ERROR="fragLoadError",r.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",r.FRAG_DECRYPT_ERROR="fragDecryptError",r.FRAG_PARSING_ERROR="fragParsingError",r.FRAG_GAP="fragGap",r.REMUX_ALLOC_ERROR="remuxAllocError",r.KEY_LOAD_ERROR="keyLoadError",r.KEY_LOAD_TIMEOUT="keyLoadTimeOut",r.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",r.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",r.BUFFER_APPEND_ERROR="bufferAppendError",r.BUFFER_APPENDING_ERROR="bufferAppendingError",r.BUFFER_STALLED_ERROR="bufferStalledError",r.BUFFER_FULL_ERROR="bufferFullError",r.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",r.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",r.INTERNAL_EXCEPTION="internalException",r.INTERNAL_ABORTED="aborted",r.UNKNOWN="unknown",r}({});const ri=function(){},Bn={trace:ri,debug:ri,log:ri,warn:ri,info:ri,error:ri};let gs=Bn;function Vp(r){const t=self.console[r];return t?t.bind(self.console,`[${r}] >`):ri}function jp(r,...t){t.forEach(function(e){gs[e]=r[e]?r[e].bind(r):Vp(e)})}function zp(r,t){if(self.console&&r===!0||typeof r=="object"){jp(r,"debug","log","info","warn","error");try{gs.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch{gs=Bn}}else gs=Bn}const R=gs,Kp=/^(\d+)x(\d+)$/,Zl=/(.+?)=(".*?"|.*?)(?:,|$)/g;class dt{constructor(t){typeof t=="string"&&(t=dt.parseAttrList(t));for(const e in t)t.hasOwnProperty(e)&&(e.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(e)),this[e]=t[e])}decimalInteger(t){const e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(t){if(this[t]){let e=(this[t]||"0x").slice(2);e=(e.length&1?"0":"")+e;const i=new Uint8Array(e.length/2);for(let s=0;s<e.length/2;s++)i[s]=parseInt(e.slice(s*2,s*2+2),16);return i}else return null}hexadecimalIntegerAsNumber(t){const e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const i=this[t];return i?parseFloat(i):e}enumeratedString(t){return this[t]}bool(t){return this[t]==="YES"}decimalResolution(t){const e=Kp.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const i={},s='"';for(Zl.lastIndex=0;(e=Zl.exec(t))!==null;){let n=e[2];n.indexOf(s)===0&&n.lastIndexOf(s)===n.length-1&&(n=n.slice(1,-1));const a=e[1].trim();i[a]=n}return i}}function Wp(r){return r!=="ID"&&r!=="CLASS"&&r!=="START-DATE"&&r!=="DURATION"&&r!=="END-DATE"&&r!=="END-ON-NEXT"}function Yp(r){return r==="SCTE35-OUT"||r==="SCTE35-IN"}class Jl{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){const i=e.attr;for(const s in i)if(Object.prototype.hasOwnProperty.call(t,s)&&t[s]!==i[s]){R.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=s;break}t=Et(new dt({}),i,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const i=new Date(this.attr["END-DATE"]);K(i.getTime())&&(this._endDate=i)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const t=this.duration;return t!==null?new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(K(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&K(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class rr{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var at={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Ql{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[at.AUDIO]:null,[at.VIDEO]:null,[at.AUDIOVIDEO]:null},this.baseurl=t}setByteRange(t,e){const i=t.split("@",2),s=[];i.length===1?s[0]=e?e.byteRangeEndOffset:0:s[0]=parseInt(i[1]),s[1]=parseInt(i[0])+s[0],this._byteRange=s}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Un.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class Hn extends Ql{constructor(t,e){super(e),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new rr,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=t}get decryptdata(){const{levelkeys:t}=this;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{const i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!K(this.programDateTime))return null;const t=K(this.duration)?this.duration:0;return this.programDateTime+t*1e3}get encrypted(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){const e=Object.keys(this.levelkeys),i=e.length;if(i>1||i===1&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(t){if(this.levelkeys){const e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}}abortRequests(){var t,e;(t=this.loader)==null||t.abort(),(e=this.keyLoader)==null||e.abort()}setElementaryStreamInfo(t,e,i,s,n,a=!1){const{elementaryStreams:o}=this,l=o[t];if(!l){o[t]={startPTS:e,endPTS:i,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,e),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[at.AUDIO]=null,t[at.VIDEO]=null,t[at.AUDIOVIDEO]=null}}class Xp extends Ql{constructor(t,e,i,s,n){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new rr,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=s;const a=t.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(){const{elementaryStreams:t}=this;return!!(t.audio||t.video||t.audiovideo)}}const qp=10;class Zp{constructor(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}reloaded(t){if(!t){this.advanced=!0,this.updated=!0;return}const e=this.lastPartSn-t.lastPartSn,i=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!i||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||e===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(t.misses*.6):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?K(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||qp}get drift(){const t=this.driftEndTime-this.driftStartTime;return t>0?(this.driftEnd-this.driftStart)*1e3/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return(t=this.fragments)!=null&&t.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function Gn(r){return Uint8Array.from(atob(r),t=>t.charCodeAt(0))}function Jp(r){const t=_l(r).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e}function Qp(r){const t=function(e,i,s){const n=e[i];e[i]=e[s],e[s]=n};t(r,0,3),t(r,1,2),t(r,4,5),t(r,6,7)}function _p(r){const t=r.split(":");let e=null;if(t[0]==="data"&&t.length===2){const i=t[1].split(";"),s=i[i.length-1].split(",");if(s.length===2){const n=s[0]==="base64",a=s[1];n?(i.splice(-1,1),e=Gn(a)):e=Jp(a)}}return e}function _l(r){return Uint8Array.from(unescape(encodeURIComponent(r)),t=>t.charCodeAt(0))}var ct={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},zt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function $l(r){switch(r){case zt.FAIRPLAY:return ct.FAIRPLAY;case zt.PLAYREADY:return ct.PLAYREADY;case zt.WIDEVINE:return ct.WIDEVINE;case zt.CLEARKEY:return ct.CLEARKEY}}var th={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function $p(r){if(r===th.WIDEVINE)return ct.WIDEVINE}function eh(r){switch(r){case ct.FAIRPLAY:return zt.FAIRPLAY;case ct.PLAYREADY:return zt.PLAYREADY;case ct.WIDEVINE:return zt.WIDEVINE;case ct.CLEARKEY:return zt.CLEARKEY}}function Vn(r){const{drmSystems:t,widevineLicenseUrl:e}=r,i=t?[ct.FAIRPLAY,ct.WIDEVINE,ct.PLAYREADY,ct.CLEARKEY].filter(s=>!!t[s]):[];return!i[ct.WIDEVINE]&&e&&i.push(ct.WIDEVINE),i}const ih=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function tg(r,t,e,i){let s;switch(r){case ct.FAIRPLAY:s=["cenc","sinf"];break;case ct.WIDEVINE:case ct.PLAYREADY:s=["cenc"];break;case ct.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${r}`)}return eg(s,t,e,i)}function eg(r,t,e,i){return[{initDataTypes:r,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(s=>({contentType:`audio/mp4; codecs="${s}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:e.map(s=>({contentType:`video/mp4; codecs="${s}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function ni(r,t,e){return Uint8Array.prototype.slice?r.slice(t,e):new Uint8Array(Array.prototype.slice.call(r,t,e))}const jn=(r,t)=>t+10<=r.length&&r[t]===73&&r[t+1]===68&&r[t+2]===51&&r[t+3]<255&&r[t+4]<255&&r[t+6]<128&&r[t+7]<128&&r[t+8]<128&&r[t+9]<128,sh=(r,t)=>t+10<=r.length&&r[t]===51&&r[t+1]===68&&r[t+2]===73&&r[t+3]<255&&r[t+4]<255&&r[t+6]<128&&r[t+7]<128&&r[t+8]<128&&r[t+9]<128,nr=(r,t)=>{const e=t;let i=0;for(;jn(r,t);){i+=10;const s=ar(r,t+6);i+=s,sh(r,t+10)&&(i+=10),t+=i}if(i>0)return r.subarray(e,e+i)},ar=(r,t)=>{let e=0;return e=(r[t]&127)<<21,e|=(r[t+1]&127)<<14,e|=(r[t+2]&127)<<7,e|=r[t+3]&127,e},ig=(r,t)=>jn(r,t)&&ar(r,t+6)+10<=r.length-t,sg=r=>{const t=nh(r);for(let e=0;e<t.length;e++){const i=t[e];if(rh(i))return hg(i)}},rh=r=>r&&r.key==="PRIV"&&r.info==="com.apple.streaming.transportStreamTimestamp",rg=r=>{const t=String.fromCharCode(r[0],r[1],r[2],r[3]),e=ar(r,4),i=10;return{type:t,size:e,data:r.subarray(i,i+e)}},nh=r=>{let t=0;const e=[];for(;jn(r,t);){const i=ar(r,t+6);t+=10;const s=t+i;for(;t+8<s;){const n=rg(r.subarray(t)),a=ng(n);a&&e.push(a),t+=n.size+10}sh(r,t)&&(t+=10)}return e},ng=r=>r.type==="PRIV"?ag(r):r.type[0]==="W"?lg(r):og(r),ag=r=>{if(r.size<2)return;const t=pe(r.data,!0),e=new Uint8Array(r.data.subarray(t.length+1));return{key:r.type,info:t,data:e.buffer}},og=r=>{if(r.size<2)return;if(r.type==="TXXX"){let e=1;const i=pe(r.data.subarray(e),!0);e+=i.length+1;const s=pe(r.data.subarray(e));return{key:r.type,info:i,data:s}}const t=pe(r.data.subarray(1));return{key:r.type,data:t}},lg=r=>{if(r.type==="WXXX"){if(r.size<2)return;let e=1;const i=pe(r.data.subarray(e),!0);e+=i.length+1;const s=pe(r.data.subarray(e));return{key:r.type,info:i,data:s}}const t=pe(r.data);return{key:r.type,data:t}},hg=r=>{if(r.data.byteLength===8){const t=new Uint8Array(r.data),e=t[3]&1;let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,e&&(i+=4772185884e-2),Math.round(i)}},pe=(r,t=!1)=>{const e=dg();if(e){const h=e.decode(r);if(t){const d=h.indexOf("\0");return d!==-1?h.substring(0,d):h}return h.replace(/\0/g,"")}const i=r.length;let s,n,a,o="",l=0;for(;l<i;){if(s=r[l++],s===0&&t)return o;if(!(s===0||s===3))switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=r[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=r[l++],a=r[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o};let zn;function dg(){return!zn&&typeof self.TextDecoder<"u"&&(zn=new self.TextDecoder("utf-8")),zn}const ge={hexDump:function(r){let t="";for(let e=0;e<r.length;e++){let i=r[e].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},or=Math.pow(2,32)-1,cg=[].push,ah={video:1,audio:2,id3:3,text:4};function Ct(r){return String.fromCharCode.apply(null,r)}function oh(r,t){const e=r[t]<<8|r[t+1];return e<0?65536+e:e}function q(r,t){const e=lh(r,t);return e<0?4294967296+e:e}function lh(r,t){return r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3]}function Kn(r,t,e){r[t]=e>>24,r[t+1]=e>>16&255,r[t+2]=e>>8&255,r[t+3]=e&255}function et(r,t){const e=[];if(!t.length)return e;const i=r.byteLength;for(let s=0;s<i;){const n=q(r,s),a=Ct(r.subarray(s+4,s+8)),o=n>1?s+n:i;if(a===t[0])if(t.length===1)e.push(r.subarray(s+8,o));else{const l=et(r.subarray(s+8,o),t.slice(1));l.length&&cg.apply(e,l)}s=o}return e}function ug(r){const t=[],e=r[0];let i=8;const s=q(r,i);i+=4;const n=0,a=0;e===0?i+=8:i+=16,i+=2;let o=r.length+a;const l=oh(r,i);i+=2;for(let h=0;h<l;h++){let d=i;const c=q(r,d);d+=4;const u=c&2147483647;if((c&2147483648)>>>31===1)return R.warn("SIDX has hierarchical references (not supported)"),null;const f=q(r,d);d+=4,t.push({referenceSize:u,subsegmentDuration:f,info:{duration:f/s,start:o,end:o+u-1}}),o+=u,d+=4,i=d}return{earliestPresentationTime:n,timescale:s,version:e,referencesCount:l,references:t}}function hh(r){const t=[],e=et(r,["moov","trak"]);for(let i=0;i<e.length;i++){const s=e[i],n=et(s,["tkhd"])[0];if(n){let a=n[0],o=a===0?12:20;const l=q(n,o),h=et(s,["mdia","mdhd"])[0];if(h){a=h[0],o=a===0?12:20;const d=q(h,o),c=et(s,["mdia","hdlr"])[0];if(c){const u=Ct(c.subarray(8,12)),f={soun:at.AUDIO,vide:at.VIDEO}[u];if(f){const p=et(s,["mdia","minf","stbl","stsd"])[0];let g;p&&(g=Ct(p.subarray(12,16))),t[l]={timescale:d,type:f},t[f]={timescale:d,id:l,codec:g}}}}}}return et(r,["moov","mvex","trex"]).forEach(i=>{const s=q(i,4),n=t[s];n&&(n.default={duration:q(i,12),flags:q(i,20)})}),t}function fg(r,t){if(!r||!t)return r;const e=t.keyId;return e&&t.isCommonEncryption&&et(r,["moov","trak"]).forEach(i=>{const s=et(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let n=et(s,["enca"]);const a=n.length>0;a||(n=et(s,["encv"])),n.forEach(o=>{const l=a?o.subarray(28):o.subarray(78);et(l,["sinf"]).forEach(h=>{const d=dh(h);if(d){const c=d.subarray(8,24);c.some(u=>u!==0)||(R.log(`[eme] Patching keyId in 'enc${a?"a":"v"}>sinf>>tenc' box: ${ge.hexDump(c)} -> ${ge.hexDump(e)}`),d.set(e,8))}})})}),r}function dh(r){const t=et(r,["schm"])[0];if(t){const e=Ct(t.subarray(4,8));if(e==="cbcs"||e==="cenc")return et(r,["schi","tenc"])[0]}return R.error("[eme] missing 'schm' box"),null}function pg(r,t){return et(t,["moof","traf"]).reduce((e,i)=>{const s=et(i,["tfdt"])[0],n=s[0],a=et(i,["tfhd"]).reduce((o,l)=>{const h=q(l,4),d=r[h];if(d){let c=q(s,4);if(n===1){if(c===or)return R.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;c*=or+1,c+=q(s,8)}const u=d.timescale||9e4,f=c/u;if(isFinite(f)&&(o===null||f<o))return f}return o},null);return a!==null&&isFinite(a)&&(e===null||a<e)?a:e},null)}function gg(r,t){let e=0,i=0,s=0;const n=et(r,["moof","traf"]);for(let a=0;a<n.length;a++){const o=n[a],l=et(o,["tfhd"])[0],h=q(l,4),d=t[h];if(!d)continue;const c=d.default,u=q(l,0)|(c==null?void 0:c.flags);let f=c==null?void 0:c.duration;u&8&&(u&2?f=q(l,12):f=q(l,8));const p=d.timescale||9e4,g=et(o,["trun"]);for(let m=0;m<g.length;m++){if(e=mg(g[m]),!e&&f){const b=q(g[m],4);e=f*b}d.type===at.VIDEO?i+=e/p:d.type===at.AUDIO&&(s+=e/p)}}if(i===0&&s===0){let a=0;const o=et(r,["sidx"]);for(let l=0;l<o.length;l++){const h=ug(o[l]);h!=null&&h.references&&(a+=h.references.reduce((d,c)=>d+c.info.duration||0,0))}return a}return i||s}function mg(r){const t=q(r,0);let e=8;t&1&&(e+=4),t&4&&(e+=4);let i=0;const s=q(r,4);for(let n=0;n<s;n++){if(t&256){const a=q(r,e);i+=a,e+=4}t&512&&(e+=4),t&1024&&(e+=4),t&2048&&(e+=4)}return i}function vg(r,t,e){et(t,["moof","traf"]).forEach(i=>{et(i,["tfhd"]).forEach(s=>{const n=q(s,4),a=r[n];if(!a)return;const o=a.timescale||9e4;et(i,["tfdt"]).forEach(l=>{const h=l[0];let d=q(l,4);if(h===0)d-=e*o,d=Math.max(d,0),Kn(l,4,d);else{d*=Math.pow(2,32),d+=q(l,8),d-=e*o,d=Math.max(d,0);const c=Math.floor(d/(or+1)),u=Math.floor(d%(or+1));Kn(l,4,c),Kn(l,8,u)}})})})}function yg(r){const t={valid:null,remainder:null},e=et(r,["moof"]);if(e){if(e.length<2)return t.remainder=r,t}else return t;const i=e[e.length-1];return t.valid=ni(r,0,i.byteOffset-8),t.remainder=ni(r,i.byteOffset-8),t}function ai(r,t){const e=new Uint8Array(r.length+t.length);return e.set(r),e.set(t,r.length),e}function ch(r,t){const e=[],i=t.samples,s=t.timescale,n=t.id;let a=!1;return et(i,["moof"]).map(o=>{const l=o.byteOffset-8;et(o,["traf"]).map(h=>{const d=et(h,["tfdt"]).map(c=>{const u=c[0];let f=q(c,4);return u===1&&(f*=Math.pow(2,32),f+=q(c,8)),f/s})[0];return d!==void 0&&(r=d),et(h,["tfhd"]).map(c=>{const u=q(c,4),f=q(c,0)&16777215,p=(f&1)!==0,g=(f&2)!==0,m=(f&8)!==0;let b=0;const A=(f&16)!==0;let T=0;const y=(f&32)!==0;let E=8;u===n&&(p&&(E+=8),g&&(E+=4),m&&(b=q(c,E),E+=4),A&&(T=q(c,E),E+=4),y&&(E+=4),t.type==="video"&&(a=bg(t.codec)),et(h,["trun"]).map(S=>{const L=S[0],D=q(S,0)&16777215,k=(D&1)!==0;let x=0;const F=(D&4)!==0,O=(D&256)!==0;let G=0;const W=(D&512)!==0;let w=0;const I=(D&1024)!==0,B=(D&2048)!==0;let U=0;const H=q(S,4);let V=8;k&&(x=q(S,V),V+=4),F&&(V+=4);let J=x+l;for(let $=0;$<H;$++){if(O?(G=q(S,V),V+=4):G=b,W?(w=q(S,V),V+=4):w=T,I&&(V+=4),B&&(L===0?U=q(S,V):U=lh(S,V),V+=4),t.type===at.VIDEO){let Q=0;for(;Q<w;){const rt=q(i,J);if(J+=4,Ag(a,i[J])){const tt=i.subarray(J,J+rt);uh(tt,a?2:1,r+U/s,e)}J+=rt,Q+=rt+4}}r+=G/s}}))})})}),e}function bg(r){if(!r)return!1;const t=r.indexOf("."),e=t<0?r:r.substring(0,t);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function Ag(r,t){if(r){const e=t>>1&63;return e===39||e===40}else return(t&31)===6}function uh(r,t,e,i){const s=fh(r);let n=0;n+=t;let a=0,o=0,l=!1,h=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;h=s[n++],a+=h}while(h===255);o=0;do{if(n>=s.length)break;h=s[n++],o+=h}while(h===255);const d=s.length-n;if(!l&&a===4&&n<s.length){if(l=!0,s[n++]===181){const c=oh(s,n);if(n+=2,c===49){const u=q(s,n);if(n+=4,u===1195456820){const f=s[n++];if(f===3){const p=s[n++],g=31&p,m=64&p,b=m?2+g*3:0,A=new Uint8Array(b);if(m){A[0]=p;for(let T=1;T<b;T++)A[T]=s[n++]}i.push({type:f,payloadType:a,pts:e,bytes:A})}}}}}else if(a===5&&o<d){if(l=!0,o>16){const c=[];for(let p=0;p<16;p++){const g=s[n++].toString(16);c.push(g.length==1?"0"+g:g),(p===3||p===5||p===7||p===9)&&c.push("-")}const u=o-16,f=new Uint8Array(u);for(let p=0;p<u;p++)f[p]=s[n++];i.push({payloadType:a,pts:e,uuid:c.join(""),userData:pe(f),userDataBytes:f})}}else if(o<d)n+=o;else if(o>d)break}}function fh(r){const t=r.byteLength,e=[];let i=1;for(;i<t-2;)r[i]===0&&r[i+1]===0&&r[i+2]===3?(e.push(i+2),i+=2):i++;if(e.length===0)return r;const s=t-e.length,n=new Uint8Array(s);let a=0;for(i=0;i<s;a++,i++)a===e[0]&&(a++,e.shift()),n[i]=r[a];return n}function Tg(r){const t=r[0];let e="",i="",s=0,n=0,a=0,o=0,l=0,h=0;if(t===0){for(;Ct(r.subarray(h,h+1))!=="\0";)e+=Ct(r.subarray(h,h+1)),h+=1;for(e+=Ct(r.subarray(h,h+1)),h+=1;Ct(r.subarray(h,h+1))!=="\0";)i+=Ct(r.subarray(h,h+1)),h+=1;i+=Ct(r.subarray(h,h+1)),h+=1,s=q(r,12),n=q(r,16),o=q(r,20),l=q(r,24),h=28}else if(t===1){h+=4,s=q(r,h),h+=4;const c=q(r,h);h+=4;const u=q(r,h);for(h+=4,a=4294967296*c+u,Number.isSafeInteger(a)||(a=Number.MAX_SAFE_INTEGER,R.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=q(r,h),h+=4,l=q(r,h),h+=4;Ct(r.subarray(h,h+1))!=="\0";)e+=Ct(r.subarray(h,h+1)),h+=1;for(e+=Ct(r.subarray(h,h+1)),h+=1;Ct(r.subarray(h,h+1))!=="\0";)i+=Ct(r.subarray(h,h+1)),h+=1;i+=Ct(r.subarray(h,h+1)),h+=1}const d=r.subarray(h,r.byteLength);return{schemeIdUri:e,value:i,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:d}}function Eg(r,...t){const e=t.length;let i=8,s=e;for(;s--;)i+=t[s].byteLength;const 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(r,4),s=0,i=8;s<e;s++)n.set(t[s],i),i+=t[s].byteLength;return n}function wg(r,t,e){if(r.byteLength!==16)throw new RangeError("Invalid system id");let i,s;if(t){i=1,s=new Uint8Array(t.length*16);for(let o=0;o<t.length;o++){const l=t[o];if(l.byteLength!==16)throw new RangeError("Invalid key");s.set(l,o*16)}}else i=0,s=new Uint8Array;let n;i>0?(n=new Uint8Array(4),t.length>0&&new DataView(n.buffer).setUint32(0,t.length,!1)):n=new Uint8Array;const a=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(a.buffer).setUint32(0,e.byteLength,!1),Eg([112,115,115,104],new Uint8Array([i,0,0,0]),r,n,s,a,e||new Uint8Array)}function Sg(r){if(!(r instanceof ArrayBuffer)||r.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},e=new DataView(r),i=e.getUint32(0);if(r.byteLength!==i&&i>44||e.getUint32(4)!==1886614376||(t.version=e.getUint32(8)>>>24,t.version>1))return null;t.systemId=ge.hexDump(new Uint8Array(r,12,16));const s=e.getUint32(28);if(t.version===0){if(i-32<s)return null;t.data=new Uint8Array(r,32,s)}else if(t.version===1){t.kids=[];for(let n=0;n<s;n++)t.kids.push(new Uint8Array(r,32+n*16,16))}return t}let lr={};class ms{static clearKeyUriToKeyIdMap(){lr={}}constructor(t,e,i,s=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=e,this.keyFormat=i,this.keyFormatVersions=s,this.iv=n,this.encrypted=t?t!=="NONE":!1,this.isCommonEncryption=this.encrypted&&t!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case zt.FAIRPLAY:case zt.WIDEVINE:case zt.PLAYREADY:case zt.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(t){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof t!="number"&&(this.method==="AES-128"&&!this.iv&&R.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const i=Lg(t);return new ms(this.method,this.uri,"identity",this.keyFormatVersions,i)}const e=_p(this.uri);if(e)switch(this.keyFormat){case zt.WIDEVINE:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case zt.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=wg(i,null,e);const s=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),n=String.fromCharCode.apply(null,Array.from(s)),a=n.substring(n.indexOf("<"),n.length),o=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(o){const l=o.childNodes[0]?o.childNodes[0].nodeValue:o.getAttribute("VALUE");if(l){const h=Gn(l).subarray(0,16);Qp(h),this.keyId=h}}break}default:{let i=e.subarray(0,16);if(i.length!==16){const s=new Uint8Array(16);s.set(i,16-i.length),i=s}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=lr[this.uri];if(!i){const s=Object.keys(lr).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,s),lr[this.uri]=i}this.keyId=i}return this}}function Lg(r){const t=new Uint8Array(16);for(let e=12;e<16;e++)t[e]=r>>8*(15-e)&255;return t}const ph=/\{\$([a-zA-Z0-9-_]+)\}/g;function gh(r){return ph.test(r)}function Kt(r,t,e){if(r.variableList!==null||r.hasVariableRefs)for(let i=e.length;i--;){const s=e[i],n=t[s];n&&(t[s]=Wn(r,n))}}function Wn(r,t){if(r.variableList!==null||r.hasVariableRefs){const e=r.variableList;return t.replace(ph,i=>{const s=i.substring(2,i.length-1),n=e==null?void 0:e[s];return n===void 0?(r.playlistParsingError||(r.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),i):n})}return t}function mh(r,t,e){let i=r.variableList;i||(r.variableList=i={});let s,n;if("QUERYPARAM"in t){s=t.QUERYPARAM;try{const a=new self.URL(e).searchParams;if(a.has(s))n=a.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${e}"`)}catch(a){r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=t.NAME,n=t.VALUE;s in i?r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):i[s]=n||""}function Rg(r,t,e){const i=t.IMPORT;if(e&&i in e){let s=r.variableList;s||(r.variableList=s={}),s[i]=e[i]}else r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function hr(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const xg={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},vh=hr();function kg(r,t){const e=xg[t];return!!e&&e[r.slice(0,4)]===!0}function Yn(r,t){var e;return(e=vh==null?void 0:vh.isTypeSupported(`${t||"video"}/mp4;codecs="${r}"`))!=null?e:!1}const yh=/#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,bh=/#EXT-X-MEDIA:(.*)/g,Dg=/^#EXT(?:INF|-X-TARGETDURATION):/m,Ah=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Cg=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class oe{static findGroup(t,e){for(let i=0;i<t.length;i++){const s=t[i];if(s.id===e)return s}}static convertAVC1ToAVCOTI(t){const e=t.split(".");if(e.length>2){let i=e.shift()+".";return i+=parseInt(e.shift()).toString(16),i+=("000"+parseInt(e.shift()).toString(16)).slice(-4),i}return t}static resolve(t,e){return Un.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return Dg.test(t)}static parseMasterPlaylist(t,e){const i=gh(t),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];yh.lastIndex=0;let a;for(;(a=yh.exec(t))!=null;)if(a[1]){var o;const h=new dt(a[1]);Kt(s,h,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const d=Wn(s,a[2]),c={attrs:h,bitrate:h.decimalInteger("AVERAGE-BANDWIDTH")||h.decimalInteger("BANDWIDTH"),name:h.NAME,url:oe.resolve(d,e)},u=h.decimalResolution("RESOLUTION");u&&(c.width=u.width,c.height=u.height),Ig((h.CODECS||"").split(/[ ,]+/).filter(f=>f),c),c.videoCodec&&c.videoCodec.indexOf("avc1")!==-1&&(c.videoCodec=oe.convertAVC1ToAVCOTI(c.videoCodec)),(o=c.unknownCodecs)!=null&&o.length||n.push(c),s.levels.push(c)}else if(a[3]){const h=a[3],d=a[4];switch(h){case"SESSION-DATA":{const c=new dt(d);Kt(s,c,["DATA-ID","LANGUAGE","VALUE","URI"]);const u=c["DATA-ID"];u&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[u]=c);break}case"SESSION-KEY":{const c=Th(d,e,s);c.encrypted&&c.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(c)):R.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${d}"`);break}case"DEFINE":{{const c=new dt(d);Kt(s,c,["NAME","VALUE","QUERYPARAM"]),mh(s,c,e)}break}case"CONTENT-STEERING":{const c=new dt(d);Kt(s,c,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:oe.resolve(c["SERVER-URI"],e),pathwayId:c["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=Eh(d);break}}}const l=n.length>0&&n.length<s.levels.length;return s.levels=l?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(t,e,i){let s;const n={},a=i.levels,o={AUDIO:a.map(h=>({id:h.attrs.AUDIO,audioCodec:h.audioCodec})),SUBTITLES:a.map(h=>({id:h.attrs.SUBTITLES,textCodec:h.textCodec})),"CLOSED-CAPTIONS":[]};let l=0;for(bh.lastIndex=0;(s=bh.exec(t))!==null;){const h=new dt(s[1]),d=h.TYPE;if(d){const c=o[d],u=n[d]||[];n[d]=u,Kt(i,h,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const f={attrs:h,bitrate:0,id:l++,groupId:h["GROUP-ID"]||"",instreamId:h["INSTREAM-ID"],name:h.NAME||h.LANGUAGE||"",type:d,default:h.bool("DEFAULT"),autoselect:h.bool("AUTOSELECT"),forced:h.bool("FORCED"),lang:h.LANGUAGE,url:h.URI?oe.resolve(h.URI,e):""};if(c!=null&&c.length){const p=oe.findGroup(c,f.groupId)||c[0];wh(f,p,"audioCodec"),wh(f,p,"textCodec")}u.push(f)}}return n}static parseLevelPlaylist(t,e,i,s,n,a){const o=new Zp(e),l=o.fragments;let h=null,d=0,c=0,u=0,f=0,p=null,g=new Hn(s,e),m,b,A,T=-1,y=!1;for(Ah.lastIndex=0,o.m3u8=t,o.hasVariableRefs=gh(t);(m=Ah.exec(t))!==null;){y&&(y=!1,g=new Hn(s,e),g.start=u,g.sn=d,g.cc=f,g.level=i,h&&(g.initSegment=h,g.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null));const D=m[1];if(D){g.duration=parseFloat(D);const k=(" "+m[2]).slice(1);g.title=k||null,g.tagList.push(k?["INF",D,k]:["INF",D])}else if(m[3]){if(K(g.duration)){g.start=u,A&&Rh(g,A,o),g.sn=d,g.level=i,g.cc=f,g.urlId=n,l.push(g);const k=(" "+m[3]).slice(1);g.relurl=Wn(o,k),Sh(g,p),p=g,u+=g.duration,d++,c=0,y=!0}}else if(m[4]){const k=(" "+m[4]).slice(1);p?g.setByteRange(k,p):g.setByteRange(k)}else if(m[5])g.rawProgramDateTime=(" "+m[5]).slice(1),g.tagList.push(["PROGRAM-DATE-TIME",g.rawProgramDateTime]),T===-1&&(T=l.length);else{if(m=m[0].match(Cg),!m){R.warn("No matches on slow regex match for level playlist!");continue}for(b=1;b<m.length&&!(typeof m[b]<"u");b++);const k=(" "+m[b]).slice(1),x=(" "+m[b+1]).slice(1),F=m[b+2]?(" "+m[b+2]).slice(1):"";switch(k){case"PLAYLIST-TYPE":o.type=x.toUpperCase();break;case"MEDIA-SEQUENCE":d=o.startSN=parseInt(x);break;case"SKIP":{const O=new dt(x);Kt(o,O,["RECENTLY-REMOVED-DATERANGES"]);const G=O.decimalInteger("SKIPPED-SEGMENTS");if(K(G)){o.skippedSegments=G;for(let w=G;w--;)l.unshift(null);d+=G}const W=O.enumeratedString("RECENTLY-REMOVED-DATERANGES");W&&(o.recentlyRemovedDateranges=W.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(x),1);break;case"VERSION":o.version=parseInt(x);break;case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(x||F)&&g.tagList.push(F?[x,F]:[x]);break;case"DISCONTINUITY":f++,g.tagList.push(["DIS"]);break;case"GAP":g.gap=!0,g.tagList.push([k]);break;case"BITRATE":g.tagList.push([k,x]);break;case"DATERANGE":{const O=new dt(x);Kt(o,O,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Kt(o,O,O.clientAttrs);const G=new Jl(O,o.dateRanges[O.ID]);G.isValid||o.skippedSegments?o.dateRanges[G.id]=G:R.warn(`Ignoring invalid DATERANGE tag: "${x}"`),g.tagList.push(["EXT-X-DATERANGE",x]);break}case"DEFINE":{{const O=new dt(x);Kt(o,O,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in O?Rg(o,O,a):mh(o,O,e)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(x);break;case"KEY":{const O=Th(x,e,o);if(O.isSupported()){if(O.method==="NONE"){A=void 0;break}A||(A={}),A[O.keyFormat]&&(A=Et({},A)),A[O.keyFormat]=O}else R.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${x}"`);break}case"START":o.startTimeOffset=Eh(x);break;case"MAP":{const O=new dt(x);if(Kt(o,O,["BYTERANGE","URI"]),g.duration){const G=new Hn(s,e);Lh(G,O,i,A),h=G,g.initSegment=h,h.rawProgramDateTime&&!g.rawProgramDateTime&&(g.rawProgramDateTime=h.rawProgramDateTime)}else Lh(g,O,i,A),h=g,y=!0;break}case"SERVER-CONTROL":{const O=new dt(x);o.canBlockReload=O.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=O.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&O.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=O.optionalFloat("PART-HOLD-BACK",0),o.holdBack=O.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const O=new dt(x);o.partTarget=O.decimalFloatingPoint("PART-TARGET");break}case"PART":{let O=o.partList;O||(O=o.partList=[]);const G=c>0?O[O.length-1]:void 0,W=c++,w=new dt(x);Kt(o,w,["BYTERANGE","URI"]);const I=new Xp(w,g,e,W,G);O.push(I),g.duration+=I.duration;break}case"PRELOAD-HINT":{const O=new dt(x);Kt(o,O,["URI"]),o.preloadHint=O;break}case"RENDITION-REPORT":{const O=new dt(x);Kt(o,O,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(O);break}default:R.warn(`line parsed but not handled: ${m}`);break}}}p&&!p.relurl?(l.pop(),u-=p.duration,o.partList&&(o.fragmentHint=p)):o.partList&&(Sh(g,p),g.cc=f,o.fragmentHint=g,A&&Rh(g,A,o));const E=l.length,S=l[0],L=l[E-1];if(u+=o.skippedSegments*o.targetduration,u>0&&E&&L){o.averagetargetduration=u/E;const D=L.sn;o.endSN=D!=="initSegment"?D:0,o.live||(L.endList=!0),S&&(o.startCC=S.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(u+=o.fragmentHint.duration),o.totalduration=u,o.endCC=f,T>0&&Pg(l,T),o}}function Th(r,t,e){var i,s;const n=new dt(r);Kt(e,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const a=(i=n.METHOD)!=null?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),h=n.KEYFORMATVERSIONS,d=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&R.error(`Invalid IV: ${n.IV}`);const c=o?oe.resolve(o,t):"",u=(h||"1").split("/").map(Number).filter(Number.isFinite);return new ms(a,c,d,u,l)}function Eh(r){const t=new dt(r).decimalFloatingPoint("TIME-OFFSET");return K(t)?t:null}function Ig(r,t){["video","audio","text"].forEach(e=>{const i=r.filter(s=>kg(s,e));if(i.length){const s=i.filter(n=>n.lastIndexOf("avc1",0)===0||n.lastIndexOf("mp4a",0)===0);t[`${e}Codec`]=s.length>0?s[0]:i[0],r=r.filter(n=>i.indexOf(n)===-1)}}),t.unknownCodecs=r}function wh(r,t,e){const i=t[e];i&&(r[e]=i)}function Pg(r,t){let e=r[t];for(let i=t;i--;){const s=r[i];if(!s)return;s.programDateTime=e.programDateTime-s.duration*1e3,e=s}}function Sh(r,t){r.rawProgramDateTime?r.programDateTime=Date.parse(r.rawProgramDateTime):t!=null&&t.programDateTime&&(r.programDateTime=t.endProgramDateTime),K(r.programDateTime)||(r.programDateTime=null,r.rawProgramDateTime=null)}function Lh(r,t,e,i){r.relurl=t.URI,t.BYTERANGE&&r.setByteRange(t.BYTERANGE),r.level=e,r.sn="initSegment",i&&(r.levelkeys=i),r.initSegment=null}function Rh(r,t,e){r.levelkeys=t;const{encryptedFragments:i}=e;(!i.length||i[i.length-1].levelkeys!==t)&&Object.keys(t).some(s=>t[s].isCommonEncryption)&&i.push(r)}var st={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},X={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function xh(r){const{type:t}=r;switch(t){case st.AUDIO_TRACK:return X.AUDIO;case st.SUBTITLE_TRACK:return X.SUBTITLE;default:return X.MAIN}}function Xn(r,t){let e=r.url;return(e===void 0||e.indexOf("data:")===0)&&(e=t.url),e}class Og{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:t}=this;t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.LEVEL_LOADING,this.onLevelLoading,this),t.on(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.LEVEL_LOADING,this.onLevelLoading,this),t.off(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,i=e.pLoader,s=e.loader,n=i||s,a=new n(e);return this.loaders[t.type]=a,a}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){const{url:i}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:st.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(t,e){const{id:i,level:s,url:n,deliveryDirectives:a}=e;this.load({id:i,level:s,responseType:"text",type:st.LEVEL,url:n,deliveryDirectives:a})}onAudioTrackLoading(t,e){const{id:i,groupId:s,url:n,deliveryDirectives:a}=e;this.load({id:i,groupId:s,level:null,responseType:"text",type:st.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(t,e){const{id:i,groupId:s,url:n,deliveryDirectives:a}=e;this.load({id:i,groupId:s,level:null,responseType:"text",type:st.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(t){var e;const i=this.hls.config;let s=this.getInternalLoader(t);if(s){const h=s.context;if(h&&h.url===t.url){R.trace("[playlist-loader]: playlist request ongoing");return}R.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),s.abort()}let n;if(t.type===st.MANIFEST?n=i.manifestLoadPolicy.default:n=Et({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(t),(e=t.deliveryDirectives)!=null&&e.part){let h;if(t.type===st.LEVEL&&t.level!==null?h=this.hls.levels[t.level].details:t.type===st.AUDIO_TRACK&&t.id!==null?h=this.hls.audioTracks[t.id].details:t.type===st.SUBTITLE_TRACK&&t.id!==null&&(h=this.hls.subtitleTracks[t.id].details),h){const d=h.partTarget,c=h.targetduration;if(d&&c){const u=Math.max(d*3,c*.8)*1e3;n=Et({},n,{maxTimeToFirstByteMs:Math.min(u,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(u,n.maxTimeToFirstByteMs)})}}}const 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:(h,d,c,u)=>{const f=this.getInternalLoader(c);this.resetInternalLoader(c.type);const p=h.data;if(p.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(h,c,new Error("no EXTM3U delimiter"),u||null,d);return}d.parsing.start=performance.now(),oe.isMediaPlaylist(p)?this.handleTrackOrLevelPlaylist(h,d,c,u||null,f):this.handleMasterPlaylist(h,d,c,u)},onError:(h,d,c,u)=>{this.handleNetworkError(d,c,!1,h,u)},onTimeout:(h,d,c)=>{this.handleNetworkError(d,c,!0,void 0,h)}};s.load(t,o,l)}handleMasterPlaylist(t,e,i,s){const n=this.hls,a=t.data,o=Xn(t,i),l=oe.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(t,i,l.playlistParsingError,s,e);return}const{contentSteering:h,levels:d,sessionData:c,sessionKeys:u,startTimeOffset:f,variableList:p}=l;this.variableList=p;const{AUDIO:g=[],SUBTITLES:m,"CLOSED-CAPTIONS":b}=oe.parseMasterPlaylistMedia(a,o,l);g.length&&!g.some(A=>!A.url)&&d[0].audioCodec&&!d[0].attrs.AUDIO&&(R.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:!1,autoselect:!1,forced:!1,id:-1,attrs:new dt({}),bitrate:0,url:""})),n.trigger(v.MANIFEST_LOADED,{levels:d,audioTracks:g,subtitles:m,captions:b,contentSteering:h,url:o,stats:e,networkDetails:s,sessionData:c,sessionKeys:u,startTimeOffset:f,variableList:p})}handleTrackOrLevelPlaylist(t,e,i,s,n){const a=this.hls,{id:o,level:l,type:h}=i,d=Xn(t,i),c=K(o)?o:0,u=K(l)?l:c,f=xh(i),p=oe.parseLevelPlaylist(t.data,d,u,f,c,this.variableList);if(h===st.MANIFEST){const g={attrs:new dt({}),bitrate:0,details:p,name:"",url:d};a.trigger(v.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:d,stats:e,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),i.levelDetails=p,this.handlePlaylistLoaded(p,t,e,i,s,n)}handleManifestParsingError(t,e,i,s,n){this.hls.trigger(v.ERROR,{type:Y.NETWORK_ERROR,details:P.MANIFEST_PARSING_ERROR,fatal:e.type===st.MANIFEST,url:t.url,err:i,error:i,reason:i.message,response:t,context:e,networkDetails:s,stats:n})}handleNetworkError(t,e,i=!1,s,n){let a=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${t.type}`;t.type===st.LEVEL?a+=`: ${t.level} id: ${t.id}`:(t.type===st.AUDIO_TRACK||t.type===st.SUBTITLE_TRACK)&&(a+=` id: ${t.id} group-id: "${t.groupId}"`);const o=new Error(a);R.warn(`[playlist-loader]: ${a}`);let l=P.UNKNOWN,h=!1;const d=this.getInternalLoader(t);switch(t.type){case st.MANIFEST:l=i?P.MANIFEST_LOAD_TIMEOUT:P.MANIFEST_LOAD_ERROR,h=!0;break;case st.LEVEL:l=i?P.LEVEL_LOAD_TIMEOUT:P.LEVEL_LOAD_ERROR,h=!1;break;case st.AUDIO_TRACK:l=i?P.AUDIO_TRACK_LOAD_TIMEOUT:P.AUDIO_TRACK_LOAD_ERROR,h=!1;break;case st.SUBTITLE_TRACK:l=i?P.SUBTITLE_TRACK_LOAD_TIMEOUT:P.SUBTITLE_LOAD_ERROR,h=!1;break}d&&this.resetInternalLoader(t.type);const c={type:Y.NETWORK_ERROR,details:l,fatal:h,url:t.url,loader:d,context:t,error:o,networkDetails:e,stats:n};if(s){const u=(e==null?void 0:e.url)||t.url;c.response=jt({url:u,data:void 0},s)}this.hls.trigger(v.ERROR,c)}handlePlaylistLoaded(t,e,i,s,n,a){const o=this.hls,{type:l,level:h,id:d,groupId:c,deliveryDirectives:u}=s,f=Xn(e,s),p=xh(s),g=typeof s.level=="number"&&p===X.MAIN?h:void 0;if(!t.fragments.length){const b=new Error("No Segments found in Playlist");o.trigger(v.ERROR,{type:Y.NETWORK_ERROR,details:P.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:b,reason:b.message,response:e,context:s,level:g,parent:p,networkDetails:n,stats:i});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const m=t.playlistParsingError;if(m){o.trigger(v.ERROR,{type:Y.NETWORK_ERROR,details:P.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:m,reason:m.message,response:e,context:s,level:g,parent:p,networkDetails:n,stats:i});return}switch(t.live&&a&&(a.getCacheAge&&(t.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),l){case st.MANIFEST:case st.LEVEL:o.trigger(v.LEVEL_LOADED,{details:t,level:g||0,id:d||0,stats:i,networkDetails:n,deliveryDirectives:u});break;case st.AUDIO_TRACK:o.trigger(v.AUDIO_TRACK_LOADED,{details:t,id:d||0,groupId:c||"",stats:i,networkDetails:n,deliveryDirectives:u});break;case st.SUBTITLE_TRACK:o.trigger(v.SUBTITLE_TRACK_LOADED,{details:t,id:d||0,groupId:c||"",stats:i,networkDetails:n,deliveryDirectives:u});break}}}function kh(r,t){let e;try{e=new Event("addtrack")}catch{e=document.createEvent("Event"),e.initEvent("addtrack",!1,!1)}e.track=r,t.dispatchEvent(e)}function Dh(r,t){const e=r.mode;if(e==="disabled"&&(r.mode="hidden"),r.cues&&!r.cues.getCueById(t.id))try{if(r.addCue(t),!r.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){R.debug(`[texttrack-utils]: ${i}`);try{const s=new self.TextTrackCue(t.startTime,t.endTime,t.text);s.id=t.id,r.addCue(s)}catch(s){R.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}e==="disabled"&&(r.mode=e)}function Li(r){const t=r.mode;if(t==="disabled"&&(r.mode="hidden"),r.cues)for(let e=r.cues.length;e--;)r.removeCue(r.cues[e]);t==="disabled"&&(r.mode=t)}function qn(r,t,e,i){const s=r.mode;if(s==="disabled"&&(r.mode="hidden"),r.cues&&r.cues.length>0){const n=Fg(r.cues,t,e);for(let a=0;a<n.length;a++)(!i||i(n[a]))&&r.removeCue(n[a])}s==="disabled"&&(r.mode=s)}function Mg(r,t){if(t<r[0].startTime)return 0;const e=r.length-1;if(t>r[e].endTime)return-1;let i=0,s=e;for(;i<=s;){const n=Math.floor((s+i)/2);if(t<r[n].startTime)s=n-1;else if(t>r[n].startTime&&i<e)i=n+1;else return n}return r[i].startTime-t<t-r[s].startTime?i:s}function Fg(r,t,e){const i=[],s=Mg(r,t);if(s>-1)for(let n=s,a=r.length;n<a;n++){const o=r[n];if(o.startTime>=t&&o.endTime<=e)i.push(o);else if(o.startTime>e)return i}return i}var le={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const Ng=.25;function Zn(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const dr=(()=>{const r=Zn();try{new r(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Jn(r,t){return r.getTime()/1e3-t}function Ug(r){return Uint8Array.from(r.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class Bg{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:t}=this;t.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(v.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(Li(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const e=this.getID3Track(t.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;e<t.length;e++){const i=t[e];if(i.kind==="metadata"&&i.label==="id3")return kh(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:s}}}=this;if(!i&&!s)return;const{samples:n}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=Zn();for(let o=0;o<n.length;o++){const l=n[o].type;if(l===le.emsg&&!i||!s)continue;const h=nh(n[o].data);if(h){const d=n[o].pts;let c=d+n[o].duration;c>dr&&(c=dr),c-d<=0&&(c=d+Ng);for(let u=0;u<h.length;u++){const f=h[u];if(!rh(f)){this.updateId3CueEnds(d,l);const p=new a(d,c,"");p.value=f,l&&(p.type=l),this.id3Track.addCue(p)}}}}}updateId3CueEnds(t,e){var i;const s=(i=this.id3Track)==null?void 0:i.cues;if(s)for(let n=s.length;n--;){const a=s[n];a.type===e&&a.startTime<t&&a.endTime===dr&&(a.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:i,type:s}){const{id3Track:n,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let h;s==="audio"?h=d=>d.type===le.audioId3&&l:s==="video"?h=d=>d.type===le.emsg&&o:h=d=>d.type===le.audioId3&&l||d.type===le.emsg&&o,qn(n,e,i,h)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:s}=this,{dateRanges:n}=e,a=Object.keys(n);if(s){const d=Object.keys(i).filter(c=>!a.includes(c));for(let c=d.length;c--;){const u=d[c];Object.keys(i[u].cues).forEach(f=>{s.removeCue(i[u].cues[f])}),delete i[u]}}const o=e.fragments[e.fragments.length-1];if(a.length===0||!K(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=o.programDateTime/1e3-o.start,h=Zn();for(let d=0;d<a.length;d++){const c=a[d],u=n[c],f=i[c],p=(f==null?void 0:f.cues)||{};let g=(f==null?void 0:f.durationKnown)||!1;const m=Jn(u.startDate,l);let b=dr;const A=u.endDate;if(A)b=Jn(A,l),g=!0;else if(u.endOnNext&&!g){const y=a.reduce((E,S)=>{const L=n[S];return L.class===u.class&&L.id!==S&&L.startDate>u.startDate&&E.push(L),E},[]).sort((E,S)=>E.startDate.getTime()-S.startDate.getTime())[0];y&&(b=Jn(y.startDate,l),g=!0)}const T=Object.keys(u.attr);for(let y=0;y<T.length;y++){const E=T[y];if(!Wp(E))continue;let S=p[E];if(S)g&&!f.durationKnown&&(S.endTime=b);else{let L=u.attr[E];S=new h(m,b,""),Yp(E)&&(L=Ug(L)),S.value={key:E,data:L},S.type=le.dateRange,S.id=c,this.id3Track.addCue(S),p[E]=S}}i[c]={cues:p,dateRange:u,durationKnown:g}}}}class Hg{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:t,levelDetails:e}=this;return t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){const{levelDetails:t}=this;if(t===null)return null;const{holdBack:e,partHoldBack:i,targetduration:s}=t,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig;let h=o&&i||e;(l.liveSyncDuration||l.liveSyncDurationCount||h===0)&&(h=n!==void 0?n:a*s);const d=s,c=1;return h+Math.min(this.stallCount*c,d)}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency,i=this.levelDetails;if(t===null||e===null||i===null)return null;const s=i.edge,n=t-e-this.edgeStalled,a=s-i.totalduration,o=s-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,n),o)}get drift(){const{levelDetails:t}=this;return t===null?1:t.drift}get edgeStalled(){const{levelDetails:t}=this;if(t===null)return 0;const e=(this.config.lowLatencyMode&&t.partTarget||t.targetduration)*3;return Math.max(t.age-e,0)}get forwardBufferLength(){const{media:t,levelDetails:e}=this;if(!t||!e)return 0;const i=t.buffered.length;return(i?t.buffered.end(i-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(v.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(v.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(t,{details:e}){this.levelDetails=e,e.advanced&&this.timeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){var i;e.details===P.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&R.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:t,levelDetails:e}=this;if(!t||!e)return;this.currentTime=t.currentTime;const i=this.computeLatency();if(i===null)return;this._latency=i;const{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1)return;const a=this.targetLatency;if(a===null)return;const o=i-a,l=Math.min(this.maxLatency,a+e.targetduration),h=o<l;if(e.live&&h&&o>.05&&this.forwardBufferLength>1){const d=Math.min(2,Math.max(1,n)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;t.playbackRate=Math.min(d,Math.max(1,c))}else t.playbackRate!==1&&t.playbackRate!==0&&(t.playbackRate=1)}estimateLiveEdge(){const{levelDetails:t}=this;return t===null?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return t===null?null:t-this.currentTime}}const Qn=["NONE","TYPE-0","TYPE-1",null];var vs={No:"",Yes:"YES",v2:"v2"};function Gg(r,t){const{canSkipUntil:e,canSkipDateRanges:i,endSN:s}=r,n=t!==void 0?t-s:0;return e&&n<e?i?vs.v2:vs.Yes:vs.No}class Ch{constructor(t,e,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=i}addDirectives(t){const e=new self.URL(t);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class ys{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(e=>e).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(t){const e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}get audioGroupId(){var t;return(t=this.audioGroupIds)==null?void 0:t[this.urlId]}get textGroupId(){var t;return(t=this.textGroupIds)==null?void 0:t[this.urlId]}addFallback(t){this.url.push(t.url),this._attrs.push(t.attrs)}}function _n(r,t){const e=t.startPTS;if(K(e)){let i=0,s;t.sn>r.sn?(i=e-r.start,s=r):(i=r.start-e,s=t),s.duration!==i&&(s.duration=i)}else t.sn>r.sn?r.cc===t.cc&&r.minEndPTS?t.start=r.start+(r.minEndPTS-r.start):t.start=r.start+r.duration:t.start=Math.max(r.start-t.duration,0)}function Ih(r,t,e,i,s,n){i-e<=0&&(R.warn("Fragment should have a positive duration",t),i=e+t.duration,n=s+t.duration);let a=e,o=i;const l=t.startPTS,h=t.endPTS;if(K(l)){const g=Math.abs(l-e);K(t.deltaPTS)?t.deltaPTS=Math.max(g,t.deltaPTS):t.deltaPTS=g,a=Math.max(e,l),e=Math.min(e,l),s=Math.min(s,t.startDTS),o=Math.min(i,h),i=Math.max(i,h),n=Math.max(n,t.endDTS)}const d=e-t.start;t.start!==0&&(t.start=e),t.duration=i-t.start,t.startPTS=e,t.maxStartPTS=a,t.startDTS=s,t.endPTS=i,t.minEndPTS=o,t.endDTS=n;const c=t.sn;if(!r||c<r.startSN||c>r.endSN)return 0;let u;const f=c-r.startSN,p=r.fragments;for(p[f]=t,u=f;u>0;u--)_n(p[u],p[u-1]);for(u=f;u<p.length-1;u++)_n(p[u],p[u+1]);return r.fragmentHint&&_n(p[p.length-1],r.fragmentHint),r.PTSKnown=r.alignedSliding=!0,d}function Vg(r,t){let e=null;const i=r.fragments;for(let l=i.length-1;l>=0;l--){const h=i[l].initSegment;if(h){e=h;break}}r.fragmentHint&&delete r.fragmentHint.endPTS;let s=0,n;if(Kg(r,t,(l,h)=>{l.relurl&&(s=l.cc-h.cc),K(l.startPTS)&&K(l.endPTS)&&(h.start=h.startPTS=l.startPTS,h.startDTS=l.startDTS,h.maxStartPTS=l.maxStartPTS,h.endPTS=l.endPTS,h.endDTS=l.endDTS,h.minEndPTS=l.minEndPTS,h.duration=l.endPTS-l.startPTS,h.duration&&(n=h),t.PTSKnown=t.alignedSliding=!0),h.elementaryStreams=l.elementaryStreams,h.loader=l.loader,h.stats=l.stats,h.urlId=l.urlId,l.initSegment&&(h.initSegment=l.initSegment,e=l.initSegment)}),e&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach(l=>{var h;(!l.initSegment||l.initSegment.relurl===((h=e)==null?void 0:h.relurl))&&(l.initSegment=e)}),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(l=>!l),t.deltaUpdateFailed){R.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=t.skippedSegments;l--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=jg(r.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const a=t.fragments;if(s){R.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=s}t.skippedSegments&&(t.startCC=t.fragments[0].cc),zg(r.partList,t.partList,(l,h)=>{h.elementaryStreams=l.elementaryStreams,h.stats=l.stats}),n?Ih(t,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):Ph(r,t),a.length&&(t.totalduration=t.edge-a[0].start),t.driftStartTime=r.driftStartTime,t.driftStart=r.driftStart;const o=t.advancedDateTime;if(t.advanced&&o){const l=t.edge;t.driftStart||(t.driftStartTime=o,t.driftStart=l),t.driftEndTime=o,t.driftEnd=l}else t.driftEndTime=r.driftEndTime,t.driftEnd=r.driftEnd,t.advancedDateTime=r.advancedDateTime}function jg(r,t,e){const i=Et({},r);return e&&e.forEach(s=>{delete i[s]}),Object.keys(t).forEach(s=>{const n=new Jl(t[s].attr,i[s]);n.isValid?i[s]=n:R.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[s].attr)}"`)}),i}function zg(r,t,e){if(r&&t){let i=0;for(let s=0,n=r.length;s<=n;s++){const a=r[s],o=t[s+i];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?e(a,o):i--}}}function Kg(r,t,e){const i=t.skippedSegments,s=Math.max(r.startSN,t.startSN)-t.startSN,n=(r.fragmentHint?1:0)+(i?t.endSN:Math.min(r.endSN,t.endSN))-t.startSN,a=t.startSN-r.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments;for(let h=s;h<=n;h++){const d=l[a+h];let c=o[h];i&&!c&&h<i&&(c=t.fragments[h]=d),d&&c&&e(d,c)}}function Ph(r,t){const e=t.startSN+t.skippedSegments-r.startSN,i=r.fragments;e<0||e>=i.length||$n(t,i[e].start)}function $n(r,t){if(t){const e=r.fragments;for(let i=r.skippedSegments;i<e.length;i++)e[i].start+=t;r.fragmentHint&&(r.fragmentHint.start+=t)}}function Wg(r,t=1/0){let e=1e3*r.targetduration;if(r.updated){const i=r.fragments,s=4;if(i.length&&e*s>t){const n=i[i.length-1].duration*1e3;n<e&&(e=n)}}else e/=2;return Math.round(e)}function Yg(r,t,e){if(!(r!=null&&r.details))return null;const i=r.details;let s=i.fragments[t-i.startSN];return s||(s=i.fragmentHint,s&&s.sn===t)?s:t<i.startSN&&e&&e.sn===t?e:null}function Oh(r,t,e){var i;return r!=null&&r.details?Mh((i=r.details)==null?void 0:i.partList,t,e):null}function Mh(r,t,e){if(r)for(let i=r.length;i--;){const s=r[i];if(s.index===e&&s.fragment.sn===t)return s}return null}function cr(r){switch(r.details){case P.FRAG_LOAD_TIMEOUT:case P.KEY_LOAD_TIMEOUT:case P.LEVEL_LOAD_TIMEOUT:case P.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Fh(r,t){const e=cr(t);return r.default[`${e?"timeout":"error"}Retry`]}function ta(r,t){const e=r.backoff==="linear"?1:Math.pow(2,t);return Math.min(e*r.retryDelayMs,r.maxRetryDelayMs)}function Nh(r){return jt(jt({},r),{errorRetry:null,timeoutRetry:null})}function ur(r,t,e,i){return!!r&&t<r.maxNumRetry&&(Xg(i)||!!e)}function Xg(r){return r===0&&navigator.onLine===!1||!!r&&(r<400||r>499)}const Uh={search:function(r,t){let e=0,i=r.length-1,s=null,n=null;for(;e<=i;){s=(e+i)/2|0,n=r[s];const a=t(n);if(a>0)e=s+1;else if(a<0)i=s-1;else return n}return null}};function qg(r,t,e){if(t===null||!Array.isArray(r)||!r.length||!K(t))return null;const i=r[0].programDateTime;if(t<(i||0))return null;const s=r[r.length-1].endProgramDateTime;if(t>=(s||0))return null;e=e||0;for(let n=0;n<r.length;++n){const a=r[n];if(Zg(t,e,a))return a}return null}function bs(r,t,e=0,i=0){let s=null;if(r?s=t[r.sn-t[0].sn+1]||null:e===0&&t[0].start===0&&(s=t[0]),s&&ea(e,i,s)===0)return s;const n=Uh.search(t,ea.bind(null,e,i));return n&&(n!==r||!s)?n:s}function ea(r=0,t=0,e){if(e.start<=r&&e.start+e.duration>r)return 0;const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-i<=r?1:e.start-i>r&&e.start?-1:0}function Zg(r,t,e){const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0))*1e3;return(e.endProgramDateTime||0)-i>r}function Jg(r,t){return Uh.search(r,e=>e.cc<t?1:e.cc>t?-1:0)}const Qg=3e5;var Ft={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},$t={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class _g{constructor(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=R.log.bind(R,"[info]:"),this.warn=R.warn.bind(R,"[warning]:"),this.error=R.error.bind(R,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(v.ERROR,this.onError,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(v.ERROR,this.onError,this),t.off(v.ERROR,this.onErrorOut,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){this.playlistError=0}stopLoad(){}getVariantLevelIndex(t){return(t==null?void 0:t.type)===X.MAIN?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var i,s;if(e.fatal)return;const n=this.hls,a=e.context;switch(e.details){case P.FRAG_LOAD_ERROR:case P.FRAG_LOAD_TIMEOUT:case P.KEY_LOAD_ERROR:case P.KEY_LOAD_TIMEOUT:e.errorAction=this.getFragRetryOrSwitchAction(e);return;case P.FRAG_PARSING_ERROR:if((i=e.frag)!=null&&i.gap){e.errorAction={action:Ft.DoNothing,flags:$t.None};return}case P.FRAG_GAP:case P.FRAG_DECRYPT_ERROR:{e.errorAction=this.getFragRetryOrSwitchAction(e),e.errorAction.action=Ft.SendAlternateToPenaltyBox;return}case P.LEVEL_EMPTY_ERROR:case P.LEVEL_PARSING_ERROR:{var o,l;const h=e.parent===X.MAIN?e.level:n.loadLevel;e.details===P.LEVEL_EMPTY_ERROR&&(o=e.context)!=null&&(l=o.levelDetails)!=null&&l.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,h):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,h))}return;case P.LEVEL_LOAD_ERROR:case P.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,a.level));return;case P.AUDIO_TRACK_LOAD_ERROR:case P.AUDIO_TRACK_LOAD_TIMEOUT:case P.SUBTITLE_LOAD_ERROR:case P.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){const h=n.levels[n.loadLevel];if(h&&(a.type===st.AUDIO_TRACK&&a.groupId===h.audioGroupId||a.type===st.SUBTITLE_TRACK&&a.groupId===h.textGroupId)){e.errorAction=this.getPlaylistRetryOrSwitchAction(e,n.loadLevel),e.errorAction.action=Ft.SendAlternateToPenaltyBox,e.errorAction.flags=$t.MoveAllAlternatesMatchingHost;return}}return;case P.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const h=n.levels[n.loadLevel],d=h==null?void 0:h.attrs["HDCP-LEVEL"];d&&(e.errorAction={action:Ft.SendAlternateToPenaltyBox,flags:$t.MoveAllAlternatesMatchingHDCP,hdcpLevel:d})}return;case P.BUFFER_ADD_CODEC_ERROR:case P.REMUX_ALLOC_ERROR:e.errorAction=this.getLevelSwitchAction(e,(s=e.level)!=null?s:n.loadLevel);return;case P.INTERNAL_EXCEPTION:case P.BUFFER_APPENDING_ERROR:case P.BUFFER_APPEND_ERROR:case P.BUFFER_FULL_ERROR:case P.LEVEL_SWITCH_ERROR:case P.BUFFER_STALLED_ERROR:case P.BUFFER_SEEK_OVER_HOLE:case P.BUFFER_NUDGE_ON_STALL:e.errorAction={action:Ft.DoNothing,flags:$t.None};return}if(e.type===Y.KEY_SYSTEM_ERROR){const h=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,h);return}}getPlaylistRetryOrSwitchAction(t,e){var i;const s=this.hls,n=Fh(s.config.playlistLoadPolicy,t),a=this.playlistError++,o=(i=t.response)==null?void 0:i.code;if(ur(n,a,cr(t),o))return{action:Ft.RetryRequest,flags:$t.None,retryConfig:n,retryCount:a};const l=this.getLevelSwitchAction(t,e);return n&&(l.retryConfig=n,l.retryCount=a),l}getFragRetryOrSwitchAction(t){const e=this.hls,i=this.getVariantLevelIndex(t.frag),s=e.levels[i],{fragLoadPolicy:n,keyLoadPolicy:a}=e.config,o=Fh(t.details.startsWith("key")?a:n,t),l=e.levels.reduce((c,u)=>c+u.fragmentError,0);if(s){var h;t.details!==P.FRAG_GAP&&s.fragmentError++;const c=(h=t.response)==null?void 0:h.code;if(ur(o,l,cr(t),c))return{action:Ft.RetryRequest,flags:$t.None,retryConfig:o,retryCount:l}}const d=this.getLevelSwitchAction(t,i);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(t,e){const i=this.hls;e==null&&(e=i.loadLevel);const s=this.hls.levels[e];if(s&&(s.loadError++,i.autoLevelEnabled)){var n,a;let o=-1;const{levels:l,loadLevel:h,minAutoLevel:d,maxAutoLevel:c}=i,u=(n=t.frag)==null?void 0:n.type,{type:f,groupId:p}=(a=t.context)!=null?a:{};for(let g=l.length;g--;){const m=(g+h)%l.length;if(m!==h&&m>=d&&m<=c&&l[m].loadError===0){const b=l[m];if(t.details===P.FRAG_GAP&&t.frag){const A=l[m].details;if(A){const T=bs(t.frag,A.fragments,t.frag.start);if(T!=null&&T.gap)continue}}else if(f===st.AUDIO_TRACK&&p===b.audioGroupId||f===st.SUBTITLE_TRACK&&p===b.textGroupId||u===X.AUDIO&&s.audioGroupId===b.audioGroupId||u===X.SUBTITLE&&s.textGroupId===b.textGroupId)continue;o=m;break}}if(o>-1&&i.loadLevel!==o)return t.levelRetry=!0,this.playlistError=0,{action:Ft.SendAlternateToPenaltyBox,flags:$t.None,nextAutoLevel:o}}return{action:Ft.SendAlternateToPenaltyBox,flags:$t.MoveAllAlternatesMatchingHost}}onErrorOut(t,e){var i;switch((i=e.errorAction)==null?void 0:i.action){case Ft.DoNothing:break;case Ft.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),!e.errorAction.resolved&&e.details!==P.FRAG_GAP&&(e.fatal=!0);break}if(e.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(t){const e=this.hls,i=t.errorAction;if(!i)return;const{flags:s,hdcpLevel:n,nextAutoLevel:a}=i;switch(s){case $t.None:this.switchLevel(t,a);break;case $t.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(t));break;case $t.MoveAllAlternatesMatchingHDCP:n&&(e.maxHdcpLevel=Qn[Qn.indexOf(n)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(t,a)}switchLevel(t,e){e!==void 0&&t.errorAction&&(this.warn(`switching to level ${e} after ${t.details}`),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(t){const{hls:e,penalizedRenditions:i}=this,s=t.parent===X.MAIN?t.level:e.loadLevel,n=e.levels[s],a=n.url.length,o=t.frag?t.frag.urlId:n.urlId;n.urlId===o&&(!t.frag||n.details)&&this.penalizeRendition(n,t);for(let l=1;l<a;l++){const h=(o+l)%a,d=i[h];if(!d||$g(d,t,i[o]))return this.warn(`Switching to Redundant Stream ${h+1}/${a}: "${n.url[h]}" after ${t.details}`),this.playlistError=0,e.levels.forEach(c=>{c.urlId=h}),e.nextLoadLevel=s,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:i}=this,s=i[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};s.lastErrorPerfMs=performance.now(),s.errors.push(e),s.details=t.details,i[t.urlId]=s}}function $g(r,t,e){if(performance.now()-r.lastErrorPerfMs>Qg)return!0;const i=r.details;if(t.details===P.FRAG_GAP&&i&&t.frag){const s=t.frag.start,n=bs(null,i.fragments,s);if(n&&!n.gap)return!0}if(e&&r.errors.length<e.errors.length){const s=r.errors[r.errors.length-1];if(i&&s.frag&&t.frag&&Math.abs(s.frag.start-t.frag.start)>i.targetduration*3)return!0}return!1}class ia{constructor(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=R.log.bind(R,`${e}:`),this.warn=R.warn.bind(R,`${e}:`),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,e){const i=e==null?void 0:e.renditionReports;if(i){let s=-1;for(let n=0;n<i.length;n++){const a=i[n];let o;try{o=new self.URL(a.URI,e.url).href}catch(l){R.warn(`Could not construct new URL for Rendition Report: ${l}`),o=a.URI||""}if(o===t){s=n;break}else o===t.substring(0,o.length)&&(s=n)}if(s!==-1){const n=i[s],a=parseInt(n["LAST-MSN"])||(e==null?void 0:e.lastPartSn);let o=parseInt(n["LAST-PART"])||(e==null?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){const l=Math.min(e.age-e.partTarget,e.targetduration);o>=0&&l>e.partTarget&&(o+=1)}return new Ch(a,o>=0?o:void 0,vs.No)}}}loadPlaylist(t){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}shouldReloadPlaylist(t){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(t)}playlistLoaded(t,e,i){const{details:s,stats:n}=e,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||i!=null&&i.live){if(s.reloaded(i),i&&this.log(`live playlist ${t} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),i&&s.fragments.length>0&&Vg(i,s),!this.canLoad||!s.live)return;let l,h,d;if(s.canBlockReload&&s.endSN&&s.advanced){const m=this.hls.config.lowLatencyMode,b=s.lastPartSn,A=s.endSN,T=s.lastPartIndex,y=T!==-1,E=b===A,S=m?0:T;y?(h=E?A+1:b,d=E?S:T+1):h=A+1;const L=s.age,D=L+s.ageHeader;let k=Math.min(D-s.partTarget,s.targetduration*1.5);if(k>0){if(i&&k>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${k} with playlist age: ${s.age}`),k=0;else{const x=Math.floor(k/s.targetduration);if(h+=x,d!==void 0){const F=Math.round(k%s.targetduration/s.partTarget);d+=F}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${L.toFixed(2)}s goal: ${k} skip sn ${x} to part ${d}`)}s.tuneInGoal=k}if(l=this.getDeliveryDirectives(s,e.deliveryDirectives,h,d),m||!E){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,e.deliveryDirectives,h,d));const c=this.hls.mainForwardBufferInfo,u=c?c.end-c.len:0,f=(s.edge-u)*1e3,p=Wg(s,f);s.updated&&a>this.requestScheduled+p&&(this.requestScheduled=n.loading.start),h!==void 0&&s.canBlockReload?this.requestScheduled=n.loading.first+p-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+p<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=p);let g=this.requestScheduled-a;g=Math.max(0,g),this.log(`reload live playlist ${t} in ${Math.round(g)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),g)}else this.clearTimer()}getDeliveryDirectives(t,e,i,s){let n=Gg(t,i);return e!=null&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,s=e.part,n=vs.No),new Ch(i,s,n)}checkRetry(t){const e=t.details,i=cr(t),s=t.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===Ft.RetryRequest||!s.resolved&&n===Ft.SendAlternateToPenaltyBox);if(l){var h;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(i&&(h=t.context)!=null&&h.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const d=ta(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),d),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${e}" in ${d}ms`)}t.levelRetry=!0,s.resolved=!0}return l}}let sa;class tm extends ia{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(v.LEVEL_LOADED,this.onLevelLoaded,this),t.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(v.FRAG_LOADED,this.onFragLoaded,this),t.on(v.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(v.LEVEL_LOADED,this.onLevelLoaded,this),t.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(v.FRAG_LOADED,this.onFragLoaded,this),t.off(v.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const i=[],s={};let n;e.levels.forEach(a=>{var o;const l=a.attrs;((o=a.audioCodec)==null?void 0:o.indexOf("mp4a.40.34"))!==-1&&(sa||(sa=/chrome|firefox/i.test(navigator.userAgent)),sa&&(a.audioCodec=void 0));const{AUDIO:h,CODECS:d,"FRAME-RATE":c,"PATHWAY-ID":u,RESOLUTION:f,SUBTITLES:p}=l,g=`${`${u||"."}-`}${a.bitrate}-${f}-${c}-${d}`;n=s[g],n?n.addFallback(a):(n=new ys(a),s[g]=n,i.push(n)),fr(n,"audio",h),fr(n,"text",p)}),this.filterAndSortMediaOptions(i,e)}filterAndSortMediaOptions(t,e){let i=[],s=[],n=!1,a=!1,o=!1,l=t.filter(({audioCodec:f,videoCodec:p,width:g,height:m,unknownCodecs:b})=>(n||(n=!!(g&&m)),a||(a=!!p),o||(o=!!f),!(b!=null&&b.length)&&(!f||Yn(f,"audio"))&&(!p||Yn(p,"video"))));if((n||a)&&o&&(l=l.filter(({videoCodec:f,width:p,height:g})=>!!f||!!(p&&g))),l.length===0){Promise.resolve().then(()=>{if(this.hls){const f=new Error("no level with compatible codecs found in manifest");this.hls.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:f,reason:f.message})}});return}e.audioTracks&&(i=e.audioTracks.filter(f=>!f.audioCodec||Yn(f.audioCodec,"audio")),Bh(i)),e.subtitles&&(s=e.subtitles,Bh(s));const h=l.slice(0);l.sort((f,p)=>f.attrs["HDCP-LEVEL"]!==p.attrs["HDCP-LEVEL"]?(f.attrs["HDCP-LEVEL"]||"")>(p.attrs["HDCP-LEVEL"]||"")?1:-1:f.bitrate!==p.bitrate?f.bitrate-p.bitrate:f.attrs["FRAME-RATE"]!==p.attrs["FRAME-RATE"]?f.attrs.decimalFloatingPoint("FRAME-RATE")-p.attrs.decimalFloatingPoint("FRAME-RATE"):f.attrs.SCORE!==p.attrs.SCORE?f.attrs.decimalFloatingPoint("SCORE")-p.attrs.decimalFloatingPoint("SCORE"):n&&f.height!==p.height?f.height-p.height:0);let d=h[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==h.length)){for(let f=0;f<h.length;f++)if(h[f].pathwayId===l[0].pathwayId){d=h[f];break}}this._levels=l;for(let f=0;f<l.length;f++)if(l[f]===d){this._firstLevel=f,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${d.bitrate}`);break}const c=o&&!a,u={levels:l,audioTracks:i,subtitleTracks:s,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:o,video:a,altAudio:!c&&i.some(f=>!!f.url)};this.hls.trigger(v.MANIFEST_PARSED,u),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(t){const e=this._levels;if(e.length===0)return;if(t<0||t>=e.length){const d=new Error("invalid level idx"),c=t<0;if(this.hls.trigger(v.ERROR,{type:Y.OTHER_ERROR,details:P.LEVEL_SWITCH_ERROR,level:t,fatal:c,error:d,reason:d.message}),c)return;t=Math.min(t,e.length-1)}const i=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,a=e[t],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=a,i===t&&a.details&&s&&n===o)return;this.log(`Switching to level ${t}${o?" with Pathway "+o:""} from level ${i}${n?" with Pathway "+n:""}`);const l=Et({},a,{level:t,maxBitrate:a.maxBitrate,attrs:a.attrs,uri:a.uri,urlId:a.urlId});delete l._attrs,delete l._urlId,this.hls.trigger(v.LEVEL_SWITCHING,l);const h=a.details;if(!h||h.live){const d=this.switchParams(a.uri,s==null?void 0:s.details);this.loadPlaylist(d)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){if(this._startLevel===void 0){const t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}else return this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){e.fatal||!e.context||e.context.type===st.LEVEL&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){if(e!==void 0&&e.type===X.MAIN){const i=this._levels[e.level];i!==void 0&&(i.loadError=0)}}onLevelLoaded(t,e){var i;const{level:s,details:n}=e,a=this._levels[s];if(!a){var o;this.warn(`Invalid level index ${s}`),(o=e.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(s,e,a.details)):(i=e.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const i=this.currentLevel;if(!i)return;const s=this.hls.audioTracks[e.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==s){let n=-1;for(let a=0;a<i.audioGroupIds.length;a++)if(i.audioGroupIds[a]===s){n=a;break}n!==-1&&n!==i.urlId&&(i.urlId=n,this.canLoad&&this.startLoad())}}loadPlaylist(t){super.loadPlaylist();const e=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){const s=i.urlId;let n=i.uri;if(t)try{n=t.addDirectives(n)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}const a=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${e}${(t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""} with${a?" Pathway "+a:""} URI ${s+1}/${i.url.length} ${n}`),this.clearTimer(),this.hls.trigger(v.LEVEL_LOADING,{url:n,level:e,id:s,deliveryDirectives:t||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}removeLevel(t,e){const i=(n,a)=>a!==e,s=this._levels.filter((n,a)=>a!==t?!0:n.url.length>1&&e!==void 0?(n.url=n.url.filter(i),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(i)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(i)),n.urlId=0,!0):(this.steering&&this.steering.removeLevel(n),!1));this.hls.trigger(v.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(t,{levels:e}){e.forEach((i,s)=>{const{details:n}=i;n!=null&&n.fragments&&n.fragments.forEach(a=>{a.level=s})}),this._levels=e}}function fr(r,t,e){e&&(t==="audio"?(r.audioGroupIds||(r.audioGroupIds=[]),r.audioGroupIds[r.url.length-1]=e):t==="text"&&(r.textGroupIds||(r.textGroupIds=[]),r.textGroupIds[r.url.length-1]=e))}function Bh(r){const t={};r.forEach(e=>{const i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}var Lt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class em{constructor(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(v.BUFFER_APPENDED,this.onBufferAppended,this),t.on(v.FRAG_BUFFERED,this.onFragBuffered,this),t.on(v.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(v.BUFFER_APPENDED,this.onBufferAppended,this),t.off(v.FRAG_BUFFERED,this.onFragBuffered,this),t.off(v.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const i=this.activePartLists[e];if(i)for(let s=i.length;s--;){const n=i[s];if(!n)break;const a=n.end;if(n.start<=t&&a!==null&&t<=a)return n}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:i}=this,s=Object.keys(i);for(let n=s.length;n--;){const a=i[s[n]];if((a==null?void 0:a.body.type)===e&&a.buffered){const o=a.body;if(o.start<=t&&t<=o.end)return o}}return null}detectEvictedFragments(t,e,i,s){this.timeRanges&&(this.timeRanges[t]=e);const n=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===i&&this.removeFragment(o.body);return}const l=o.range[t];l&&l.time.some(h=>{const d=!this.isTimeBuffered(h.startPTS,h.endPTS,e);return d&&this.removeFragment(o.body),d})})}detectPartialFragments(t){const e=this.timeRanges,{frag:i,part:s}=t;if(!e||i.sn==="initSegment")return;const n=Ri(i),a=this.fragments[n];if(!a||a.buffered&&i.gap)return;const o=!i.relurl;Object.keys(e).forEach(l=>{const h=i.elementaryStreams[l];if(!h)return;const d=e[l],c=o||h.partial===!0;a.range[l]=this.getBufferedTimes(i,s,c,d)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=i.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),pr(a)||this.removeParts(i.sn-1,i.type)):this.removeFragment(a.body)}removeParts(t,e){const i=this.activePartLists[e];i&&(this.activePartLists[e]=i.filter(s=>s.fragment.sn>=t))}fragBuffered(t,e){const i=Ri(t);let s=this.fragments[i];!s&&e&&(s=this.fragments[i]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(t,e,i,s){const n={time:[],partial:i},a=t.start,o=t.end,l=t.minEndPTS||o,h=t.maxStartPTS||a;for(let d=0;d<s.length;d++){const c=s.start(d)-this.bufferPadding,u=s.end(d)+this.bufferPadding;if(h>=c&&l<=u){n.time.push({startPTS:Math.max(a,s.start(d)),endPTS:Math.min(o,s.end(d))});break}else if(a<u&&o>c)n.partial=!0,n.time.push({startPTS:Math.max(a,s.start(d)),endPTS:Math.min(o,s.end(d))});else if(o<=c)break}return n}getPartialFragment(t){let e=null,i,s,n,a=0;const{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(h=>{const d=l[h];d&&pr(d)&&(s=d.body.start-o,n=d.body.end+o,t>=s&&t<=n&&(i=Math.min(t-s,n-t),a<=i&&(e=d.body,a=i)))}),e}isEndListAppended(t){const e=this.endListFragments[t];return e!==void 0&&(e.buffered||pr(e))}getState(t){const e=Ri(t),i=this.fragments[e];return i?i.buffered?pr(i)?Lt.PARTIAL:Lt.OK:Lt.APPENDING:Lt.NOT_LOADED}isTimeBuffered(t,e,i){let s,n;for(let a=0;a<i.length;a++){if(s=i.start(a)-this.bufferPadding,n=i.end(a)+this.bufferPadding,t>=s&&e<=n)return!0;if(e<=s)return!1}return!1}onFragLoaded(t,e){const{frag:i,part:s}=e;if(i.sn==="initSegment"||i.bitrateTest)return;const n=s?null:e,a=Ri(i);this.fragments[a]={body:i,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:i,part:s,timeRanges:n}=e;if(i.sn==="initSegment")return;const a=i.type;if(s){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(s)}this.timeRanges=n,Object.keys(n).forEach(o=>{const l=n[o];this.detectEvictedFragments(o,l,a,s)})}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=Ri(t);return!!this.fragments[e]}hasParts(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)}removeFragmentsInRange(t,e,i,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o)return;const l=o.body;l.type!==i||s&&!l.gap||l.start<e&&l.end>t&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(t){const e=Ri(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const i=this.activePartLists[t.type];if(i){const s=t.sn;this.activePartLists[t.type]=i.filter(n=>n.fragment.sn!==s)}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function pr(r){var t,e,i;return r.buffered&&(r.body.gap||((t=r.range.video)==null?void 0:t.partial)||((e=r.range.audio)==null?void 0:e.partial)||((i=r.range.audiovideo)==null?void 0:i.partial))}function Ri(r){return`${r.type}_${r.level}_${r.urlId}_${r.sn}`}const Hh=Math.pow(2,17);class im{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const i=t.url;if(!i)return Promise.reject(new Re({type:Y.NETWORK_ERROR,details:P.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),t.gap)if(t.tagList.some(f=>f[0]==="GAP")){l(Vh(t));return}else t.gap=!1;const h=this.loader=t.loader=n?new n(s):new a(s),d=Gh(t),c=Nh(s.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:Hh};t.stats=h.stats,h.load(d,u,{onSuccess:(f,p,g,m)=>{this.resetLoader(t,h);let b=f.data;g.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(b.slice(0,16)),b=b.slice(16)),o({frag:t,part:null,payload:b,networkDetails:m})},onError:(f,p,g,m)=>{this.resetLoader(t,h),l(new Re({type:Y.NETWORK_ERROR,details:P.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:jt({url:i,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:g,stats:m}))},onAbort:(f,p,g)=>{this.resetLoader(t,h),l(new Re({type:Y.NETWORK_ERROR,details:P.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:g,stats:f}))},onTimeout:(f,p,g)=>{this.resetLoader(t,h),l(new Re({type:Y.NETWORK_ERROR,details:P.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:g,stats:f}))},onProgress:(f,p,g,m)=>{e&&e({frag:t,part:null,payload:g,networkDetails:m})}})})}loadPart(t,e,i){this.abort();const s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap){l(Vh(t,e));return}const h=this.loader=t.loader=n?new n(s):new a(s),d=Gh(t,e),c=Nh(s.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Hh};e.stats=h.stats,h.load(d,u,{onSuccess:(f,p,g,m)=>{this.resetLoader(t,h),this.updateStatsFromPart(t,e);const b={frag:t,part:e,payload:f.data,networkDetails:m};i(b),o(b)},onError:(f,p,g,m)=>{this.resetLoader(t,h),l(new Re({type:Y.NETWORK_ERROR,details:P.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:jt({url:d.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:g,stats:m}))},onAbort:(f,p,g)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,h),l(new Re({type:Y.NETWORK_ERROR,details:P.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:g,stats:f}))},onTimeout:(f,p,g)=>{this.resetLoader(t,h),l(new Re({type:Y.NETWORK_ERROR,details:P.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:g,stats:f}))}})})}updateStatsFromPart(t,e){const i=t.stats,s=e.stats,n=s.total;if(i.loaded+=s.loaded,n){const l=Math.round(t.duration/e.duration),h=Math.min(Math.round(i.loaded/n),l),d=(l-h)*Math.round(i.loaded/h);i.total=i.loaded+d}else i.total=Math.max(i.loaded,i.total);const a=i.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function Gh(r,t=null){const e=t||r,i={frag:r,part:t,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},s=e.byteRangeStartOffset,n=e.byteRangeEndOffset;if(K(s)&&K(n)){var a;let o=s,l=n;if(r.sn==="initSegment"&&((a=r.decryptdata)==null?void 0:a.method)==="AES-128"){const h=n-s;h%16&&(l=n+(16-h%16)),s!==0&&(i.resetIV=!0,o=s-16)}i.rangeStart=o,i.rangeEnd=l}return i}function Vh(r,t){const e=new Error(`GAP ${r.gap?"tag":"attribute"} found`),i={type:Y.MEDIA_ERROR,details:P.FRAG_GAP,fatal:!1,frag:r,error:e,networkDetails:null};return t&&(i.part=t),(t||r).stats.aborted=!0,new Re(i)}class Re extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class sm{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const e in this.keyUriToKeyInfo){const i=this.keyUriToKeyInfo[e].loader;if(i){if(t&&t!==i.context.frag.type)return;i.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=P.KEY_LOAD_ERROR,i,s,n){return new Re({type:Y.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:n,error:i,networkDetails:s})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:s}=t;for(let n=0;n<e.length;n++){const a=e[n];if(s<=a.cc&&(i==="initSegment"||a.sn==="initSegment"||i<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(e=>this.loadInternal(t,e)):this.loadInternal(t)}loadInternal(t,e){var i,s;e&&t.setKeyFormat(e);const n=t.decryptdata;if(!n){const h=new Error(e?`Expected frag.decryptdata to be defined after setting format ${e}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,P.KEY_LOAD_ERROR,h))}const a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(t,P.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((i=o)!=null&&i.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:t,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(h=>(n.key=h.keyInfo.decryptdata.key,{frag:t,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,t):this.loadKeyEME(o,t);case"AES-128":return this.loadKeyHTTP(o,t);default:return Promise.reject(this.createKeyLoadError(t,P.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(t,e){const i={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const s=this.emeController.loadKey(i);if(s)return(t.keyLoadPromise=s.then(n=>(t.mediaKeySessionContext=n,i))).catch(n=>{throw t.keyLoadPromise=null,n})}return Promise.resolve(i)}loadKeyHTTP(t,e){const i=this.config,s=i.loader,n=new s(i);return e.keyLoader=t.loader=n,t.keyLoadPromise=new Promise((a,o)=>{const l={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},h=i.keyLoadPolicy.default,d={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(u,f,p,g)=>{const{frag:m,keyInfo:b,url:A}=p;if(!m.decryptdata||b!==this.keyUriToKeyInfo[A])return o(this.createKeyLoadError(m,P.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),g));b.decryptdata.key=m.decryptdata.key=new Uint8Array(u.data),m.keyLoader=null,b.loader=null,a({frag:m,keyInfo:b})},onError:(u,f,p,g)=>{this.resetLoader(f),o(this.createKeyLoadError(e,P.KEY_LOAD_ERROR,new Error(`HTTP Error ${u.code} loading key ${u.text}`),p,jt({url:l.url,data:void 0},u)))},onTimeout:(u,f,p)=>{this.resetLoader(f),o(this.createKeyLoadError(e,P.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),p))},onAbort:(u,f,p)=>{this.resetLoader(f),o(this.createKeyLoadError(e,P.INTERNAL_ABORTED,new Error("key loading aborted"),p))}};n.load(l,d,c)})}resetLoader(t){const{frag:e,keyInfo:i,url:s}=t,n=i.loader;e.keyLoader===n&&(e.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}}class rm{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}const nm={length:0,start:()=>0,end:()=>0};class lt{static isBuffered(t,e){try{if(t){const i=lt.getBuffered(t);for(let s=0;s<i.length;s++)if(e>=i.start(s)&&e<=i.end(s))return!0}}catch{}return!1}static bufferInfo(t,e,i){try{if(t){const s=lt.getBuffered(t),n=[];let a;for(a=0;a<s.length;a++)n.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(n,e,i)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}}static bufferedInfo(t,e,i){e=Math.max(0,e),t.sort(function(h,d){return h.start-d.start||d.end-h.end});let s=[];if(i)for(let h=0;h<t.length;h++){const d=s.length;if(d){const c=s[d-1].end;t[h].start-c<i?t[h].end>c&&(s[d-1].end=t[h].end):s.push(t[h])}else s.push(t[h])}else s=t;let n=0,a,o=e,l=e;for(let h=0;h<s.length;h++){const d=s[h].start,c=s[h].end;if(e+i>=d&&e<c)o=d,l=c,n=l-e;else if(e+i<d){a=d;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(t){try{return t.buffered}catch(e){return R.log("failed to get media.buffered",e),nm}}}class ra{constructor(t,e,i,s=0,n=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=gr(),this.buffering={audio:gr(),video:gr(),audiovideo:gr()},this.level=t,this.sn=e,this.id=i,this.size=s,this.part=n,this.partial=a}}function gr(){return{start:0,executeStart:0,executeEnd:0,end:0}}function jh(r,t){let e=null;for(let i=0,s=r.length;i<s;i++){const n=r[i];if(n&&n.cc===t){e=n;break}}return e}function am(r,t,e){return!!(t.details&&(e.endCC>e.startCC||r&&r.cc<e.startCC))}function om(r,t,e=0){const i=r.fragments,s=t.fragments;if(!s.length||!i.length){R.log("No fragments to align");return}const n=jh(i,s[0].cc);if(!n||n&&!n.startPTS){R.log("No frag in previous level to align on");return}return n}function zh(r,t){if(r){const e=r.start+t;r.start=r.startPTS=e,r.endPTS=e+r.duration}}function na(r,t){const e=t.fragments;for(let i=0,s=e.length;i<s;i++)zh(e[i],r);t.fragmentHint&&zh(t.fragmentHint,r),t.alignedSliding=!0}function lm(r,t,e){t&&(hm(r,e,t),!e.alignedSliding&&t.details&&dm(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&Ph(t.details,e))}function hm(r,t,e){if(am(r,e,t)){const i=om(e.details,t);i&&K(i.start)&&(R.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),na(i.start,t))}}function dm(r,t){if(!t.fragments.length||!r.hasProgramDateTime||!t.hasProgramDateTime)return;const e=t.fragments[0].programDateTime,i=r.fragments[0].programDateTime,s=(i-e)/1e3+t.fragments[0].start;s&&K(s)&&(R.log(`Adjusting PTS using programDateTime delta ${i-e}ms, sliding:${s.toFixed(3)} ${r.url} `),na(s,r))}function Kh(r,t){if(!r.hasProgramDateTime||!t.hasProgramDateTime)return;const e=r.fragments,i=t.fragments;if(!e.length||!i.length)return;const s=Math.round(i.length/2)-1,n=i[s],a=jh(e,n.cc)||e[Math.round(e.length/2)-1],o=n.programDateTime,l=a.programDateTime;if(o===null||l===null)return;const h=(l-o)/1e3-(a.start-n.start);na(h,r)}class cm{constructor(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}decrypt(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)}}class um{constructor(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function fm(r){const t=r.byteLength,e=t&&new DataView(r.buffer).getUint8(t-1);return e?ni(r,0,t-e):r}class pm{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_(t){const e=new DataView(t),i=new Uint32Array(4);for(let s=0;s<4;s++)i[s]=e.getUint32(s*4);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,s=i[0],n=i[1],a=i[2],o=i[3],l=this.invSubMix,h=l[0],d=l[1],c=l[2],u=l[3],f=new Uint32Array(256);let p=0,g=0,m=0;for(m=0;m<256;m++)m<128?f[m]=m<<1:f[m]=m<<1^283;for(m=0;m<256;m++){let b=g^g<<1^g<<2^g<<3^g<<4;b=b>>>8^b&255^99,t[p]=b,e[b]=p;const A=f[p],T=f[A],y=f[T];let E=f[b]*257^b*16843008;s[p]=E<<24|E>>>8,n[p]=E<<16|E>>>16,a[p]=E<<8|E>>>24,o[p]=E,E=y*16843009^T*65537^A*257^p*16843008,h[b]=E<<24|E>>>8,d[b]=E<<16|E>>>16,c[b]=E<<8|E>>>24,u[b]=E,p?(p=A^f[f[f[y^A]]],g^=f[f[g]]):p=g=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let i=!0,s=0;for(;s<e.length&&i;)i=e[s]===this.key[s],s++;if(i)return;this.key=e;const n=this.keySize=e.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);const a=this.ksRows=(n+6+1)*4;let o,l;const h=this.keySchedule=new Uint32Array(a),d=this.invKeySchedule=new Uint32Array(a),c=this.sBox,u=this.rcon,f=this.invSubMix,p=f[0],g=f[1],m=f[2],b=f[3];let A,T;for(o=0;o<a;o++){if(o<n){A=h[o]=e[o];continue}T=A,o%n===0?(T=T<<8|T>>>24,T=c[T>>>24]<<24|c[T>>>16&255]<<16|c[T>>>8&255]<<8|c[T&255],T^=u[o/n|0]<<24):n>6&&o%n===4&&(T=c[T>>>24]<<24|c[T>>>16&255]<<16|c[T>>>8&255]<<8|c[T&255]),h[o]=A=(h[o-n]^T)>>>0}for(l=0;l<a;l++)o=a-l,l&3?T=h[o]:T=h[o-4],l<4||o<=4?d[l]=T:d[l]=p[c[T>>>24]]^g[c[T>>>16&255]]^m[c[T>>>8&255]]^b[c[T&255]],d[l]=d[l]>>>0}networkToHostOrderSwap(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24}decrypt(t,e,i){const s=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],h=o[1],d=o[2],c=o[3],u=this.uint8ArrayToUint32Array_(i);let f=u[0],p=u[1],g=u[2],m=u[3];const b=new Int32Array(t),A=new Int32Array(b.length);let T,y,E,S,L,D,k,x,F,O,G,W,w,I;const B=this.networkToHostOrderSwap;for(;e<b.length;){for(F=B(b[e]),O=B(b[e+1]),G=B(b[e+2]),W=B(b[e+3]),L=F^n[0],D=W^n[1],k=G^n[2],x=O^n[3],w=4,I=1;I<s;I++)T=l[L>>>24]^h[D>>16&255]^d[k>>8&255]^c[x&255]^n[w],y=l[D>>>24]^h[k>>16&255]^d[x>>8&255]^c[L&255]^n[w+1],E=l[k>>>24]^h[x>>16&255]^d[L>>8&255]^c[D&255]^n[w+2],S=l[x>>>24]^h[L>>16&255]^d[D>>8&255]^c[k&255]^n[w+3],L=T,D=y,k=E,x=S,w=w+4;T=a[L>>>24]<<24^a[D>>16&255]<<16^a[k>>8&255]<<8^a[x&255]^n[w],y=a[D>>>24]<<24^a[k>>16&255]<<16^a[x>>8&255]<<8^a[L&255]^n[w+1],E=a[k>>>24]<<24^a[x>>16&255]<<16^a[L>>8&255]<<8^a[D&255]^n[w+2],S=a[x>>>24]<<24^a[L>>16&255]<<16^a[D>>8&255]<<8^a[k&255]^n[w+3],A[e]=B(T^f),A[e+1]=B(S^p),A[e+2]=B(E^g),A[e+3]=B(y^m),f=F,p=O,g=G,m=W,e=e+4}return A.buffer}}const gm=16;class aa{constructor(t,{removePKCS7Padding:e=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=e,e)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}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(){const{currentResult:t,remainderData:e}=this;if(!t||e)return this.reset(),null;const i=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?fm(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(t,e,i){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(t),e,i);const a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,i)}softwareDecrypt(t,e,i){const{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(t=ai(a,t),this.remainderData=null);const o=this.getValidChunk(t);if(!o.length)return null;s&&(i=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new pm),l.expandKey(e);const h=n;return this.currentResult=l.decrypt(o.buffer,0,i),this.currentIV=ni(o,-16).buffer,h||null}webCryptoDecrypt(t,e,i){const s=this.subtle;return(this.key!==e||!this.fastAesKey)&&(this.key=e,this.fastAesKey=new um(s,e)),this.fastAesKey.expandKey().then(n=>s?(this.logOnce("WebCrypto AES decrypt"),new cm(s,new Uint8Array(i)).decrypt(t.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(R.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(t,e,i)))}onWebCryptoError(t,e,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,i);const s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const i=t.length-t.length%gm;return i!==t.length&&(e=ni(t,0,i),this.remainderData=ni(t,i)),e}logOnce(t){this.logEnabled&&(R.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const mm={toString:function(r){let t="";const e=r.length;for(let i=0;i<e;i++)t+=`[${r.start(i).toFixed(3)}-${r.end(i).toFixed(3)}]`;return t}},N={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"};class oa extends rm{constructor(t,e,i,s,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=N.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=s,this.log=R.log.bind(R,`${s}:`),this.warn=R.warn.bind(R,`${s}:`),this.hls=t,this.fragmentLoader=new im(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new aa(t.config),t.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=N.STOPPED}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;const i=e.partList;if(i!=null&&i.length){const n=i[i.length-1];return lt.isBuffered(this.media,n.start+n.duration/2)}const s=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var t;return(t=this.levels[this.levelLastLoaded])==null?void 0:t.details}}onMediaAttached(t,e){const i=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);const s=this.config;this.levels&&s.autoStartLoad&&this.state===N.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){const t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:t,fragCurrent:e,media:i,mediaBuffer:s,state:n}=this,a=i?i.currentTime:0,o=lt.bufferInfo(s||i,a,t.maxBufferHole);if(this.log(`media seeking to ${K(a)?a.toFixed(3):a}, state: ${n}`),this.state===N.ENDED)this.resetLoadingState();else if(e){const l=t.maxFragLookUpTolerance,h=e.start-l,d=e.start+e.duration+l;if(!o.len||d<o.start||h>o.end){const c=a>d;(a<h||c)&&(c&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=N.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(t,e,i){this._loadFragForPlayback(t,e,i)}_loadFragForPlayback(t,e,i){const s=n=>{if(this.fragContextChanged(t)){this.warn(`Fragment ${t.sn}${n.part?" p: "+n.part.index:""} of level ${t.level} was dropped during download.`),this.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(t,e,i,s).then(n=>{if(!n)return;const a=this.state;if(this.fragContextChanged(t)){(a===N.FRAG_LOADING||!this.fragCurrent&&a===N.PARSING)&&(this.fragmentTracker.removeFragment(t),this.state=N.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(v.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(n),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===Lt.APPENDING){const s=t.type,n=this.getFwdBufferInfo(this.mediaBuffer,s),a=Math.max(t.duration,n?n.len:this.config.maxBufferLength);this.reduceMaxBufferLength(a)&&i.removeFragment(t)}else((e=this.mediaBuffer)==null?void 0:e.buffered.length)===0?i.removeAllFragments():i.hasParts(t.type)&&(i.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),i.getState(t)===Lt.PARTIAL&&i.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const e=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)}flushMainBuffer(t,e,i=null){if(!(t-e))return;const s={startOffset:t,endOffset:e,type:i};this.hls.trigger(v.BUFFER_FLUSHING,s)}_loadInitSegment(t,e){this._doFragLoad(t,e).then(i=>{if(!i||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:s}=this,{payload:n}=i,a=t.decryptdata;if(n&&n.byteLength>0&&a&&a.key&&a.iv&&a.method==="AES-128"){const o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw s.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:t}),l}).then(l=>{const h=self.performance.now();return s.trigger(v.FRAG_DECRYPTED,{frag:t,payload:l,stats:{tstart:o,tdecrypt:h}}),i.payload=l,i})}return i}).then(i=>{const{fragCurrent:s,hls:n,levels:a}=this;if(!a)throw new Error("init load aborted, missing levels");const o=t.stats;this.state=N.IDLE,e.fragmentError=0,t.data=new Uint8Array(i.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),i.frag===s&&n.trigger(v.FRAG_BUFFERED,{stats:o,frag:s,part:null,id:t.type}),this.tick()}).catch(i=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(i),this.resetFragmentLoading(t))})}fragContextChanged(t){const{fragCurrent:e}=this;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId}fragBufferedComplete(t,e){var i,s,n,a;const o=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===X.MAIN?"level":"track"} ${t.level} (frag:[${((i=t.startPTS)!=null?i:NaN).toFixed(3)}-${((s=t.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?mm.toString(lt.getBuffered(o)):"(detached)"})`),this.state=N.IDLE,o&&(!this.loadedmetadata&&t.type==X.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:i,part:s,partsLoaded:n}=t,a=!n||n.length===0||n.some(l=>!l),o=new ra(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!a);e.flush(o)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,i=null,s){var n;const a=e==null?void 0:e.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(t.encrypted&&!((n=t.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${t.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${t.level}`),this.state=N.KEY_LOADING,this.fragCurrent=t,o=this.keyLoader.load(t).then(d=>{if(!this.fragContextChanged(d.frag))return this.hls.trigger(v.KEY_LOADED,d),this.state===N.KEY_LOADING&&(this.state=N.IDLE),d}),this.hls.trigger(v.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(t,a.encryptedFragments),i=Math.max(t.start,i||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){const d=a.partList;if(d&&s){i>t.end&&a.fragmentHint&&(t=a.fragmentHint);const c=this.getNextPart(d,t,i);if(c>-1){const u=d[c];this.log(`Loading part sn: ${t.sn} p: ${u.index} cc: ${t.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${c}-${d.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=u.start+u.duration,this.state=N.FRAG_LOADING;let f;return o?f=o.then(p=>!p||this.fragContextChanged(p.frag)?null:this.doFragPartsLoad(t,u,e,s)).catch(p=>this.handleFragLoadError(p)):f=this.doFragPartsLoad(t,u,e,s).catch(p=>this.handleFragLoadError(p)),this.hls.trigger(v.FRAG_LOADING,{frag:t,part:u,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!t.url||this.loadedEndOfParts(d,i))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),K(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=N.FRAG_LOADING;const l=this.config.progressive;let h;return l&&o?h=o.then(d=>!d||this.fragContextChanged(d==null?void 0:d.frag)?null:this.fragmentLoader.load(t,s)).catch(d=>this.handleFragLoadError(d)):h=Promise.all([this.fragmentLoader.load(t,l?s:void 0),o]).then(([d])=>(!l&&d&&s&&s(d),d)).catch(d=>this.handleFragLoadError(d)),this.hls.trigger(v.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):h}doFragPartsLoad(t,e,i,s){return new Promise((n,a)=>{var o;const l=[],h=(o=i.details)==null?void 0:o.partList,d=c=>{this.fragmentLoader.loadPart(t,c,s).then(u=>{l[c.index]=u;const f=u.part;this.hls.trigger(v.FRAG_LOADED,u);const p=Oh(i,t.sn,c.index+1)||Mh(h,t.sn,c.index+1);if(p)d(p);else return n({frag:t,part:f,partsLoaded:l})}).catch(a)};d(e)})}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===P.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(v.ERROR,e)}else this.hls.trigger(v.ERROR,{type:Y.OTHER_ERROR,details:P.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==N.PARSING){!this.fragCurrent&&this.state!==N.STOPPED&&this.state!==N.ERROR&&(this.state=N.IDLE);return}const{frag:i,part:s,level:n}=e,a=self.performance.now();i.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(i,s,n,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:i}=this,{level:s,sn:n,part:a}=t;if(!(e!=null&&e[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${s}. The current chunk will not be buffered.`),null;const o=e[s],l=a>-1?Oh(o,n,a):null,h=l?l.fragment:Yg(o,n,i);return h?(i&&i!==h&&(h.stats=i.stats),{frag:h,part:l,level:o}):null}bufferFragmentData(t,e,i,s,n){var a;if(!t||this.state!==N.PARSING)return;const{data1:o,data2:l}=t;let h=o;if(o&&l&&(h=ai(o,l)),!((a=h)!=null&&a.length))return;const d={type:t.type,frag:e,part:i,chunkMeta:s,parent:e.type,data:h};if(this.hls.trigger(v.BUFFER_APPENDING,d),t.dropped&&t.independent&&!i){if(n)return;this.flushBufferGap(e)}}flushBufferGap(t){const e=this.media;if(!e)return;if(!lt.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}const i=e.currentTime,s=lt.bufferInfo(e,i,0),n=t.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(t.start-a,s.end-a),i+a);t.start-o>a&&this.flushMainBuffer(o,t.start)}getFwdBufferInfo(t,e){const i=this.getLoadPosition();return K(i)?this.getFwdBufferInfoAtPos(t,i,e):null}getFwdBufferInfoAtPos(t,e,i){const{config:{maxBufferHole:s}}=this,n=lt.bufferInfo(t,e,s);if(n.len===0&&n.nextStart!==void 0){const a=this.fragmentTracker.getBufferedFrag(e,i);if(a&&n.nextStart<a.end)return lt.bufferInfo(t,e,Math.max(n.nextStart,s))}return n}getMaxBufferLength(t){const{config:e}=this;let i;return t?i=Math.max(8*e.maxBufferSize/t,e.maxBufferLength):i=e.maxBufferLength,Math.min(i,e.maxMaxBufferLength)}reduceMaxBufferLength(t){const e=this.config,i=t||e.maxBufferLength;return e.maxMaxBufferLength>=i?(e.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${e.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(t,e=X.MAIN){const i=this.fragmentTracker.getAppendedFrag(t,X.MAIN);return i&&"fragment"in i?i.fragment:i}getNextFragment(t,e){const i=e.fragments,s=i.length;if(!s)return null;const{config:n}=this,a=i[0].start;let o;if(e.live){const l=n.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;!e.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(o=this.getInitialLiveFragment(e,i),this.startPosition=o?this.hls.liveSyncPosition||o.start:t)}else t<=a&&(o=i[0]);if(!o){const l=n.lowLatencyMode?e.partEnd:e.fragmentEnd;o=this.getFragmentAtPosition(t,l,e)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(t,e){const i=this.fragmentTracker.getState(t);return(i===Lt.OK||i===Lt.PARTIAL&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,i,s,n){const a=t.gap,o=this.getNextFragment(this.nextLoadPosition,e);if(o===null)return o;if(t=o,a&&t&&!t.gap&&i.nextStart){const l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s);if(l!==null&&i.len+l.len>=n)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${t.sn}`),null}return t}mapToInitFragWhenRequired(t){return t!=null&&t.initSegment&&!(t!=null&&t.initSegment.data)&&!this.bitrateTest?t.initSegment:t}getNextPart(t,e,i){let s=-1,n=!1,a=!0;for(let o=0,l=t.length;o<l;o++){const h=t[o];if(a=a&&!h.independent,s>-1&&i<h.start)break;const d=h.loaded;d?s=-1:(n||h.independent||a)&&h.fragment===e&&(s=o),n=d}return s}loadedEndOfParts(t,e){const i=t[t.length-1];return i&&e>i.start&&i.loaded}getInitialLiveFragment(t,e){const i=this.fragPrevious;let s=null;if(i){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),s=qg(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const n=i.sn+1;if(n>=t.startSN&&n<=t.endSN){const a=e[n-t.startSN];i.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=Jg(e,i.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?t.fragmentEnd:t.edge,t))}return s}getFragmentAtPosition(t,e,i){const{config:s}=this;let{fragPrevious:n}=this,{fragments:a,endSN:o}=i;const{fragmentHint:l}=i,h=s.maxFragLookUpTolerance,d=i.partList,c=!!(s.lowLatencyMode&&d!=null&&d.length&&l);c&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let u;if(t<e){const f=t>e-h?0:h;u=bs(n,a,t,f)}else u=a[a.length-1];if(u){const f=u.sn-i.startSN,p=this.fragmentTracker.getState(u);if((p===Lt.OK||p===Lt.PARTIAL&&u.gap)&&(n=u),n&&u.sn===n.sn&&(!c||d[0].fragment.sn>u.sn)&&n&&u.level===n.level){const g=a[f+1];u.sn<o&&this.fragmentTracker.getState(g)!==Lt.OK?u=g:u=null}}return u}synchronizeToLiveEdge(t){const{config:e,media:i}=this;if(!i)return;const s=this.hls.liveSyncPosition,n=i.currentTime,a=t.fragments[0].start,o=t.edge,l=n>=a-e.maxFragLookUpTolerance&&n<=o;if(s!==null&&i.duration>s&&(n<s||!l)){const h=e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!l&&i.readyState<4||n<o-h)&&(this.loadedmetadata||(this.nextLoadPosition=s),i.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),i.currentTime=s))}}alignPlaylists(t,e){const{levels:i,levelLastLoaded:s,fragPrevious:n}=this,a=s!==null?i[s]:null,o=t.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;const l=t.fragments[0].start,h=!e,d=t.alignedSliding&&K(l);if(h||!d&&!l){lm(n,a,t);const c=t.fragments[0].start;return this.log(`Live playlist sliding: ${c.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} prev-sn: ${n?n.sn:"na"} fragments: ${o}`),c}return l}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*3)}setStartPosition(t,e){let i=this.startPosition;if(i<e&&(i=-1),i===-1||this.lastCurrentTime===-1){const s=this.startTimeOffset!==null,n=s?this.startTimeOffset:t.startTimeOffset;n!==null&&K(n)?(i=e+n,n<0&&(i+=t.totalduration),i=Math.min(Math.max(e,i),e+t.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):t.live?i=this.hls.liveSyncPosition||e:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}getLoadPosition(){const{media:t}=this;let e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e}handleFragLoadAborted(t,e){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn(`Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==N.FRAG_LOADING_WAITING_RETRY)&&(this.state=N.IDLE)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const c=this.getCurrentContext(e.chunkMeta);c&&(e.frag=c.frag)}const i=e.frag;if(!i||i.type!==t||!this.levels)return;if(this.fragContextChanged(i)){var s;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}const n=e.details===P.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);const a=e.errorAction,{action:o,retryCount:l=0,retryConfig:h}=a||{};if(a&&o===Ft.RetryRequest&&h){var d;this.resetStartWhenNotLoaded((d=this.levelLastLoaded)!=null?d:i.level);const c=ta(h,l);this.warn(`Fragment ${i.sn} of ${t} ${i.level} errored with ${e.details}, retrying loading ${l+1}/${h.maxNumRetry} in ${c}ms`),a.resolved=!0,this.retryDate=self.performance.now()+c,this.state=N.FRAG_LOADING_WAITING_RETRY}else h&&a?(this.resetFragmentErrors(t),l<h.maxNumRetry?n||(a.resolved=!0):R.warn(`${e.details} reached or exceeded max retry (${l})`)):(a==null?void 0:a.action)===Ft.SendAlternateToPenaltyBox?this.state=N.WAITING_LEVEL:this.state=N.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===N.PARSING||this.state===N.PARSED){const e=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,e),s=i&&i.len>.5;s&&this.reduceMaxBufferLength(i.len);const n=!s;return n&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${e} buffer`),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(t){t===X.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==N.STOPPED&&(this.state=N.IDLE)}afterBufferFlushed(t,e,i){if(!t)return;const s=lt.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,s,i),this.state===N.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=N.IDLE}resetStartWhenNotLoaded(t){if(!this.loadedmetadata){this.startFragRequested=!1;const e=this.levels?this.levels[t].details:null;e!=null&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){var e;this.warn(`The loading context changed while buffering fragment ${t.sn} of level ${t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((e=this.levelLastLoaded)!=null?e:t.level),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,e,i,s){var n;const a=i.details;if(!a){this.warn("level.details undefined");return}if(Object.keys(t.elementaryStreams).reduce((o,l)=>{const h=t.elementaryStreams[l];if(h){const d=h.endPTS-h.startPTS;if(d<=0)return this.warn(`Could not parse fragment ${t.sn} ${l} duration reliably (${d})`),o||!1;const c=s?0:Ih(a,t,h.startPTS,h.endPTS,h.startDTS,h.endDTS);return this.hls.trigger(v.LEVEL_PTS_UPDATED,{details:a,level:i,drift:c,type:l,frag:t,start:h.startPTS,end:h.endPTS}),!0}return o},!1))i.fragmentError=0;else if(((n=this.transmuxer)==null?void 0:n.error)===null){const o=new Error(`Found no media in fragment ${t.sn} of level ${t.level} resetting transmuxer to fallback to playlist timing`);if(i.fragmentError===0&&(i.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(o.message),this.hls.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:t,reason:`Found no media in msn ${t.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=N.PARSED,this.hls.trigger(v.FRAG_PARSED,{frag:t,part:e})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){if(t.event==="demuxerWorker"){var e,i,s;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((e=(i=this.levelLastLoaded)!=null?i:(s=this.fragCurrent)==null?void 0:s.level)!=null?e:0),this.resetLoadingState()}}set state(t){const e=this._state;e!==t&&(this._state=t,this.log(`${e}->${t}`))}get state(){return this._state}}function Wh(){return self.SourceBuffer||self.WebKitSourceBuffer}function vm(){const r=hr();if(!r)return!1;const t=Wh(),e=r&&typeof r.isTypeSupported=="function"&&r.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function";return!!e&&!!i}function ym(){var r;const t=Wh();return typeof(t==null||(r=t.prototype)==null?void 0:r.changeType)=="function"}function bm(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Am(){const r=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(r);return{worker:new self.Worker(t),objectURL:t}}function Tm(r){const t=new self.URL(r,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}function me(r="",t=9e4){return{type:r,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class Yh{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(t,e,i,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,i){}demux(t,e){this.cachedData&&(t=ai(this.cachedData,t),this.cachedData=null);let i=nr(t,0),s=i?i.length:0,n;const a=this._audioTrack,o=this._id3Track,l=i?sg(i):void 0,h=t.length;for((this.basePTS===null||this.frameIndex===0&&K(l))&&(this.basePTS=Em(l,e,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:le.audioId3,duration:Number.POSITIVE_INFINITY});s<h;){if(this.canParse(t,s)){const d=this.appendFrame(a,t,s);d?(this.frameIndex++,this.lastPTS=d.sample.pts,s+=d.length,n=s):s=h}else ig(t,s)?(i=nr(t,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:le.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,n=s):s++;if(s===h&&n!==h){const d=ni(t,n);this.cachedData?this.cachedData=ai(this.cachedData,d):this.cachedData=d}}return{audioTrack:a,videoTrack:me(),id3Track:o,textTrack:me()}}demuxSampleAes(t,e,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(t){const e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:me(),id3Track:this._id3Track,textTrack:me()}}destroy(){}}const Em=(r,t,e)=>{if(K(r))return r*90;const i=e?e.baseTime*9e4/e.timescale:0;return t*9e4+i};function wm(r,t,e,i){let s,n,a,o;const l=navigator.userAgent.toLowerCase(),h=i,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((t[e+2]&192)>>>6)+1;const c=(t[e+2]&60)>>>2;if(c>d.length-1){r.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${c}`});return}return a=(t[e+2]&1)<<2,a|=(t[e+3]&192)>>>6,R.log(`manifest codec:${i}, ADTS type:${s}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(s=5,o=new Array(4),n=c-3):(s=2,o=new Array(2),n=c):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=c):(s=5,o=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&c>=6?n=c-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(c>=6&&a===1||/vivaldi/i.test(l))||!i&&a===1)&&(s=2,o=new Array(2)),n=c)),o[0]=s<<3,o[0]|=(c&14)>>1,o[1]|=(c&1)<<7,o[1]|=a<<3,s===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:d[c],channelCount:a,codec:"mp4a.40."+s,manifestCodec:h}}function Xh(r,t){return r[t]===255&&(r[t+1]&246)===240}function qh(r,t){return r[t+1]&1?7:9}function la(r,t){return(r[t+3]&3)<<11|r[t+4]<<3|(r[t+5]&224)>>>5}function Sm(r,t){return t+5<r.length}function mr(r,t){return t+1<r.length&&Xh(r,t)}function Lm(r,t){return Sm(r,t)&&Xh(r,t)&&la(r,t)<=r.length-t}function Rm(r,t){if(mr(r,t)){const e=qh(r,t);if(t+e>=r.length)return!1;const i=la(r,t);if(i<=e)return!1;const s=t+i;return s===r.length||mr(r,s)}return!1}function Zh(r,t,e,i,s){if(!r.samplerate){const n=wm(t,e,i,s);if(!n)return;r.config=n.config,r.samplerate=n.samplerate,r.channelCount=n.channelCount,r.codec=n.codec,r.manifestCodec=n.manifestCodec,R.log(`parsed codec:${r.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function Jh(r){return 9216e4/r}function xm(r,t){const e=qh(r,t);if(t+e<=r.length){const i=la(r,t)-e;if(i>0)return{headerLength:e,frameLength:i}}}function Qh(r,t,e,i,s){const n=Jh(r.samplerate),a=i+s*n,o=xm(t,e);let l;if(o){const{frameLength:d,headerLength:c}=o,u=c+d,f=Math.max(0,e+u-t.length);f?(l=new Uint8Array(u-c),l.set(t.subarray(e+c,t.length),0)):l=t.subarray(e+c,e+u);const p={unit:l,pts:a};return f||r.samples.push(p),{sample:p,length:u,missing:f}}const h=t.length-e;return l=new Uint8Array(h),l.set(t.subarray(e,t.length),0),{sample:{unit:l,pts:a},length:h,missing:-1}}class km extends Yh{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,i,s){super.resetInitSegment(t,e,i,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:s,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(nr(t,0)||[]).length;for(let i=t.length;e<i;e++)if(Rm(t,e))return R.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return Lm(t,e)}appendFrame(t,e,i){Zh(t,this.observer,e,i,t.manifestCodec);const s=Qh(t,e,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const Dm=/\/emsg[-/]ID3/i;class Cm{constructor(t,e){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=e}resetTimeStamp(){}resetInitSegment(t,e,i,s){const n=this.videoTrack=me("video",1),a=this.audioTrack=me("audio",1),o=this.txtTrack=me("text",1);if(this.id3Track=me("id3",1),this.timeOffset=0,!(t!=null&&t.byteLength))return;const l=hh(t);if(l.video){const{id:h,timescale:d,codec:c}=l.video;n.id=h,n.timescale=o.timescale=d,n.codec=c}if(l.audio){const{id:h,timescale:d,codec:c}=l.audio;a.id=h,a.timescale=d,a.codec=c}o.id=ah.text,n.sampleDuration=0,n.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(t){return t=t.length>16384?t.subarray(0,16384):t,et(t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let i=t;const s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=ai(this.remainderData,t));const o=yg(i);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=i;const a=this.extractID3Track(s,e);return n.samples=ch(e,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,i=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(e,this.timeOffset);return i.samples=ch(t,e),{videoTrack:e,audioTrack:me(),id3Track:s,textTrack:me()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const s=et(t.samples,["emsg"]);s&&s.forEach(n=>{const a=Tg(n);if(Dm.test(a.schemeIdUri)){const o=K(a.presentationTime)?a.presentationTime/a.timeScale:e+a.presentationTimeDelta/a.timeScale;let l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);const h=a.payload;i.samples.push({data:h,len:h.byteLength,dts:o,pts:o,type:le.emsg,duration:l})}})}return i}demuxSampleAes(t,e,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}let vr=null;const Im=[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],Pm=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Om=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Mm=[0,1,1,4];function _h(r,t,e,i,s){if(e+24>t.length)return;const n=$h(t,e);if(n&&e+n.frameLength<=t.length){const a=n.samplesPerFrame*9e4/n.sampleRate,o=i+s*a,l={unit:t.subarray(e,e+n.frameLength),pts:o,dts:o};return r.config=[],r.channelCount=n.channelCount,r.samplerate=n.sampleRate,r.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function $h(r,t){const e=r[t+1]>>3&3,i=r[t+1]>>1&3,s=r[t+2]>>4&15,n=r[t+2]>>2&3;if(e!==1&&s!==0&&s!==15&&n!==3){const a=r[t+2]>>1&1,o=r[t+3]>>6,l=e===3?3-i:i===3?3:4,h=Im[l*14+s-1]*1e3,d=Pm[(e===3?0:e===2?1:2)*3+n],c=o===3?1:2,u=Om[e][i],f=Mm[i],p=u*8*f,g=Math.floor(u*h/d+a)*f;if(vr===null){const m=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);vr=m?parseInt(m[1]):0}return vr&&vr<=87&&i===2&&h>=224e3&&o===0&&(r[t+3]=r[t+3]|128),{sampleRate:d,channelCount:c,frameLength:g,samplesPerFrame:p}}}function ha(r,t){return r[t]===255&&(r[t+1]&224)===224&&(r[t+1]&6)!==0}function td(r,t){return t+1<r.length&&ha(r,t)}function Fm(r,t){return ha(r,t)&&4<=r.length-t}function Nm(r,t){if(t+1<r.length&&ha(r,t)){const e=$h(r,t);let i=4;e!=null&&e.frameLength&&(i=e.frameLength);const s=t+i;return s===r.length||td(r,s)}return!1}class ed{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const t=this.data,e=this.bytesAvailable,i=t.byteLength-e,s=new Uint8Array(4),n=Math.min(4,e);if(n===0)throw new Error("no bytes available");s.set(t.subarray(i,i+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(t){let e;t=Math.min(t,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,e=t>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let e=Math.min(this.bitsAvailable,t);const i=this.word>>>32-e;if(t>32&&R.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return e=t-e,e>0&&this.bitsAvailable?i<<e|this.readBits(e):i}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(this.word&2147483648>>>t)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(t){let e=8,i=8,s;for(let n=0;n<t;n++)i!==0&&(s=this.readEG(),i=(e+s+256)%256),e=i===0?e:i}readSPS(){let t=0,e=0,i=0,s=0,n,a,o;const l=this.readUByte.bind(this),h=this.readBits.bind(this),d=this.readUEG.bind(this),c=this.readBoolean.bind(this),u=this.skipBits.bind(this),f=this.skipEG.bind(this),p=this.skipUEG.bind(this),g=this.skipScalingList.bind(this);l();const m=l();if(h(5),u(3),l(),p(),m===100||m===110||m===122||m===244||m===44||m===83||m===86||m===118||m===128){const S=d();if(S===3&&u(1),p(),p(),u(1),c())for(a=S!==3?8:12,o=0;o<a;o++)c()&&(o<6?g(16):g(64))}p();const b=d();if(b===0)d();else if(b===1)for(u(1),f(),f(),n=d(),o=0;o<n;o++)f();p(),u(1);const A=d(),T=d(),y=h(1);y===0&&u(1),u(1),c()&&(t=d(),e=d(),i=d(),s=d());let E=[1,1];if(c()&&c())switch(l()){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:{E=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((A+1)*16-t*2-e*2),height:(2-y)*(T+1)*16-(y?2:4)*(i+s),pixelRatio:E}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Um{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new aa(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,i){const s=t[e].unit;if(s.length<=16)return;const n=s.subarray(16,s.length-s.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{const l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,i)})}decryptAacSamples(t,e,i){for(;;e++){if(e>=t.length){i();return}if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(t){const e=Math.floor((t.length-48)/160)*16+16,i=new Int8Array(e);let s=0;for(let n=32;n<t.length-16;n+=160,s+=16)i.set(t.subarray(n,n+16),s);return i}getAvcDecryptedUnit(t,e){const i=new Uint8Array(e);let s=0;for(let n=32;n<t.length-16;n+=160,s+=16)t.set(i.subarray(s,s+16),n);return t}decryptAvcSample(t,e,i,s,n){const a=fh(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(t,e,i+1,s)})}decryptAvcSamples(t,e,i,s){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length){s();return}const n=t[e].units;for(;!(i>=n.length);i++){const a=n[i];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(t,e,i,s,a),!this.decrypter.isSync()))return}}}}const Nt=188;class Fe{constructor(t,e,i){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=i}static probe(t){const e=Fe.syncOffset(t);return e>0&&R.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),e!==-1}static syncOffset(t){const e=t.length;let i=Math.min(Nt*5,t.length-Nt)+1,s=0;for(;s<i;){let n=!1,a=-1,o=0;for(let l=s;l<e;l+=Nt)if(t[l]===71){if(o++,a===-1&&(a=l,a!==0&&(i=Math.min(a+Nt*99,t.length-Nt)+1)),n||(n=da(t,l)===0),n&&o>1&&(a===0&&o>2||l+Nt>i))return a}else{if(o)return-1;break}s++}return-1}static createTrack(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:ah[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}}resetInitSegment(t,e,i,s){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Fe.createTrack("video"),this._audioTrack=Fe.createTrack("audio",s),this._id3Track=Fe.createTrack("id3"),this._txtTrack=Fe.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=i,this._duration=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_avcTrack:e,_id3Track:i}=this;t&&(t.pesData=null),e&&(e.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(t,e,i=!1,s=!1){i||(this.sampleAes=null);let n;const a=this._avcTrack,o=this._audioTrack,l=this._id3Track,h=this._txtTrack;let d=a.pid,c=a.pesData,u=o.pid,f=l.pid,p=o.pesData,g=l.pesData,m=null,b=this.pmtParsed,A=this._pmtId,T=t.length;if(this.remainderData&&(t=ai(this.remainderData,t),T=t.length,this.remainderData=null),T<Nt&&!s)return this.remainderData=t,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:h};const y=Math.max(0,Fe.syncOffset(t));T-=(T-y)%Nt,T<t.byteLength&&!s&&(this.remainderData=new Uint8Array(t.buffer,T,t.buffer.byteLength-T));let E=0;for(let L=y;L<T;L+=Nt)if(t[L]===71){const D=!!(t[L+1]&64),k=da(t,L),x=(t[L+3]&48)>>4;let F;if(x>1){if(F=L+5+t[L+4],F===L+Nt)continue}else F=L+4;switch(k){case d:D&&(c&&(n=xi(c))&&this.parseAVCPES(a,h,n,!1),c={data:[],size:0}),c&&(c.data.push(t.subarray(F,L+Nt)),c.size+=L+Nt-F);break;case u:if(D){if(p&&(n=xi(p)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break}p={data:[],size:0}}p&&(p.data.push(t.subarray(F,L+Nt)),p.size+=L+Nt-F);break;case f:D&&(g&&(n=xi(g))&&this.parseID3PES(l,n),g={data:[],size:0}),g&&(g.data.push(t.subarray(F,L+Nt)),g.size+=L+Nt-F);break;case 0:D&&(F+=t[F]+1),A=this._pmtId=Bm(t,F);break;case A:{D&&(F+=t[F]+1);const O=Hm(t,F,this.typeSupported,i);d=O.avc,d>0&&(a.pid=d),u=O.audio,u>0&&(o.pid=u,o.segmentCodec=O.segmentCodec),f=O.id3,f>0&&(l.pid=f),m!==null&&!b&&(R.warn(`MPEG-TS PMT found at ${L} after unknown PID '${m}'. Backtracking to sync byte @${y} to parse all TS packets.`),m=null,L=y-188),b=this.pmtParsed=!0;break}case 17:case 8191:break;default:m=k;break}}else E++;if(E>0){const L=new Error(`Found ${E} TS packet/s that do not start with 0x47`);this.observer.emit(v.ERROR,v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,fatal:!1,error:L,reason:L.message})}a.pesData=c,o.pesData=p,l.pesData=g;const S={audioTrack:o,videoTrack:a,id3Track:l,textTrack:h};return s&&this.extractRemainingSamples(S),S}flush(){const{remainderData:t}=this;this.remainderData=null;let e;return t?e=this.demux(t,-1,!1,!0):e={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(t){const{audioTrack:e,videoTrack:i,id3Track:s,textTrack:n}=t,a=i.pesData,o=e.pesData,l=s.pesData;let h;if(a&&(h=xi(a))?(this.parseAVCPES(i,n,h,!0),i.pesData=null):i.pesData=a,o&&(h=xi(o))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,h);break;case"mp3":this.parseMPEGPES(e,h);break}e.pesData=null}else o!=null&&o.size&&R.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=o;l&&(h=xi(l))?(this.parseID3PES(s,h),s.pesData=null):s.pesData=l}demuxSampleAes(t,e,i){const s=this.demux(t,i,!0,!this.config.progressive),n=this.sampleAes=new Um(this.observer,this.config,e);return this.decrypt(s,n)}decrypt(t,e){return new Promise(i=>{const{audioTrack:s,videoTrack:n}=t;s.samples&&s.segmentCodec==="aac"?e.decryptAacSamples(s.samples,0,()=>{n.samples?e.decryptAvcSamples(n.samples,0,0,()=>{i(t)}):i(t)}):n.samples&&e.decryptAvcSamples(n.samples,0,0,()=>{i(t)})})}destroy(){this._duration=0}parseAVCPES(t,e,i,s){const n=this.parseAVCNALu(t,i.data);let a=this.avcSample,o,l=!1;i.data=null,a&&n.length&&!t.audFound&&(As(a,t),a=this.avcSample=yr(!1,i.pts,i.dts,"")),n.forEach(h=>{var d;switch(h.type){case 1:{let u=!1;o=!0;const f=h.data;if(l&&f.length>4){const p=new ed(f).readSliceType();(p===2||p===4||p===7||p===9)&&(u=!0)}if(u){var c;(c=a)!=null&&c.frame&&!a.key&&(As(a,t),a=this.avcSample=null)}a||(a=this.avcSample=yr(!0,i.pts,i.dts,"")),a.frame=!0,a.key=u;break}case 5:o=!0,(d=a)!=null&&d.frame&&!a.key&&(As(a,t),a=this.avcSample=null),a||(a=this.avcSample=yr(!0,i.pts,i.dts,"")),a.key=!0,a.frame=!0;break;case 6:{o=!0,uh(h.data,1,i.pts,e.samples);break}case 7:if(o=!0,l=!0,!t.sps){const u=h.data,f=new ed(u).readSPS();t.width=f.width,t.height=f.height,t.pixelRatio=f.pixelRatio,t.sps=[u],t.duration=this._duration;const p=u.subarray(1,4);let g="avc1.";for(let m=0;m<3;m++){let b=p[m].toString(16);b.length<2&&(b="0"+b),g+=b}t.codec=g}break;case 8:o=!0,t.pps||(t.pps=[h.data]);break;case 9:o=!1,t.audFound=!0,a&&As(a,t),a=this.avcSample=yr(!1,i.pts,i.dts,"");break;case 12:o=!0;break;default:o=!1,a&&(a.debug+="unknown NAL "+h.type+" ");break}a&&o&&a.units.push(h)}),s&&a&&(As(a,t),this.avcSample=null)}getLastNalUnit(t){var e;let i=this.avcSample,s;if((!i||i.units.length===0)&&(i=t[t.length-1]),(e=i)!=null&&e.units){const n=i.units;s=n[n.length-1]}return s}parseAVCNALu(t,e){const i=e.byteLength;let s=t.naluState||0;const n=s,a=[];let o=0,l,h,d,c=-1,u=0;for(s===-1&&(c=0,u=e[0]&31,s=0,o=1);o<i;){if(l=e[o++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(c>=0){const f={data:e.subarray(c,o-s-1),type:u};a.push(f)}else{const f=this.getLastNalUnit(t.samples);if(f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),h=o-s-1,h>0)){const p=new Uint8Array(f.data.byteLength+h);p.set(f.data,0),p.set(e.subarray(0,h),f.data.byteLength),f.data=p,f.state=0}}o<i?(d=e[o]&31,c=o,u=d,s=0):s=-1}else s=0}if(c>=0&&s>=0){const f={data:e.subarray(c,i),type:u,state:s};a.push(f)}if(a.length===0){const f=this.getLastNalUnit(t.samples);if(f){const p=new Uint8Array(f.data.byteLength+e.byteLength);p.set(f.data,0),p.set(e,f.data.byteLength),f.data=p}}return t.naluState=s,a}parseAACPES(t,e){let i=0;const s=this.aacOverFlow;let n=e.data;if(s){this.aacOverFlow=null;const c=s.missing,u=s.sample.unit.byteLength;if(c===-1){const f=new Uint8Array(u+n.byteLength);f.set(s.sample.unit,0),f.set(n,u),n=f}else{const f=u-c;s.sample.unit.set(n.subarray(0,c),f),t.samples.push(s.sample),i=s.missing}}let a,o;for(a=i,o=n.length;a<o-1&&!mr(n,a);a++);if(a!==i){let c;const u=a<o-1;u?c=`AAC PES did not start with ADTS header,offset:${a}`:c="No ADTS header found in AAC PES";const f=new Error(c);if(R.warn(`parsing error: ${c}`),this.observer.emit(v.ERROR,v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,fatal:!1,levelRetry:u,error:f,reason:c}),!u)return}Zh(t,this.observer,n,a,this.audioCodec);let l;if(e.pts!==void 0)l=e.pts;else if(s){const c=Jh(t.samplerate);l=s.sample.pts+c}else{R.warn("[tsdemuxer]: AAC PES unknown PTS");return}let h=0,d;for(;a<o;)if(d=Qh(t,n,a,l,h),a+=d.length,d.missing){this.aacOverFlow=d;break}else for(h++;a<o-1&&!mr(n,a);a++);}parseMPEGPES(t,e){const i=e.data,s=i.length;let n=0,a=0;const o=e.pts;if(o===void 0){R.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(td(i,a)){const l=_h(t,i,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseID3PES(t,e){if(e.pts===void 0){R.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=Et({},e,{type:this._avcTrack?le.emsg:le.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function yr(r,t,e,i){return{key:r,frame:!1,pts:t,dts:e,units:[],debug:i,length:0}}function da(r,t){return((r[t+1]&31)<<8)+r[t+2]}function Bm(r,t){return(r[t+10]&31)<<8|r[t+11]}function Hm(r,t,e,i){const s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=(r[t+1]&15)<<8|r[t+2],a=t+3+n-4,o=(r[t+10]&15)<<8|r[t+11];for(t+=12+o;t<a;){const l=da(r,t);switch(r[t]){case 207:if(!i){R.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:s.audio===-1&&(s.audio=l);break;case 21:s.id3===-1&&(s.id3=l);break;case 219:if(!i){R.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:s.avc===-1&&(s.avc=l);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?R.log("MPEG audio found, not supported in this browser"):s.audio===-1&&(s.audio=l,s.segmentCodec="mp3");break;case 36:R.warn("Unsupported HEVC stream type found");break}t+=((r[t+3]&15)<<8|r[t+4])+5}return s}function xi(r){let t=0,e,i,s,n,a;const o=r.data;if(!r||r.size===0)return null;for(;o[0].length<19&&o.length>1;){const l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(e=o[0],(e[0]<<16)+(e[1]<<8)+e[2]===1){if(i=(e[4]<<8)+e[5],i&&i>r.size-6)return null;const l=e[7];l&192&&(n=(e[9]&14)*536870912+(e[10]&255)*4194304+(e[11]&254)*16384+(e[12]&255)*128+(e[13]&254)/2,l&64?(a=(e[14]&14)*536870912+(e[15]&255)*4194304+(e[16]&254)*16384+(e[17]&255)*128+(e[18]&254)/2,n-a>54e5&&(R.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=e[8];let h=s+9;if(r.size<=h)return null;r.size-=h;const d=new Uint8Array(r.size);for(let c=0,u=o.length;c<u;c++){e=o[c];let f=e.byteLength;if(h)if(h>f){h-=f;continue}else e=e.subarray(h),f-=h,h=0;d.set(e,t),t+=f}return i&&(i-=s+3),{data:d,pts:n,dts:a,len:i}}return null}function As(r,t){if(r.units.length&&r.frame){if(r.pts===void 0){const e=t.samples,i=e.length;if(i){const s=e[i-1];r.pts=s.pts,r.dts=s.dts}else{t.dropped++;return}}t.samples.push(r)}r.debug.length&&R.log(r.pts+"/"+r.dts+":"+r.debug)}class Gm extends Yh{resetInitSegment(t,e,i,s){super.resetInitSegment(t,e,i,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:s,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(nr(t,0)||[]).length;for(let i=t.length;e<i;e++)if(Nm(t,e))return R.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return Fm(t,e)}appendFrame(t,e,i){if(this.basePTS!==null)return _h(t,e,i,this.basePTS,this.frameIndex)}}class id{static getSilentFrame(t,e){switch(t){case"mp4a.40.2":if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===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(e===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(e===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(e===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(e===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}}}const Ne=Math.pow(2,32)-1;class C{static init(){C.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let t;for(t in C.types)C.types.hasOwnProperty(t)&&(C.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const e=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]);C.HDLR_TYPES={video:e,audio:i};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);C.STTS=C.STSC=C.STCO=n,C.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),C.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),C.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),C.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);C.FTYP=C.box(C.types.ftyp,a,l,a,o),C.DINF=C.box(C.types.dinf,C.box(C.types.dref,s))}static box(t,...e){let i=8,s=e.length;const n=s;for(;s--;)i+=e[s].byteLength;const 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(t,4),s=0,i=8;s<n;s++)a.set(e[s],i),i+=e[s].byteLength;return a}static hdlr(t){return C.box(C.types.hdlr,C.HDLR_TYPES[t])}static mdat(t){return C.box(C.types.mdat,t)}static mdhd(t,e){e*=t;const i=Math.floor(e/(Ne+1)),s=Math.floor(e%(Ne+1));return C.box(C.types.mdhd,new Uint8Array([1,0,0,0,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,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(t){return C.box(C.types.mdia,C.mdhd(t.timescale,t.duration),C.hdlr(t.type),C.minf(t))}static mfhd(t){return C.box(C.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]))}static minf(t){return t.type==="audio"?C.box(C.types.minf,C.box(C.types.smhd,C.SMHD),C.DINF,C.stbl(t)):C.box(C.types.minf,C.box(C.types.vmhd,C.VMHD),C.DINF,C.stbl(t))}static moof(t,e,i){return C.box(C.types.moof,C.mfhd(t),C.traf(i,e))}static moov(t){let e=t.length;const i=[];for(;e--;)i[e]=C.trak(t[e]);return C.box.apply(null,[C.types.moov,C.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(C.mvex(t)))}static mvex(t){let e=t.length;const i=[];for(;e--;)i[e]=C.trex(t[e]);return C.box.apply(null,[C.types.mvex,...i])}static mvhd(t,e){e*=t;const i=Math.floor(e/(Ne+1)),s=Math.floor(e%(Ne+1)),n=new Uint8Array([1,0,0,0,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,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return C.box(C.types.mvhd,n)}static sdtp(t){const e=t.samples||[],i=new Uint8Array(4+e.length);let s,n;for(s=0;s<e.length;s++)n=e[s].flags,i[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return C.box(C.types.sdtp,i)}static stbl(t){return C.box(C.types.stbl,C.stsd(t),C.box(C.types.stts,C.STTS),C.box(C.types.stsc,C.STSC),C.box(C.types.stsz,C.STSZ),C.box(C.types.stco,C.STCO))}static avc1(t){let e=[],i=[],s,n,a;for(s=0;s<t.sps.length;s++)n=t.sps[s],a=n.byteLength,e.push(a>>>8&255),e.push(a&255),e=e.concat(Array.prototype.slice.call(n));for(s=0;s<t.pps.length;s++)n=t.pps[s],a=n.byteLength,i.push(a>>>8&255),i.push(a&255),i=i.concat(Array.prototype.slice.call(n));const o=C.box(C.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|t.sps.length].concat(e).concat([t.pps.length]).concat(i))),l=t.width,h=t.height,d=t.pixelRatio[0],c=t.pixelRatio[1];return C.box(C.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,h>>8&255,h&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,C.box(C.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),C.box(C.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,d&255,c>>24,c>>16&255,c>>8&255,c&255])))}static esds(t){const e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))}static mp4a(t){const e=t.samplerate;return C.box(C.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]),C.box(C.types.esds,C.esds(t)))}static mp3(t){const e=t.samplerate;return C.box(C.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]))}static stsd(t){return t.type==="audio"?t.segmentCodec==="mp3"&&t.codec==="mp3"?C.box(C.types.stsd,C.STSD,C.mp3(t)):C.box(C.types.stsd,C.STSD,C.mp4a(t)):C.box(C.types.stsd,C.STSD,C.avc1(t))}static tkhd(t){const e=t.id,i=t.duration*t.timescale,s=t.width,n=t.height,a=Math.floor(i/(Ne+1)),o=Math.floor(i%(Ne+1));return C.box(C.types.tkhd,new Uint8Array([1,0,0,7,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,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(t,e){const i=C.sdtp(t),s=t.id,n=Math.floor(e/(Ne+1)),a=Math.floor(e%(Ne+1));return C.box(C.types.traf,C.box(C.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),C.box(C.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])),C.trun(t,i.length+16+20+8+16+8+8),i)}static trak(t){return t.duration=t.duration||4294967295,C.box(C.types.trak,C.tkhd(t),C.mdia(t))}static trex(t){const e=t.id;return C.box(C.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){const i=t.samples||[],s=i.length,n=12+16*s,a=new Uint8Array(n);let o,l,h,d,c,u;for(e+=8+n,a.set([t.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),o=0;o<s;o++)l=i[o],h=l.duration,d=l.size,c=l.flags,u=l.cts,a.set([h>>>24&255,h>>>16&255,h>>>8&255,h&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,c.degradPrio&61440,c.degradPrio&15,u>>>24&255,u>>>16&255,u>>>8&255,u&255],12+16*o);return C.box(C.types.trun,a)}static initSegment(t){C.types||C.init();const e=C.moov(t),i=new Uint8Array(C.FTYP.byteLength+e.byteLength);return i.set(C.FTYP),i.set(e,C.FTYP.byteLength),i}}C.types=void 0,C.HDLR_TYPES=void 0,C.STTS=void 0,C.STSC=void 0,C.STCO=void 0,C.STSZ=void 0,C.VMHD=void 0,C.SMHD=void 0,C.STSD=void 0,C.FTYP=void 0,C.DINF=void 0;const sd=9e4;function ca(r,t,e=1,i=!1){const s=r*t*e;return i?Math.round(s):s}function Vm(r,t,e=1,i=!1){return ca(r,t,1/e,i)}function Ts(r,t=!1){return ca(r,1e3,1/sd,t)}function jm(r,t=1){return ca(r,sd,1/t)}const zm=10*1e3,rd=1024,Km=1152;let br=null,ua=null;class fa{constructor(t,e,i,s=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=i,this.ISGenerated=!1,br===null){const n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);br=n?parseInt(n[1]):0}if(ua===null){const n=navigator.userAgent.match(/Safari\/(\d+)/i);ua=n?parseInt(n[1]):0}}destroy(){}resetTimeStamp(t){R.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){R.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){R.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const i=t.reduce((s,n)=>{const a=n.pts-s;return a<-4294967296?(e=!0,te(s,n.pts)):a>0?s:n.pts},t[0].pts);return e&&R.debug("PTS rollover detected"),i}remux(t,e,i,s,n,a,o,l){let h,d,c,u,f,p,g=n,m=n;const b=t.pid>-1,A=e.pid>-1,T=e.samples.length,y=t.samples.length>0,E=o&&T>0||T>1;if((!b||y)&&(!A||E)||this.ISGenerated||o){this.ISGenerated||(c=this.generateIS(t,e,n,a));const S=this.isVideoContiguous;let L=-1,D;if(E&&(L=Wm(e.samples),!S&&this.config.forceKeyFrameOnDiscontinuity))if(p=!0,L>0){R.warn(`[mp4-remuxer]: Dropped ${L} out of ${T} video samples due to a missing keyframe`);const k=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(L),e.dropped+=L,m+=(e.samples[0].pts-k)/e.inputTimeScale,D=m}else L===-1&&(R.warn(`[mp4-remuxer]: No keyframe found out of ${T} video samples`),p=!1);if(this.ISGenerated){if(y&&E){const k=this.getVideoStartPts(e.samples),x=(te(t.samples[0].pts,k)-k)/e.inputTimeScale;g+=Math.max(0,x),m+=Math.max(0,-x)}if(y){if(t.samplerate||(R.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(t,e,n,a)),d=this.remuxAudio(t,g,this.isAudioContiguous,a,A||E||l===X.AUDIO?m:void 0),E){const k=d?d.endPTS-d.startPTS:0;e.inputTimeScale||(R.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(t,e,n,a)),h=this.remuxVideo(e,m,S,k)}}else E&&(h=this.remuxVideo(e,m,S,0));h&&(h.firstKeyFrame=L,h.independent=L!==-1,h.firstKeyFramePTS=D)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(f=nd(i,n,this._initPTS,this._initDTS)),s.samples.length&&(u=ad(s,n,this._initPTS))),{audio:d,video:h,initSegment:c,independent:p,text:u,id3:f}}generateIS(t,e,i,s){const n=t.samples,a=e.samples,o=this.typeSupported,l={},h=this._initPTS;let d=!h||s,c="audio/mp4",u,f,p;if(d&&(u=f=1/0),t.config&&n.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":o.mpeg?(c="audio/mpeg",t.codec=""):o.mp3&&(t.codec="mp3");break}l.audio={id:"audio",container:c,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):C.initSegment([t]),metadata:{channelCount:t.channelCount}},d&&(p=t.inputTimeScale,!h||p!==h.timescale?u=f=n[0].pts-Math.round(p*i):d=!1)}if(e.sps&&e.pps&&a.length&&(e.timescale=e.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:C.initSegment([e]),metadata:{width:e.width,height:e.height}},d))if(p=e.inputTimeScale,!h||p!==h.timescale){const g=this.getVideoStartPts(a),m=Math.round(p*i);f=Math.min(f,te(a[0].dts,g)-m),u=Math.min(u,g-m)}else d=!1;if(Object.keys(l).length)return this.ISGenerated=!0,d?(this._initPTS={baseTime:u,timescale:p},this._initDTS={baseTime:f,timescale:p}):u=p=void 0,{tracks:l,initPTS:u,timescale:p}}remuxVideo(t,e,i,s){const n=t.inputTimeScale,a=t.samples,o=[],l=a.length,h=this._initPTS;let d=this.nextAvcDts,c=8,u=this.videoSampleDuration,f,p,g=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,b=!1;if(!i||d===null){const U=e*n,H=a[0].pts-te(a[0].dts,a[0].pts);d=U-H}const A=h.baseTime*n/h.timescale;for(let U=0;U<l;U++){const H=a[U];H.pts=te(H.pts-A,d),H.dts=te(H.dts-A,d),H.dts<a[U>0?U-1:U].dts&&(b=!0)}b&&a.sort(function(U,H){const V=U.dts-H.dts,J=U.pts-H.pts;return V||J}),f=a[0].dts,p=a[a.length-1].dts;const T=p-f,y=T?Math.round(T/(l-1)):u||t.inputTimeScale/30;if(i){const U=f-d,H=U>y,V=U<-1;if((H||V)&&(H?R.warn(`AVC: ${Ts(U,!0)} ms (${U}dts) hole between fragments detected, filling it`):R.warn(`AVC: ${Ts(-U,!0)} ms (${U}dts) overlapping between fragments detected`),!V||d>=a[0].pts)){f=d;const J=a[0].pts-U;a[0].dts=f,a[0].pts=J,R.log(`Video: First PTS/DTS adjusted: ${Ts(J,!0)}/${Ts(f,!0)}, delta: ${Ts(U,!0)} ms`)}}f=Math.max(0,f);let E=0,S=0;for(let U=0;U<l;U++){const H=a[U],V=H.units,J=V.length;let $=0;for(let Q=0;Q<J;Q++)$+=V[Q].data.length;S+=$,E+=J,H.length=$,H.dts=Math.max(H.dts,f),g=Math.min(H.pts,g),m=Math.max(H.pts,m)}p=a[l-1].dts;const L=S+4*E+8;let D;try{D=new Uint8Array(L)}catch(U){this.observer.emit(v.ERROR,v.ERROR,{type:Y.MUX_ERROR,details:P.REMUX_ALLOC_ERROR,fatal:!1,error:U,bytes:L,reason:`fail allocating video mdat ${L}`});return}const k=new DataView(D.buffer);k.setUint32(0,L),D.set(C.types.mdat,4);let x=!1,F=Number.POSITIVE_INFINITY,O=Number.POSITIVE_INFINITY,G=Number.NEGATIVE_INFINITY,W=Number.NEGATIVE_INFINITY;for(let U=0;U<l;U++){const H=a[U],V=H.units;let J=0;for(let rt=0,tt=V.length;rt<tt;rt++){const Pt=V[rt],St=Pt.data,yt=Pt.data.byteLength;k.setUint32(c,yt),c+=4,D.set(St,c),c+=yt,J+=4+yt}let $;if(U<l-1)u=a[U+1].dts-H.dts,$=a[U+1].pts-H.pts;else{const rt=this.config,tt=U>0?H.dts-a[U-1].dts:y;if($=U>0?H.pts-a[U-1].pts:y,rt.stretchShortVideoTrack&&this.nextAudioPts!==null){const Pt=Math.floor(rt.maxBufferHole*n),St=(s?g+s*n:this.nextAudioPts)-H.pts;St>Pt?(u=St-tt,u<0?u=tt:x=!0,R.log(`[mp4-remuxer]: It is approximately ${St/90} ms to the next segment; using duration ${u/90} ms for the last video frame.`)):u=tt}else u=tt}const Q=Math.round(H.pts-H.dts);F=Math.min(F,u),G=Math.max(G,u),O=Math.min(O,$),W=Math.max(W,$),o.push(new od(H.key,u,J,Q))}if(o.length){if(br){if(br<70){const U=o[0].flags;U.dependsOn=2,U.isNonSync=0}}else if(ua&&W-O<G-F&&y/G<.025&&o[0].cts===0){R.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let U=f;for(let H=0,V=o.length;H<V;H++){const J=U+o[H].duration,$=U+o[H].cts;if(H<V-1){const Q=J+o[H+1].cts;o[H].duration=Q-$}else o[H].duration=H?o[H-1].duration:y;o[H].cts=0,U=J}}}u=x||!u?y:u,this.nextAvcDts=d=p+u,this.videoSampleDuration=u,this.isVideoContiguous=!0;const w=C.moof(t.sequenceNumber++,f,Et({},t,{samples:o})),I="video",B={data1:w,data2:D,startPTS:g/n,endPTS:(m+u)/n,startDTS:f/n,endDTS:d/n,type:I,hasAudio:!1,hasVideo:!0,nb:o.length,dropped:t.dropped};return t.samples=[],t.dropped=0,B}remuxAudio(t,e,i,s,n){const a=t.inputTimeScale,o=t.samplerate?t.samplerate:a,l=a/o,h=t.segmentCodec==="aac"?rd:Km,d=h*l,c=this._initPTS,u=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],p=n!==void 0;let g=t.samples,m=u?0:8,b=this.nextAudioPts||-1;const A=e*a,T=c.baseTime*a/c.timescale;if(this.isAudioContiguous=i=i||g.length&&b>0&&(s&&Math.abs(A-b)<9e3||Math.abs(te(g[0].pts-T,A)-b)<20*d),g.forEach(function(w){w.pts=te(w.pts-T,A)}),!i||b<0){if(g=g.filter(w=>w.pts>=0),!g.length)return;n===0?b=0:s&&!p?b=Math.max(0,A):b=g[0].pts}if(t.segmentCodec==="aac"){const w=this.config.maxAudioFramesDrift;for(let I=0,B=b;I<g.length;I++){const U=g[I],H=U.pts,V=H-B,J=Math.abs(1e3*V/a);if(V<=-w*d&&p)I===0&&(R.warn(`Audio frame @ ${(H/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*V/a)} ms.`),this.nextAudioPts=b=B=H);else if(V>=w*d&&J<zm&&p){let $=Math.round(V/d);B=H-$*d,B<0&&($--,B+=d),I===0&&(this.nextAudioPts=b=B),R.warn(`[mp4-remuxer]: Injecting ${$} audio frame @ ${(B/a).toFixed(3)}s due to ${Math.round(1e3*V/a)} ms gap.`);for(let Q=0;Q<$;Q++){const rt=Math.max(B,0);let tt=id.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);tt||(R.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),tt=U.unit.subarray()),g.splice(I,0,{unit:tt,pts:rt}),B+=d,I++}}U.pts=B,B+=d}}let y=null,E=null,S,L=0,D=g.length;for(;D--;)L+=g[D].unit.byteLength;for(let w=0,I=g.length;w<I;w++){const B=g[w],U=B.unit;let H=B.pts;if(E!==null){const J=f[w-1];J.duration=Math.round((H-E)/l)}else if(i&&t.segmentCodec==="aac"&&(H=b),y=H,L>0){L+=m;try{S=new Uint8Array(L)}catch(J){this.observer.emit(v.ERROR,v.ERROR,{type:Y.MUX_ERROR,details:P.REMUX_ALLOC_ERROR,fatal:!1,error:J,bytes:L,reason:`fail allocating audio mdat ${L}`});return}u||(new DataView(S.buffer).setUint32(0,L),S.set(C.types.mdat,4))}else return;S.set(U,m);const V=U.byteLength;m+=V,f.push(new od(!0,h,V,0)),E=H}const k=f.length;if(!k)return;const x=f[f.length-1];this.nextAudioPts=b=E+l*x.duration;const F=u?new Uint8Array(0):C.moof(t.sequenceNumber++,y/l,Et({},t,{samples:f}));t.samples=[];const O=y/a,G=b/a,W={data1:F,data2:S,startPTS:O,endPTS:G,startDTS:O,endDTS:G,type:"audio",hasAudio:!0,hasVideo:!1,nb:k};return this.isAudioContiguous=!0,W}remuxEmptyAudio(t,e,i,s){const n=t.inputTimeScale,a=t.samplerate?t.samplerate:n,o=n/a,l=this.nextAudioPts,h=this._initDTS,d=h.baseTime*9e4/h.timescale,c=(l!==null?l:s.startDTS*n)+d,u=s.endDTS*n+d,f=o*rd,p=Math.ceil((u-c)/f),g=id.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(R.warn("[mp4-remuxer]: remux empty Audio"),!g){R.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const m=[];for(let b=0;b<p;b++){const A=c+b*f;m.push({unit:g,pts:A,dts:A})}return t.samples=m,this.remuxAudio(t,e,i,!1)}}function te(r,t){let e;if(t===null)return r;for(t<r?e=-8589934592:e=8589934592;Math.abs(r-t)>4294967296;)r+=e;return r}function Wm(r){for(let t=0;t<r.length;t++)if(r[t].key)return t;return-1}function nd(r,t,e,i){const s=r.samples.length;if(!s)return;const n=r.inputTimeScale;for(let o=0;o<s;o++){const l=r.samples[o];l.pts=te(l.pts-e.baseTime*n/e.timescale,t*n)/n,l.dts=te(l.dts-i.baseTime*n/i.timescale,t*n)/n}const a=r.samples;return r.samples=[],{samples:a}}function ad(r,t,e){const i=r.samples.length;if(!i)return;const s=r.inputTimeScale;for(let a=0;a<i;a++){const o=r.samples[a];o.pts=te(o.pts-e.baseTime*s/e.timescale,t*s)/s}r.samples.sort((a,o)=>a.pts-o.pts);const n=r.samples;return r.samples=[],{samples:n}}class od{constructor(t,e,i,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=i,this.cts=s,this.flags=new Ym(t)}}class Ym{constructor(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}}class Xm{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,i,s){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(fg(t,s)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:i}=this;if(!(t!=null&&t.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const s=this.initData=hh(t);e||(e=ld(s.audio,at.AUDIO)),i||(i=ld(s.video,at.VIDEO));const n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:s.video?n.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:R.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(t,e,i,s,n,a){var o,l;let{initPTS:h,lastEndTime:d}=this;const c={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};K(d)||(d=this.lastEndTime=n||0);const u=e.samples;if(!(u!=null&&u.length))return c;const f={initPTS:void 0,timescale:1};let p=this.initData;if((o=p)!=null&&o.length||(this.generateInitSegment(u),p=this.initData),!((l=p)!=null&&l.length))return R.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const g=gg(u,p),m=pg(p,u),b=m===null?n:m;(qm(h,b,n,g)||f.timescale!==h.timescale&&a)&&(f.initPTS=b-n,h&&h.timescale===1&&R.warn(`Adjusting initPTS by ${f.initPTS-h.baseTime}`),this.initPTS=h={baseTime:f.initPTS,timescale:1});const A=t?b-h.baseTime/h.timescale:d,T=A+g;vg(p,u,h.baseTime/h.timescale),g>0?this.lastEndTime=T:(R.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const y=!!p.audio,E=!!p.video;let S="";y&&(S+="audio"),E&&(S+="video");const L={data1:u,startPTS:A,startDTS:A,endPTS:T,endDTS:T,type:S,hasAudio:y,hasVideo:E,nb:1,dropped:0};return c.audio=L.type==="audio"?L:void 0,c.video=L.type!=="audio"?L:void 0,c.initSegment=f,c.id3=nd(i,n,h,h),s.samples.length&&(c.text=ad(s,n,h)),c}}function qm(r,t,e,i){if(r===null)return!0;const s=Math.max(i,1),n=t-r.baseTime/r.timescale;return Math.abs(n-e)>s}function ld(r,t){const e=r==null?void 0:r.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||t===at.VIDEO?"avc1.42e01e":"mp4a.40.5"}let xe;try{xe=self.performance.now.bind(self.performance)}catch{R.debug("Unable to use Performance API on this environment"),xe=typeof self<"u"&&self.Date.now}const pa=[{demux:Cm,remux:Xm},{demux:Fe,remux:fa},{demux:km,remux:fa},{demux:Gm,remux:fa}];class hd{constructor(t,e,i,s,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=i,this.vendor=s,this.id=n}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,i,s){const n=i.transmuxing;n.executeStart=xe();let a=new Uint8Array(t);const{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);const{contiguous:h,discontinuity:d,trackSwitch:c,accurateTimeOffset:u,timeOffset:f,initSegmentChange:p}=s||o,{audioCodec:g,videoCodec:m,defaultInitPts:b,duration:A,initSegmentData:T}=l,y=Zm(a,e);if(y&&y.method==="AES-128"){const D=this.getDecrypter();if(D.isSync()){let k=D.softwareDecrypt(a,y.key.buffer,y.iv.buffer);if(i.part>-1&&(k=D.flush()),!k)return n.executeEnd=xe(),ga(i);a=new Uint8Array(k)}else return this.decryptionPromise=D.webCryptoDecrypt(a,y.key.buffer,y.iv.buffer).then(k=>{const x=this.push(k,null,i);return this.decryptionPromise=null,x}),this.decryptionPromise}const E=this.needsProbing(d,c);if(E){const D=this.configureTransmuxer(a);if(D)return R.warn(`[transmuxer] ${D.message}`),this.observer.emit(v.ERROR,v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,fatal:!1,error:D,reason:D.message}),n.executeEnd=xe(),ga(i)}(d||c||p||E)&&this.resetInitSegment(T,g,m,A,e),(d||p||E)&&this.resetInitialTimestamp(b),h||this.resetContiguity();const S=this.transmux(a,y,f,u,i),L=this.currentTransmuxState;return L.contiguous=!0,L.discontinuity=!1,L.trackSwitch=!1,n.executeEnd=xe(),S}flush(t){const e=t.transmuxing;e.executeStart=xe();const{decrypter:i,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(t));const a=[],{timeOffset:o}=s;if(i){const c=i.flush();c&&a.push(this.push(c,null,t))}const{demuxer:l,remuxer:h}=this;if(!l||!h)return e.executeEnd=xe(),[ga(t)];const d=l.flush(o);return Ar(d)?d.then(c=>(this.flushRemux(a,c,t),a)):(this.flushRemux(a,d,t),a)}flushRemux(t,e,i){const{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=e,{accurateTimeOffset:l,timeOffset:h}=this.currentTransmuxState;R.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const d=this.remuxer.remux(s,n,a,o,h,l,!0,this.id);t.push({remuxResult:d,chunkMeta:i}),i.transmuxing.executeEnd=xe()}resetInitialTimestamp(t){const{demuxer:e,remuxer:i}=this;!e||!i||(e.resetTimeStamp(t),i.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;!t||!e||(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,i,s,n){const{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(t,e,i,s),o.resetInitSegment(t,e,i,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,i,s,n){let a;return e&&e.method==="SAMPLE-AES"?a=this.transmuxSampleAes(t,e,i,s,n):a=this.transmuxUnencrypted(t,i,s,n),a}transmuxUnencrypted(t,e,i,s){const{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,e,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(t,e,i,s,n){return this.demuxer.demuxSampleAes(t,e,i).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,i,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(t){const{config:e,observer:i,typeSupported:s,vendor:n}=this;let a;for(let c=0,u=pa.length;c<u;c++)if(pa[c].demux.probe(t)){a=pa[c];break}if(!a)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,l=this.remuxer,h=a.remux,d=a.demux;(!l||!(l instanceof h))&&(this.remuxer=new h(i,e,s,n)),(!o||!(o instanceof d))&&(this.demuxer=new d(i,e,s),this.probe=d.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new aa(this.config)),t}}function Zm(r,t){let e=null;return r.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(e=t),e}const ga=r=>({remuxResult:{},chunkMeta:r});function Ar(r){return"then"in r&&r.then instanceof Function}class Jm{constructor(t,e,i,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=i,this.duration=s,this.defaultInitPts=n||null}}class Qm{constructor(t,e,i,s,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=i,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}}var dd={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(l,h,d){this.fn=l,this.context=h,this.once=d||!1}function n(l,h,d,c,u){if(typeof d!="function")throw new TypeError("The listener must be a function");var f=new s(d,c||l,u),p=e?e+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,l._eventsCount++),l}function a(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],h,d;if(this._eventsCount===0)return l;for(d in h=this._events)t.call(h,d)&&l.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(h)):l},o.prototype.listeners=function(l){var h=e?e+l:l,d=this._events[h];if(!d)return[];if(d.fn)return[d.fn];for(var c=0,u=d.length,f=new Array(u);c<u;c++)f[c]=d[c].fn;return f},o.prototype.listenerCount=function(l){var h=e?e+l:l,d=this._events[h];return d?d.fn?1:d.length:0},o.prototype.emit=function(l,h,d,c,u,f){var p=e?e+l:l;if(!this._events[p])return!1;var g=this._events[p],m=arguments.length,b,A;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),m){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,h),!0;case 3:return g.fn.call(g.context,h,d),!0;case 4:return g.fn.call(g.context,h,d,c),!0;case 5:return g.fn.call(g.context,h,d,c,u),!0;case 6:return g.fn.call(g.context,h,d,c,u,f),!0}for(A=1,b=new Array(m-1);A<m;A++)b[A-1]=arguments[A];g.fn.apply(g.context,b)}else{var T=g.length,y;for(A=0;A<T;A++)switch(g[A].once&&this.removeListener(l,g[A].fn,void 0,!0),m){case 1:g[A].fn.call(g[A].context);break;case 2:g[A].fn.call(g[A].context,h);break;case 3:g[A].fn.call(g[A].context,h,d);break;case 4:g[A].fn.call(g[A].context,h,d,c);break;default:if(!b)for(y=1,b=new Array(m-1);y<m;y++)b[y-1]=arguments[y];g[A].fn.apply(g[A].context,b)}}return!0},o.prototype.on=function(l,h,d){return n(this,l,h,d,!1)},o.prototype.once=function(l,h,d){return n(this,l,h,d,!0)},o.prototype.removeListener=function(l,h,d,c){var u=e?e+l:l;if(!this._events[u])return this;if(!h)return a(this,u),this;var f=this._events[u];if(f.fn)f.fn===h&&(!c||f.once)&&(!d||f.context===d)&&a(this,u);else{for(var p=0,g=[],m=f.length;p<m;p++)(f[p].fn!==h||c&&!f[p].once||d&&f[p].context!==d)&&g.push(f[p]);g.length?this._events[u]=g.length===1?g[0]:g:a(this,u)}return this},o.prototype.removeAllListeners=function(l){var h;return l?(h=e?e+l:l,this._events[h]&&a(this,h)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,r.exports=o})(dd);var _m=dd.exports,ma=Up(_m);const va=hr()||{isTypeSupported:()=>!1};class cd{constructor(t,e,i,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const n=t.config;this.hls=t,this.id=e,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const a=(h,d)=>{d=d||{},d.frag=this.frag,d.id=this.id,h===v.ERROR&&(this.error=d.error),this.hls.trigger(h,d)};this.observer=new ma,this.observer.on(v.FRAG_DECRYPTED,a),this.observer.on(v.ERROR,a);const o={mp4:va.isTypeSupported("video/mp4"),mpeg:va.isTypeSupported("audio/mpeg"),mp3:va.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(n.workerPath||bm())){try{n.workerPath?(R.log(`loading Web Worker ${n.workerPath} for "${e}"`),this.workerContext=Tm(n.workerPath)):(R.log(`injecting Web Worker for "${e}"`),this.workerContext=Am()),this.onwmsg=d=>this.onWorkerMessage(d);const{worker:h}=this.workerContext;h.addEventListener("message",this.onwmsg),h.onerror=d=>{const c=new Error(`${d.message} (${d.filename}:${d.lineno})`);n.enableWorker=!1,R.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(v.ERROR,{type:Y.OTHER_ERROR,details:P.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:c})},h.postMessage({cmd:"init",typeSupported:o,vendor:l,id:e,config:JSON.stringify(n)})}catch(h){R.warn(`Error setting up "${e}" Web Worker, fallback to inline`,h),this.resetWorker(),this.error=null,this.transmuxer=new hd(this.observer,o,n,l,e)}return}this.transmuxer=new hd(this.observer,o,n,l,e)}resetWorker(){if(this.workerContext){const{worker:t,objectURL:e}=this.workerContext;e&&self.URL.revokeObjectURL(e),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,i,s,n,a,o,l,h,d){var c,u;h.transmuxing.start=self.performance.now();const{transmuxer:f}=this,p=a?a.start:n.start,g=n.decryptdata,m=this.frag,b=!(m&&n.cc===m.cc),A=!(m&&h.level===m.level),T=m?h.sn-m.sn:-1,y=this.part?h.part-this.part.index:-1,E=T===0&&h.id>1&&h.id===(m==null?void 0:m.stats.chunkCount),S=!A&&(T===1||T===0&&(y===1||E&&y<=0)),L=self.performance.now();(A||T||n.stats.parsing.start===0)&&(n.stats.parsing.start=L),a&&(y||!S)&&(a.stats.parsing.start=L);const D=!(m&&((c=n.initSegment)==null?void 0:c.url)===((u=m.initSegment)==null?void 0:u.url)),k=new Qm(b,S,l,A,p,D);if(!S||b||D){R.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${h.sn} p: ${h.part} level: ${h.level} id: ${h.id}
|
164
|
+
discontinuity: ${b}
|
165
|
+
trackSwitch: ${A}
|
166
|
+
contiguous: ${S}
|
167
|
+
accurateTimeOffset: ${l}
|
168
|
+
timeOffset: ${p}
|
169
|
+
initSegmentChange: ${D}`);const x=new Jm(i,s,e,o,d);this.configureTransmuxer(x)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:g,chunkMeta:h,state:k},t instanceof ArrayBuffer?[t]:[]);else if(f){const x=f.push(t,g,h,k);Ar(x)?(f.async=!0,x.then(F=>{this.handleTransmuxComplete(F)}).catch(F=>{this.transmuxerError(F,h,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(x))}}flush(t){t.transmuxing.start=self.performance.now();const{transmuxer:e}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(e){let i=e.flush(t);Ar(i)||e.async?(Ar(i)||(i=Promise.resolve(i)),i.then(s=>{this.handleFlushResult(s,t)}).catch(s=>{this.transmuxerError(s,t,"transmuxer-interface flush error")})):this.handleFlushResult(i,t)}}transmuxerError(t,e,i){this.hls&&(this.error=t,this.hls.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:i}))}handleFlushResult(t,e){t.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(e)}onWorkerMessage(t){const e=t.data,i=this.hls;switch(e.event){case"init":{var s;const n=(s=this.workerContext)==null?void 0:s.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(e.data);break}case"flush":{this.onFlush(e.data);break}case"workerLog":R[e.data.logType]&&R[e.data.logType](e.data.message);break;default:{e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,i.trigger(e.event,e.data);break}}}configureTransmuxer(t){const{transmuxer:e}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)}handleTransmuxComplete(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)}}const $m=250,ya=2,tv=.1,ev=.05;class iv{constructor(t,e,i,s){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=i,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:i,media:s,stalled:n}=this;if(s===null)return;const{currentTime:a,seeking:o}=s,l=this.seeking&&!o,h=!this.seeking&&o;if(this.seeking=o,a!==t){if(this.moved=!0,n!==null){if(this.stallReported){const b=self.performance.now()-n;R.warn(`playback not stuck anymore @${a}, after ${Math.round(b)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(h||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!lt.getBuffered(s).length)return;const d=lt.bufferInfo(s,a,0),c=d.len>0,u=d.nextStart||0;if(!c&&!u)return;if(o){const b=d.len>ya,A=!u||e&&e.start<=a||u-a>ya&&!this.fragmentTracker.getPartialFragment(a);if(b||A)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var f;const b=Math.max(u,d.start||0)-a,A=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,T=!(A==null||(f=A.details)==null)&&f.live?A.details.targetduration*2:ya,y=this.fragmentTracker.getPartialFragment(a);if(b>0&&(b<=T||y)){this._trySkipBufferHole(y);return}}const p=self.performance.now();if(n===null){this.stalled=p;return}const g=p-n;if(!o&&g>=$m&&(this._reportStall(d),!this.media))return;const m=lt.bufferInfo(s,a,i.maxBufferHole);this._tryFixBufferStall(m,g)}_tryFixBufferStall(t,e){const{config:i,fragmentTracker:s,media:n}=this;if(n===null)return;const a=n.currentTime,o=s.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(t.len>i.maxBufferHole||t.nextStart&&t.nextStart-a<i.maxBufferHole)&&e>i.highBufferWatchdogPeriod*1e3&&(R.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:i,stallReported:s}=this;if(!s&&i){this.stallReported=!0;const n=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(t)})`);R.warn(n.message),e.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:i,media:s}=this;if(s===null)return 0;const n=s.currentTime,a=lt.bufferInfo(s,n,0),o=n<a.start?a.start:a.nextStart;if(o){const l=a.len<=e.maxBufferHole,h=a.len>0&&a.len<1&&s.readyState<3,d=o-n;if(d>0&&(l||h)){if(d>e.maxBufferHole){const{fragmentTracker:u}=this;let f=!1;if(n===0){const p=u.getAppendedFrag(0,X.MAIN);p&&o<p.end&&(f=!0)}if(!f){const p=t||u.getAppendedFrag(n,X.MAIN);if(p){let g=!1,m=p.end;for(;m<o;){const b=u.getPartialFragment(m);if(b)m+=b.duration;else{g=!0;break}}if(g)return 0}}}const c=Math.max(o+ev,n+tv);if(R.warn(`skipping hole, adjusting currentTime from ${n} to ${c}`),this.moved=!0,this.stalled=null,s.currentTime=c,t&&!t.gap){const u=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${c}`);i.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:u,reason:u.message,frag:t})}return c}}return 0}_tryNudgeBuffer(){const{config:t,hls:e,media:i,nudgeRetry:s}=this;if(i===null)return;const n=i.currentTime;if(this.nudgeRetry++,s<t.nudgeMaxRetry){const a=n+(s+1)*t.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);R.warn(o.message),i.currentTime=a,e.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const a=new Error(`Playhead still not moving while enough data buffered @${n} after ${t.nudgeMaxRetry} nudges`);R.error(a.message),e.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}}const sv=100;class rv extends oa{constructor(t,e,i){super(t,e,i,"[stream-controller]",X.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.MANIFEST_PARSED,this.onManifestParsed,this),t.on(v.LEVEL_LOADING,this.onLevelLoading,this),t.on(v.LEVEL_LOADED,this.onLevelLoaded,this),t.on(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(v.ERROR,this.onError,this),t.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(v.BUFFER_CREATED,this.onBufferCreated,this),t.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.MANIFEST_PARSED,this.onManifestParsed,this),t.off(v.LEVEL_LOADED,this.onLevelLoaded,this),t.off(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(v.ERROR,this.onError,this),t.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(v.BUFFER_CREATED,this.onBufferCreated,this),t.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(t){if(this.levels){const{lastCurrentTime:e,hls:i}=this;if(this.stopLoad(),this.setInterval(sv),this.level=-1,!this.startFragRequested){let s=i.startLevel;s===-1&&(i.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=i.nextAutoLevel),this.level=i.nextLoadLevel=s,this.loadedmetadata=!1}e>0&&t===-1&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=N.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=N.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case N.WAITING_LEVEL:{var t;const{levels:i,level:s}=this,n=i==null||(t=i[s])==null?void 0:t.details;if(n&&(!n.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(n))break;this.state=N.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=N.IDLE;break}break}case N.FRAG_LOADING_WAITING_RETRY:{var e;const i=self.performance.now(),s=this.retryDate;(!s||i>=s||(e=this.media)!=null&&e.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=N.IDLE)}break}this.state===N.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:i,media:s}=this,{config:n,nextLoadLevel:a}=t;if(e===null||!s&&(this.startFragRequested||!n.startFragPrefetch)||this.altAudio&&this.audioOnly||!(i!=null&&i[a]))return;const o=i[a],l=this.getMainFwdBufferInfo();if(l===null)return;const h=this.getLevelDetails();if(h&&this._streamEnded(l,h)){const m={};this.altAudio&&(m.type="video"),this.hls.trigger(v.BUFFER_EOS,m),this.state=N.ENDED;return}t.loadLevel!==a&&t.manualLevel===-1&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=t.nextLoadLevel=a;const d=o.details;if(!d||this.state===N.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a){this.level=a,this.state=N.WAITING_LEVEL;return}const c=l.len,u=this.getMaxBufferLength(o.maxBitrate);if(c>=u)return;this.backtrackFragment&&this.backtrackFragment.start>l.end&&(this.backtrackFragment=null);const f=this.backtrackFragment?this.backtrackFragment.start:l.end;let p=this.getNextFragment(f,d);if(this.couldBacktrack&&!this.fragPrevious&&p&&p.sn!=="initSegment"&&this.fragmentTracker.getState(p)!==Lt.OK){var g;const m=((g=this.backtrackFragment)!=null?g:p).sn-d.startSN,b=d.fragments[m-1];b&&p.cc===b.cc&&(p=b,this.fragmentTracker.removeFragment(b))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,f)){if(!p.gap){const m=this.audioOnly&&!this.altAudio?at.AUDIO:at.VIDEO,b=(m===at.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;b&&this.afterBufferFlushed(b,m,X.MAIN)}p=this.getNextFragmentLoopLoading(p,d,l,X.MAIN,u)}p&&(p.initSegment&&!p.initSegment.data&&!this.bitrateTest&&(p=p.initSegment),this.loadFragment(p,o,f))}loadFragment(t,e,i){const s=this.fragmentTracker.getState(t);this.fragCurrent=t,s===Lt.NOT_LOADED||s===Lt.PARTIAL?t.sn==="initSegment"?this._loadInitSegment(t,e):this.bitrateTest?(this.log(`Fragment ${t.sn} of level ${t.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(t,e)):(this.startFragRequested=!0,super.loadFragment(t,e,i)):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,X.MAIN)}followingBufferedFrag(t){return t?this.getBufferedFrag(t.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:t,media:e}=this;if(e!=null&&e.readyState){let i;const s=this.getAppendedFrag(e.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);const n=this.getLevelDetails();if(n!=null&&n.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!e.paused&&t){const o=this.hls.nextLoadLevel,l=t[o],h=this.fragLastKbps;h&&this.fragCurrent?i=this.fragCurrent.duration*l.maxBitrate/(1e3*h)+1:i=0}else i=0;const a=this.getBufferedFrag(e.currentTime+i);if(a){const o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();const l=o.maxStartPTS?o.maxStartPTS:o.start,h=o.duration,d=Math.max(a.end,l+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*.5),h*.75));this.flushMainBuffer(d,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case N.KEY_LOADING:case N.FRAG_LOADING:case N.FRAG_LOADING_WAITING_RETRY:case N.PARSING:case N.PARSED:this.state=N.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,e){super.flushMainBuffer(t,e,this.altAudio?"video":null)}onMediaAttached(t,e){super.onMediaAttached(t,e);const i=e.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new iv(this.config,i,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:t}=this;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const t=this.media,e=t?t.currentTime:null;K(e)&&this.log(`Media seeked to ${e.toFixed(3)}`);const i=this.getMainFwdBufferInfo();if(i===null||i.len===0){this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(v.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(t,e){let i=!1,s=!1,n;e.levels.forEach(a=>{n=a.audioCodec,n&&(n.indexOf("mp4a.40.2")!==-1&&(i=!0),n.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=i&&s&&!ym(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1}onLevelLoading(t,e){const{levels:i}=this;if(!i||this.state!==N.IDLE)return;const s=i[e.level];(!s.details||s.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(s.details))&&(this.state=N.WAITING_LEVEL)}onLevelLoaded(t,e){var i;const{levels:s}=this,n=e.level,a=e.details,o=a.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=s[n],h=this.fragCurrent;h&&(this.state===N.FRAG_LOADING||this.state===N.FRAG_LOADING_WAITING_RETRY)&&(h.level!==e.level||h.urlId!==l.urlId)&&h.loader&&this.abortCurrentFrag();let d=0;if(a.live||(i=l.details)!=null&&i.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;d=this.alignPlaylists(a,l.details)}if(l.details=a,this.levelLastLoaded=n,this.hls.trigger(v.LEVEL_UPDATED,{details:a,level:n}),this.state===N.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=N.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,d),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:s,payload:n}=t,{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}const o=a[i.level],l=o.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const h=o.videoCodec,d=l.PTSKnown||!l.live,c=(e=i.initSegment)==null?void 0:e.data,u=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new cd(this.hls,X.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),p=s?s.index:-1,g=p!==-1,m=new ra(i.level,i.sn,i.stats.chunkCount,n.byteLength,p,g),b=this.initPTS[i.cc];f.push(n,c,u,h,i,s,l.totalduration,d,m,b)}onAudioTrackSwitching(t,e){const i=this.altAudio;if(!e.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const n=this.fragCurrent;n&&(this.log("Switching to main audio track, cancel main fragment load"),n.abortRequests(),this.fragmentTracker.removeFragment(n)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const s=this.hls;i&&(s.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),s.trigger(v.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const i=e.id,s=!!this.hls.audioTracks[i].url;if(s){const n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=s,this.tick()}onBufferCreated(t,e){const i=e.tracks;let s,n,a=!1;for(const o in i){const l=i[o];if(l.id==="main"){if(n=o,s=l,o==="video"){const h=i[o];h&&(this.videoBuffer=h.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:i,part:s}=e;if(i&&i.type!==X.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===N.PARSED&&(this.state=N.IDLE);return}const n=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}onError(t,e){var i;if(e.fatal){this.state=N.ERROR;return}switch(e.details){case P.FRAG_GAP:case P.FRAG_PARSING_ERROR:case P.FRAG_DECRYPT_ERROR:case P.FRAG_LOAD_ERROR:case P.FRAG_LOAD_TIMEOUT:case P.KEY_LOAD_ERROR:case P.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(X.MAIN,e);break;case P.LEVEL_LOAD_ERROR:case P.LEVEL_LOAD_TIMEOUT:case P.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===N.WAITING_LEVEL&&((i=e.context)==null?void 0:i.type)===st.LEVEL&&(this.state=N.IDLE);break;case P.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="main")return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case P.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}checkBuffer(){const{media:t,gapController:e}=this;if(!(!t||!e||!t.readyState)){if(this.loadedmetadata||!lt.getBuffered(t).length){const i=this.state!==N.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=N.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==at.AUDIO||this.audioOnly&&!this.altAudio){const i=(e===at.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,e,X.MAIN)}}onLevelsUpdated(t,e){this.levels=e.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:t}=this;if(!t)return;const e=t.currentTime;let i=this.startPosition;if(i>=0&&e<i){if(t.seeking){this.log(`could not seek to ${i}, already seeking at ${e}`);return}const s=lt.getBuffered(t),n=(s.length?s.start(0):0)-i;n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${n} to match buffer start`),i+=n,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${e}`),t.currentTime=i}}_getAudioCodec(t){let e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e.indexOf("mp4a.40.5")!==-1?e="mp4a.40.2":e="mp4a.40.5"),e}_loadBitrateTestFrag(t,e){t.bitrateTest=!0,this._doFragLoad(t,e).then(i=>{const{hls:s}=this;if(!i||this.fragContextChanged(t))return;e.fragmentError=0,this.state=N.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const n=t.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(v.FRAG_LOADED,i),t.bitrateTest=!1})}_handleTransmuxComplete(t){var e;const i="main",{hls:s}=this,{remuxResult:n,chunkMeta:a}=t,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:h,level:d}=o,{video:c,text:u,id3:f,initSegment:p}=n,{details:g}=d,m=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,p){if(p!=null&&p.tracks){const T=l.initSegment||l;this._bufferInitSegment(d,p.tracks,T,a),s.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:i,tracks:p.tracks})}const b=p.initPTS,A=p.timescale;K(b)&&(this.initPTS[l.cc]={baseTime:b,timescale:A},s.trigger(v.INIT_PTS_FOUND,{frag:l,id:i,initPTS:b,timescale:A}))}if(c&&g&&l.sn!=="initSegment"){const b=g.fragments[l.sn-1-g.startSN],A=l.sn===g.startSN,T=!b||l.cc>b.cc;if(n.independent!==!1){const{startPTS:y,endPTS:E,startDTS:S,endDTS:L}=c;if(h)h.elementaryStreams[c.type]={startPTS:y,endPTS:E,startDTS:S,endDTS:L};else if(c.firstKeyFrame&&c.independent&&a.id===1&&!T&&(this.couldBacktrack=!0),c.dropped&&c.independent){const D=this.getMainFwdBufferInfo(),k=(D?D.end:this.getLoadPosition())+this.config.maxBufferHole,x=c.firstKeyFramePTS?c.firstKeyFramePTS:y;if(!A&&k<x-this.config.maxBufferHole&&!T){this.backtrack(l);return}else T&&(l.gap=!0);l.setElementaryStreamInfo(c.type,l.start,E,l.start,L,!0)}l.setElementaryStreamInfo(c.type,y,E,S,L),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(c,l,h,a,A||T)}else if(A||T)l.gap=!0;else{this.backtrack(l);return}}if(m){const{startPTS:b,endPTS:A,startDTS:T,endDTS:y}=m;h&&(h.elementaryStreams[at.AUDIO]={startPTS:b,endPTS:A,startDTS:T,endDTS:y}),l.setElementaryStreamInfo(at.AUDIO,b,A,T,y),this.bufferFragmentData(m,l,h,a)}if(g&&f!=null&&(e=f.samples)!=null&&e.length){const b={id:i,frag:l,details:g,samples:f.samples};s.trigger(v.FRAG_PARSING_METADATA,b)}if(g&&u){const b={id:i,frag:l,details:g,samples:u.samples};s.trigger(v.FRAG_PARSING_USERDATA,b)}}_bufferInitSegment(t,e,i,s){if(this.state!==N.PARSING)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;const{audio:n,video:a,audiovideo:o}=e;if(n){let l=t.audioCodec;const h=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),n.metadata.channelCount!==1&&h.indexOf("firefox")===-1&&(l="mp4a.40.5")),h.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),t.audioCodec&&t.audioCodec!==l&&this.log(`Swapping manifest audio codec "${t.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${t.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=t.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${t.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${t.attrs.CODECS||""}/${o.codec}]`),this.hls.trigger(v.BUFFER_CODECS,e),Object.keys(e).forEach(l=>{const h=e[l].initSegment;h!=null&&h.byteLength&&this.hls.trigger(v.BUFFER_APPENDING,{type:l,data:h,frag:i,part:null,chunkMeta:s,parent:i.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,X.MAIN)}backtrack(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=N.IDLE}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&t.seeking===!1){const i=t.currentTime;if(lt.isBuffered(t,i)?e=this.getAppendedFrag(i):lt.isBuffered(t,i+.1)&&(e=this.getAppendedFrag(i+.1)),e){this.backtrackFragment=null;const s=this.fragPlaying,n=e.level;(!s||e.sn!==s.sn||s.level!==n||e.urlId!==s.urlId)&&(this.fragPlaying=e,this.hls.trigger(v.FRAG_CHANGED,{frag:e}),(!s||s.level!==n)&&this.hls.trigger(v.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const t=this.nextBufferedFrag;return t?t.level:-1}get currentFrag(){const t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}get currentProgramDateTime(){const t=this.media;if(t){const e=t.currentTime,i=this.currentFrag;if(i&&K(e)&&K(i.programDateTime)){const s=i.programDateTime+(e-i.start)*1e3;return new Date(s)}}return null}get currentLevel(){const t=this.currentFrag;return t?t.level:-1}get nextBufferedFrag(){const t=this.currentFrag;return t?this.followingBufferedFrag(t):null}get forceStartLoad(){return this._forceStartLoad}}class ki{constructor(t,e=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=i}sample(t,e){const i=Math.pow(this.alpha_,t);this.estimate_=e*(1-i)+i*this.estimate_,this.totalWeight_+=t}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_}}class nv{constructor(t,e,i,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new ki(t),this.fast_=new ki(e),this.defaultTTFB_=s,this.ttfb_=new ki(t)}update(t,e){const{slow_:i,fast_:s,ttfb_:n}=this;i.halfLife!==t&&(this.slow_=new ki(t,i.getEstimate(),i.getTotalWeight())),s.halfLife!==e&&(this.fast_=new ki(e,s.getEstimate(),s.getTotalWeight())),n.halfLife!==t&&(this.ttfb_=new ki(t,n.getEstimate(),n.getTotalWeight()))}sample(t,e){t=Math.max(t,this.minDelayMs_);const i=8*e,s=t/1e3,n=i/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(t){const e=t/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(i,Math.max(t,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}class av{constructor(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;const e=t.config;this.bwEstimator=new nv(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(v.FRAG_LOADING,this.onFragLoading,this),t.on(v.FRAG_LOADED,this.onFragLoaded,this),t.on(v.FRAG_BUFFERED,this.onFragBuffered,this),t.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(v.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:t}=this;t.off(v.FRAG_LOADING,this.onFragLoading,this),t.off(v.FRAG_LOADED,this.onFragLoaded,this),t.off(v.FRAG_BUFFERED,this.onFragBuffered,this),t.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(v.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(t,e){var i;const s=e.frag;this.ignoreFragment(s)||(this.fragCurrent=s,this.partCurrent=(i=e.part)!=null?i:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(t,e){this.clearTimer()}getTimeToLoadFrag(t,e,i,s){const n=t+i/e,a=s?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(t,e){const i=this.hls.config,{total:s,bwEstimate:n}=e.stats;K(s)&&K(n)&&(this.lastLevelLoadSec=8*s/n),e.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:t,partCurrent:e,hls:i}=this,{autoLevelEnabled:s,media:n}=i;if(!t||!n)return;const a=performance.now(),o=e?e.stats:t.stats,l=e?e.duration:t.duration,h=a-o.loading.start;if(o.aborted||o.loaded&&o.loaded===o.total||t.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!s||n.paused||!n.playbackRate||!n.readyState)return;const d=i.mainForwardBufferInfo;if(d===null)return;const c=this.bwEstimator.getEstimateTTFB(),u=Math.abs(n.playbackRate);if(h<=Math.max(c,1e3*(l/(u*2))))return;const f=d.len/u;if(f>=2*l/u)return;const p=o.loading.first?o.loading.first-o.loading.start:-1,g=o.loaded&&p>-1,m=this.bwEstimator.getEstimate(),{levels:b,minAutoLevel:A}=i,T=b[t.level],y=o.total||Math.max(o.loaded,Math.round(l*T.maxBitrate/8));let E=h-p;E<1&&g&&(E=Math.min(h,o.loaded*8/m));const S=g?o.loaded*1e3/E:0,L=S?(y-o.loaded)/S:y*8/m+c/1e3;if(L<=f)return;const D=S?S*8:m;let k=Number.POSITIVE_INFINITY,x;for(x=t.level-1;x>A;x--){const F=b[x].maxBitrate;if(k=this.getTimeToLoadFrag(c/1e3,D,l*F,!b[x].details),k<f)break}k>=L||k>l*10||(i.nextLoadLevel=x,g?this.bwEstimator.sample(h-Math.min(c,p),o.loaded):this.bwEstimator.sampleTTFB(h),this.clearTimer(),R.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;
|
170
|
+
Time to underbuffer: ${f.toFixed(3)} s
|
171
|
+
Estimated load time for current fragment: ${L.toFixed(3)} s
|
172
|
+
Estimated load time for down switch fragment: ${k.toFixed(3)} s
|
173
|
+
TTFB estimate: ${p}
|
174
|
+
Current BW estimate: ${K(m)?(m/1024).toFixed(3):"Unknown"} Kb/s
|
175
|
+
New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
|
176
|
+
Aborting and switching to level ${x}`),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),i.trigger(v.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:o}))}onFragLoaded(t,{frag:e,part:i}){const s=i?i.stats:e.stats;if(e.type===X.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(e)){if(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const n=i?i.duration:e.duration,a=this.hls.levels[e.level],o=(a.loaded?a.loaded.bytes:0)+s.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(e.bitrateTest){const n={stats:s,frag:e,part:i,id:e.type};this.onFragBuffered(v.FRAG_BUFFERED,n),e.bitrateTest=!1}}}onFragBuffered(t,e){const{frag:i,part:s}=e,n=s!=null&&s.stats.loaded?s.stats:i.stats;if(n.aborted||this.ignoreFragment(i))return;const 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.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==X.MAIN||t.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const t=this._nextAutoLevel,e=this.bwEstimator;if(t!==-1&&!e.canEstimate())return t;let i=this.getNextABRAutoLevel();if(t!==-1){const s=this.hls.levels;if(s.length>Math.max(t,i)&&s[t].loadError<=s[i].loadError)return t}return t!==-1&&(i=Math.min(t,i)),i}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:i}=this,{maxAutoLevel:s,config:n,minAutoLevel:a,media:o}=i,l=e?e.duration:t?t.duration:0,h=o&&o.playbackRate!==0?Math.abs(o.playbackRate):1,d=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,c=i.mainForwardBufferInfo,u=(c?c.len:0)/h;let f=this.findBestLevel(d,a,s,u,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(f>=0)return f;R.trace(`[abr] ${u?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let p=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay,g=n.abrBandWidthFactor,m=n.abrBandWidthUpFactor;if(!u){const b=this.bitrateTestDelay;b&&(p=(l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay)-b,R.trace(`[abr] bitrate test took ${Math.round(1e3*b)}ms, set first fragment max fetchDuration to ${Math.round(1e3*p)} ms`),g=m=1)}return f=this.findBestLevel(d,a,s,u+p,g,m),Math.max(f,0)}findBestLevel(t,e,i,s,n,a){var o;const{fragCurrent:l,partCurrent:h,lastLoadedFragLevel:d}=this,{levels:c}=this.hls,u=c[d],f=!!(u!=null&&(o=u.details)!=null&&o.live),p=u==null?void 0:u.codecSet,g=h?h.duration:l?l.duration:0,m=this.bwEstimator.getEstimateTTFB()/1e3;let b=e,A=-1;for(let T=i;T>=e;T--){const y=c[T];if(!y||p&&y.codecSet!==p){y&&(b=Math.min(T,b),A=Math.max(T,A));continue}A!==-1&&R.trace(`[abr] Skipped level(s) ${b}-${A} with CODECS:"${c[A].attrs.CODECS}"; not compatible with "${u.attrs.CODECS}"`);const E=y.details,S=(h?E==null?void 0:E.partTarget:E==null?void 0:E.averagetargetduration)||g;let L;T<=d?L=n*t:L=a*t;const D=c[T].maxBitrate,k=this.getTimeToLoadFrag(m,L,D*S,E===void 0);if(R.trace(`[abr] level:${T} adjustedbw-bitrate:${Math.round(L-D)} avgDuration:${S.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:${k.toFixed(1)}`),L>D&&(k===0||!K(k)||f&&!this.bitrateTestDelay||k<s))return T}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}}class ud{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:e}=this;let i;if(t.length)t.length===1?i=t[0]:i=ov(t,e);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function ov(r,t){const e=new Uint8Array(t);let i=0;for(let s=0;s<r.length;s++){const n=r[s];e.set(n,i),i+=n.length}return e}const fd=100;class lv extends oa{constructor(t,e,i){super(t,e,i,"[audio-stream-controller]",X.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:t}=this;t.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.LEVEL_LOADED,this.onLevelLoaded,this),t.on(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(v.ERROR,this.onError,this),t.on(v.BUFFER_RESET,this.onBufferReset,this),t.on(v.BUFFER_CREATED,this.onBufferCreated,this),t.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.LEVEL_LOADED,this.onLevelLoaded,this),t.off(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(v.ERROR,this.onError,this),t.off(v.BUFFER_RESET,this.onBufferReset,this),t.off(v.BUFFER_CREATED,this.onBufferCreated,this),t.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(t,{frag:e,id:i,initPTS:s,timescale:n}){if(i==="main"){const a=e.cc;this.initPTS[e.cc]={baseTime:s,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${s}`),this.videoTrackCC=a,this.state===N.WAITING_INIT_PTS&&this.tick()}}startLoad(t){if(!this.levels){this.startPosition=t,this.state=N.STOPPED;return}const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(fd),e>0&&t===-1?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=N.IDLE):(this.loadedmetadata=!1,this.state=N.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case N.IDLE:this.doTickIdle();break;case N.WAITING_TRACK:{var t;const{levels:i,trackId:s}=this,n=i==null||(t=i[s])==null?void 0:t.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=N.WAITING_INIT_PTS}break}case N.FRAG_LOADING_WAITING_RETRY:{var e;const i=performance.now(),s=this.retryDate;(!s||i>=s||(e=this.media)!=null&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=N.IDLE);break}case N.WAITING_INIT_PTS:{const i=this.waitingData;if(i){const{frag:s,part:n,cache:a,complete:o}=i;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.FRAG_LOADING;const l=a.flush(),h={frag:s,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(h),o&&super._handleFragmentLoadComplete(h)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const l=this.getLoadPosition(),h=lt.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);ea(h.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${h.end} is needed`),this.clearWaitingFragment())}}else this.state=N.IDLE}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:t}=this;t!=null&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){const{hls:t,levels:e,media:i,trackId:s}=this,n=t.config;if(!(e!=null&&e[s])||!i&&(this.startFragRequested||!n.startFragPrefetch))return;const a=e[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(o)){this.state=N.WAITING_TRACK;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,at.AUDIO,X.AUDIO));const h=this.getFwdBufferInfo(l,X.AUDIO);if(h===null)return;const{bufferedTrack:d,switchingTrack:c}=this;if(!c&&this._streamEnded(h,o)){t.trigger(v.BUFFER_EOS,{type:"audio"}),this.state=N.ENDED;return}const u=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,X.MAIN),f=h.len,p=this.getMaxBufferLength(u==null?void 0:u.len);if(f>=p&&!c)return;const g=o.fragments[0].start;let m=h.end;if(c&&i){const y=this.getLoadPosition();d&&c.attrs!==d.attrs&&(m=y),o.PTSKnown&&y<g&&(h.end>g||h.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=g+.05)}let b=this.getNextFragment(m,o),A=!1;if(b&&this.isLoopLoading(b,m)&&(A=!!b.gap,b=this.getNextFragmentLoopLoading(b,o,h,X.MAIN,p)),!b){this.bufferFlushed=!0;return}const T=u&&b.start>u.end+o.targetduration;if(T||!(u!=null&&u.len)&&h.len){const y=this.getAppendedFrag(b.start,X.MAIN);if(y===null||(A||(A=!!y.gap||!!T&&u.len===0),T&&!A||A&&h.nextStart&&h.nextStart<y.end))return}this.loadFragment(b,a,m)}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.min(Math.max(e,t),this.config.maxMaxBufferLength):e}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(t,{audioTracks:e}){this.resetTransmuxer(),this.levels=e.map(i=>new ys(i))}onAudioTrackSwitching(t,e){const i=!!e.url;this.trackId=e.id;const{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),i?this.setInterval(fd):this.resetTransmuxer(),i?(this.switchingTrack=e,this.state=N.IDLE):(this.switchingTrack=null,this.bufferedTrack=e,this.state=N.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(t,e){this.mainDetails=e.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(v.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,e){var i;if(this.mainDetails==null){this.cachedTrackLoadedData=e;return}const{levels:s}=this,{details:n,id:a}=e;if(!s){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const o=s[a];let l=0;if(n.live||(i=o.details)!=null&&i.live){this.checkLiveUpdate(n);const h=this.mainDetails;if(n.deltaUpdateFailed||!h)return;!o.details&&n.hasProgramDateTime&&h.hasProgramDateTime?(Kh(n,h),l=n.fragments[0].start):l=this.alignPlaylists(n,o.details)}o.details=n,this.levelLastLoaded=a,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(o.details,l),this.state===N.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=N.IDLE),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:s,payload:n}=t,{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}const h=l[o];if(!h){this.warn("Audio track is undefined on fragment load progress");return}const d=h.details;if(!d){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const c=a.defaultAudioCodec||h.audioCodec||"mp4a.40.2";let u=this.transmuxer;u||(u=this.transmuxer=new cd(this.hls,X.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const f=this.initPTS[i.cc],p=(e=i.initSegment)==null?void 0:e.data;if(f!==void 0){const g=s?s.index:-1,m=g!==-1,b=new ra(i.level,i.sn,i.stats.chunkCount,n.byteLength,g,m);u.push(n,p,c,"",i,s,d.totalduration,!1,b,f)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${d.startSN} ,${d.endSN}],track ${o}`);const{cache:g}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new ud,complete:!1};g.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=N.WAITING_INIT_PTS}}_handleFragmentLoadComplete(t){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){const i=e.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){const{frag:i,part:s}=e;if(i.type!==X.AUDIO){if(!this.loadedmetadata&&i.type===X.MAIN){const n=this.videoBuffer||this.media;n&<.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(i.sn!=="initSegment"){this.fragPrevious=i;const n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(v.AUDIO_TRACK_SWITCHED,jt({},n)))}this.fragBufferedComplete(i,s)}onError(t,e){var i;if(e.fatal){this.state=N.ERROR;return}switch(e.details){case P.FRAG_GAP:case P.FRAG_PARSING_ERROR:case P.FRAG_DECRYPT_ERROR:case P.FRAG_LOAD_ERROR:case P.FRAG_LOAD_TIMEOUT:case P.KEY_LOAD_ERROR:case P.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(X.AUDIO,e);break;case P.AUDIO_TRACK_LOAD_ERROR:case P.AUDIO_TRACK_LOAD_TIMEOUT:case P.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===N.WAITING_TRACK&&((i=e.context)==null?void 0:i.type)===st.AUDIO_TRACK&&(this.state=N.IDLE);break;case P.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="audio")return;this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case P.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}onBufferFlushed(t,{type:e}){e===at.AUDIO&&(this.bufferFlushed=!0,this.state===N.ENDED&&(this.state=N.IDLE))}_handleTransmuxComplete(t){var e;const i="audio",{hls:s}=this,{remuxResult:n,chunkMeta:a}=t,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:h,level:d}=o,{details:c}=d,{audio:u,text:f,id3:p,initSegment:g}=n;if(this.fragContextChanged(l)||!c){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),g!=null&&g.tracks){const m=l.initSegment||l;this._bufferInitSegment(g.tracks,m,a),s.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:m,id:i,tracks:g.tracks})}if(u){const{startPTS:m,endPTS:b,startDTS:A,endDTS:T}=u;h&&(h.elementaryStreams[at.AUDIO]={startPTS:m,endPTS:b,startDTS:A,endDTS:T}),l.setElementaryStreamInfo(at.AUDIO,m,b,A,T),this.bufferFragmentData(u,l,h,a)}if(p!=null&&(e=p.samples)!=null&&e.length){const m=Et({id:i,frag:l,details:c},p);s.trigger(v.FRAG_PARSING_METADATA,m)}if(f){const m=Et({id:i,frag:l,details:c},f);s.trigger(v.FRAG_PARSING_USERDATA,m)}}_bufferInitSegment(t,e,i){if(this.state!==N.PARSING)return;t.video&&delete t.video;const s=t.audio;if(!s)return;s.levelCodec=s.codec,s.id="audio",this.log(`Init audio buffer, container:${s.container}, codecs[parsed]=[${s.codec}]`),this.hls.trigger(v.BUFFER_CODECS,t);const n=s.initSegment;if(n!=null&&n.byteLength){const a={type:"audio",frag:e,part:null,chunkMeta:i,parent:e.type,data:n};this.hls.trigger(v.BUFFER_APPENDING,a)}this.tick()}loadFragment(t,e,i){const s=this.fragmentTracker.getState(t);if(this.fragCurrent=t,this.switchingTrack||s===Lt.NOT_LOADED||s===Lt.PARTIAL){var n;t.sn==="initSegment"?this._loadInitSegment(t,e):(n=e.details)!=null&&n.live&&!this.initPTS[t.cc]?(this.log(`Waiting for video PTS in continuity counter ${t.cc} of live stream before loading audio fragment ${t.sn} of level ${this.trackId}`),this.state=N.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(t,e,i))}else this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){const{hls:e,media:i,bufferedTrack:s}=this,n=s==null?void 0:s.attrs,a=t.attrs;i&&n&&(n.CHANNELS!==a.CHANNELS||n.NAME!==a.NAME||n.LANGUAGE!==a.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(v.AUDIO_TRACK_SWITCHED,jt({},t))}}class hv extends ia{constructor(t){super(t,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.MANIFEST_PARSED,this.onManifestParsed,this),t.on(v.LEVEL_LOADING,this.onLevelLoading,this),t.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.MANIFEST_PARSED,this.onManifestParsed,this),t.off(v.LEVEL_LOADING,this.onLevelLoading,this),t.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(v.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){const{id:i,groupId:s,details:n}=e,a=this.tracksInGroup[i];if(!a||a.groupId!==s){this.warn(`Track with id:${i} and group:${s} not found in active group ${a.groupId}`);return}const o=a.details;a.details=e.details,this.log(`audio-track ${i} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,o)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!(e!=null&&e.audioGroupIds))return;const i=e.audioGroupIds[e.urlId];if(this.groupId!==i){this.groupId=i||null;const s=this.tracks.filter(a=>!i||a.groupId===i);this.selectDefaultTrack&&!s.some(a=>a.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=s;const n={audioTracks:s};this.log(`Updating audio tracks, ${s.length} track(s) found in group:${i}`),this.hls.trigger(v.AUDIO_TRACKS_UPDATED,n),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(t,e){e.fatal||!e.context||e.context.type===st.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(e))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioTrack(t){const e=this.tracksInGroup;if(t<0||t>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();const i=this.currentTrack;e[this.trackId];const s=e[t],{groupId:n,name:a}=s;if(this.log(`Switching to audio-track ${t} "${a}" lang:${s.lang} group:${n}`),this.trackId=t,this.currentTrack=s,this.selectDefaultTrack=!1,this.hls.trigger(v.AUDIO_TRACK_SWITCHING,jt({},s)),s.details&&!s.details.live)return;const o=this.switchParams(s.url,i==null?void 0:i.details);this.loadPlaylist(o)}selectInitialTrack(){const t=this.tracksInGroup,e=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(e!==-1)this.setAudioTrack(e);else{const i=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${t.length}`);this.warn(i.message),this.hls.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const s=e[i];if((!this.selectDefaultTrack||s.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]!==void 0&&t.attrs["STABLE-RENDITION-ID"]===s.attrs["STABLE-RENDITION-ID"]||t.name===s.name&&t.lang===s.lang))return s.id}return-1}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const i=e.id,s=e.groupId;let n=e.url;if(t)try{n=t.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${i} "${e.name}" lang:${e.lang} group:${s}`),this.clearTimer(),this.hls.trigger(v.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:t||null})}}}function pd(r,t){if(r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(!dv(r[e].attrs,t[e].attrs))return!1;return!0}function dv(r,t){const e=r["STABLE-RENDITION-ID"];return e?e===t["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>r[i]!==t[i])}const gd=500;class cv extends oa{constructor(t,e,i){super(t,e,i,"[subtitle-stream-controller]",X.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:t}=this;t.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.LEVEL_LOADED,this.onLevelLoaded,this),t.on(v.ERROR,this.onError,this),t.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.LEVEL_LOADED,this.onLevelLoaded,this),t.off(v.ERROR,this.onError,this),t.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=N.IDLE,this.setInterval(gd),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(t,e){this.mainDetails=e.details}onSubtitleFragProcessed(t,e){const{frag:i,success:s}=e;if(this.fragPrevious=i,this.state=N.IDLE,!s)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a;const o=i.start;for(let h=0;h<n.length;h++)if(o>=n[h].start&&o<=n[h].end){a=n[h];break}const l=i.start+i.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(i)}onBufferFlushing(t,e){const{startOffset:i,endOffset:s}=e;if(i===0&&s!==Number.POSITIVE_INFINITY){const n=s-1;if(n<=0)return;e.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,X.SUBTITLE)}}onFragBuffered(t,e){if(!this.loadedmetadata&&e.frag.type===X.MAIN){var i;(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)}}onError(t,e){const i=e.frag;(i==null?void 0:i.type)===X.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==N.STOPPED&&(this.state=N.IDLE))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){if(pd(this.levels,e)){this.levels=e.map(i=>new ys(i));return}this.tracksBuffered=[],this.levels=e.map(i=>{const s=new ys(i);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,X.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(t,e){if(this.currentTrackId=e.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}const i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(gd)}onSubtitleTrackLoaded(t,e){var i;const{details:s,id:n}=e,{currentTrackId:a,levels:o}=this;if(!o.length)return;const l=o[a];if(n>=o.length||n!==a||!l)return;this.mediaBuffer=this.mediaBufferTimeRanges;let h=0;if(s.live||(i=l.details)!=null&&i.live){const d=this.mainDetails;if(s.deltaUpdateFailed||!d)return;const c=d.fragments[0];l.details?(h=this.alignPlaylists(s,l.details),h===0&&c&&(h=c.start,$n(s,h))):s.hasProgramDateTime&&d.hasProgramDateTime?(Kh(s,d),h=s.fragments[0].start):c&&(h=c.start,$n(s,h))}l.details=s,this.levelLastLoaded=n,!this.startFragRequested&&(this.mainDetails||!s.live)&&this.setStartPosition(l.details,h),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===N.IDLE&&(bs(null,s.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0))}_handleFragmentLoadComplete(t){const{frag:e,payload:i}=t,s=e.decryptdata,n=this.hls;if(!this.fragContextChanged(e)&&i&&i.byteLength>0&&s&&s.key&&s.iv&&s.method==="AES-128"){const a=performance.now();this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:e}),o}).then(o=>{const l=performance.now();n.trigger(v.FRAG_DECRYPTED,{frag:e,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=N.IDLE})}}doTick(){if(!this.media){this.state=N.IDLE;return}if(this.state===N.IDLE){const{currentTrackId:t,levels:e}=this,i=e[t];if(!e.length||!i||!i.details)return;const{config:s}=this,n=this.getLoadPosition(),a=lt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,h=this.getFwdBufferInfo(this.media,X.MAIN),d=i.details,c=this.getMaxBufferLength(h==null?void 0:h.len)+d.levelTargetDuration;if(l>c)return;const u=d.fragments,f=u.length,p=d.edge;let g=null;const m=this.fragPrevious;if(o<p){const b=s.maxFragLookUpTolerance,A=o>p-b?0:b;g=bs(m,u,Math.max(u[0].start,o),A),!g&&m&&m.start<u[0].start&&(g=u[0])}else g=u[f-1];if(!g)return;if(g=this.mapToInitFragWhenRequired(g),g.sn!=="initSegment"){const b=g.sn-d.startSN,A=u[b-1];A&&A.cc===g.cc&&this.fragmentTracker.getState(A)===Lt.NOT_LOADED&&(g=A)}this.fragmentTracker.getState(g)===Lt.NOT_LOADED&&this.loadFragment(g,i,o)}}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.max(e,t):e}loadFragment(t,e,i){this.fragCurrent=t,t.sn==="initSegment"?this._loadInitSegment(t,e):(this.startFragRequested=!0,super.loadFragment(t,e,i))}get mediaBufferTimeRanges(){return new uv(this.tracksBuffered[this.currentTrackId]||[])}}class uv{constructor(t){this.buffered=void 0;const e=(i,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return t[s][i]};this.buffered={get length(){return t.length},end(i){return e("end",i,t.length)},start(i){return e("start",i,t.length)}}}}class fv extends ia{constructor(t){super(t,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:t}=this;t.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.MANIFEST_PARSED,this.onManifestParsed,this),t.on(v.LEVEL_LOADING,this.onLevelLoading,this),t.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.MANIFEST_PARSED,this.onManifestParsed,this),t.off(v.LEVEL_LOADING,this.onLevelLoading,this),t.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(v.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.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(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)}onMediaDetaching(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),ba(this.media.textTracks).forEach(t=>{Li(t)}),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){const{id:i,details:s}=e,{trackId:n}=this,a=this.tracksInGroup[n];if(!a){this.warn(`Invalid subtitle track id ${i}`);return}const o=a.details;a.details=e.details,this.log(`subtitle track ${i} loaded [${s.startSN}-${s.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,o)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!(e!=null&&e.textGroupIds))return;const i=e.textGroupIds[e.urlId],s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){const n=this.tracks.filter(l=>!i||l.groupId===i);this.tracksInGroup=n;const a=this.findTrackId(s==null?void 0:s.name)||this.findTrackId();this.groupId=i||null;const o={subtitleTracks:n};this.log(`Updating subtitle tracks, ${n.length} track(s) found in "${i}" group-id`),this.hls.trigger(v.SUBTITLE_TRACKS_UPDATED,o),a!==-1&&this.setSubtitleTrack(a,s)}else this.shouldReloadPlaylist(s)&&this.setSubtitleTrack(this.trackId,s)}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const s=e[i];if((!this.selectDefaultTrack||s.default)&&(!t||t===s.name))return s.id}return-1}onError(t,e){e.fatal||!e.context||e.context.type===st.SUBTITLE_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.checkRetry(e)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(t){this.selectDefaultTrack=!1;const e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const i=e.id,s=e.groupId;let n=e.url;if(t)try{n=t.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(v.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:t||null})}}toggleTrackModes(t){const{media:e,trackId:i}=this;if(!e)return;const s=ba(e.textTracks),n=s.filter(o=>o.groupId===this.groupId);if(t===-1)[].slice.call(s).forEach(o=>{o.mode="disabled"});else{const o=n[i];o&&(o.mode="disabled")}const a=n[t];a&&(a.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(t,e){var i;const s=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=t;return}if(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(t===-1||(i=s[t])!=null&&i.details)||t<-1||t>=s.length)return;this.clearTimer();const n=s[t];if(this.log(`Switching to subtitle-track ${t}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:"")),this.trackId=t,n){const{id:a,groupId:o="",name:l,type:h,url:d}=n;this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:h,url:d});const c=this.switchParams(n.url,e==null?void 0:e.details);this.loadPlaylist(c)}else this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:t})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=-1;const e=ba(this.media.textTracks);for(let i=0;i<e.length;i++)if(e[i].mode==="hidden")t=i;else if(e[i].mode==="showing"){t=i;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}}function ba(r){const t=[];for(let e=0;e<r.length;e++){const i=r[e];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&t.push(r[e])}return t}class pv{constructor(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}append(t,e){const i=this.queues[e];i.push(t),i.length===1&&this.buffers[e]&&this.executeNext(e)}insertAbort(t,e){this.queues[e].unshift(t),this.executeNext(e)}appendBlocker(t){let e;const i=new Promise(n=>{e=n}),s={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,t),i}executeNext(t){const{buffers:e,queues:i}=this,s=e[t],n=i[t];if(n.length){const a=n[0];try{a.execute()}catch(o){R.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),a.onError(o),s!=null&&s.updating||(n.shift(),this.executeNext(t))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const md=hr(),vd=/([ha]vc.)(?:\.[^.,]+)+/;class gv{constructor(t){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{const{media:e,mediaSource:i}=this;R.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(v.MEDIA_ATTACHED,{media:e})),i&&i.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{R.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{R.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:i}=this;e&&e.src!==i&&R.error(`Media element src was set while attaching MediaSource (${i} > ${e.src})`)},this.hls=t,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){const{hls:t}=this;t.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.MANIFEST_PARSED,this.onManifestParsed,this),t.on(v.BUFFER_RESET,this.onBufferReset,this),t.on(v.BUFFER_APPENDING,this.onBufferAppending,this),t.on(v.BUFFER_CODECS,this.onBufferCodecs,this),t.on(v.BUFFER_EOS,this.onBufferEos,this),t.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(v.FRAG_PARSED,this.onFragParsed,this),t.on(v.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:t}=this;t.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.MANIFEST_PARSED,this.onManifestParsed,this),t.off(v.BUFFER_RESET,this.onBufferReset,this),t.off(v.BUFFER_APPENDING,this.onBufferAppending,this),t.off(v.BUFFER_CODECS,this.onBufferCodecs,this),t.off(v.BUFFER_EOS,this.onBufferEos,this),t.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(v.FRAG_PARSED,this.onFragParsed,this),t.off(v.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new pv(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,e){let i=2;(e.audio&&!e.video||!e.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,R.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const i=this.media=e.media;if(i&&md){const s=this.mediaSource=new md;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(s),this._objectUrl=i.src,i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:i}=this;if(e){if(R.log("[buffer-controller]: media source detaching"),e.readyState==="open")try{e.endOfStream()}catch(s){R.warn(`[buffer-controller]: onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),i&&self.URL.revokeObjectURL(i),t.src===i?(t.removeAttribute("src"),t.load()):R.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(v.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(t=>{const e=this.sourceBuffer[t];try{e&&(this.removeBufferListeners(t),this.mediaSource&&this.mediaSource.removeSourceBuffer(e),this.sourceBuffer[t]=void 0)}catch(i){R.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,i)}}),this._initSourceBuffer()}onBufferCodecs(t,e){const i=this.getSourceBufferTypes().length;Object.keys(e).forEach(s=>{if(i){const n=this.tracks[s];if(n&&typeof n.buffer.changeType=="function"){const{id:a,codec:o,levelCodec:l,container:h,metadata:d}=e[s],c=(n.levelCodec||n.codec).replace(vd,"$1"),u=(l||o).replace(vd,"$1");if(c!==u){const f=`${h};codecs=${l||o}`;this.appendChangeType(s,f),R.log(`[buffer-controller]: switching codec ${c} to ${u}`),this.tracks[s]={buffer:n.buffer,codec:o,container:h,levelCodec:l,metadata:d,id:a}}}}else this.pendingTracks[s]=e[s]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(t,e){const{operationQueue:i}=this,s={execute:()=>{const n=this.sourceBuffer[t];n&&(R.log(`[buffer-controller]: changing ${t} sourceBuffer type to ${e}`),n.changeType(e)),i.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:n=>{R.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,n)}};i.append(s,t)}onBufferAppending(t,e){const{hls:i,operationQueue:s,tracks:n}=this,{data:a,type:o,frag:l,part:h,chunkMeta:d}=e,c=d.buffering[o],u=self.performance.now();c.start=u;const f=l.stats.buffering,p=h?h.stats.buffering:null;f.start===0&&(f.start=u),p&&p.start===0&&(p.start=u);const g=n.audio;let m=!1;o==="audio"&&(g==null?void 0:g.container)==="audio/mpeg"&&(m=!this.lastMpegAudioChunk||d.id===1||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);const b=l.start,A={execute:()=>{if(c.executeStart=self.performance.now(),m){const T=this.sourceBuffer[o];if(T){const y=b-T.timestampOffset;Math.abs(y)>=.1&&(R.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${b} (delta: ${y}) sn: ${l.sn})`),T.timestampOffset=b)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{const T=self.performance.now();c.executeEnd=c.end=T,f.first===0&&(f.first=T),p&&p.first===0&&(p.first=T);const{sourceBuffer:y}=this,E={};for(const S in y)E[S]=lt.getBuffered(y[S]);this.appendError=0,this.hls.trigger(v.BUFFER_APPENDED,{type:o,frag:l,part:h,chunkMeta:d,parent:l.type,timeRanges:E})},onError:T=>{R.error(`[buffer-controller]: Error encountered while trying to append to the ${o} SourceBuffer`,T);const y={type:Y.MEDIA_ERROR,parent:l.type,details:P.BUFFER_APPEND_ERROR,frag:l,part:h,chunkMeta:d,error:T,err:T,fatal:!1};T.code===DOMException.QUOTA_EXCEEDED_ERR?y.details=P.BUFFER_FULL_ERROR:(this.appendError++,y.details=P.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(R.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),y.fatal=!0)),i.trigger(v.ERROR,y)}};s.append(A,o)}onBufferFlushing(t,e){const{operationQueue:i}=this,s=n=>({execute:this.removeExecutor.bind(this,n,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(v.BUFFER_FLUSHED,{type:n})},onError:a=>{R.warn(`[buffer-controller]: Failed to remove from ${n} SourceBuffer`,a)}});e.type?i.append(s(e.type),e.type):this.getSourceBufferTypes().forEach(n=>{i.append(s(n),n)})}onFragParsed(t,e){const{frag:i,part:s}=e,n=[],a=s?s.elementaryStreams:i.elementaryStreams;a[at.AUDIOVIDEO]?n.push("audiovideo"):(a[at.AUDIO]&&n.push("audio"),a[at.VIDEO]&&n.push("video"));const o=()=>{const l=self.performance.now();i.stats.buffering.end=l,s&&(s.stats.buffering.end=l);const h=s?s.stats:i.stats;this.hls.trigger(v.FRAG_BUFFERED,{frag:i,part:s,stats:h,id:i.type})};n.length===0&&R.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(o,n)}onFragChanged(t,e){this.flushBackBuffer()}onBufferEos(t,e){this.getSourceBufferTypes().reduce((i,s)=>{const n=this.sourceBuffer[s];return n&&(!e.type||e.type===s)&&(n.ending=!0,n.ended||(n.ended=!0,R.log(`[buffer-controller]: ${s} sourceBuffer now EOS`))),i&&!!(!n||n.ended)},!0)&&(R.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(s=>{const n=this.sourceBuffer[s];n&&(n.ending=!1)});const{mediaSource:i}=this;if(!i||i.readyState!=="open"){i&&R.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${i.readyState}`);return}R.log("[buffer-controller]: Calling mediaSource.endOfStream()"),i.endOfStream()}))}onLevelUpdated(t,{details:e}){e.fragments.length&&(this.details=e,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:t,details:e,media:i,sourceBuffer:s}=this;if(!i||e===null)return;const n=this.getSourceBufferTypes();if(!n.length)return;const a=e.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(!K(a)||a<0)return;const o=i.currentTime,l=e.levelTargetDuration,h=Math.max(a,l),d=Math.floor(o/l)*l-h;n.forEach(c=>{const u=s[c];if(u){const f=lt.getBuffered(u);if(f.length>0&&d>f.start(0)){if(t.trigger(v.BACK_BUFFER_REACHED,{bufferEnd:d}),e.live)t.trigger(v.LIVE_BACK_BUFFER_REACHED,{bufferEnd:d});else if(u.ended&&f.end(f.length-1)-o<l*2){R.info(`[buffer-controller]: Cannot flush ${c} back buffer while SourceBuffer is in ended state`);return}t.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:d,type:c})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:t,hls:e,media:i,mediaSource:s}=this,n=t.fragments[0].start+t.totalduration,a=i.duration,o=K(s.duration)?s.duration:0;t.live&&e.config.liveDurationInfinity?(R.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(t)):(n>o&&n>a||!K(a))&&(R.log(`[buffer-controller]: Updating Media Source duration to ${n.toFixed(3)}`),s.duration=n)}updateSeekableRange(t){const e=this.mediaSource,i=t.fragments;if(i.length&&t.live&&e!=null&&e.setLiveSeekableRange){const s=Math.max(0,i[0].start),n=Math.max(s,s+t.totalduration);e.setLiveSeekableRange(s,n)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:i}=this,s=Object.keys(i).length;if(s&&!t||s===2){this.createSourceBuffers(i),this.pendingTracks={};const n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(v.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{e.executeNext(a)});else{const a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(t){const{sourceBuffer:e,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const s in t)if(!e[s]){const n=t[s];if(!n)throw Error(`source buffer exists for track ${s}, however track does not`);const a=n.levelCodec||n.codec,o=`${n.container};codecs=${a}`;R.log(`[buffer-controller]: creating sourceBuffer(${o})`);try{const l=e[s]=i.addSourceBuffer(o),h=s;this.addBufferListener(h,"updatestart",this._onSBUpdateStart),this.addBufferListener(h,"updateend",this._onSBUpdateEnd),this.addBufferListener(h,"error",this._onSBUpdateError),this.tracks[s]={buffer:l,codec:a,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(l){R.error(`[buffer-controller]: error while trying to add sourceBuffer: ${l.message}`),this.hls.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:o})}}}_onSBUpdateStart(t){const{operationQueue:e}=this;e.current(t).onStart()}_onSBUpdateEnd(t){const{operationQueue:e}=this;e.current(t).onComplete(),e.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){const i=new Error(`${t} SourceBuffer error`);R.error(`[buffer-controller]: ${i}`,e),this.hls.trigger(v.ERROR,{type:Y.MEDIA_ERROR,details:P.BUFFER_APPENDING_ERROR,error:i,fatal:!1});const s=this.operationQueue.current(t);s&&s.onError(e)}removeExecutor(t,e,i){const{media:s,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[t];if(!s||!n||!l){R.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(t);return}const h=K(s.duration)?s.duration:1/0,d=K(n.duration)?n.duration:1/0,c=Math.max(0,e),u=Math.min(i,h,d);u>c&&!l.ending?(l.ended=!1,R.log(`[buffer-controller]: Removing [${c},${u}] from the ${t} SourceBuffer`),l.remove(c,u)):a.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:i,sourceBuffer:s}=this,n=s[e];if(!n){R.warn(`[buffer-controller]: Attempting to append to the ${e} SourceBuffer, but it does not exist`),i.shiftAndExecuteNext(e);return}n.ended=!1,n.appendBuffer(t)}blockBuffers(t,e=this.getSourceBufferTypes()){if(!e.length){R.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);return}const{operationQueue:i}=this,s=e.map(n=>i.appendBlocker(n));Promise.all(s).then(()=>{t(),e.forEach(n=>{const a=this.sourceBuffer[n];a!=null&&a.updating||i.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,i){const s=this.sourceBuffer[t];if(!s)return;const n=i.bind(this,t);this.listeners[t].push({event:e,listener:n}),s.addEventListener(e,n)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach(i=>{e.removeEventListener(i.event,i.listener)})}}const yd={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},bd=function(r){let t=r;return yd.hasOwnProperty(r)&&(t=yd[r]),String.fromCharCode(t)},he=15,ke=100,mv={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},vv={17:2,18:4,21:6,22:8,23:10,19:13,20:15},yv={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},bv={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Av=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Tv{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const i=typeof e=="function"?e():e;R.log(`${this.time} [${t}] ${i}`)}}}const oi=function(r){const t=[];for(let e=0;e<r.length;e++)t.push(r[e].toString(16));return t};class Ad{constructor(t,e,i,s,n){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=e||!1,this.italics=i||!1,this.background=s||"black",this.flash=n||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(t){const e=["foreground","underline","italics","background","flash"];for(let i=0;i<e.length;i++){const s=e[i];t.hasOwnProperty(s)&&(this[s]=t[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash}copy(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class Ev{constructor(t,e,i,s,n,a){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new Ad(e,i,s,n,a)}reset(){this.uchar=" ",this.penState.reset()}setChar(t,e){this.uchar=t,this.penState.copy(e)}setPenState(t){this.penState.copy(t)}equals(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)}copy(t){this.uchar=t.uchar,this.penState.copy(t.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class wv{constructor(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let e=0;e<ke;e++)this.chars.push(new Ev);this.logger=t,this.pos=0,this.currPenState=new Ad}equals(t){let e=!0;for(let i=0;i<ke;i++)if(!this.chars[i].equals(t.chars[i])){e=!1;break}return e}copy(t){for(let e=0;e<ke;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<ke;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t}setCursor(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>ke&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ke)}moveCursor(t){const e=this.pos+t;if(t>1)for(let i=this.pos+1;i<e+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(e)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(t){t>=144&&this.backSpace();const e=bd(t);if(this.pos>=ke){this.logger.log(0,()=>"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1)}clearFromPos(t){let e;for(e=t;e<ke;e++)this.chars[e].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const t=[];let e=!0;for(let i=0;i<ke;i++){const s=this.chars[i].uchar;s!==" "&&(e=!1),t.push(s)}return e?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)}}class Aa{constructor(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let e=0;e<he;e++)this.rows.push(new wv(t));this.logger=t,this.currRow=he-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let t=0;t<he;t++)this.rows[t].clear();this.currRow=he-1}equals(t){let e=!0;for(let i=0;i<he;i++)if(!this.rows[i].equals(t.rows[i])){e=!1;break}return e}copy(t){for(let e=0;e<he;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<he;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(t){this.rows[this.currRow].insertChar(t)}setPen(t){this.rows[this.currRow].setPenStyles(t)}moveCursor(t){this.rows[this.currRow].moveCursor(t)}setCursor(t){this.logger.log(2,"setCursor: "+t),this.rows[this.currRow].setCursor(t)}setPAC(t){this.logger.log(2,()=>"pacData = "+JSON.stringify(t));let e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(let o=0;o<he;o++)this.rows[o].clear();const n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){const o=a.rows[n].cueStartTime,l=this.logger.time;if(o&&l!==null&&o<l)for(let h=0;h<this.nrRollUpRows;h++)this.rows[e-this.nrRollUpRows+h+1].copy(a.rows[n+h])}}this.currRow=e;const i=this.rows[this.currRow];if(t.indent!==null){const n=t.indent,a=Math.max(n-1,0);i.setCursor(t.indent),t.color=i.chars[a].penState.foreground}const s={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(t){this.logger.log(2,()=>"bkgData = "+JSON.stringify(t)),this.backSpace(),this.setPen(t),this.insertChar(32)}setRollUpRows(t){this.nrRollUpRows=t}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(2,"Rolling up")}getDisplayText(t){t=t||!1;const e=[];let i="",s=-1;for(let n=0;n<he;n++){const a=this.rows[n].getTextString();a&&(s=n+1,t?e.push("Row "+s+": '"+a+"'"):e.push(a.trim()))}return e.length>0&&(t?i="["+e.join(" | ")+"]":i=e.join(`
|
177
|
+
`)),i}getTextAndFormat(){return this.rows}}class Td{constructor(t,e,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=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new Aa(i),this.nonDisplayedMemory=new Aa(i),this.lastOutputScreen=new Aa(i),this.currRollUpRow=this.displayedMemory.rows[he-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[he-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(t){this.outputFilter=t}setPAC(t){this.writeScreen.setPAC(t)}setBkgData(t){this.writeScreen.setBkgData(t)}setMode(t){t!==this.mode&&(this.mode=t,this.logger.log(2,()=>"MODE="+t),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=t)}insertChars(t){for(let i=0;i<t.length;i++)this.writeScreen.insertChar(t[i]);const e=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>e+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)}ccMIDROW(t){const e={flash:!1};if(e.underline=t%2===1,e.italics=t>=46,e.italics)e.foreground="white";else{const i=Math.floor(t/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=s[i]}this.logger.log(2,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)}outputDataUpdate(t=!1){const e=this.logger.time;e!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=e:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))}}class Ed{constructor(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const s=new Tv;this.channels=[null,new Td(t,e,s),new Td(t+1,i,s)],this.cmdHistory=Sd(),this.logger=s}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let i,s,n,a=!1;this.logger.time=t;for(let o=0;o<e.length;o+=2)if(s=e[o]&127,n=e[o+1]&127,!(s===0&&n===0)){if(this.logger.log(3,"["+oi([e[o],e[o+1]])+"] -> ("+oi([s,n])+")"),i=this.parseCmd(s,n),i||(i=this.parseMidrow(s,n)),i||(i=this.parsePAC(s,n)),i||(i=this.parseBackgroundAttributes(s,n)),!i&&(a=this.parseChars(s,n),a)){const l=this.currentChannel;l&&l>0?this.channels[l].insertChars(a):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!i&&!a&&this.logger.log(2,"Couldn't parse cleaned data "+oi([s,n])+" orig: "+oi([e[o],e[o+1]]))}}parseCmd(t,e){const{cmdHistory:i}=this,s=(t===20||t===28||t===21||t===29)&&e>=32&&e<=47,n=(t===23||t===31)&&e>=33&&e<=35;if(!(s||n))return!1;if(wd(t,e,i))return Di(null,null,i),this.logger.log(3,"Repeated command ("+oi([t,e])+") is dropped"),!0;const a=t===20||t===21||t===23?1:2,o=this.channels[a];return t===20||t===21||t===28||t===29?e===32?o.ccRCL():e===33?o.ccBS():e===34?o.ccAOF():e===35?o.ccAON():e===36?o.ccDER():e===37?o.ccRU(2):e===38?o.ccRU(3):e===39?o.ccRU(4):e===40?o.ccFON():e===41?o.ccRDC():e===42?o.ccTR():e===43?o.ccRTD():e===44?o.ccEDM():e===45?o.ccCR():e===46?o.ccENM():e===47&&o.ccEOC():o.ccTO(e-32),Di(t,e,i),this.currentChannel=a,!0}parseMidrow(t,e){let i=0;if((t===17||t===25)&&e>=32&&e<=47){if(t===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const s=this.channels[i];return s?(s.ccMIDROW(e),this.logger.log(3,"MIDROW ("+oi([t,e])+")"),!0):!1}return!1}parsePAC(t,e){let i;const s=this.cmdHistory,n=(t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127,a=(t===16||t===24)&&e>=64&&e<=95;if(!(n||a))return!1;if(wd(t,e,s))return Di(null,null,s),!0;const o=t<=23?1:2;e>=64&&e<=95?i=o===1?mv[t]:yv[t]:i=o===1?vv[t]:bv[t];const l=this.channels[o];return l?(l.setPAC(this.interpretPAC(i,e)),Di(t,e,s),this.currentChannel=o,!0):!1}interpretPAC(t,e){let i;const s={color:null,italics:!1,indent:null,underline:!1,row:t};return e>95?i=e-96:i=e-64,s.underline=(i&1)===1,i<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((i-16)/2)*4,s}parseChars(t,e){let i,s=null,n=null;if(t>=25?(i=2,n=t-8):(i=1,n=t),n>=17&&n<=19){let a;n===17?a=e+80:n===18?a=e+112:a=e+144,this.logger.log(2,"Special char '"+bd(a)+"' in channel "+i),s=[a]}else t>=32&&t<=127&&(s=e===0?[t]:[t,e]);if(s){const a=oi(s);this.logger.log(3,"Char codes = "+a.join(",")),Di(t,e,this.cmdHistory)}return s}parseBackgroundAttributes(t,e){const i=(t===16||t===24)&&e>=32&&e<=47,s=(t===23||t===31)&&e>=45&&e<=47;if(!(i||s))return!1;let n;const a={};t===16||t===24?(n=Math.floor((e-32)/2),a.background=Av[n],e%2===1&&(a.background=a.background+"_semi")):e===45?a.background="transparent":(a.foreground="black",e===47&&(a.underline=!0));const o=t<=23?1:2;return this.channels[o].setBkgData(a),Di(t,e,this.cmdHistory),!0}reset(){for(let t=0;t<Object.keys(this.channels).length;t++){const e=this.channels[t];e&&e.reset()}this.cmdHistory=Sd()}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const i=this.channels[e];i&&i.cueSplitAtTime(t)}}}function Di(r,t,e){e.a=r,e.b=t}function wd(r,t,e){return e.a===r&&e.b===t}function Sd(){return{a:null,b:null}}class Tr{constructor(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(t,e,i){(this.startTime===null||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Ta=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const r=["","lr","rl"],t=["start","middle","end","left","right"];function e(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;const h=l.toLowerCase();return~o.indexOf(h)?h:!1}function i(o){return e(r,o)}function s(o){return e(t,o)}function n(o,...l){let h=1;for(;h<arguments.length;h++){const d=arguments[h];for(const c in d)o[c]=d[c]}return o}function a(o,l,h){const d=this,c={enumerable:!0};d.hasBeenReset=!1;let u="",f=!1,p=o,g=l,m=h,b=null,A="",T=!0,y="auto",E="start",S=50,L="middle",D=50,k="middle";Object.defineProperty(d,"id",n({},c,{get:function(){return u},set:function(x){u=""+x}})),Object.defineProperty(d,"pauseOnExit",n({},c,{get:function(){return f},set:function(x){f=!!x}})),Object.defineProperty(d,"startTime",n({},c,{get:function(){return p},set:function(x){if(typeof x!="number")throw new TypeError("Start time must be set to a number.");p=x,this.hasBeenReset=!0}})),Object.defineProperty(d,"endTime",n({},c,{get:function(){return g},set:function(x){if(typeof x!="number")throw new TypeError("End time must be set to a number.");g=x,this.hasBeenReset=!0}})),Object.defineProperty(d,"text",n({},c,{get:function(){return m},set:function(x){m=""+x,this.hasBeenReset=!0}})),Object.defineProperty(d,"region",n({},c,{get:function(){return b},set:function(x){b=x,this.hasBeenReset=!0}})),Object.defineProperty(d,"vertical",n({},c,{get:function(){return A},set:function(x){const F=i(x);if(F===!1)throw new SyntaxError("An invalid or illegal string was specified.");A=F,this.hasBeenReset=!0}})),Object.defineProperty(d,"snapToLines",n({},c,{get:function(){return T},set:function(x){T=!!x,this.hasBeenReset=!0}})),Object.defineProperty(d,"line",n({},c,{get:function(){return y},set:function(x){if(typeof x!="number"&&x!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");y=x,this.hasBeenReset=!0}})),Object.defineProperty(d,"lineAlign",n({},c,{get:function(){return E},set:function(x){const F=s(x);if(!F)throw new SyntaxError("An invalid or illegal string was specified.");E=F,this.hasBeenReset=!0}})),Object.defineProperty(d,"position",n({},c,{get:function(){return S},set:function(x){if(x<0||x>100)throw new Error("Position must be between 0 and 100.");S=x,this.hasBeenReset=!0}})),Object.defineProperty(d,"positionAlign",n({},c,{get:function(){return L},set:function(x){const F=s(x);if(!F)throw new SyntaxError("An invalid or illegal string was specified.");L=F,this.hasBeenReset=!0}})),Object.defineProperty(d,"size",n({},c,{get:function(){return D},set:function(x){if(x<0||x>100)throw new Error("Size must be between 0 and 100.");D=x,this.hasBeenReset=!0}})),Object.defineProperty(d,"align",n({},c,{get:function(){return k},set:function(x){const F=s(x);if(!F)throw new SyntaxError("An invalid or illegal string was specified.");k=F,this.hasBeenReset=!0}})),d.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}();class Sv{decode(t,e){if(!t)return"";if(typeof t!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function Ld(r){function t(i,s,n,a){return(i|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}const e=r.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?t(e[2],e[3],0,e[4]):t(e[1],e[2],e[3],e[4]):null}class Lv{constructor(){this.values=Object.create(null)}set(t,e){!this.get(t)&&e!==""&&(this.values[t]=e)}get(t,e,i){return i?this.has(t)?this.values[t]:e[i]:this.has(t)?this.values[t]:e}has(t){return t in this.values}alt(t,e,i){for(let s=0;s<i.length;++s)if(e===i[s]){this.set(t,e);break}}integer(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))}percent(t,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){const i=parseFloat(e);if(i>=0&&i<=100)return this.set(t,i),!0}return!1}}function Rd(r,t,e,i){const s=i?r.split(i):[r];for(const n in s){if(typeof s[n]!="string")continue;const a=s[n].split(e);if(a.length!==2)continue;const o=a[0],l=a[1];t(o,l)}}const Ea=new Ta(0,0,""),Er=Ea.align==="middle"?"middle":"center";function Rv(r,t,e){const i=r;function s(){const o=Ld(r);if(o===null)throw new Error("Malformed timestamp: "+i);return r=r.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){const h=new Lv;Rd(o,function(u,f){let p;switch(u){case"region":for(let g=e.length-1;g>=0;g--)if(e[g].id===f){h.set(u,e[g].region);break}break;case"vertical":h.alt(u,f,["rl","lr"]);break;case"line":p=f.split(","),h.integer(u,p[0]),h.percent(u,p[0])&&h.set("snapToLines",!1),h.alt(u,p[0],["auto"]),p.length===2&&h.alt("lineAlign",p[1],["start",Er,"end"]);break;case"position":p=f.split(","),h.percent(u,p[0]),p.length===2&&h.alt("positionAlign",p[1],["start",Er,"end","line-left","line-right","auto"]);break;case"size":h.percent(u,f);break;case"align":h.alt(u,f,["start",Er,"end","left","right"]);break}},/:/,/\s/),l.region=h.get("region",null),l.vertical=h.get("vertical","");let d=h.get("line","auto");d==="auto"&&Ea.line===-1&&(d=-1),l.line=d,l.lineAlign=h.get("lineAlign","start"),l.snapToLines=h.get("snapToLines",!0),l.size=h.get("size",100),l.align=h.get("align",Er);let c=h.get("position","auto");c==="auto"&&Ea.position===50&&(c=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=c}function a(){r=r.replace(/^\s+/,"")}if(a(),t.startTime=s(),a(),r.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);r=r.slice(3),a(),t.endTime=s(),a(),n(r,t)}function xd(r){return r.replace(/<br(?: \/)?>/gi,`
|
178
|
+
`)}class xv{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Sv,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const e=this;t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));function i(){let n=e.buffer,a=0;for(n=xd(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
|
179
|
+
`;)++a;const o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
|
180
|
+
`&&++a,e.buffer=n.slice(a),o}function s(n){Rd(n,function(a,o){},/:/)}try{let n="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;n=i();const o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");e.state="HEADER"}let a=!1;for(;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(a?a=!1:n=i(),e.state){case"HEADER":/:/.test(n)?s(n):n||(e.state="ID");continue;case"NOTE":n||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){e.state="NOTE";break}if(!n)continue;if(e.cue=new Ta(0,0,""),e.state="CUE",n.indexOf("-->")===-1){e.cue.id=n;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{Rv(n,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{const o=n.indexOf("-->")!==-1;if(!n||o&&(a=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
|
181
|
+
`),e.cue.text+=n}continue;case"BADCUE":n||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const t=this;try{if((t.cue||t.state==="HEADER")&&(t.buffer+=`
|
182
|
+
|
183
|
+
`,t.parse()),t.state==="INITIAL"||t.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){t.onparsingerror&&t.onparsingerror(e)}return t.onflush&&t.onflush(),this}}const kv=/\r\n|\n\r|\n|\r/g,wa=function(r,t,e=0){return r.slice(e,e+t.length)===t},Dv=function(r){let t=parseInt(r.slice(-3));const e=parseInt(r.slice(-6,-4)),i=parseInt(r.slice(-9,-7)),s=r.length>9?parseInt(r.substring(0,r.indexOf(":"))):0;if(!K(t)||!K(e)||!K(i)||!K(s))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${r}`);return t+=1e3*e,t+=60*1e3*i,t+=60*60*1e3*s,t},Sa=function(r){let t=5381,e=r.length;for(;e;)t=t*33^r.charCodeAt(--e);return(t>>>0).toString()};function La(r,t,e){return Sa(r.toString())+Sa(t.toString())+Sa(e)}const Cv=function(r,t,e){let i=r[t],s=r[i.prevCC];if(!s||!s.new&&i.new){r.ccOffset=r.presentationOffset=i.start,i.new=!1;return}for(;(n=s)!=null&&n.new;){var n;r.ccOffset+=i.start-s.start,i.new=!1,i=s,s=r[i.prevCC]}r.presentationOffset=e};function Iv(r,t,e,i,s,n,a){const o=new xv,l=pe(new Uint8Array(r)).trim().replace(kv,`
|
184
|
+
`).split(`
|
185
|
+
`),h=[],d=t?jm(t.baseTime,t.timescale):0;let c="00:00.000",u=0,f=0,p,g=!0;o.oncue=function(m){const b=e[i];let A=e.ccOffset;const T=(u-d)/9e4;if(b!=null&&b.new&&(f!==void 0?A=e.ccOffset=b.start:Cv(e,i,T)),T){if(!t){p=new Error("Missing initPTS for VTT MPEGTS");return}A=T-e.presentationOffset}const y=m.endTime-m.startTime,E=te((m.startTime+A-f)*9e4,s*9e4)/9e4;m.startTime=Math.max(E,0),m.endTime=Math.max(E+y,0);const S=m.text.trim();m.text=decodeURIComponent(encodeURIComponent(S)),m.id||(m.id=La(m.startTime,m.endTime,S)),m.endTime>0&&h.push(m)},o.onparsingerror=function(m){p=m},o.onflush=function(){if(p){a(p);return}n(h)},l.forEach(m=>{if(g)if(wa(m,"X-TIMESTAMP-MAP=")){g=!1,m.slice(16).split(",").forEach(b=>{wa(b,"LOCAL:")?c=b.slice(6):wa(b,"MPEGTS:")&&(u=parseInt(b.slice(7)))});try{f=Dv(c)/1e3}catch(b){p=b}return}else m===""&&(g=!1);o.parse(m+`
|
186
|
+
`)}),o.flush()}const Ra="stpp.ttml.im1t",kd=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Dd=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Pv={left:"start",center:"center",right:"end",start:"start",end:"end"};function Cd(r,t,e,i){const s=et(new Uint8Array(r),["mdat"]);if(s.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const n=s.map(o=>pe(o)),a=Vm(t.baseTime,1,t.timescale);try{n.forEach(o=>e(Ov(o,a)))}catch(o){i(o)}}function Ov(r,t){const e=new DOMParser().parseFromString(r,"text/xml").getElementsByTagName("tt")[0];if(!e)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(i).reduce((h,d)=>(h[d]=e.getAttribute(`ttp:${d}`)||i[d],h),{}),n=e.getAttribute("xml:space")!=="preserve",a=Id(xa(e,"styling","style")),o=Id(xa(e,"layout","region")),l=xa(e,"body","[begin]");return[].map.call(l,h=>{const d=Pd(h,n);if(!d||!h.hasAttribute("begin"))return null;const c=Da(h.getAttribute("begin"),s),u=Da(h.getAttribute("dur"),s);let f=Da(h.getAttribute("end"),s);if(c===null)throw Od(h);if(f===null){if(u===null)throw Od(h);f=c+u}const p=new Ta(c-t,f-t,d);p.id=La(p.startTime,p.endTime,p.text);const g=o[h.getAttribute("region")],m=a[h.getAttribute("style")],b=Mv(g,m,a),{textAlign:A}=b;if(A){const T=Pv[A];T&&(p.lineAlign=T),p.align=A}return Et(p,b),p}).filter(h=>h!==null)}function xa(r,t,e){const i=r.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(e)):[]}function Id(r){return r.reduce((t,e)=>{const i=e.getAttribute("xml:id");return i&&(t[i]=e),t},{})}function Pd(r,t){return[].slice.call(r.childNodes).reduce((e,i,s)=>{var n;return i.nodeName==="br"&&s?e+`
|
187
|
+
`:(n=i.childNodes)!=null&&n.length?Pd(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function Mv(r,t,e){const i="http://www.w3.org/ns/ttml#styling";let s=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=r!=null&&r.hasAttribute("style")?r.getAttribute("style"):null;return a&&e.hasOwnProperty(a)&&(s=e[a]),n.reduce((o,l)=>{const h=ka(t,i,l)||ka(r,i,l)||ka(s,i,l);return h&&(o[l]=h),o},{})}function ka(r,t,e){return r&&r.hasAttributeNS(t,e)?r.getAttributeNS(t,e):null}function Od(r){return new Error(`Could not parse ttml timestamp ${r}`)}function Da(r,t){if(!r)return null;let e=Ld(r);return e===null&&(kd.test(r)?e=Fv(r,t):Dd.test(r)&&(e=Nv(r,t))),e}function Fv(r,t){const e=kd.exec(r),i=(e[4]|0)+(e[5]|0)/t.subFrameRate;return(e[1]|0)*3600+(e[2]|0)*60+(e[3]|0)+i/t.frameRate}function Nv(r,t){const e=Dd.exec(r),i=Number(e[1]);switch(e[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}class Uv{constructor(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Md(),this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.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}},this.config.enableCEA708Captions){const e=new Tr(this,"textTrack1"),i=new Tr(this,"textTrack2"),s=new Tr(this,"textTrack3"),n=new Tr(this,"textTrack4");this.cea608Parser1=new Ed(1,e,i),this.cea608Parser2=new Ed(3,s,n)}t.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(v.FRAG_LOADING,this.onFragLoading,this),t.on(v.FRAG_LOADED,this.onFragLoaded,this),t.on(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(v.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(v.FRAG_LOADING,this.onFragLoading,this),t.off(v.FRAG_LOADED,this.onFragLoaded,this),t.off(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(v.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(t,e,i,s,n){let a=!1;for(let o=n.length;o--;){const l=n[o],h=Hv(l[0],l[1],e,i);if(h>=0&&(l[0]=Math.min(l[0],e),l[1]=Math.max(l[1],i),a=!0,h/(i-e)>.5))return}if(a||n.push([e,i]),this.config.renderTextTracksNatively){const o=this.captionsTracks[t];this.Cues.newCue(o,e,i,s)}else{const o=this.Cues.newCue(null,e,i,s);this.hls.trigger(v.CUES_PARSED,{type:"captions",cues:o,track:t})}}onInitPtsFound(t,{frag:e,id:i,initPTS:s,timescale:n}){const{unparsedVttFrags:a}=this;i==="main"&&(this.initPTS[e.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(v.FRAG_LOADED,o)}))}getExistingTrack(t){const{media:e}=this;if(e)for(let i=0;i<e.textTracks.length;i++){const s=e.textTracks[i];if(s[t])return s}return null}createCaptionsTrack(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)}createNativeTrack(t){if(this.captionsTracks[t])return;const{captionsProperties:e,captionsTracks:i,media:s}=this,{label:n,languageCode:a}=e[t],o=this.getExistingTrack(t);if(o)i[t]=o,Li(i[t]),kh(i[t],s);else{const l=this.createTextTrack("captions",n,a);l&&(l[t]=!0,i[t]=l)}}createNonNativeTrack(t){if(this.nonNativeCaptionsTracks[t])return;const e=this.captionsProperties[t];if(!e)return;const i=e.label,s={_id:t,label:i,kind:"captions",default:e.media?!!e.media.default:!1,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=s,this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(t,e,i){const s=this.media;if(s)return s.addTextTrack(t,e,i)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:t}=this;Object.keys(t).forEach(e=>{Li(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Md(),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(){const{media:t}=this;if(!t)return;const e=t.textTracks;if(e)for(let i=0;i<e.length;i++)Li(e[i])}onSubtitleTracksUpdated(t,e){const i=e.subtitleTracks||[],s=i.some(n=>n.textCodec===Ra);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(pd(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const n=this.media?this.media.textTracks:null;this.tracks.forEach((a,o)=>{let l;if(n&&o<n.length){let h=null;for(let d=0;d<n.length;d++)if(Bv(n[d],a)){h=n[d];break}h&&(l=h)}if(l)Li(l);else{const h=this._captionsOrSubtitlesFromCharacteristics(a);l=this.createTextTrack(h,a.name,a.lang),l&&(l.mode="disabled")}l&&(l.groupId=a.groupId,this.textTracks.push(l))})}else if(this.tracks.length){const n=this.tracks.map(a=>({label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}));this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:n})}}}_captionsOrSubtitlesFromCharacteristics(t){if(t.attrs.CHARACTERISTICS){const e=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(e&&i)return"captions"}return"subtitles"}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach(i=>{const s=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!s)return;const n=`textTrack${s[1]}`,a=this.captionsProperties[n];a&&(a.label=i.name,i.lang&&(a.languageCode=i.lang),a.media=i)})}closedCaptionsForLevel(t){const e=this.hls.levels[t.level];return e==null?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){const{cea608Parser1:i,cea608Parser2:s,lastSn:n,lastPartIndex:a}=this;if(!(!this.enabled||!(i&&s))&&e.frag.type===X.MAIN){var o,l;const h=e.frag.sn,d=(o=e==null||(l=e.part)==null?void 0:l.index)!=null?o:-1;h===n+1||h===n&&d===a+1||(i.reset(),s.reset()),this.lastSn=h,this.lastPartIndex=d}}onFragLoaded(t,e){const{frag:i,payload:s}=e;if(i.type===X.SUBTITLE)if(s.byteLength){const n=i.decryptdata,a="stats"in e;if(n==null||!n.encrypted||a){const o=this.tracks[i.level],l=this.vttCCs;l[i.cc]||(l[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===Ra?this._parseIMSC1(i,s):this._parseVTTs(e)}}else this.hls.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const i=this.hls;Cd(e,this.initPTS[t.cc],s=>{this._appendCues(s,t.level),i.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},s=>{R.log(`Failed to parse IMSC1: ${s}`),i.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:s})})}_parseVTTs(t){var e;const{frag:i,payload:s}=t,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[i.cc]&&o===-1){a.push(t);return}const l=this.hls,h=(e=i.initSegment)!=null&&e.data?ai(i.initSegment.data,new Uint8Array(s)):s;Iv(h,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,d=>{this._appendCues(d,i.level),l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},d=>{const c=d.message==="Missing initPTS for VTT MPEGTS";c?a.push(t):this._fallbackToIMSC1(i,s),R.log(`Failed to parse VTT cue: ${d}`),!(c&&o>i.cc)&&l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:d})})}_fallbackToIMSC1(t,e){const i=this.tracks[t.level];i.textCodec||Cd(e,this.initPTS[t.cc],()=>{i.textCodec=Ra,this._parseIMSC1(t,e)},()=>{i.textCodec="wvtt"})}_appendCues(t,e){const i=this.hls;if(this.config.renderTextTracksNatively){const s=this.textTracks[e];if(!s||s.mode==="disabled")return;t.forEach(n=>Dh(s,n))}else{const s=this.tracks[e];if(!s)return;const n=s.default?"default":"subtitles"+e;i.trigger(v.CUES_PARSED,{type:"subtitles",cues:t,track:n})}}onFragDecrypted(t,e){const{frag:i}=e;i.type===X.SUBTITLE&&this.onFragLoaded(v.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){const{cea608Parser1:i,cea608Parser2:s}=this;if(!this.enabled||!(i&&s))return;const{frag:n,samples:a}=e;if(!(n.type===X.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){const l=a[o].bytes;if(l){const h=this.extractCea608Data(l);i.addData(a[o].pts,h[0]),s.addData(a[o].pts,h[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:i,endOffsetSubtitles:s,type:n}){const{media:a}=this;if(!(!a||a.currentTime<i)){if(!n||n==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(l=>qn(o[l],e,i))}if(this.config.renderTextTracksNatively&&e===0&&s!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(l=>qn(o[l],e,s))}}}extractCea608Data(t){const e=[[],[]],i=t[0]&31;let s=2;for(let n=0;n<i;n++){const a=t[s++],o=127&t[s++],l=127&t[s++];if(!(o===0&&l===0)&&4&a){const h=3&a;(h===0||h===1)&&(e[h].push(o),e[h].push(l))}}return e}}function Bv(r,t){return!!r&&r.label===t.name&&!(r.textTrack1||r.textTrack2)}function Hv(r,t,e,i){return Math.min(t,i)-Math.max(r,e)}function Md(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class Ca{constructor(t){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=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(t){this.streamController=t}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:t}=this;t.on(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(v.MANIFEST_PARSED,this.onManifestParsed,this),t.on(v.BUFFER_CODECS,this.onBufferCodecs,this),t.on(v.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(v.MANIFEST_PARSED,this.onManifestParsed,this),t.off(v.BUFFER_CODECS,this.onBufferCodecs,this),t.off(v.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const i=this.hls.levels[e.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null}onManifestParsed(t,e){const i=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,i.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onBufferCodecs(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const t=this.hls.levels;if(t.length){const e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}}getMaxLevel(t){const e=this.hls.levels;if(!e.length)return-1;const i=e.filter((s,n)=>this.isLevelAllowed(s)&&n<=t);return this.clientRect=null,Ca.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),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;const t=this.media,e={width:0,height:0};if(t){const i=t.getBoundingClientRect();e.width=i.width,e.height=i.height,!e.width&&!e.height&&(e.width=i.right-i.left||t.width||0,e.height=i.bottom-i.top||t.height||0)}return this.clientRect=e,e}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch{}return t}isLevelAllowed(t){return!this.restrictedLevels.some(e=>t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height)}static getMaxLevelByMediaSize(t,e,i){if(!(t!=null&&t.length))return-1;const s=(a,o)=>o?a.width!==o.width||a.height!==o.height:!0;let n=t.length-1;for(let a=0;a<t.length;a+=1){const o=t[a];if((o.width>=e||o.height>=i)&&s(o,t[a+1])){n=a;break}}return n}}class Gv{constructor(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const i=this.hls.config;if(i.capLevelOnFPSDrop){const s=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,i){const s=performance.now();if(e){if(this.lastTime){const n=s-this.lastTime,a=i-this.lastDroppedFrames,o=e-this.lastDecodedFrames,l=1e3*a/n,h=this.hls;if(h.trigger(v.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:i}),l>0&&a>h.config.fpsDroppedMonitoringThreshold*o){let d=h.currentLevel;R.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(h.autoLevelCapping===-1||h.autoLevelCapping>=d)&&(d=d-1,h.trigger(v.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:h.currentLevel}),h.autoLevelCapping=d,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,this.lastDecodedFrames=e}}checkFPSInterval(){const t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){const e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}}const wr="[eme]";class Ci{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=Ci.CDMCleanupPromise?[Ci.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=R.debug.bind(R,wr),this.log=R.log.bind(R,wr),this.warn=R.warn.bind(R,wr),this.error=R.error.bind(R,wr),this.hls=t,this.config=t.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:i}=this.config,s=e[t];if(s)return s.licenseUrl;if(t===ct.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${t}"`)}getServerCertificateUrl(t){const{drmSystems:e}=this.config,i=e[t];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const e=this.hls.levels,i=(a,o,l)=>!!a&&l.indexOf(a)===o,s=e.map(a=>a.audioCodec).filter(i),n=e.map(a=>a.videoCodec).filter(i);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{const l=h=>{const d=h.shift();this.getMediaKeysPromise(d,s,n).then(c=>a({keySystem:d,mediaKeys:c})).catch(c=>{h.length?l(h):c instanceof ee?o(c):o(new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_NO_ACCESS,error:c,fatal:!0},c.message))})};l(t)})}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${i}`;return ih===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return i(t,e)}getMediaKeysPromise(t,e,i){const s=tg(t,e,i,this.config.drmSystemOptions),n=this.keySystemAccessPromises[t];let a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${t}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(t,s);const o=this.keySystemAccessPromises[t]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${t}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const h=this.fetchServerCertificate(t);return this.log(`Create media-keys for "${t}"`),o.mediaKeys=l.createMediaKeys().then(d=>(this.log(`Media-keys created for "${t}"`),h.then(c=>c?this.setMediaKeysServerCertificate(d,t,c):d))),o.mediaKeys.catch(d=>{this.error(`Failed to create media-keys for "${t}"}: ${d}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:i}){this.log(`Creating key-system session "${e}" keyId: ${ge.hexDump(t.keyId||[])}`);const s=i.createSession(),n={decryptdata:t,keySystem:e,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const i=this.createMediaKeySessionContext(t),s=this.getKeyIdString(e),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(i,n,e.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)}getKeyIdString(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(t.keyId===null)throw new Error("keyId is null");return ge.hexDump(t.keyId)}updateKeySession(t,e){var i;const s=t.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${ge.hexDump(((i=t.decryptdata)==null?void 0:i.keyId)||[])}
|
188
|
+
} (data length: ${e&&e.byteLength})`),s.update(e)}selectKeySystemFormat(t){const e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${t.sn} ${t.type}: ${t.level}) key formats ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise}getKeyFormatPromise(t){return new Promise((e,i)=>{const s=Vn(this.config),n=t.map($l).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{const o=eh(a);o?e(o):i(new Error(`Unable to find format for key-system "${a}"`))}).catch(i)})}loadKey(t){const e=t.keyInfo.decryptdata,i=this.getKeyIdString(e),s=`(keyId: ${i} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[i];return n||(n=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(e).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${s}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();const l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:e}),h="cenc";return this.generateRequestWithPreferredKeySession(l,h,e.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof ee?this.hls.trigger(v.ERROR,t.data):this.hls.trigger(v.ERROR,{type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const s=$l(t.keyFormat),n=s?[s]:Vn(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=Vn(this.config)),t.length===0)throw new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(t)}_onMediaEncrypted(t){const{initDataType:e,initData:i}=t;if(this.debug(`"${t.type}" event: init data type: "${e}"`),i===null)return;let s,n;if(e==="sinf"&&this.config.drmSystems[ct.FAIRPLAY]){const d=Ct(new Uint8Array(i));try{const c=Gn(JSON.parse(d).sinf),u=dh(new Uint8Array(c));if(!u)return;s=u.subarray(8,24),n=ct.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const d=Sg(i);if(d===null)return;d.version===0&&d.systemId===th.WIDEVINE&&d.data&&(s=d.data.subarray(8,24)),n=$p(d.systemId)}if(!n||!s)return;const a=ge.hexDump(s),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this;let h=o[a];for(let d=0;d<l.length;d++){const c=l[d],u=c.decryptdata;if(u.pssh||!u.keyId)continue;const f=ge.hexDump(u.keyId);if(a===f||u.uri.replace(/-/g,"").indexOf(a)!==-1){h=o[f],delete o[f],u.pssh=new Uint8Array(i),u.keyId=s,h=o[a]=h.then(()=>this.generateRequestWithPreferredKeySession(c,e,i,"encrypted-event-key-match"));break}}h||(h=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:d,mediaKeys:c})=>{var u;this.throwIfDestroyed();const f=new ms("ISO-23001-7",a,(u=eh(d))!=null?u:"");return f.pssh=new Uint8Array(i),f.keyId=s,this.attemptSetMediaKeys(d,c).then(()=>{this.throwIfDestroyed();const p=this.createMediaKeySessionContext({decryptdata:f,keySystem:d,mediaKeys:c});return this.generateRequestWithPreferredKeySession(p,e,i,"encrypted-event-no-match")})})),h.catch(d=>this.handleError(d))}_onWaitingForKey(t){this.log(`"${t.type}" event`)}attemptSetMediaKeys(t,e){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const s=Promise.all(i).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(e)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${t}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>i.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(t,e,i,s){var n,a;const o=(n=this.config.drmSystems)==null||(a=n[t.keySystem])==null?void 0:a.generateRequest;if(o)try{const u=o.call(this.hls,e,i,t);if(!u)throw new Error("Invalid response from configured generateRequest filter");e=u.initDataType,i=t.decryptdata.pssh=u.initData?new Uint8Array(u.initData):null}catch(u){var l;if(this.warn(u.message),(l=this.hls)!=null&&l.config.debug)throw u}if(i===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(t);const h=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${s}": ${h} (init data type: ${e} length: ${i?i.byteLength:null})`);const d=new ma;t.mediaKeysSession.onmessage=u=>{const f=t.mediaKeysSession;if(!f){d.emit("error",new Error("invalid state"));return}const{messageType:p,message:g}=u;this.log(`"${p}" message event for session "${f.sessionId}" message size: ${g.byteLength}`),p==="license-request"||p==="license-renewal"?this.renewLicense(t,g).catch(m=>{this.handleError(m),d.emit("error",m)}):p==="license-release"?t.keySystem===ct.FAIRPLAY&&(this.updateKeySession(t,_l("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${p}"`)},t.mediaKeysSession.onkeystatuseschange=u=>{if(!t.mediaKeysSession){d.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(t);const f=t.keyStatus;d.emit("keyStatus",f),f==="expired"&&(this.warn(`${t.keySystem} expired for key ${h}`),this.renewKeySession(t))};const c=new Promise((u,f)=>{d.on("error",f),d.on("keyStatus",p=>{p.startsWith("usable")?u():p==="output-restricted"?f(new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):p==="internal-error"?f(new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${p}"`)):p==="expired"?f(new Error("key expired while generating request")):this.warn(`unhandled key status change "${p}"`)})});return t.mediaKeysSession.generateRequest(e,i).then(()=>{var u;this.log(`Request generated for key-session "${(u=t.mediaKeysSession)==null?void 0:u.sessionId}" keyId: ${h}`)}).catch(u=>{throw new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_NO_SESSION,error:u,fatal:!1},`Error generating key-session request: ${u}`)}).then(()=>c).catch(u=>{throw d.removeAllListeners(),this.removeSession(t),u}).then(()=>(d.removeAllListeners(),t))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach((e,i)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${ge.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${ge.hexDump(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e})}fetchServerCertificate(t){const e=this.config,i=e.loader,s=new i(e),n=this.getServerCertificateUrl(t);return n?(this.log(`Fetching serverCertificate for "${t}"`),new Promise((a,o)=>{const l={responseType:"arraybuffer",url:n},h=e.certLoadPolicy.default,d={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(u,f,p,g)=>{a(u.data)},onError:(u,f,p,g)=>{o(new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:p,response:jt({url:l.url,data:void 0},u)},`"${t}" certificate request failed (${n}). Status: ${u.code} (${u.text})`))},onTimeout:(u,f,p)=>{o(new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:p,response:{url:l.url,data:void 0}},`"${t}" certificate request timed out (${n})`))},onAbort:(u,f,p)=>{o(new Error("aborted"))}};s.load(l,d,c)})):Promise.resolve()}setMediaKeysServerCertificate(t,e,i){return new Promise((s,n)=>{t.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${e}"`),s(t)}).catch(a=>{n(new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then(i=>this.updateKeySession(t,new Uint8Array(i)).catch(s=>{throw new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}setupLicenseXHR(t,e,i,s){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return n.call(this.hls,t,e,i,s)}).catch(a=>{if(!i.decryptdata)throw a;return t.open("POST",e,!0),n.call(this.hls,t,e,i,s)}).then(a=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:a||s})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:s}))}requestLicense(t,e){const i=this.config.keyLoadPolicy.default;return new Promise((s,n)=>{const a=this.getLicenseServerUrl(t.keySystem);this.log(`Sending license request to URL: ${a}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!t.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}`);const h=this.config.licenseResponseCallback;if(h)try{l=h.call(this.hls,o,a,t)}catch(d){this.error(d)}s(l)}else{const l=i.errorRetry,h=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>h||o.status>=400&&o.status<500)n(new ee({type:Y.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{const d=h-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${d} attempts left`),this.requestLicense(t,e).then(s,n)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=o,this.setupLicenseXHR(o,a,t,e).then(({xhr:l,licenseChallenge:h})=>{l.send(h)})})}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const i=e.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const t=this.media,e=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},ms.clearKeyUriToKeyIdMap();const i=e.length;Ci.CDMCleanupPromise=Promise.all(e.map(s=>this.removeSession(s)).concat(t==null?void 0:t.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}. media.src: ${t==null?void 0:t.src}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}. media.src: ${t==null?void 0:t.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(t,{sessionKeys:e}){if(!(!e||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=e.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(t){const{mediaKeysSession:e,licenseXhr:i}=t;if(e){this.log(`Remove licenses and keys and close session ${e.sessionId}`),e.onmessage=null,e.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const s=this.mediaKeySessions.indexOf(t);return s>-1&&this.mediaKeySessions.splice(s,1),e.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>e.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}}Ci.CDMCleanupPromise=void 0;class ee extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),this.data=t,t.err=t.error}}const Vv=1;var Wt={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const jv="h";class Ue{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:Wt.MANIFEST,su:!this.initialized})}catch(n){R.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{const n=s.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===Wt.VIDEO||o===Wt.AUDIO||o==Wt.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){R.warn("Could not generate segment CMCD data.",n)}},this.hls=t;const e=this.config=t.config,{cmcd:i}=e;i!=null&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||Ue.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}registerListeners(){const t=this.hls;t.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(v.MEDIA_DETACHED,this.onMediaDetached,this),t.on(v.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(v.MEDIA_DETACHED,this.onMediaDetached,this),t.off(v.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(t,e){this.media=e.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(t,e){var i,s;this.audioBuffer=(i=e.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(s=e.tracks.video)==null?void 0:s.buffer}createData(){var t;return{v:Vv,sf:jv,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){Et(e,this.createData());const i=e.ot===Wt.INIT||e.ot===Wt.VIDEO||e.ot===Wt.MUXED;if(this.starved&&i&&(e.bs=!0,e.su=!0,this.starved=!1),e.su==null&&(e.su=this.buffering),this.useHeaders){const s=Ue.toHeaders(e);if(!Object.keys(s).length)return;t.headers||(t.headers={}),Et(t.headers,s)}else{const s=Ue.toQuery(e);if(!s)return;t.url=Ue.appendQueryToUri(t.url,s)}}getObjectType(t){const{type:e}=t;if(e==="subtitle")return Wt.TIMED_TEXT;if(t.sn==="initSegment")return Wt.INIT;if(e==="audio")return Wt.AUDIO;if(e==="main")return this.hls.audioTracks.length?Wt.VIDEO:Wt.MUXED}getTopBandwidth(t){let e=0,i;const s=this.hls;if(t===Wt.AUDIO)i=s.audioTracks;else{const n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;i=s.levels.slice(0,a)}for(const n of i)n.bitrate>e&&(e=n.bitrate);return e>0?e:NaN}getBufferLength(t){const e=this.hls.media,i=t===Wt.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!e?NaN:lt.bufferInfo(i,e.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,i=t||this.config.loader;return class{constructor(s){this.loader=void 0,this.loader=new i(s)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(s,n,a){e(s),this.loader.load(s,n,a)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,i=t||this.config.loader;return class{constructor(s){this.loader=void 0,this.loader=new i(s)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(s,n,a){e(s),this.loader.load(s,n,a)}}}static uuid(){const t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}static serialize(t){const e=[],i=l=>!Number.isNaN(l)&&l!=null&&l!==""&&l!==!1,s=l=>Math.round(l),n=l=>s(l/100)*100,a={br:s,d:s,bl:n,dl:n,mtp:n,nor:l=>encodeURIComponent(l),rtp:n,tb:s},o=Object.keys(t||{}).sort();for(const l of o){let h=t[l];if(!i(h)||l==="v"&&h===1||l=="pr"&&h===1)continue;const d=a[l];d&&(h=d(h));const c=typeof h;let u;l==="ot"||l==="sf"||l==="st"?u=`${l}=${h}`:c==="boolean"?u=l:c==="number"?u=`${l}=${h}`:u=`${l}=${JSON.stringify(h)}`,e.push(u)}return e.join(",")}static toHeaders(t){const e=Object.keys(t),i={},s=["Object","Request","Session","Status"],n=[{},{},{},{}],a={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const o of e){const l=a[o]!=null?a[o]:1;n[l][o]=t[o]}for(let o=0;o<n.length;o++){const l=Ue.serialize(n[o]);l&&(i[`CMCD-${s[o]}`]=l)}return i}static toQuery(t){return`CMCD=${encodeURIComponent(Ue.serialize(t))}`}static appendQueryToUri(t,e){if(!e)return t;const i=t.includes("?")?"&":"?";return`${t}${i}${e}`}}const zv=3e5;class Kv{constructor(t){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=t,this.log=R.log.bind(R,"[content-steering]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(v.MANIFEST_LOADING,this.onManifestLoading,this),t.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(v.MANIFEST_PARSED,this.onManifestParsed,this),t.on(v.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(v.MANIFEST_LOADING,this.onManifestLoading,this),t.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(v.MANIFEST_PARSED,this.onManifestParsed,this),t.off(v.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const t=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,t)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){const e=this.levels;e&&(this.levels=e.filter(i=>i!==t))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(t,e){const{contentSteering:i}=e;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:i}=e;if((i==null?void 0:i.action)===Ft.SendAlternateToPenaltyBox&&i.flags===$t.MoveAllAlternatesMatchingHost){let s=this.pathwayPriority;const n=this.pathwayId;this.penalizedPathways[n]||(this.penalizedPathways[n]=performance.now()),!s&&this.levels&&(s=this.levels.reduce((a,o)=>(a.indexOf(o.pathwayId)===-1&&a.push(o.pathwayId),a),[])),s&&s.length>1&&(this.updatePathwayPriority(s),i.resolved=this.pathwayId!==n)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);if(e.length===0){const i=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),e=this.getLevelsForPathway(i),this.pathwayId=i}return e.length!==t.length?(this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e):t}getLevelsForPathway(t){return this.levels===null?[]:this.levels.filter(e=>t===e.pathwayId)}updatePathwayPriority(t){this.pathwayPriority=t;let e;const i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach(n=>{s-i[n]>zv&&delete i[n]});for(let n=0;n<t.length;n++){const a=t[n];if(i[a])continue;if(a===this.pathwayId)return;const o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(e=this.getLevelsForPathway(a),e.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,this.hls.trigger(v.LEVELS_UPDATED,{levels:e});const h=this.hls.levels[o];l&&h&&this.levels&&(h.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&h.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${h.bitrate}`),this.hls.nextLoadLevel=o);break}}}clonePathways(t){const e=this.levels;if(!e)return;const i={},s={};t.forEach(n=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(e.some(d=>d.pathwayId===a))return;const h=this.getLevelsForPathway(o).map(d=>{const c=Et({},d);c.details=void 0,c.url=Nd(d.uri,d.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l);const u=new dt(d.attrs);u["PATHWAY-ID"]=a;const f=u.AUDIO&&`${u.AUDIO}_clone_${a}`,p=u.SUBTITLES&&`${u.SUBTITLES}_clone_${a}`;f&&(i[u.AUDIO]=f,u.AUDIO=f),p&&(s[u.SUBTITLES]=p,u.SUBTITLES=p),c.attrs=u;const g=new ys(c);return fr(g,"audio",f),fr(g,"text",p),g});e.push(...h),Fd(this.audioTracks,i,l,a),Fd(this.subtitleTracks,s,l,a)})}loadSteeringManifest(t){const e=this.hls.config,i=e.loader;this.loader&&this.loader.destroy(),this.loader=new i(e);let s;try{s=new self.URL(t)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${t}`);return}if(s.protocol!=="data:"){const d=(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+d)}const n={responseType:"json",url:s.href},a=e.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},h={onSuccess:(d,c,u,f)=>{this.log(`Loaded steering manifest: "${s}"`);const p=d.data;if(p.VERSION!==1){this.log(`Steering VERSION ${p.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=p.TTL;const{"RELOAD-URI":g,"PATHWAY-CLONES":m,"PATHWAY-PRIORITY":b}=p;if(g)try{this.uri=new self.URL(g,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${g}`);return}this.scheduleRefresh(this.uri||u.url),m&&this.clonePathways(m),b&&this.updatePathwayPriority(b)},onError:(d,c,u,f)=>{if(this.log(`Error loading steering manifest: ${d.code} ${d.text} (${c.url})`),this.stopLoad(),d.code===410){this.enabled=!1,this.log(`Steering manifest ${c.url} no longer available`);return}let p=this.timeToLoad*1e3;if(d.code===429){const g=this.loader;if(typeof(g==null?void 0:g.getResponseHeader)=="function"){const m=g.getResponseHeader("Retry-After");m&&(p=parseFloat(m)*1e3)}this.log(`Steering manifest ${c.url} rate limited`);return}this.scheduleRefresh(this.uri||c.url,p)},onTimeout:(d,c,u)=>{this.log(`Timeout loading steering manifest (${c.url})`),this.scheduleRefresh(this.uri||c.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,l,h)}scheduleRefresh(t,e=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(t)},e)}}function Fd(r,t,e,i){r&&Object.keys(t).forEach(s=>{const n=r.filter(a=>a.groupId===s).map(a=>{const o=Et({},a);return o.details=void 0,o.attrs=new dt(o.attrs),o.url=o.attrs.URI=Nd(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),o.groupId=o.attrs["GROUP-ID"]=t[s],o.attrs["PATHWAY-ID"]=i,o});r.push(...n)})}function Nd(r,t,e,i){const{HOST:s,PARAMS:n,[e]:a}=i;let o;t&&(o=a==null?void 0:a[t],o&&(r=o));const l=new self.URL(r);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(h=>{h&&l.searchParams.set(h,n[h])}),l.href}const Wv=/^age:\s*[\d.]+\s*$/im;class Ud{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new rr,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,e,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t)return;const i=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!this.stats.aborted)return n(i,e.url)}).catch(a=>(i.open("GET",e.url,!0),n(i,e.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,e,t)}).catch(a=>{this.callbacks.onError({code:i.status,text:a.message},e,i,s)}):this.openAndSendXhr(i,e,t)}openAndSendXhr(t,e,i){t.readyState||t.open("GET",e.url,!0);const s=this.context.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=i.loadPolicy;if(s)for(const o in s)t.setRequestHeader(o,s[o]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),i.timeout=n&&K(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:i}=this;if(!t||!e)return;const s=e.readyState,n=this.config;if(!i.aborted&&s>=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)))),s===4)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const a=e.status,o=e.responseType!=="text";if(a>=200&&a<300&&(o&&e.response||e.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const l=o?e.response:e.responseText,h=e.responseType==="arraybuffer"?l.byteLength:l.length;if(i.loaded=i.total=h,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;const d=this.callbacks.onProgress;if(d&&d(i,t,l,e),!this.callbacks)return;const c={url:e.responseURL,data:l,code:a};this.callbacks.onSuccess(c,i,t,e)}else{const l=n.loadPolicy.errorRetry,h=i.retry;ur(l,h,!1,a)?this.retry(l):(R.error(`${a} while loading ${t.url}`),this.callbacks.onError({code:a,text:e.statusText},t,e,i))}}}loadtimeout(){var t;const e=(t=this.config)==null?void 0:t.loadPolicy.timeoutRetry,i=this.stats.retry;if(ur(e,i,!0))this.retry(e);else{R.warn(`timeout while loading ${this.context.url}`);const s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:i}=this;this.retryDelay=ta(t,i.retry),i.retry++,R.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${e.url}, retrying ${i.retry}/${t.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(t){const e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;if(this.loader&&Wv.test(this.loader.getAllResponseHeaders())){const e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}function Yv(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const Xv=/(\d+)-(\d+)\/(\d+)/;class Bd{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||Qv,this.controller=new self.AbortController,this.stats=new rr}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const t=this.response;t!=null&&t.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(t,e,i){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();const n=qv(t,this.controller.signal),a=i.onProgress,o=t.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:h,maxLoadTimeMs:d}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=i,this.request=this.fetchSetup(t,n),self.clearTimeout(this.requestTimeout),e.timeout=h&&K(h)?h:d,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,t,this.response)},e.timeout),self.fetch(this.request).then(c=>{this.response=this.loader=c;const u=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=d,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,t,this.response)},d-(u-s.loading.start)),!c.ok){const{status:f,statusText:p}=c;throw new _v(p||"fetch, bad network response",f,c)}return s.loading.first=u,s.total=Jv(c.headers)||s.total,a&&K(e.highWaterMark)?this.loadProgressively(c,s,t,e.highWaterMark,a):o?c.arrayBuffer():t.responseType==="json"?c.json():c.text()}).then(c=>{const{response:u}=this;self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const f=c[l];f&&(s.loaded=s.total=f);const p={url:u.url,data:c,code:u.status};a&&!K(e.highWaterMark)&&a(s,t,c,u),i.onSuccess(p,s,t,u)}).catch(c=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;const u=c&&c.code||0,f=c?c.message:null;i.onError({code:u,text:f},t,c?c.details:null,s)})}getCacheAge(){let t=null;if(this.response){const e=this.response.headers.get("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,e,i,s=0,n){const a=new ud,o=t.body.getReader(),l=()=>o.read().then(h=>{if(h.done)return a.dataLength&&n(e,i,a.flush(),t),Promise.resolve(new ArrayBuffer(0));const d=h.value,c=d.length;return e.loaded+=c,c<s||a.dataLength?(a.push(d),a.dataLength>=s&&n(e,i,a.flush(),t)):n(e,i,d,t),l()}).catch(()=>Promise.reject());return l()}}function qv(r,t){const e={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(Et({},r.headers))};return r.rangeEnd&&e.headers.set("Range","bytes="+r.rangeStart+"-"+String(r.rangeEnd-1)),e}function Zv(r){const t=Xv.exec(r);if(t)return parseInt(t[2])-parseInt(t[1])+1}function Jv(r){const t=r.get("Content-Range");if(t){const i=Zv(t);if(K(i))return i}const e=r.get("Content-Length");if(e)return parseInt(e)}function Qv(r,t){return new self.Request(r.url,t)}class _v extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const $v=/\s/,t0={newCue(r,t,e,i){const s=[];let n,a,o,l,h;const d=self.VTTCue||self.TextTrackCue;for(let u=0;u<i.rows.length;u++)if(n=i.rows[u],o=!0,l=0,h="",!n.isEmpty()){var c;for(let g=0;g<n.chars.length;g++)$v.test(n.chars[g].uchar)&&o?l++:(h+=n.chars[g].uchar,o=!1);n.cueStartTime=t,t===e&&(e+=1e-4),l>=16?l--:l++;const f=xd(h.trim()),p=La(t,e,f);r!=null&&(c=r.cues)!=null&&c.getCueById(p)||(a=new d(t,e,f),a.id=p,a.line=u+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(a))}return r&&s.length&&(s.sort((u,f)=>u.line==="auto"||f.line==="auto"?0:u.line>8&&f.line>8?f.line-u.line:u.line-f.line),s.forEach(u=>Dh(r,u))),s}},e0={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},i0=jt(jt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Ud,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:av,bufferController:gv,capLevelController:Ca,errorController:_g,fpsController:Gv,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:ih,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:e0},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},s0()),{},{subtitleStreamController:cv,subtitleTrackController:fv,timelineController:Uv,audioStreamController:lv,audioTrackController:hv,emeController:Ci,cmcdController:Ue,contentSteeringController:Kv});function s0(){return{cueHandler:t0,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function r0(r,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(t.liveMaxLatencyDurationCount!==void 0&&(t.liveSyncDurationCount===void 0||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(t.liveMaxLatencyDuration!==void 0&&(t.liveSyncDuration===void 0||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const e=Ia(r),i=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(n=>{const a=`${n==="level"?"playlist":n}LoadPolicy`,o=t[a]===void 0,l=[];s.forEach(h=>{const d=`${n}Loading${h}`,c=t[d];if(c!==void 0&&o){l.push(d);const u=e[a].default;switch(t[a]={default:u},h){case"TimeOut":u.maxLoadTimeMs=c,u.maxTimeToFirstByteMs=c;break;case"MaxRetry":u.errorRetry.maxNumRetry=c,u.timeoutRetry.maxNumRetry=c;break;case"RetryDelay":u.errorRetry.retryDelayMs=c,u.timeoutRetry.retryDelayMs=c;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=c,u.timeoutRetry.maxRetryDelayMs=c;break}}}),l.length&&R.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(t[a])}`)}),jt(jt({},e),t)}function Ia(r){return r&&typeof r=="object"?Array.isArray(r)?r.map(Ia):Object.keys(r).reduce((t,e)=>(t[e]=Ia(r[e]),t),{}):r}function n0(r){const t=r.loader;t!==Bd&&t!==Ud?(R.log("[config]: Custom loader detected, cannot enable progressive streaming"),r.progressive=!1):Yv()&&(r.loader=Bd,r.progressive=!0,r.enableSoftwareAES=!0,R.log("[config]: Progressive streaming enabled, using FetchLoader"))}class De{static get version(){return"1.4.12"}static isSupported(){return vm()}static get Events(){return v}static get ErrorTypes(){return Y}static get ErrorDetails(){return P}static get DefaultConfig(){return De.defaultConfig?De.defaultConfig:i0}static set DefaultConfig(t){De.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new ma,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,zp(t.debug||!1,"Hls instance");const e=this.config=r0(De.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&n0(e);const{abrController:i,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=e,l=new a(this),h=this.abrController=new i(this),d=this.bufferController=new s(this),c=this.capLevelController=new n(this),u=new o(this),f=new Og(this),p=new Bg(this),g=e.contentSteeringController,m=g?new g(this):null,b=this.levelController=new tm(this,m),A=new em(this),T=new sm(this.config),y=this.streamController=new rv(this,A,T);c.setStreamController(y),u.setStreamController(y);const E=[f,b,y];m&&E.splice(1,0,m),this.networkControllers=E;const S=[h,d,c,u,p,A];this.audioTrackController=this.createController(e.audioTrackController,E);const L=e.audioStreamController;L&&E.push(new L(this,A,T)),this.subtitleTrackController=this.createController(e.subtitleTrackController,E);const D=e.subtitleStreamController;D&&E.push(new D(this,A,T)),this.createController(e.timelineController,S),T.emeController=this.emeController=this.createController(e.emeController,S),this.cmcdController=this.createController(e.cmcdController,S),this.latencyController=this.createController(Hg,S),this.coreComponents=S,E.push(l);const k=l.onErrorOut;typeof k=="function"&&this.on(v.ERROR,k,l)}createController(t,e){if(t){const i=new t(this);return e&&e.push(i),i}return null}on(t,e,i=this){this._emitter.on(t,e,i)}once(t,e,i=this){this._emitter.once(t,e,i)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,i=this,s){this._emitter.off(t,e,i,s)}listeners(t){return this._emitter.listeners(t)}emit(t,e,i){return this._emitter.emit(t,e,i)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(i){R.error("An internal error happened while handling event "+t+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(v.ERROR,{type:Y.OTHER_ERROR,details:P.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){R.log("destroy"),this.trigger(v.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;const t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){R.log("attachMedia"),this._media=t,this.trigger(v.MEDIA_ATTACHING,{media:t})}detachMedia(){R.log("detachMedia"),this.trigger(v.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,i=this.url,s=this.url=Un.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});R.log(`loadSource:${s}`),e&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(v.MANIFEST_LOADING,{url:t})}startLoad(t=-1){R.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){R.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){R.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){R.log("recoverMediaError");const t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t,e=0){this.levelController.removeLevel(t,e)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){R.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){R.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){R.log(`set loadLevel:${t}`),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){R.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){R.log(`set startLevel:${t}`),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){const e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(R.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){Qn.indexOf(t)>-1&&(this._maxHdcpLevel=t)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:e}}=this;if(!t)return 0;const i=t.length;for(let s=0;s<i;s++)if(t[s].maxBitrate>=e)return s;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:i}=this;let s;if(e===-1&&t&&t.length?s=t.length-1:s=e,i)for(let n=s;n--;){const a=t[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return s}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const e=this.audioTrackController;e&&(e.audioTrack=t)}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return t?t.subtitleDisplay:!1}set subtitleDisplay(t){const e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}De.defaultConfig=void 0;function a0(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function o0(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}async function Hd(r){return r.duration===1/0?new Promise(t=>{r.currentTime=Number.MAX_SAFE_INTEGER,r.ontimeupdate=()=>{r.ontimeupdate=null,t(r.duration),r.currentTime=0}}):r.duration}class l0{constructor(t){this._duration=0,this._processing=!1,this._scenes=null,this._videos={},this._videoState={},this._resolveVideo=e=>{const{id:i,src:s,playlist:n,duration:a,captions:o,startOffset:l,endOffset:h}=e;return new Promise(d=>{let c=null;const u=document.createElement("video");if(u.playsInline=!0,u.muted=!0,u.loop=!1,u.volume=this.host.volume,u.playbackRate=this.host.playbackRate,n&&!a0()&&De.isSupported()){let f=!1;c=new De({autoStartLoad:!0,xhrSetup:p=>{const{open:g}=p,m=n.split("?")[1];p.open=function(b,A,T){A.toString().includes("?")||(A+="?"+m),g.apply(this,[b,A,T])}}}),c.loadSource(n),c.attachMedia(u),c.startLoadOnce=(p=-1)=>{c&&!f&&(c.startLoad(p),f=!0)},c.on(De.Events.LEVEL_LOADED,async()=>{f||c==null||c.stopLoad();const p=a??await Hd(u),g=(1-((e==null?void 0:e.endOffset)??0))*p;d({id:i,hls:c,duration:g,captions:o,node:u,start:(l??0)*p})})}else{u.src=s;let f=!1;if(u.startLoadOnce=()=>{f||(u.preload="auto",u.load(),f=!0)},a){u.preload="none";const p=(1-(h??0))*a;d({id:i,hls:c,duration:p,captions:o,node:u,start:(l??0)*a})}else{u.preload="metadata";const p=async()=>{const g=await Hd(u),m=(1-(h??0))*g;d({id:i,hls:c,duration:m,captions:o,node:u,start:(l??0)*g}),u.removeEventListener("loadedmetadata",p)};u.addEventListener("loadedmetadata",p)}}})},this._handleLoadedData=(e,i)=>()=>{const s=this.videoState[e];s!=null&&s.initialised||(this.videoState={...this.videoState,[e]:{...s,initialised:!0,waiting:!1,buffered:(s==null?void 0:s.buffered)??[]}},this.setVideosCurrentTime(this.host.currentTime),this.host.dispatchEvent(new CustomEvent("video:loadeddata",{detail:{id:e,node:i}})))},this._handleWaiting=e=>()=>{const i=this.videoState[e];i!=null&&i.initialised&&!(i!=null&&i.waiting)&&(this.videoState={...this.videoState,[e]:{...i,waiting:!0}})},this._handleCanPlay=e=>()=>{const i=this.videoState[e];i!=null&&i.initialised&&i!=null&&i.waiting&&(this.videoState={...this.videoState,[e]:{...i,waiting:!1}})},this._handleProgress=(e,i)=>()=>{var s;const n=i==null?void 0:i.buffered,a=[],{start:o,video:l}=((s=this.scenes)==null?void 0:s.scenes.find(({video:h})=>e===(h==null?void 0:h.id)))??{};if(i&&n&&l&&typeof o<"u"){for(let d=0;d<n.length;d++){const c=n.start(d),u=n.end(d);Math.max(c,l.start)<=Math.min(u,l.start+l.duration)&&a.push({start:Math.max(0,(Math.max(c-l.start,0)+o)/this.host.duration*100),end:Math.min((Math.min(u-l.start,l.duration)+o)/this.host.duration*100,100)})}const h=this.videoState[e];this.videoState={...this.videoState,[e]:{...h,buffered:a}}}},this._handleSeeked=(e,i)=>()=>{const s=this.videoState[e];s!=null&&s.initialised&&(this.host.draw(),this.host.dispatchEvent(new CustomEvent("video:seeked",{detail:{id:e,node:i}})))},this._handlePlay=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:play",{detail:{id:e,node:i}}))},this._handlePlaying=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:playing",{detail:{id:e,node:i}}))},this._handlePause=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:pause",{detail:{id:e,node:i}}))},this._handleStalled=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:stalled",{detail:{id:e,node:i}}))},this._handleTimeUpdate=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:timeupdate",{detail:{id:e,node:i}}))},this._handleEnded=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:ended",{detail:{id:e,node:i}}))},this._handleError=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:error",{detail:{id:e,node:i}}))},this.host=t,this.host.addController(this)}set processing(t){t!==this._processing&&(this._processing=t,this.host.requestUpdate())}get processing(){return this._processing}set duration(t){!isNaN(t)&&t!==this._duration&&(this._duration=t,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(t){this._scenes=t,this.host.requestUpdate()}get scenes(){return this._scenes}set videos(t){this._videos=t,this.host.requestUpdate()}get videos(){return this._videos}set videoState(t){this._videoState=t,this.host.requestUpdate()}get videoState(){return this._videoState}_setupTask(){new Uo(this.host,async([t,e,i,s,n])=>{try{if(i||t){if(this.host.reset(),this.processing=!0,Object.keys(this.videos??{}).forEach(o=>{if(this.videos){const{hls:l,node:h}=this.videos[o];l==null||l.destroy(),h.src=""}}),i){let o=null;if(s)try{o=await(await fetch(s,{method:"GET"})).text()}catch{this.host.dispatchEvent(new ErrorEvent("error",new Error("Track failed to fetch")))}const l=i.includes(".m3u8")?"playlist":"video";this.scenes=await el({data:{questions:{items:[{answer:{id:"source",media:{[l]:i},captions:{current:o}}}]}},template:e,burnCaptions:n},this._resolveVideo)}else this.scenes=await el({data:t,template:e,burnCaptions:n},this._resolveVideo);const a={loadeddata:this._handleLoadedData,waiting:this._handleWaiting,canplay:this._handleCanPlay,progress:this._handleProgress,seeked:this._handleSeeked,play:this._handlePlay,playing:this._handlePlaying,pause:this._handlePause,stalled:this._handleStalled,timeupdate:this._handleTimeUpdate,ended:this._handleEnded,error:this._handleError};this.videos=this.scenes.scenes.reduce((o,{video:l})=>{if(l){const{id:h,node:d}=l,c=Object.keys(a).reduce((u,f)=>{const p=f,g=a[p](h,d);return u[p]=g,d.addEventListener(f,g),u},{});o[l.id]={...l,listeners:c}}return o},{}),this.videoState=this.scenes.scenes.reduce((o,{video:l})=>(l&&(o[l.id]={initialised:!1,waiting:!0,buffered:[]}),o),{}),this.duration=this.scenes.duration,this.host.reset(this.host.currentTime,!this.host.paused),this.host.autoplay&&this.host.play()}}catch(a){console.log(a),this.scenes=null,this.duration=0,this.host.dispatchEvent(new ErrorEvent("error",new Error("Failed to create scenes")))}finally{this.processing=!1}},()=>[this.host.data,this.host.template,this.host.src,this.host.track,this.host.burnCaptions])}_setVideoCurrentTime({time:t,scene:e}){const{start:i,video:s}=e;if(s&&s.node&&typeof i<"u"){const n=t-i;s.node.currentTime=Math.max(s.start,Math.min(s.start+s.duration,n+s.start))}}setVideosCurrentTime(t){var e;(e=this.scenes)==null||e.scenes.forEach(i=>{this._setVideoCurrentTime({time:t,scene:i})})}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(t=>{var e,i;(e=this.videos)!=null&&e[t]&&((i=this.videos[t].hls)==null||i.destroy(),this.videos[t].node.pause(),Object.keys(this.videos[t].listeners).forEach(s=>{var n;if((n=this.videos)!=null&&n[t]){const a=this.videos[t].listeners[s];this.videos[t].node.removeEventListener(s,a)}}),delete this.videos[t])}),this.videos={}}}function h0(r){r.requestFullscreen?r.requestFullscreen():r.mozRequestFullScreen?r.mozRequestFullScreen():r.webkitRequestFullscreen?r.webkitRequestFullscreen():r.msRequestFullscreen&&r.msRequestFullscreen()}function d0(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const Pa=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen"],c0={id:"captions",event:"captions:click",label:"Closed Captions"},u0={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},Gd={title:"Playback Speed",items:[{id:"playback-rate-0.5",event:"playbackRate:click",label:"0.5x",value:.5},{id:"playback-rate-1",event:"playbackRate:click",label:"1.0x",value:1},{id:"playback-rate-1.5",event:"playbackRate:click",label:"1.5x",value:1.5},{id:"playback-rate-2",event:"playbackRate:click",label:"2.0x",value:2}]},f0={id:"playbackRate",label:"Playback playbackRate",subItems:Gd};class p0 extends rl{constructor(t){if(super(t),this.element=null,this.observer=void 0,t.type!==yi.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}disconnected(){var t;(t=this.observer)==null||t.disconnect(),this.observer=void 0}reconnected(){var t;this.element&&((t=this.observer)==null||t.observe(this.element))}update(t,[e]){return this.isConnected&&!this.observer&&(this.observer=new ResizeObserver(e),this.element=t.element,this.observer.observe(this.element)),se}}const Sr=bi(p0),g0=`
|
189
189
|
@font-face {
|
190
190
|
font-family: "Futura";
|
191
191
|
font-weight: 800;
|
@@ -211,7 +211,7 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
211
211
|
font-weight: 700;
|
212
212
|
font-style: bold;
|
213
213
|
src: url(data:application/font-woff;base64,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);
|
214
|
-
}`,
|
214
|
+
}`,ve={"red-120":"#feeded","red-130":"#fcd5d0","red-400":"#e84a4a","red-500":"#c51c3a","red-700":"#a21c39","red-800":"#850231","red-900":"#580A2D","teal-100":"#a5e9ed","teal-600":"#006776","purple-100":"#d7cfff","purple-700":"#5f2fe9","green-200":"#a4d7aa","green-500":"#38b319","green-800":"#2b3c2f","grey-100":"#f0f0f0","light-50":"rgba(255, 255, 255, .05)","light-100":"rgba(255, 255, 255, .1)","light-200":"rgba(255, 255, 255, .2)","light-400":"rgba(255, 255, 255, .4)","light-500":"rgba(255, 255, 255, .5)","light-640":"rgba(255, 255, 255, .64)","light-800":"rgba(255, 255, 255, .8)","light-1000":"#fff","dark-50":"rgba(0, 0, 0, .05)","dark-80":"rgba(0, 0, 0, .08)","dark-100":"rgba(0, 0, 0, .1)","dark-200":"rgba(0, 0, 0, .2)","dark-250":"rgba(0, 0, 0, .25)","dark-400":"rgba(0, 0, 0, .4)","dark-500":"rgba(0, 0, 0, .5)","dark-640":"rgba(0, 0, 0, .64)","dark-800":"rgba(0, 0, 0, .8)","dark-900":"rgba(0, 0, 0, .9)","dark-1000":"#000"},b0={colors:ve,space:{xxs:".25rem",xs:".5rem",small:".75rem",medium:"1rem",large:"1.5rem",xl:"2.5rem"},sizes:{xxs:"1rem",xs:"1.5rem",small:"2rem",medium:"2.5rem",large:"3rem"},fontWeights:{regular:400,semibold:500,bold:700},lineHeights:{small:1.1,medium:1.25,large:1.4},letterSpacings:{xxs:"-.04rem",xs:"-.03rem",small:"-.02rem",medium:"-.01rem",large:0},fontSizes:{micro:".625rem",small:".75rem",medium:".875rem",large:"1rem",xl:"1.25rem",xxl:"1.5rem",xxxl:"2rem",huge:"2.75rem"},fontFamilies:{sans:'Roobert, "Times New Roman", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,"Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',mono:'"Maison Neue Mono", Menlo, Monaco, Consolas, Liberation Mono, "Courier New", monospace'},borderWidths:{thin:".0625rem"},radii:{small:".25rem",medium:".5rem",large:".75rem",xl:"1rem"},shadows:{small:`.25rem .25rem .25rem ${ve["dark-100"]}`,medium:`0 .125rem .625rem ${ve["dark-100"]}`,large:`0 .25rem 1rem ${ve["dark-50"]}`,xl:`.25rem .25rem 1rem ${ve["dark-250"]}`,xxl:`0 .25rem 2rem ${ve["dark-100"]}`,xxxl:`.25rem .25rem 3rem ${ve["dark-250"]}`,toolbar:`0 -.625rem .625rem ${ve["dark-50"]}`,text:`0 0 .25rem ${ve["dark-250"]}`},timings:{fast:".1s",normal:".2s",slow:".3s"},easings:{linear:"linear"},focusOutline:{width:".2rem",color:ve["dark-400"]},iconSizes:{small:"0.75rem",medium:"1rem",large:"1.5rem"}},Vd=sf.flatten(b0,{delimiter:"-"}),A0=Object.keys(Vd).map(r=>Hi(`:host { --${r}: ${Vd[r]}; }`)),T0=r=>{class t extends r{firstUpdated(){if(document.querySelectorAll("#vmp-embedded-font-futura").length<=0){const i=document.createElement("style");i.setAttribute("id","vmp-embedded-font-futura"),i.innerHTML=g0,document.head.appendChild(i)}if(document.querySelectorAll("#vmp-embedded-font-cisco-sans").length<=0){const i=document.createElement("style");i.setAttribute("id","vmp-embedded-font-cisco-sans"),i.innerHTML=m0,document.head.appendChild(i)}{const i=document.querySelectorAll("#vmp-embedded-font-roobert-normal"),s=document.querySelectorAll("#vmp-embedded-font-roobert-semibold");if(i.length<=0){const n=document.createElement("style");n.setAttribute("id","vmp-embedded-font-roobert-normal"),n.innerHTML=v0,document.head.appendChild(n)}if(s.length<=0){const n=document.createElement("style");n.setAttribute("id","vmp-embedded-font-roobert-semibold"),n.innerHTML=y0,document.head.appendChild(n)}}}}return t.styles=[(r==null?void 0:r.styles)??[],A0,Mt`
|
215
215
|
:host {
|
216
216
|
font-family: var(--fontFamilies-sans);
|
217
217
|
font-size: var(--fontSizes-medium);
|
@@ -292,7 +292,7 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
292
292
|
scroll-behavior: auto !important;
|
293
293
|
}
|
294
294
|
}
|
295
|
-
`],t},ot=T0(vi),E0=(
|
295
|
+
`],t},ot=T0(vi),E0=(r,t)=>(typeof window<"u"&&(window.customElements.get(r)??window.customElements.define(r,t)),t),w0=(r,t)=>{const{kind:e,elements:i}=t;return{kind:e,elements:i,finisher(s){typeof window<"u"&&(window.customElements.get(r)??window.customElements.define(r,s))}}},Yt=r=>t=>typeof t=="function"?E0(r,t):w0(r,t);class S0 extends is{constructor(t){if(super(t),t.type!==yi.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}update(t,[e]){return e==null||e(t.element),se}}const jd=bi(S0);class L0{constructor(t){this.hiddenControls=[],this._measureRef=re(),this._prevControlsWidth=0,this._hideables={},this._showables={},this._onResize=e=>{var i,s,n;const a=this._measureRef.value,o=(n=(s=(i=e==null?void 0:e[0])==null?void 0:i.borderBoxSize)==null?void 0:s[0])==null?void 0:n.inlineSize;if(a&&o&&o!==this._prevControlsWidth){Object.keys(this._hideables).forEach(h=>{this._hideables[h].element.style.display=""}),Object.keys(this._showables).forEach(h=>{this._showables[h].element.style.display="none"});const l=[];for(;a.scrollWidth>a.offsetWidth;){const h=Object.keys(this._hideables).find(d=>this._hideables[d].hideIndex===l.length);if(h){const d=this._hideables[h].element;d&&(d.style.display="none"),l.push(h)}Object.keys(this._showables).forEach(d=>{this._showables[d].showOn.some(c=>l.includes(c))&&(this._showables[d].element.style.display="flex")})}this.hiddenControls=l,this._prevControlsWidth=o,this.host.requestUpdate()}},this.host=t}measure(){return ne(this._measureRef)}contain(){return Sr(this._onResize)}hide(t,e){return jd(i=>{this._hideables[t]={element:i,hideIndex:e}})}show(t,e){return jd(i=>{this._showables[t]={element:i,showOn:e}})}}function zd(r,t={}){const e=Math.max(0,r||0),i=Math.floor(e/3600),s=Math.floor(e%3600/60),n=Math.floor(e%3600%60),a=Math.floor(e%1*1e3);let o=i?`${i}:${`${s}`.padStart(2,"0")}:${`${n}`.padStart(2,"0")}`:`${s}:${`${n}`.padStart(2,"0")}`;return t.includeMs&&(o+=`:${`${a}`.padStart(3,"0")}`),o}var R0=Object.defineProperty,x0=Object.getOwnPropertyDescriptor,Ii=(r,t,e,i)=>{for(var s=i>1?void 0:i?x0(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&R0(t,e,s),s};let Be=class extends ot{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return _`<button
|
296
296
|
class=${ht({active:this.active,"size-tiny":this.size==="tiny","size-small":this.size==="small","size-large":this.size==="large","radius-medium":this.rounded==="medium","radius-full":this.rounded==="full","weight-light":this.weight==="light","weight-heavy":this.weight==="heavy"})}
|
297
297
|
>
|
298
298
|
<slot></slot>
|
@@ -373,7 +373,7 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
373
373
|
.weight-light:focus {
|
374
374
|
background: #9d9d9d;
|
375
375
|
}
|
376
|
-
`],Ii([
|
376
|
+
`],Ii([j({type:Boolean})],Be.prototype,"active",2),Ii([j({type:String})],Be.prototype,"size",2),Ii([j({type:String})],Be.prototype,"rounded",2),Ii([j({type:String})],Be.prototype,"weight",2),Ii([j({type:String})],Be.prototype,"icon",2),Be=Ii([Yt("vmp-button")],Be);const Kd={"arrow-left":()=>_`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
|
377
377
|
<path
|
378
378
|
d="M16.6666 9.21875H6.52492L11.1833 4.85156L9.99992 3.75L3.33325 10L9.99992 16.25L11.1749 15.1484L6.52492 10.7812H16.6666V9.21875Z"
|
379
379
|
fill="currentColor"
|
@@ -529,23 +529,23 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
529
529
|
<path
|
530
530
|
d="M9.853 23.246L4.86 7.688H0L7 27.42h5.52l7.265-19.733h-4.65L9.854 23.246zM95.12 7.08a8.905 8.905 0 00-4.648 1.294V0H86.14v27.419h4.332V16.087a4.656 4.656 0 014.649-4.65 4.656 4.656 0 014.649 4.65v11.332h4.332V16.087c.026-4.966-4.015-9.008-8.981-9.008zM57.188 19.02a4.656 4.656 0 01-4.649 4.649 4.656 4.656 0 01-4.649-4.65V7.689h-4.332V19.02c0 4.966 4.041 8.98 8.981 8.98 4.94 0 8.981-4.04 8.981-8.98V7.688h-4.332V19.02zM30.483 7.133c-5.732 0-10.408 4.675-10.408 10.407s4.676 10.408 10.408 10.408c5.732 0 10.408-4.676 10.408-10.408 0-5.732-4.676-10.407-10.408-10.407zm0 16.483a6.076 6.076 0 116.075-6.076c0 3.355-2.747 6.076-6.075 6.076zM74.517 23.616a6.076 6.076 0 010-12.151 6.132 6.132 0 015.045 2.668l3.592-2.43a10.473 10.473 0 00-8.637-4.57c-5.732 0-10.408 4.675-10.408 10.407s4.676 10.408 10.408 10.408a10.35 10.35 0 008.611-4.596l-3.593-2.43a5.975 5.975 0 01-5.018 2.694z"
|
531
531
|
/>
|
532
|
-
</svg>`};var k0=Object.defineProperty,D0=Object.getOwnPropertyDescriptor,Wd=(
|
532
|
+
</svg>`};var k0=Object.defineProperty,D0=Object.getOwnPropertyDescriptor,Wd=(r,t,e,i)=>{for(var s=i>1?void 0:i?D0(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&k0(t,e,s),s};let Lr=class extends ot{render(){return!this.icon||!Object.keys(Kd).includes(this.icon)?null:Kd[this.icon]()}};Lr.styles=[ot.styles??[],Mt`
|
533
533
|
:host {
|
534
534
|
display: flex;
|
535
535
|
align-items: center;
|
536
536
|
justify-content: center;
|
537
537
|
flex-shrink: 0;
|
538
538
|
}
|
539
|
-
`],Wd([
|
539
|
+
`],Wd([j({type:String})],Lr.prototype,"icon",2),Lr=Wd([Yt("vmp-icon")],Lr);var C0=Object.defineProperty,I0=Object.getOwnPropertyDescriptor,Pi=(r,t,e,i)=>{for(var s=i>1?void 0:i?I0(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&C0(t,e,s),s};let He=class extends ot{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return _`
|
540
540
|
<vmp-button
|
541
541
|
?active=${this.active}
|
542
|
-
size=${
|
543
|
-
rounded=${
|
544
|
-
weight=${
|
542
|
+
size=${ss(this.size)}
|
543
|
+
rounded=${ss(this.rounded)}
|
544
|
+
weight=${ss(this.weight)}
|
545
545
|
>
|
546
546
|
<vmp-icon
|
547
547
|
class=${ht({tiny:this.size==="tiny",small:this.size==="small",large:this.size==="large"})}
|
548
|
-
icon=${
|
548
|
+
icon=${ss(this.icon)}
|
549
549
|
></vmp-icon>
|
550
550
|
</vmp-button>
|
551
551
|
`}};He.styles=[ot.styles??[],Mt`
|
@@ -563,8 +563,8 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
563
563
|
height: 32px;
|
564
564
|
width: 32px;
|
565
565
|
}
|
566
|
-
`],Pi([
|
567
|
-
`;var P0=Object.defineProperty,O0=Object.getOwnPropertyDescriptor,Oi=(
|
566
|
+
`],Pi([j({type:Boolean})],He.prototype,"active",2),Pi([j({type:String})],He.prototype,"size",2),Pi([j({type:String})],He.prototype,"rounded",2),Pi([j({type:String})],He.prototype,"weight",2),Pi([j({type:String})],He.prototype,"icon",2),He=Pi([Yt("vmp-icon-button")],He);const Oa=`.tippy-box[data-animation=shift-away-subtle][data-state=hidden]{opacity:0}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=top]{transform:translateY(5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=bottom]{transform:translateY(-5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=left]{transform:translate(5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=right]{transform:translate(-5px)}
|
567
|
+
`;var P0=Object.defineProperty,O0=Object.getOwnPropertyDescriptor,Oi=(r,t,e,i)=>{for(var s=i>1?void 0:i?O0(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&P0(t,e,s),s};let Ge=class extends ot{constructor(){super(...arguments),this.bold=!1,this.semibold=!1,this.truncate=!1,this.size="medium",this.content=""}render(){return _`
|
568
568
|
<div
|
569
569
|
part="content"
|
570
570
|
class=${ht({bold:this.bold,semibold:this.semibold,truncate:this.truncate,[this.size]:!0})}
|
@@ -613,20 +613,20 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
613
613
|
text-overflow: ellipsis;
|
614
614
|
overflow: hidden;
|
615
615
|
}
|
616
|
-
`],Oi([
|
616
|
+
`],Oi([j({type:Boolean})],Ge.prototype,"bold",2),Oi([j({type:Boolean})],Ge.prototype,"semibold",2),Oi([j({type:Boolean})],Ge.prototype,"truncate",2),Oi([j({type:String})],Ge.prototype,"size",2),Oi([j({type:String})],Ge.prototype,"content",2),Ge=Oi([Yt("vmp-text")],Ge);var M0=Object.defineProperty,F0=Object.getOwnPropertyDescriptor,Ve=(r,t,e,i)=>{for(var s=i>1?void 0:i?F0(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&M0(t,e,s),s};const Ma=1.2;let ye=class extends ot{constructor(){super(...arguments),this.bold=!1,this.semibold=!1,this.content="",this.minFontSize=16,this.maxFontSize=32,this.fontSize=this.minFontSize,this.lines=void 0,this._textRef=re(),this._handleResize=()=>{if(this.lines=void 0,this._textRef.value){let r=this.fontSize;for(;r<this.minFontSize||r<=this.maxFontSize-2&&this._textRef.value.scrollHeight===this._textRef.value.offsetHeight;)r=r+2,this._textRef.value.style.fontSize=`${r}px`;for(;r>this.maxFontSize||r>=this.minFontSize+2&&this._textRef.value.scrollHeight>this._textRef.value.offsetHeight;)r=r-2,this._textRef.value.style.fontSize=`${r}px`;this.fontSize=r,this._textRef.value.scrollHeight>this._textRef.value.offsetHeight&&(this.lines=Math.floor(this._textRef.value.offsetHeight/(this.fontSize*Ma)))}}}updated(r){(r.has("minFontSize")||r.has("maxFontSize")||r.has("content"))&&this._handleResize()}render(){return _`
|
617
617
|
<span
|
618
618
|
${ne(this._textRef)}
|
619
|
-
${
|
620
|
-
style=${
|
619
|
+
${Sr(this._handleResize)}
|
620
|
+
style=${Mp({fontSize:`${this.fontSize}px`,lineHeight:Ma,"-webkit-line-clamp":this.lines})}
|
621
621
|
part="content"
|
622
622
|
class=${ht({bold:this.bold,semibold:this.semibold})}
|
623
623
|
>
|
624
624
|
${this.content}
|
625
625
|
</span>
|
626
|
-
`}};
|
626
|
+
`}};ye.styles=[ot.styles??[],Mt`
|
627
627
|
:host {
|
628
628
|
--text-size: var(--fontSizes-medium);
|
629
|
-
--text-line-height: ${
|
629
|
+
--text-line-height: ${Ma};
|
630
630
|
--text-weight: var(--fontWeights-regular);
|
631
631
|
|
632
632
|
display: flex;
|
@@ -656,7 +656,7 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
656
656
|
.semibold {
|
657
657
|
--text-weight: var(--fontWeights-semibold);
|
658
658
|
}
|
659
|
-
`],Ve([
|
659
|
+
`],Ve([j({type:Boolean})],ye.prototype,"bold",2),Ve([j({type:Boolean})],ye.prototype,"semibold",2),Ve([j({type:String})],ye.prototype,"content",2),Ve([j({type:Number})],ye.prototype,"minFontSize",2),Ve([j({type:Number})],ye.prototype,"maxFontSize",2),Ve([Bt()],ye.prototype,"fontSize",2),Ve([Bt()],ye.prototype,"lines",2),ye=Ve([Yt("vmp-responsive-text")],ye);var N0=Object.defineProperty,U0=Object.getOwnPropertyDescriptor,Es=(r,t,e,i)=>{for(var s=i>1?void 0:i?U0(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&N0(t,e,s),s};let li=class extends ot{constructor(){super(...arguments),this.activeItems=[],this.visibleItems=null,this.subItemsActive=null,this.tippy=null,this._contentRef=re()}_handleBackClick(){this.subItemsActive=null,this.visibleItems=this.items??null}willUpdate(){this.visibleItems=this.visibleItems??this.items??null}updated(){var r,t;const e=(t=(r=this.items)==null?void 0:r.items.find(({id:i})=>this.subItemsActive===i))==null?void 0:t.subItems;this.visibleItems=e??this.items??null,e||(this.subItemsActive=null)}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var r;const t=(r=this.shadowRoot)==null?void 0:r.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=si(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!0,placement:"top",trigger:"click",onShow:()=>{this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!0}))},onHide:()=>{this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!1}))},appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var r;super.disconnectedCallback(),(r=this.tippy)==null||r.destroy()}render(){var r,t;return _`
|
660
660
|
<slot></slot>
|
661
661
|
<div ${ne(this._contentRef)} class="content">
|
662
662
|
<div class="title">
|
@@ -669,7 +669,7 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
669
669
|
?bold=${!0}
|
670
670
|
?truncate=${!0}
|
671
671
|
size="small"
|
672
|
-
.content=${((
|
672
|
+
.content=${((r=this.visibleItems)==null?void 0:r.title)??"Sub Menu"}
|
673
673
|
></vmp-text>
|
674
674
|
</div>
|
675
675
|
${hl(((t=this.visibleItems)==null?void 0:t.items)??[],({id:e})=>e,e=>_`
|
@@ -682,7 +682,7 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
682
682
|
</button>
|
683
683
|
`)}
|
684
684
|
</div>
|
685
|
-
`}};li.styles=[ot.styles??[],Hi(
|
685
|
+
`}};li.styles=[ot.styles??[],Hi(Oa),Mt`
|
686
686
|
:host {
|
687
687
|
display: flex;
|
688
688
|
}
|
@@ -740,12 +740,12 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
740
740
|
height: 20px;
|
741
741
|
width: 20px;
|
742
742
|
}
|
743
|
-
`],
|
743
|
+
`],Es([j({type:Object})],li.prototype,"items",2),Es([j({type:Array})],li.prototype,"activeItems",2),Es([Bt()],li.prototype,"visibleItems",2),Es([Bt()],li.prototype,"subItemsActive",2),li=Es([Yt("vmp-menu")],li);var B0=Object.defineProperty,H0=Object.getOwnPropertyDescriptor,Fa=(r,t,e,i)=>{for(var s=i>1?void 0:i?H0(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&B0(t,e,s),s};let ws=class extends ot{constructor(){super(...arguments),this.content="",this.disabled=!1,this.tippy=null,this._contentRef=re()}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var r;const t=(r=this.shadowRoot)==null?void 0:r.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=si(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!1,placement:"top",zIndex:1e4,appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var r;super.disconnectedCallback(),(r=this.tippy)==null||r.destroy()}updated(){var r,t;this.disabled?(r=this.tippy)==null||r.disable():(t=this.tippy)==null||t.enable()}render(){return _`
|
744
744
|
<slot></slot>
|
745
745
|
<div ${ne(this._contentRef)} class="content">
|
746
746
|
<vmp-text content=${this.content}></vmp-text>
|
747
747
|
</div>
|
748
|
-
`}};
|
748
|
+
`}};ws.styles=[ot.styles??[],Hi(Oa),Mt`
|
749
749
|
:host {
|
750
750
|
display: flex;
|
751
751
|
}
|
@@ -759,19 +759,19 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
759
759
|
background: var(--colors-dark-800);
|
760
760
|
border-radius: var(--radii-medium);
|
761
761
|
}
|
762
|
-
`],
|
762
|
+
`],Fa([j({type:String})],ws.prototype,"content",2),Fa([j({type:Boolean})],ws.prototype,"disabled",2),ws=Fa([Yt("vmp-tooltip")],ws);var G0=Object.defineProperty,V0=Object.getOwnPropertyDescriptor,Na=(r,t,e,i)=>{for(var s=i>1?void 0:i?V0(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&G0(t,e,s),s};let Ss=class extends ot{constructor(){super(...arguments),this.volume=1,this.muted=!1,this.tippy=null,this._contentRef=re(),this._anchorRef=re(),this._menuOpen=!1}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{this._anchorRef.value&&this._contentRef.value&&(this.tippy=si(this._anchorRef.value,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!0,placement:"top",interactiveBorder:20,onShow:()=>{this._menuOpen=!0,this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!0}))},onHide:()=>{this._menuOpen=!1,this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!1}))},appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var r;super.disconnectedCallback(),(r=this.tippy)==null||r.destroy()}render(){return _`
|
763
763
|
<vmp-icon-button
|
764
764
|
${ne(this._anchorRef)}
|
765
765
|
icon=${this.muted||this.volume===0?"muted":this.volume<1/3?"volume-low":this.volume<2/3?"volume-medium":"volume-high"}
|
766
766
|
weight="heavy"
|
767
767
|
rounded="full"
|
768
|
-
@pointerdown=${
|
768
|
+
@pointerdown=${r=>{this._menuOpen&&r.preventDefault()}}
|
769
769
|
@click=${()=>{this._menuOpen&&this.dispatchEvent(new CustomEvent("volume:click",{bubbles:!0,composed:!0,detail:this.muted}))}}
|
770
770
|
></vmp-icon-button>
|
771
771
|
<div ${ne(this._contentRef)} class="content">
|
772
772
|
<input key="volume" type="range" min="0" max="1" step="0.01" .value=${this.volume.toString()} />
|
773
773
|
</div>
|
774
|
-
`}};
|
774
|
+
`}};Ss.styles=[ot.styles??[],Hi(Oa),Mt`
|
775
775
|
.content {
|
776
776
|
--volume-slider-height: 4px;
|
777
777
|
--volume-slider-width: 78px;
|
@@ -899,7 +899,7 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
899
899
|
--volume-slider-height: 8px;
|
900
900
|
color: var(--colors-light-800);
|
901
901
|
}
|
902
|
-
`],
|
902
|
+
`],Na([j({type:Number})],Ss.prototype,"volume",2),Na([j({type:Boolean})],Ss.prototype,"muted",2),Ss=Na([Yt("vmp-volume-button")],Ss);var j0=Object.defineProperty,z0=Object.getOwnPropertyDescriptor,Rr=(r,t,e,i)=>{for(var s=i>1?void 0:i?z0(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&j0(t,e,s),s};let Mi=class extends ot{constructor(){super(...arguments),this.duration=0,this.currentTime=0,this.buffer=[]}render(){var r;const t=((r=this.buffer)==null?void 0:r.sort((e,i)=>e.start<i.start?-1:i.start<e.start?1:0).reduce((e,{start:i,end:s},n)=>{const a=e[n-1],o=Math.floor(i),l=Math.ceil(s);return e.push({id:i,start:Math.max(0,o),end:Math.min(l,100)}),a&&a.end>=i-1&&(e[n].start=a.end),e},[]))??[];return _`
|
903
903
|
<div class="container">
|
904
904
|
<input
|
905
905
|
key="scrubber"
|
@@ -1048,11 +1048,11 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
1048
1048
|
--player-scrubber-height: 16px;
|
1049
1049
|
color: var(--colors-light-800);
|
1050
1050
|
}
|
1051
|
-
`],
|
1051
|
+
`],Rr([j({type:Number})],Mi.prototype,"duration",2),Rr([j({type:Number})],Mi.prototype,"currentTime",2),Rr([j({type:Array})],Mi.prototype,"buffer",2),Mi=Rr([Yt("vmp-progress-scrubber")],Mi);var K0=Object.defineProperty,W0=Object.getOwnPropertyDescriptor,It=(r,t,e,i)=>{for(var s=i>1?void 0:i?W0(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&K0(t,e,s),s};let wt=class extends ot{constructor(){super(...arguments),this.resizeHider=new L0(this),this.playing=!1,this.volume=1,this.muted=!1,this.currentTime=0,this.duration=0,this.level=-1,this.playbackRate=1,this.buffer=[],this.levels=[],this.captions=!1,this.fullscreen=!1,this.controls=Pa,this.volumeMenuOpen=!1,this.levelsMenuOpen=!1,this.playbackRateMenuOpen=!1,this.settingsMenuOpen=!1}_handleNavigateBackClick(){this.dispatchEvent(new CustomEvent("navigate:back",{bubbles:!0,composed:!0}))}_handleNavigateForwardClick(){this.dispatchEvent(new CustomEvent("navigate:forward",{bubbles:!0,composed:!0}))}_handlePlayClick(){this.dispatchEvent(new CustomEvent("play:click",{bubbles:!0,composed:!0,detail:this.playing}))}_handleCaptionsClick(){this.dispatchEvent(new CustomEvent("captions:click",{bubbles:!0,composed:!0,detail:this.captions}))}_handleFullscreenClick(){this.dispatchEvent(new CustomEvent("fullscreen:click",{bubbles:!0,composed:!0,detail:this.fullscreen}))}_handleVolumeMenuToggle({detail:r}){this.volumeMenuOpen=r}_handleLevelsMenuOpen({detail:r}){this.levelsMenuOpen=r}_handlePlaybackMenuToggle({detail:r}){this.playbackRateMenuOpen=r}_handleSettingsMenuToggle({detail:r}){this.settingsMenuOpen=r}hideMenus(){var r,t;(t=Array.from((r=this.shadowRoot)==null?void 0:r.querySelectorAll("vmp-menu, vmp-tooltip, vmp-volume-button")))==null||t.forEach(e=>{var i;(i=e.tippy)==null||i.hide()})}render(){var r,t,e,i,s,n,a,o,l,h,d,c,u;const f=((r=this.levels)==null?void 0:r.map((w,I)=>{const B=Math.min(w.width,w.height);return{id:`level-${I.toString()}`,event:"level:click",label:`${B}p`,value:{resolution:B,level:I}}}))??[],p={title:"Quality",items:[...f.reverse(),{id:"level--1",event:"level:click",label:"Auto",value:{level:-1,resolution:"auto"}}]},g={id:"levels",label:"Quality",subItems:p},m=(t=p.items)==null?void 0:t.find(({value:w})=>w.level===this.level),b=["levels","playback-rate","captions","fullscreen"].filter(w=>{var I;return(I=this.controls)==null?void 0:I.includes(w)}),A={title:"Settings",items:[c0,u0,g,f0].filter(({id:w})=>b.includes(w)&&this.resizeHider.hiddenControls.includes(w))},T=(e=this.controls)==null?void 0:e.includes("progress"),y=(i=this.controls)==null?void 0:i.includes("navigation"),E=(s=this.controls)==null?void 0:s.includes("play"),S=(n=this.controls)==null?void 0:n.includes("volume"),L=(a=this.controls)==null?void 0:a.includes("current-time"),D=(o=this.controls)==null?void 0:o.includes("duration"),k=(l=this.controls)==null?void 0:l.includes("levels"),x=(h=this.controls)==null?void 0:h.includes("speed"),F=(d=this.controls)==null?void 0:d.includes("captions"),O=(c=this.controls)==null?void 0:c.includes("fullscreen"),G=E||S||L||D||k||x||F||O,W=[`level-${(u=this.level)==null?void 0:u.toString()}`,`playback-rate-${this.playbackRate.toString()}`,this.captions&&"captions",this.fullscreen&&"fullscreen"].filter(Boolean);return _`
|
1052
1052
|
<div
|
1053
1053
|
${this.resizeHider.measure()}
|
1054
1054
|
${this.resizeHider.contain()}
|
1055
|
-
class=${ht({container:!0,hidden:!T&&!
|
1055
|
+
class=${ht({container:!0,hidden:!T&&!G})}
|
1056
1056
|
>
|
1057
1057
|
<div
|
1058
1058
|
class=${ht({"scrubber-container":!0,hidden:!T})}
|
@@ -1066,7 +1066,7 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
1066
1066
|
</div>
|
1067
1067
|
<div
|
1068
1068
|
${this.resizeHider.contain()}
|
1069
|
-
class=${ht({buttons:!0,hidden:!
|
1069
|
+
class=${ht({buttons:!0,hidden:!G})}
|
1070
1070
|
>
|
1071
1071
|
<div class="section">
|
1072
1072
|
<div
|
@@ -1087,7 +1087,7 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
1087
1087
|
></vmp-icon-button>
|
1088
1088
|
</div>
|
1089
1089
|
<vmp-icon-button
|
1090
|
-
class=${ht({hidden:!
|
1090
|
+
class=${ht({hidden:!E})}
|
1091
1091
|
icon=${this.playing?"pause":"play"}
|
1092
1092
|
weight="heavy"
|
1093
1093
|
rounded="full"
|
@@ -1105,11 +1105,11 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
1105
1105
|
${this.resizeHider.hide("current-time",1)}
|
1106
1106
|
class=${ht({hidden:!L})}
|
1107
1107
|
?bold=${!0}
|
1108
|
-
content="${zd(this.currentTime)}${
|
1108
|
+
content="${zd(this.currentTime)}${D?"/":null}"
|
1109
1109
|
></vmp-text>
|
1110
1110
|
<vmp-text
|
1111
1111
|
${this.resizeHider.hide("duration",5)}
|
1112
|
-
class=${ht({hidden:!
|
1112
|
+
class=${ht({hidden:!D})}
|
1113
1113
|
?bold=${!0}
|
1114
1114
|
content=${zd(this.duration)}
|
1115
1115
|
></vmp-text>
|
@@ -1142,7 +1142,7 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
1142
1142
|
</vmp-menu>
|
1143
1143
|
<vmp-tooltip
|
1144
1144
|
${this.resizeHider.hide("captions",3)}
|
1145
|
-
class=${ht({hidden:!
|
1145
|
+
class=${ht({hidden:!F})}
|
1146
1146
|
content="Captions"
|
1147
1147
|
>
|
1148
1148
|
<vmp-icon-button
|
@@ -1249,17 +1249,17 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
1249
1249
|
.hidden {
|
1250
1250
|
display: none;
|
1251
1251
|
}
|
1252
|
-
`],It([
|
1252
|
+
`],It([j({type:Boolean})],wt.prototype,"playing",2),It([j({type:Number})],wt.prototype,"volume",2),It([j({type:Boolean})],wt.prototype,"muted",2),It([j({type:Number})],wt.prototype,"currentTime",2),It([j({type:Number})],wt.prototype,"duration",2),It([j({type:Number})],wt.prototype,"level",2),It([j({type:Number})],wt.prototype,"playbackRate",2),It([j({type:Array})],wt.prototype,"buffer",2),It([j({type:Array,attribute:!1})],wt.prototype,"levels",2),It([j({type:Boolean})],wt.prototype,"captions",2),It([j({type:Boolean})],wt.prototype,"fullscreen",2),It([j({type:Array})],wt.prototype,"controls",2),It([Bt()],wt.prototype,"volumeMenuOpen",2),It([Bt()],wt.prototype,"levelsMenuOpen",2),It([Bt()],wt.prototype,"playbackRateMenuOpen",2),It([Bt()],wt.prototype,"settingsMenuOpen",2),wt=It([Yt("vmp-player-controls")],wt);var Y0=Object.defineProperty,X0=Object.getOwnPropertyDescriptor,q0=(r,t,e,i)=>{for(var s=i>1?void 0:i?X0(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&Y0(t,e,s),s};let Ua=class extends ot{render(){return _`<vmp-icon icon="loading"></vmp-icon>`}};Ua.styles=[ot.styles??[],Mt`
|
1253
1253
|
:host {
|
1254
1254
|
display: flex;
|
1255
1255
|
align-items: center;
|
1256
1256
|
justify-content: center;
|
1257
1257
|
}
|
1258
|
-
`],
|
1258
|
+
`],Ua=q0([Yt("vmp-loading-spinner")],Ua);var Z0=Object.defineProperty,J0=Object.getOwnPropertyDescriptor,Yd=(r,t,e,i)=>{for(var s=i>1?void 0:i?J0(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&Z0(t,e,s),s};let xr=class extends ot{constructor(){super(...arguments),this.caption=""}render(){return _`
|
1259
1259
|
<div class="container">
|
1260
1260
|
<vmp-text content=${this.caption} size="large"></vmp-text>
|
1261
1261
|
</div>
|
1262
|
-
`}};
|
1262
|
+
`}};xr.styles=[ot.styles??[],Mt`
|
1263
1263
|
.container {
|
1264
1264
|
display: block;
|
1265
1265
|
margin: 0 var(--space-small);
|
@@ -1278,12 +1278,12 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
1278
1278
|
/* Line height controls the spacing between the cloned boxes so has to override the default */
|
1279
1279
|
line-height: 2.2;
|
1280
1280
|
}
|
1281
|
-
`],Yd([
|
1281
|
+
`],Yd([j({type:String})],xr.prototype,"caption",2),xr=Yd([Yt("vmp-captions")],xr);var Q0=Object.defineProperty,_0=Object.getOwnPropertyDescriptor,Ut=(r,t,e,i)=>{for(var s=i>1?void 0:i?_0(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&Q0(t,e,s),s};const $0=3e3;let Rt=class extends ot{constructor(){super(...arguments),this.loading=!1,this.playing=!1,this.volume=1,this.muted=!1,this.currentTime=0,this.duration=0,this.levels=[],this.level=-1,this.playbackRate=1,this.caption="",this.buffer=[],this.captions=!1,this.fullscreen=!1,this.controls=Pa,this.showControls=!0,this._hasTouched=!1,this._playerControlsRef=re()}_startHideControls(){clearTimeout(this._controlHideTimeout),this._controlHideTimeout=setTimeout(()=>{this.showControls=!1,this._hasTouched=!1},$0)}_immediateShowControls(){this.showControls=!0,clearTimeout(this._controlHideTimeout)}_immediateHideControls(){this.showControls=!1,this._hasTouched=!1,clearTimeout(this._controlHideTimeout)}willUpdate(r){var t;r.has("showControls")&&this.playing&&!this.showControls&&((t=this._playerControlsRef.value)==null||t.hideMenus())}render(){var r;const t=(r=this.controls)==null?void 0:r.includes("play-large"),e=this.playing&&!this.showControls,i=!!(t&&!this.playing);return _`
|
1282
1282
|
<div
|
1283
1283
|
class=${ht({container:!0,hide:e})}
|
1284
1284
|
@mousemove=${()=>{this._immediateShowControls(),this._startHideControls()}}
|
1285
1285
|
@mouseleave=${this._immediateHideControls}
|
1286
|
-
@touchstart=${
|
1286
|
+
@touchstart=${s=>{this.playing&&!this.showControls&&!this._hasTouched&&(s.preventDefault(),this._hasTouched=!0,this._immediateShowControls(),this._startHideControls())}}
|
1287
1287
|
>
|
1288
1288
|
<div
|
1289
1289
|
class=${ht({fixtures:!0,invisible:!this.loading&&!i})}
|
@@ -1300,7 +1300,7 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
1300
1300
|
<div
|
1301
1301
|
class=${ht({controls:!0,hide:e})}
|
1302
1302
|
@focusin=${this._immediateShowControls}
|
1303
|
-
@mousemove=${
|
1303
|
+
@mousemove=${s=>{s.stopPropagation(),this._immediateShowControls()}}
|
1304
1304
|
@click=${this._immediateShowControls}
|
1305
1305
|
>
|
1306
1306
|
${this.captions?_`<vmp-captions
|
@@ -1324,7 +1324,7 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
1324
1324
|
></vmp-player-controls>
|
1325
1325
|
</div>
|
1326
1326
|
</div>
|
1327
|
-
`}};
|
1327
|
+
`}};Rt.styles=[ot.styles??[],Mt`
|
1328
1328
|
:host {
|
1329
1329
|
--overlay-border-radius: var(--player-border-radius, 0px);
|
1330
1330
|
}
|
@@ -1396,49 +1396,49 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
1396
1396
|
vmp-captions.hiddenControls {
|
1397
1397
|
transform: translateY(calc(var(--space-small) * -1));
|
1398
1398
|
}
|
1399
|
-
`],Ut([
|
1399
|
+
`],Ut([j({type:Boolean})],Rt.prototype,"loading",2),Ut([j({type:Boolean})],Rt.prototype,"playing",2),Ut([j({type:Number})],Rt.prototype,"volume",2),Ut([j({type:Boolean})],Rt.prototype,"muted",2),Ut([j({type:Number})],Rt.prototype,"currentTime",2),Ut([j({type:Number})],Rt.prototype,"duration",2),Ut([j({type:Array,attribute:!1})],Rt.prototype,"levels",2),Ut([j({type:Number})],Rt.prototype,"level",2),Ut([j({type:Number})],Rt.prototype,"playbackRate",2),Ut([j({type:String})],Rt.prototype,"caption",2),Ut([j({type:Array})],Rt.prototype,"buffer",2),Ut([j({type:Boolean})],Rt.prototype,"captions",2),Ut([j({type:Boolean})],Rt.prototype,"fullscreen",2),Ut([j({type:Array})],Rt.prototype,"controls",2),Ut([Bt()],Rt.prototype,"showControls",2),Rt=Ut([Yt("vmp-player-overlay")],Rt);var ty=Object.defineProperty,ey=Object.getOwnPropertyDescriptor,xt=(r,t,e,i)=>{for(var s=i>1?void 0:i?ey(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&ty(t,e,s),s};let vt=class extends ot{constructor(){super(...arguments),this.burnCaptions=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=Du,this._sceneController=new l0(this),this._drawController=new Np(this),this._wasPlaying=!1,this._manualMute=this.muted,this._seekerRAF=null,this._lastWaiting=!1,this._lastTimestamp=null,this._lastTimeUpdate=null,this._playerRef=re(),this._canvasRef=re(),this._aspectRatio=this.propAspectRatio,this._waiting=!1,this._stalled=!1,this._seeking=!1,this._captions=!1,this._fullscreen=!1,this._paused=!0,this._playbackRate=1,this._volume=null,this._muted=null,this._videoResolution=-1,this._handleContainerResize=()=>{this._playerRef.value&&(this.propAspectRatio||(this._aspectRatio=this._playerRef.value.offsetWidth/this._playerRef.value.offsetHeight))},this._handleCanvasResize=()=>{this.draw()},this._seeker=r=>{var t;this.sceneConfig&&this.scenes.length>0&&(this._waiting=this._drawController.activeScenes.some(({video:e})=>{if(e){const i=this._sceneController.videoState[e.id];return!i||!i.initialised||i.waiting}}),this.waiting?(this._lastTimestamp=null,this._lastWaiting||this.dispatchEvent(new CustomEvent("waiting"))):this._lastWaiting&&this.dispatchEvent(new CustomEvent("playing")),!this.stalled&&r-(this._lastTimestamp??0)>1e3/this.sceneConfig.frameRate&&(this._drawController.currentTime=this._drawController.currentTime+(r-(this._lastTimestamp??r))/1e3*this.playbackRate,this._lastTimestamp=r),this._lastWaiting=this._waiting,this._drawController.currentTime>=this.duration&&(this.pause(),this.dispatchEvent(new CustomEvent("ended")))),this.paused||((t=this.scene)!=null&&t.video?this._lastTimeUpdate&&r-this._lastTimeUpdate>1e3&&(this._stalled=!0):(this._stalled=!1,this._lastTimeUpdate=r),this._seekerRAF=requestAnimationFrame(this._seeker))},this._handleFullscreenChange=()=>{document.fullscreenElement?this._fullscreen=!0:this._fullscreen=!1}}get aspectRatio(){return this._aspectRatio}get waiting(){return!this.paused&&this._waiting}get stalled(){return this._stalled}get seeking(){return this._seeking}get captions(){return this._captions}get fullscreen(){return this._fullscreen}get processing(){return this._sceneController.processing}get duration(){return this._sceneController.duration}get scene(){return this._drawController.activeScenes[this._drawController.activeScenes.length-1]}get scenes(){var r;return((r=this._sceneController.scenes)==null?void 0:r.scenes)??[]}get sceneConfig(){return this._sceneController.scenes}get videos(){return this._sceneController.videos??{}}get videoState(){return this._sceneController.videoState}set paused(r){r!==this._paused&&(this._paused=r,this.requestUpdate(),this.dispatchEvent(new CustomEvent(r?"pause":"play")))}get paused(){return this._paused}set playbackRate(r){r!==this._playbackRate&&(this._playbackRate=r,this.scenes.forEach(({video:t})=>{t&&(t.node.playbackRate=r)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:r})))}get playbackRate(){return this._playbackRate}set volume(r){const t=Math.min(1,Math.max(0,r));t!==this._volume&&(this.scenes.forEach(({video:e})=>{e&&(e.node.volume=t)}),localStorage.setItem("vmp-player-volume",t.toString()),this._volume=t,t>0&&(this.muted=!1),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:r})))}get volume(){return this._volume??(this._volume=parseFloat(localStorage.getItem("vmp-player-volume")??"1"))}set muted(r){this.scenes.forEach(({video:t})=>{t&&(t.node.muted=r)}),r!==this._muted&&(this._muted=r,localStorage.setItem("vmp-player-muted",r.toString()),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:r?0:this.volume})))}get muted(){return this._muted??(this._muted=this.autoplay||localStorage.getItem("vmp-player-muted")==="true")}set videoResolution(r){r!==this._videoResolution&&(this._videoResolution=r,this.scenes.forEach(({video:t})=>{if(t!=null&&t.hls){const e=t.hls.levels.findIndex(i=>Math.min(i.height,i.width)===r);t.hls.currentLevel=e??-1}}),this.requestUpdate())}get videoResolution(){return this._videoResolution}set currentTime(r){r!==this._drawController.currentTime&&(this._drawController.currentTime=r,this._sceneController.setVideosCurrentTime(r))}get currentTime(){return this._drawController.currentTime}reset(r=0,t=!1){this._lastTimestamp=null,this._drawController.currentTime=r,this._sceneController.setVideosCurrentTime(r),t?this.play():this.pause()}clear(){this._drawController.clear()}play(){this.paused=!1,this._lastTimestamp=null,this._lastTimeUpdate=1/0,this.duration>0&&this._drawController.currentTime>=this.duration&&this.reset(0,!0),this._seekerRAF||(this._seekerRAF=requestAnimationFrame(this._seeker))}pause(){this._seekerRAF&&(cancelAnimationFrame(this._seekerRAF),this._seekerRAF=null),this.paused=!0,this.scenes.forEach(({video:r})=>{r&&r.node.pause()})}draw(r){return this._drawController.draw(r)}setScene(r){var t,e;if((t=this._sceneController)!=null&&t.scenes){const i=(e=this.scenes)==null?void 0:e[r];if(!i)return this.dispatchEvent(new ErrorEvent("error",new Error(`No scene at index: ${r}`)));this.reset(i.start+this._sceneController.scenes.transitionDuration,!this.paused)}}toggleFullscreen(r){r??this.fullscreen?d0():this._playerRef.value&&h0(this._playerRef.value)}connectedCallback(){super.connectedCallback(),document.addEventListener("fullscreenchange",this._handleFullscreenChange),this.addEventListener("video:timeupdate",r=>{this._stalled=!1,this._lastTimeUpdate=r.timeStamp})}willUpdate(){this.propAspectRatio&&(this._aspectRatio=this.propAspectRatio)}updated(r){r.has("_stalled")&&this.stalled&&this.dispatchEvent(new CustomEvent("stalled")),r.has("propAspectRatio")&&!this.propAspectRatio&&this._handleContainerResize()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("fullscreenchange",this._handleFullscreenChange)}render(){var r,t,e,i,s,n;const a=this.loading||this.processing||this.duration<=0,{height:o,width:l}=ts({resolution:((r=this.sceneConfig)==null?void 0:r.resolution)??720,aspectRatio:this.aspectRatio}),h=Object.keys(this.videoState).reduce((p,g)=>p.concat(this.videoState[g].buffered??[]),[...this._drawController.fakeBufferSegments]),d=a?[]:(t=this.controls??Pa)==null?void 0:t.filter(p=>!(p==="fullscreen"&&o0()||p==="navigation"&&(!this.scenes||this.scenes.length<=1))),c=(((e=this.scenes)==null?void 0:e.length)??0)-1,u=((i=this.scenes)==null?void 0:i.findIndex(p=>p===this._drawController.activeScenes[0]))??0,f=(n=(s=this._drawController.activeScenes[0])==null?void 0:s.video)==null?void 0:n.hls;return _`
|
1400
1400
|
<div
|
1401
1401
|
${ne(this._playerRef)}
|
1402
|
-
${
|
1402
|
+
${Sr(this._handleContainerResize)}
|
1403
1403
|
class=${ht({player:!0,responsive:!this.propAspectRatio})}
|
1404
1404
|
>
|
1405
1405
|
<canvas
|
1406
1406
|
${ne(this._canvasRef)}
|
1407
1407
|
${this._drawController.canvas()}
|
1408
|
-
${
|
1409
|
-
height=${
|
1410
|
-
width=${
|
1408
|
+
${Sr(this._handleCanvasResize)}
|
1409
|
+
height=${o}
|
1410
|
+
width=${l}
|
1411
1411
|
></canvas>
|
1412
1412
|
<vmp-player-overlay
|
1413
1413
|
${this._drawController.controls()}
|
1414
|
-
?disabled=${
|
1414
|
+
?disabled=${a}
|
1415
1415
|
?playing=${!this.paused}
|
1416
1416
|
?loading=${this.loading||this.processing||this.waiting||this.stalled}
|
1417
1417
|
?muted=${this.muted}
|
1418
1418
|
volume=${this.volume}
|
1419
1419
|
duration=${this.duration}
|
1420
|
-
.levels=${(
|
1421
|
-
level=${
|
1420
|
+
.levels=${(f==null?void 0:f.levels)??[]}
|
1421
|
+
level=${ss(f!=null&&f.autoLevelEnabled?-1:f==null?void 0:f.currentLevel)}
|
1422
1422
|
playbackRate=${this.playbackRate}
|
1423
1423
|
caption=${this._drawController.caption}
|
1424
|
-
.buffer=${
|
1425
|
-
.controls=${
|
1424
|
+
.buffer=${h}
|
1425
|
+
.controls=${d}
|
1426
1426
|
?captions=${this.captions}
|
1427
1427
|
?fullscreen=${this.fullscreen}
|
1428
|
-
@navigate:back=${
|
1429
|
-
@navigate:forward=${
|
1430
|
-
@play:click=${({detail:
|
1431
|
-
@volume:click=${({detail:
|
1432
|
-
@level:click=${({detail:
|
1433
|
-
@playbackRate:click=${({detail:
|
1428
|
+
@navigate:back=${p=>{p.defaultPrevented||this.setScene(u<=0?c:u-1)}}
|
1429
|
+
@navigate:forward=${p=>{p.defaultPrevented||this.setScene(u>=c?0:u+1)}}
|
1430
|
+
@play:click=${({detail:p})=>{a||(p?this.pause():(this.muted=this._manualMute,this.play()))}}
|
1431
|
+
@volume:click=${({detail:p})=>{this.muted=!p,this._manualMute=!p}}
|
1432
|
+
@level:click=${({detail:p})=>{this.videoResolution=p.value.resolution}}
|
1433
|
+
@playbackRate:click=${({detail:p})=>{this.playbackRate=p.value??1}}
|
1434
1434
|
@captions:click=${()=>{this._captions=!this._captions}}
|
1435
1435
|
@fullscreen:click=${()=>{this.toggleFullscreen()}}
|
1436
|
-
@input=${
|
1437
|
-
@pointerdown=${
|
1438
|
-
@pointerup=${
|
1436
|
+
@input=${p=>{const g=p.composedPath()[0],m=g.getAttribute("key");if(m==="scrubber"){const b=parseFloat(g.value);this._drawController.currentTime=b,this._sceneController.setVideosCurrentTime(b),this.dispatchEvent(new CustomEvent("seeking",{detail:b}))}m==="volume"&&(this.volume=parseFloat(g.value))}}
|
1437
|
+
@pointerdown=${p=>{p.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!0,this._wasPlaying=!this.paused,this.paused||this.pause())}}
|
1438
|
+
@pointerup=${p=>{p.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!1,this._wasPlaying&&(this.play(),this._wasPlaying=!1),this.dispatchEvent(new CustomEvent("seeked",{detail:this._drawController.currentTime})))}}
|
1439
1439
|
></vmp-player-overlay>
|
1440
1440
|
</div>
|
1441
|
-
`}};
|
1441
|
+
`}};vt.styles=[ot.styles??[],Mt`
|
1442
1442
|
:host {
|
1443
1443
|
--player-border-radius: var(--vouch-media-player-border-radius, 0px);
|
1444
1444
|
}
|
@@ -1471,7 +1471,7 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
1471
1471
|
right: 0;
|
1472
1472
|
bottom: 0;
|
1473
1473
|
}
|
1474
|
-
`],
|
1474
|
+
`],xt([j({type:Object})],vt.prototype,"data",2),xt([j({type:Object})],vt.prototype,"template",2),xt([j({type:Boolean})],vt.prototype,"burnCaptions",2),xt([j({type:String})],vt.prototype,"src",2),xt([j({type:String})],vt.prototype,"track",2),xt([j({type:Number,attribute:"aspectratio"})],vt.prototype,"propAspectRatio",2),xt([j({type:String})],vt.prototype,"preload",2),xt([j({type:Boolean})],vt.prototype,"autoplay",2),xt([j({type:Boolean})],vt.prototype,"loading",2),xt([j({type:Array})],vt.prototype,"controls",2),xt([j({attribute:!1})],vt.prototype,"compilation",2),xt([Bt()],vt.prototype,"_aspectRatio",2),xt([Bt()],vt.prototype,"_waiting",2),xt([Bt()],vt.prototype,"_stalled",2),xt([Bt()],vt.prototype,"_seeking",2),xt([Bt()],vt.prototype,"_captions",2),xt([Bt()],vt.prototype,"_fullscreen",2),vt=xt([Yt("vmp-media-player")],vt);var iy=Object.defineProperty,sy=Object.getOwnPropertyDescriptor,be=(r,t,e,i)=>{for(var s=i>1?void 0:i?sy(t,e):t,n=r.length-1,a;n>=0;n--)(a=r[n])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&iy(t,e,s),s};mt.Embed=class extends vi{constructor(){super(...arguments),this._mediaPlayerRef=Co(),this.env="prod",this.apiKey="",this.preload="auto",this.autoplay=!1,this.aspectRatio=0,this.eventController=new Mc(this,["durationchange","ended","error","loadeddata","pause","stalled","play","playing","ratechange","scenechange","seeking","seeked","timeupdate","volumechange","waiting","video:loadeddata","video:seeked","video:play","video:playing","video:pause","video:stalled","video:timeupdate","video:ended","video:error"]),this._fetcherController=new nu(this),this._trackingController=new du(this)}get vouch(){return this._fetcherController.vouch}get template(){return this._fetcherController.template}get fetching(){return this._fetcherController.fetching}get waiting(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.waiting}get seeking(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.seeking}get paused(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.paused}get captions(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.captions}get fullscreen(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.fullscreen}get duration(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.duration}set currentTime(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.currentTime=t)}get currentTime(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.currentTime)??0}set playbackRate(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.playbackRate=t)}get playbackRate(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.playbackRate)??1}set volume(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.volume=t)}get volume(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.volume)??1}set muted(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.muted=t)}get muted(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.muted)??!1}get scene(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.scene)??null}get scenes(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.scenes)??[]}get videoState(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.videoState}get mediaPlayer(){return this._mediaPlayerRef.value}play(){var t;(t=this._mediaPlayerRef.value)==null||t.play()}pause(){var t;(t=this._mediaPlayerRef.value)==null||t.pause()}setScene(t){var e;(e=this._mediaPlayerRef.value)==null||e.setScene(t)}render(){return _`
|
1475
1475
|
<vmp-media-player
|
1476
1476
|
${Io(this._mediaPlayerRef)}
|
1477
1477
|
${this.eventController.register()}
|
@@ -1479,10 +1479,9 @@ var embeds=function(ft){"use strict";var Iy=Object.defineProperty;var Py=(ft,Ee,
|
|
1479
1479
|
?loading=${this.fetching}
|
1480
1480
|
.data=${this.vouch}
|
1481
1481
|
.template=${this.template}
|
1482
|
-
|
1483
|
-
|
1484
|
-
preload=${$s(this.preload)}
|
1482
|
+
aspectRatio=${ko(this.aspectRatio)}
|
1483
|
+
preload=${ko(this.preload)}
|
1485
1484
|
.controls=${this.controls}
|
1486
1485
|
></vmp-media-player>
|
1487
|
-
`}},de([G({type:Object,attribute:"data"})],ft.Embed.prototype,"data",2),de([G({type:String})],ft.Embed.prototype,"vouchId",2),de([G({type:String})],ft.Embed.prototype,"templateId",2),de([G({type:String})],ft.Embed.prototype,"env",2),de([G({type:String})],ft.Embed.prototype,"apiKey",2),de([G({type:String})],ft.Embed.prototype,"preload",2),de([G({type:Boolean})],ft.Embed.prototype,"autoplay",2),de([G({type:Number})],ft.Embed.prototype,"resolution",2),de([G({type:Number})],ft.Embed.prototype,"aspectRatio",2),de([G({type:Array})],ft.Embed.prototype,"controls",2),ft.Embed=de([Tc("vouch-embed")],ft.Embed);function Ae(s){if(typeof s!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(s))}function Xd(s,t){for(var e="",i=0,r=-1,n=0,a,o=0;o<=s.length;++o){if(o<s.length)a=s.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(r===o-1||n===1))if(r!==o-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){var l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),r=o,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=o,n=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+="/"+s.slice(r+1,o):e=s.slice(r+1,o),i=o-r-1;r=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}function sy(s,t){var e=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+i:e+s+i:i}var Fi={resolve:function(){for(var t="",e=!1,i,r=arguments.length-1;r>=-1&&!e;r--){var n;r>=0?n=arguments[r]:(i===void 0&&(i=process.cwd()),n=i),Ae(n),n.length!==0&&(t=n+"/"+t,e=n.charCodeAt(0)===47)}return t=Xd(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(Ae(t),t.length===0)return".";var e=t.charCodeAt(0)===47,i=t.charCodeAt(t.length-1)===47;return t=Xd(t,!e),t.length===0&&!e&&(t="."),t.length>0&&i&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return Ae(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,e=0;e<arguments.length;++e){var i=arguments[e];Ae(i),i.length>0&&(t===void 0?t=i:t+="/"+i)}return t===void 0?".":Fi.normalize(t)},relative:function(t,e){if(Ae(t),Ae(e),t===e||(t=Fi.resolve(t),e=Fi.resolve(e),t===e))return"";for(var i=1;i<t.length&&t.charCodeAt(i)===47;++i);for(var r=t.length,n=r-i,a=1;a<e.length&&e.charCodeAt(a)===47;++a);for(var o=e.length,l=o-a,h=n<l?n:l,d=-1,c=0;c<=h;++c){if(c===h){if(l>h){if(e.charCodeAt(a+c)===47)return e.slice(a+c+1);if(c===0)return e.slice(a+c)}else n>h&&(t.charCodeAt(i+c)===47?d=c:c===0&&(d=0));break}var u=t.charCodeAt(i+c),f=e.charCodeAt(a+c);if(u!==f)break;u===47&&(d=c)}var p="";for(c=i+d+1;c<=r;++c)(c===r||t.charCodeAt(c)===47)&&(p.length===0?p+="..":p+="/..");return p.length>0?p+e.slice(a+d):(a+=d,e.charCodeAt(a)===47&&++a,e.slice(a))},_makeLong:function(t){return t},dirname:function(t){if(Ae(t),t.length===0)return".";for(var e=t.charCodeAt(0),i=e===47,r=-1,n=!0,a=t.length-1;a>=1;--a)if(e=t.charCodeAt(a),e===47){if(!n){r=a;break}}else n=!1;return r===-1?i?"/":".":i&&r===1?"//":t.slice(0,r)},basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Ae(t);var i=0,r=-1,n=!0,a;if(e!==void 0&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var o=e.length-1,l=-1;for(a=t.length-1;a>=0;--a){var h=t.charCodeAt(a);if(h===47){if(!n){i=a+1;break}}else l===-1&&(n=!1,l=a+1),o>=0&&(h===e.charCodeAt(o)?--o===-1&&(r=a):(o=-1,r=l))}return i===r?r=l:r===-1&&(r=t.length),t.slice(i,r)}else{for(a=t.length-1;a>=0;--a)if(t.charCodeAt(a)===47){if(!n){i=a+1;break}}else r===-1&&(n=!1,r=a+1);return r===-1?"":t.slice(i,r)}},extname:function(t){Ae(t);for(var e=-1,i=0,r=-1,n=!0,a=0,o=t.length-1;o>=0;--o){var l=t.charCodeAt(o);if(l===47){if(!n){i=o+1;break}continue}r===-1&&(n=!1,r=o+1),l===46?e===-1?e=o:a!==1&&(a=1):e!==-1&&(a=-1)}return e===-1||r===-1||a===0||a===1&&e===r-1&&e===i+1?"":t.slice(e,r)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return sy("/",t)},parse:function(t){Ae(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var i=t.charCodeAt(0),r=i===47,n;r?(e.root="/",n=1):n=0;for(var a=-1,o=0,l=-1,h=!0,d=t.length-1,c=0;d>=n;--d){if(i=t.charCodeAt(d),i===47){if(!h){o=d+1;break}continue}l===-1&&(h=!1,l=d+1),i===46?a===-1?a=d:c!==1&&(c=1):a!==-1&&(c=-1)}return a===-1||l===-1||c===0||c===1&&a===l-1&&a===o+1?l!==-1&&(o===0&&r?e.base=e.name=t.slice(1,l):e.base=e.name=t.slice(o,l)):(o===0&&r?(e.name=t.slice(1,a),e.base=t.slice(1,l)):(e.name=t.slice(o,a),e.base=t.slice(o,l)),e.ext=t.slice(a,l)),o>0?e.dir=t.slice(0,o-1):r&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};Fi.posix=Fi;var ny=Fi;const{basename:qd,extname:ay}=ny;class oy{constructor(){let t=(()=>typeof gn>"u")(),e="image/png",i="image/jpeg",r="image/jpeg",n="image/webp",a="application/pdf",o="image/svg+xml";Object.assign(this,{toMime:this.toMime.bind(this),fromMime:this.fromMime.bind(this),expected:t?'"png", "jpg", or "webp"':'"png", "jpg", "pdf", or "svg"',formats:t?{png:e,jpg:i,jpeg:r,webp:n}:{png:e,jpg:i,jpeg:r,pdf:a,svg:o},mimes:t?{[e]:"png",[i]:"jpg",[n]:"webp"}:{[e]:"png",[i]:"jpg",[a]:"pdf",[o]:"svg"}})}toMime(t){return this.formats[(t||"").replace(/^\./,"").toLowerCase()]}fromMime(t){return this.mimes[t]}}function ly(s,{filename:t="",extension:e="",format:g,page:r,quality:n,matte:a,density:o,outline:l,archive:f}={}){var{fromMime:d,toMime:c,expected:u}=new oy,f=f||"canvas",p=g||e.replace(/@\d+x$/i,"")||ay(t),g=d(c(p)||p),m=c(g),b=s.length;if(!p)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!g)throw new Error(`Unsupported file format "${p}" (expected ${u})`);if(!b)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let A,T,y=t.replace(/{(\d*)}/g,(S,L)=>(T=!0,L=parseInt(L,10),A=isFinite(L)?L:isFinite(A)?A:-1,"{}")),w=r>0?r-1:r<0?b+r:void 0;if(isFinite(w)&&w<0||w>=b)throw new RangeError(b==1?`Canvas only has a ‘page 1’ (${w} is out of bounds)`:`Canvas has pages 1–${b} (${w} is out of bounds)`);if(s=isFinite(w)?[s[w]]:T||g=="pdf"?s:s.slice(-1),n===void 0)n=.92;else if(typeof n!="number"||!isFinite(n)||n<0||n>1)throw new TypeError("The quality option must be an number in the 0.0–1.0 range");if(o===void 0){let S=(e||qd(t,p)).match(/@(\d+)x$/i);o=S?parseInt(S[1],10):1}else if(typeof o!="number"||!Number.isInteger(o)||o<1)throw new TypeError("The density option must be a non-negative integer");return l===void 0?l=!0:g=="svg"&&(l=!!l),{filename:t,pattern:y,format:g,mime:m,pages:s,padding:A,quality:n,matte:a,density:o,outline:l,archive:f}}class ks{static for(t){return new ks().append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=this.crc|0,i=this.table,r=0,n=t.length|0;r<n;r++)e=e>>>8^i[(e^t[r])&255];return this.crc=e,this}}ks.prototype.table=(()=>{var s,t,e,i=[];for(s=0;s<256;s++){for(e=s,t=0;t<8;t++)e=e&1?e>>>1^3988292384:e>>>1;i[s]=e}return i})();function Ha(s){let t=new Uint8Array(s),e=new DataView(t.buffer),i={array:t,view:e,size:s,set8(r,n){return e.setUint8(r,n),i},set16(r,n){return e.setUint16(r,n,!0),i},set32(r,n){return e.setUint32(r,n,!0),i},bytes(r,n){return t.set(n,r),i}};return i}const Ds=class Ds{constructor(t){let e=new Date;Object.assign(this,{directory:t,offset:0,files:[],time:(e.getHours()<<6|e.getMinutes())<<5|e.getSeconds()/2,date:(e.getFullYear()-1980<<4|e.getMonth()+1)<<5|e.getDate()}),this.add(t)}async add(t,e){let i=!e,r=Ds.encoder.encode(`${this.directory}/${i?"":t}`),n=new Uint8Array(i?0:await e.arrayBuffer()),a=30+r.length,o=a+n.length,l=16,{offset:h}=this,d=Ha(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,ks.for(n)).set32(14,n.length).set32(18,n.length).set16(22,r.length);h+=a;let c=Ha(a+n.length+l).set32(0,67324752).bytes(4,d.array).bytes(30,r).bytes(a,n);h+=n.length,c.set32(o,134695760).bytes(o+4,d.array.slice(10,22)),h+=l,this.files.push({offset:h,folder:i,name:r,header:d,payload:c}),this.offset=h}toBuffer(){let t=this.files.reduce((c,{name:u})=>46+u.length+c,0),e=Ha(t+22),i=0;for(var{offset:r,name:n,header:a,folder:o}of this.files)e.set32(i,33639248).set16(i+4,20).bytes(i+6,a.array).set8(i+38,o?16:0).set32(i+42,r).bytes(i+46,n),i+=46+n.length;e.set32(i,101010256).set16(i+8,this.files.length).set16(i+10,this.files.length).set32(i+12,t).set32(i+16,this.offset);let l=new Uint8Array(this.offset+e.size),h=0;for(var{payload:d}of this.files)l.set(d.array,h),h+=d.size;return l.set(e.array,h),l}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}};ec(Ds,"encoder",new TextEncoder);let Ga=Ds;const Va=(s,t,e,i)=>{if(i){let{width:r,height:n}=s,a=Object.assign(document.createElement("canvas"),{width:r,height:n}),o=a.getContext("2d");o.fillStyle=i,o.fillRect(0,0,r,n),o.drawImage(s,0,0),s=a}return new Promise((r,n)=>s.toBlob(r,t,e))},hy=(...s)=>Va(...s).then(t=>t.arrayBuffer()),dy=async(s,t,e,i,r)=>{Zd(r,await Va(s,t,e,i))},cy=async(s,t,e,i,r,n,a)=>{let o=d=>n.replace("{}",String(d+1).padStart(a,"0")),l=qd(r,".zip")||"archive",h=new Ga(l);await Promise.all(s.map(async(d,c)=>{let u=o(c);await h.add(u,await Va(d,t,e,i))})),Zd(`${l}.zip`,h.blob)},Zd=(s,t)=>{const e=window.URL.createObjectURL(t),i=document.createElement("a");i.style.display="none",i.href=e,i.setAttribute("download",s),typeof i.download>"u"&&i.setAttribute("target","_blank"),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>window.URL.revokeObjectURL(e),100)};var uy={asBuffer:hy,asDownload:dy,asZipDownload:cy,atScale:(s,t,e)=>s.map(i=>{if(t==1&&!e)return i.canvas;let r=document.createElement("canvas"),n=r.getContext("2d"),a=i.canvas?i.canvas:i;return r.width=a.width*t,r.height=a.height*t,e&&(n.fillStyle=e,n.fillRect(0,0,r.width,r.height)),n.scale(t,t),n.drawImage(a,0,0),r}),options:ly};const{asBuffer:ja,asDownload:fy,asZipDownload:py,atScale:za,options:Ka}=uy,Jd=Symbol.for("toDataURL"),gy=s=>{let t=Object.assign(new Qd,{crossOrigin:"Anonymous",src:s});return t.decode().then(()=>t)};class my{constructor(t,e){let i=document.createElement("canvas"),r=[];Object.defineProperty(i,"async",{value:!0,writable:!1,enumerable:!0});for(var[n,a]of Object.entries({png:()=>ja(i,"image/png"),jpg:()=>ja(i,"image/jpeg"),pages:()=>r.concat(i).map(o=>o.getContext("2d"))}))Object.defineProperty(i,n,{get:a});return Object.assign(i,{width:t,height:e,newPage(...o){var{width:h,height:d}=i,l=Object.assign(document.createElement("canvas"),{width:h,height:d});l.getContext("2d").drawImage(i,0,0),r.push(l);var[h,d]=o.length?o:[h,d];return Object.assign(i,{width:h,height:d}).getContext("2d")},saveAs(o,l){l=typeof l=="number"?{quality:l}:l;let h=Ka(this.pages,{filename:o,...l}),{pattern:d,padding:c,mime:u,quality:f,matte:p,density:g,archive:m}=h,b=za(h.pages,g);return c==null?fy(b[0],u,f,p,o):py(b,u,f,p,m,d,c)},toBuffer(o="png",l={}){l=typeof l=="number"?{quality:l}:l;let h=Ka(this.pages,{extension:o,...l}),{mime:d,quality:c,matte:u,pages:f,density:p}=h,g=za(f,p,u)[0];return ja(g,d,c,u)},[Jd]:i.toDataURL.bind(i),toDataURL(o="png",l={}){l=typeof l=="number"?{quality:l}:l;let h=Ka(this.pages,{extension:o,...l}),{mime:d,quality:c,matte:u,pages:f,density:p}=h,g=za(f,p,u)[0],m=g[g===i?Jd:"toDataURL"](d,c);return Promise.resolve(m)}})}}const{CanvasRenderingContext2D:vy,CanvasGradient:yy,CanvasPattern:by,Image:Qd,ImageData:Ay,Path2D:Ty,DOMMatrix:Ey,DOMRect:wy,DOMPoint:Sy}=window;var _d={Canvas:my,loadImage:gy,CanvasRenderingContext2D:vy,CanvasGradient:yy,CanvasPattern:by,Image:Qd,ImageData:Ay,Path2D:Ty,DOMMatrix:Ey,DOMRect:wy,DOMPoint:Sy};const $d=Ee({__proto__:null,default:mn(_d)},[_d]);return Object.defineProperty(ft,Symbol.toStringTag,{value:"Module"}),ft}({});
|
1486
|
+
`}},be([j({type:Object,attribute:"data"})],mt.Embed.prototype,"data",2),be([j({type:String})],mt.Embed.prototype,"vouchId",2),be([j({type:String})],mt.Embed.prototype,"templateId",2),be([j({type:String})],mt.Embed.prototype,"env",2),be([j({type:String})],mt.Embed.prototype,"apiKey",2),be([j({type:Array})],mt.Embed.prototype,"controls",2),be([j({type:String})],mt.Embed.prototype,"preload",2),be([j({type:Boolean})],mt.Embed.prototype,"autoplay",2),be([j({type:Number})],mt.Embed.prototype,"aspectRatio",2),mt.Embed=be([Tc("vouch-embed")],mt.Embed);function Ae(r){if(typeof r!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(r))}function Xd(r,t){for(var e="",i=0,s=-1,n=0,a,o=0;o<=r.length;++o){if(o<r.length)a=r.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(s===o-1||n===1))if(s!==o-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){var l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),s=o,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=o,n=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+="/"+r.slice(s+1,o):e=r.slice(s+1,o),i=o-s-1;s=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}function ry(r,t){var e=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+i:e+r+i:i}var Fi={resolve:function(){for(var t="",e=!1,i,s=arguments.length-1;s>=-1&&!e;s--){var n;s>=0?n=arguments[s]:(i===void 0&&(i=process.cwd()),n=i),Ae(n),n.length!==0&&(t=n+"/"+t,e=n.charCodeAt(0)===47)}return t=Xd(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(Ae(t),t.length===0)return".";var e=t.charCodeAt(0)===47,i=t.charCodeAt(t.length-1)===47;return t=Xd(t,!e),t.length===0&&!e&&(t="."),t.length>0&&i&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return Ae(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,e=0;e<arguments.length;++e){var i=arguments[e];Ae(i),i.length>0&&(t===void 0?t=i:t+="/"+i)}return t===void 0?".":Fi.normalize(t)},relative:function(t,e){if(Ae(t),Ae(e),t===e||(t=Fi.resolve(t),e=Fi.resolve(e),t===e))return"";for(var i=1;i<t.length&&t.charCodeAt(i)===47;++i);for(var s=t.length,n=s-i,a=1;a<e.length&&e.charCodeAt(a)===47;++a);for(var o=e.length,l=o-a,h=n<l?n:l,d=-1,c=0;c<=h;++c){if(c===h){if(l>h){if(e.charCodeAt(a+c)===47)return e.slice(a+c+1);if(c===0)return e.slice(a+c)}else n>h&&(t.charCodeAt(i+c)===47?d=c:c===0&&(d=0));break}var u=t.charCodeAt(i+c),f=e.charCodeAt(a+c);if(u!==f)break;u===47&&(d=c)}var p="";for(c=i+d+1;c<=s;++c)(c===s||t.charCodeAt(c)===47)&&(p.length===0?p+="..":p+="/..");return p.length>0?p+e.slice(a+d):(a+=d,e.charCodeAt(a)===47&&++a,e.slice(a))},_makeLong:function(t){return t},dirname:function(t){if(Ae(t),t.length===0)return".";for(var e=t.charCodeAt(0),i=e===47,s=-1,n=!0,a=t.length-1;a>=1;--a)if(e=t.charCodeAt(a),e===47){if(!n){s=a;break}}else n=!1;return s===-1?i?"/":".":i&&s===1?"//":t.slice(0,s)},basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Ae(t);var i=0,s=-1,n=!0,a;if(e!==void 0&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var o=e.length-1,l=-1;for(a=t.length-1;a>=0;--a){var h=t.charCodeAt(a);if(h===47){if(!n){i=a+1;break}}else l===-1&&(n=!1,l=a+1),o>=0&&(h===e.charCodeAt(o)?--o===-1&&(s=a):(o=-1,s=l))}return i===s?s=l:s===-1&&(s=t.length),t.slice(i,s)}else{for(a=t.length-1;a>=0;--a)if(t.charCodeAt(a)===47){if(!n){i=a+1;break}}else s===-1&&(n=!1,s=a+1);return s===-1?"":t.slice(i,s)}},extname:function(t){Ae(t);for(var e=-1,i=0,s=-1,n=!0,a=0,o=t.length-1;o>=0;--o){var l=t.charCodeAt(o);if(l===47){if(!n){i=o+1;break}continue}s===-1&&(n=!1,s=o+1),l===46?e===-1?e=o:a!==1&&(a=1):e!==-1&&(a=-1)}return e===-1||s===-1||a===0||a===1&&e===s-1&&e===i+1?"":t.slice(e,s)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return ry("/",t)},parse:function(t){Ae(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var i=t.charCodeAt(0),s=i===47,n;s?(e.root="/",n=1):n=0;for(var a=-1,o=0,l=-1,h=!0,d=t.length-1,c=0;d>=n;--d){if(i=t.charCodeAt(d),i===47){if(!h){o=d+1;break}continue}l===-1&&(h=!1,l=d+1),i===46?a===-1?a=d:c!==1&&(c=1):a!==-1&&(c=-1)}return a===-1||l===-1||c===0||c===1&&a===l-1&&a===o+1?l!==-1&&(o===0&&s?e.base=e.name=t.slice(1,l):e.base=e.name=t.slice(o,l)):(o===0&&s?(e.name=t.slice(1,a),e.base=t.slice(1,l)):(e.name=t.slice(o,a),e.base=t.slice(o,l)),e.ext=t.slice(a,l)),o>0?e.dir=t.slice(0,o-1):s&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};Fi.posix=Fi;var ny=Fi;const{basename:qd,extname:ay}=ny;class oy{constructor(){let t=(()=>typeof pn>"u")(),e="image/png",i="image/jpeg",s="image/jpeg",n="image/webp",a="application/pdf",o="image/svg+xml";Object.assign(this,{toMime:this.toMime.bind(this),fromMime:this.fromMime.bind(this),expected:t?'"png", "jpg", or "webp"':'"png", "jpg", "pdf", or "svg"',formats:t?{png:e,jpg:i,jpeg:s,webp:n}:{png:e,jpg:i,jpeg:s,pdf:a,svg:o},mimes:t?{[e]:"png",[i]:"jpg",[n]:"webp"}:{[e]:"png",[i]:"jpg",[a]:"pdf",[o]:"svg"}})}toMime(t){return this.formats[(t||"").replace(/^\./,"").toLowerCase()]}fromMime(t){return this.mimes[t]}}function ly(r,{filename:t="",extension:e="",format:g,page:s,quality:n,matte:a,density:o,outline:l,archive:f}={}){var{fromMime:d,toMime:c,expected:u}=new oy,f=f||"canvas",p=g||e.replace(/@\d+x$/i,"")||ay(t),g=d(c(p)||p),m=c(g),b=r.length;if(!p)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!g)throw new Error(`Unsupported file format "${p}" (expected ${u})`);if(!b)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let A,T,y=t.replace(/{(\d*)}/g,(S,L)=>(T=!0,L=parseInt(L,10),A=isFinite(L)?L:isFinite(A)?A:-1,"{}")),E=s>0?s-1:s<0?b+s:void 0;if(isFinite(E)&&E<0||E>=b)throw new RangeError(b==1?`Canvas only has a ‘page 1’ (${E} is out of bounds)`:`Canvas has pages 1–${b} (${E} is out of bounds)`);if(r=isFinite(E)?[r[E]]:T||g=="pdf"?r:r.slice(-1),n===void 0)n=.92;else if(typeof n!="number"||!isFinite(n)||n<0||n>1)throw new TypeError("The quality option must be an number in the 0.0–1.0 range");if(o===void 0){let S=(e||qd(t,p)).match(/@(\d+)x$/i);o=S?parseInt(S[1],10):1}else if(typeof o!="number"||!Number.isInteger(o)||o<1)throw new TypeError("The density option must be a non-negative integer");return l===void 0?l=!0:g=="svg"&&(l=!!l),{filename:t,pattern:y,format:g,mime:m,pages:r,padding:A,quality:n,matte:a,density:o,outline:l,archive:f}}class kr{static for(t){return new kr().append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=this.crc|0,i=this.table,s=0,n=t.length|0;s<n;s++)e=e>>>8^i[(e^t[s])&255];return this.crc=e,this}}kr.prototype.table=(()=>{var r,t,e,i=[];for(r=0;r<256;r++){for(e=r,t=0;t<8;t++)e=e&1?e>>>1^3988292384:e>>>1;i[r]=e}return i})();function Ba(r){let t=new Uint8Array(r),e=new DataView(t.buffer),i={array:t,view:e,size:r,set8(s,n){return e.setUint8(s,n),i},set16(s,n){return e.setUint16(s,n,!0),i},set32(s,n){return e.setUint32(s,n,!0),i},bytes(s,n){return t.set(n,s),i}};return i}const Dr=class Dr{constructor(t){let e=new Date;Object.assign(this,{directory:t,offset:0,files:[],time:(e.getHours()<<6|e.getMinutes())<<5|e.getSeconds()/2,date:(e.getFullYear()-1980<<4|e.getMonth()+1)<<5|e.getDate()}),this.add(t)}async add(t,e){let i=!e,s=Dr.encoder.encode(`${this.directory}/${i?"":t}`),n=new Uint8Array(i?0:await e.arrayBuffer()),a=30+s.length,o=a+n.length,l=16,{offset:h}=this,d=Ba(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,kr.for(n)).set32(14,n.length).set32(18,n.length).set16(22,s.length);h+=a;let c=Ba(a+n.length+l).set32(0,67324752).bytes(4,d.array).bytes(30,s).bytes(a,n);h+=n.length,c.set32(o,134695760).bytes(o+4,d.array.slice(10,22)),h+=l,this.files.push({offset:h,folder:i,name:s,header:d,payload:c}),this.offset=h}toBuffer(){let t=this.files.reduce((c,{name:u})=>46+u.length+c,0),e=Ba(t+22),i=0;for(var{offset:s,name:n,header:a,folder:o}of this.files)e.set32(i,33639248).set16(i+4,20).bytes(i+6,a.array).set8(i+38,o?16:0).set32(i+42,s).bytes(i+46,n),i+=46+n.length;e.set32(i,101010256).set16(i+8,this.files.length).set16(i+10,this.files.length).set32(i+12,t).set32(i+16,this.offset);let l=new Uint8Array(this.offset+e.size),h=0;for(var{payload:d}of this.files)l.set(d.array,h),h+=d.size;return l.set(e.array,h),l}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}};ec(Dr,"encoder",new TextEncoder);let Ha=Dr;const Ga=(r,t,e,i)=>{if(i){let{width:s,height:n}=r,a=Object.assign(document.createElement("canvas"),{width:s,height:n}),o=a.getContext("2d");o.fillStyle=i,o.fillRect(0,0,s,n),o.drawImage(r,0,0),r=a}return new Promise((s,n)=>r.toBlob(s,t,e))},hy=(...r)=>Ga(...r).then(t=>t.arrayBuffer()),dy=async(r,t,e,i,s)=>{Zd(s,await Ga(r,t,e,i))},cy=async(r,t,e,i,s,n,a)=>{let o=d=>n.replace("{}",String(d+1).padStart(a,"0")),l=qd(s,".zip")||"archive",h=new Ha(l);await Promise.all(r.map(async(d,c)=>{let u=o(c);await h.add(u,await Ga(d,t,e,i))})),Zd(`${l}.zip`,h.blob)},Zd=(r,t)=>{const e=window.URL.createObjectURL(t),i=document.createElement("a");i.style.display="none",i.href=e,i.setAttribute("download",r),typeof i.download>"u"&&i.setAttribute("target","_blank"),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>window.URL.revokeObjectURL(e),100)};var uy={asBuffer:hy,asDownload:dy,asZipDownload:cy,atScale:(r,t,e)=>r.map(i=>{if(t==1&&!e)return i.canvas;let s=document.createElement("canvas"),n=s.getContext("2d"),a=i.canvas?i.canvas:i;return s.width=a.width*t,s.height=a.height*t,e&&(n.fillStyle=e,n.fillRect(0,0,s.width,s.height)),n.scale(t,t),n.drawImage(a,0,0),s}),options:ly};const{asBuffer:Va,asDownload:fy,asZipDownload:py,atScale:ja,options:za}=uy,Jd=Symbol.for("toDataURL"),gy=r=>{let t=Object.assign(new Qd,{crossOrigin:"Anonymous",src:r});return t.decode().then(()=>t)};class my{constructor(t,e){let i=document.createElement("canvas"),s=[];Object.defineProperty(i,"async",{value:!0,writable:!1,enumerable:!0});for(var[n,a]of Object.entries({png:()=>Va(i,"image/png"),jpg:()=>Va(i,"image/jpeg"),pages:()=>s.concat(i).map(o=>o.getContext("2d"))}))Object.defineProperty(i,n,{get:a});return Object.assign(i,{width:t,height:e,newPage(...o){var{width:h,height:d}=i,l=Object.assign(document.createElement("canvas"),{width:h,height:d});l.getContext("2d").drawImage(i,0,0),s.push(l);var[h,d]=o.length?o:[h,d];return Object.assign(i,{width:h,height:d}).getContext("2d")},saveAs(o,l){l=typeof l=="number"?{quality:l}:l;let h=za(this.pages,{filename:o,...l}),{pattern:d,padding:c,mime:u,quality:f,matte:p,density:g,archive:m}=h,b=ja(h.pages,g);return c==null?fy(b[0],u,f,p,o):py(b,u,f,p,m,d,c)},toBuffer(o="png",l={}){l=typeof l=="number"?{quality:l}:l;let h=za(this.pages,{extension:o,...l}),{mime:d,quality:c,matte:u,pages:f,density:p}=h,g=ja(f,p,u)[0];return Va(g,d,c,u)},[Jd]:i.toDataURL.bind(i),toDataURL(o="png",l={}){l=typeof l=="number"?{quality:l}:l;let h=za(this.pages,{extension:o,...l}),{mime:d,quality:c,matte:u,pages:f,density:p}=h,g=ja(f,p,u)[0],m=g[g===i?Jd:"toDataURL"](d,c);return Promise.resolve(m)}})}}const{CanvasRenderingContext2D:vy,CanvasGradient:yy,CanvasPattern:by,Image:Qd,ImageData:Ay,Path2D:Ty,DOMMatrix:Ey,DOMRect:wy,DOMPoint:Sy}=window;var _d={Canvas:my,loadImage:gy,CanvasRenderingContext2D:vy,CanvasGradient:yy,CanvasPattern:by,Image:Qd,ImageData:Ay,Path2D:Ty,DOMMatrix:Ey,DOMRect:wy,DOMPoint:Sy};const $d=Ee({__proto__:null,default:gn(_d)},[_d]);return Object.defineProperty(mt,Symbol.toStringTag,{value:"Module"}),mt}({});
|
1488
1487
|
//# sourceMappingURL=embeds.iife.js.map
|