@vouchfor/embeds 0.0.0-experiment.8b3403f → 0.0.0-experiment.8c5a3f8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,200 +1,218 @@
1
- var embeds=function(At){"use strict";var q0=Object.defineProperty;var z0=(At,xe,ye)=>xe in At?q0(At,xe,{enumerable:!0,configurable:!0,writable:!0,value:ye}):At[xe]=ye;var Ic=(At,xe,ye)=>(z0(At,typeof xe!="symbol"?xe+"":xe,ye),ye);function xe(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"}))}/**
1
+ var bk=Object.defineProperty;var Ak=(Be,Yr,Lr)=>Yr in Be?bk(Be,Yr,{enumerable:!0,configurable:!0,writable:!0,value:Lr}):Be[Yr]=Lr;var y2=(Be,Yr,Lr)=>(Ak(Be,typeof Yr!="symbol"?Yr+"":Yr,Lr),Lr);var embeds=function(Be){var ep;"use strict";function Yr(n,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 n)){const o=Object.getOwnPropertyDescriptor(i,s);o&&Object.defineProperty(n,s,o.get?o:{enumerable:!0,get:()=>i[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}/**
2
2
  * @license
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
- */const ye=window,_r=ye.ShadowRoot&&(ye.ShadyCSS===void 0||ye.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,kr=Symbol(),Da=new WeakMap;let Ca=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==kr)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(_r&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=Da.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Da.set(e,t))}return t}toString(){return this.cssText}};const Ui=r=>new Ca(typeof r=="string"?r:r+"",void 0,kr),jt=(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 Ca(e,r,kr)},Pc=(r,t)=>{_r?r.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet):t.forEach(e=>{const i=document.createElement("style"),s=ye.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,r.appendChild(i)})},xa=_r?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return Ui(e)})(r):r;/**
5
+ */const Lr=globalThis,al=Lr.ShadowRoot&&(Lr.ShadyCSS===void 0||Lr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Hh=Symbol(),Vh=new WeakMap;let T2=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Hh)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(al&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=Vh.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Vh.set(e,t))}return t}toString(){return this.cssText}};const k2=n=>new T2(typeof n=="string"?n:n+"",void 0,Hh),w2=(n,t)=>{if(al)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=Lr.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,n.appendChild(i)}},Wh=al?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return k2(e)})(n):n;/**
6
6
  * @license
7
7
  * Copyright 2017 Google LLC
8
8
  * SPDX-License-Identifier: BSD-3-Clause
9
- */var Ir;const Rs=window,Pa=Rs.trustedTypes,Oc=Pa?Pa.emptyScript:"",Oa=Rs.reactiveElementPolyfillSupport,Dr={toAttribute(r,t){switch(t){case Boolean:r=r?Oc: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}},$a=(r,t)=>t!==r&&(t==t||r==r),Cr={attribute:!0,type:String,converter:Dr,reflect:!1,hasChanged:$a},xr="finalized";let gi=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=Cr){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)||Cr}static finalize(){if(this.hasOwnProperty(xr))return!1;this[xr]=!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(xa(s))}else t!==void 0&&e.push(xa(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 Pc(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=Cr){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:Dr).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:Dr;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||$a)(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){}};gi[xr]=!0,gi.elementProperties=new Map,gi.elementStyles=[],gi.shadowRootOptions={mode:"open"},Oa==null||Oa({ReactiveElement:gi}),((Ir=Rs.reactiveElementVersions)!==null&&Ir!==void 0?Ir:Rs.reactiveElementVersions=[]).push("1.6.2");/**
9
+ */const{is:S2,defineProperty:R2,getOwnPropertyDescriptor:_2,getOwnPropertyNames:L2,getOwnPropertySymbols:C2,getPrototypeOf:I2}=Object,us=globalThis,jh=us.trustedTypes,x2=jh?jh.emptyScript:"",ol=us.reactiveElementPolyfillSupport,jn=(n,t)=>n,Va={toAttribute(n,t){switch(t){case Boolean:n=n?x2:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},ll=(n,t)=>!S2(n,t),Kh={attribute:!0,type:String,converter:Va,reflect:!1,hasChanged:ll};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),us.litPropertyMetadata??(us.litPropertyMetadata=new WeakMap);let Kn=class 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=Kh){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&&R2(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:o}=_2(this.prototype,t)??{get(){return this[e]},set(c){this[e]=c}};return{get(){return s==null?void 0:s.call(this)},set(c){const d=s==null?void 0:s.call(this);o.call(this,c),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Kh}static _$Ei(){if(this.hasOwnProperty(jn("elementProperties")))return;const t=I2(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(jn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(jn("properties"))){const e=this.properties,i=[...L2(e),...C2(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(Wh(s))}else t!==void 0&&e.push(Wh(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._$ES(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$E_??(this._$E_=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$E_)==null||e.delete(t)}_$ES(){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 w2(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$E_)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$E_)==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 o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const c=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Va).toAttribute(e,i.type);this._$Em=t,c==null?this.removeAttribute(s):this.setAttribute(s,c),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const c=i.getPropertyOptions(s),d=typeof c.converter=="function"?{fromAttribute:c.converter}:((o=c.converter)==null?void 0:o.fromAttribute)!==void 0?c.converter:Va;this._$Em=s,this[s]=d.fromAttribute(e,c.type),this._$Em=null}}requestUpdate(t,e,i,s=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??ll)(s?o: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.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,c]of this._$Ep)this[o]=c;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,c]of s)c.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],c)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$E_)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.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._$E_)==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){}};Kn.elementStyles=[],Kn.shadowRootOptions={mode:"open"},Kn[jn("elementProperties")]=new Map,Kn[jn("finalized")]=new Map,ol==null||ol({ReactiveElement:Kn}),(us.reactiveElementVersions??(us.reactiveElementVersions=[])).push("2.0.2");/**
10
10
  * @license
11
11
  * Copyright 2017 Google LLC
12
12
  * SPDX-License-Identifier: BSD-3-Clause
13
- */var Pr;const _s=window,mi=_s.trustedTypes,Ma=mi?mi.createPolicy("lit-html",{createHTML:r=>r}):void 0,Or="$lit$",Be=`lit$${(Math.random()+"").slice(9)}$`,Fa="?"+Be,$c=`<${Fa}>`,qe=document,ks=()=>qe.createComment(""),Bi=r=>r===null||typeof r!="object"&&typeof r!="function",Na=Array.isArray,Mc=r=>Na(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",$r=`[
14
- \f\r]`,Hi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ua=/-->/g,Ba=/>/g,ze=RegExp(`>|${$r}(?:([^\\s"'>=/]+)(${$r}*=${$r}*(?:[^
15
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Ha=/'/g,Ga=/"/g,Va=/^(?:script|style|textarea|title)$/i,Gi=Symbol.for("lit-noChange"),kt=Symbol.for("lit-nothing"),Ka=new WeakMap,Xe=qe.createTreeWalker(qe,129,null,!1);function ja(r,t){if(!Array.isArray(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ma!==void 0?Ma.createHTML(t):t}const Fc=(r,t)=>{const e=r.length-1,i=[];let s,n=t===2?"<svg>":"",a=Hi;for(let o=0;o<e;o++){const l=r[o];let h,c,d=-1,u=0;for(;u<l.length&&(a.lastIndex=u,c=a.exec(l),c!==null);)u=a.lastIndex,a===Hi?c[1]==="!--"?a=Ua:c[1]!==void 0?a=Ba:c[2]!==void 0?(Va.test(c[2])&&(s=RegExp("</"+c[2],"g")),a=ze):c[3]!==void 0&&(a=ze):a===ze?c[0]===">"?(a=s??Hi,d=-1):c[1]===void 0?d=-2:(d=a.lastIndex-c[2].length,h=c[1],a=c[3]===void 0?ze:c[3]==='"'?Ga:Ha):a===Ga||a===Ha?a=ze:a===Ua||a===Ba?a=Hi:(a=ze,s=void 0);const f=a===ze&&r[o+1].startsWith("/>")?" ":"";n+=a===Hi?l+$c:d>=0?(i.push(h),l.slice(0,d)+Or+l.slice(d)+Be+f):l+Be+(d===-2?(i.push(void 0),o):f)}return[ja(r,n+(r[e]||"<?>")+(t===2?"</svg>":"")),i]};let Mr=class Dc{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let n=0,a=0;const o=t.length-1,l=this.parts,[h,c]=Fc(t,e);if(this.el=Dc.createElement(h,i),Xe.currentNode=this.el.content,e===2){const d=this.el.content,u=d.firstChild;u.remove(),d.append(...u.childNodes)}for(;(s=Xe.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes()){const d=[];for(const u of s.getAttributeNames())if(u.endsWith(Or)||u.startsWith(Be)){const f=c[a++];if(d.push(u),f!==void 0){const p=s.getAttribute(f.toLowerCase()+Or).split(Be),g=/([.?@])?(.*)/.exec(f);l.push({type:1,index:n,name:g[2],strings:p,ctor:g[1]==="."?Uc:g[1]==="?"?Hc:g[1]==="@"?Gc:Is})}else l.push({type:6,index:n})}for(const u of d)s.removeAttribute(u)}if(Va.test(s.tagName)){const d=s.textContent.split(Be),u=d.length-1;if(u>0){s.textContent=mi?mi.emptyScript:"";for(let f=0;f<u;f++)s.append(d[f],ks()),Xe.nextNode(),l.push({type:2,index:++n});s.append(d[u],ks())}}}else if(s.nodeType===8)if(s.data===Fa)l.push({type:2,index:n});else{let d=-1;for(;(d=s.data.indexOf(Be,d+1))!==-1;)l.push({type:7,index:n}),d+=Be.length-1}n++}}static createElement(t,e){const i=qe.createElement("template");return i.innerHTML=t,i}};function vi(r,t,e=r,i){var s,n,a,o;if(t===Gi)return t;let l=i!==void 0?(s=e._$Co)===null||s===void 0?void 0:s[i]:e._$Cl;const h=Bi(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=vi(r,l._$AS(r,t.values),l,i)),t}let Nc=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:qe).importNode(i,!0);Xe.currentNode=n;let a=Xe.nextNode(),o=0,l=0,h=s[0];for(;h!==void 0;){if(o===h.index){let c;h.type===2?c=new Wa(a,a.nextSibling,this,t):h.type===1?c=new h.ctor(a,h.name,h.strings,this,t):h.type===6&&(c=new Vc(a,this,t)),this._$AV.push(c),h=s[++l]}o!==(h==null?void 0:h.index)&&(a=Xe.nextNode(),o++)}return Xe.currentNode=qe,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++}},Wa=class Cc{constructor(t,e,i,s){var n;this.type=2,this._$AH=kt,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=vi(this,t,e),Bi(t)?t===kt||t==null||t===""?(this._$AH!==kt&&this._$AR(),this._$AH=kt):t!==this._$AH&&t!==Gi&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):Mc(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!==kt&&Bi(this._$AH)?this._$AA.nextSibling.data=t:this.$(qe.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=Mr.createElement(ja(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 Nc(n,this),o=a.u(this.options);a.v(i),this.$(o),this._$AH=a}}_$AC(t){let e=Ka.get(t.strings);return e===void 0&&Ka.set(t.strings,e=new Mr(t)),e}T(t){Na(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 Cc(this.k(ks()),this.k(ks()),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))}},Is=class{constructor(t,e,i,s,n){this.type=1,this._$AH=kt,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=kt}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=vi(this,t,e,0),a=!Bi(t)||t!==this._$AH&&t!==Gi,a&&(this._$AH=t);else{const o=t;let l,h;for(t=n[0],l=0;l<n.length-1;l++)h=vi(this,o[i+l],e,l),h===Gi&&(h=this._$AH[l]),a||(a=!Bi(h)||h!==this._$AH[l]),h===kt?t=kt:t!==kt&&(t+=(h??"")+n[l+1]),this._$AH[l]=h}a&&!s&&this.j(t)}j(t){t===kt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Uc=class extends Is{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===kt?void 0:t}};const Bc=mi?mi.emptyScript:"";let Hc=class extends Is{constructor(){super(...arguments),this.type=4}j(t){t&&t!==kt?this.element.setAttribute(this.name,Bc):this.element.removeAttribute(this.name)}},Gc=class extends Is{constructor(t,e,i,s,n){super(t,e,i,s,n),this.type=5}_$AI(t,e=this){var i;if((t=(i=vi(this,t,e,0))!==null&&i!==void 0?i:kt)===Gi)return;const s=this._$AH,n=t===kt&&s!==kt||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,a=t!==kt&&(s===kt||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)}},Vc=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){vi(this,t)}};const Ya=_s.litHtmlPolyfillSupport;Ya==null||Ya(Mr,Wa),((Pr=_s.litHtmlVersions)!==null&&Pr!==void 0?Pr:_s.litHtmlVersions=[]).push("2.8.0");/**
13
+ */const Yn=globalThis,Wa=Yn.trustedTypes,Yh=Wa?Wa.createPolicy("lit-html",{createHTML:n=>n}):void 0,cl="$lit$",zr=`lit$${(Math.random()+"").slice(9)}$`,hl="?"+zr,D2=`<${hl}>`,Hs=document,ja=()=>Hs.createComment(""),zn=n=>n===null||typeof n!="object"&&typeof n!="function",zh=Array.isArray,Xh=n=>zh(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",dl=`[
14
+ \f\r]`,Xn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Zh=/-->/g,qh=/>/g,Vs=RegExp(`>|${dl}(?:([^\\s"'>=/]+)(${dl}*=${dl}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Qh=/'/g,Jh=/"/g,td=/^(?:script|style|textarea|title)$/i,fs=Symbol.for("lit-noChange"),Qe=Symbol.for("lit-nothing"),ed=new WeakMap,Ws=Hs.createTreeWalker(Hs,129);function id(n,t){if(!Array.isArray(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Yh!==void 0?Yh.createHTML(t):t}const rd=(n,t)=>{const e=n.length-1,i=[];let s,o=t===2?"<svg>":"",c=Xn;for(let d=0;d<e;d++){const f=n[d];let p,g,v=-1,b=0;for(;b<f.length&&(c.lastIndex=b,g=c.exec(f),g!==null);)b=c.lastIndex,c===Xn?g[1]==="!--"?c=Zh:g[1]!==void 0?c=qh:g[2]!==void 0?(td.test(g[2])&&(s=RegExp("</"+g[2],"g")),c=Vs):g[3]!==void 0&&(c=Vs):c===Vs?g[0]===">"?(c=s??Xn,v=-1):g[1]===void 0?v=-2:(v=c.lastIndex-g[2].length,p=g[1],c=g[3]===void 0?Vs:g[3]==='"'?Jh:Qh):c===Jh||c===Qh?c=Vs:c===Zh||c===qh?c=Xn:(c=Vs,s=void 0);const E=c===Vs&&n[d+1].startsWith("/>")?" ":"";o+=c===Xn?f+D2:v>=0?(i.push(p),f.slice(0,v)+cl+f.slice(v)+zr+E):f+zr+(v===-2?d:E)}return[id(n,o+(n[e]||"<?>")+(t===2?"</svg>":"")),i]};let ul=class b2{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,c=0;const d=t.length-1,f=this.parts,[p,g]=rd(t,e);if(this.el=b2.createElement(p,i),Ws.currentNode=this.el.content,e===2){const v=this.el.content.firstChild;v.replaceWith(...v.childNodes)}for(;(s=Ws.nextNode())!==null&&f.length<d;){if(s.nodeType===1){if(s.hasAttributes())for(const v of s.getAttributeNames())if(v.endsWith(cl)){const b=g[c++],E=s.getAttribute(v).split(zr),T=/([.?@])?(.*)/.exec(b);f.push({type:1,index:o,name:T[2],strings:E,ctor:T[1]==="."?nd:T[1]==="?"?ad:T[1]==="@"?od:Zn}),s.removeAttribute(v)}else v.startsWith(zr)&&(f.push({type:6,index:o}),s.removeAttribute(v));if(td.test(s.tagName)){const v=s.textContent.split(zr),b=v.length-1;if(b>0){s.textContent=Wa?Wa.emptyScript:"";for(let E=0;E<b;E++)s.append(v[E],ja()),Ws.nextNode(),f.push({type:2,index:++o});s.append(v[b],ja())}}}else if(s.nodeType===8)if(s.data===hl)f.push({type:2,index:o});else{let v=-1;for(;(v=s.data.indexOf(zr,v+1))!==-1;)f.push({type:7,index:o}),v+=zr.length-1}o++}}static createElement(t,e){const i=Hs.createElement("template");return i.innerHTML=t,i}};function js(n,t,e=n,i){var c,d;if(t===fs)return t;let s=i!==void 0?(c=e._$Co)==null?void 0:c[i]:e._$Cl;const o=zn(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((d=s==null?void 0:s._$AO)==null||d.call(s,!1),o===void 0?s=void 0:(s=new o(n),s._$AT(n,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=s:e._$Cl=s),s!==void 0&&(t=js(n,s._$AS(n,t.values),s,i)),t}let sd=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){const{el:{content:e},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??Hs).importNode(e,!0);Ws.currentNode=s;let o=Ws.nextNode(),c=0,d=0,f=i[0];for(;f!==void 0;){if(c===f.index){let p;f.type===2?p=new fl(o,o.nextSibling,this,t):f.type===1?p=new f.ctor(o,f.name,f.strings,this,t):f.type===6&&(p=new ld(o,this,t)),this._$AV.push(p),f=i[++d]}c!==(f==null?void 0:f.index)&&(o=Ws.nextNode(),c++)}return Ws.currentNode=Hs,s}p(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++}},fl=class A2{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=Qe,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}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=js(this,t,e),zn(t)?t===Qe||t==null||t===""?(this._$AH!==Qe&&this._$AR(),this._$AH=Qe):t!==this._$AH&&t!==fs&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):Xh(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!==Qe&&zn(this._$AH)?this._$AA.nextSibling.data=t:this.$(Hs.createTextNode(t)),this._$AH=t}g(t){var o;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=ul.createElement(id(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(e);else{const c=new sd(s,this),d=c.u(this.options);c.p(e),this.$(d),this._$AH=c}}_$AC(t){let e=ed.get(t.strings);return e===void 0&&ed.set(t.strings,e=new ul(t)),e}T(t){zh(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new A2(this.k(ja()),this.k(ja()),this,this.options)):i=e[s],i._$AI(o),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?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._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Zn=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,o){this.type=1,this._$AH=Qe,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Qe}_$AI(t,e=this,i,s){const o=this.strings;let c=!1;if(o===void 0)t=js(this,t,e,0),c=!zn(t)||t!==this._$AH&&t!==fs,c&&(this._$AH=t);else{const d=t;let f,p;for(t=o[0],f=0;f<o.length-1;f++)p=js(this,d[i+f],e,f),p===fs&&(p=this._$AH[f]),c||(c=!zn(p)||p!==this._$AH[f]),p===Qe?t=Qe:t!==Qe&&(t+=(p??"")+o[f+1]),this._$AH[f]=p}c&&!s&&this.O(t)}O(t){t===Qe?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},nd=class extends Zn{constructor(){super(...arguments),this.type=3}O(t){this.element[this.name]=t===Qe?void 0:t}},ad=class extends Zn{constructor(){super(...arguments),this.type=4}O(t){this.element.toggleAttribute(this.name,!!t&&t!==Qe)}},od=class extends Zn{constructor(t,e,i,s,o){super(t,e,i,s,o),this.type=5}_$AI(t,e=this){if((t=js(this,t,e,0)??Qe)===fs)return;const i=this._$AH,s=t===Qe&&i!==Qe||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==Qe&&(i===Qe||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},ld=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){js(this,t)}};const P2={j:cl,P:zr,A:hl,C:1,M:rd,L:sd,R:Xh,V:js,D:fl,I:Zn,H:ad,N:od,U:nd,B:ld},pl=Yn.litHtmlPolyfillSupport;pl==null||pl(ul,fl),(Yn.litHtmlVersions??(Yn.litHtmlVersions=[])).push("3.1.0");/**
16
+ * @license
17
+ * Copyright 2019 Google LLC
18
+ * SPDX-License-Identifier: BSD-3-Clause
19
+ */const Ka=globalThis,gl=Ka.ShadowRoot&&(Ka.ShadyCSS===void 0||Ka.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ml=Symbol(),cd=new WeakMap;let hd=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==ml)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(gl&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=cd.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&cd.set(e,t))}return t}toString(){return this.cssText}};const qn=n=>new hd(typeof n=="string"?n:n+"",void 0,ml),Ti=(n,...t)=>{const e=n.length===1?n[0]:t.reduce((i,s,o)=>i+(c=>{if(c._$cssResult$===!0)return c.cssText;if(typeof c=="number")return c;throw Error("Value passed to 'css' function must be a 'css' function result: "+c+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+n[o+1],n[0]);return new hd(e,n,ml)},O2=(n,t)=>{if(gl)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=Ka.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,n.appendChild(i)}},dd=gl?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return qn(e)})(n):n;/**
16
20
  * @license
17
21
  * Copyright 2017 Google LLC
18
22
  * SPDX-License-Identifier: BSD-3-Clause
19
- */var Fr;const Ds=window,yi=Ds.trustedTypes,qa=yi?yi.createPolicy("lit-html",{createHTML:r=>r}):void 0,Cs="$lit$",Pe=`lit$${(Math.random()+"").slice(9)}$`,Nr="?"+Pe,Kc=`<${Nr}>`,Qe=document,Vi=()=>Qe.createComment(""),Ki=r=>r===null||typeof r!="object"&&typeof r!="function",za=Array.isArray,Xa=r=>za(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",Ur=`[
20
- \f\r]`,ji=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Qa=/-->/g,Za=/>/g,Ze=RegExp(`>|${Ur}(?:([^\\s"'>=/]+)(${Ur}*=${Ur}*(?:[^
21
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Ja=/'/g,to=/"/g,eo=/^(?:script|style|textarea|title)$/i,jc=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),st=jc(1),Ee=Symbol.for("lit-noChange"),It=Symbol.for("lit-nothing"),io=new WeakMap,Je=Qe.createTreeWalker(Qe,129,null,!1),so=(r,t)=>{const e=r.length-1,i=[];let s,n=t===2?"<svg>":"",a=ji;for(let l=0;l<e;l++){const h=r[l];let c,d,u=-1,f=0;for(;f<h.length&&(a.lastIndex=f,d=a.exec(h),d!==null);)f=a.lastIndex,a===ji?d[1]==="!--"?a=Qa:d[1]!==void 0?a=Za:d[2]!==void 0?(eo.test(d[2])&&(s=RegExp("</"+d[2],"g")),a=Ze):d[3]!==void 0&&(a=Ze):a===Ze?d[0]===">"?(a=s??ji,u=-1):d[1]===void 0?u=-2:(u=a.lastIndex-d[2].length,c=d[1],a=d[3]===void 0?Ze:d[3]==='"'?to:Ja):a===to||a===Ja?a=Ze:a===Qa||a===Za?a=ji:(a=Ze,s=void 0);const p=a===Ze&&r[l+1].startsWith("/>")?" ":"";n+=a===ji?h+Kc:u>=0?(i.push(c),h.slice(0,u)+Cs+h.slice(u)+Pe+p):h+Pe+(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[qa!==void 0?qa.createHTML(o):o,i]};class Wi{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let n=0,a=0;const o=t.length-1,l=this.parts,[h,c]=so(t,e);if(this.el=Wi.createElement(h,i),Je.currentNode=this.el.content,e===2){const d=this.el.content,u=d.firstChild;u.remove(),d.append(...u.childNodes)}for(;(s=Je.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes()){const d=[];for(const u of s.getAttributeNames())if(u.endsWith(Cs)||u.startsWith(Pe)){const f=c[a++];if(d.push(u),f!==void 0){const p=s.getAttribute(f.toLowerCase()+Cs).split(Pe),g=/([.?@])?(.*)/.exec(f);l.push({type:1,index:n,name:g[2],strings:p,ctor:g[1]==="."?no:g[1]==="?"?ao:g[1]==="@"?oo:Yi})}else l.push({type:6,index:n})}for(const u of d)s.removeAttribute(u)}if(eo.test(s.tagName)){const d=s.textContent.split(Pe),u=d.length-1;if(u>0){s.textContent=yi?yi.emptyScript:"";for(let f=0;f<u;f++)s.append(d[f],Vi()),Je.nextNode(),l.push({type:2,index:++n});s.append(d[u],Vi())}}}else if(s.nodeType===8)if(s.data===Nr)l.push({type:2,index:n});else{let d=-1;for(;(d=s.data.indexOf(Pe,d+1))!==-1;)l.push({type:7,index:n}),d+=Pe.length-1}n++}}static createElement(t,e){const i=Qe.createElement("template");return i.innerHTML=t,i}}function ti(r,t,e=r,i){var s,n,a,o;if(t===Ee)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=ti(r,l._$AS(r,t.values),l,i)),t}let ro=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:Qe).importNode(i,!0);Je.currentNode=n;let a=Je.nextNode(),o=0,l=0,h=s[0];for(;h!==void 0;){if(o===h.index){let c;h.type===2?c=new xs(a,a.nextSibling,this,t):h.type===1?c=new h.ctor(a,h.name,h.strings,this,t):h.type===6&&(c=new lo(a,this,t)),this._$AV.push(c),h=s[++l]}o!==(h==null?void 0:h.index)&&(a=Je.nextNode(),o++)}return Je.currentNode=Qe,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++}},xs=class xc{constructor(t,e,i,s){var n;this.type=2,this._$AH=It,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=ti(this,t,e),Ki(t)?t===It||t==null||t===""?(this._$AH!==It&&this._$AR(),this._$AH=It):t!==this._$AH&&t!==Ee&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):Xa(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!==It&&Ki(this._$AH)?this._$AA.nextSibling.data=t:this.$(Qe.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=Wi.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 ro(n,this),o=a.u(this.options);a.v(i),this.$(o),this._$AH=a}}_$AC(t){let e=io.get(t.strings);return e===void 0&&io.set(t.strings,e=new Wi(t)),e}T(t){za(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 xc(this.k(Vi()),this.k(Vi()),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=It,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=It}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=ti(this,t,e,0),a=!Ki(t)||t!==this._$AH&&t!==Ee,a&&(this._$AH=t);else{const o=t;let l,h;for(t=n[0],l=0;l<n.length-1;l++)h=ti(this,o[i+l],e,l),h===Ee&&(h=this._$AH[l]),a||(a=!Ki(h)||h!==this._$AH[l]),h===It?t=It:t!==It&&(t+=(h??"")+n[l+1]),this._$AH[l]=h}a&&!s&&this.j(t)}j(t){t===It?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class no extends Yi{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===It?void 0:t}}const Wc=yi?yi.emptyScript:"";class ao extends Yi{constructor(){super(...arguments),this.type=4}j(t){t&&t!==It?this.element.setAttribute(this.name,Wc):this.element.removeAttribute(this.name)}}let oo=class 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=ti(this,t,e,0))!==null&&i!==void 0?i:It)===Ee)return;const s=this._$AH,n=t===It&&s!==It||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,a=t!==It&&(s===It||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){ti(this,t)}}const Yc={O:Cs,P:Pe,A:Nr,C:1,M:so,L:ro,D:Xa,R:ti,I:xs,V:Yi,H:ao,N:oo,U:no,F:lo},ho=Ds.litHtmlPolyfillSupport;ho==null||ho(Wi,xs),((Fr=Ds.litHtmlVersions)!==null&&Fr!==void 0?Fr:Ds.litHtmlVersions=[]).push("2.7.4");const qc=(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 xs(t.insertBefore(Vi(),o),o,void 0,e??{})}return a._$AI(r),a};/**
23
+ */const{is:M2,defineProperty:$2,getOwnPropertyDescriptor:N2,getOwnPropertyNames:F2,getOwnPropertySymbols:U2,getPrototypeOf:B2}=Object,ps=globalThis,ud=ps.trustedTypes,G2=ud?ud.emptyScript:"",vl=ps.reactiveElementPolyfillSupport,Qn=(n,t)=>n,yl={toAttribute(n,t){switch(t){case Boolean:n=n?G2:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},fd=(n,t)=>!M2(n,t),pd={attribute:!0,type:String,converter:yl,reflect:!1,hasChanged:fd};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),ps.litPropertyMetadata??(ps.litPropertyMetadata=new WeakMap);let mn=class 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=pd){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&&$2(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:o}=N2(this.prototype,t)??{get(){return this[e]},set(c){this[e]=c}};return{get(){return s==null?void 0:s.call(this)},set(c){const d=s==null?void 0:s.call(this);o.call(this,c),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??pd}static _$Ei(){if(this.hasOwnProperty(Qn("elementProperties")))return;const t=B2(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Qn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Qn("properties"))){const e=this.properties,i=[...F2(e),...U2(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(dd(s))}else t!==void 0&&e.push(dd(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._$ES(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$E_??(this._$E_=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$E_)==null||e.delete(t)}_$ES(){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 O2(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$E_)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$E_)==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 o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const c=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:yl).toAttribute(e,i.type);this._$Em=t,c==null?this.removeAttribute(s):this.setAttribute(s,c),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const c=i.getPropertyOptions(s),d=typeof c.converter=="function"?{fromAttribute:c.converter}:((o=c.converter)==null?void 0:o.fromAttribute)!==void 0?c.converter:yl;this._$Em=s,this[s]=d.fromAttribute(e,c.type),this._$Em=null}}requestUpdate(t,e,i,s=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??fd)(s?o: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.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,c]of this._$Ep)this[o]=c;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,c]of s)c.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],c)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$E_)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.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._$E_)==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){}};mn.elementStyles=[],mn.shadowRootOptions={mode:"open"},mn[Qn("elementProperties")]=new Map,mn[Qn("finalized")]=new Map,vl==null||vl({ReactiveElement:mn}),(ps.reactiveElementVersions??(ps.reactiveElementVersions=[])).push("2.0.2");/**
22
24
  * @license
23
25
  * Copyright 2017 Google LLC
24
26
  * SPDX-License-Identifier: BSD-3-Clause
25
- */var Br,Hr;let Ei=class extends gi{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=qc(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 Ee}};Ei.finalized=!0,Ei._$litElement$=!0,(Br=globalThis.litElementHydrateSupport)===null||Br===void 0||Br.call(globalThis,{LitElement:Ei});const co=globalThis.litElementPolyfillSupport;co==null||co({LitElement:Ei}),((Hr=globalThis.litElementVersions)!==null&&Hr!==void 0?Hr:globalThis.litElementVersions=[]).push("3.3.2");/**
27
+ */const Jn=globalThis,Ya=Jn.trustedTypes,gd=Ya?Ya.createPolicy("lit-html",{createHTML:n=>n}):void 0,md="$lit$",gs=`lit$${(Math.random()+"").slice(9)}$`,vd="?"+gs,H2=`<${vd}>`,Ks=document,ta=()=>Ks.createComment(""),ea=n=>n===null||typeof n!="object"&&typeof n!="function",yd=Array.isArray,V2=n=>yd(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",bl=`[
28
+ \f\r]`,ia=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,bd=/-->/g,Ad=/>/g,Ys=RegExp(`>|${bl}(?:([^\\s"'>=/]+)(${bl}*=${bl}*(?:[^
29
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Ed=/'/g,Td=/"/g,kd=/^(?:script|style|textarea|title)$/i,W2=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),ie=W2(1),ms=Symbol.for("lit-noChange"),di=Symbol.for("lit-nothing"),wd=new WeakMap,zs=Ks.createTreeWalker(Ks,129);function Sd(n,t){if(!Array.isArray(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return gd!==void 0?gd.createHTML(t):t}const j2=(n,t)=>{const e=n.length-1,i=[];let s,o=t===2?"<svg>":"",c=ia;for(let d=0;d<e;d++){const f=n[d];let p,g,v=-1,b=0;for(;b<f.length&&(c.lastIndex=b,g=c.exec(f),g!==null);)b=c.lastIndex,c===ia?g[1]==="!--"?c=bd:g[1]!==void 0?c=Ad:g[2]!==void 0?(kd.test(g[2])&&(s=RegExp("</"+g[2],"g")),c=Ys):g[3]!==void 0&&(c=Ys):c===Ys?g[0]===">"?(c=s??ia,v=-1):g[1]===void 0?v=-2:(v=c.lastIndex-g[2].length,p=g[1],c=g[3]===void 0?Ys:g[3]==='"'?Td:Ed):c===Td||c===Ed?c=Ys:c===bd||c===Ad?c=ia:(c=Ys,s=void 0);const E=c===Ys&&n[d+1].startsWith("/>")?" ":"";o+=c===ia?f+H2:v>=0?(i.push(p),f.slice(0,v)+md+f.slice(v)+gs+E):f+gs+(v===-2?d:E)}return[Sd(n,o+(n[e]||"<?>")+(t===2?"</svg>":"")),i]};class ra{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,c=0;const d=t.length-1,f=this.parts,[p,g]=j2(t,e);if(this.el=ra.createElement(p,i),zs.currentNode=this.el.content,e===2){const v=this.el.content.firstChild;v.replaceWith(...v.childNodes)}for(;(s=zs.nextNode())!==null&&f.length<d;){if(s.nodeType===1){if(s.hasAttributes())for(const v of s.getAttributeNames())if(v.endsWith(md)){const b=g[c++],E=s.getAttribute(v).split(gs),T=/([.?@])?(.*)/.exec(b);f.push({type:1,index:o,name:T[2],strings:E,ctor:T[1]==="."?Y2:T[1]==="?"?z2:T[1]==="@"?X2:za}),s.removeAttribute(v)}else v.startsWith(gs)&&(f.push({type:6,index:o}),s.removeAttribute(v));if(kd.test(s.tagName)){const v=s.textContent.split(gs),b=v.length-1;if(b>0){s.textContent=Ya?Ya.emptyScript:"";for(let E=0;E<b;E++)s.append(v[E],ta()),zs.nextNode(),f.push({type:2,index:++o});s.append(v[b],ta())}}}else if(s.nodeType===8)if(s.data===vd)f.push({type:2,index:o});else{let v=-1;for(;(v=s.data.indexOf(gs,v+1))!==-1;)f.push({type:7,index:o}),v+=gs.length-1}o++}}static createElement(t,e){const i=Ks.createElement("template");return i.innerHTML=t,i}}function vn(n,t,e=n,i){var c,d;if(t===ms)return t;let s=i!==void 0?(c=e._$Co)==null?void 0:c[i]:e._$Cl;const o=ea(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((d=s==null?void 0:s._$AO)==null||d.call(s,!1),o===void 0?s=void 0:(s=new o(n),s._$AT(n,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=s:e._$Cl=s),s!==void 0&&(t=vn(n,s._$AS(n,t.values),s,i)),t}let K2=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){const{el:{content:e},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??Ks).importNode(e,!0);zs.currentNode=s;let o=zs.nextNode(),c=0,d=0,f=i[0];for(;f!==void 0;){if(c===f.index){let p;f.type===2?p=new Al(o,o.nextSibling,this,t):f.type===1?p=new f.ctor(o,f.name,f.strings,this,t):f.type===6&&(p=new Z2(o,this,t)),this._$AV.push(p),f=i[++d]}c!==(f==null?void 0:f.index)&&(o=zs.nextNode(),c++)}return zs.currentNode=Ks,s}p(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++}},Al=class E2{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=di,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}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=vn(this,t,e),ea(t)?t===di||t==null||t===""?(this._$AH!==di&&this._$AR(),this._$AH=di):t!==this._$AH&&t!==ms&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):V2(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!==di&&ea(this._$AH)?this._$AA.nextSibling.data=t:this.$(Ks.createTextNode(t)),this._$AH=t}g(t){var o;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=ra.createElement(Sd(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(e);else{const c=new K2(s,this),d=c.u(this.options);c.p(e),this.$(d),this._$AH=c}}_$AC(t){let e=wd.get(t.strings);return e===void 0&&wd.set(t.strings,e=new ra(t)),e}T(t){yd(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new E2(this.k(ta()),this.k(ta()),this,this.options)):i=e[s],i._$AI(o),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?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._$Cv=t,(e=this._$AP)==null||e.call(this,t))}};class za{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,o){this.type=1,this._$AH=di,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=di}_$AI(t,e=this,i,s){const o=this.strings;let c=!1;if(o===void 0)t=vn(this,t,e,0),c=!ea(t)||t!==this._$AH&&t!==ms,c&&(this._$AH=t);else{const d=t;let f,p;for(t=o[0],f=0;f<o.length-1;f++)p=vn(this,d[i+f],e,f),p===ms&&(p=this._$AH[f]),c||(c=!ea(p)||p!==this._$AH[f]),p===di?t=di:t!==di&&(t+=(p??"")+o[f+1]),this._$AH[f]=p}c&&!s&&this.O(t)}O(t){t===di?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Y2 extends za{constructor(){super(...arguments),this.type=3}O(t){this.element[this.name]=t===di?void 0:t}}let z2=class extends za{constructor(){super(...arguments),this.type=4}O(t){this.element.toggleAttribute(this.name,!!t&&t!==di)}};class X2 extends za{constructor(t,e,i,s,o){super(t,e,i,s,o),this.type=5}_$AI(t,e=this){if((t=vn(this,t,e,0)??di)===ms)return;const i=this._$AH,s=t===di&&i!==di||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==di&&(i===di||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}let Z2=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){vn(this,t)}};const El=Jn.litHtmlPolyfillSupport;El==null||El(ra,Al),(Jn.litHtmlVersions??(Jn.litHtmlVersions=[])).push("3.1.0");const q2=(n,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const o=(e==null?void 0:e.renderBefore)??null;i._$litPart$=s=new Al(t.insertBefore(ta(),o),o,void 0,e??{})}return s._$AI(n),s};/**
26
30
  * @license
27
31
  * Copyright 2017 Google LLC
28
32
  * SPDX-License-Identifier: BSD-3-Clause
29
- */const zc=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);/**
33
+ */let yn=class extends mn{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=q2(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return ms}};yn._$litElement$=!0,yn.finalized=!0,(ep=globalThis.litElementHydrateSupport)==null||ep.call(globalThis,{LitElement:yn});const Tl=globalThis.litElementPolyfillSupport;Tl==null||Tl({LitElement:yn}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.2");/**
30
34
  * @license
31
35
  * Copyright 2017 Google LLC
32
36
  * SPDX-License-Identifier: BSD-3-Clause
33
- */const Xc=(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)}},Qc=(r,t,e)=>{t.constructor.createProperty(e,r)};function j(r){return(t,e)=>e!==void 0?Qc(r,t,e):Xc(r,t)}/**
37
+ */const Q2=n=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(n,t)}):customElements.define(n,t)};/**
34
38
  * @license
35
39
  * Copyright 2017 Google LLC
36
40
  * SPDX-License-Identifier: BSD-3-Clause
37
- */function Wt(r){return j({...r,state:!0})}/**
41
+ */const J2={attribute:!0,type:String,converter:Va,reflect:!1,hasChanged:ll},tg=(n=J2,t,e)=>{const{kind:i,metadata:s}=e;let o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),o.set(e.name,n),i==="accessor"){const{name:c}=e;return{set(d){const f=t.get.call(this);t.set.call(this,d),this.requestUpdate(c,f,n)},init(d){return d!==void 0&&this.C(c,void 0,n),d}}}if(i==="setter"){const{name:c}=e;return function(d){const f=this[c];t.call(this,d),this.requestUpdate(c,f,n)}}throw Error("Unsupported decorator location: "+i)};function It(n){return(t,e)=>typeof e=="object"?tg(n,t,e):((i,s,o)=>{const c=s.hasOwnProperty(o);return s.constructor.createProperty(o,c?{...i,wrapped:!0}:i),c?Object.getOwnPropertyDescriptor(s,o):void 0})(n,t,e)}/**
38
42
  * @license
39
- * Copyright 2021 Google LLC
43
+ * Copyright 2017 Google LLC
40
44
  * SPDX-License-Identifier: BSD-3-Clause
41
- */var Gr;((Gr=window.HTMLSlotElement)===null||Gr===void 0?void 0:Gr.prototype.assignedElements)!=null;/**
45
+ */function ki(n){return It({...n,state:!0,attribute:!1})}/**
42
46
  * @license
43
47
  * Copyright 2018 Google LLC
44
48
  * SPDX-License-Identifier: BSD-3-Clause
45
- */const uo=r=>r??kt;/**
49
+ */const Xs=n=>n??Qe;/**
46
50
  * @license
47
51
  * Copyright 2020 Google LLC
48
52
  * SPDX-License-Identifier: BSD-3-Clause
49
- */const Zc=r=>r.strings===void 0;/**
53
+ */const{D:eg}=P2,ig=n=>n.strings===void 0,Rd=()=>document.createComment(""),sa=(n,t,e)=>{var o;const i=n._$AA.parentNode,s=t===void 0?n._$AB:t._$AA;if(e===void 0){const c=i.insertBefore(Rd(),s),d=i.insertBefore(Rd(),s);e=new eg(c,d,n,n.options)}else{const c=e._$AB.nextSibling,d=e._$AM,f=d!==n;if(f){let p;(o=e._$AQ)==null||o.call(e,n),e._$AM=n,e._$AP!==void 0&&(p=n._$AU)!==d._$AU&&e._$AP(p)}if(c!==s||f){let p=e._$AA;for(;p!==c;){const g=p.nextSibling;i.insertBefore(p,s),p=g}}}return e},Zs=(n,t,e=n)=>(n._$AI(t,e),n),rg={},sg=(n,t=rg)=>n._$AH=t,ng=n=>n._$AH,kl=n=>{var i;(i=n._$AP)==null||i.call(n,!1,!0);let t=n._$AA;const e=n._$AB.nextSibling;for(;t!==e;){const s=t.nextSibling;t.remove(),t=s}};/**
50
54
  * @license
51
55
  * Copyright 2017 Google LLC
52
56
  * SPDX-License-Identifier: BSD-3-Clause
53
- */const Jc={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},td=r=>(...t)=>({_$litDirective$:r,values:t});let ed=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)}};/**
57
+ */const bn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},An=n=>(...t)=>({_$litDirective$:n,values:t});let na=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
58
  * @license
55
59
  * Copyright 2017 Google LLC
56
60
  * SPDX-License-Identifier: BSD-3-Clause
57
- */const qi=(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),qi(n,t);return!0},Ps=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)},fo=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),rd(t)}};function id(r){this._$AN!==void 0?(Ps(this),this._$AM=r,fo(this)):this._$AM=r}function sd(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++)qi(i[n],!1),Ps(i[n]);else i!=null&&(qi(i,!1),Ps(i));else qi(this,r)}const rd=r=>{var t,e,i,s;r.type==Jc.CHILD&&((t=(i=r)._$AP)!==null&&t!==void 0||(i._$AP=sd),(e=(s=r)._$AQ)!==null&&e!==void 0||(s._$AQ=id))};let nd=class extends ed{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),fo(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&&(qi(this,t),Ps(this))}setValue(t){if(Zc(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(){}};/**
61
+ */const aa=(n,t)=>{var i;const e=n._$AN;if(e===void 0)return!1;for(const s of e)(i=s._$AO)==null||i.call(s,t,!1),aa(s,t);return!0},Xa=n=>{let t,e;do{if((t=n._$AM)===void 0)break;e=t._$AN,e.delete(n),n=t}while((e==null?void 0:e.size)===0)},_d=n=>{for(let t;t=n._$AM;n=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(n))break;e.add(n),lg(t)}};function ag(n){this._$AN!==void 0?(Xa(this),this._$AM=n,_d(this)):this._$AM=n}function og(n,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 o=e;o<i.length;o++)aa(i[o],!1),Xa(i[o]);else i!=null&&(aa(i,!1),Xa(i));else aa(this,n)}const lg=n=>{n.type==bn.CHILD&&(n._$AP??(n._$AP=og),n._$AQ??(n._$AQ=ag))};let Ld=class extends na{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),_d(this),this.isConnected=t._$AU}_$AO(t,e=!0){var i,s;t!==this.isConnected&&(this.isConnected=t,t?(i=this.reconnected)==null||i.call(this):(s=this.disconnected)==null||s.call(this)),e&&(aa(this,t),Xa(this))}setValue(t){if(ig(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
62
  * @license
59
63
  * Copyright 2020 Google LLC
60
64
  * SPDX-License-Identifier: BSD-3-Clause
61
- */const po=()=>new ad;let ad=class{};const Vr=new WeakMap,go=td(class extends nd{render(r){return kt}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)),kt}ot(r){var t;if(typeof this.G=="function"){const e=(t=this.dt)!==null&&t!==void 0?t:globalThis;let i=Vr.get(e);i===void 0&&(i=new WeakMap,Vr.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=Vr.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 od(r,t,e){function i(s){e.dispatchEvent(new CustomEvent(s.type,s))}return t.addEventListener(r,i),()=>{t.removeEventListener(r,i)}}class ld{constructor(t,e){this._events=[],this._cleanup=[],this._forwardElementRef=po(),this.host=t,this._events=e,t.addController(this)}register(){return go(this._forwardElementRef)}hostConnected(){requestAnimationFrame(()=>{this._events.forEach(t=>{this._forwardElementRef.value&&this._cleanup.push(od(t,this._forwardElementRef.value,this.host))})})}hostDisconnected(){this._cleanup.forEach(t=>{t()}),this._cleanup=[]}}/**
65
+ */const wi=()=>new cg;let cg=class{};const wl=new WeakMap,Si=An(class extends Ld{render(n){return Qe}update(n,[t]){var i;const e=t!==this.G;return e&&this.G!==void 0&&this.ot(void 0),(e||this.rt!==this.lt)&&(this.G=t,this.ct=(i=n.options)==null?void 0:i.host,this.ot(this.lt=n.element)),Qe}ot(n){if(typeof this.G=="function"){const t=this.ct??globalThis;let e=wl.get(t);e===void 0&&(e=new WeakMap,wl.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ct,void 0),e.set(this.G,n),n!==void 0&&this.G.call(this.ct,n)}else this.G.value=n}get rt(){var n,t;return typeof this.G=="function"?(n=wl.get(this.ct??globalThis))==null?void 0:n.get(this.G):(t=this.G)==null?void 0:t.value}disconnected(){this.rt===this.lt&&this.ot(void 0)}reconnected(){this.ot(this.lt)}});function hg(n,t,e){function i(s){e.dispatchEvent(new CustomEvent(s.type,s))}return t.addEventListener(n,i),()=>{t.removeEventListener(n,i)}}class dg{constructor(t,e){this._events=[],this._cleanup=[],this._forwardElementRef=wi(),this.host=t,this._events=e,t.addController(this)}register(){return Si(this._forwardElementRef)}hostConnected(){requestAnimationFrame(()=>{this._events.forEach(t=>{this._forwardElementRef.value&&this._cleanup.push(hg(t,this._forwardElementRef.value,this.host))})})}hostDisconnected(){this._cleanup.forEach(t=>{t()}),this._cleanup=[]}}/**
62
66
  * @license
63
67
  * Copyright 2019 Google LLC
64
68
  * SPDX-License-Identifier: BSD-3-Clause
65
- */const Os=globalThis,Kr=Os.ShadowRoot&&(Os.ShadyCSS===void 0||Os.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,mo=Symbol(),vo=new WeakMap;let hd=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==mo)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(Kr&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=vo.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&vo.set(e,t))}return t}toString(){return this.cssText}};const cd=r=>new hd(typeof r=="string"?r:r+"",void 0,mo),dd=(r,t)=>{if(Kr)r.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=Os.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,r.appendChild(i)}},yo=Kr?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return cd(e)})(r):r;/**
69
+ */const Za=globalThis,Sl=Za.ShadowRoot&&(Za.ShadyCSS===void 0||Za.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Cd=Symbol(),Id=new WeakMap;let ug=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Cd)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(Sl&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=Id.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Id.set(e,t))}return t}toString(){return this.cssText}};const fg=n=>new ug(typeof n=="string"?n:n+"",void 0,Cd),pg=(n,t)=>{if(Sl)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=Za.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,n.appendChild(i)}},xd=Sl?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return fg(e)})(n):n;/**
66
70
  * @license
67
71
  * Copyright 2017 Google LLC
68
72
  * SPDX-License-Identifier: BSD-3-Clause
69
- */const{is:ud,defineProperty:fd,getOwnPropertyDescriptor:pd,getOwnPropertyNames:gd,getOwnPropertySymbols:md,getPrototypeOf:vd}=Object,He=globalThis,Eo=He.trustedTypes,yd=Eo?Eo.emptyScript:"",jr=He.reactiveElementPolyfillSupport,zi=(r,t)=>r,Wr={toAttribute(r,t){switch(t){case Boolean:r=r?yd: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}},Yr=(r,t)=>!ud(r,t),bo={attribute:!0,type:String,converter:Wr,reflect:!1,hasChanged:Yr};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),He.litPropertyMetadata??(He.litPropertyMetadata=new WeakMap);class Xi 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=bo){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&&fd(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:n}=pd(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)??bo}static _$Ei(){if(this.hasOwnProperty(zi("elementProperties")))return;const t=vd(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(zi("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(zi("properties"))){const e=this.properties,i=[...gd(e),...md(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(yo(s))}else t!==void 0&&e.push(yo(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 dd(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:Wr).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:Wr;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??Yr)(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){}}Xi.elementStyles=[],Xi.shadowRootOptions={mode:"open"},Xi[zi("elementProperties")]=new Map,Xi[zi("finalized")]=new Map,jr==null||jr({ReactiveElement:Xi}),(He.reactiveElementVersions??(He.reactiveElementVersions=[])).push("2.0.0");/**
73
+ */const{is:gg,defineProperty:mg,getOwnPropertyDescriptor:vg,getOwnPropertyNames:yg,getOwnPropertySymbols:bg,getPrototypeOf:Ag}=Object,vs=globalThis,Dd=vs.trustedTypes,Eg=Dd?Dd.emptyScript:"",Rl=vs.reactiveElementPolyfillSupport,oa=(n,t)=>n,_l={toAttribute(n,t){switch(t){case Boolean:n=n?Eg:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},Ll=(n,t)=>!gg(n,t),Pd={attribute:!0,type:String,converter:_l,reflect:!1,hasChanged:Ll};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),vs.litPropertyMetadata??(vs.litPropertyMetadata=new WeakMap);class la 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=Pd){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&&mg(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:o}=vg(this.prototype,t)??{get(){return this[e]},set(c){this[e]=c}};return{get(){return s==null?void 0:s.call(this)},set(c){const d=s==null?void 0:s.call(this);o.call(this,c),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Pd}static _$Ei(){if(this.hasOwnProperty(oa("elementProperties")))return;const t=Ag(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(oa("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(oa("properties"))){const e=this.properties,i=[...yg(e),...bg(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(xd(s))}else t!==void 0&&e.push(xd(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 pg(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 o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const c=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:_l).toAttribute(e,i.type);this._$Em=t,c==null?this.removeAttribute(s):this.setAttribute(s,c),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const c=i.getPropertyOptions(s),d=typeof c.converter=="function"?{fromAttribute:c.converter}:((o=c.converter)==null?void 0:o.fromAttribute)!==void 0?c.converter:_l;this._$Em=s,this[s]=d.fromAttribute(e,c.type),this._$Em=null}}requestUpdate(t,e,i,s=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??Ll)(s?o: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[o,c]of this._$Ep)this[o]=c;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,c]of s)c.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],c)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$ES)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.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){}}la.elementStyles=[],la.shadowRootOptions={mode:"open"},la[oa("elementProperties")]=new Map,la[oa("finalized")]=new Map,Rl==null||Rl({ReactiveElement:la}),(vs.reactiveElementVersions??(vs.reactiveElementVersions=[])).push("2.0.0");/**
70
74
  * @license
71
75
  * Copyright 2017 Google LLC
72
76
  * SPDX-License-Identifier: BSD-3-Clause
73
- */const Ed=Symbol();let To=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??bd,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,c;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(d){n=!0,i=d}if(this.u===s){if(e===Ed)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,(c=this.o)==null||c.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 bd=(r,t)=>r===t||r.length===t.length&&r.every((e,i)=>!Yr(e,t[i])),qr="https://vouchfor.com",Td="https://d2rxhdlm2q91uk.cloudfront.net",Ad="https://d1ix11aj5kfygl.cloudfront.net",wd="https://d157jlwnudd93d.cloudfront.net",Sd="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",Ld="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",Rd="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",_d="https://embed-dev.vouchfor.com/v2",kd="https://embed-staging.vouchfor.com/v2",Id="https://embed.vouchfor.com/v2",Dd="https://dev.vouchfor.com",Cd="https://staging.vouchfor.com",xd="https://app.vouchfor.com";function $s(r){if(!["dev","staging","prod"].includes(r))throw new Error(`Unknown environment: ${r}`);if(r==="dev")return{marketingUrl:qr,videoUrl:Td,publicApiUrl:Sd,embedApiUrl:_d,publicRecorderUrl:Dd};if(r==="staging")return{marketingUrl:qr,videoUrl:Ad,publicApiUrl:Ld,embedApiUrl:kd,publicRecorderUrl:Cd};if(r==="prod")return{marketingUrl:qr,videoUrl:wd,publicApiUrl:Rd,embedApiUrl:Id,publicRecorderUrl:xd}}class Pd{constructor(t){this._fetching=!1,this.getVouch=async(e,i,s)=>{const{embedApiUrl:n}=$s(e),a=await fetch(`${n}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i]]}).then(o=>(this.host.dispatchEvent(new CustomEvent("vouch:loaded",{detail:s})),o.json()));return fetch(`${n}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),a},this.getTemplate=async(e,i,s)=>{const{embedApiUrl:n}=$s(e),a=await fetch(`${n}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i]]}).then(o=>o.json());return fetch(`${n}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),a},this.host=t,new To(this.host,async([e,i,s,n,a])=>{var o,l,h,c;try{if(t.vouch=void 0,t.template=void 0,s){let d;a&&(this.fetching=!0,d=await this.getTemplate(e,i,a)),t.vouch=s,t.template=d??((l=(o=s==null?void 0:s.settings)==null?void 0:o.template)==null?void 0:l.instance)}else if(n){this.fetching=!0;const[d,u]=await Promise.all([this.getVouch(e,i,n),a?this.getTemplate(e,i,a):null]);t.vouch=d,t.template=u??((c=(h=d==null?void 0:d.settings)==null?void 0:h.template)==null?void 0:c.instance)}}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}}let Ms;const Od=new Uint8Array(16);function $d(){if(!Ms&&(Ms=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ms))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ms(Od)}const Nt=[];for(let r=0;r<256;++r)Nt.push((r+256).toString(16).slice(1));function Md(r,t=0){return Nt[r[t+0]]+Nt[r[t+1]]+Nt[r[t+2]]+Nt[r[t+3]]+"-"+Nt[r[t+4]]+Nt[r[t+5]]+"-"+Nt[r[t+6]]+Nt[r[t+7]]+"-"+Nt[r[t+8]]+Nt[r[t+9]]+"-"+Nt[r[t+10]]+Nt[r[t+11]]+Nt[r[t+12]]+Nt[r[t+13]]+Nt[r[t+14]]+Nt[r[t+15]]}const Ao={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Qi(r,t,e){if(Ao.randomUUID&&!t&&!r)return Ao.randomUUID();r=r||{};const i=r.random||(r.rng||$d)();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 Md(i)}const Fd=2e3;class Nd{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}=$s(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,c=>c.slice(-1).toUpperCase());s[h]=l}}),{source:this.host.trackingSource,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}=$s(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]>Fd&&(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,c,d,u,f,p,g,v;if(typeof window>"u")return{client:null,tab:null,request:Qi()};const t=this._visitorId||((a=(n=window.localStorage)==null?void 0:n.getItem)==null?void 0:a.call(n,"vouch-uid-visitor"))||this._createVisitor(Qi()),e=this._clientId||((l=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:l.call(o,"vouch-uid-client"))||Qi(),i=this._tabId||((c=(h=window.sessionStorage)==null?void 0:h.getItem)==null?void 0:c.call(h,"vouch-uid-tab"))||Qi(),s=Qi();return t!==this._visitorId&&(this._visitorId=t,(u=(d=window.localStorage)==null?void 0:d.setItem)==null||u.call(d,"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,(v=(g=window.sessionStorage)==null?void 0:g.setItem)==null||v.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 Fs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function zr(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Xr={exports:{}};(function(r,t){(function(e,i){i(t)})(Fs,function(e){function i(b){var T,k,N=new Error(b);return T=N,k=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(T,k):T.__proto__=k,N}function s(b,T,k){var N=T.slice(0,k).split(/\n/),U=N.length,K=N[U-1].length+1;throw i(b+=" at line "+U+" col "+K+`:
74
-
75
- `+T.split(/\n/)[U-1]+`
76
- `+Array(K).join(" ")+"^")}i.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var n=new Function("return this")().Promise,a=!1;try{a=new Function("return (async function(){}).constructor")()}catch(b){if(!(b instanceof SyntaxError))throw b}function o(b,T){return Object.prototype.hasOwnProperty.call(b,T)}function l(b,T,k){for(var N in T)o(T,N)&&(T[N]==null||typeof T[N]!="object"||N!=="storage"&&N!=="prefixes"||k?b[N]=T[N]:b[N]=l({},T[N]));return b}var h=/^async +/,c=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,d=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,u=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,f=/[.*+\-?^${}()|[\]\\]/g;function p(b){return f.test(b)?b.replace(f,"\\$&"):b}function g(b,T){T.rmWhitespace&&(b=b.replace(/[\r\n]+/g,`
77
- `).replace(/^\s+|\s+$/gm,"")),c.lastIndex=0,d.lastIndex=0,u.lastIndex=0;var k=T.prefixes,N=[k.h,k.b,k.i,k.r,k.c,k.e].reduce(function(nt,it){return nt&&it?nt+"|"+p(it):it?p(it):nt},""),U=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+p(T.tags[1])+")","g"),K=new RegExp("([^]*?)"+p(T.tags[0])+"(-|_)?\\s*("+N+")?\\s*","g"),W=0,X=!1;function lt(nt,it){var vt,dt={f:[]},Ct=0,et="c";function ut(ve){var De=b.slice(W,ve),Ht=De.trim();if(et==="f")Ht==="safe"?dt.raw=!0:T.async&&h.test(Ht)?(Ht=Ht.replace(h,""),dt.f.push([Ht,"",!0])):dt.f.push([Ht,""]);else if(et==="fp")dt.f[dt.f.length-1][1]+=Ht;else if(et==="err"){if(Ht){var ne=De.search(/\S/);s("invalid syntax",b,W+ne)}}else dt[et]=Ht;W=ve+1}for(it==="h"||it==="b"||it==="c"?et="n":it==="r"&&(dt.raw=!0,it="i"),U.lastIndex=W;(vt=U.exec(b))!==null;){var bt=vt[1],pt=vt[2],Tt=vt[3],_t=vt[4],Ot=vt[5],ft=vt.index;if(bt)bt==="("?(Ct===0&&(et==="n"?(ut(ft),et="p"):et==="f"&&(ut(ft),et="fp")),Ct++):bt===")"?--Ct===0&&et!=="c"&&(ut(ft),et="err"):Ct===0&&bt==="|"?(ut(ft),et="f"):bt==="=>"&&(ut(ft),W+=1,et="res");else if(pt)if(pt==="/*"){var Yt=b.indexOf("*/",U.lastIndex);Yt===-1&&s("unclosed comment",b,vt.index),U.lastIndex=Yt+2}else pt==="'"?(d.lastIndex=vt.index,d.exec(b)?U.lastIndex=d.lastIndex:s("unclosed string",b,vt.index)):pt==='"'?(u.lastIndex=vt.index,u.exec(b)?U.lastIndex=u.lastIndex:s("unclosed string",b,vt.index)):pt==="`"&&(c.lastIndex=vt.index,c.exec(b)?U.lastIndex=c.lastIndex:s("unclosed string",b,vt.index));else if(Tt)return ut(ft),W=ft+vt[0].length,K.lastIndex=W,X=Ot,_t&&it==="h"&&(it="s"),dt.t=it,dt}return s("unclosed tag",b,nt),dt}var rt=function nt(it,vt){it.b=[],it.d=[];var dt,Ct=!1,et=[];function ut(ne,Mi){ne&&(ne=function(ee,fi,Ss,Ls){var Ce,O;return typeof fi.autoTrim=="string"?Ce=O=fi.autoTrim:Array.isArray(fi.autoTrim)&&(Ce=fi.autoTrim[1],O=fi.autoTrim[0]),(Ss||Ss===!1)&&(Ce=Ss),(Ls||Ls===!1)&&(O=Ls),Ce==="slurp"&&O==="slurp"?ee.trim():(Ce==="_"||Ce==="slurp"?ee=String.prototype.trimLeft?ee.trimLeft():ee.replace(/^[\s\uFEFF\xA0]+/,""):Ce!=="-"&&Ce!=="nl"||(ee=ee.replace(/^(?:\n|\r|\r\n)/,"")),O==="_"||O==="slurp"?ee=String.prototype.trimRight?ee.trimRight():ee.replace(/[\s\uFEFF\xA0]+$/,""):O!=="-"&&O!=="nl"||(ee=ee.replace(/(?:\n|\r|\r\n)$/,"")),ee)}(ne,T,X,Mi))&&(ne=ne.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),et.push(ne))}for(;(dt=K.exec(b))!==null;){var bt,pt=dt[1],Tt=dt[2],_t=dt[3]||"";for(var Ot in k)if(k[Ot]===_t){bt=Ot;break}ut(pt,Tt),W=dt.index+dt[0].length,bt||s("unrecognized tag type: "+_t,b,W);var ft=lt(dt.index,bt),Yt=ft.t;if(Yt==="h"){var ve=ft.n||"";T.async&&h.test(ve)&&(ft.a=!0,ft.n=ve.replace(h,"")),ft=nt(ft),et.push(ft)}else if(Yt==="c"){if(it.n===ft.n)return Ct?(Ct.d=et,it.b.push(Ct)):it.d=et,it;s("Helper start and end don't match",b,dt.index+dt[0].length)}else if(Yt==="b"){Ct?(Ct.d=et,it.b.push(Ct)):it.d=et;var De=ft.n||"";T.async&&h.test(De)&&(ft.a=!0,ft.n=De.replace(h,"")),Ct=ft,et=[]}else if(Yt==="s"){var Ht=ft.n||"";T.async&&h.test(Ht)&&(ft.a=!0,ft.n=Ht.replace(h,"")),et.push(ft)}else et.push(ft)}if(!vt)throw i('unclosed helper "'+it.n+'"');return ut(b.slice(W,b.length),!1),it.d=et,it}({f:[]},!0);if(T.plugins)for(var at=0;at<T.plugins.length;at++){var Rt=T.plugins[at];Rt.processAST&&(rt.d=Rt.processAST(rt.d,T))}return rt.d}function v(b,T){var k=g(b,T),N="var tR='';"+(T.useWith?"with("+T.varName+"||{}){":"")+S(k,T)+"if(cb){cb(null,tR)} return tR"+(T.useWith?"}":"");if(T.plugins)for(var U=0;U<T.plugins.length;U++){var K=T.plugins[U];K.processFnString&&(N=K.processFnString(N,T))}return N}function E(b,T){for(var k=0;k<T.length;k++){var N=T[k][0],U=T[k][1];b=(T[k][2]?"await ":"")+"c.l('F','"+N+"')("+b,U&&(b+=","+U),b+=")"}return b}function A(b,T,k,N,U,K){var W="{exec:"+(U?"async ":"")+y(k,T,b)+",params:["+N+"]";return K&&(W+=",name:'"+K+"'"),U&&(W+=",async:true"),W+="}"}function L(b,T){for(var k="[",N=0;N<b.length;N++){var U=b[N];k+=A(T,U.res||"",U.d,U.p||"",U.a,U.n),N<b.length&&(k+=",")}return k+="]"}function y(b,T,k){return"function("+T+"){var tR='';"+S(b,k)+"return tR}"}function S(b,T){for(var k=0,N=b.length,U="";k<N;k++){var K=b[k];if(typeof K=="string")U+="tR+='"+K+"';";else{var W=K.t,X=K.c||"",lt=K.f,rt=K.n||"",at=K.p||"",Rt=K.res||"",nt=K.b,it=!!K.a;if(W==="i"){T.defaultFilter&&(X="c.l('F','"+T.defaultFilter+"')("+X+")");var vt=E(X,lt);!K.raw&&T.autoEscape&&(vt="c.l('F','e')("+vt+")"),U+="tR+="+vt+";"}else if(W==="h")if(T.storage.nativeHelpers.get(rt))U+=T.storage.nativeHelpers.get(rt)(K,T);else{var dt=(it?"await ":"")+"c.l('H','"+rt+"')("+A(T,Rt,K.d,at,it);dt+=nt?","+L(nt,T):",[]",U+="tR+="+E(dt+=",c)",lt)+";"}else W==="s"?U+="tR+="+E((it?"await ":"")+"c.l('H','"+rt+"')({params:["+at+"]},[],c)",lt)+";":W==="e"&&(U+=X+`
78
- `)}}return U}var R=function(){function b(T){this.cache=T}return b.prototype.define=function(T,k){this.cache[T]=k},b.prototype.get=function(T){return this.cache[T]},b.prototype.remove=function(T){delete this.cache[T]},b.prototype.reset=function(){this.cache={}},b.prototype.load=function(T){l(this.cache,T,!0)},b}();function D(b,T,k,N){if(T&&T.length>0)throw i((N?"Native":"")+"Helper '"+b+"' doesn't accept blocks");if(k&&k.length>0)throw i((N?"Native":"")+"Helper '"+b+"' doesn't accept filters")}var M={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function C(b){return M[b]}var I=new R({}),G=new R({each:function(b,T){var k="",N=b.params[0];if(D("each",T,!1),b.async)return new Promise(function(K){(function W(X,lt,rt,at,Rt){rt(X[lt],lt).then(function(nt){at+=nt,lt===X.length-1?Rt(at):W(X,lt+1,rt,at,Rt)})})(N,0,b.exec,k,K)});for(var U=0;U<N.length;U++)k+=b.exec(N[U],U);return k},foreach:function(b,T){var k=b.params[0];if(D("foreach",T,!1),b.async)return new Promise(function(K){(function W(X,lt,rt,at,Rt,nt){at(lt[rt],X[lt[rt]]).then(function(it){Rt+=it,rt===lt.length-1?nt(Rt):W(X,lt,rt+1,at,Rt,nt)})})(k,Object.keys(k),0,b.exec,"",K)});var N="";for(var U in k)o(k,U)&&(N+=b.exec(U,k[U]));return N},include:function(b,T,k){D("include",T,!1);var N=k.storage.templates.get(b.params[0]);if(!N)throw i('Could not fetch template "'+b.params[0]+'"');return N(b.params[1],k)},extends:function(b,T,k){var N=b.params[1]||{};N.content=b.exec();for(var U=0;U<T.length;U++){var K=T[U];N[K.name]=K.exec()}var W=k.storage.templates.get(b.params[0]);if(!W)throw i('Could not fetch template "'+b.params[0]+'"');return W(N,k)},useScope:function(b,T){return D("useScope",T,!1),b.exec(b.params[0])}}),F=new R({if:function(b,T){D("if",!1,b.f,!0);var k="if("+b.p+"){"+S(b.d,T)+"}";if(b.b)for(var N=0;N<b.b.length;N++){var U=b.b[N];U.n==="else"?k+="else{"+S(U.d,T)+"}":U.n==="elif"&&(k+="else if("+U.p+"){"+S(U.d,T)+"}")}return k},try:function(b,T){if(D("try",!1,b.f,!0),!b.b||b.b.length!==1||b.b[0].n!=="catch")throw i("native helper 'try' only accepts 1 block, 'catch'");var k="try{"+S(b.d,T)+"}",N=b.b[0];return k+="catch"+(N.res?"("+N.res+")":"")+"{"+S(N.d,T)+"}"},block:function(b,T){return D("block",b.b,b.f,!0),"if(!"+T.varName+"["+b.p+"]){tR+=("+y(b.d,"",T)+")()}else{tR+="+T.varName+"["+b.p+"]}"}}),V=new R({e:function(b){var T=String(b);return/[&<>"']/.test(T)?T.replace(/[&<>"']/g,C):T}}),q={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(b,T){if(b==="H"){var k=this.storage.helpers.get(T);if(k)return k;throw i("Can't find helper '"+T+"'")}if(b==="F"){var N=this.storage.filters.get(T);if(N)return N;throw i("Can't find filter '"+T+"'")}},async:!1,storage:{helpers:G,nativeHelpers:F,filters:V,templates:I},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function w(b,T){var k={};return l(k,q),T&&l(k,T),b&&l(k,b),k.l.bind(k),k}function P(b,T){var k=w(T||{}),N=Function;if(k.async){if(!a)throw i("This environment doesn't support async/await");N=a}try{return new N(k.varName,"c","cb",v(b,k))}catch(U){throw U instanceof SyntaxError?i(`Bad template syntax
79
-
80
- `+U.message+`
81
- `+Array(U.message.length+1).join("=")+`
82
- `+v(b,k)):U}}function H(b,T){var k;return T.cache&&T.name&&T.storage.templates.get(T.name)?T.storage.templates.get(T.name):(k=typeof b=="function"?b:P(b,T),T.cache&&T.name&&T.storage.templates.define(T.name,k),k)}q.l.bind(q),e.compile=P,e.compileScope=S,e.compileScopeIntoFunction=y,e.compileToString=v,e.defaultConfig=q,e.filters=V,e.getConfig=w,e.helpers=G,e.nativeHelpers=F,e.parse=g,e.render=function(b,T,k,N){var U=w(k||{});if(!U.async)return H(b,U)(T,U);if(!N){if(typeof n=="function")return new n(function(K,W){try{K(H(b,U)(T,U))}catch(X){W(X)}});throw i("Please provide a callback function, this env doesn't support Promises")}try{H(b,U)(T,U,N)}catch(K){return N(K)}},e.templates=I,Object.defineProperty(e,"__esModule",{value:!0})})})(Xr,Xr.exports);var ei=Xr.exports,Qr={exports:{}};(function(r,t){var e=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Fs<"u"&&Fs,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 c=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],d=ArrayBuffer.isView||function(w){return w&&c.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 P={next:function(){var H=w.shift();return{done:H===void 0,value:H}}};return l.iterable&&(P[Symbol.iterator]=function(){return P}),P}function g(w){this.map={},w instanceof g?w.forEach(function(P,H){this.append(H,P)},this):Array.isArray(w)?w.forEach(function(P){this.append(P[0],P[1])},this):w&&Object.getOwnPropertyNames(w).forEach(function(P){this.append(P,w[P])},this)}g.prototype.append=function(w,P){w=u(w),P=f(P);var H=this.map[w];this.map[w]=H?H+", "+P:P},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,P){this.map[u(w)]=f(P)},g.prototype.forEach=function(w,P){for(var H in this.map)this.map.hasOwnProperty(H)&&w.call(P,this.map[H],H,this)},g.prototype.keys=function(){var w=[];return this.forEach(function(P,H){w.push(H)}),p(w)},g.prototype.values=function(){var w=[];return this.forEach(function(P){w.push(P)}),p(w)},g.prototype.entries=function(){var w=[];return this.forEach(function(P,H){w.push([H,P])}),p(w)},l.iterable&&(g.prototype[Symbol.iterator]=g.prototype.entries);function v(w){if(w.bodyUsed)return Promise.reject(new TypeError("Already read"));w.bodyUsed=!0}function E(w){return new Promise(function(P,H){w.onload=function(){P(w.result)},w.onerror=function(){H(w.error)}})}function A(w){var P=new FileReader,H=E(P);return P.readAsArrayBuffer(w),H}function L(w){var P=new FileReader,H=E(P);return P.readAsText(w),H}function y(w){for(var P=new Uint8Array(w),H=new Array(P.length),b=0;b<P.length;b++)H[b]=String.fromCharCode(P[b]);return H.join("")}function S(w){if(w.slice)return w.slice(0);var P=new Uint8Array(w.byteLength);return P.set(new Uint8Array(w)),P.buffer}function R(){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=S(w.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):l.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(w)||d(w))?this._bodyArrayBuffer=S(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=v(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=v(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=v(this);if(w)return w;if(this._bodyBlob)return L(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(I)}),this.json=function(){return this.text().then(JSON.parse)},this}var D=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function M(w){var P=w.toUpperCase();return D.indexOf(P)>-1?P:w}function C(w,P){if(!(this instanceof C))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');P=P||{};var H=P.body;if(w instanceof C){if(w.bodyUsed)throw new TypeError("Already read");this.url=w.url,this.credentials=w.credentials,P.headers||(this.headers=new g(w.headers)),this.method=w.method,this.mode=w.mode,this.signal=w.signal,!H&&w._bodyInit!=null&&(H=w._bodyInit,w.bodyUsed=!0)}else this.url=String(w);if(this.credentials=P.credentials||this.credentials||"same-origin",(P.headers||!this.headers)&&(this.headers=new g(P.headers)),this.method=M(P.method||this.method||"GET"),this.mode=P.mode||this.mode||null,this.signal=P.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&H)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(H),(this.method==="GET"||this.method==="HEAD")&&(P.cache==="no-store"||P.cache==="no-cache")){var b=/([?&])_=[^&]*/;if(b.test(this.url))this.url=this.url.replace(b,"$1_="+new Date().getTime());else{var T=/\?/;this.url+=(T.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}C.prototype.clone=function(){return new C(this,{body:this._bodyInit})};function I(w){var P=new FormData;return w.trim().split("&").forEach(function(H){if(H){var b=H.split("="),T=b.shift().replace(/\+/g," "),k=b.join("=").replace(/\+/g," ");P.append(decodeURIComponent(T),decodeURIComponent(k))}}),P}function G(w){var P=new g,H=w.replace(/\r?\n[\t ]+/g," ");return H.split("\r").map(function(b){return b.indexOf(`
83
- `)===0?b.substr(1,b.length):b}).forEach(function(b){var T=b.split(":"),k=T.shift().trim();if(k){var N=T.join(":").trim();P.append(k,N)}}),P}R.call(C.prototype);function F(w,P){if(!(this instanceof F))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');P||(P={}),this.type="default",this.status=P.status===void 0?200:P.status,this.ok=this.status>=200&&this.status<300,this.statusText=P.statusText===void 0?"":""+P.statusText,this.headers=new g(P.headers),this.url=P.url||"",this._initBody(w)}R.call(F.prototype),F.prototype.clone=function(){return new F(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new g(this.headers),url:this.url})},F.error=function(){var w=new F(null,{status:0,statusText:""});return w.type="error",w};var V=[301,302,303,307,308];F.redirect=function(w,P){if(V.indexOf(P)===-1)throw new RangeError("Invalid status code");return new F(null,{status:P,headers:{location:w}})},a.DOMException=o.DOMException;try{new a.DOMException}catch{a.DOMException=function(P,H){this.message=P,this.name=H;var b=Error(P);this.stack=b.stack},a.DOMException.prototype=Object.create(Error.prototype),a.DOMException.prototype.constructor=a.DOMException}function q(w,P){return new Promise(function(H,b){var T=new C(w,P);if(T.signal&&T.signal.aborted)return b(new a.DOMException("Aborted","AbortError"));var k=new XMLHttpRequest;function N(){k.abort()}k.onload=function(){var K={status:k.status,statusText:k.statusText,headers:G(k.getAllResponseHeaders()||"")};K.url="responseURL"in k?k.responseURL:K.headers.get("X-Request-URL");var W="response"in k?k.response:k.responseText;setTimeout(function(){H(new F(W,K))},0)},k.onerror=function(){setTimeout(function(){b(new TypeError("Network request failed"))},0)},k.ontimeout=function(){setTimeout(function(){b(new TypeError("Network request failed"))},0)},k.onabort=function(){setTimeout(function(){b(new a.DOMException("Aborted","AbortError"))},0)};function U(K){try{return K===""&&o.location.href?o.location.href:K}catch{return K}}k.open(T.method,U(T.url),!0),T.credentials==="include"?k.withCredentials=!0:T.credentials==="omit"&&(k.withCredentials=!1),"responseType"in k&&(l.blob?k.responseType="blob":l.arrayBuffer&&T.headers.get("Content-Type")&&T.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(k.responseType="arraybuffer")),P&&typeof P.headers=="object"&&!(P.headers instanceof g)?Object.getOwnPropertyNames(P.headers).forEach(function(K){k.setRequestHeader(K,f(P.headers[K]))}):T.headers.forEach(function(K,W){k.setRequestHeader(W,K)}),T.signal&&(T.signal.addEventListener("abort",N),k.onreadystatechange=function(){k.readyState===4&&T.signal.removeEventListener("abort",N)}),k.send(typeof T._bodyInit>"u"?null:T._bodyInit)})}return q.polyfill=!0,o.fetch||(o.fetch=q,o.Headers=g,o.Request=C,o.Response=F),a.Headers=g,a.Request=C,a.Response=F,a.fetch=q,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})(Qr,Qr.exports);var Ud=Qr.exports;const Bd=zr(Ud);function Hd({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:c})=>{s.globalAlpha=1,c.width=c.height=0,c.width=r.width,c.height=r.height;const d=c.getContext("2d");if(d){const u=o+l,f=o===0,p=u===a;h({currentTime:e,canvas:c,context:d}),!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(c,0,0,r.width,r.height)}})}}}function Gd(r){if(typeof r=="string"){const[t,e]=r.split(":");return Math.min(parseFloat(t),parseFloat(e))}return r}function Vd(r){if(typeof r=="string"){const[t,e]=r.split(":"),i=parseFloat(t),s=parseFloat(e);return i/s}return r}function bi({resolution:r,aspectRatio:t}){const e=Gd(r),i=Vd(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 Kd({format:r,resolution:t,aspectRatio:e,videoResolution:i,videoAspectRatio:s}){const{height:n,width:a}=bi({resolution:t,aspectRatio:e}),{height:o,width:l}=bi({resolution:i,aspectRatio:s}),h=e>s;let c=1;if(r==="letterbox"||r==="letterbox-video")c=h?n/o:a/l;else if(r==="squarebox"){const g=Math.min(n,a);c=l>=o?g/o:g/l}else(r==="crop"||r==="crop-top")&&(c=h?a/l:n/o);const d=a/c,u=n/c,f=(l-d)/2;let p=(o-u)/2;return r==="crop-top"&&(p=Math.min(0,p)),{sx:f,sy:p,sWidth:d,sHeight:u,scale:c}}function Ns({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),c=(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??c,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 d=Math.max(t,0),u=Math.min(t+i,h),f=Math.max(e,0),p=Math.min(e+s,c),g=o/i,v=l/s;return[r,d,f,u-d,p-f,t<0?n-t*g:n,e<0?a-e*v:a,(u-d)*g,(p-f)*v]}function wo({context:r,source:t,format:e="letterbox",videoResolution:i,videoAspectRatio:s,posX:n,posY:a,width:o,height:l,offscreenCanvas:h}){const{sx:c,sy:d,sWidth:u,sHeight:f,scale:p}=Kd({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(c<0){const y=Math.abs(c)*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(d<0){const y=Math.abs(d)*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:S}=bi({resolution:i,aspectRatio:s});h.width=y,h.height=S;const R=h.getContext("2d",{alpha:!1});if(R==null||R.drawImage(t,0,0,y,S),R){r.save(),r.globalCompositeOperation="destination-out",r.fillRect(n,a,o,l);const D=Ns({source:h,sx:c,sy:d,sw:u,sh:f,dx:n,dy:a,dw:o,dh:l});r.globalCompositeOperation="source-over",r.drawImage(...D),R.save();const M=1.3,C=-(y*M-y)/2,I=-(S*M-S)/2;if(R.filter="blur(40px) brightness(20%)",R.translate(C,I),R.scale(M,M),R.drawImage(h,0,0,y,S),R.restore(),r.globalCompositeOperation="destination-over",c<0){const G=o/s,F=l/G,V=Ns({source:h,sy:(1-F)*S/2,sh:F*S,dx:n,dy:a,dw:o,dh:l});r.drawImage(...V)}if(d<0){const G=l*s,F=o/G,V=Ns({source:h,sx:(1-F)*y/2,sw:F*y,dx:n,dy:a,dw:o,dh:l});r.drawImage(...V)}r.restore()}}else{const y=Ns({source:t,sx:c,sy:d,sw:u,sh:f,dx:n,dy:a,dw:o,dh:l});r.drawImage(...y)}const v=c*-1*p,E=d*-1*p,A=o-v*2,L=l-E*2;return{dx:v,dy:E,dw:A,dh:L}}const jd=/\d{0,2}:?\d{2}:\d{2}\.\d{3}\s-->\s\d{0,2}:?\d{2}:\d{2}\.\d{3}\s{1,2}.*/g,Wd=/\d{0,2}:?\d{2}:\d{2}\.\d{3}/g;function So(r){if(!r)return[];const t=r.match(jd);return t?t==null?void 0:t.map(e=>{const[i,s]=e.replace(`\r
77
+ */const Tg=Symbol();class Cl{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 o;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??kg,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=(o=this.A)==null?void 0:o.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 c,d,f,p,g;let e,i;t??(t=this.A()),this.k=t,this.status===1?(c=this.T)==null||c.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 o=!1;try{e=await this._(t,{signal:this.T.signal})}catch(v){o=!0,i=v}if(this.u===s){if(e===Tg)this.status=0;else{if(o===!1){try{(d=this.m)==null||d.call(this,e)}catch{}this.status=2,(f=this.i)==null||f.call(this,e)}else{try{(p=this.g)==null||p.call(this,i)}catch{}this.status=3,(g=this.o)==null||g.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,o;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(o=t.error)==null?void 0:o.call(t,this.error);default:throw Error("Unexpected status: "+this.status)}}}const kg=(n,t)=>n===t||n.length===t.length&&n.every((e,i)=>!Ll(e,t[i]));let qa;const wg=new Uint8Array(16);function Sg(){if(!qa&&(qa=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!qa))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return qa(wg)}const yi=[];for(let n=0;n<256;++n)yi.push((n+256).toString(16).slice(1));function Rg(n,t=0){return yi[n[t+0]]+yi[n[t+1]]+yi[n[t+2]]+yi[n[t+3]]+"-"+yi[n[t+4]]+yi[n[t+5]]+"-"+yi[n[t+6]]+yi[n[t+7]]+"-"+yi[n[t+8]]+yi[n[t+9]]+"-"+yi[n[t+10]]+yi[n[t+11]]+yi[n[t+12]]+yi[n[t+13]]+yi[n[t+14]]+yi[n[t+15]]}const Od={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function qs(n,t,e){if(Od.randomUUID&&!t&&!n)return Od.randomUUID();n=n||{};const i=n.random||(n.rng||Sg)();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 Rg(i)}const Md="https://d2rxhdlm2q91uk.cloudfront.net",_g="https://d1ix11aj5kfygl.cloudfront.net",Lg="https://d157jlwnudd93d.cloudfront.net",$d="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",Cg="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",Ig="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",xg="http://localhost:6060/v2",Dg="https://embed-dev.vouchfor.com/v2",Pg="https://embed-staging.vouchfor.com/v2",Og="https://embed.vouchfor.com/v2";function Qa(n){if(!["local","dev","staging","prod"].includes(n))throw new Error(`Unknown environment: ${n}`);if(n==="local")return{videoUrl:Md,publicApiUrl:$d,embedApiUrl:xg};if(n==="dev")return{videoUrl:Md,publicApiUrl:$d,embedApiUrl:Dg};if(n==="staging")return{videoUrl:_g,publicApiUrl:Cg,embedApiUrl:Pg};if(n==="prod")return{videoUrl:Lg,publicApiUrl:Ig,embedApiUrl:Og}}class Mg{constructor(t){this._fetching=!1,this.getVouch=async(e,i,s)=>{var g;const{embedApiUrl:o}=Qa(e),c=qs(),d=await fetch(`${o}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",c]]}),f=await d.json();return this.host.dispatchEvent(new CustomEvent("vouch:loaded",{detail:f==null?void 0:f.id})),((g=d==null?void 0:d.headers)==null?void 0:g.get("X-Cache-Check"))!==c&&fetch(`${o}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.getTemplate=async(e,i,s)=>{var g;const{embedApiUrl:o}=Qa(e),c=qs(),d=await fetch(`${o}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",c]]}),f=await d.json();return((g=d==null?void 0:d.headers)==null?void 0:g.get("X-Cache-Check"))!==c&&fetch(`${o}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.host=t,new Cl(this.host,async([e,i,s,o,c])=>{var d,f,p,g;try{if(t.vouch=void 0,t.template=void 0,s){let v;c&&(this.fetching=!0,v=await this.getTemplate(e,i,c)),t.vouch=s,t.template=v??((f=(d=s==null?void 0:s.settings)==null?void 0:d.template)==null?void 0:f.instance)}else if(o){this.fetching=!0;const[v,b]=await Promise.all([this.getVouch(e,i,o),c?this.getTemplate(e,i,c):null]);t.vouch=v,t.template=b??((g=(p=v==null?void 0:v.settings)==null?void 0:p.template)==null?void 0:g.instance)}}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}}const $g={name:"@vouchfor/embeds",version:"0.0.0-experiment.8c5a3f8",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"experiment",access:"public"},scripts:{build:"rm -rf dist && tsc && vite build --mode iife && vite build --mode es","build:deps":"yarn --cwd ../media-player build","build:package":"yarn build","build:storybook":"yarn prebuild && storybook build","generate:manifest":"wca src --outFile custom-elements.json",lint:"eslint . --quiet","lint:fix":"eslint . --fix","lint:staged":"lint-staged",prepublishOnly:"yarn build",size:"size-limit",storybook:"yarn prebuild && storybook dev -p 6007",prebuild:"yarn build:deps && yarn generate:manifest",test:"true"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@lit/task":"^1.0.0","@vouchfor/media-player":"0.0.0-experiment.8c5a3f8",uuid:"^9.0.1"},peerDependencies:{lit:"^3.1.0"},devDependencies:{"@esm-bundle/chai":"^4.3.4-fix.0","@open-wc/testing":"^3.2.0","@storybook/addon-essentials":"^7.4.5","@storybook/addon-links":"^7.4.5","@storybook/blocks":"^7.4.5","@storybook/web-components":"^7.4.5","@storybook/web-components-vite":"^7.4.5","@types/mocha":"^10.0.1","@vouchfor/eslint-config":"^1.0.0","@vouchfor/prettier-config":"^1.0.0","@web/dev-server-esbuild":"^0.4.1","@web/test-runner":"^0.17.1","@web/test-runner-browserstack":"^0.6.1","@web/test-runner-mocha":"^0.8.1","@web/test-runner-playwright":"^0.10.1",dotenv:"^16.3.1",eslint:"^8.50.0","eslint-plugin-import":"^2.28.1","lint-staged":"^14.0.1",lit:"^3.1.0",prettier:"^3.0.3",react:"^18.2.0","react-dom":"^18.2.0",storybook:"^7.4.5",typescript:"^5.1.3",vite:"^4.4.9","vite-plugin-dts":"^3.6.0","web-component-analyzer":"^1.1.7"}},Nd=1;class Ng{constructor(t){this._tabId=void 0,this._clientId=void 0,this._visitorId=void 0,this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createVisitor=e=>{var s,o;const{publicApiUrl:i}=Qa(this.host.env);return(o=(s=window.localStorage)==null?void 0:s.setItem)==null||o.call(s,"vouch-uid-visitor",e),navigator.sendBeacon(`${i}/api/visitor`,JSON.stringify({visitorId:e})),e},this._getReportingMetadata=()=>{var o,c;const[e,i]=((c=(o=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:o.split)==null?void 0:c.call(o,"/"))??[],s={};return[...new URLSearchParams(location.search).entries()].forEach(([d,f])=>{if(/utm/.test(d)){const p=d.toLowerCase().replace(/[-_][a-z0-9]/g,g=>g.slice(-1).toUpperCase());s[p]=f}}),{source:this.host.trackingSource,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 s=this._findVouchId(i);if(!s||this.host.disableTracking)return;const{publicApiUrl:o}=Qa(this.host.env),{client:c,tab:d,request:f,visitor:p}=this._getUids();navigator.sendBeacon(`${o}/api/v2/events`,JSON.stringify({event:e,payload:{...i,vouchId:s},context:{"x-uid-client":c,"x-uid-tab":d,"x-uid-request":f,"x-uid-visitor":p,"x-reporting-metadata":this._getReportingMetadata(),"x-embeds-version":$g.version}}))},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:e,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Nd&&this._sendTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]}},this._handleVouchLoaded=({detail:e})=>{e&&(this._hasLoaded[e]||(this._sendTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._sendTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:e,key:i,node:s}})=>{this._answersViewed[i]||(this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:e}),this._answersViewed[i]=!0),this._streamStartTime[i]||(this._streamStartTime[i]=s.currentTime,this._streamLatestTime[i]=s.currentTime)},this._handleVideoTimeUpdate=({detail:{id:e,key:i,node:s}})=>{var o,c;!this.host.paused&&e===((c=(o=this.host.scene)==null?void 0:o.video)==null?void 0:c.id)&&(this._currentlyPlayingVideo={id:e,key:i,node:s},this._streamLatestTime[i]=s.currentTime)},this._handleVideoPause=({detail:{id:e,key:i}})=>{this._streamLatestTime[i]>this._streamStartTime[i]+Nd&&this._sendTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]},this._pageUnloading=()=>{this._streamEnded(),this.host.pause()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=t,t.addController(this)}_findVouchId(t){return t&&"vouchId"in t?t.vouchId:this.host.vouch?this.host.vouch.id:null}_getUids(){var o,c,d,f,p,g,v,b,E,T,w,_;if(typeof window>"u")return{client:null,tab:null,request:qs()};const t=this._visitorId||((c=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:c.call(o,"vouch-uid-visitor"))||this._createVisitor(qs()),e=this._clientId||((f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"))||qs(),i=this._tabId||((g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab"))||qs(),s=qs();return t!==this._visitorId&&(this._visitorId=t,(b=(v=window.localStorage)==null?void 0:v.setItem)==null||b.call(v,"vouch-uid-visitor",t)),e!==this._clientId&&(this._clientId=e,(T=(E=window.localStorage)==null?void 0:E.setItem)==null||T.call(E,"vouch-uid-client",e)),i!==this._tabId&&(this._tabId=i,(_=(w=window.sessionStorage)==null?void 0:w.setItem)==null||_.call(w,"vouch-uid-tab",i)),{client:e,tab:i,request:s,visitor:t}}hostConnected(){requestAnimationFrame(()=>{var t,e,i,s;"onvisibilitychange"in document?document.addEventListener("visibilitychange",this._handleVisibilityChange):window.addEventListener("pagehide",this._handlePageHide),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._streamEnded(),"onvisibilitychange"in document?document.removeEventListener("visibilitychange",this._handleVisibilityChange):window.removeEventListener("pagehide",this._handlePageHide),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)}}const Fg=(n,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const s=Object.getOwnPropertyDescriptor(n,e),o=Object.getOwnPropertyDescriptor(t,e);!Ug(s,o)&&i||Object.defineProperty(n,e,o)},Ug=function(n,t){return n===void 0||n.configurable||n.writable===t.writable&&n.enumerable===t.enumerable&&n.configurable===t.configurable&&(n.writable||n.value===t.value)},Bg=(n,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(n)&&Object.setPrototypeOf(n,e)},Gg=(n,t)=>`/* Wrapped ${n}*/
78
+ ${t}`,Hg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Vg=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Wg=(n,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,s=Gg.bind(null,i,t.toString());Object.defineProperty(s,"name",Vg),Object.defineProperty(n,"toString",{...Hg,value:s})};function jg(n,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=n;for(const s of Reflect.ownKeys(t))Fg(n,t,s,e);return Bg(n,t),Wg(n,t,i),n}const Kg=new WeakMap;function ys(n,{cacheKey:t=([i])=>i,cache:e=new Map}={}){const i=new Map,s=function(...o){const c=t(o);if(i.has(c))return i.get(c);const d=(async()=>{try{if(e&&await e.has(c))return await e.get(c);const p=await n.apply(this,o);try{return p}finally{e&&await e.set(c,p)}}finally{i.delete(c)}})();return i.set(c,d),d};return jg(s,n,{ignoreNonConfigurable:!0}),Kg.set(s,e),s}var Ja=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Il(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var xl={exports:{}};(function(n,t){(function(e,i){i(t)})(Ja,function(e){function i($){var U,X,mt=new Error($);return U=mt,X=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(U,X):U.__proto__=X,mt}function s($,U,X){var mt=U.slice(0,X).split(/\n/),bt=mt.length,xt=mt[bt-1].length+1;throw i($+=" at line "+bt+" col "+xt+`:
79
+
80
+ `+U.split(/\n/)[bt-1]+`
81
+ `+Array(xt).join(" ")+"^")}i.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var o=new Function("return this")().Promise,c=!1;try{c=new Function("return (async function(){}).constructor")()}catch($){if(!($ instanceof SyntaxError))throw $}function d($,U){return Object.prototype.hasOwnProperty.call($,U)}function f($,U,X){for(var mt in U)d(U,mt)&&(U[mt]==null||typeof U[mt]!="object"||mt!=="storage"&&mt!=="prefixes"||X?$[mt]=U[mt]:$[mt]=f({},U[mt]));return $}var p=/^async +/,g=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,v=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,b=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,E=/[.*+\-?^${}()|[\]\\]/g;function T($){return E.test($)?$.replace(E,"\\$&"):$}function w($,U){U.rmWhitespace&&($=$.replace(/[\r\n]+/g,`
82
+ `).replace(/^\s+|\s+$/gm,"")),g.lastIndex=0,v.lastIndex=0,b.lastIndex=0;var X=U.prefixes,mt=[X.h,X.b,X.i,X.r,X.c,X.e].reduce(function(be,jt){return be&&jt?be+"|"+T(jt):jt?T(jt):be},""),bt=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+T(U.tags[1])+")","g"),xt=new RegExp("([^]*?)"+T(U.tags[0])+"(-|_)?\\s*("+mt+")?\\s*","g"),Ut=0,Qt=!1;function ue(be,jt){var ge,oe={f:[]},Ce=0,Ft="c";function Xe(ti){var Xi=$.slice(Ut,ti),$e=Xi.trim();if(Ft==="f")$e==="safe"?oe.raw=!0:U.async&&p.test($e)?($e=$e.replace(p,""),oe.f.push([$e,"",!0])):oe.f.push([$e,""]);else if(Ft==="fp")oe.f[oe.f.length-1][1]+=$e;else if(Ft==="err"){if($e){var Ci=Xi.search(/\S/);s("invalid syntax",$,Ut+Ci)}}else oe[Ft]=$e;Ut=ti+1}for(jt==="h"||jt==="b"||jt==="c"?Ft="n":jt==="r"&&(oe.raw=!0,jt="i"),bt.lastIndex=Ut;(ge=bt.exec($))!==null;){var qe=ge[1],Mi=ge[2],Tr=ge[3],ke=ge[4],li=ge[5],me=ge.index;if(qe)qe==="("?(Ce===0&&(Ft==="n"?(Xe(me),Ft="p"):Ft==="f"&&(Xe(me),Ft="fp")),Ce++):qe===")"?--Ce===0&&Ft!=="c"&&(Xe(me),Ft="err"):Ce===0&&qe==="|"?(Xe(me),Ft="f"):qe==="=>"&&(Xe(me),Ut+=1,Ft="res");else if(Mi)if(Mi==="/*"){var Je=$.indexOf("*/",bt.lastIndex);Je===-1&&s("unclosed comment",$,ge.index),bt.lastIndex=Je+2}else Mi==="'"?(v.lastIndex=ge.index,v.exec($)?bt.lastIndex=v.lastIndex:s("unclosed string",$,ge.index)):Mi==='"'?(b.lastIndex=ge.index,b.exec($)?bt.lastIndex=b.lastIndex:s("unclosed string",$,ge.index)):Mi==="`"&&(g.lastIndex=ge.index,g.exec($)?bt.lastIndex=g.lastIndex:s("unclosed string",$,ge.index));else if(Tr)return Xe(me),Ut=me+ge[0].length,xt.lastIndex=Ut,Qt=li,ke&&jt==="h"&&(jt="s"),oe.t=jt,oe}return s("unclosed tag",$,be),oe}var se=function be(jt,ge){jt.b=[],jt.d=[];var oe,Ce=!1,Ft=[];function Xe(Ci,ss){Ci&&(Ci=function(ci,kr,_s,Ls){var ir,ct;return typeof kr.autoTrim=="string"?ir=ct=kr.autoTrim:Array.isArray(kr.autoTrim)&&(ir=kr.autoTrim[1],ct=kr.autoTrim[0]),(_s||_s===!1)&&(ir=_s),(Ls||Ls===!1)&&(ct=Ls),ir==="slurp"&&ct==="slurp"?ci.trim():(ir==="_"||ir==="slurp"?ci=String.prototype.trimLeft?ci.trimLeft():ci.replace(/^[\s\uFEFF\xA0]+/,""):ir!=="-"&&ir!=="nl"||(ci=ci.replace(/^(?:\n|\r|\r\n)/,"")),ct==="_"||ct==="slurp"?ci=String.prototype.trimRight?ci.trimRight():ci.replace(/[\s\uFEFF\xA0]+$/,""):ct!=="-"&&ct!=="nl"||(ci=ci.replace(/(?:\n|\r|\r\n)$/,"")),ci)}(Ci,U,Qt,ss))&&(Ci=Ci.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),Ft.push(Ci))}for(;(oe=xt.exec($))!==null;){var qe,Mi=oe[1],Tr=oe[2],ke=oe[3]||"";for(var li in X)if(X[li]===ke){qe=li;break}Xe(Mi,Tr),Ut=oe.index+oe[0].length,qe||s("unrecognized tag type: "+ke,$,Ut);var me=ue(oe.index,qe),Je=me.t;if(Je==="h"){var ti=me.n||"";U.async&&p.test(ti)&&(me.a=!0,me.n=ti.replace(p,"")),me=be(me),Ft.push(me)}else if(Je==="c"){if(jt.n===me.n)return Ce?(Ce.d=Ft,jt.b.push(Ce)):jt.d=Ft,jt;s("Helper start and end don't match",$,oe.index+oe[0].length)}else if(Je==="b"){Ce?(Ce.d=Ft,jt.b.push(Ce)):jt.d=Ft;var Xi=me.n||"";U.async&&p.test(Xi)&&(me.a=!0,me.n=Xi.replace(p,"")),Ce=me,Ft=[]}else if(Je==="s"){var $e=me.n||"";U.async&&p.test($e)&&(me.a=!0,me.n=$e.replace(p,"")),Ft.push(me)}else Ft.push(me)}if(!ge)throw i('unclosed helper "'+jt.n+'"');return Xe($.slice(Ut,$.length),!1),jt.d=Ft,jt}({f:[]},!0);if(U.plugins)for(var zt=0;zt<U.plugins.length;zt++){var Oe=U.plugins[zt];Oe.processAST&&(se.d=Oe.processAST(se.d,U))}return se.d}function _($,U){var X=w($,U),mt="var tR='';"+(U.useWith?"with("+U.varName+"||{}){":"")+N(X,U)+"if(cb){cb(null,tR)} return tR"+(U.useWith?"}":"");if(U.plugins)for(var bt=0;bt<U.plugins.length;bt++){var xt=U.plugins[bt];xt.processFnString&&(mt=xt.processFnString(mt,U))}return mt}function D($,U){for(var X=0;X<U.length;X++){var mt=U[X][0],bt=U[X][1];$=(U[X][2]?"await ":"")+"c.l('F','"+mt+"')("+$,bt&&($+=","+bt),$+=")"}return $}function M($,U,X,mt,bt,xt){var Ut="{exec:"+(bt?"async ":"")+x(X,U,$)+",params:["+mt+"]";return xt&&(Ut+=",name:'"+xt+"'"),bt&&(Ut+=",async:true"),Ut+="}"}function F($,U){for(var X="[",mt=0;mt<$.length;mt++){var bt=$[mt];X+=M(U,bt.res||"",bt.d,bt.p||"",bt.a,bt.n),mt<$.length&&(X+=",")}return X+="]"}function x($,U,X){return"function("+U+"){var tR='';"+N($,X)+"return tR}"}function N($,U){for(var X=0,mt=$.length,bt="";X<mt;X++){var xt=$[X];if(typeof xt=="string")bt+="tR+='"+xt+"';";else{var Ut=xt.t,Qt=xt.c||"",ue=xt.f,se=xt.n||"",zt=xt.p||"",Oe=xt.res||"",be=xt.b,jt=!!xt.a;if(Ut==="i"){U.defaultFilter&&(Qt="c.l('F','"+U.defaultFilter+"')("+Qt+")");var ge=D(Qt,ue);!xt.raw&&U.autoEscape&&(ge="c.l('F','e')("+ge+")"),bt+="tR+="+ge+";"}else if(Ut==="h")if(U.storage.nativeHelpers.get(se))bt+=U.storage.nativeHelpers.get(se)(xt,U);else{var oe=(jt?"await ":"")+"c.l('H','"+se+"')("+M(U,Oe,xt.d,zt,jt);oe+=be?","+F(be,U):",[]",bt+="tR+="+D(oe+=",c)",ue)+";"}else Ut==="s"?bt+="tR+="+D((jt?"await ":"")+"c.l('H','"+se+"')({params:["+zt+"]},[],c)",ue)+";":Ut==="e"&&(bt+=Qt+`
83
+ `)}}return bt}var V=function(){function $(U){this.cache=U}return $.prototype.define=function(U,X){this.cache[U]=X},$.prototype.get=function(U){return this.cache[U]},$.prototype.remove=function(U){delete this.cache[U]},$.prototype.reset=function(){this.cache={}},$.prototype.load=function(U){f(this.cache,U,!0)},$}();function j($,U,X,mt){if(U&&U.length>0)throw i((mt?"Native":"")+"Helper '"+$+"' doesn't accept blocks");if(X&&X.length>0)throw i((mt?"Native":"")+"Helper '"+$+"' doesn't accept filters")}var rt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function nt($){return rt[$]}var Q=new V({}),Tt=new V({each:function($,U){var X="",mt=$.params[0];if(j("each",U,!1),$.async)return new Promise(function(xt){(function Ut(Qt,ue,se,zt,Oe){se(Qt[ue],ue).then(function(be){zt+=be,ue===Qt.length-1?Oe(zt):Ut(Qt,ue+1,se,zt,Oe)})})(mt,0,$.exec,X,xt)});for(var bt=0;bt<mt.length;bt++)X+=$.exec(mt[bt],bt);return X},foreach:function($,U){var X=$.params[0];if(j("foreach",U,!1),$.async)return new Promise(function(xt){(function Ut(Qt,ue,se,zt,Oe,be){zt(ue[se],Qt[ue[se]]).then(function(jt){Oe+=jt,se===ue.length-1?be(Oe):Ut(Qt,ue,se+1,zt,Oe,be)})})(X,Object.keys(X),0,$.exec,"",xt)});var mt="";for(var bt in X)d(X,bt)&&(mt+=$.exec(bt,X[bt]));return mt},include:function($,U,X){j("include",U,!1);var mt=X.storage.templates.get($.params[0]);if(!mt)throw i('Could not fetch template "'+$.params[0]+'"');return mt($.params[1],X)},extends:function($,U,X){var mt=$.params[1]||{};mt.content=$.exec();for(var bt=0;bt<U.length;bt++){var xt=U[bt];mt[xt.name]=xt.exec()}var Ut=X.storage.templates.get($.params[0]);if(!Ut)throw i('Could not fetch template "'+$.params[0]+'"');return Ut(mt,X)},useScope:function($,U){return j("useScope",U,!1),$.exec($.params[0])}}),gt=new V({if:function($,U){j("if",!1,$.f,!0);var X="if("+$.p+"){"+N($.d,U)+"}";if($.b)for(var mt=0;mt<$.b.length;mt++){var bt=$.b[mt];bt.n==="else"?X+="else{"+N(bt.d,U)+"}":bt.n==="elif"&&(X+="else if("+bt.p+"){"+N(bt.d,U)+"}")}return X},try:function($,U){if(j("try",!1,$.f,!0),!$.b||$.b.length!==1||$.b[0].n!=="catch")throw i("native helper 'try' only accepts 1 block, 'catch'");var X="try{"+N($.d,U)+"}",mt=$.b[0];return X+="catch"+(mt.res?"("+mt.res+")":"")+"{"+N(mt.d,U)+"}"},block:function($,U){return j("block",$.b,$.f,!0),"if(!"+U.varName+"["+$.p+"]){tR+=("+x($.d,"",U)+")()}else{tR+="+U.varName+"["+$.p+"]}"}}),$t=new V({e:function($){var U=String($);return/[&<>"']/.test(U)?U.replace(/[&<>"']/g,nt):U}}),Wt={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function($,U){if($==="H"){var X=this.storage.helpers.get(U);if(X)return X;throw i("Can't find helper '"+U+"'")}if($==="F"){var mt=this.storage.filters.get(U);if(mt)return mt;throw i("Can't find filter '"+U+"'")}},async:!1,storage:{helpers:Tt,nativeHelpers:gt,filters:$t,templates:Q},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function H($,U){var X={};return f(X,Wt),U&&f(X,U),$&&f(X,$),X.l.bind(X),X}function J($,U){var X=H(U||{}),mt=Function;if(X.async){if(!c)throw i("This environment doesn't support async/await");mt=c}try{return new mt(X.varName,"c","cb",_($,X))}catch(bt){throw bt instanceof SyntaxError?i(`Bad template syntax
84
+
85
+ `+bt.message+`
86
+ `+Array(bt.message.length+1).join("=")+`
87
+ `+_($,X)):bt}}function St($,U){var X;return U.cache&&U.name&&U.storage.templates.get(U.name)?U.storage.templates.get(U.name):(X=typeof $=="function"?$:J($,U),U.cache&&U.name&&U.storage.templates.define(U.name,X),X)}Wt.l.bind(Wt),e.compile=J,e.compileScope=N,e.compileScopeIntoFunction=x,e.compileToString=_,e.defaultConfig=Wt,e.filters=$t,e.getConfig=H,e.helpers=Tt,e.nativeHelpers=gt,e.parse=w,e.render=function($,U,X,mt){var bt=H(X||{});if(!bt.async)return St($,bt)(U,bt);if(!mt){if(typeof o=="function")return new o(function(xt,Ut){try{xt(St($,bt)(U,bt))}catch(Qt){Ut(Qt)}});throw i("Please provide a callback function, this env doesn't support Promises")}try{St($,bt)(U,bt,mt)}catch(xt){return mt(xt)}},e.templates=Q,Object.defineProperty(e,"__esModule",{value:!0})})})(xl,xl.exports);var Qs=xl.exports,Dl={exports:{}};(function(n,t){var e=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Ja<"u"&&Ja,i=function(){function o(){this.fetch=!1,this.DOMException=e.DOMException}return o.prototype=e,new o}();(function(o){(function(c){var d=typeof o<"u"&&o||typeof self<"u"&&self||typeof d<"u"&&d,f={searchParams:"URLSearchParams"in d,iterable:"Symbol"in d&&"iterator"in Symbol,blob:"FileReader"in d&&"Blob"in d&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in d,arrayBuffer:"ArrayBuffer"in d};function p(H){return H&&DataView.prototype.isPrototypeOf(H)}if(f.arrayBuffer)var g=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],v=ArrayBuffer.isView||function(H){return H&&g.indexOf(Object.prototype.toString.call(H))>-1};function b(H){if(typeof H!="string"&&(H=String(H)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(H)||H==="")throw new TypeError('Invalid character in header field name: "'+H+'"');return H.toLowerCase()}function E(H){return typeof H!="string"&&(H=String(H)),H}function T(H){var J={next:function(){var St=H.shift();return{done:St===void 0,value:St}}};return f.iterable&&(J[Symbol.iterator]=function(){return J}),J}function w(H){this.map={},H instanceof w?H.forEach(function(J,St){this.append(St,J)},this):Array.isArray(H)?H.forEach(function(J){this.append(J[0],J[1])},this):H&&Object.getOwnPropertyNames(H).forEach(function(J){this.append(J,H[J])},this)}w.prototype.append=function(H,J){H=b(H),J=E(J);var St=this.map[H];this.map[H]=St?St+", "+J:J},w.prototype.delete=function(H){delete this.map[b(H)]},w.prototype.get=function(H){return H=b(H),this.has(H)?this.map[H]:null},w.prototype.has=function(H){return this.map.hasOwnProperty(b(H))},w.prototype.set=function(H,J){this.map[b(H)]=E(J)},w.prototype.forEach=function(H,J){for(var St in this.map)this.map.hasOwnProperty(St)&&H.call(J,this.map[St],St,this)},w.prototype.keys=function(){var H=[];return this.forEach(function(J,St){H.push(St)}),T(H)},w.prototype.values=function(){var H=[];return this.forEach(function(J){H.push(J)}),T(H)},w.prototype.entries=function(){var H=[];return this.forEach(function(J,St){H.push([St,J])}),T(H)},f.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function _(H){if(H.bodyUsed)return Promise.reject(new TypeError("Already read"));H.bodyUsed=!0}function D(H){return new Promise(function(J,St){H.onload=function(){J(H.result)},H.onerror=function(){St(H.error)}})}function M(H){var J=new FileReader,St=D(J);return J.readAsArrayBuffer(H),St}function F(H){var J=new FileReader,St=D(J);return J.readAsText(H),St}function x(H){for(var J=new Uint8Array(H),St=new Array(J.length),$=0;$<J.length;$++)St[$]=String.fromCharCode(J[$]);return St.join("")}function N(H){if(H.slice)return H.slice(0);var J=new Uint8Array(H.byteLength);return J.set(new Uint8Array(H)),J.buffer}function V(){return this.bodyUsed=!1,this._initBody=function(H){this.bodyUsed=this.bodyUsed,this._bodyInit=H,H?typeof H=="string"?this._bodyText=H:f.blob&&Blob.prototype.isPrototypeOf(H)?this._bodyBlob=H:f.formData&&FormData.prototype.isPrototypeOf(H)?this._bodyFormData=H:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(H)?this._bodyText=H.toString():f.arrayBuffer&&f.blob&&p(H)?(this._bodyArrayBuffer=N(H.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(H)||v(H))?this._bodyArrayBuffer=N(H):this._bodyText=H=Object.prototype.toString.call(H):this._bodyText="",this.headers.get("content-type")||(typeof H=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):f.searchParams&&URLSearchParams.prototype.isPrototypeOf(H)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var H=_(this);if(H)return H;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 H=_(this);return H||(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(M)}),this.text=function(){var H=_(this);if(H)return H;if(this._bodyBlob)return F(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(x(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},f.formData&&(this.formData=function(){return this.text().then(Q)}),this.json=function(){return this.text().then(JSON.parse)},this}var j=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function rt(H){var J=H.toUpperCase();return j.indexOf(J)>-1?J:H}function nt(H,J){if(!(this instanceof nt))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');J=J||{};var St=J.body;if(H instanceof nt){if(H.bodyUsed)throw new TypeError("Already read");this.url=H.url,this.credentials=H.credentials,J.headers||(this.headers=new w(H.headers)),this.method=H.method,this.mode=H.mode,this.signal=H.signal,!St&&H._bodyInit!=null&&(St=H._bodyInit,H.bodyUsed=!0)}else this.url=String(H);if(this.credentials=J.credentials||this.credentials||"same-origin",(J.headers||!this.headers)&&(this.headers=new w(J.headers)),this.method=rt(J.method||this.method||"GET"),this.mode=J.mode||this.mode||null,this.signal=J.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&St)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(St),(this.method==="GET"||this.method==="HEAD")&&(J.cache==="no-store"||J.cache==="no-cache")){var $=/([?&])_=[^&]*/;if($.test(this.url))this.url=this.url.replace($,"$1_="+new Date().getTime());else{var U=/\?/;this.url+=(U.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}nt.prototype.clone=function(){return new nt(this,{body:this._bodyInit})};function Q(H){var J=new FormData;return H.trim().split("&").forEach(function(St){if(St){var $=St.split("="),U=$.shift().replace(/\+/g," "),X=$.join("=").replace(/\+/g," ");J.append(decodeURIComponent(U),decodeURIComponent(X))}}),J}function Tt(H){var J=new w,St=H.replace(/\r?\n[\t ]+/g," ");return St.split("\r").map(function($){return $.indexOf(`
88
+ `)===0?$.substr(1,$.length):$}).forEach(function($){var U=$.split(":"),X=U.shift().trim();if(X){var mt=U.join(":").trim();J.append(X,mt)}}),J}V.call(nt.prototype);function gt(H,J){if(!(this instanceof gt))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');J||(J={}),this.type="default",this.status=J.status===void 0?200:J.status,this.ok=this.status>=200&&this.status<300,this.statusText=J.statusText===void 0?"":""+J.statusText,this.headers=new w(J.headers),this.url=J.url||"",this._initBody(H)}V.call(gt.prototype),gt.prototype.clone=function(){return new gt(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new w(this.headers),url:this.url})},gt.error=function(){var H=new gt(null,{status:0,statusText:""});return H.type="error",H};var $t=[301,302,303,307,308];gt.redirect=function(H,J){if($t.indexOf(J)===-1)throw new RangeError("Invalid status code");return new gt(null,{status:J,headers:{location:H}})},c.DOMException=d.DOMException;try{new c.DOMException}catch{c.DOMException=function(J,St){this.message=J,this.name=St;var $=Error(J);this.stack=$.stack},c.DOMException.prototype=Object.create(Error.prototype),c.DOMException.prototype.constructor=c.DOMException}function Wt(H,J){return new Promise(function(St,$){var U=new nt(H,J);if(U.signal&&U.signal.aborted)return $(new c.DOMException("Aborted","AbortError"));var X=new XMLHttpRequest;function mt(){X.abort()}X.onload=function(){var xt={status:X.status,statusText:X.statusText,headers:Tt(X.getAllResponseHeaders()||"")};xt.url="responseURL"in X?X.responseURL:xt.headers.get("X-Request-URL");var Ut="response"in X?X.response:X.responseText;setTimeout(function(){St(new gt(Ut,xt))},0)},X.onerror=function(){setTimeout(function(){$(new TypeError("Network request failed"))},0)},X.ontimeout=function(){setTimeout(function(){$(new TypeError("Network request failed"))},0)},X.onabort=function(){setTimeout(function(){$(new c.DOMException("Aborted","AbortError"))},0)};function bt(xt){try{return xt===""&&d.location.href?d.location.href:xt}catch{return xt}}X.open(U.method,bt(U.url),!0),U.credentials==="include"?X.withCredentials=!0:U.credentials==="omit"&&(X.withCredentials=!1),"responseType"in X&&(f.blob?X.responseType="blob":f.arrayBuffer&&U.headers.get("Content-Type")&&U.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(X.responseType="arraybuffer")),J&&typeof J.headers=="object"&&!(J.headers instanceof w)?Object.getOwnPropertyNames(J.headers).forEach(function(xt){X.setRequestHeader(xt,E(J.headers[xt]))}):U.headers.forEach(function(xt,Ut){X.setRequestHeader(Ut,xt)}),U.signal&&(U.signal.addEventListener("abort",mt),X.onreadystatechange=function(){X.readyState===4&&U.signal.removeEventListener("abort",mt)}),X.send(typeof U._bodyInit>"u"?null:U._bodyInit)})}return Wt.polyfill=!0,d.fetch||(d.fetch=Wt,d.Headers=w,d.Request=nt,d.Response=gt),c.Headers=w,c.Request=nt,c.Response=gt,c.fetch=Wt,c})({})})(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,n.exports=t})(Dl,Dl.exports);var Yg=Dl.exports;const zg=Il(Yg);function Pl({canvas:n,scenes:t,currentTime:e}){if(t&&n){const i=t.scenes.filter(({start:o,duration:c})=>e>=o&&e<=o+c);if(i.length<=0)return;const s=n.getContext("2d");if(s){const o=t.transitionDuration,c=Math.max(...t.scenes.map(({start:d,duration:f})=>d+f));s.globalCompositeOperation="lighter",s.clearRect(0,0,n.width,n.height),i.forEach(({start:d,duration:f,draw:p,transitionCanvas:g})=>{s.globalAlpha=1,g.width=g.height=0,g.width=n.width,g.height=n.height;const v=g.getContext("2d");if(v){const b=d+f,E=d===0,T=b===c;p({currentTime:e,canvas:g,context:v}),!E&&e>=d&&e<=d+o/2?s.globalAlpha=Math.max(0,Math.min(1,(e-d)/(o/2))):!T&&e>=b-o/2&&e<=b&&(s.globalAlpha=Math.max(0,Math.min(1,(b-e)/(o/2)))),s.drawImage(g,0,0,n.width,n.height)}})}}}function Xg(n){if(typeof n=="string"){const[t,e]=n.split(":");return Math.min(parseFloat(t),parseFloat(e))}return n}function Zg(n){if(typeof n=="string"){const[t,e]=n.split(":"),i=parseFloat(t),s=parseFloat(e);return i/s}return n}function Ol({resolution:n,aspectRatio:t}){const e=Xg(n),i=Zg(t),s=i>=1,o=Math.min(s?e*i:e/i,e),c=Math.max(s?e*i:e/i,e);return{resolution:e,aspectRatio:i,height:s?o:c,width:s?c:o}}function qg({format:n,resolution:t,aspectRatio:e,sourceWidth:i,sourceHeight:s}){const{width:o,height:c}=Ol({resolution:t,aspectRatio:e}),d=i/s,f=e>d;let p=1;if(n==="letterbox"||n==="letterbox-video")p=f?c/s:o/i;else if(n==="squarebox"){const T=Math.min(c,o);p=i>=s?T/s:T/i}else n==="crop"&&(p=f?o/i:c/s);const g=o/p,v=c/p,b=(i-g)/2,E=(s-v)/2;return{sx:b,sy:E,sWidth:g,sHeight:v,scale:p}}function ca({source:n,sx:t,sy:e,sw:i,sh:s,dx:o,dy:c,dw:d,dh:f}){const p=(n==null?void 0:n.naturalWidth)??(n==null?void 0:n.videoWidth)??(n==null?void 0:n.width),g=(n==null?void 0:n.naturalHeight)??(n==null?void 0:n.videoHeight)??(n==null?void 0:n.height);t=t??0,e=e??0,i=i??p,s=s??g,i<0&&(t+=i,i=Math.abs(i)),s<0&&(e+=s,s=Math.abs(s)),d<0&&(o+=d,d=Math.abs(d)),f<0&&(c+=f,f=Math.abs(f));const v=Math.max(t,0),b=Math.min(t+i,p),E=Math.max(e,0),T=Math.min(e+s,g),w=d/i,_=f/s;return[n,v,E,b-v,T-E,t<0?o-t*w:o,e<0?c-e*_:c,(b-v)*w,(T-E)*_]}function Fd({context:n,source:t,crop:e,format:i="letterbox",posX:s,posY:o,drawAreaWidth:c,drawAreaHeight:d,sourceWidth:f,sourceHeight:p,cropCanvas:g,letterboxCanvas:v}){const{x:b,y:E,width:T,height:w}=e??{},_=f*(b??0),D=p*(E??0),M=f*Math.min(1-(b??0),T??1),F=p*Math.min(1-(E??0),w??1),x=g.getContext("2d");if(x){g.width=M,g.height=F;const J=ca({source:t,sx:_,sy:D,sw:M,sh:F,dx:0,dy:0,dw:M,dh:F});x.drawImage(...J)}const N=M/F,{sx:V,sy:j,sWidth:rt,sHeight:nt,scale:Q}=qg({resolution:Math.min(c,d),aspectRatio:c/d,format:i,sourceWidth:M,sourceHeight:F}),Tt=g&&typeof n.filter<"u";if(i==="letterbox"||i==="squarebox"||i==="letterbox-video"&&!Tt){if(V<0){const J=Math.abs(V)*Q;n.fillStyle="black",n.beginPath(),n.rect(s,o,J,d),n.rect(s+c-J,o,J,d),n.fill(),n.closePath()}if(j<0){const J=Math.abs(j)*Q;n.fillStyle="black",n.beginPath(),n.rect(s,o,c,J),n.rect(s,o+d-J,c,J),n.fill(),n.closePath()}}if(i==="letterbox-video"&&Tt){const J=v.getContext("2d");if(J){v.width=M,v.height=F,n.save(),n.globalCompositeOperation="destination-out",n.fillRect(s,o,c,d);const St=ca({source:g,sx:V,sy:j,sw:rt,sh:nt,dx:s,dy:o,dw:c,dh:d});n.globalCompositeOperation="source-over",n.drawImage(...St),J.save();const $=1.2,U=-(M*$-M)/2,X=-(F*$-F)/2,mt=Math.min(M/20,F/20);if(J.filter=`blur(${mt}px) brightness(20%)`,J.translate(U,X),J.scale($,$),J.drawImage(g,0,0,M,F),J.restore(),n.globalCompositeOperation="destination-over",V<0){const bt=c/N,xt=d/bt,Ut=ca({source:v,sy:(1-xt)*F/2,sh:xt*F,dx:s,dy:o,dw:c,dh:d});n.drawImage(...Ut)}if(j<0){const bt=d*N,xt=c/bt,Ut=ca({source:v,sx:(1-xt)*M/2,sw:xt*M,dx:s,dy:o,dw:c,dh:d});n.drawImage(...Ut)}n.restore()}}else{const J=ca({source:g,sx:V,sy:j,sw:rt,sh:nt,dx:s,dy:o,dw:c,dh:d});n.drawImage(...J)}const gt=V*-1*Q,$t=j*-1*Q,Wt=c-gt*2,H=d-$t*2;return{dx:gt,dy:$t,dw:Wt,dh:H}}const Ud=[{family:"Noto Arabic",regex:/\p{Script=Arabic}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansArabic-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Chinese",regex:/\p{Script=Han}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansSC-VariableFont_wght.woff2",style:"normal"},{family:"Noto Hebrew",regex:/\p{Script=Hebrew}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansHebrew-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Hindi",regex:/\p{Script=Devanagari}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansDevanagari-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Japanese",regex:/\p{Script=Han}|\p{Script=Katakana}|\p{Script=Hiragana}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansJP-VariableFont_wght.woff2",style:"normal"},{family:"Noto Korean",regex:/\p{Script=Hangul}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansKR-VariableFont_wght.woff2",style:"normal"},{family:"Noto Color Emoji",regex:/\p{Extended_Pictographic}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoColorEmoji-Regular.woff2",style:"normal"}];function to({text:n,font:t}){let e=t;return Ud.forEach(({family:i,regex:s})=>{s.exec(n)&&(e+=`, ${i}`)}),e}const Qg=/\d{0,2}:?\d{2}:\d{2}\.\d{3}\s-->\s\d{0,2}:?\d{2}:\d{2}\.\d{3}\s{1,2}.*/g,Jg=/\d{0,2}:?\d{2}:\d{2}\.\d{3}/g;function Bd(n){if(!n)return[];const t=n.match(Qg);return t?t==null?void 0:t.map(e=>{const[i,s]=e.replace(`\r
84
89
  `,`
85
90
  `).split(`
86
- `),[n,a]=i.match(Wd)||[];return{start:n,end:a,text:s}}):[]}function Us(r){const[t,e,i]=r.split(":");return i?parseInt(t)*60*60+parseInt(e)*60+parseFloat(i):parseInt(t)*60+parseInt(e)}function Yd({canvas:r,dx:t,dy:e,dw:i,dh:s,relativeTime:n,vttCaptions:a}){if(a){const o=So(a).find(({start:l,end:h})=>l&&h&&n>=Us(l)&&n<Us(h));if(o){const l=r.getContext("2d");if(l){const h=Math.min(i,s);let c=[""];const d=i*.9,u=h*.05;l.font=`${u}px Roobert, Dejavu Sans, sans-serif`,l.textBaseline="middle",o.text.split(" ").forEach(f=>{const p=c.length-1,g=l.measureText(c[p]).width,v=l.measureText(` ${f}`).width;g+v<d?c[p]=`${c[p]} ${f}`:c=[...c,f]}),c.forEach((f,p)=>{const g=f.trim(),v=l.measureText(g),E=t+(i-v.width)/2,A=e+(s*.85-(u+h*.04)*(c.length-1-p)),L=u*.8,y=u/1.5,S=t+(i-v.width-y)/2,R=A-L,D=v.width+y,M=L*2,C=l.globalAlpha;l.save(),l.globalAlpha=.8*C,l.fillStyle="#000000",l.beginPath(),l.roundRect(S,R,D,M,h*.01),l.fill(),l.closePath(),l.globalAlpha=C,l.fillStyle="#FFFFFF",l.fillText(g,E,A),l.restore()})}}}}const Oe=1.8;function Zi(r){return typeof r=="number"?{top:r,right:r,bottom:r,left:r}:{top:0,right:0,bottom:0,left:0,...r}}function qd(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 Bs(r,t){return typeof r=="number"?r:typeof r=="function"?r(t):null}function Hs(r,t){const{w:e,gap:i=0,padding:s=0,direction:n="column",elements:a}=r,{right:o,left:l}=Zi(s);if(e){const h=Bs(e,t);if(h)return h}if(a){const h=a.length;if(n==="row")return o+l+i*(h-1)+a.reduce((c,d)=>c+=Hs(d,t),0);if(n==="column"){let c=0;return a.forEach(d=>{const u=o+l+Hs(d,t);u>c&&(c=u)}),c}}return 0}function zd(r,t,e){const{w:i=0,gap:s=0,padding:n=0,direction:a="column"}=r,{right:o,left:l}=Zi(n),h=t.length,c=t.reduce((u,f)=>{const{w:p}=f;if(p){const g=Bs(p,e);if(g)return u+=g}return p==="auto"?u+=Hs(f,e):u},0),d=t.filter(({w:u})=>u==="fill").length;return t.reduce((u,f)=>{const{w:p}=f,g=i-o-l,v=Math.min(g,Hs(f,e));if(p==="fill"){if(a==="row"){const E=(i-c-o-l-s*(h-1))/d;return u=[...u,E]}if(a==="column")return u=[...u,g]}return u=[...u,v]},[])}function Gs(r,t){const{h:e,gap:i=0,padding:s=0,direction:n="column",elements:a}=r,{top:o,bottom:l}=Zi(s);if(e){const h=Bs(e,t);if(h)return h}if(a){const h=a.length;if(n==="row"){let c=0;return a.forEach(d=>{const u=o+l+Gs(d,t);u>c&&(c=u)}),c}if(n==="column")return o+l+i*(h-1)+a.reduce((c,d)=>c+=Gs(d,t),0)}return 0}function Xd(r,t,e){const{h:i=0,gap:s=0,padding:n=0,direction:a="column"}=r,{top:o,bottom:l}=Zi(n),h=t.length,c=t.reduce((u,f)=>{const{h:p}=f;if(p){const g=Bs(p,e);if(g)return u+=g}return p==="auto"?u+=Gs(f,e):u},0),d=t.filter(({h:u})=>u==="fill").length;return t.reduce((u,f)=>{const{h:p}=f,g=i-o-l,v=Math.min(g,Gs(f,e));if(p==="fill"){if(a==="row")return u=[...u,g];if(a==="column"){const E=(i-c-o-l-s*(h-1))/d;return u=[...u,E]}}return u=[...u,v]},[])}function Lo({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,c={x:0,y:0,w:n/h,h:a/h,gap:0,padding:0,direction:"column",align:"start",justify:"start",...o},{x:d,y:u,w:f,h:p,gap:g,padding:v,direction:E,align:A,justify:L}=c,{top:y,right:S,bottom:R,left:D}=Zi(v);l.map((M,C)=>{const I=r.getContext("2d",{alpha:!1});if(I){const G=l.length,{x:F,y:V,radius:q,elements:w=[],draw:P}=M,{topLeft:H,topRight:b,bottomRight:T,bottomLeft:k}=qd(q,h),N=zd(c,l,{context:I}),[U,K,W]=N.reduce((Tt,_t,Ot)=>(Ot<C&&(Tt[0]=Tt[0]+=_t),Ot>C&&(Tt[1]=Tt[1]+=_t),Tt[2]=Tt[2]+=_t,Tt),[0,0,0]),X=N[C],lt=Xd(c,l,{context:I,width:X}),[rt,at,Rt]=lt.reduce((Tt,_t,Ot)=>(Ot<C&&(Tt[0]=Tt[0]+=_t),Ot>C&&(Tt[1]=Tt[1]+=_t),Tt[2]=Tt[2]+=_t,Tt),[0,0,0]),nt=lt[C],it={"row|start|start":D+U+g*C,"row|center|start":D+U+g*C,"row|end|start":D+U+g*C,"row|start|center":f/2-W/2-g*(G-1)/2+U+g*C,"row|center|center":f/2-W/2-g*(G-1)/2+U+g*C,"row|end|center":f/2-W/2-g*(G-1)/2+U+g*C,"row|start|end":f-S-X-K-g*(G-C),"row|center|end":f-S-X-K-g*(G-C),"row|end|end":f-S-X-K-g*(G-C),"column|start|start":D,"column|center|start":f/2-X/2,"column|end|start":f-S-X-K,"column|start|center":D,"column|center|center":f/2-X/2,"column|end|center":f-S-X-K,"column|start|end":D,"column|center|end":f/2-X/2,"column|end|end":f-S-X-K},vt={"row|start|start":y,"row|center|start":p/2-nt/2,"row|end|start":p-R-nt-at,"row|start|center":y,"row|center|center":p/2-nt/2,"row|end|center":p-R-nt-at,"row|start|end":y,"row|center|end":p/2-nt/2,"row|end|end":p-R-nt-at,"column|start|start":y+rt+g*C,"column|center|start":y+rt+g*C,"column|end|start":y+rt+g*C,"column|start|center":p/2-Rt/2-g*(G-1)/2+rt+g*C,"column|center|center":p/2-Rt/2-g*(G-1)+rt+g*C,"column|end|center":p/2-Rt/2-g*(G-1)+rt+g*C,"column|start|end":p-R-nt-at-g*(G-C),"column|center|end":p-R-nt-at-g*(G-C),"column|end|end":p-R-nt-at-g*(G-C)},dt=d+(F??it[`${E}|${A}|${L}`]),Ct=u+(V??vt[`${E}|${A}|${L}`]),et=i+dt*h,ut=s+Ct*h,bt=X*h,pt=nt*h;P&&(I.save(),q&&(I.beginPath(),I.moveTo(et+Math.min(pt/Oe,H),ut),I.lineTo(et+bt-Math.min(pt/Oe,b),ut),I.quadraticCurveTo(et+bt,ut,et+bt,ut+Math.min(pt/Oe,b)),I.lineTo(et+bt,ut+pt-Math.min(pt/Oe,T)),I.quadraticCurveTo(et+bt,ut+pt,et+bt-Math.min(pt/Oe,T),ut+pt),I.lineTo(et+Math.min(pt/Oe,k),ut+pt),I.quadraticCurveTo(et,ut+pt,et,ut+pt-Math.min(pt/Oe,k)),I.lineTo(et,ut+Math.min(pt/Oe,H)),I.quadraticCurveTo(et,ut,et+Math.min(pt/Oe,H),ut),I.closePath(),e&&(I.strokeStyle="blue",I.stroke()),I.clip()),P({scale:h,canvas:r,context:I,offscreenCanvas:t,dx:et,dy:ut,dw:bt,dh:pt}),e&&(I.strokeStyle="red",I.strokeRect(et,ut,bt,pt)),I.restore()),Lo({canvas:r,offscreenCanvas:t,debug:e,origin:{x:i,y:s,w:n,h:a},parent:{...M,x:dt,y:Ct,w:X,h:nt},elements:w})}})}function Qd(r){return Lo(r)}function Vs({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 Ro(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.type!=="gradient"?!!e.value:i==null?void 0:i.some(s=>Ro(s)):!1}function _o({debug:r,elements:t,currentTime:e,relativeTime:i}){return t.map(s=>{const{node:n}=s;if(Ro(s))return{...s,...(n==null?void 0:n.type)==="text"&&n.value?{w:n.fill?"fill":({context:a})=>n&&n.type==="text"&&n.value?(a.font=n.font,a.textBaseline="top",Math.ceil(a.measureText(n.value).width)):0,h:n.fill?"fill":({width:a,context:o})=>{var l,h;if(n&&n.type==="text"){const c=/(?<value>\d+\.?\d*)(?=px)/,d=parseFloat(((h=(l=n.font.match(c))==null?void 0:l.groups)==null?void 0:h.value)??"0");return n.wrap?Vs({context:o,node:n,maxW:a}).length*d:d}return 0}}:{},...(n==null?void 0:n.type)==="image"&&n.image&&n.size?{w:()=>{var a,o,l,h,c,d;const u=((a=n.image)==null?void 0:a.naturalWidth)??((o=n.image)==null?void 0:o.width),f=((l=n.image)==null?void 0:l.naturalHeight)??((h=n.image)==null?void 0:h.height),p=u/f,g=(c=n.size)==null?void 0:c.w,v=((d=n.size)==null?void 0:d.h)??0;return g??(p>=1?v:v*p)},h:()=>{var a,o,l,h,c,d;const u=((a=n.image)==null?void 0:a.naturalWidth)??((o=n.image)==null?void 0:o.width),f=((l=n.image)==null?void 0:l.naturalHeight)??((h=n.image)==null?void 0:h.height),p=u/f,g=((c=n.size)==null?void 0:c.w)??0;return((d=n.size)==null?void 0:d.h)??(p<1?g:g*p)}}:{},elements:s.elements?_o({debug:r,elements:s.elements,currentTime:e,relativeTime:i}):void 0,draw:({canvas:a,offscreenCanvas:o,context:l,dx:h,dy:c,dw:d,dh:u,scale:f})=>{var p,g,v,E,A,L,y,S,R,D,M;if(n){const{type:C,from:I=0,to:G=1/0}=n;if(i>=I&&i<=G){if(l.save(),i&&G-.3333333333333333<=i&&(l.globalAlpha=1-(.16666666666666666-(G-i))/.16666666666666666),C==="box"&&(l.fillStyle=n.background,l.fillRect(h,c,d,u)),C==="text"&&n.value){const F=/(?<value>\d+\.?\d*)(?=px)/;let V=0;const q=parseFloat(((g=(p=n.font.match(F))==null?void 0:p.groups)==null?void 0:g.value)??"0")*f;if(n.fill){const{minSize:w,maxSize:P}=n.fill;V=w*f,l.font=n.font.replace(F,V.toString());const H=10*f;let b=0,T=Vs({context:l,node:n,maxW:d});for(;V+H<P*f&&(T.length+1)*(V+H)<u;)if(V+=H,l.font=n.font.replace(F,V.toString()),T=Vs({context:l,node:n,maxW:d}),b=T.reduce((k,N)=>(N.metrics.width>k&&(k=N.metrics.width),k),0),b>d){V-=H;break}l.font=n.font.replace(F,V.toString())}else V=q,l.font=n.font.replace(F,q.toString());l.textBaseline="top",l.fillStyle=n.color,n.wrap?Vs({context:l,node:n,maxW:d}).forEach((w,P)=>{l.fillText(w.text,h,c+V*P)}):l.fillText(n.value,h,c)}if(C==="image"&&n.image&&l.drawImage(n.image,h,c,d,u),C==="video"&&((v=n.video)!=null&&v.node||(E=n.video)!=null&&E.getSource)){const F=n.format??"letterbox",V=((L=(A=n.video)==null?void 0:A.getSource)==null?void 0:L.call(A,i))??n.video.node,q=(V==null?void 0:V.videoWidth)??(V==null?void 0:V.naturalWidth)??(V==null?void 0:V.width),w=(V==null?void 0:V.videoHeight)??(V==null?void 0:V.naturalHeight)??(V==null?void 0:V.height);if(q&&w){const{resolution:H,aspectRatio:b}=bi({resolution:Math.min(q,w),aspectRatio:q/w}),{dx:T,dy:k,dw:N,dh:U}=wo({offscreenCanvas:o,context:l,source:V,format:F,videoResolution:H,videoAspectRatio:b,posX:h,posY:c,width:d,height:u});n.elements&&Zr({debug:r,canvas:a,offscreenCanvas:o,currentTime:e,relativeTime:i,origin:{x:Math.max(h,h+T),y:Math.max(c,c+k),w:Math.min(d,N),h:Math.min(u,U)},elements:n.elements})}const P=1/3;if(n.poster&&e>=0&&e<=P){l.save(),l.globalAlpha=1-e/P;const H=((y=n.poster)==null?void 0:y.naturalWidth)??((S=n.poster)==null?void 0:S.width),b=((R=n.poster)==null?void 0:R.naturalHeight)??((D=n.poster)==null?void 0:D.height);if(H&&b){const{resolution:T,aspectRatio:k}=bi({resolution:Math.min(H,b),aspectRatio:H/b}),{dx:N,dy:U,dw:K,dh:W}=wo({offscreenCanvas:o,context:l,source:n.poster,format:F,videoResolution:T,videoAspectRatio:k,posX:h,posY:c,width:d,height:u});n.elements&&Zr({debug:r,canvas:a,offscreenCanvas:o,currentTime:e,relativeTime:i,origin:{x:Math.max(h,h+N),y:Math.max(c,c+U),w:Math.min(d,K),h:Math.min(u,W)},elements:n.elements})}l.restore()}}if(C==="gradient"&&n.value){const F=l.createLinearGradient(h+d,c,h+d,c+u);(M=n.value)==null||M.forEach(V=>{F.addColorStop(V.percent,V.color)}),l.fillStyle=F,l.fillRect(h,c,d,u)}l.restore()}}}}}).filter(Boolean)}function Zr({debug:r,elements:t,currentTime:e,relativeTime:i,...s}){return Qd({...s,debug:r,elements:_o({debug:r,elements:t,currentTime:e,relativeTime:i})})}const Zd=(r,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const s=Object.getOwnPropertyDescriptor(r,e),n=Object.getOwnPropertyDescriptor(t,e);!Jd(s,n)&&i||Object.defineProperty(r,e,n)},Jd=function(r,t){return r===void 0||r.configurable||r.writable===t.writable&&r.enumerable===t.enumerable&&r.configurable===t.configurable&&(r.writable||r.value===t.value)},tu=(r,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(r)&&Object.setPrototypeOf(r,e)},eu=(r,t)=>`/* Wrapped ${r}*/
87
- ${t}`,iu=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),su=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),ru=(r,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,s=eu.bind(null,i,t.toString());Object.defineProperty(s,"name",su),Object.defineProperty(r,"toString",{...iu,value:s})};function nu(r,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=r;for(const s of Reflect.ownKeys(t))Zd(r,t,s,e);return tu(r,t),ru(r,t,i),r}const au=new WeakMap;function ko(r,{cacheKey:t=([i])=>i,cache:e=new Map}={}){const i=new Map,s=function(...n){const a=t(n);if(i.has(a))return i.get(a);const o=(async()=>{try{if(e&&await e.has(a))return await e.get(a);const l=await r.apply(this,n);try{return l}finally{e&&await e.set(a,l)}}finally{i.delete(a)}})();return i.set(a,o),o};return nu(s,r,{ignoreNonConfigurable:!0}),au.set(s,e),s}const ou={id:"default",name:"None",template:{id:"basic",name:"Basic",layouts:[{name:"basic",tree:`[
91
+ `),[o,c]=i.match(Jg)||[];return{start:o,end:c,text:s}}):[]}function eo(n){const[t,e,i]=n.split(":");return i?parseInt(t)*60*60+parseInt(e)*60+parseFloat(i):parseInt(t)*60+parseInt(e)}function tm({canvas:n,dx:t,dy:e,dw:i,dh:s,relativeTime:o,vttCaptions:c}){if(c){const d=Bd(c).find(({start:f,end:p})=>f&&p&&o>=eo(f)&&o<eo(p));if(d){const f=n.getContext("2d");if(f){const p=Math.min(i,s);let g=[""];const v=i*.9,b=p*.05;f.font=to({text:c,font:`400 ${b}px Roobert Captions`}),f.textBaseline="middle",d.text.split(" ").forEach(E=>{const T=g.length-1,w=f.measureText(g[T]).width,_=f.measureText(` ${E}`).width;w+_<v?g[T]=`${g[T]} ${E}`:g=[...g,E]}),g.forEach((E,T)=>{const w=E.trim(),_=f.measureText(w),D=t+(i-_.width)/2,M=e+(s*.85-(b+p*.04)*(g.length-1-T)),F=b*.8,x=b/1.5,N=t+(i-_.width-x)/2,V=M-F,j=_.width+x,rt=F*2,nt=f.globalAlpha;f.save(),f.globalAlpha=.8*nt,f.fillStyle="#000000",f.beginPath(),f.roundRect(N,V,j,rt,p*.01),f.fill(),f.closePath(),f.globalAlpha=nt,f.fillStyle="#FFFFFF",f.fillText(w,D,M),f.restore()})}}}}const em=(n,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const s=Object.getOwnPropertyDescriptor(n,e),o=Object.getOwnPropertyDescriptor(t,e);!im(s,o)&&i||Object.defineProperty(n,e,o)},im=function(n,t){return n===void 0||n.configurable||n.writable===t.writable&&n.enumerable===t.enumerable&&n.configurable===t.configurable&&(n.writable||n.value===t.value)},rm=(n,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(n)&&Object.setPrototypeOf(n,e)},sm=(n,t)=>`/* Wrapped ${n}*/
92
+ ${t}`,nm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),am=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),om=(n,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,s=sm.bind(null,i,t.toString());Object.defineProperty(s,"name",am),Object.defineProperty(n,"toString",{...nm,value:s})};function lm(n,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=n;for(const s of Reflect.ownKeys(t))em(n,t,s,e);return rm(n,t),om(n,t,i),n}const cm=new WeakMap,Gd=new WeakMap;function Hd(n,{cacheKey:t,cache:e=new Map,maxAge:i}={}){if(i===0)return n;if(typeof i=="number"){if(i>2147483647)throw new TypeError("The `maxAge` option cannot exceed 2147483647.");if(i<0)throw new TypeError("The `maxAge` option should not be a negative number.")}const s=function(...o){var c;const d=t?t(o):o[0],f=e.get(d);if(f)return f.data;const p=n.apply(this,o);if(e.set(d,{data:p,maxAge:i?Date.now()+i:Number.POSITIVE_INFINITY}),typeof i=="number"&&i!==Number.POSITIVE_INFINITY){const g=setTimeout(()=>{e.delete(d)},i);(c=g.unref)==null||c.call(g);const v=Gd.get(n)??new Set;v.add(g),Gd.set(n,v)}return p};return lm(s,n,{ignoreNonConfigurable:!0}),cm.set(s,e),s}function Vd({context:n,word:t,maxW:e=1/0}){const i=[],s=n.measureText(t);if(s.width<e)return[{text:t,metrics:s}];for(let o=1;o<t.length;o++){i[i.length-1]||i.push({text:t[0],metrics:n.measureText(t[0])});const c=i[i.length-1].text+t[o],d=n.measureText(c);d.width<e?i[i.length-1]={text:c,metrics:d}:i.push({text:t[o],metrics:n.measureText(t[o])})}return i}const Ml=Hd(({context:n,font:t,fontSize:e,text:i,maxW:s=1/0})=>{try{return n.save(),n.font=t.replace(ho,e.toString()),i.split(`
93
+ `).flatMap(o=>{const c=o.split(" ").filter(Boolean);return c.slice(1).reduce((d,f)=>{const p=`${d[d.length-1].text} ${f}`.trim(),g=n.measureText(p);return g.width>s?d=[...d,...Vd({context:n,word:f,maxW:s})]:d[d.length-1]={text:p,metrics:g},d},Vd({context:n,word:c[0],maxW:s}))})}finally{n.restore()}},{cacheKey:([{font:n,fontSize:t,text:e,maxW:i}])=>`${n}_${t}_${e}_${i}`}),Wd=Hd(({font:n,scale:t,context:e,maxW:i,maxH:s,text:o,minSize:c,maxSize:d})=>{var f,p;let g=0;if(d){g=(c??0)*t;let v=0;for(;d*t>g+1;){g+=1;const b=Ml({context:e,font:n,fontSize:g,text:o,maxW:i});if(v=b.reduce((E,T)=>(T.metrics.width>E&&(E=T.metrics.width),E),0),v>i||b.length*g>s){g-=1;break}}}else g=parseFloat(((p=(f=n.match(ho))==null?void 0:f.groups)==null?void 0:p.value)??"0")*t;return g},{cacheKey:([{font:n,text:t,minSize:e,maxSize:i,scale:s,maxW:o,maxH:c}])=>`${n}_${t}_${e}_${i}_${s}_${o}_${c}`});function hm(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ee={},$l={},re={};Object.defineProperty(re,"__esModule",{value:!0}),re.default=re.Wrap=re.Unit=re.PrintOptions=re.PositionType=re.Overflow=re.NodeType=re.MeasureMode=re.LogLevel=re.Justify=re.Gutter=re.FlexDirection=re.ExperimentalFeature=re.Errata=re.Edge=re.Display=re.Direction=re.Dimension=re.Align=void 0;let Xr=function(n){return n[n.Auto=0]="Auto",n[n.FlexStart=1]="FlexStart",n[n.Center=2]="Center",n[n.FlexEnd=3]="FlexEnd",n[n.Stretch=4]="Stretch",n[n.Baseline=5]="Baseline",n[n.SpaceBetween=6]="SpaceBetween",n[n.SpaceAround=7]="SpaceAround",n}({});re.Align=Xr;let Nl=function(n){return n[n.Width=0]="Width",n[n.Height=1]="Height",n}({});re.Dimension=Nl;let io=function(n){return n[n.Inherit=0]="Inherit",n[n.LTR=1]="LTR",n[n.RTL=2]="RTL",n}({});re.Direction=io;let Fl=function(n){return n[n.Flex=0]="Flex",n[n.None=1]="None",n}({});re.Display=Fl;let Cr=function(n){return n[n.Left=0]="Left",n[n.Top=1]="Top",n[n.Right=2]="Right",n[n.Bottom=3]="Bottom",n[n.Start=4]="Start",n[n.End=5]="End",n[n.Horizontal=6]="Horizontal",n[n.Vertical=7]="Vertical",n[n.All=8]="All",n}({});re.Edge=Cr;let ha=function(n){return n[n.None=0]="None",n[n.StretchFlexBasis=1]="StretchFlexBasis",n[n.All=2147483647]="All",n[n.Classic=2147483646]="Classic",n}({});re.Errata=ha;let ro=function(n){return n[n.WebFlexBasis=0]="WebFlexBasis",n[n.AbsolutePercentageAgainstPaddingEdge=1]="AbsolutePercentageAgainstPaddingEdge",n[n.FixJNILocalRefOverflows=2]="FixJNILocalRefOverflows",n}({});re.ExperimentalFeature=ro;let da=function(n){return n[n.Column=0]="Column",n[n.ColumnReverse=1]="ColumnReverse",n[n.Row=2]="Row",n[n.RowReverse=3]="RowReverse",n}({});re.FlexDirection=da;let so=function(n){return n[n.Column=0]="Column",n[n.Row=1]="Row",n[n.All=2]="All",n}({});re.Gutter=so;let Js=function(n){return n[n.FlexStart=0]="FlexStart",n[n.Center=1]="Center",n[n.FlexEnd=2]="FlexEnd",n[n.SpaceBetween=3]="SpaceBetween",n[n.SpaceAround=4]="SpaceAround",n[n.SpaceEvenly=5]="SpaceEvenly",n}({});re.Justify=Js;let tn=function(n){return n[n.Error=0]="Error",n[n.Warn=1]="Warn",n[n.Info=2]="Info",n[n.Debug=3]="Debug",n[n.Verbose=4]="Verbose",n[n.Fatal=5]="Fatal",n}({});re.LogLevel=tn;let no=function(n){return n[n.Undefined=0]="Undefined",n[n.Exactly=1]="Exactly",n[n.AtMost=2]="AtMost",n}({});re.MeasureMode=no;let Ul=function(n){return n[n.Default=0]="Default",n[n.Text=1]="Text",n}({});re.NodeType=Ul;let ao=function(n){return n[n.Visible=0]="Visible",n[n.Hidden=1]="Hidden",n[n.Scroll=2]="Scroll",n}({});re.Overflow=ao;let oo=function(n){return n[n.Static=0]="Static",n[n.Relative=1]="Relative",n[n.Absolute=2]="Absolute",n}({});re.PositionType=oo;let lo=function(n){return n[n.Layout=1]="Layout",n[n.Style=2]="Style",n[n.Children=4]="Children",n}({});re.PrintOptions=lo;let ua=function(n){return n[n.Undefined=0]="Undefined",n[n.Point=1]="Point",n[n.Percent=2]="Percent",n[n.Auto=3]="Auto",n}({});re.Unit=ua;let co=function(n){return n[n.NoWrap=0]="NoWrap",n[n.Wrap=1]="Wrap",n[n.WrapReverse=2]="WrapReverse",n}({});re.Wrap=co;var dm={ALIGN_AUTO:Xr.Auto,ALIGN_FLEX_START:Xr.FlexStart,ALIGN_CENTER:Xr.Center,ALIGN_FLEX_END:Xr.FlexEnd,ALIGN_STRETCH:Xr.Stretch,ALIGN_BASELINE:Xr.Baseline,ALIGN_SPACE_BETWEEN:Xr.SpaceBetween,ALIGN_SPACE_AROUND:Xr.SpaceAround,DIMENSION_WIDTH:Nl.Width,DIMENSION_HEIGHT:Nl.Height,DIRECTION_INHERIT:io.Inherit,DIRECTION_LTR:io.LTR,DIRECTION_RTL:io.RTL,DISPLAY_FLEX:Fl.Flex,DISPLAY_NONE:Fl.None,EDGE_LEFT:Cr.Left,EDGE_TOP:Cr.Top,EDGE_RIGHT:Cr.Right,EDGE_BOTTOM:Cr.Bottom,EDGE_START:Cr.Start,EDGE_END:Cr.End,EDGE_HORIZONTAL:Cr.Horizontal,EDGE_VERTICAL:Cr.Vertical,EDGE_ALL:Cr.All,ERRATA_NONE:ha.None,ERRATA_STRETCH_FLEX_BASIS:ha.StretchFlexBasis,ERRATA_ALL:ha.All,ERRATA_CLASSIC:ha.Classic,EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS:ro.WebFlexBasis,EXPERIMENTAL_FEATURE_ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE:ro.AbsolutePercentageAgainstPaddingEdge,EXPERIMENTAL_FEATURE_FIX_JNILOCAL_REF_OVERFLOWS:ro.FixJNILocalRefOverflows,FLEX_DIRECTION_COLUMN:da.Column,FLEX_DIRECTION_COLUMN_REVERSE:da.ColumnReverse,FLEX_DIRECTION_ROW:da.Row,FLEX_DIRECTION_ROW_REVERSE:da.RowReverse,GUTTER_COLUMN:so.Column,GUTTER_ROW:so.Row,GUTTER_ALL:so.All,JUSTIFY_FLEX_START:Js.FlexStart,JUSTIFY_CENTER:Js.Center,JUSTIFY_FLEX_END:Js.FlexEnd,JUSTIFY_SPACE_BETWEEN:Js.SpaceBetween,JUSTIFY_SPACE_AROUND:Js.SpaceAround,JUSTIFY_SPACE_EVENLY:Js.SpaceEvenly,LOG_LEVEL_ERROR:tn.Error,LOG_LEVEL_WARN:tn.Warn,LOG_LEVEL_INFO:tn.Info,LOG_LEVEL_DEBUG:tn.Debug,LOG_LEVEL_VERBOSE:tn.Verbose,LOG_LEVEL_FATAL:tn.Fatal,MEASURE_MODE_UNDEFINED:no.Undefined,MEASURE_MODE_EXACTLY:no.Exactly,MEASURE_MODE_AT_MOST:no.AtMost,NODE_TYPE_DEFAULT:Ul.Default,NODE_TYPE_TEXT:Ul.Text,OVERFLOW_VISIBLE:ao.Visible,OVERFLOW_HIDDEN:ao.Hidden,OVERFLOW_SCROLL:ao.Scroll,POSITION_TYPE_STATIC:oo.Static,POSITION_TYPE_RELATIVE:oo.Relative,POSITION_TYPE_ABSOLUTE:oo.Absolute,PRINT_OPTIONS_LAYOUT:lo.Layout,PRINT_OPTIONS_STYLE:lo.Style,PRINT_OPTIONS_CHILDREN:lo.Children,UNIT_UNDEFINED:ua.Undefined,UNIT_POINT:ua.Point,UNIT_PERCENT:ua.Percent,UNIT_AUTO:ua.Auto,WRAP_NO_WRAP:co.NoWrap,WRAP_WRAP:co.Wrap,WRAP_WRAP_REVERSE:co.WrapReverse};re.default=dm,Object.defineProperty($l,"__esModule",{value:!0}),$l.default=fm;var bs=um(re);function jd(n){if(typeof WeakMap!="function")return null;var t=new WeakMap,e=new WeakMap;return(jd=function(i){return i?e:t})(n)}function um(n,t){if(!t&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var e=jd(t);if(e&&e.has(n))return e.get(n);var i={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in n)if(o!=="default"&&Object.prototype.hasOwnProperty.call(n,o)){var c=s?Object.getOwnPropertyDescriptor(n,o):null;c&&(c.get||c.set)?Object.defineProperty(i,o,c):i[o]=n[o]}return i.default=n,e&&e.set(n,i),i}function fm(n){function t(s,o,c){const d=s[o];s[o]=function(){for(var f=arguments.length,p=new Array(f),g=0;g<f;g++)p[g]=arguments[g];return c.call(this,d,...p)}}for(const s of["setPosition","setMargin","setFlexBasis","setWidth","setHeight","setMinWidth","setMinHeight","setMaxWidth","setMaxHeight","setPadding"]){const o={[bs.Unit.Point]:n.Node.prototype[s],[bs.Unit.Percent]:n.Node.prototype[`${s}Percent`],[bs.Unit.Auto]:n.Node.prototype[`${s}Auto`]};t(n.Node.prototype,s,function(c){for(var d=arguments.length,f=new Array(d>1?d-1:0),p=1;p<d;p++)f[p-1]=arguments[p];const g=f.pop();let v,b;if(g==="auto")v=bs.Unit.Auto,b=void 0;else if(typeof g=="object")v=g.unit,b=g.valueOf();else if(v=typeof g=="string"&&g.endsWith("%")?bs.Unit.Percent:bs.Unit.Point,b=parseFloat(g),!Number.isNaN(g)&&Number.isNaN(b))throw new Error(`Invalid value ${g} for ${s}`);if(!o[v])throw new Error(`Failed to execute "${s}": Unsupported unit '${g}'`);return b!==void 0?o[v].call(this,...f,b):o[v].call(this,...f)})}function e(s){return n.MeasureCallback.implement({measure:function(){const{width:o,height:c}=s(...arguments);return{width:o??NaN,height:c??NaN}}})}t(n.Node.prototype,"setMeasureFunc",function(s,o){return o?s.call(this,e(o)):this.unsetMeasureFunc()});function i(s){return n.DirtiedCallback.implement({dirtied:s})}return t(n.Node.prototype,"setDirtiedFunc",function(s,o){s.call(this,i(o))}),t(n.Config.prototype,"free",function(){n.Config.destroy(this)}),t(n.Node,"create",(s,o)=>o?n.Node.createWithConfig(o):n.Node.createDefault()),t(n.Node.prototype,"free",function(){n.Node.destroy(this)}),t(n.Node.prototype,"freeRecursive",function(){for(let s=0,o=this.getChildCount();s<o;++s)this.getChild(0).freeRecursive();this.free()}),t(n.Node.prototype,"calculateLayout",function(s){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:NaN,c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:NaN,d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:bs.Direction.LTR;return s.call(this,o,c,d)}),{Config:n.Config,Node:n.Node,...bs.default}}var Kd={exports:{}};(function(n,t){var e=(()=>{var i=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(s){s=s||{};var o;o||(o=typeof s<"u"?s:{});var c,d;o.ready=new Promise(function(L,C){c=L,d=C});var f=Object.assign({},o),p="";typeof document<"u"&&document.currentScript&&(p=document.currentScript.src),i&&(p=i),p.indexOf("blob:")!==0?p=p.substr(0,p.replace(/[?#].*/,"").lastIndexOf("/")+1):p="";var g=o.print||console.log.bind(console),v=o.printErr||console.warn.bind(console);Object.assign(o,f),f=null;var b;o.wasmBinary&&(b=o.wasmBinary),o.noExitRuntime;function E(){this.buffer=new ArrayBuffer(H/65536*65536)}function T(){}function w(L){this.exports=function(C){function B(ei){return ei.set=function(le,rr){this[le]=rr},ei.get=function(le){return this[le]},ei}for(var G,it=new Uint8Array(123),vt=25;vt>=0;--vt)it[48+vt]=52+vt,it[65+vt]=vt,it[97+vt]=26+vt;it[43]=62,it[47]=63;function lt(ei,le,rr){for(var $i,ft,Fr=0,l=le,At=rr.length,Nn=le+(At*3>>2)-(rr[At-2]=="=")-(rr[At-1]=="=");Fr<At;Fr+=4)$i=it[rr.charCodeAt(Fr+1)],ft=it[rr.charCodeAt(Fr+2)],ei[l++]=it[rr.charCodeAt(Fr)]<<2|$i>>4,l<Nn&&(ei[l++]=$i<<4|ft>>2),l<Nn&&(ei[l++]=ft<<6|it[rr.charCodeAt(Fr+3)])}function Rt(ei){lt(G,1024,"T25seSBsZWFmIG5vZGVzIHdpdGggY3VzdG9tIG1lYXN1cmUgZnVuY3Rpb25zIHNob3VsZCBtYW51YWxseSBtYXJrIHRoZW1zZWx2ZXMgYXMgZGlydHkAaXNEaXJ0eQBtYXJrRGlydHkAZGVzdHJveQBzZXREaXNwbGF5AGdldERpc3BsYXkAc2V0RmxleAAtKyAgIDBYMHgALTBYKzBYIDBYLTB4KzB4IDB4AHNldEZsZXhHcm93AGdldEZsZXhHcm93AHNldE92ZXJmbG93AGdldE92ZXJmbG93AGNhbGN1bGF0ZUxheW91dABnZXRDb21wdXRlZExheW91dAB1bnNpZ25lZCBzaG9ydABnZXRDaGlsZENvdW50AHVuc2lnbmVkIGludABzZXRKdXN0aWZ5Q29udGVudABnZXRKdXN0aWZ5Q29udGVudABzZXRBbGlnbkNvbnRlbnQAZ2V0QWxpZ25Db250ZW50AGdldFBhcmVudABpbXBsZW1lbnQAc2V0TWF4SGVpZ2h0UGVyY2VudABzZXRIZWlnaHRQZXJjZW50AHNldE1pbkhlaWdodFBlcmNlbnQAc2V0RmxleEJhc2lzUGVyY2VudABzZXRQb3NpdGlvblBlcmNlbnQAc2V0TWFyZ2luUGVyY2VudABzZXRNYXhXaWR0aFBlcmNlbnQAc2V0V2lkdGhQZXJjZW50AHNldE1pbldpZHRoUGVyY2VudABzZXRQYWRkaW5nUGVyY2VudABjcmVhdGVEZWZhdWx0AHVuaXQAcmlnaHQAaGVpZ2h0AHNldE1heEhlaWdodABnZXRNYXhIZWlnaHQAc2V0SGVpZ2h0AGdldEhlaWdodABzZXRNaW5IZWlnaHQAZ2V0TWluSGVpZ2h0AGdldENvbXB1dGVkSGVpZ2h0AGdldENvbXB1dGVkUmlnaHQAbGVmdABnZXRDb21wdXRlZExlZnQAcmVzZXQAX19kZXN0cnVjdABmbG9hdAB1aW50NjRfdAB1c2VXZWJEZWZhdWx0cwBzZXRVc2VXZWJEZWZhdWx0cwBzZXRBbGlnbkl0ZW1zAGdldEFsaWduSXRlbXMAc2V0RmxleEJhc2lzAGdldEZsZXhCYXNpcwBDYW5ub3QgZ2V0IGxheW91dCBwcm9wZXJ0aWVzIG9mIG11bHRpLWVkZ2Ugc2hvcnRoYW5kcwB1c2VMZWdhY3lTdHJldGNoQmVoYXZpb3VyAHNldFVzZUxlZ2FjeVN0cmV0Y2hCZWhhdmlvdXIAc2V0UG9pbnRTY2FsZUZhY3RvcgBNZWFzdXJlQ2FsbGJhY2tXcmFwcGVyAERpcnRpZWRDYWxsYmFja1dyYXBwZXIAQ2Fubm90IHJlc2V0IGEgbm9kZSBzdGlsbCBhdHRhY2hlZCB0byBhIG93bmVyAHNldEJvcmRlcgBnZXRCb3JkZXIAZ2V0Q29tcHV0ZWRCb3JkZXIAdW5zaWduZWQgY2hhcgB0b3AAZ2V0Q29tcHV0ZWRUb3AAc2V0RmxleFdyYXAAZ2V0RmxleFdyYXAAc2V0R2FwAGdldEdhcAAlcABzZXRIZWlnaHRBdXRvAHNldEZsZXhCYXNpc0F1dG8Ac2V0TWFyZ2luQXV0bwBzZXRXaWR0aEF1dG8AU2NhbGUgZmFjdG9yIHNob3VsZCBub3QgYmUgbGVzcyB0aGFuIHplcm8Ac2V0QXNwZWN0UmF0aW8AZ2V0QXNwZWN0UmF0aW8Ac2V0UG9zaXRpb24AZ2V0UG9zaXRpb24Abm90aWZ5T25EZXN0cnVjdGlvbgBzZXRGbGV4RGlyZWN0aW9uAGdldEZsZXhEaXJlY3Rpb24Ac2V0TWFyZ2luAGdldE1hcmdpbgBnZXRDb21wdXRlZE1hcmdpbgBuYW4AYm90dG9tAGdldENvbXB1dGVkQm90dG9tAGJvb2wAZW1zY3JpcHRlbjo6dmFsAHNldEZsZXhTaHJpbmsAZ2V0RmxleFNocmluawBNZWFzdXJlQ2FsbGJhY2sARGlydGllZENhbGxiYWNrAHdpZHRoAHNldE1heFdpZHRoAGdldE1heFdpZHRoAHNldFdpZHRoAGdldFdpZHRoAHNldE1pbldpZHRoAGdldE1pbldpZHRoAGdldENvbXB1dGVkV2lkdGgAdW5zaWduZWQgbG9uZwBzdGQ6OndzdHJpbmcAc3RkOjpzdHJpbmcAc3RkOjp1MTZzdHJpbmcAc3RkOjp1MzJzdHJpbmcAc2V0UGFkZGluZwBnZXRQYWRkaW5nAGdldENvbXB1dGVkUGFkZGluZwBBdHRlbXB0aW5nIHRvIGNvbnN0cnVjdCBZR05vZGUgd2l0aCBudWxsIGNvbmZpZwBUcmllZCB0byBjb25zdHJ1Y3QgWUdOb2RlIHdpdGggbnVsbCBjb25maWcAY3JlYXRlV2l0aENvbmZpZwBpbmYAc2V0QWxpZ25TZWxmAGdldEFsaWduU2VsZgBTaXplAHZhbHVlAFZhbHVlAGNyZWF0ZQBtZWFzdXJlAHNldFBvc2l0aW9uVHlwZQBnZXRQb3NpdGlvblR5cGUAaXNSZWZlcmVuY2VCYXNlbGluZQBzZXRJc1JlZmVyZW5jZUJhc2VsaW5lAGNvcHlTdHlsZQBkb3VibGUATm9kZQBleHRlbmQAaW5zZXJ0Q2hpbGQAZ2V0Q2hpbGQAcmVtb3ZlQ2hpbGQAdm9pZABhdmFpbGFibGVIZWlnaHQgaXMgaW5kZWZpbml0ZSBzbyBoZWlnaHRNZWFzdXJlTW9kZSBtdXN0IGJlIFlHTWVhc3VyZU1vZGVVbmRlZmluZWQAYXZhaWxhYmxlV2lkdGggaXMgaW5kZWZpbml0ZSBzbyB3aWR0aE1lYXN1cmVNb2RlIG11c3QgYmUgWUdNZWFzdXJlTW9kZVVuZGVmaW5lZABzZXRFeHBlcmltZW50YWxGZWF0dXJlRW5hYmxlZABpc0V4cGVyaW1lbnRhbEZlYXR1cmVFbmFibGVkAGRpcnRpZWQAQ2Fubm90IHJlc2V0IGEgbm9kZSB3aGljaCBzdGlsbCBoYXMgY2hpbGRyZW4gYXR0YWNoZWQAdW5zZXRNZWFzdXJlRnVuYwB1bnNldERpcnRpZWRGdW5jAHNldEVycmF0YQBnZXRFcnJhdGEARXhwZWN0IGN1c3RvbSBiYXNlbGluZSBmdW5jdGlvbiB0byBub3QgcmV0dXJuIE5hTgBOQU4ASU5GAGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHNob3J0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBzaG9ydD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBpbnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGZsb2F0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQ4X3Q+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8Y2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgY2hhcj4Ac3RkOjpiYXNpY19zdHJpbmc8dW5zaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8c2lnbmVkIGNoYXI+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGRvdWJsZT4AQ2hpbGQgYWxyZWFkeSBoYXMgYSBvd25lciwgaXQgbXVzdCBiZSByZW1vdmVkIGZpcnN0LgBDYW5ub3Qgc2V0IG1lYXN1cmUgZnVuY3Rpb246IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAENhbm5vdCBhZGQgY2hpbGQ6IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAChudWxsKQAlcwoAAQAAAAMAAAAAAAAAAgAAAAMAAAABAAAAAgAAAAAAAAABAAAAAQ=="),lt(G,4338,"wH8DAAAAAADAfwAAAABpaQB2AHZp"),lt(G,4368,"exsAAHkbAAC5GwAAsxsAALkbAACzGwAAaWlpZmlmaQCsGwAAfBsAAHZpaQB9GwAAwBsAAGlpaQ=="),lt(G,4432,"xwAAAMgAAADJ"),lt(G,4452,"xwAAAMoAAADLAAAArBs="),lt(G,4480,"exsAALkbAACzGwAAuRsAALMbAADAGwAAuxsAAMAbAABpaWlpAAAAAKwbAACRGwAArBsAAJMbAACUGwAAwBs="),lt(G,4552,"zAAAAM0AAADO"),lt(G,4572,"zAAAAM8AAADLAAAAlxsAAKwbAACXGw=="),lt(G,4608,"rBsAAJcbAACzGwAArRsAAHZpaWlpAAAArBsAAJcbAAC5GwAAdmlpZgAAAACsGwAAlxsAAK0bAAB2aWlpAAAAAKwbAACXGwAAsxsAAK0bAACYGwAAsxsAAK0bAACYGwAAsxsAAJgbAABpAGRpaQB2aWlkAACcGwAAnBsAAJcbAACsGwAAnBsAAKwbAACcGwAAmxsAAKwbAACcGwAAsxsAAKwbAACcGwAAsxsAALobAAB2aWlpZAAAAKwbAACcGwAAuhsAALMbAACdGwAAmhsAAJ0bAACzGwAAmhsAAJ0bAAC6GwAAnRsAALobAACdGwAAsxsAAGRpaWkAAAAAuRsAAJwbAACzGwAAZmlpaQAAAACsGwAAnBsAAJwbAAC0GwAArBsAAJwbAACcGwAAtBsAAJ0bAACcGwAAnBsAAJwbAACcGwAAtBsAAK0bAACcGwAArBsAAJwbAACtGwAArBsAAJwbAAB5GwAArBsAAJwbAACRGwAArRsAAJ0bAAAAAAAArBsAAJwbAAC6GwAAuhsAALMbAAB2aWlkZGkAAJkbAACdGw=="),lt(G,5040,"GQAKABkZGQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAAZABEKGRkZAwoHAAEACQsYAAAJBgsAAAsABhkAAAAZGRk="),lt(G,5121,"DgAAAAAAAAAAGQAKDRkZGQANAAACAAkOAAAACQAOAAAO"),lt(G,5179,"DA=="),lt(G,5191,"EwAAAAATAAAAAAkMAAAAAAAMAAAM"),lt(G,5237,"EA=="),lt(G,5249,"DwAAAAQPAAAAAAkQAAAAAAAQAAAQ"),lt(G,5295,"Eg=="),lt(G,5307,"EQAAAAARAAAAAAkSAAAAAAASAAASAAAaAAAAGhoa"),lt(G,5362,"GgAAABoaGgAAAAAAAAk="),lt(G,5411,"FA=="),lt(G,5423,"FwAAAAAXAAAAAAkUAAAAAAAUAAAU"),lt(G,5469,"Fg=="),lt(G,5481,"FQAAAAAVAAAAAAkWAAAAAAAWAAAWAAAwMTIzNDU2Nzg5QUJDREVG"),lt(G,5556,"1Q=="),lt(G,5596,"//////////8="),lt(G,5664,"8B8BAAAAAAAF"),lt(G,5684,"0A=="),lt(G,5708,"0QAAANIAAADUGw=="),lt(G,5732,"Ag=="),lt(G,5748,"//////////8="),lt(G,5816,"BQ=="),lt(G,5828,"0w=="),lt(G,5852,"0QAAANQAAADoGwAAAAQ="),lt(G,5876,"AQ=="),lt(G,5892,"/////wo="),lt(G,5960,"1g==")}var Lt=new ArrayBuffer(16),Ct=new Int32Array(Lt),Nt=new Float32Array(Lt),Kt=new Float64Array(Lt);function te(ei){return Ct[ei]}function Dt(ei,le){Ct[ei]=le}function Ae(){return Kt[0]}function pi(ei){Kt[0]=ei}function he(){throw new Error("abort")}function Zi(ei){Nt[2]=ei}function Bt(){return Nt[2]}function Zo(ei){var le=ei.a,rr=le.a,$i=rr.buffer;rr.grow=yk;var ft=new Int8Array($i),Fr=new Int16Array($i),l=new Int32Array($i),At=new Uint8Array($i),Nn=new Uint16Array($i),lp=new Uint32Array($i),I=new Float32Array($i),Ne=new Float64Array($i),Fe=Math.imul,m=Math.fround,Ge=Math.abs,mr=Math.clz32,pE=Math.min,gE=Math.max,Yt=NaN,cp=1/0,wt=le.b,Ei=le.c,os=le.d,ls=le.e,Ds=le.f,Fn=le.g,Ma=le.h,qo=le.i,bh=le.j,Ah=le.k,Eh=le.l,hp=le.m,dp=le.n,up=le.o,fp=le.p,pp=le.q,mE=le.r,vE=le.s,yE=le.t,bE=le.u,AE=le.v,EE=le.w,TE=le.x,kE=le.y,wE=le.z,SE=le.A,RE=le.B,_E=le.C,LE=le.D,Et=73712,Ni=0;function gp(r,a,h,u,y,A,k,S,P,K,tt,dt,q,et){var O=0,W=m(0),Y=0,Z=m(0),at=0,ot=m(0),pt=0,yt=m(0),_t=0,Ot=0,Mt=m(0),Ht=0,Zt=0,ne=m(0),pe=m(0),_e=m(0),De=m(0),Pe=0,Ue=m(0),Ve=m(0),ii=0,ri=0,vi=m(0),Di=0,Qi=0,Pi=0,Bi=0,Ji=m(0),tr=0,Rr=0,_r=0,Vr=0,Wr=m(0),jr=0,Kr=0,cs=0,hs=0,ds=m(0),$s=0,Ns=0,Fs=0,Us=m(0),Bs=0,Gs=m(0),Fa=0,Ua=m(0),Ba=m(0),Ga=m(0),Ha=0,nl=m(0),$h=0,Nh=m(0),Fh=m(0),Uh=m(0),Bh=m(0),Gh=0,d2=0,u2=0,f2=0,p2=0,g2=0,m2=0,v2=0,We=0,je=m(0),Wn=m(0);O=Et-384|0,Et=O;t:{r:{i:{if(!(y&&a!=a)){if(!(A&&h!=h)){if(Y=(P?0:4)+tt|0,l[Y>>2]=l[Y>>2]+1,Y=l[r+24>>2]&3,$h=(u|0)<=1?1:u,Bi=Y||$h,ft[r+300|0]=At[r+300|0]&252|Bi&3,Y=r+252|0,u=((Bi|0)!=1)<<3,$s=(Bi|0)==2?3:2,ot=de(r,$s,k),I[Y+u>>2]=ot,at=Y,Y=((Bi|0)==1)<<3,pe=we(r,$s,k),I[at+Y>>2]=pe,yt=de(r,0,k),I[r+256>>2]=yt,De=we(r,0,k),I[r+264>>2]=De,at=r+268|0,We=at+u|0,je=fe(r,$s),I[We>>2]=je,We=Y+at|0,je=Se(r,$s),I[We>>2]=je,W=fe(r,0),I[r+272>>2]=W,Ue=Se(r,0),I[r+280>>2]=Ue,at=u,u=r+284|0,We=at+u|0,je=Ie(r,$s,k),I[We>>2]=je,We=u+Y|0,je=xe(r,$s,k),I[We>>2]=je,Z=Ie(r,0,k),I[r+288>>2]=Z,Mt=xe(r,0,k),I[r+296>>2]=Mt,ot=m(ot+pe),pe=m(yt+De),u=l[r+8>>2],u){yt=m(m(m(I[r+284>>2]+I[r+292>>2])+I[r+268>>2])+I[r+276>>2]),h=m(A?h-pe:Yt),W=m(m(Z+Mt)+W),Z=m(y?a-ot:Yt),a=Z;e:{if(a!=a)break e;if(a=m(Z-yt),a!=a){a=m(0);break e}a=ce(a,m(0))}ot=m(W+Ue),W=h;e:{if(h!=h)break e;if(W=m(h-ot),W!=W){W=m(0);break e}W=ce(W,m(0))}if(!((y|0)!=1|(A|0)!=1)){a=He(r,2,Z,k),u=a!=a,W=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));e:{if(!(u|W!=W)){a=ce(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=He(r,0,h,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(At[r+4|0]&16){Pt[u|0](O+24|0,r,a,y,W,A,0);break e}Pt[u|0](O+24|0,r,a,y,W,A)}l[tt+20>>2]=l[tt+20>>2]+1,u=(et<<2)+tt|0,l[u+24>>2]=l[u+24>>2]+1,a=m(yt+I[O+24>>2]),a=He(r,2,y?(y|0)==2?a:Z:a,k),u=a!=a,W=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));e:{if(!(u|W!=W)){a=ce(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=m(ot+I[O+28>>2]),a=He(r,0,A?(A|0)==2?a:h:a,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}if(u=l[r+556>>2],et=l[r+560>>2],(u|0)==(et|0)){pe=m(h-pe),a=He(r,2,y&-3?m(a-ot):m(m(m(I[r+284>>2]+I[r+292>>2])+I[r+268>>2])+I[r+276>>2]),k),u=a!=a,h=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}I[r+516>>2]=a,a=He(r,0,A&-3?pe:m(m(m(Z+Mt)+W)+Ue),S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(P||(W=m(a-ot),Z=m(h-pe),!(!(!(W<=m(0))|(y|0)!=2)&W==W|!(!(Z<=m(0))|(A|0)!=2)&Z==Z)&((y|0)!=1|(A|0)!=1)))break e;a=He(r,2,W!=W||(y|0)==2&&W<m(0)?m(0):W,k),u=a!=a,h=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));s:{if(!(u|h!=h)){a=ce(a,h);break s}a=u?h:a}I[r+516>>2]=a,a=He(r,0,Z!=Z||(A|0)==2&&Z<m(0)?m(0):Z,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));s:{if(!(u|h!=h)){a=ce(a,h);break s}a=u?h:a}I[r+520>>2]=a;break t}for(ii=et-u|0,Vr=ii>>2;Y=l[u>>2],l[Y+552>>2]!=(r|0)&&(at=l[r+568>>2],Y=Cp(l[at>>2],At[at+8|0],Y,r,_t,0),l[u>>2]=Y,l[Y+552>>2]=r),_t=_t+1|0,u=u+4|0,(et|0)!=(u|0););ft[r+300|0]=At[r+300|0]&251,_t=3,Di=l[r+24>>2],u=Di>>>2&3;e:{s:{n:{if((Bi|0)==2){et=0;a:switch(u-2|0){case 0:break e;case 1:break a;default:break n}_t=2;break e}if(_t=2,et=0,u>>>0>1)break s}et=_t}_t=u}Nh=m(a-ot),Wr=m(m(Ie(r,_t,k)+fe(r,_t))+m(xe(r,_t,k)+Se(r,_t))),Ue=m(Ie(r,et,k)+fe(r,et)),Ji=m(Ue+m(xe(r,et,k)+Se(r,et))),tr=_t>>>0>1,yt=Ap(r,0,Nh,tr?Wr:Ji,k),Fh=m(h-pe),Ve=Ap(r,1,Fh,tr?Ji:Wr,S),De=tr?Ve:yt,pe=tr?yt:Ve,jr=l[r+560>>2],Y=l[r+556>>2],Qi=tr?y:A;e:{if((Qi|0)!=1)break e;if((Y|0)==(jr|0))break i;for(u=Y;;){at=l[u>>2];s:{if(!Up(at))break s;if(Zt=0,pt)break e;n:{a:{if(!l[at+552>>2]){W=m(0);break a}if(h=I[at+32>>2],h!=h&&(W=m(0),h=I[at+28>>2],!(h>m(0))))break a;if(W=h,h!=h)break n}if(m(Ge(W))<m(9999999747378752e-20))break e}if(a=Hn(at),a!=a){pt=at;break s}if(pt=at,m(Ge(a))<m(9999999747378752e-20))break e}if(Zt=pt,u=u+4|0,(jr|0)==(u|0))break}}if((Y|0)==(jr|0))break i;for(Fa=(Bi|0)<=1?1:Bi,Ns=yt!=yt,Kr=Ns|(y|0)!=1,cs=Ve==Ve,Fs=yt==yt,W=m(0);;){Ht=l[Y>>2],bp(Ht),at=l[Ht+24>>2];e:{if(at&4194304){if(kp(Ht,0),u=At[Ht+4|0],at=u|1,ft[Ht+4|0]=at,!(u&4))break e;ft[Ht+4|0]=at&251;break e}if(P&&(u=at&3,Ip(Ht,u||Fa,pe,De,yt),at=l[Ht+24>>2]),(at&196608)==131072)break e;s:{if((Ht|0)==(Zt|0)){l[Zt+308>>2]=0,l[Zt+304>>2]=q,h=m(0);break s}hs=l[r+24>>2],u=hs>>>2&3;n:{a:{if((Bi|0)!=2)break a;pt=3;o:switch(u-2|0){case 0:break n;case 1:break o;default:break a}pt=2;break n}pt=u}Rr=pt>>>0>1,ot=Rr?yt:Ve,h=m(0),a=I[Ht+40>>2];n:{a:{Ot=l[Ht+40>>2];o:{if((Ot|0)==2139156720)break o;if((Ot|0)==2140081935)break a;u=4336;l:{if((Ot|0)!=2141891242){if(a==a)break l;u=4344}h=I[u>>2];c:{h:switch(Ot=l[u+4>>2],Ot|0){case 0:case 3:break h;default:break c}if(a=m(Yt),!(I[Ht+28>>2]>m(0)))break n;Ot=ft[l[Ht+568>>2]+8|0]&1,u=Ot?2143289344:0,Ot=Ot?3:1,h=(Dt(2,u),Bt())}switch(a=m(Yt),Ot-1|0){case 0:break a;case 1:break o;default:break n}}if(h=(Dt(2,(Ot&-1073741825)+536870912|0),Bt()),!(Ot&1073741824))break a}a=m(m(ot*h)*m(.009999999776482582));break n}a=h}h=I[Ht+572>>2],Ot=0;n:{a:switch(Pe=l[Ht+576>>2],Pe|0){case 0:case 3:break n;default:break a}if(Z=I[Ht+572>>2],!((Pe|0)!=1|Z!=Z)){if(h<m(0))break n;Ot=1;break n}if(Ot=1,(Pe|0)!=2|Z!=Z||(Ot=0,h<m(0)))break n;Ot=Fs}Z=I[Ht+580>>2],u=0;n:{a:switch(ri=l[Ht+584>>2],ri|0){case 0:case 3:break n;default:break a}if(Mt=I[Ht+580>>2],!((ri|0)!=1|Mt!=Mt)){if(Z<m(0))break n;u=1;break n}if(u=1,(ri|0)!=2|Mt!=Mt||(u=0,Z<m(0)))break n;u=cs}n:{a:{if(!(a!=a|ot!=ot)){if(h=I[Ht+308>>2],(!(ft[l[Ht+568>>2]+12|0]&1)|l[Ht+304>>2]==(q|0))&h==h)break n;if(h=m(m(Ie(Ht,pt,yt)+fe(Ht,pt))+m(xe(Ht,pt,yt)+Se(Ht,pt))),!(h<=a)&a<h)break a;h=a;break a}if(Ot&Rr){Z=m(m(Ie(Ht,2,yt)+fe(Ht,2))+m(xe(Ht,2,yt)+Se(Ht,2))),a=m(Yt);o:switch(Pe-1|0){case 1:h=m(m(yt*h)*m(.009999999776482582));case 0:if(a=h,Z<=a)break a;break;default:break o}if(!(a==a|Z==Z)){h=a;break a}if(a<Z){h=Z;break a}h=a!=a?Z:a;break a}if(!(Rr|u^1)){a=m(m(Ie(Ht,0,yt)+fe(Ht,0))+m(xe(Ht,0,yt)+Se(Ht,0))),h=m(Yt);o:switch(ri-1|0){case 1:Z=m(m(Ve*Z)*m(.009999999776482582));case 0:if(h=Z,a<=h)break a;break;default:break o}if(h!=h&a!=a)break a;if(a>h){h=a;break a}h=h!=h?a:h;break a}if(l[O+360>>2]=2143289344,l[O+24>>2]=2143289344,Pi=0,l[O+356>>2]=0,l[O+352>>2]=0,Mt=m(de(Ht,2,yt)+we(Ht,2,yt)),ne=de(Ht,0,yt),_e=we(Ht,0,yt),ot=m(Yt),_r=0,a=m(Yt),Ot){o:{l:switch(Pe-1|0){case 0:a=h;break o;case 1:break l;default:break o}a=m(m(yt*h)*m(.009999999776482582))}l[O+356>>2]=1,a=m(Mt+a),I[O+24>>2]=a,_r=1}if(ne=m(ne+_e),u){h=m(Yt);o:{l:switch(ri-1|0){case 0:h=Z;break o;case 1:break l;default:break o}h=m(m(Ve*Z)*m(.009999999776482582))}l[O+352>>2]=1,ot=m(ne+h),I[O+360>>2]=ot,Pi=1}Pe=(hs&3145728)==2097152,ri=pt>>>0<2;o:{l:{c:{if(!(Pe&ri)){if(Pe|Ns)break l;if(a!=a)break c;break l}if(Ns|a==a)break o}_r=2,l[O+356>>2]=2,I[O+24>>2]=yt,a=yt}l:{if(!Pe||ri){if(Pe|Ve!=Ve)break o;if(ot!=ot)break l;break o}if(ot==ot|Ve!=Ve)break o}Pi=2,l[O+352>>2]=2,I[O+360>>2]=Ve,ot=Ve}h=I[Ht+224>>2],Pe=h!=h;o:{if(Pe)break o;l:{if(!(Rr|(_r|0)!=1)){l[O+352>>2]=1,I[O+360>>2]=ne+m(m(a-Mt)/h);break l}if(ri|(Pi|0)!=1)break o;l[O+356>>2]=1,I[O+24>>2]=m(m(ot-ne)*h)+Mt}Pi=1,_r=1}at=at>>>13&7,at=at||hs>>>10&7;o:{if((at|0)==5|(_r|0)==1|(Rr|(Ot|Kr))|(at|0)!=4||(l[O+356>>2]=1,I[O+24>>2]=yt,Pe))break o;Pi=1,l[O+352>>2]=1,I[O+360>>2]=m(yt-Mt)/h}o:{if(ri|(A|0)!=1|Ve!=Ve|u|(at|0)!=4|(Pi|0)==1||(l[O+352>>2]=1,I[O+360>>2]=Ve,Pe))break o;l[O+356>>2]=1,I[O+24>>2]=m(Ve-ne)*h}if(Un(Ht,2,yt,yt,O+356|0,O+24|0),Un(Ht,0,Ve,yt,O+352|0,O+360|0),un(Ht,I[O+24>>2],I[O+360>>2],Bi,l[O+356>>2],l[O+352>>2],yt,Ve,0,5,K,tt,dt,q),a=I[(Ht+(l[(pt<<2)+4320>>2]<<2)|0)+516>>2],u=a!=a,h=m(m(Ie(Ht,pt,yt)+fe(Ht,pt))+m(xe(Ht,pt,yt)+Se(Ht,pt))),!(u|h!=h)){h=ce(a,h);break a}h=u?h:a}I[Ht+308>>2]=h}l[Ht+304>>2]=q}W=m(W+m(h+m(de(Ht,_t,yt)+we(Ht,_t,yt))))}if(Y=Y+4|0,(jr|0)==(Y|0))break}break r}l[O>>2]=3072,sr(r,O),qi(),he()}l[O+16>>2]=3154,sr(r,O+16|0),qi(),he()}W=m(0)}a=m(W+m(0)),Ua=tr?S:k,Us=tr?k:S,ii>>>0>=5&&(a=m(m(Qo(r,_t,De)*m(Vr-1>>>0))+a)),u=a>pe,jr=Di&786432,cs=(Qi|0)==2&&jr&&u?1:Qi,Ht=tr?A:y,Rr=(Ht|0)==1,d2=Rr&(P^1),tr=_t>>>0<2,u2=Ht&-3,Ns=r+208|0,A=et<<2,ri=A+4288|0,f2=Rr&!jr,p2=(Ht|0)!=1|P,Y=_t<<2,_r=Y+4288|0,Fs=Y+4320|0,hs=De==De,g2=hs<<1,Pe=A+4320|0,m2=!Qi|!u,Fa=O+52|0,Uh=Qo(r,et,De),at=0,u=0,Pi=0;r:{for(;;){Qi=u,Ui(O+24|0,0,44),u=l[r+560>>2],A=l[r+556>>2];i:{if((u|0)==(A|0))break i;if(u=u-A|0,(u|0)<0)break r;if(Y=Na(O+360|0,u>>2,0,Fa),u=l[O+44>>2],A=l[O+48>>2]-u|0,A=Ps(l[O+364>>2]-A|0,u,A),u=l[O+44>>2],l[O+364>>2]=u,l[O+44>>2]=A,pt=l[O+368>>2],Ot=l[O+372>>2],A=l[O+48>>2],l[O+368>>2]=A,Zt=l[O+52>>2],l[O+48>>2]=pt,l[O+52>>2]=Ot,l[O+372>>2]=Zt,l[Y>>2]=u,(u|0)!=(A|0)&&(l[O+368>>2]=A+((u-A|0)+3&-4)),!u)break i;gi(u)}Zt=l[r+24>>2],u=Zt>>>2&3;i:{e:{if(A=Zt&3,((A||$h)|0)!=2)break e;pt=3;s:switch(u-2|0){case 0:break i;case 1:break s;default:break e}pt=2;break i}pt=u}W=Qo(r,pt,yt),Y=at,Ot=l[r+560>>2],A=l[r+556>>2];i:{if(Y>>>0>=Ot-A>>2>>>0)break i;for(Zt=Zt&786432,h=m(0);;){if(Ot-A>>2>>>0<=Y>>>0)break r;if(u=l[(Y<<2)+A>>2],ii=l[u+24>>2],!(ii&4194304|(ii&196608)==131072)){if(l[u+548>>2]=Qi,a=de(u,pt,yt),Z=we(u,pt,yt),A=l[O+24>>2],ot=(Y|0)==(at|0)?m(0):W,a=m(a+Z),Z=I[u+308>>2],Mt=He(u,pt,Z,Us),!(!A||!(m(ot+m(a+m(h+Mt)))>pe)|!Zt))break i;if(l[O+24>>2]=A+1,ot=m(ot+m(a+Mt)),I[O+28>>2]=ot+I[O+28>>2],Up(u)){e:{if(!l[u+552>>2]){a=m(0);break e}if(a=I[u+32>>2],a==a)break e;a=I[u+28>>2],a=a>m(0)?a:m(0)}I[O+32>>2]=a+I[O+32>>2],We=O,je=m(I[O+36>>2]-m(Hn(u)*Z)),I[We+36>>2]=je}A=l[O+48>>2];e:{if((A|0)!=l[O+52>>2]){l[A>>2]=u,l[O+48>>2]=A+4;break e}if(A=A-l[O+44>>2]|0,ii=A>>2,Ot=ii+1|0,Ot>>>0>=1073741824)break r;if(Di=A>>1,Ot=Na(O+360|0,A>>>0>=2147483644?1073741823:Ot>>>0<Di>>>0?Di:Ot,ii,Fa),l[l[O+368>>2]>>2]=u,l[O+368>>2]=l[O+368>>2]+4,u=l[O+44>>2],A=l[O+48>>2]-u|0,A=Ps(l[O+364>>2]-A|0,u,A),u=l[O+44>>2],l[O+364>>2]=u,l[O+44>>2]=A,ii=l[O+368>>2],Di=l[O+372>>2],A=l[O+48>>2],l[O+368>>2]=A,Kr=l[O+52>>2],l[O+48>>2]=ii,l[O+52>>2]=Di,l[O+372>>2]=Kr,l[Ot>>2]=u,(u|0)!=(A|0)&&(l[O+368>>2]=A+((u-A|0)+3&-4)),!u)break e;gi(u)}A=l[r+556>>2],Ot=l[r+560>>2],h=m(h+ot)}if(Y=Y+1|0,!(Y>>>0<Ot-A>>2>>>0))break}}_e=I[O+32>>2],!(_e>m(0))|!(_e<m(1))||(l[O+32>>2]=1065353216,_e=m(1)),vi=I[O+36>>2],!(vi>m(0))|!(vi<m(1))||(l[O+36>>2]=1065353216,vi=m(1)),l[O+40>>2]=Y,Mt=I[O+28>>2],pt=l[O+24>>2],Pi&&gi(Pi),Z=I[O+56>>2],ii=l[O+48>>2],Pi=l[O+44>>2];i:{e:{s:{n:{if((cs|0)==1)break n;h=m(0),a=I[Ns>>2];a:{o:{u=l[Ns>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(a==a)break c;A=4344}switch(h=I[A>>2],a=m(Yt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}a=m(m(h*k)*m(.009999999776482582));break a}a=h}h=m(0),W=I[r+216>>2];a:{o:{u=l[r+216>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(W==W)break c;A=4344}switch(h=I[A>>2],W=m(Yt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}W=m(m(h*k)*m(.009999999776482582));break a}W=h}h=m(0),ot=I[r+212>>2];a:{o:{u=l[r+212>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(ot==ot)break c;A=4344}switch(h=I[A>>2],ot=m(Yt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}ot=m(m(h*S)*m(.009999999776482582));break a}ot=h}h=m(0),ne=I[r+220>>2];a:{o:{u=l[r+220>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(ne==ne)break c;A=4344}switch(h=I[A>>2],ne=m(Yt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}ne=m(m(h*S)*m(.009999999776482582));break a}ne=h}if(u=_t>>>0>1,h=m((u?a:ot)-Wr),h==h&h>Mt||(h=m((u?W:ne)-Wr),h==h&h<Mt))break s;if(ft[l[r+568>>2]+16|0]&1)break n;if(h=Mt,!l[r+552>>2]|_e==m(0))break e;a=I[r+32>>2];a:{o:{if(a==a){h=a;break o}if(h=I[r+28>>2],!(h>m(0)))break a}if(h!=h){h=pe;break e}a=I[r+32>>2]}if(a!=a&&(h=Mt,a=I[r+28>>2],!(a>m(0)))||(h=pe,a!=m(0)))break e;h=Mt;break e}h=pe}if(h!=h)break e;Z=m(h-Mt);break i}if(!(Mt<m(0)))break i;Z=m(-Mt)}if(pe=h,!d2){i:{if((ii|0)==(Pi|0)){ot=m(0);break i}for(ne=m(0),A=Pi;;){u=l[A>>2],Mt=I[u+308>>2],h=He(u,_t,Mt,Us);e:{if(Z<m(0)){if(a=m(h*m(-Hn(u))),!(a>m(0)|a<m(0)))break e;W=m(m(m(Z/vi)*a)+h),a=He(u,_t,W,pe),Ot=a!=a,ot=m(m(Ie(u,_t,yt)+fe(u,_t))+m(xe(u,_t,yt)+Se(u,_t)));s:{if(!(Ot|ot!=ot)){a=ce(a,ot);break s}a=Ot?ot:a}if(W!=W|a!=a|a==W)break e;ne=m(ne+m(a-h)),vi=m(m(Hn(u)*Mt)+vi);break e}if(!(Z>m(0))|!l[u+552>>2]||(W=I[u+32>>2],W!=W&&(W=I[u+28>>2],!(W>m(0))))||!(W<m(0)|W>m(0)))break e;ot=m(m(m(Z/_e)*W)+h),a=He(u,_t,ot,pe),Ot=a!=a,Mt=m(m(Ie(u,_t,yt)+fe(u,_t))+m(xe(u,_t,yt)+Se(u,_t)));s:{if(!(Ot|Mt!=Mt)){a=ce(a,Mt);break s}a=Ot?Mt:a}if(ot!=ot|a!=a|a==ot)break e;_e=m(_e-W),ne=m(ne+m(a-h))}if(A=A+4|0,(ii|0)==(A|0))break}for(ne=m(Z-ne),Ba=m(ne/vi),Ga=m(ne/_e),Ha=Rr&(m2|!(At[r+26|0]&12)),Kr=!Ha,Di=l[Pe>>2],ot=m(0),Ot=Pi;;){u=l[Ot>>2],Mt=He(u,_t,I[u+308>>2],Us);e:{s:{if(ne<m(0)){if(W=Mt,a=m(W*m(-Hn(u))),a==m(0))break e;a=vi==m(0)?m(Mt+a):m(m(Ba*a)+Mt);break s}if(W=Mt,!(ne>m(0))|!l[u+552>>2]||(a=I[u+32>>2],a!=a&&(a=I[u+28>>2],!(a>m(0))))||!(a<m(0)|a>m(0)))break e;a=m(m(Ga*a)+Mt)}if(a=He(u,_t,a,pe),A=a!=a,h=m(m(Ie(u,_t,yt)+fe(u,_t))+m(xe(u,_t,yt)+Se(u,_t))),!(A|h!=h)){W=ce(a,h);break e}W=A?h:a}a=de(u,_t,yt),h=we(u,_t,yt),_e=de(u,et,yt),nl=we(u,et,yt),h=m(a+h),Bh=m(W+h),I[O+352>>2]=Bh,l[O+344>>2]=1,_e=m(_e+nl),a=I[u+224>>2];e:{if(a==a){l[O+348>>2]=1,h=m(Bh-h),I[O+356>>2]=_e+m(tr?h*a:h/a);break e}s:{if(Bs=De!=De,Bs)break s;Zt=(Di<<3)+u|0,a=I[Zt+572>>2];n:{a:{o:{l:switch(A=l[Zt+576>>2],A|0){case 0:case 3:break o;default:break l}if(h=I[Zt+572>>2],(A|0)!=1|h!=h)break a;if(!(Kr|!(a<m(0))))break n;break s}if(!Ha)break s;break n}if(Kr|(!(a<m(0))|((A|0)!=2|h!=h)))break s}if(A=l[u+24>>2]>>>13&7,A||(A=l[r+24>>2]>>>10&7),(A|0)!=4||(pn(O+24|0,u,et),l[O+28>>2]==3)||(fn(O+360|0,u,et),l[O+364>>2]==3))break s;l[O+348>>2]=1,I[O+356>>2]=De;break e}Zt=(Di<<3)+u|0,h=I[Zt+572>>2];s:{n:{a:{o:{l:switch(A=l[Zt+576>>2],A|0){case 0:case 3:break o;default:break l}if(a=I[Zt+572>>2],!((A|0)!=1|a!=a)){if(a=h,a<m(0))break o;break s}if((A|0)!=2|a!=a)break a;if(Bs)break o;if(!(h<m(0)))break n}l[O+348>>2]=g2,I[O+356>>2]=De;break e}a=m(Yt);a:switch(A-1|0){case 1:break n;case 0:break a;default:break s}a=h;break s}a=m(m(De*h)*m(.009999999776482582))}a=m(_e+a),I[O+356>>2]=a,l[O+348>>2]=(Rr|(A|0)!=2)&a==a}Un(u,_t,pe,yt,O+344|0,O+352|0),Un(u,et,De,yt,O+348|0,O+356|0),Zt=(Di<<3)+u|0,a=I[Zt+572>>2];e:{s:{n:{a:switch(A=l[Zt+576>>2],A|0){case 0:case 3:break n;default:break a}if(h=I[Zt+572>>2],!((A|0)!=1|h!=h)){if(a<m(0))break n;break s}if((A|0)!=2|h!=h)break s;if(a<m(0))break n;if(Zt=0,hs)break e}if(Zt=0,A=l[u+24>>2]>>>13&7,A||(A=l[r+24>>2]>>>10&7),(A|0)!=4||(pn(O+24|0,u,et),l[O+28>>2]==3))break e;fn(O+360|0,u,et),Zt=l[O+364>>2]!=3;break e}Zt=0}a=I[O+352>>2],h=I[O+356>>2],A=_t>>>0>1,_e=A?a:h,a=A?h:a,Bs=l[O+344>>2],Gh=l[O+348>>2],v2=A?Bs:Gh,Bs=A?Gh:Bs,A=(Zt^1)&P,un(u,_e,a,At[r+300|0]&3,v2,Bs,yt,Ve,A,A?4:7,K,tt,dt,q),ot=m(ot+m(W-Mt)),A=At[r+300|0];e:{s:{if(A&4){Zt=A&251;break s}if(Zt=A&251,A=0,!(At[u+300|0]&4))break e}A=4}if(ft[r+300|0]=A|Zt,Ot=Ot+4|0,(ii|0)==(Ot|0))break}}Z=m(Z-ot)}u=At[r+300|0],ft[r+300|0]=u&251|(Z<m(0)?4:u&4),ne=m(Ie(r,_t,k)+fe(r,_t)),Ba=m(xe(r,_t,k)+Se(r,_t)),Mt=Qo(r,_t,k);i:{if(!(!(Z>m(0))|(cs|0)!=2)){ot=m(0),h=m(0);e:{s:{u=Ns+(l[Fs>>2]<<2)|0,a=I[u>>2],u=l[u>>2],A=(u|0)==2139156720;n:{if(!A){if(Ot=(u|0)==2140081935,Ot)break s;if(Zt=(u|0)==2141891242,Zt|a!=a)break i;if(Ot)break s;if(Zt)break i;if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break n}h=m(m(Us*h)*m(.009999999776482582))}if(h!=h)break i;h=m(0);n:{if(A)break n;if((u|0)==2140081935)break s;A=4336;a:{if((u|0)!=2141891242){if(a==a)break a;A=4344}switch(h=I[A>>2],W=m(Yt),l[A+4>>2]-1|0){case 0:break s;case 1:break n;default:break e}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break s}W=m(m(Us*h)*m(.009999999776482582));break e}W=h}if(a=m(m(m(W-ne)-Ba)-m(pe-Z)),a!=a)break i;ot=ce(a,m(0));break i}ot=Z}Zt=Y>>>0<=at>>>0;i:{if(!Zt){for(ii=l[r+556>>2],u=l[r+560>>2]-ii>>2,Di=u>>>0<at>>>0?at:u,Ot=0,u=at;;){if((u|0)==(Di|0))break r;if(A=l[ii+(u<<2)>>2],(l[A+24>>2]&196608)!=131072&&(Kr=O+24|0,pn(Kr,A,_t),Ha=l[O+28>>2],fn(Kr,A,_t),Ot=(((Ha|0)==3)+Ot|0)+(l[O+28>>2]==3)|0),u=u+1|0,(Y|0)==(u|0))break}if(_e=m(0),h=Mt,Ot)break i}_e=m(0),Ot=0,h=Mt;e:switch((l[r+24>>2]>>>4&7)-1|0){case 0:_e=m(ot*m(.5));break i;case 1:_e=ot;break i;case 2:if(pt>>>0<2)break i;h=m(Mt+m((je=m(0),Wn=ce(ot,m(0)),We=ot!=ot,(We?je:Wn)/m(pt-1>>>0))));break i;case 4:_e=m(ot/m(pt+1>>>0)),h=m(Mt+_e);break i;case 3:break e;default:break i}_e=m(m(ot*m(.5))/m(pt>>>0)),h=m(m(_e+_e)+Mt)}if(a=m(ne+_e),Z=m(0),ii=Dp(r),Zt)h=m(0);else{for(Di=Y-1|0,Ga=m(ot/m(Ot|0)),ne=m(0),W=m(0),u=at;;){if(A=l[r+556>>2],l[r+560>>2]-A>>2>>>0<=u>>>0)break r;A=l[A+(u<<2)>>2],pt=A+228|0,Fi(O+24|0,pt,320),h=m(h-((u|0)==(Di|0)?Mt:m(0))),Ot=l[A+24>>2];i:{if(Ot&4194304)break i;e:{if((Ot&196608)==131072){if(!nr(A,_t))break e;if(!P)break i;ot=Os(A,_t,pe),vi=fe(r,_t),nl=de(A,_t,yt),I[pt+(l[_r>>2]<<2)>>2]=nl+m(ot+vi);break i}if(pn(O+360|0,A,_t),a=m(a+(l[O+364>>2]==3?Ga:m(-0))),P&&(Ot=pt,pt=l[_r>>2]<<2,I[Ot+pt>>2]=a+I[pt+(O+24|0)>>2]),fn(O+360|0,A,_t),a=m(a+(l[O+364>>2]==3?Ga:m(-0))),!p2){a=m(a+m(m(h+m(de(A,_t,yt)+we(A,_t,yt)))+I[O+104>>2])),Z=De;break i}if(pt=A+516|0,a=m(a+m(h+m(I[pt+(l[Fs>>2]<<2)>>2]+m(de(A,_t,yt)+we(A,_t,yt))))),ii){ot=Jo(A),vi=de(A,0,yt),ot=m(ot+vi),vi=m(m(I[A+520>>2]+m(de(A,0,yt)+we(A,0,yt)))-ot),A=ne!=ne;s:{if(!(A|ot!=ot)){ne=ce(ne,ot);break s}ne=A?ot:ne}if(A=W!=W,!(A|vi!=vi)){W=ce(W,vi);break i}W=A?vi:W;break i}if(ot=m(I[pt+(l[Pe>>2]<<2)>>2]+m(de(A,et,yt)+we(A,et,yt))),A=Z!=Z,!(ot!=ot|A)){Z=ce(Z,ot);break i}Z=A?ot:Z;break i}if(!P)break i;A=l[_r>>2]<<2,ot=I[A+(O+24|0)>>2],We=A+pt|0,je=m(_e+m(ot+fe(r,_t))),I[We>>2]=je}if(u=u+1|0,(Y|0)==(u|0))break}h=m(W+ne)}if(Z=ii?h:Z,ot=De,!u2){h=He(r,et,m(Ji+Z),Ua),u=h!=h,W=m(m(Ie(r,et,k)+fe(r,et))+m(xe(r,et,k)+Se(r,et)));i:{if(!(u|W!=W)){h=ce(h,W);break i}h=u?W:h}ot=m(h-Ji)}h=He(r,et,m(Ji+(f2?De:Z)),Ua),u=h!=h,W=m(m(Ie(r,et,k)+fe(r,et))+m(xe(r,et,k)+Se(r,et)));i:{if(!(u|W!=W)){h=ce(h,W);break i}h=u?W:h}if(W=m(h-Ji),!(Zt|!P))for(;;){if(u=l[r+556>>2],l[r+560>>2]-u>>2>>>0<=at>>>0)break r;pt=l[u+(at<<2)>>2],u=l[pt+24>>2];i:{if(u&4194304)break i;if((u&196608)==131072){e:{if(!nr(pt,et)){A=l[ri>>2];break e}if(h=Os(pt,et,De),Z=fe(r,et),Mt=de(pt,et,yt),A=l[ri>>2],h=m(Mt+m(h+Z)),I[(pt+(A<<2)|0)+228>>2]=h,h==h)break i}We=pt+(A<<2)|0,je=m(fe(r,et)+de(pt,et,yt)),I[We+228>>2]=je;break i}A=u>>>13&7,A||(A=l[r+24>>2]>>>10&7);e:{s:{if((A|0)==5){A=l[r+24>>2]&8?5:1;break s}if((A|0)!=4||(pn(O+24|0,pt,et),A=4,l[O+28>>2]==3)||(fn(O+360|0,pt,et),l[O+364>>2]==3))break s;A=pt+(l[Pe>>2]<<3)|0,Z=I[A+572>>2];n:{a:switch(u=l[A+576>>2],u|0){case 0:case 3:break n;default:break a}if(Mt=I[A+572>>2],!((u|0)!=1|Mt!=Mt)){if(h=Ue,Z<m(0))break n;break e}if(h=Ue,hs&!(Z<m(0))|((u|0)!=2|Mt!=Mt))break e}Z=I[(pt+(l[Fs>>2]<<2)|0)+516>>2],h=W,Mt=I[pt+224>>2],Mt==Mt&&(h=m(m(de(pt,et,yt)+we(pt,et,yt))+m(tr?Z*Mt:Z/Mt))),I[O+360>>2]=h,We=O,je=m(Z+m(de(pt,_t,yt)+we(pt,_t,yt))),I[We+24>>2]=je,l[O+356>>2]=1,l[O+352>>2]=1,Un(pt,_t,pe,yt,O+356|0,O+24|0),Un(pt,et,De,yt,O+352|0,O+360|0),Z=I[O+360>>2],Mt=I[O+24>>2],u=_t>>>0>1,h=u?Z:Mt,Z=u?Mt:Z,u=(jr|0)!=0&(l[r+24>>2]&896)!=512,un(pt,Z,h,Bi,!(u&tr|Z!=Z),(!u|tr)&h==h,yt,Ve,1,2,K,tt,dt,q),h=Ue;break e}h=I[(pt+(l[Pe>>2]<<2)|0)+516>>2],Z=de(pt,et,yt),Mt=we(pt,et,yt),pn(O+24|0,pt,et),Z=m(ot-m(h+m(Z+Mt)));s:{if(l[O+28>>2]!=3||(fn(O+360|0,pt,et),l[O+364>>2]!=3))break s;h=m(Z*m(.5)),h=m(Ue+(je=m(0),Wn=ce(h,m(0)),We=h!=h,We?je:Wn));break e}if(fn(O+24|0,pt,et),h=Ue,l[O+28>>2]==3)break e;if(pn(O+24|0,pt,et),l[O+28>>2]==3){h=m(Ue+(je=m(0),Wn=ce(Z,m(0)),We=Z!=Z,We?je:Wn));break e}s:switch(A-1|0){case 1:h=m(Ue+m(Z*m(.5)));break e;case 0:break e;default:break s}h=m(Ue+Z)}u=pt+(l[ri>>2]<<2)|0,I[u+228>>2]=h+m(ds+I[u+228>>2])}if(at=at+1|0,(at|0)==(Y|0))break}h=m((Qi?Uh:m(0))+W),u=Gs!=Gs,a=m(Ba+a);i:{if(!(u|a!=a)){Gs=ce(Gs,a);break i}Gs=u?a:Gs}if(ds=m(ds+h),u=Qi+1|0,at=Y,!(Vr>>>0>Y>>>0))break}i:{if(!P||!jr&&!Dp(r))break i;ne=m(0);e:{s:{if(De!=De)break s;a=m(De-ds);n:switch((l[r+24>>2]>>>7&7)-2|0){case 0:Ue=m(Ue+m(a*m(.5)));break s;case 2:if(!(De>ds))break s;ne=m(a/m(u>>>0));break s;case 5:if(De>ds){if(Ue=m(Ue+m(a/m(u<<1>>>0))),u>>>0<2)break s;ne=m(a/m(u>>>0));break e}Ue=m(Ue+m(a*m(.5)));break s;case 4:if(!(De>ds)|u>>>0<2)break s;ne=m(a/m(Qi>>>0));break e;case 1:break n;default:break s}Ue=m(Ue+a)}if(!u)break i}for(Ot=0,u=0,A=0;;){if(Z=m(0),h=m(0),a=m(0),W=m(0),Y=u,Vr>>>0>u>>>0){e:{for(;;){if(A=l[r+556>>2],l[r+560>>2]-A>>2>>>0<=Y>>>0)break r;at=l[A+(Y<<2)>>2],pt=l[at+24>>2];s:{if(pt&4194304|(pt&196608)==131072)break s;if(A=Y,l[at+548>>2]!=(Ot|0))break e;a=I[(at+(l[Pe>>2]<<2)|0)+516>>2];n:{if(!(a>=m(0)))break n;if(A=h!=h,a=m(a+m(de(at,et,yt)+we(at,et,yt))),!(A|a!=a)){h=ce(h,a);break n}h=A?a:h}if(A=pt>>>13&7,A||(A=l[r+24>>2]>>>10&7),!(At[r+24|0]&8)|(A|0)!=5)break s;a=Jo(at),ot=de(at,0,yt),a=m(a+ot),ot=m(m(I[at+520>>2]+m(de(at,0,yt)+we(at,0,yt)))-a),A=h!=h,at=W!=W;n:{if(!(at|a!=a)){W=ce(W,a);break n}W=at?a:W}at=Z!=Z;n:{if(!(at|ot!=ot)){Z=ce(Z,ot);break n}Z=at?ot:Z}if(a=m(W+Z),!(A|a!=a)){h=ce(h,a);break s}h=A?a:h}if(Y=Y+1|0,(Vr|0)==(Y|0))break}A=Vr}a=h}if(ot=m(Ue+(Ot?Uh:m(0))),h=m(ne+a),Ue=m(ot+h),u>>>0<A>>>0)for(Mt=m(ot+W);;){if(Y=l[r+556>>2],l[r+560>>2]-Y>>2>>>0<=u>>>0)break r;at=l[Y+(u<<2)>>2],Y=l[at+24>>2];e:{if(Y&4194304|(Y&196608)==131072)break e;Y=Y>>>13&7,Y||(Y=l[r+24>>2]>>>10&7);s:{n:switch(Y-1|0){case 4:if(At[r+24|0]&8)break s;case 0:a=de(at,et,yt),I[(at+(l[ri>>2]<<2)|0)+228>>2]=ot+a;break e;case 2:a=we(at,et,yt),Y=at+228|0,I[Y+(l[ri>>2]<<2)>>2]=m(Ue-a)-I[(Y+(l[Pe>>2]<<2)|0)+288>>2];break e;case 1:Y=at+228|0,I[Y+(l[ri>>2]<<2)>>2]=ot+m(m(h-I[(Y+(l[Pe>>2]<<2)|0)+288>>2])*m(.5));break e;case 3:break n;default:break e}a=de(at,et,yt),I[(at+(l[ri>>2]<<2)|0)+228>>2]=ot+a,pt=at+(l[Pe>>2]<<3)|0,a=I[pt+572>>2];n:{a:switch(Y=l[pt+576>>2],Y|0){case 0:case 3:break n;default:break a}if(W=I[pt+572>>2],!((Y|0)!=1|W!=W)){if(a<m(0))break n;break e}if(hs&!(a<m(0))|((Y|0)!=2|W!=W))break e}n:{if(_t>>>0>=2){Z=h,a=I[at+516>>2],W=m(a+m(de(at,_t,yt)+we(at,_t,yt)));break n}Z=m(I[at+520>>2]+m(de(at,et,yt)+we(at,et,yt))),a=I[at+516>>2],W=h}n:{a:{if(!(W!=W|a!=a)){if(m(Ge(m(W-a)))<m(9999999747378752e-20))break a;break n}if(W==W|a==a)break n}if(a=I[at+520>>2],Y=a!=a,!(Y|Z!=Z)){if(!(m(Ge(m(Z-a)))<m(9999999747378752e-20)))break n;break e}if(Z==Z)break n;if(Y)break e}un(at,W,Z,Bi,1,1,yt,Ve,1,3,K,tt,dt,q);break e}We=at,je=m(m(Mt-Jo(at))+Os(at,0,De)),I[We+232>>2]=je}if(u=u+1|0,(A|0)==(u|0))break}if(Y=(Ot|0)!=(Qi|0),Ot=Ot+1|0,u=A,!Y)break}}pt=r+516|0,a=He(r,2,Nh,k),u=a!=a,h=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));i:{if(!(u|h!=h)){a=ce(a,h);break i}a=u?h:a}I[pt>>2]=a,a=He(r,0,Fh,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));i:{if(!(u|h!=h)){a=ce(a,h);break i}a=u?h:a}I[r+520>>2]=a;i:{e:{s:{if(cs&&(u=l[r+24>>2]>>>20&3,(u|0)==2|(cs|0)!=2))break s;if(a=He(r,_t,Gs,Us),u=a!=a,h=m(m(Ie(r,_t,k)+fe(r,_t))+m(xe(r,_t,k)+Se(r,_t))),!(u|h!=h)){a=ce(a,h);break e}a=u?h:a;break e}if((cs|0)!=2|(u|0)!=2)break i;h=m(Wr+pe),u=h!=h,a=He(r,_t,Gs,Us);s:{if(!(u|a!=a)){a=Ih(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Wr!=Wr)){a=ce(a,Wr);break e}a=u?Wr:a}I[pt+(l[Fs>>2]<<2)>>2]=a}i:{e:{s:{if(Ht&&(A=(Ht|0)!=2,u=l[r+24>>2]>>>20&3,A|(u|0)==2))break s;if(a=He(r,et,m(Ji+ds),Ua),u=a!=a,h=m(m(Ie(r,et,k)+fe(r,et))+m(xe(r,et,k)+Se(r,et))),!(u|h!=h)){a=ce(a,h);break e}a=u?h:a;break e}if(A|(u|0)!=2)break i;h=m(Ji+De),u=h!=h,a=He(r,et,m(Ji+ds),Ua);s:{if(!(u|a!=a)){a=Ih(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Ji!=Ji)){a=ce(a,Ji);break e}a=u?Ji:a}I[pt+(l[Pe>>2]<<2)>>2]=a}i:{if(!P)break i;if((l[r+24>>2]&786432)==524288)for(A=Vr>>>0<=1?1:Vr,P=l[r+556>>2],at=l[r+560>>2]-P>>2,u=0;Y=0,Y=u>>>0<at>>>0?l[P+(u<<2)>>2]:Y,(l[Y+24>>2]&196608)!=131072&&(Y=Y+228|0,Ot=Y+(l[ri>>2]<<2)|0,Zt=l[Pe>>2]<<2,I[Ot>>2]=m(I[Zt+pt>>2]-I[Ot>>2])-I[(Y+Zt|0)+288>>2]),u=u+1|0,(A|0)!=(u|0););if(A=l[r+556>>2],P=l[r+560>>2],(A|0)!=(P|0))for(Ot=((_t>>>0>1?cs:y)|0)!=0;;){y=l[A>>2];e:{if((l[y+24>>2]&4390912)!=131072)break e;W=yt,pe=Ve,At[l[r+568>>2]+12|0]&2&&(pe=I[r+520>>2],W=I[r+516>>2]),u=l[r+24>>2]>>>2&3;s:{n:{if((Bi|0)==2){at=0,Y=3;a:switch(u-2|0){case 0:break s;case 1:break a;default:break n}Y=2;break s}if(at=0,u>>>0<=1)break n;Y=u;break s}Y=u,at=$s}S=m(de(y,2,W)+we(y,2,W)),k=de(y,0,W),Z=we(y,0,W),a=I[y+572>>2];s:{n:{a:switch(u=l[y+576>>2],u|0){case 0:case 3:break n;default:break a}h=I[y+572>>2];a:{if(!((u|0)!=1|h!=h)){if(h=a,!(a<m(0)))break a;break n}o:{if(!((u|0)!=2|h!=h)){if(W!=W|a<m(0))break n;break o}h=m(Yt);l:switch(u-1|0){case 1:break o;case 0:break l;default:break a}h=a;break a}h=m(m(W*a)*m(.009999999776482582))}h=m(S+h);break s}if(h=m(Yt),!nr(y,2)||!il(y,2))break s;if(a=He(y,2,m(m(I[r+516>>2]-m(fe(r,2)+Se(r,2)))-m(Os(y,2,W)+$a(y,2,W))),W),u=a!=a,h=m(m(Ie(y,2,W)+fe(y,2))+m(xe(y,2,W)+Se(y,2))),!(u|h!=h)){h=ce(a,h);break s}h=u?h:a}Z=m(k+Z);s:{n:{a:{o:{l:{c:{h:{Zt=h!=h,k=I[y+580>>2];f:{d:{p:switch(u=l[y+584>>2],u|0){case 0:case 3:break d;default:break p}a=I[y+580>>2];p:{if(!((u|0)!=1|a!=a)){if(a=k,!(a<m(0)))break p;break d}v:{if(!((u|0)!=2|a!=a)){if(pe!=pe|k<m(0))break d;break v}a=m(Yt);y:switch(u-1|0){case 1:break v;case 0:break y;default:break p}a=k;break p}a=m(m(pe*k)*m(.009999999776482582))}a=m(Z+a);break f}d:{if(nr(y,0)&&il(y,0))break d;if(a=m(Yt),h==h)break h;break a}if(a=He(y,0,m(m(I[r+520>>2]-m(fe(r,0)+Se(r,0)))-m(Os(y,0,pe)+$a(y,0,pe))),pe),u=a!=a,k=m(m(Ie(y,0,W)+fe(y,0))+m(xe(y,0,W)+Se(y,0))),!(u|k!=k)){a=ce(a,k);break f}a=u?k:a}if((Zt|0)==(a!=a|0)||(ot=I[y+224>>2],ot!=ot))break l;if(h!=h){h=m(m(m(a-Z)*ot)+S);break l}if(a==a)break l;break c}if(ot=I[y+224>>2],ot!=ot)break o}a=m(Z+m(m(h-S)/ot))}if(h!=h)break a;if(a==a)break s}u=0;break n}u=1}Zt=W>m(0),Qi=u&Ot&Y>>>0<2,h=Qi&&Zt?W:h,u=u^1,un(y,h,a,Bi,Qi&&Zt?2:u,a==a,h,a,0,6,K,tt,dt,q),h=m(I[y+516>>2]+e2(y,2,W)),a=m(I[y+520>>2]+e2(y,0,W))}un(y,h,a,Bi,1,1,h,a,1,1,K,tt,dt,q);s:{n:{a:{if(!il(y,Y)||nr(y,Y))break a;u=l[(Y<<2)+4320>>2]<<2,a=Y>>>0<2?pe:W,a=m(m(m(m(I[u+pt>>2]-I[(u+y|0)+516>>2])-Se(r,Y))-we(y,Y,a))-$a(y,Y,a));break n}if(!(nr(y,Y)|(l[r+24>>2]&112)!=16)){u=l[(Y<<2)+4320>>2]<<2,a=m(m(I[u+pt>>2]-I[(u+y|0)+516>>2])*m(.5));break n}if(!(nr(y,Y)|(l[r+24>>2]&112)!=32)){u=l[(Y<<2)+4320>>2]<<2,a=m(I[u+pt>>2]-I[(u+y|0)+516>>2]);break n}if(!(At[l[r+568>>2]+12|0]&2)||!nr(y,Y))break s;a=I[pt+(l[(Y<<2)+4320>>2]<<2)>>2],a=m(m(Os(y,Y,a)+fe(r,Y))+de(y,Y,a))}I[(y+(l[(Y<<2)+4288>>2]<<2)|0)+228>>2]=a}s:{n:{if(!il(y,at)||nr(y,at))break n;u=l[(at<<2)+4320>>2]<<2,a=Y>>>0<2?W:pe,a=m(m(m(m(I[u+pt>>2]-I[(u+y|0)+516>>2])-Se(r,at))-we(y,at,a))-$a(y,at,a));break s}n:{if(nr(y,at)||(u=l[y+24>>2]>>>13&7,u||(u=l[r+24>>2]>>>10&7),(u|0)!=2))break n;u=l[(at<<2)+4320>>2]<<2,a=m(m(I[u+pt>>2]-I[(u+y|0)+516>>2])*m(.5));break s}n:{if(nr(y,at))break n;Y=l[y+24>>2]>>>13&7,u=l[r+24>>2],Y=Y||u>>>10&7;a:{if((Y|0)==5){if((u&786432)==524288)break a;break n}if(((Y|0)==3|0)==((u&786432)==524288|0))break n}u=l[(at<<2)+4320>>2]<<2,a=m(I[u+pt>>2]-I[(u+y|0)+516>>2]);break s}if(!(At[l[r+568>>2]+12|0]&2)||!nr(y,at))break e;a=I[pt+(l[(at<<2)+4320>>2]<<2)>>2],a=m(m(Os(y,at,a)+fe(r,at))+de(y,at,a))}I[(y+(l[(at<<2)+4288>>2]<<2)|0)+228>>2]=a}if(A=A+4|0,(P|0)==(A|0))break}if(!((et|_t)&1))break i;for(A=et&1,P=_t&1,K=Vr>>>0<=1?1:Vr,tt=(et<<2)+4304|0,dt=(_t<<2)+4304|0,q=l[r+556>>2],et=l[r+560>>2]-q>>2,r=0;;){if((r|0)==(et|0))break r;u=l[q+(r<<2)>>2];e:{if(At[u+26|0]&64||(P&&(y=u+228|0,Y=l[Fs>>2]<<2,I[y+(l[dt>>2]<<2)>>2]=m(I[Y+pt>>2]-I[(y+Y|0)+288>>2])-I[y+(l[_r>>2]<<2)>>2]),!A))break e;u=u+228|0,y=l[Pe>>2]<<2,I[u+(l[tt>>2]<<2)>>2]=m(I[y+pt>>2]-I[(u+y|0)+288>>2])-I[u+(l[ri>>2]<<2)>>2]}if(r=r+1|0,(K|0)==(r|0))break}}if(!Pi)break t;gi(Pi);break t}Ds(),he()}Et=O+384|0}function mp(){var r=0,a=0;Fn(7032,7033,7034,0,4352,17,4355,0,4355,0,2529,4357,18),r=ht(8),l[r>>2]=8,l[r+4>>2]=1,wt(7032,2922,6,4368,4392,19,r|0,1),Fn(7036,7037,7038,7032,4352,20,4352,21,4352,22,2001,4357,23),r=ht(4),l[r>>2]=24,wt(7036,2359,2,4400,4408,25,r|0,0),os(7032,1398,2,4412,4420,26,27),os(7032,3027,3,4500,4512,28,29),Fn(7056,7057,7058,0,4352,30,4355,0,4355,0,2545,4357,31),r=ht(8),l[r>>2]=8,l[r+4>>2]=1,wt(7056,3293,2,4520,4408,32,r|0,1),Fn(7059,7060,7061,7056,4352,33,4352,34,4352,35,2024,4357,36),r=ht(4),l[r>>2]=37,wt(7059,2359,2,4528,4408,38,r|0,0),os(7056,1398,2,4536,4420,39,40),os(7056,3027,3,4500,4512,28,41),Fn(7062,7063,7064,0,4352,42,4355,0,4355,0,2861,4357,43),fp(7062,1,4584,4352,44,45),os(7062,2915,1,4584,4352,44,45),os(7062,1129,2,4588,4408,46,47),r=ht(8),l[r+4>>2]=0,l[r>>2]=48,wt(7062,3234,4,4608,4624,49,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=50,wt(7062,1981,3,4632,4644,51,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=52,wt(7062,1952,3,4652,4664,53,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=54,wt(7062,3389,3,4672,4664,55,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=56,wt(7062,1800,3,4652,4664,53,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=57,wt(7062,3264,3,4684,4512,58,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=59,wt(7062,1926,2,4696,4420,60,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=61,wt(7062,3399,2,4704,4420,62,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=63,wt(7062,1785,2,4696,4420,60,r|0,0),Eh(7065,1271,4712,64,4357,65),Vn(1732,0),Vn(1612,8),Vn(2145,16),Vn(2455,24),Vn(2561,32),Vn(1618,40),Ah(7065),Eh(7035,2898,4712,66,4357,67),Kp(2561,0),Kp(1618,8),Ah(7035),Eh(7066,2909,4712,68,4357,69),r=ht(4),l[r>>2]=8,a=ht(4),l[a>>2]=8,qo(7066,2903,7098,4714,70,r|0,7098,4718,71,a|0),r=ht(4),l[r>>2]=0,a=ht(4),l[a>>2]=0,qo(7066,1607,7091,4420,72,r|0,7091,4664,73,a|0),Ah(7066),Fn(7067,7068,7069,0,4352,74,4355,0,4355,0,3022,4357,75),fp(7067,1,4724,4352,76,77),os(7067,1593,1,4724,4352,76,77),os(7067,2851,2,4728,4420,78,79),os(7067,1129,2,4736,4408,80,81),r=ht(8),l[r+4>>2]=0,l[r>>2]=82,wt(7067,1753,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=84,wt(7067,3005,3,4744,4664,85,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=86,wt(7067,2930,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=88,wt(7067,2335,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=90,wt(7067,1485,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=91,wt(7067,1356,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=92,wt(7067,1818,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=93,wt(7067,2872,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=94,wt(7067,2379,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=95,wt(7067,2164,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=96,wt(7067,1320,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=97,wt(7067,2413,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=98,wt(7067,1504,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=99,wt(7067,2236,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=100,wt(7067,1220,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=101,wt(7067,1137,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=102,wt(7067,1159,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=104,wt(7067,1846,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=105,wt(7067,1465,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=106,wt(7067,2219,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=107,wt(7067,1196,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=108,wt(7067,2501,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=109,wt(7067,2591,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=110,wt(7067,1540,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=111,wt(7067,2250,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=112,wt(7067,1651,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=113,wt(7067,1428,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=114,wt(7067,2205,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=115,wt(7067,2609,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=116,wt(7067,1556,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=117,wt(7067,1671,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=118,wt(7067,1445,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=119,wt(7067,2567,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=120,wt(7067,1521,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=121,wt(7067,1625,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=122,wt(7067,1408,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=123,wt(7067,2305,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=124,wt(7067,2093,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=125,wt(7067,2719,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=126,wt(7067,1575,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=127,wt(7067,2188,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=128,wt(7067,2946,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=130,wt(7067,2347,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=132,wt(7067,1372,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=133,wt(7067,1832,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=134,wt(7067,2885,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=135,wt(7067,2396,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=136,wt(7067,2176,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=137,wt(7067,1338,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=138,wt(7067,2423,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=139,wt(7067,1859,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=141,wt(7067,1208,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=143,wt(7067,2515,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=144,wt(7067,2600,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=145,wt(7067,1661,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=146,wt(7067,2621,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=147,wt(7067,1684,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=148,wt(7067,2579,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=149,wt(7067,1638,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=150,wt(7067,2320,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=151,wt(7067,2103,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=153,wt(7067,1232,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=154,wt(7067,1148,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=155,wt(7067,2730,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=156,wt(7067,2195,3,4860,4872,157,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=158,wt(7067,3034,4,4880,4624,159,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=160,wt(7067,3055,3,4896,4664,161,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=162,wt(7067,1293,2,4908,4420,163,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=164,wt(7067,1388,2,4916,4420,165,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=166,wt(7067,3046,3,4924,4512,167,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=168,wt(7067,2962,2,4936,4420,169,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=170,wt(7067,2982,3,4944,4664,171,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=172,wt(7067,3357,3,4956,4664,173,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=174,wt(7067,3355,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=175,wt(7067,3374,3,4968,4664,176,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=177,wt(7067,3372,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=178,wt(7067,1119,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=179,wt(7067,1111,2,4980,4420,180,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=181,wt(7067,1244,5,4992,5012,182,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=183,wt(7067,1737,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=184,wt(7067,1715,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=185,wt(7067,2149,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=186,wt(7067,2462,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=187,wt(7067,2633,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=188,wt(7067,1697,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=189,wt(7067,1260,2,5020,4420,190,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=191,wt(7067,2433,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=192,wt(7067,2113,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=193,wt(7067,2741,3,4840,4852,152,r|0,0)}function CE(r,a,h,u,y,A){r=r|0,a=+a,h=h|0,u=u|0,y=y|0,A=A|0;var k=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,O=0,W=0,Y=0,Z=0,at=0,ot=0,pt=0,yt=0,_t=0,Ot=0,Mt=0;q=Et-560|0,Et=q,l[q+44>>2]=0,pi(+a),k=te(1)|0,te(0)|0;t:{if((k|0)<0){at=1,Ot=1177,a=-a,pi(+a),k=te(1)|0,te(0)|0;break t}if(y&2048){at=1,Ot=1180;break t}at=y&1,Ot=at?1183:1178,Mt=!at}t:{if((k&2146435072)==2146435072){k=at+3|0,mi(r,32,h,k,y&-65537),hi(r,Ot,at),u=A&32,hi(r,a!=a?u?2451:3459:u?2868:3463,3),mi(r,32,h,k,y^8192),et=(h|0)<(k|0)?k:h;break t}pt=q+16|0;r:{i:{e:{if(a=Mp(a,q+44|0),a=a+a,a!=0){if(k=l[q+44>>2],l[q+44>>2]=k-1,yt=A|32,(yt|0)!=97)break e;break r}if(yt=A|32,(yt|0)==97)break r;tt=l[q+44>>2],dt=(u|0)<0?6:u;break i}tt=k-29|0,l[q+44>>2]=tt,a=a*268435456,dt=(u|0)<0?6:u}for(Y=(q+48|0)+((tt|0)>=0?288:0)|0,S=Y;a<4294967296&a>=0?u=~~a>>>0:u=0,l[S>>2]=u,S=S+4|0,a=(a-+(u>>>0))*1e9,a!=0;);i:{if((tt|0)<=0){u=tt,k=S,P=Y;break i}for(P=Y,u=tt;;){O=(u|0)>=29?29:u,k=S-4|0;e:{if(P>>>0>k>>>0)break e;for(u=0;K=l[k>>2],_t=u,u=O&31,(O&63)>>>0>=32?(et=K<<u,u=0):(et=(1<<u)-1&K>>>32-u,u=K<<u),_t=_t+u|0,K=et+W|0,u=Tp(_t,u>>>0>_t>>>0?K+1|0:K,1e9),K=Ch(u,Ni,-1e9,0)+_t|0,l[k>>2]=K,k=k-4|0,P>>>0<=k>>>0;);if(!u)break e;P=P-4|0,l[P>>2]=u}for(;k=S,P>>>0<k>>>0&&(S=k-4|0,!l[S>>2]););if(u=l[q+44>>2]-O|0,l[q+44>>2]=u,S=k,!((u|0)>0))break}}if((u|0)<0)for(ot=((dt+25>>>0)/9|0)+1|0,W=(yt|0)==102;;){u=0-u|0,et=(u|0)>=9?9:u;i:{if(k>>>0<=P>>>0){S=l[P>>2];break i}for(O=1e9>>>et|0,K=-1<<et^-1,u=0,S=P;_t=u,u=l[S>>2],l[S>>2]=_t+(u>>>et|0),u=Fe(O,u&K),S=S+4|0,S>>>0<k>>>0;);if(S=l[P>>2],!u)break i;l[k>>2]=u,k=k+4|0}if(u=et+l[q+44>>2]|0,l[q+44>>2]=u,P=(!S<<2)+P|0,S=W?Y:P,k=k-S>>2>(ot|0)?S+(ot<<2)|0:k,!((u|0)<0))break}u=0;i:{if(k>>>0<=P>>>0||(u=Fe(Y-P>>2,9),S=10,K=l[P>>2],K>>>0<10))break i;for(;u=u+1|0,S=Fe(S,10),K>>>0>=S>>>0;);}if(S=(dt-((yt|0)!=102?u:0)|0)-((yt|0)==103&(dt|0)!=0)|0,(S|0)<(Fe(k-Y>>2,9)-9|0)){if(O=S+9216|0,K=(O|0)/9|0,tt=((((tt|0)<0?4:292)+q|0)+(K<<2)|0)-4048|0,S=10,et=O+Fe(K,-9)|0,(et|0)<=7)for(;S=Fe(S,10),et=et+1|0,(et|0)!=8;);O=l[tt>>2],ot=(O>>>0)/(S>>>0)|0,W=Fe(ot,S),K=tt+4|0;i:{if((O|0)==(W|0)&(K|0)==(k|0))break i;O=O-W|0;e:{if(!(ot&1)&&(a=9007199254740992,!(ft[tt-4|0]&1)|((S|0)!=1e9|P>>>0>=tt>>>0)))break e;a=9007199254740994}if(Z=(k|0)==(K|0)?1:1.5,K=S>>>1|0,Z=K>>>0>O>>>0?.5:(K|0)==(O|0)?Z:1.5,At[Ot|0]!=45|Mt||(Z=-Z,a=-a),l[tt>>2]=W,a+Z==a)break i;if(u=S+W|0,l[tt>>2]=u,u>>>0>=1e9)for(;l[tt>>2]=0,tt=tt-4|0,tt>>>0<P>>>0&&(P=P-4|0,l[P>>2]=0),u=l[tt>>2]+1|0,l[tt>>2]=u,u>>>0>999999999;);if(u=Fe(Y-P>>2,9),S=10,K=l[P>>2],K>>>0<10)break i;for(;u=u+1|0,S=Fe(S,10),K>>>0>=S>>>0;);}S=tt+4|0,k=k>>>0>S>>>0?S:k}for(;K=k,O=k>>>0<=P>>>0,!O&&(k=K-4|0,!l[k>>2]););i:{if((yt|0)!=103){tt=y&8;break i}if(S=dt||1,k=(S|0)>(u|0)&(u|0)>-5,dt=(k?u^-1:-1)+S|0,A=(k?-1:-2)+A|0,tt=y&8,tt)break i;k=-9;e:{if(O||(tt=l[K-4>>2],!tt)||(et=10,k=0,(tt>>>0)%10|0))break e;for(;S=k,k=k+1|0,et=Fe(et,10),!((tt>>>0)%(et>>>0)|0););k=S^-1}if(S=Fe(K-Y>>2,9),(A&-33)==70){tt=0,k=(k+S|0)-9|0,k=(k|0)>0?k:0,dt=(k|0)>(dt|0)?dt:k;break i}tt=0,k=((u+S|0)+k|0)-9|0,k=(k|0)>0?k:0,dt=(k|0)>(dt|0)?dt:k}if(et=-1,O=tt|dt,((O?2147483645:2147483646)|0)<(dt|0))break t;W=(((O|0)!=0)+dt|0)+1|0,S=A&-33;i:{if((S|0)==70){if((W^2147483647)<(u|0))break t;k=(u|0)>0?u:0;break i}if(k=u>>31,k=Bn((k^u)-k|0,0,pt),(pt-k|0)<=1)for(;k=k-1|0,ft[k|0]=48,(pt-k|0)<2;);if(ot=k-2|0,ft[ot|0]=A,ft[k-1|0]=(u|0)<0?45:43,k=pt-ot|0,(k|0)>(W^2147483647))break t}if(u=k+W|0,(u|0)>(at^2147483647))break t;W=u+at|0,mi(r,32,h,W,y),hi(r,Ot,at),mi(r,48,h,W,y^65536);i:{e:{s:{if((S|0)==70){for(A=q+16|0,u=A|8,tt=A|9,S=P>>>0>Y>>>0?Y:P,P=S;;){k=Bn(l[P>>2],0,tt);n:{if((S|0)!=(P|0)){if(q+16>>>0>=k>>>0)break n;for(;k=k-1|0,ft[k|0]=48,q+16>>>0<k>>>0;);break n}if((k|0)!=(tt|0))break n;ft[q+24|0]=48,k=u}if(hi(r,k,tt-k|0),P=P+4|0,!(Y>>>0>=P>>>0))break}if(O&&hi(r,4275,1),(dt|0)<=0|P>>>0>=K>>>0)break s;for(;;){if(k=Bn(l[P>>2],0,tt),k>>>0>q+16>>>0)for(;k=k-1|0,ft[k|0]=48,q+16>>>0<k>>>0;);if(hi(r,k,(dt|0)>=9?9:dt),k=dt-9|0,P=P+4|0,K>>>0<=P>>>0)break e;if(u=(dt|0)>9,dt=k,!u)break}break e}n:{if((dt|0)<0)break n;for(Y=P>>>0<K>>>0?K:P+4|0,A=q+16|0,u=A|8,K=A|9,S=P;;){k=Bn(l[S>>2],0,K),(K|0)==(k|0)&&(ft[q+24|0]=48,k=u);a:{if((S|0)!=(P|0)){if(q+16>>>0>=k>>>0)break a;for(;k=k-1|0,ft[k|0]=48,q+16>>>0<k>>>0;);break a}if(hi(r,k,1),k=k+1|0,!(tt|dt))break a;hi(r,4275,1)}if(A=K-k|0,hi(r,k,(A|0)>(dt|0)?dt:A),dt=dt-A|0,S=S+4|0,Y>>>0<=S>>>0)break n;if(!((dt|0)>=0))break}}mi(r,48,dt+18|0,18,0),hi(r,ot,pt-ot|0);break i}k=dt}mi(r,48,k+9|0,9,0)}mi(r,32,h,W,y^8192),et=(h|0)<(W|0)?W:h;break t}tt=(A<<26>>31&9)+Ot|0;r:{if(u>>>0>11)break r;for(k=12-u|0,Z=16;Z=Z*16,k=k-1|0,!!k;);if(At[tt|0]==45){a=-(Z+(-a-Z));break r}a=a+Z-Z}for(Y=at|2,P=A&32,S=l[q+44>>2],k=S>>31,k=Bn((k^S)-k|0,0,pt),(pt|0)==(k|0)&&(ft[q+15|0]=48,k=q+15|0),dt=k-2|0,ft[dt|0]=A+15,ft[k-1|0]=(S|0)<0?45:43,k=y&8,S=q+16|0;A=S,Ge(a)<2147483648?K=~~a:K=-2147483648,ft[S|0]=P|At[K+5504|0],a=(a-+(K|0))*16,S=A+1|0,!(k|(u|0)>0)&a==0|(S-(q+16|0)|0)!=1||(ft[A+1|0]=46,S=A+2|0),a!=0;);if(et=-1,k=pt-dt|0,A=k+Y|0,(2147483645-A|0)<(u|0))break t;r:{i:{if(!u||(P=S-(q+16|0)|0,(P-2|0)>=(u|0)))break i;u=u+2|0;break r}P=S-(q+16|0)|0,u=P}A=u+A|0,mi(r,32,h,A,y),hi(r,tt,Y),mi(r,48,h,A,y^65536),hi(r,q+16|0,P),mi(r,48,u-P|0,0,0),hi(r,dt,k),mi(r,32,h,A,y^8192),et=(h|0)<(A|0)?A:h}return Et=q+560|0,et|0}function vp(r,a,h,u,y,A,k){var S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,O=0,W=0,Y=0,Z=0,at=0,ot=0,pt=0,yt=0,_t=0,Ot=0,Mt=0,Ht=0,Zt=0;K=Et-80|0,Et=K,l[K+76>>2]=a,Mt=K+55|0,ot=K+56|0;t:{r:{i:{e:{s:for(;;){if(tt=a,(W^2147483647)<(S|0))break e;W=S+W|0;n:{a:{o:{if(S=tt,P=At[S|0],P)for(;;){l:{a=P&255;c:{if(!a){a=S;break c}if((a|0)!=37)break l;for(P=S;;){if(At[P+1|0]!=37){a=P;break c}if(S=S+1|0,dt=At[P+2|0],a=P+2|0,P=a,(dt|0)!=37)break}}if(S=S-tt|0,Ot=W^2147483647,(S|0)>(Ot|0))break e;if(r&&hi(r,tt,S),S)continue s;l[K+76>>2]=a,S=a+1|0,Z=-1,P=ft[a+1|0],!sl(P)|At[a+2|0]!=36||(Z=P-48|0,pt=1,S=a+3|0),l[K+76>>2]=S,O=0,P=ft[S|0],a=P-32|0;c:{if(a>>>0>31){dt=S;break c}if(dt=S,a=1<<a,!(a&75913))break c;for(;;){if(dt=S+1|0,l[K+76>>2]=dt,O=a|O,P=ft[S+1|0],a=P-32|0,a>>>0>=32)break c;if(S=dt,a=1<<a,!(a&75913))break}}c:{if((P|0)==42){a=ft[dt+1|0];h:{if(!(!sl(a)|At[dt+2|0]!=36)){l[((a<<2)+y|0)-192>>2]=10,P=dt+3|0,pt=1,Y=l[((ft[dt+1|0]<<3)+u|0)-384>>2];break h}if(pt)break o;if(P=dt+1|0,!r){l[K+76>>2]=P,pt=0,Y=0;break c}a=l[h>>2],l[h>>2]=a+4,pt=0,Y=l[a>>2]}if(l[K+76>>2]=P,(Y|0)>=0)break c;Y=0-Y|0,O=O|8192;break c}if(Y=Bp(K+76|0),(Y|0)<0)break e;P=l[K+76>>2]}S=0,et=-1;c:{if(At[P|0]!=46){a=P,at=0;break c}if(At[P+1|0]==42){a=ft[P+2|0];h:{if(!(!sl(a)|At[P+3|0]!=36)){l[((a<<2)+y|0)-192>>2]=10,a=P+4|0,et=l[((ft[P+2|0]<<3)+u|0)-384>>2];break h}if(pt)break o;if(a=P+2|0,et=0,!r)break h;P=l[h>>2],l[h>>2]=P+4,et=l[P>>2]}l[K+76>>2]=a,at=(et^-1)>>>31|0;break c}l[K+76>>2]=P+1,et=Bp(K+76|0),a=l[K+76>>2],at=1}for(;;){if(q=S,dt=28,yt=a,S=ft[a|0],S-123>>>0<4294967238)break i;if(a=yt+1|0,S=At[(S+Fe(q,58)|0)+4975|0],!(S-1>>>0<8))break}l[K+76>>2]=a;c:{h:{if((S|0)!=27){if(!S)break i;if((Z|0)>=0){l[(Z<<2)+y>>2]=S,S=(Z<<3)+u|0,P=l[S+4>>2],l[K+64>>2]=l[S>>2],l[K+68>>2]=P;break h}if(!r)break n;Rp(K- -64|0,S,h,k);break c}if((Z|0)>=0)break i}if(S=0,!r)continue s}P=O&-65537,O=O&8192?P:O,Z=0,_t=1167,dt=ot;c:{h:{f:{d:{p:{v:{y:{u:{g:{b:{m:{T:{k:{A:{w:{E:switch(S=ft[yt|0],S=q&&(S&15)==3?S&-33:S,S-88|0){case 11:break c;case 9:case 13:case 14:case 15:break h;case 27:break y;case 12:case 17:break b;case 23:break m;case 0:case 32:break T;case 24:break k;case 22:break A;case 29:break w;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 10:case 16:case 18:case 19:case 20:case 21:case 25:case 26:case 28:case 30:case 31:break a;default:break E}E:switch(S-65|0){case 0:case 4:case 5:case 6:break h;case 2:break p;case 1:case 3:break a;default:break E}if((S|0)==83)break v;break a}P=l[K+64>>2],q=l[K+68>>2],S=1167;break g}S=0;A:switch(q&255){case 0:l[l[K+64>>2]>>2]=W;continue s;case 1:l[l[K+64>>2]>>2]=W;continue s;case 2:tt=l[K+64>>2],l[tt>>2]=W,l[tt+4>>2]=W>>31;continue s;case 3:Fr[l[K+64>>2]>>1]=W;continue s;case 4:ft[l[K+64>>2]]=W;continue s;case 6:l[l[K+64>>2]>>2]=W;continue s;case 7:break A;default:continue s}tt=l[K+64>>2],l[tt>>2]=W,l[tt+4>>2]=W>>31;continue s}et=et>>>0<=8?8:et,O=O|8,S=120}if(tt=ot,P=l[K+64>>2],q=l[K+68>>2],P|q)for(Ht=S&32;tt=tt-1|0,ft[tt|0]=Ht|At[(P&15)+5504|0],Zt=!q&P>>>0>15|(q|0)!=0,yt=q,q=q>>>4|0,P=(yt&15)<<28|P>>>4,!!Zt;);if(!(O&8)|!(l[K+64>>2]|l[K+68>>2]))break u;_t=(S>>>4|0)+1167|0,Z=2;break u}if(S=ot,tt=l[K+68>>2],q=tt,P=l[K+64>>2],tt|P)for(;S=S-1|0,ft[S|0]=P&7|48,yt=!q&P>>>0>7|(q|0)!=0,tt=q,q=tt>>>3|0,P=(tt&7)<<29|P>>>3,!!yt;);if(tt=S,!(O&8))break u;S=ot-tt|0,et=(S|0)<(et|0)?et:S+1|0;break u}if(P=l[K+64>>2],S=l[K+68>>2],q=S,(S|0)<0){tt=0-(q+((P|0)!=0)|0)|0,q=tt,P=0-P|0,l[K+64>>2]=P,l[K+68>>2]=tt,Z=1,S=1167;break g}if(O&2048){Z=1,S=1168;break g}Z=O&1,S=Z?1169:1167}_t=S,tt=Bn(P,q,ot)}if((et|0)<0&&at)break e;if(O=at?O&-65537:O,S=l[K+64>>2],P=l[K+68>>2],!((S|P)!=0|et)){tt=ot,et=0;break a}S=!(S|P)+(ot-tt|0)|0,et=(S|0)<(et|0)?et:S;break a}O=0,at=et>>>0>=2147483647?2147483647:et,q=at,dt=(q|0)!=0;y:{u:{S=l[K+64>>2],tt=S||4277,S=tt;g:{b:{m:{if(!(S&3)|!q)break m;for(;;){if(O=At[S|0],!O)break b;if(q=q-1|0,dt=(q|0)!=0,S=S+1|0,!(S&3))break m;if(!q)break}}if(!dt)break u;m:{if(!(!At[S|0]|q>>>0<4))for(;;){if(dt=l[S>>2],(dt^-1)&dt-16843009&-2139062144)break m;if(S=S+4|0,q=q-4|0,!(q>>>0>3))break}if(!q)break u}dt=0;break g}dt=1}for(;;){if(!dt){O=At[S|0],dt=1;continue}if(!O)break y;if(S=S+1|0,q=q-1|0,!q)break u;dt=0}}S=0}if(S=S?S-tt|0:at,dt=S+tt|0,(et|0)>=0){O=P,et=S;break a}if(O=P,et=S,At[dt|0])break e;break a}if(et){P=l[K+64>>2];break d}S=0,mi(r,32,Y,0,O);break f}l[K+12>>2]=0,l[K+8>>2]=l[K+64>>2],P=K+8|0,l[K+64>>2]=P,et=-1}S=0;d:{for(;;){if(tt=l[P>>2],!tt)break d;if(tt=jp(K+4|0,tt),dt=(tt|0)<0,!(dt|tt>>>0>et-S>>>0)){if(P=P+4|0,S=S+tt|0,et>>>0>S>>>0)continue;break d}break}if(dt)break r}if(dt=61,(S|0)<0)break i;if(mi(r,32,Y,S,O),!S){S=0;break f}for(dt=0,P=l[K+64>>2];;){if(tt=l[P>>2],!tt||(tt=jp(K+4|0,tt),dt=tt+dt|0,dt>>>0>S>>>0))break f;if(hi(r,K+4|0,tt),P=P+4|0,!(S>>>0>dt>>>0))break}}mi(r,32,Y,S,O^8192),S=(S|0)<(Y|0)?Y:S;continue s}if((et|0)<0&&at)break e;if(dt=61,S=Pt[A|0](r,Ne[K+64>>3],Y,et,O,S)|0,(S|0)>=0)continue s;break i}ft[K+55|0]=l[K+64>>2],et=1,tt=Mt,O=P;break a}P=At[S+1|0],S=S+1|0}if(r)break t;if(!pt)break n;for(S=1;;){if(r=l[(S<<2)+y>>2],r){if(Rp((S<<3)+u|0,r,h,k),W=1,S=S+1|0,(S|0)!=10)continue;break t}break}if(W=1,S>>>0>=10)break t;for(;;){if(l[(S<<2)+y>>2])break o;if(S=S+1|0,(S|0)==10)break}break t}dt=28;break i}if(q=dt-tt|0,et=(et|0)>(q|0)?et:q,(et|0)>(Z^2147483647))break e;if(dt=61,P=et+Z|0,S=(P|0)<(Y|0)?Y:P,(Ot|0)<(S|0))break i;mi(r,32,S,P,O),hi(r,_t,Z),mi(r,48,S,P,O^65536),mi(r,48,et,q,0),hi(r,tt,q),mi(r,32,S,P,O^8192);continue}break}W=0;break t}dt=61}l[1781]=dt}W=-1}return Et=K+80|0,W}function IE(r,a,h,u){r=r|0,a=+a,h=+h,u=u|0;var y=m(0),A=m(0),k=0,S=m(0),P=0,K=m(0),tt=0,dt=m(0),q=0;q=Et+-64|0,Et=q,k=l[r>>2],Ui(q+8|0,0,56),l[1755]=l[1755]+1,bp(k),S=m(a),A=I[k+572>>2];t:{r:{i:switch(r=l[k+576>>2],r|0){case 0:case 3:break r;default:break i}y=I[k+572>>2];i:{if(!((r|0)!=1|y!=y)){if(y=A,!(y<m(0)))break i;break r}e:{if(!((r|0)!=2|y!=y)){if(S!=S|A<m(0))break r;break e}y=m(Yt);s:switch(r-1|0){case 1:break e;case 0:break s;default:break i}y=A;break i}y=m(m(A*S)*m(.009999999776482582))}dt=m(y+m(de(k,2,S)+we(k,2,S))),tt=1;break t}y=m(0),A=I[k+216>>2];r:{i:{r=l[k+216>>2];e:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;tt=4336;n:{if((r|0)!=2141891242){if(A==A)break n;tt=4344}switch(y=I[tt>>2],l[tt+4>>2]-1|0){case 0:break e;case 1:break s;default:break i}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*S)*m(.009999999776482582))}if(y!=y)break i;y=m(0);e:{if((r|0)==2139156720)break e;if((r|0)==2140081935)break r;P=4336;s:{if((r|0)!=2141891242){if(A==A)break s;P=4344}switch(y=I[P>>2],dt=m(Yt),tt=2,l[P+4>>2]-1|0){case 1:break e;case 0:break r;default:break t}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break r}dt=m(m(y*S)*m(.009999999776482582)),tt=2;break t}tt=S==S,dt=S;break t}tt=2,dt=y}K=m(h),A=I[k+580>>2];t:{r:{i:switch(r=l[k+584>>2],r|0){case 0:case 3:break r;default:break i}y=I[k+580>>2];i:{if(!((r|0)!=1|y!=y)){if(y=A,!(y<m(0)))break i;break r}e:{if(!((r|0)!=2|y!=y)){if(K!=K|A<m(0))break r;break e}y=m(Yt);s:switch(r-1|0){case 1:break e;case 0:break s;default:break i}y=A;break i}y=m(m(A*K)*m(.009999999776482582))}A=m(y+m(de(k,0,S)+we(k,0,S))),r=1;break t}y=m(0),A=I[k+220>>2];r:{i:{r=l[k+220>>2];e:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;P=4336;n:{if((r|0)!=2141891242){if(A==A)break n;P=4344}switch(y=I[P>>2],l[P+4>>2]-1|0){case 0:break e;case 1:break s;default:break i}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*K)*m(.009999999776482582))}if(y!=y)break i;y=m(0);e:{if((r|0)==2139156720)break e;if((r|0)==2140081935)break r;P=4336;s:{if((r|0)!=2141891242){if(A==A)break s;P=4344}switch(y=I[P>>2],A=m(Yt),r=2,l[P+4>>2]-1|0){case 0:break r;case 1:break e;default:break t}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break r}A=m(m(y*K)*m(.009999999776482582)),r=2;break t}r=K==K,A=K;break t}r=2,A=y}un(k,dt,A,u,tt,r,S,K,1,0,l[k+568>>2],q+8|0,0,l[1755])&&(Ip(k,At[k+300|0]&3,S,K,S),_p(k,+I[l[k+568>>2]+20>>2],0,0)),Et=q- -64|0}function xE(r,a){r=r|0,a=a|0;var h=0,u=m(0),y=0,A=0,k=m(0),S=0,P=0,K=0,tt=m(0);t:{P=l[a>>2],a=l[r>>2];r:{if((l[P+24>>2]^l[a+24>>2])&8388607)break r;tt=I[P+40>>2],y=l[P+40>>2],u=I[a+40>>2];i:{e:{if(h=l[a+40>>2],(h|0)!=2139156720){if(k=m(Yt),r=3,(h|0)==2141891242)break i;if((h|0)!=2140081935)break e;k=m(0),r=1;break i}r=2;break i}if(r=0,u!=u)break i;k=(Dt(2,(h&-1073741825)+536870912|0),Bt()),r=h&1073741824?2:1}i:{e:{if((y|0)!=2139156720){if(u=m(Yt),h=3,(y|0)==2141891242)break i;if((y|0)!=2140081935)break e;u=m(0),h=1;break i}u=m(0),h=2;break i}if(h=0,tt!=tt)break i;u=(Dt(2,(y&-1073741825)+536870912|0),Bt()),h=y&1073741824?2:1}if((h|0)!=(r|0)|!(!r|k!=k&u!=u|m(Ge(m(k-u)))<m(9999999747378752e-20))||(h=a+44|0,A=P+44|0,l[h>>2]!=l[A>>2]))break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+80|0,A=P+80|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+116|0,A=P+116|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+152|0,A=P+152|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+188|0,A=P+188|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==3)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<2)break r}for(S=P+200|0,K=a+200|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],A=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(A|0))continue}break}if((h|0)!=(A|0))break r;for(S=P+208|0,K=a+208|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],A=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(A|0))continue}break}if((h|0)!=(A|0))break r;for(S=P+216|0,K=a+216|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],A=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(A|0))continue}break}if((h|0)!=(A|0)||(k=I[P+28>>2],r=k!=k,u=I[a+28>>2],(r|0)==(u==u|0)|!(r|u!=u)&u!=k)||(u=I[a+32>>2],k=I[P+32>>2],(u==u|0)==(k!=k|0)|u==u&u!=k)||(k=I[P+36>>2],r=k!=k,u=I[a+36>>2],(r|0)==(u==u|0)|!r&u!=k))break r;if(r=0,u=I[a+224>>2],u!=u&&(r=1,k=I[P+224>>2],k!=k)||(k=u,u=I[P+224>>2],k==u|u!=u&r))break t}for(Fi(a+24|0,P+24|0,204);;){if(r=At[a+4|0],r&4)break t;if(ft[a+4|0]=r|4,r=l[a+20>>2],r&&Pt[r|0](a),l[a+308>>2]=2143289344,a=l[a+552>>2],!a)break}}}function DE(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,O=0,W=0,Y=0,Z=0;h=a,a=l[a>>2]+7&-8,l[h>>2]=a+16,O=r,P=l[a>>2],u=l[a+4>>2],r=l[a+12>>2],q=r,k=Et-32|0,Et=k,r=r&2147483647,S=r,y=r-1006698496|0,r=r-1140785152|0,h=l[a+8>>2],a=h;t:{if((y|0)==(r|0)&a>>>0<a>>>0|r>>>0>y>>>0){if(r=h,h=q<<4|r>>>28,a=r<<4|u>>>28,r=h,u=u&268435455,(u|0)==134217728&(P|0)!=0|u>>>0>134217728){r=r+1073741824|0,a=a+1|0,r=a?r:r+1|0;break t}if(r=r+1073741824|0,P|(u|0)!=134217728)break t;u=a&1,a=u+a|0,r=a>>>0<u>>>0?r+1|0:r;break t}if(!(!a&(S|0)==2147418112?!(u|P):S>>>0<2147418112)){r=h,h=q<<4|r>>>28,a=r<<4|u>>>28,r=h&524287|2146959360;break t}if(a=0,r=2146435072,S>>>0>1140785151||(r=0,et=S>>>16|0,et>>>0<15249))break t;a=P,r=u,y=q&65535|65536,S=y,dt=h,A=h,K=et-15233|0;r:{if(K&64){h=a,y=K+-64|0,a=y&31,(y&63)>>>0>=32?(r=h<<a,A=0):(r=(1<<a)-1&h>>>32-a|r<<a,A=h<<a),y=r,a=0,r=0;break r}if(!K)break r;tt=A,A=K&31,(K&63)>>>0>=32?(h=tt<<A,A=0):(h=(1<<A)-1&tt>>>32-A|y<<A,A=tt<<A),y=h,W=A,tt=a,h=64-K|0,A=h&31,(h&63)>>>0>=32?(h=0,a=r>>>A|0):(h=r>>>A|0,a=((1<<A)-1&r)<<32-A|tt>>>A),A=W|a,y=h|y,a=K&31,(K&63)>>>0>=32?(h=tt<<a,a=0):(h=(1<<a)-1&tt>>>32-a|r<<a,a=tt<<a),r=h}l[k+16>>2]=a,l[k+20>>2]=r,l[k+24>>2]=A,l[k+28>>2]=y,a=15361-et|0;r:{if(a&64){u=dt,a=a+-64|0,r=a&31,(a&63)>>>0>=32?(h=0,P=S>>>r|0):(h=S>>>r|0,P=((1<<r)-1&S)<<32-r|u>>>r),u=h,dt=0,S=0;break r}if(!a)break r;y=dt,r=64-a|0,h=r&31,(r&63)>>>0>=32?(r=y<<h,A=0):(r=(1<<h)-1&y>>>32-h|S<<h,A=y<<h),y=P,P=a&31,(a&63)>>>0>=32?(h=0,y=u>>>P|0):(h=u>>>P|0,y=((1<<P)-1&u)<<32-P|y>>>P),P=A|y,u=r|h,y=dt,h=a&31,(a&63)>>>0>=32?(r=0,dt=S>>>h|0):(r=S>>>h|0,dt=((1<<h)-1&S)<<32-h|y>>>h),S=r}if(l[k>>2]=P,l[k+4>>2]=u,l[k+8>>2]=dt,l[k+12>>2]=S,a=l[k+8>>2],r=l[k+12>>2]<<4|a>>>28,a=a<<4,h=l[k>>2],S=l[k+4>>2],a=S>>>28|a,u=S&268435455,h=h|(l[k+16>>2]|l[k+24>>2]|(l[k+20>>2]|l[k+28>>2]))!=0,(u|0)==134217728&(h|0)!=0|u>>>0>134217728){a=a+1|0,r=a?r:r+1|0;break t}if(h|(u|0)!=134217728)break t;h=a,a=a+(a&1)|0,r=h>>>0>a>>>0?r+1|0:r}Et=k+32|0,Dt(0,a|0),Dt(1,q&-2147483648|r),Y=O,Z=+Ae(),Ne[Y>>3]=Z}function un(r,a,h,u,y,A,k,S,P,K,tt,dt,q,et){var O=m(0),W=0,Y=0,Z=0,at=0,ot=m(0),pt=0,yt=0,_t=m(0);t:{if(!(l[r+312>>2]!=(et|0)&&At[r+4|0]&4)&&(at=0,l[r+316>>2]==(u|0)))break t;l[r+540>>2]=-1082130432,l[r+544>>2]=-1082130432,l[r+532>>2]=0,l[r+536>>2]=0,l[r+524>>2]=-1082130432,l[r+528>>2]=-1082130432,l[r+320>>2]=0,at=1}pt=q+1|0;t:{r:{i:{e:{if(l[r+8>>2]){if(ot=de(r,2,k),_t=we(r,2,k),O=m(de(r,0,k)+we(r,0,k)),q=r+524|0,ot=m(ot+_t),Ep(y,a,A,h,l[r+532>>2],I[q>>2],l[r+536>>2],I[r+528>>2],I[r+540>>2],I[r+544>>2],ot,O,tt))break i;if(Y=l[r+320>>2],!Y)break e;for(W=r+324|0;;){if(q=W+Fe(Z,24)|0,Ep(y,a,A,h,l[q+8>>2],I[q>>2],l[q+12>>2],I[q+4>>2],I[q+16>>2],I[q+20>>2],ot,O,tt))break i;if(Z=Z+1|0,(Y|0)==(Z|0))break}break e}if(!P){if(yt=l[r+320>>2],!yt)break e;for(Y=r+324|0;;){W=Fe(Z,24),q=W+Y|0,O=I[q>>2];s:{n:{if(!(O!=O|a!=a)){if(m(Ge(m(O-a)))<m(9999999747378752e-20))break n;break s}if(O==O|a==a)break s}W=Y+W|0,O=I[W+4>>2];n:{if(!(O!=O|h!=h)){if(m(Ge(m(O-h)))<m(9999999747378752e-20))break n;break s}if(O==O|h==h)break s}if(l[W+8>>2]!=(y|0))break s;if(l[W+12>>2]==(A|0))break i}if(Z=Z+1|0,(yt|0)==(Z|0))break}break e}q=r+524|0,O=I[q>>2];s:{if(!(O!=O|a!=a)){if(m(Ge(m(O-a)))<m(9999999747378752e-20))break s;break e}if(O==O|a==a)break e}W=l[r+532>>2]==(y|0)&&l[r+536>>2]==(A|0)?q:0,O=I[r+528>>2],q=O!=O,Y=h!=h;s:{if(q|Y){q=q&Y;break s}q=m(Ge(m(O-h)))<m(9999999747378752e-20)}q=q?W:0;break i}gp(r,a,h,u,y,A,k,S,P,tt,dt,pt,et,K),l[r+316>>2]=u;break r}if(!(!q|at)){I[r+516>>2]=I[q+16>>2],I[r+520>>2]=I[q+20>>2],u=(P?12:16)+dt|0,l[u>>2]=l[u>>2]+1;break t}if(gp(r,a,h,u,y,A,k,S,P,tt,dt,pt,et,K),l[r+316>>2]=u,q)break t}q=l[r+320>>2],u=q+1|0,u>>>0>lp[dt+8>>2]&&(l[dt+8>>2]=u),(q|0)==8&&(l[r+320>>2]=0,q=0),P?u=r+524|0:(l[r+320>>2]=q+1,u=(Fe(q,24)+r|0)+324|0),l[u+12>>2]=A,l[u+8>>2]=y,I[u+4>>2]=h,I[u>>2]=a,I[u+16>>2]=I[r+516>>2],I[u+20>>2]=I[r+520>>2],q=0}t:{if(!P||(u=l[r+520>>2],l[r+244>>2]=l[r+516>>2],l[r+248>>2]=u,u=At[r+4|0],y=u|1,ft[r+4|0]=y,!(u&4)))break t;ft[r+4|0]=y&251}return l[r+312>>2]=et,!q|at}function Th(r){r=r|0;var a=0,h=0,u=0,y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0;S=8;t:{if(r>>>0>4294967239)break t;r:{for(;;){S=S>>>0<=8?8:S,a=l[1751],A=a,y=l[1750],r=r>>>0<=8?8:r+3&-4;i:{if(r>>>0<=127){k=(r>>>3|0)-1|0;break i}if(u=mr(r),k=((r>>>29-u^4)-(u<<2)|0)+110|0,r>>>0<=4095)break i;u=((r>>>30-u^2)-(u<<1)|0)+71|0,k=u>>>0>=63?63:u}if(h=k&31,(k&63)>>>0>=32?(u=0,a=a>>>h|0):(u=a>>>h|0,a=((1<<h)-1&a)<<32-h|y>>>h),a|u){for(;;){y=u;i:{if(a|u){h=u-1|0,P=h+1|0,A=h,h=a-1|0,A=(h|0)!=-1?P:A,u=mr(u^A),u=(u|0)==32?mr(a^h)+32|0:u,h=63-u|0,Ni=0-(u>>>0>63)|0;break i}Ni=0,h=64}A=h,h=A&31,(A&63)>>>0>=32?(u=0,a=y>>>h|0):(u=y>>>h|0,a=((1<<h)-1&y)<<32-h|a>>>h),P=a,k=A+k|0,h=k<<4,a=l[h+5976>>2],A=h+5968|0;i:{if((a|0)!=(A|0)){if(y=Sh(a,S,r),y)break t;y=l[a+4>>2],l[y+8>>2]=l[a+8>>2],l[l[a+8>>2]+4>>2]=y,l[a+8>>2]=A,y=h+5972|0,l[a+4>>2]=l[y>>2],l[y>>2]=a,l[l[a+4>>2]+8>>2]=a,k=k+1|0,a=(u&1)<<31|P>>>1,u=u>>>1|0;break i}K=l[1751],A=k&63,a=A,y=a&31,a>>>0>=32?(a=0,h=-1>>>y|0):(a=-1>>>y|0,h=a|(1<<y)-1<<32-y),h=h&-2,y=A&31,A>>>0>=32?(a=h<<y,h=0):(a=(1<<y)-1&h>>>32-y|a<<y,h=h<<y),tt=h,y=a,A=0-k&63,h=A,a=h&31,h>>>0>=32?(a=-1<<a,h=0):(h=-1<<a,a=h|(1<<a)-1&-1>>>32-a),dt=h&-2,h=A&31,A>>>0>=32?(A=0,a=a>>>h|0):(A=a>>>h|0,a=((1<<h)-1&a)<<32-h|dt>>>h),a=a|tt,Ni=y|A,l[1750]=l[1750]&a,l[1751]=Ni&K,a=P^1}if(!(a|u))break}A=l[1751],y=l[1750]}i:{if(y|A){u=mr(A),h=63-((u|0)==32?mr(y)+32|0:u)|0,a=h<<4,u=l[a+5976>>2];e:{if(!A&y>>>0<1073741824||(k=99,a=a+5968|0,(a|0)==(u|0)))break e;for(;;){if(!k)break e;if(y=Sh(u,S,r),y)break t;if(k=k-1|0,u=l[u+8>>2],(a|0)==(u|0))break}u=a}if(wh(r+48|0))break i;if(!u||(a=(h<<4)+5968|0,(a|0)==(u|0)))break r;for(;;){if(y=Sh(u,S,r),y)break t;if(u=l[u+8>>2],(a|0)==(u|0))break}break r}if(!wh(r+48|0))break r}if(y=0,S-1&S)break t;if(!(r>>>0<=4294967239))break}break t}y=0}return y|0}function PE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0,q=0;S=Et-80|0,Et=S,r=l[r>>2];t:{r:{if(P=l[a>>2],!l[P+552>>2]){if(l[r+8>>2])break r;a=l[r+556>>2],k=a+(h<<2)|0,u=l[r+560>>2],y=r+564|0,A=l[y>>2];i:{if(u>>>0<A>>>0){if((u|0)==(k|0)){l[k>>2]=P,l[r+560>>2]=k+4;break i}if(h=u,a=u-4|0,u>>>0>a>>>0)for(;l[h>>2]=l[a>>2],h=h+4|0,a=a+4|0,u>>>0>a>>>0;);l[r+560>>2]=h,a=k+4|0,(a|0)!=(u|0)&&(a=u-a|0,Ps(u-(a&-4)|0,k,a)),l[k>>2]=P;break i}if(u=(u-a>>2)+1|0,u>>>0>=1073741824)break t;a=A-a|0,A=a>>1,y=Na(S+32|0,a>>>0>=2147483644?1073741823:u>>>0<A>>>0?A:u,h,y),h=l[y+8>>2];e:{if((h|0)!=l[y+12>>2])break e;if(a=l[y+4>>2],u=l[y>>2],a>>>0>u>>>0){u=((a-u>>2)+1|0)/-2<<2,K=u+a|0,A=a,a=h-a|0,h=Ps(K,A,a)+a|0,l[y+8>>2]=h,l[y+4>>2]=u+l[y+4>>2];break e}a=(h|0)==(u|0)?1:h-u>>1,A=Na(S+56|0,a,a>>>2|0,l[y+16>>2]),u=l[A+8>>2],a=l[y+4>>2],h=l[y+8>>2];s:{if((a|0)==(h|0)){h=u,u=a;break s}for(h=(h-a|0)+u|0;l[u>>2]=l[a>>2],a=a+4|0,u=u+4|0,(u|0)!=(h|0););a=l[y+8>>2],u=l[y+4>>2]}if(K=l[y>>2],l[y>>2]=l[A>>2],l[A>>2]=K,l[y+4>>2]=l[A+4>>2],l[A+4>>2]=u,l[y+8>>2]=h,l[A+8>>2]=a,tt=l[y+12>>2],l[y+12>>2]=l[A+12>>2],l[A+12>>2]=tt,(a|0)!=(u|0)&&(l[A+8>>2]=((u-a|0)+3&-4)+a),!K)break e;gi(K),h=l[y+8>>2]}if(l[h>>2]=P,l[y+8>>2]=l[y+8>>2]+4,a=l[r+556>>2],h=k-a|0,dt=y,q=Ps(l[y+4>>2]-h|0,a,h),l[dt+4>>2]=q,u=l[r+560>>2]-k|0,k=Ps(l[y+8>>2],k,u),a=l[r+556>>2],l[r+556>>2]=l[y+4>>2],l[y+4>>2]=a,h=l[r+560>>2],l[r+560>>2]=u+k,l[y+8>>2]=h,u=l[r+564>>2],l[r+564>>2]=l[y+12>>2],l[y>>2]=a,l[y+12>>2]=u,(a|0)!=(h|0)&&(l[y+8>>2]=h+((a-h|0)+3&-4)),!a)break i;gi(a)}for(l[P+552>>2]=r;a=At[r+4|0],!!(!(a&4)&&(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],r)););Et=S+80|0;return}l[S+16>>2]=4075,sr(r,S+16|0),qi(),he()}l[S>>2]=4208,sr(r,S),qi(),he()}Ds(),he()}function yp(r,a){var h=0,u=0;for(l[r>>2]=0,l[r+8>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,l[r+24>>2]=0,l[r+36>>2]=2143289344,l[r+40>>2]=2141891242,l[r+28>>2]=2143289344,l[r+32>>2]=2143289344,ft[r+4|0]=At[r+4|0]&128,u=Ui(r+44|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Ui(r+80|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Ui(r+116|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Ui(r+152|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,l[r+196>>2]=0,u=r+188|0,l[u>>2]=0,l[u+4>>2]=0;l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=3;);for(l[r+24>>2]=4224,l[r+224>>2]=2143289344,l[r+216>>2]=2143289344,l[r+220>>2]=2143289344,l[r+208>>2]=2143289344,l[r+212>>2]=2143289344,l[r+200>>2]=2141891242,l[r+204>>2]=2141891242,Ui(r+228|0,0,288),l[r+244>>2]=2143289344,l[r+248>>2]=2143289344,Ui(r+252|0,0,49),l[r+308>>2]=2143289344,u=r+516|0,h=r+324|0;l[h+16>>2]=-1082130432,l[h+20>>2]=-1082130432,l[h+8>>2]=0,l[h+12>>2]=0,l[h>>2]=-1082130432,l[h+4>>2]=-1082130432,h=h+24|0,(u|0)!=(h|0););return l[r+548>>2]=0,l[r+552>>2]=0,l[r+516>>2]=2143289344,l[r+520>>2]=2143289344,l[r+572>>2]=2143289344,l[r+576>>2]=0,l[r+568>>2]=a,l[r+540>>2]=-1082130432,l[r+544>>2]=-1082130432,l[r+532>>2]=0,l[r+536>>2]=0,l[r+524>>2]=-1082130432,l[r+528>>2]=-1082130432,l[r+556>>2]=0,l[r+560>>2]=0,l[r+564>>2]=0,l[r+580>>2]=2143289344,l[r+584>>2]=0,qp((a|0)!=0,2760),ft[r+4|0]=At[r+4|0]|1,ft[a+8|0]&1&&(l[r+24>>2]=l[r+24>>2]&-909|520),r}function He(r,a,h,u){var y=m(0),A=m(0),k=0,S=m(0);t:{r:{i:{e:{s:{n:{if(a>>>0<=1){A=I[r+212>>2],a=l[r+212>>2];a:{if((a|0)==2139156720)break a;if((a|0)==2140081935)break n;k=4336;o:{if((a|0)!=2141891242){if(A==A)break o;k=4344}switch(y=I[k>>2],A=m(Yt),l[k+4>>2]-1|0){case 0:break n;case 1:break a;default:break s}}if(y=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break n}A=m(m(y*u)*m(.009999999776482582));break s}A=I[r+208>>2];a:{o:{a=l[r+208>>2];l:{if((a|0)==2139156720)break l;if((a|0)==2140081935)break o;k=4336;c:{if((a|0)!=2141891242){if(A==A)break c;k=4344}switch(y=I[k>>2],A=m(Yt),l[k+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(y=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break o}A=m(m(y*u)*m(.009999999776482582));break a}A=y}y=m(0),S=I[r+216>>2],r=l[r+216>>2];a:{if((r|0)==2139156720)break a;if((r|0)==2140081935)break i;a=4336;o:{if((r|0)!=2141891242){if(S==S)break o;a=4344}switch(y=I[a>>2],l[a+4>>2]-1|0){case 1:break a;case 0:break e;default:break r}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*u)*m(.009999999776482582));break e}A=y}y=m(0),S=I[r+220>>2],r=l[r+220>>2];s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break i;a=4336;n:{if((r|0)!=2141891242){if(S==S)break n;a=4344}switch(y=I[a>>2],l[a+4>>2]-1|0){case 1:break s;case 0:break e;default:break r}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*u)*m(.009999999776482582))}if(!(y>=m(0)))break r}if(h>y)break t}if(!(A>=m(0)))return h;y=h<A?A:h}return y}function bp(r){var a=0,h=0,u=m(0),y=m(0),A=m(0),k=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,O=0;for(k=Et-16|0,l[k+8>>2]=0,l[k+12>>2]=1,tt=r+200|0,dt=r+572|0,q=r+208|0,et=r+216|0,r=0;;){O=r,K=l[(k+8|0)+(r<<2)>>2],S=K<<2,r=et+S|0,u=I[r>>2];t:{r:{i:{e:{s:{n:{if(a=l[r>>2],P=(a|0)==2139156720,!(P|(a|0)==2140081935|(a|0)==2141891242)&u!=u)break n;r=S+q|0,y=I[r>>2],h=l[r>>2];a:{o:{if((h|0)!=2139156720){if(A=m(Yt),r=3,(h|0)==2141891242)break a;if((h|0)!=2140081935)break o;A=m(0),r=1;break a}A=m(0),r=2;break a}if(r=0,y!=y)break a;A=(Dt(2,(h&-1073741825)+536870912|0),Bt()),r=h&1073741824?2:1}h=r;a:{o:{if(!P){if(y=m(Yt),r=3,(a|0)==2141891242)break a;if((a|0)!=2140081935)break o;y=m(0),r=1;break a}y=m(0),r=2;break a}if(r=0,u!=u)break a;y=(Dt(2,(a&-1073741825)+536870912|0),Bt()),r=a&1073741824?2:1}if((h|0)!=(r|0)|!(!r|y!=y&A!=A|m(Ge(m(y-A)))<m(9999999747378752e-20)))break n;if(r=0,P)break s;if((a|0)==2140081935)break r;if((a|0)==2141891242)break i;if(u!=u)break e;r=(a&-1073741825)+536870912|0,a=a&1073741824?2:1;break t}if(r=0,a=S+tt|0,u=I[a>>2],a=l[a>>2],(a|0)==2139156720)break s;if((a|0)==2140081935)break r;if((a|0)==2141891242)break i;if(u!=u)break e;r=(a&-1073741825)+536870912|0,a=a&1073741824?2:1;break t}a=2;break t}r=2143289344,a=0;break t}r=2143289344,a=3;break t}a=1}if(h=(K<<3)+dt|0,l[h+4>>2]=a,l[h>>2]=r,r=1,!!(O&1))break}}function Fi(r,a,h){var u=0,y=0,A=0;if(h>>>0>=512)return kE(r|0,a|0,h|0),r;y=r+h|0;t:{if(!((r^a)&3)){r:{if(!(r&3)){h=r;break r}if(!h){h=r;break r}for(h=r;;){if(ft[h|0]=At[a|0],a=a+1|0,h=h+1|0,!(h&3))break r;if(!(h>>>0<y>>>0))break}}u=y&-4;r:{if(u>>>0<64||(A=u+-64|0,A>>>0<h>>>0))break r;for(;l[h>>2]=l[a>>2],l[h+4>>2]=l[a+4>>2],l[h+8>>2]=l[a+8>>2],l[h+12>>2]=l[a+12>>2],l[h+16>>2]=l[a+16>>2],l[h+20>>2]=l[a+20>>2],l[h+24>>2]=l[a+24>>2],l[h+28>>2]=l[a+28>>2],l[h+32>>2]=l[a+32>>2],l[h+36>>2]=l[a+36>>2],l[h+40>>2]=l[a+40>>2],l[h+44>>2]=l[a+44>>2],l[h+48>>2]=l[a+48>>2],l[h+52>>2]=l[a+52>>2],l[h+56>>2]=l[a+56>>2],l[h+60>>2]=l[a+60>>2],a=a- -64|0,h=h- -64|0,A>>>0>=h>>>0;);}if(h>>>0>=u>>>0)break t;for(;l[h>>2]=l[a>>2],a=a+4|0,h=h+4|0,u>>>0>h>>>0;);break t}if(y>>>0<4){h=r;break t}if(u=y-4|0,u>>>0<r>>>0){h=r;break t}for(h=r;ft[h|0]=At[a|0],ft[h+1|0]=At[a+1|0],ft[h+2|0]=At[a+2|0],ft[h+3|0]=At[a+3|0],a=a+4|0,h=h+4|0,u>>>0>=h>>>0;);}if(h>>>0<y>>>0)for(;ft[h|0]=At[a|0],a=a+1|0,h=h+1|0,(y|0)!=(h|0););return r}function Ap(r,a,h,u,y){var A=m(0),k=0,S=m(0),P=m(0),K=0,tt=0,dt=m(0),q=m(0),et=0;if(S=m(h-u),tt=S!=S,!tt){h=m(0),k=(a<<2)+r|0,A=I[k+208>>2];t:{r:{k=l[k+208>>2];i:{e:{if((k|0)==2139156720)break e;if((k|0)==2140081935)break r;K=4336;s:{if((k|0)!=2141891242){if(A==A)break s;K=4344}switch(h=I[K>>2],l[K+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(h=(Dt(2,(k&-1073741825)+536870912|0),Bt()),!(k&1073741824))break i}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break r;break t}P=m(h-u)}h=m(0),r=(a<<2)+r|0,A=I[r+216>>2];t:{r:{a=l[r+216>>2];i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break r;r=4336;s:{if((a|0)!=2141891242){if(A==A)break s;r=4344}switch(h=I[r>>2],A=m(34028234663852886e22),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(h=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break i}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break r;A=m(34028234663852886e22);break t}A=m(h-u)}if(h=(dt=S,q=Ih(S,A),et=A!=A|tt,et?dt:q),r=h!=h,!(r|P!=P))return ce(h,P);S=r?P:h}return S}function Ep(r,a,h,u,y,A,k,S,P,K,tt,dt,q){var et=m(0),O=m(0),W=0,Y=0,Z=m(0),at=m(0),ot=m(0),pt=0,yt=0;if(P<m(0)|K<m(0))r=0;else{Z=A,at=a,ot=u,O=S;t:{if(!q||(et=I[q+20>>2],O=S,et==m(0)))break t;pt=+et,at=Gr(+a,pt,0,0),ot=Gr(+u,pt,0,0),Z=Gr(+A,pt,0,0),O=Gr(+S,pt,0,0)}et=O,q=0;t:{if((r|0)!=(y|0))break t;if(yt=Z!=Z,q=at!=at,yt|q){q=q&yt;break t}q=m(Ge(m(Z-at)))<m(9999999747378752e-20)}yt=q;t:{if((h|0)!=(k|0))break t;if(W=et!=et,q=ot!=ot,W|q){W=q&W;break t}W=m(Ge(m(et-ot)))<m(9999999747378752e-20)}Y=1,q=1;t:{if(yt)break t;a=m(a-tt);r:{if((r|0)==1)break r;if(r=(r|0)!=2,!(r|y)){if(!(a>=P))break r;break t}if(q=0,!(a<A)|(r|(y|0)!=2|(a!=a|A!=A|P!=P))||(q=1,a>=P))break t}if(y=a!=a,r=P!=P,y|r){q=r&y;break t}q=m(Ge(m(a-P)))<m(9999999747378752e-20)}t:{if(W)break t;a=m(u-dt);r:{if((h|0)==1)break r;if(r=(h|0)!=2,!(r|k)){if(!(a>=K))break r;break t}if(Y=0,!(a<S)|(r|(k|0)!=2|(a!=a|S!=S|K!=K))||(Y=1,a>=K))break t}if(h=a!=a,r=K!=K,h|r){Y=r&h;break t}Y=m(Ge(m(a-K)))<m(9999999747378752e-20)}r=q&Y}return r}function kh(r){var a=0,h=0,u=0,y=0,A=0,k=0,S=0,P=0;if(pi(+r),A=te(1)|0,u=te(0)|0,y=A>>>20&2047,(y|0)==2047)return r=r*1,r/r;if(a=u<<1,k=A<<1|u>>>31,!a&(k|0)==2145386496|k>>>0<2145386496)return!a&(k|0)==2145386496?r*0:r;t:{if(!y){if(y=0,h=u<<12,a=A<<12|u>>>20,(a|0)>0|(a|0)>=0)for(;y=y-1|0,a=a<<1|h>>>31,h=h<<1,!!((a|0)>0|(a|0)>=0););a=1-y|0,h=a&31,(a&63)>>>0>=32?(a=u<<h,u=0):(a=(1<<h)-1&u>>>32-h|A<<h,u=u<<h);break t}a=A&1048575|1048576}if(h=u,(y|0)>1023){for(;;){t:{if(u=a+-1048576|0,(u|0)<0||(a=u,a|h))break t;return r*0}if(a=a<<1|h>>>31,h=h<<1,y=y-1|0,!((y|0)>1023))break}y=1023}t:{if(u=a+-1048576|0,(u|0)<0||(a=u,a|h))break t;return r*0}if((a|0)==1048575|a>>>0<1048575)for(;y=y-1|0,u=a>>>0<524288,k=a<<1|h>>>31,h=h<<1,a=k,!!u;);return P=A&-2147483648,k=a+-1048576|y<<20,S=h,A=a,S=h,u=1-y|0,h=u&31,(u&63)>>>0>=32?(a=0,u=A>>>h|0):(a=A>>>h|0,u=((1<<h)-1&A)<<32-h|S>>>h),h=(y|0)>0,Dt(0,(h?S:u)|0),Dt(1,(h?k:a)|P),+Ae()}function wh(r){var a=0,h=0,u=0,y=0,A=0;u=l[1416],a=r+7&-8,h=u+a|0;t:{r:{if(h>>>0<=u>>>0&&a||h>>>0>h2()<<16>>>0&&!(TE(h|0)|0))break r;l[1416]=h;break t}l[1781]=48,u=-1}if((u|0)!=-1){a=r+u|0,h=a-16|0,l[h+12>>2]=16,l[h>>2]=16,r=l[1748],r?A=l[r+8>>2]:A=0;t:{r:{if((A|0)==(u|0)){if(y=u-(l[u-4>>2]&-2)|0,A=l[y-4>>2],l[r+8>>2]=a,r=y-(A&-2)|0,a=-16,!(ft[(r+l[r>>2]|0)-4|0]&1))break r;a=l[r+4>>2],l[a+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=a,h=h-r|0,l[r>>2]=h;break t}l[u+12>>2]=16,l[u>>2]=16,l[u+8>>2]=a,l[u+4>>2]=r,l[1748]=u,a=16}r=a+u|0,h=h-r|0,l[r>>2]=h}l[((h&-4)+r|0)-4>>2]=h|1,a=l[r>>2]-8|0;t:{if(a>>>0<=127){h=(a>>>3|0)-1|0;break t}if(y=mr(a),h=((a>>>29-y^4)-(y<<2)|0)+110|0,a>>>0<=4095)break t;h=((a>>>30-y^2)-(y<<1)|0)+71|0,h=h>>>0>=63?63:h}a=h<<4,l[r+4>>2]=a+5968,a=a+5976|0,l[r+8>>2]=l[a>>2],l[a>>2]=r,l[l[r+8>>2]+4>>2]=r,a=l[1750],y=l[1751],r=h&31,(h&63)>>>0>=32?(h=1<<r,A=0):(A=1<<r,h=A-1&1>>>32-r),l[1750]=A|a,l[1751]=h|y}return(u|0)!=-1}function Tp(r,a,h){var u=0,y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0;t:{r:{i:{e:{s:{n:{a:{o:{l:{c:{if(a){if(!h)break c;break l}r=(r>>>0)/(h>>>0)|0,Ni=0;break t}if(!r)break o;break a}if(!(h-1&h))break n;A=(mr(h)+33|0)-mr(a)|0,k=0-A|0;break e}r=(a>>>0)/0|0,Ni=0;break t}if(u=32-mr(a)|0,u>>>0<31)break s;break i}if((h|0)==1)break r;A=h?31-mr(h-1^h)|0:32,h=A&31,(A&63)>>>0>=32?r=a>>>h|0:(u=a>>>h|0,r=((1<<h)-1&a)<<32-h|r>>>h),Ni=u;break t}A=u+1|0,k=63-u|0}if(u=A&63,y=u&31,u>>>0>=32?(u=0,S=a>>>y|0):(u=a>>>y|0,S=((1<<y)-1&a)<<32-y|r>>>y),k=k&63,y=k&31,k>>>0>=32?(a=r<<y,r=0):(a=(1<<y)-1&r>>>32-y|a<<y,r=r<<y),A)for(k=h-1|0,dt=(k|0)==-1?-1:0;P=u<<1|S>>>31,u=S<<1|a>>>31,y=dt-(P+(u>>>0>k>>>0)|0)>>31,K=h&y,S=u-K|0,u=P-(u>>>0<K>>>0)|0,a=a<<1|r>>>31,r=tt|r<<1,tt=y&1,A=A-1|0,!!A;);Ni=a<<1|r>>>31,r=tt|r<<1;break t}r=0,a=0}Ni=a}return r}function Qo(r,a,h){var u=m(0),y=m(0);t:{r:{i:{if((a&-2)==2){if(a=l[r+188>>2],u=I[r+188>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=l[r+196>>2],u=I[r+196>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u))break i;break r}if(a=l[r+192>>2],u=I[r+192>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(u=I[r+196>>2],a=l[r+196>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242))break i;if(u!=u)break r}u=m(0);i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(Yt),l[r+4>>2]-1|0){case 0:break t;case 1:break e;default:break i}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break t}y=m(m(u*h)*m(.009999999776482582))}return y}u=m(0)}return u}function kp(r,a){var h=0,u=0,y=0,A=0,k=0,S=0;for(h=Et-320|0,Et=h,u=Ui(h,0,288),h=u,l[h+16>>2]=2143289344,l[h+20>>2]=2143289344,Ui(h+24|0,0,49),l[h+80>>2]=2143289344,A=h+288|0,y=h+96|0;h=y,l[h+16>>2]=-1082130432,l[h+20>>2]=-1082130432,l[h+8>>2]=0,l[h+12>>2]=0,l[h>>2]=-1082130432,l[h+4>>2]=-1082130432,y=h+24|0,(A|0)!=(y|0););if(l[u+312>>2]=-1082130432,l[u+316>>2]=-1082130432,l[u+304>>2]=0,l[u+308>>2]=0,l[u+296>>2]=-1082130432,l[u+300>>2]=-1082130432,l[u+288>>2]=2143289344,l[u+292>>2]=2143289344,Fi(r+228|0,u,320),l[r+244>>2]=0,l[r+248>>2]=0,ft[r+4|0]=At[r+4|0]|1,y=l[r+556>>2],k=l[r+560>>2],(y|0)!=(k|0))for(;h=l[y>>2],l[h+552>>2]!=(r|0)&&(A=l[r+568>>2],h=Cp(l[A>>2],At[A+8|0],h,r,S,a),l[y>>2]=h,l[h+552>>2]=r,h=l[y>>2]),kp(h,a),S=S+1|0,y=y+4|0,(k|0)!=(y|0););Et=u+320|0}function Sh(r,a,h){var u=0,y=0,A=0,k=0;if(u=r+4|0,y=(u+a|0)-1&0-a,a=l[r>>2],y+h>>>0<=(a+r|0)-4>>>0){A=l[r+4>>2],l[A+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=A,(u|0)!=(y|0)&&(y=y-u|0,A=r-(l[r-4>>2]&-2)|0,u=y+l[A>>2]|0,l[A>>2]=u,l[(A+(u&-4)|0)-4>>2]=u,r=r+y|0,a=a-y|0,l[r>>2]=a);t:{if(h+24>>>0<=a>>>0){u=(r+h|0)+8|0,a=(a-h|0)-8|0,l[u>>2]=a,l[(u+(a&-4)|0)-4>>2]=a|1,y=l[u>>2]-8|0;r:{if(y>>>0<=127){a=(y>>>3|0)-1|0;break r}if(A=mr(y),a=((y>>>29-A^4)-(A<<2)|0)+110|0,y>>>0<=4095)break r;a=((y>>>30-A^2)-(A<<1)|0)+71|0,a=a>>>0>=63?63:a}y=a<<4,l[u+4>>2]=y+5968,y=y+5976|0,l[u+8>>2]=l[y>>2],l[y>>2]=u,l[l[u+8>>2]+4>>2]=u,y=l[1750],A=l[1751],u=a&31,(a&63)>>>0>=32?(a=1<<u,u=0):(k=1<<u,a=k-1&1>>>32-u,u=k),l[1750]=u|y,l[1751]=a|A,a=h+8|0,l[r>>2]=a,l[((a&-4)+r|0)-4>>2]=a;break t}l[(r+a|0)-4>>2]=a}r=r+4|0}else r=0;return r}function OE(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,A=0;y=Et-320|0,Et=y,r=l[r>>2];t:{if(l[r+560>>2]==l[r+556>>2]||(u=l[a>>2],a=l[u+552>>2],!Op(r,u)))break t;if((r|0)==(a|0)){for(h=Ui(y,0,288),a=h,l[a+16>>2]=2143289344,l[a+20>>2]=2143289344,Ui(a+24|0,0,49),l[a+80>>2]=2143289344,A=a+288|0,a=a+96|0;l[a+16>>2]=-1082130432,l[a+20>>2]=-1082130432,l[a+8>>2]=0,l[a+12>>2]=0,l[a>>2]=-1082130432,l[a+4>>2]=-1082130432,a=a+24|0,(A|0)!=(a|0););l[h+312>>2]=-1082130432,l[h+316>>2]=-1082130432,l[h+304>>2]=0,l[h+308>>2]=0,l[h+296>>2]=-1082130432,l[h+300>>2]=-1082130432,l[h+288>>2]=2143289344,l[h+292>>2]=2143289344,Fi(u+228|0,h,320),l[u+552>>2]=0}for(;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}Et=y+320|0}function wp(r){r=r|0;var a=0,h=0,u=0,y=0,A=0,k=0,S=0;if(r){if(k=Et-32|0,Et=k,a=l[r>>2],u=l[a+552>>2],u&&(Op(u,a),l[a+552>>2]=0),u=l[a+556>>2],h=l[a+560>>2],(u|0)!=(h|0))for(h=h-u>>2,y=h>>>0<=1?1:h,h=0;l[l[(h<<2)+u>>2]+552>>2]=0,h=h+1|0,(y|0)!=(h|0););l[a+560>>2]=u,h=a+564|0;t:{if(l[h>>2]==(u|0)||(h=Na(k+8|0,0,0,h),y=l[a+556>>2],A=l[a+560>>2]-y|0,u=l[h+4>>2]-A|0,A=Ps(u,y,A),y=l[a+556>>2],l[a+556>>2]=A,l[h+4>>2]=y,A=l[a+560>>2],l[a+560>>2]=l[h+8>>2],l[h+8>>2]=A,S=l[a+564>>2],l[a+564>>2]=l[h+12>>2],l[h>>2]=y,l[h+12>>2]=S,(y|0)!=(A|0)&&(l[h+8>>2]=A+((y-A|0)+3&-4)),!y))break t;gi(y),u=l[a+556>>2]}u&&(l[a+560>>2]=u,gi(u)),gi(a),a=l[r+8>>2],l[r+8>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),a=l[r+4>>2],l[r+4>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),Et=k+32|0,gi(r)}}function ME(r){r=r|0;var a=0,h=0,u=0;u=Et-624|0,Et=u,a=l[r+4>>2],l[r+4>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),a=l[r+8>>2],l[r+8>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a);t:{if(r=l[r>>2],l[r+560>>2]==l[r+556>>2]){if(l[r+552>>2])break t;a=yp(u+32|0,l[r+568>>2]),h=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=h,h=l[a+20>>2],l[r+16>>2]=l[a+16>>2],l[r+20>>2]=h,h=l[a+12>>2],l[r+8>>2]=l[a+8>>2],l[r+12>>2]=h,Fi(r+24|0,a+24|0,204),Fi(r+228|0,a+228|0,328),h=l[r+556>>2],h&&(l[r+560>>2]=h,gi(h)),l[r+556>>2]=l[a+556>>2],l[r+560>>2]=l[a+560>>2],l[r+564>>2]=l[a+564>>2],l[r+584>>2]=l[a+584>>2],h=l[a+580>>2],l[r+576>>2]=l[a+576>>2],l[r+580>>2]=h,h=l[a+572>>2],l[r+568>>2]=l[a+568>>2],l[r+572>>2]=h,Et=u+624|0;return}l[u+16>>2]=3301,sr(r,u+16|0),qi(),he()}l[u>>2]=2047,sr(r,u),qi(),he()}function Sp(){LE(7084,3067),_E(7085,2480,1,1,0),ls(7086,2140,1,-128,127),ls(7087,2133,1,-128,127),ls(7088,2131,1,0,255),ls(7089,1287,2,-32768,32767),ls(7090,1278,2,0,65535),ls(7091,1316,4,-2147483648,2147483647),ls(7092,1307,4,0,-1),ls(7093,2659,4,-2147483648,2147483647),ls(7094,2650,4,0,-1),i2(7095,1777,-2147483648,2147483647),i2(7096,1776,0,-1),dp(7097,1770,4),dp(7098,3015,8),up(7099,2677),up(7100,3904),bh(7101,4,2664),bh(7102,2,2689),bh(7103,4,2704),RE(7104,2485),Ei(7105,0,3835),Ei(7106,0,3937),Ei(7107,1,3865),Ei(7108,2,3467),Ei(7109,3,3498),Ei(7110,4,3538),Ei(7111,5,3567),Ei(7112,4,3974),Ei(7113,5,4004),Ei(7106,0,3669),Ei(7107,1,3636),Ei(7108,2,3735),Ei(7109,3,3701),Ei(7110,4,3802),Ei(7111,5,3768),Ei(7114,6,3605),Ei(7115,7,4043)}function Ps(r,a,h){var u=0,y=0;t:{if((r|0)==(a|0))break t;if(y=r+h|0,a-y>>>0<=0-(h<<1)>>>0)return Fi(r,a,h);u=(r^a)&3;r:{i:{if(r>>>0<a>>>0){if(u){u=r;break r}if(!(r&3)){u=r;break i}for(u=r;;){if(!h)break t;if(ft[u|0]=At[a|0],a=a+1|0,h=h-1|0,u=u+1|0,!(u&3))break}break i}e:{if(u)break e;if(y&3)for(;;){if(!h)break t;if(h=h-1|0,u=h+r|0,ft[u|0]=At[a+h|0],!(u&3))break}if(h>>>0<=3)break e;for(;h=h-4|0,l[h+r>>2]=l[a+h>>2],h>>>0>3;);}if(!h)break t;for(;h=h-1|0,ft[h+r|0]=At[a+h|0],!!h;);break t}if(h>>>0<=3)break r;for(;l[u>>2]=l[a>>2],a=a+4|0,u=u+4|0,h=h-4|0,h>>>0>3;);}if(!h)break t;for(;ft[u|0]=At[a|0],u=u+1|0,a=a+1|0,h=h-1|0,!!h;);}return r}function Rp(r,a,h,u){t:switch(a-9|0){case 0:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=l[a>>2];return;case 6:a=l[h>>2],l[h>>2]=a+4,a=Fr[a>>1],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 7:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=Nn[a>>1],l[r+4>>2]=0;return;case 8:a=l[h>>2],l[h>>2]=a+4,a=ft[a|0],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 9:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=At[a|0],l[r+4>>2]=0;return;case 16:a=l[h>>2]+7&-8,l[h>>2]=a+8,Ne[r>>3]=Ne[a>>3];return;case 17:Pt[u|0](r,h);default:return;case 1:case 4:case 14:a=l[h>>2],l[h>>2]=a+4,a=l[a>>2],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 2:case 5:case 11:case 15:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=l[a>>2],l[r+4>>2]=0;return;case 3:case 10:case 12:case 13:break t}a=l[h>>2]+7&-8,l[h>>2]=a+8,h=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=h}function _p(r,a,h,u){var y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=m(0),O=m(0),W=m(0),Y=0,Z=m(0);t:{if(a==0||(et=I[r+248>>2],O=I[r+244>>2],W=I[r+232>>2],P=+I[r+228>>2],y=At[r+4|0]&8,A=y>>>3|0,Y=r,Z=Gr(P,a,0,A),I[Y+228>>2]=Z,K=+W,Y=r,Z=Gr(K,a,0,A),I[Y+232>>2]=Z,tt=+O,k=kh(tt*a),A=k==k&Ge(k)<1e-4,S=!(A|k!=k?A:Ge(k+-1)<1e-4),dt=+et,k=kh(dt*a),A=k==k&Ge(k)<1e-4,q=!(A|k!=k?A:Ge(k+-1)<1e-4),A=0,h=P+h,y=(y|0)!=0,Y=r,Z=m(Gr(h+tt,a,y&S,y&!S)-Gr(h,a,0,y)),I[Y+244>>2]=Z,u=K+u,Y=r,Z=m(Gr(u+dt,a,y&q,y&!q)-Gr(u,a,0,y)),I[Y+248>>2]=Z,y=l[r+560>>2],S=l[r+556>>2],(y|0)==(S|0)))break t;for(y=y-S>>2,S=y>>>0<=1?1:y;y=l[r+556>>2],l[r+560>>2]-y>>2>>>0>A>>>0?y=l[y+(A<<2)>>2]:y=0,_p(y,a,h,u),A=A+1|0,(S|0)!=(A|0););}}function Ui(r,a,h){var u=0,y=0,A=0,k=0;t:{if(!h||(ft[r|0]=a,u=r+h|0,ft[u-1|0]=a,h>>>0<3)||(ft[r+2|0]=a,ft[r+1|0]=a,ft[u-3|0]=a,ft[u-2|0]=a,h>>>0<7)||(ft[r+3|0]=a,ft[u-4|0]=a,h>>>0<9)||(u=0-r&3,y=u+r|0,a=Fe(a&255,16843009),l[y>>2]=a,u=h-u&-4,h=u+y|0,l[h-4>>2]=a,u>>>0<9)||(l[y+8>>2]=a,l[y+4>>2]=a,l[h-8>>2]=a,l[h-12>>2]=a,u>>>0<25)||(l[y+24>>2]=a,l[y+20>>2]=a,l[y+16>>2]=a,l[y+12>>2]=a,l[h-16>>2]=a,l[h-20>>2]=a,l[h-24>>2]=a,l[h-28>>2]=a,k=y&4|24,h=u-k|0,h>>>0<32))break t;for(u=Ch(a,0,1,1),A=Ni,a=y+k|0;l[a+24>>2]=u,l[a+28>>2]=A,l[a+16>>2]=u,l[a+20>>2]=A,l[a+8>>2]=u,l[a+12>>2]=A,l[a>>2]=u,l[a+4>>2]=A,a=a+32|0,h=h-32|0,h>>>0>31;);}return r}function gi(r){r=r|0;var a=0,h=0,u=0,y=0,A=0;if(r){a=r-4|0,y=l[a>>2],h=y,u=a,A=l[r-8>>2],r=A&-2,(r|0)!=(A|0)&&(u=a-r|0,h=l[u+4>>2],l[h+8>>2]=l[u+8>>2],l[l[u+8>>2]+4>>2]=h,h=r+y|0),r=a+y|0,a=l[r>>2],(a|0)!=l[(r+a|0)-4>>2]&&(y=l[r+4>>2],l[y+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=y,h=a+h|0),l[u>>2]=h,l[((h&-4)+u|0)-4>>2]=h|1,a=l[u>>2]-8|0;t:{if(a>>>0<=127){r=(a>>>3|0)-1|0;break t}if(h=mr(a),r=((a>>>29-h^4)-(h<<2)|0)+110|0,a>>>0<=4095)break t;r=((a>>>30-h^2)-(h<<1)|0)+71|0,r=r>>>0>=63?63:r}a=r<<4,l[u+4>>2]=a+5968,a=a+5976|0,l[u+8>>2]=l[a>>2],l[a>>2]=u,l[l[u+8>>2]+4>>2]=u,a=l[1750],h=l[1751],u=r&31,(r&63)>>>0>=32?(r=1<<u,y=0):(y=1<<u,r=y-1&1>>>32-u),l[1750]=y|a,l[1751]=r|h}}function $E(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,k=0,S=0,P=0,K=0;u=Et-32|0,Et=u,y=l[r+28>>2],l[u+16>>2]=y,A=l[r+20>>2],l[u+28>>2]=h,l[u+24>>2]=a,a=A-y|0,l[u+20>>2]=a,A=a+h|0,P=2,a=u+16|0;t:{for(;;){r:{i:{e:{if(!t2(wE(l[r+60>>2],a|0,P|0,u+12|0)|0)){if(k=l[u+12>>2],(k|0)==(A|0))break e;if((k|0)>=0)break i;break r}if((A|0)!=-1)break r}a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,l[r+16>>2]=a+l[r+48>>2],r=h;break t}S=l[a+4>>2],K=S>>>0<k>>>0,y=(K<<3)+a|0,S=k-(K?S:0)|0,l[y>>2]=S+l[y>>2],a=(K?12:4)+a|0,l[a>>2]=l[a>>2]-S,A=A-k|0,P=P-K|0,a=y;continue}break}if(l[r+28>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,l[r>>2]=l[r>>2]|32,r=0,(P|0)==2)break t;r=h-l[a+4>>2]|0}return Et=u+32|0,r|0}function NE(r){r=r|0;var a=0,h=0,u=0,y=0,A=0;h=Et-96|0,Et=h,l[h>>2]=r,u=Et-16|0,Et=u,l[u+12>>2]=h,r=Et-144|0,Et=r,r=Fi(r,5520,144),A=h+16|0,a=A,l[r+44>>2]=a,l[r+20>>2]=a,y=-2-a|0,y=y>>>0>=2147483647?2147483647:y,l[r+48>>2]=y,a=a+y|0,l[r+28>>2]=a,l[r+16>>2]=a,Lp(r,2202,h,0,0),y&&(a=l[r+20>>2],ft[a-((a|0)==l[r+16>>2])|0]=0),Et=r+144|0,Et=u+16|0,r=A;t:{if(r&3)for(;;){if(!At[r|0])break t;if(r=r+1|0,!(r&3))break}for(;a=r,r=r+4|0,u=l[a>>2],!((u^-1)&u-16843009&-2139062144););for(;r=a,a=r+1|0,!!At[r|0];);}return r=(r-A|0)+1|0,a=Th(r),a?r=Fi(a,A,r):r=0,Et=h+96|0,r|0}function Lp(r,a,h,u,y){var A=0,k=0,S=0,P=0;A=Et-208|0,Et=A,l[A+204>>2]=h,h=A+160|0,Ui(h,0,40),l[A+200>>2]=l[A+204>>2];t:{if((vp(0,a,A+200|0,A+80|0,h,u,y)|0)<0){y=-1;break t}P=l[r+76>>2]>=0,k=l[r>>2],l[r+72>>2]<=0&&(l[r>>2]=k&-33);r:{i:{e:{if(!l[r+48>>2]){l[r+48>>2]=80,l[r+28>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,S=l[r+44>>2],l[r+44>>2]=A;break e}if(l[r+16>>2])break i}if(h=-1,Gp(r))break r}h=vp(r,a,A+200|0,A+80|0,A+160|0,u,y)}if(S&&(Pt[l[r+36>>2]](r,0,0)|0,l[r+48>>2]=0,l[r+44>>2]=S,l[r+28>>2]=0,a=l[r+20>>2],l[r+16>>2]=0,l[r+20>>2]=0,h=a?h:-1),a=r,r=l[r>>2],l[a>>2]=r|k&32,y=r&32?-1:h,!P)break t}return Et=A+208|0,y}function Jo(r){var a=0,h=m(0),u=0,y=0,A=0,k=0,S=0,P=m(0),K=0;A=Et-16|0,Et=A,a=l[r+12>>2];t:{if(a){P=I[r+520>>2],h=I[r+516>>2];r:{if(At[r+4|0]&32){h=m(Pt[a|0](r,h,P,0));break r}h=m(Pt[a|0](r,h,P))}if(h==h)break t;l[A>>2]=3409,sr(r,A),qi(),he()}r:{i:{if(k=l[r+556>>2],a=l[r+560>>2],(k|0)!=(a|0)){for(a=a-k>>2,K=a>>>0<=1?1:a;;){if(y=l[(S<<2)+k>>2],!l[y+548>>2]){if(a=l[y+24>>2],(a&196608)!=131072){if(a=a>>>13&7,a||(a=l[r+24>>2]>>>10&7),At[y+4|0]&2|(At[r+24|0]&8?(a|0)==5:0))break i;u=u||y}if(S=S+1|0,(K|0)!=(S|0))continue}break}if(u)break r}h=I[r+520>>2];break t}u=y}h=m(Jo(u)+I[u+232>>2])}return Et=A+16|0,h}function Un(r,a,h,u,y,A){var k=0,S=m(0),P=0,K=m(0);k=(l[(a<<2)+4320>>2]<<2)+r|0,S=I[k+216>>2];t:{r:{k=l[k+216>>2];i:{if((k|0)==2139156720)break i;if((k|0)==2140081935)break r;P=4336;e:{if((k|0)!=2141891242){if(S==S)break e;P=4344}switch(K=I[P>>2],S=m(Yt),l[P+4>>2]-1|0){case 0:break r;case 1:break i;default:break t}}if(K=(Dt(2,(k&-1073741825)+536870912|0),Bt()),!(k&1073741824))break r}S=m(m(K*h)*m(.009999999776482582));break t}S=K}u=m(S+m(de(r,a,u)+we(r,a,u)));t:{r:{i:switch(l[y>>2]){case 1:case 2:h=I[A>>2],u=u!=u||h<u?h:u;break r;case 0:break i;default:break t}if(u!=u)break t;l[y>>2]=2}I[A>>2]=u}}function Ie(r,a,h){var u=m(0),y=m(0),A=0,k=m(0);r=r+116|0,A=l[(a<<2)+4288>>2];t:{if((a&-2)==2){a=Ur(r,4,A,2140081935);break t}a=Br(r,A,2140081935)}t:{r:{i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(Yt),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break r}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break i}u=m(m(u*h)*m(.009999999776482582))}if(u>=m(0))return u;if(y=u,u<m(0))break t}k=y==y?y:m(0)}return k}function xe(r,a,h){var u=m(0),y=m(0),A=0,k=m(0);r=r+116|0,A=l[(a<<2)+4304>>2];t:{if((a&-2)==2){a=Ur(r,5,A,2140081935);break t}a=Br(r,A,2140081935)}t:{r:{i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(Yt),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break r}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break i}u=m(m(u*h)*m(.009999999776482582))}if(u>=m(0))return u;if(y=u,u<m(0))break t}k=y==y?y:m(0)}return k}function Cp(r,a,h,u,y,A){var k=0;t:{r:{if(r){i:{if(a&4){A=Pt[r|0](h,u,y,A)|0;break i}A=Pt[r|0](h,u,y)|0}if(A)break r}if(A=ht(588),a=Fi(A,h,552),l[a+564>>2]=0,l[a+556>>2]=0,l[a+560>>2]=0,y=l[h+556>>2],u=l[h+560>>2],(y|0)!=(u|0)){if(k=u-y|0,(k|0)<0)break t;for(r=ht(k),l[a+556>>2]=r,l[a+564>>2]=r+k;l[r>>2]=l[y>>2],r=r+4|0,y=y+4|0,(u|0)!=(y|0););l[a+560>>2]=r}r=l[h+572>>2],l[a+568>>2]=l[h+568>>2],l[a+572>>2]=r,l[a+584>>2]=l[h+584>>2],r=l[h+580>>2],l[a+576>>2]=l[h+576>>2],l[a+580>>2]=r,l[a+552>>2]=0}return A}Ds(),he()}function sr(r,a){var h=0,u=0,y=0;y=Et-16|0,Et=y,l[y+12>>2]=a;t:{r:{if(!r){a=l[y+12>>2];break r}if(a=l[y+12>>2],h=l[r+568>>2],!h)break r;if(u=l[h+4>>2],At[h+8|0]&8){Pt[u|0](h,r,5,0,4284,a)|0;break t}Pt[u|0](h,r,5,4284,a)|0;break t}r:{if(!At[7016]){h=ht(28),l[h+20>>2]=1065353216,l[h+24>>2]=0,l[h+12>>2]=0,l[h+16>>2]=0,l[h>>2]=0,ft[h+8|0]=0,u=1,l[h+4>>2]=1,l[1753]=h,ft[7016]=1,l[1752]=l[1752]+1;break r}if(h=l[1753],u=l[h+4>>2],!(At[h+8|0]&8))break r;Pt[u|0](h,r,5,0,4284,a)|0;break t}Pt[u|0](h,r,5,4284,a)|0}Et=y+16|0}function $a(r,a,h){var u=m(0),y=0,A=m(0);r=r+80|0,y=l[(a<<2)+4304>>2];t:{r:{if((a&-2)==2){a=Ur(r,5,y,2140081935);break r}a=Br(r,y,2140081935)}r:{i:{if((a|0)==2139156720)break i;if((a|0)==2140081935)break t;r=4336;e:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break e;r=4344}switch(u=I[r>>2],A=m(Yt),l[r+4>>2]-1|0){case 0:break t;case 1:break i;default:break r}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break t}A=m(m(u*h)*m(.009999999776482582))}return A}return u}function Os(r,a,h){var u=m(0),y=0,A=m(0);r=r+80|0,y=l[(a<<2)+4288>>2];t:{r:{if((a&-2)==2){a=Ur(r,4,y,2140081935);break r}a=Br(r,y,2140081935)}r:{i:{if((a|0)==2139156720)break i;if((a|0)==2140081935)break t;r=4336;e:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break e;r=4344}switch(u=I[r>>2],A=m(Yt),l[r+4>>2]-1|0){case 0:break t;case 1:break i;default:break r}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break t}A=m(m(u*h)*m(.009999999776482582))}return A}return u}function Ur(r,a,h,u){var y=m(0);a=(a<<2)+r|0,y=I[a>>2],a=l[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y||(a=(h<<2)+r|0,y=I[a>>2],a=l[a>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(a=l[r+24>>2],y=I[r+24>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(y=I[r+32>>2],r=l[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(a=u,y!=y)))break t;a=r}return a}function FE(r,a){r=r|0,a=m(a);var h=0,u=0,y=0;if(h=Et-16|0,Et=h,r=l[r>>2],!(a>=m(0))){l[h>>2]=2263,u=Et-16|0,Et=u,l[u+12>>2]=h;t:{if(r)break t;if(At[7016]){r=l[1753];break t}r=ht(28),l[r+20>>2]=1065353216,l[r+24>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r>>2]=0,ft[r+8|0]=0,l[r+4>>2]=1,l[1753]=r,ft[7016]=1,l[1752]=l[1752]+1}y=l[r+4>>2];t:{if(At[r+8|0]&8){Pt[y|0](r,0,5,0,4284,h)|0;break t}Pt[y|0](r,0,5,4284,h)|0}Et=u+16|0,qi(),he()}I[r+20>>2]=a==m(0)?m(0):a,Et=h+16|0}function Ip(r,a,h,u,y){var A=0,k=0,S=m(0),P=0;A=2,k=l[r+24>>2]>>>2&3;t:{r:{i:{if(!(!l[r+552>>2]|(a|0)!=2)){a=0,A=3;e:switch(k-2|0){case 0:break t;case 1:break e;default:break i}A=2;break t}if(a=0,k>>>0>1)break r}a=A}A=k}h=Zp(r,A,h),u=Zp(r,a,u),S=de(r,A,y),k=r+228|0,P=A<<2,I[k+(l[P+4288>>2]<<2)>>2]=h+S,S=we(r,A,y),I[k+(l[P+4304>>2]<<2)>>2]=h+S,h=de(r,a,y),A=a<<2,I[k+(l[A+4288>>2]<<2)>>2]=u+h,h=we(r,a,y),I[k+(l[A+4304>>2]<<2)>>2]=u+h}function UE(r,a,h,u,y,A){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),A=A|0;var k=0,S=0,P=0;k=Et-48|0,Et=k,P=l[a+8>>2];t:{if(ft[7052]&1){a=l[1762];break t}a=hp(5,4480)|0,ft[7052]=1,l[1762]=a}l[k+40>>2]=A,I[k+32>>2]=y,l[k+24>>2]=u,I[k+16>>2]=h,S=+yE(a|0,P|0,2922,k+12|0,k+16|0);t:{if(S<4294967296&S>=0){a=~~S>>>0;break t}a=0}u=l[k+12>>2],A=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=A,A=l[a+12>>2],l[r+8>>2]=l[a+8>>2],l[r+12>>2]=A,vE(u|0),Et=k+48|0}function BE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,k=0;if(u=Et-32|0,Et=u,y=l[a>>2],y>>>0<2147483632){t:{r:{if(y>>>0>=11){A=(y|15)+1|0,k=ht(A),l[u+16>>2]=A|-2147483648,l[u+8>>2]=k,l[u+12>>2]=y,A=y+k|0;break r}if(ft[u+19|0]=y,k=u+8|0,A=k+y|0,!y)break t}Fi(k,a+4|0,y)}return ft[A|0]=0,l[u>>2]=h,Pt[r|0](u+24|0,u+8|0,u),mE(l[u+24>>2]),r=l[u+24>>2],Ma(r|0),Ma(l[u>>2]),ft[u+19|0]<0&&gi(l[u+8>>2]),Et=u+32|0,r|0}Ds(),he()}function hi(r,a,h){var u=0,y=0,A=0;if(!(At[r|0]&32))t:{u=a,a=r,r=l[a+16>>2];r:{if(!r){if(Gp(a))break r;r=l[a+16>>2]}if(A=l[a+20>>2],r-A>>>0<h>>>0){Pt[l[a+36>>2]](a,u,h)|0;break t}i:{if(l[a+80>>2]<0)break i;for(r=h;;){if(y=r,!r)break i;if(r=y-1|0,At[u+r|0]==10)break}if(Pt[l[a+36>>2]](a,u,y)>>>0<y>>>0)break r;u=u+y|0,h=h-y|0,A=l[a+20>>2]}Fi(A,u,h),l[a+20>>2]=l[a+20>>2]+h}}}function Rh(r,a,h){var u=0,y=0,A=0;u=Et-16|0,Et=u,y=r+24|0,Pt[a|0](u+8|0,y),A=l[u+12>>2];t:{if((l[l[u+8>>2]>>2]&7<<A)>>A==(h|0))break t;for(Pt[a|0](u+8|0,y),a=l[u+8>>2],y=a,A=l[a>>2],a=l[u+12>>2],l[y>>2]=A&(7<<a^-1)|(h&7)<<a;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}Et=u+16|0}function Br(r,a,h){var u=m(0);a=(a<<2)+r|0,u=I[a>>2],a=l[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=l[r+28>>2],u=I[r+28>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u)||(u=I[r+32>>2],r=l[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(a=h,u!=u)))break t;a=r}return a}function we(r,a,h){var u=m(0),y=0;r=r+44|0,y=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Ur(r,5,y,2140081935);break t}r=Br(r,y,2140081935)}t:{if((r|0)!=2139156720){if((r|0)==2140081935|(r|0)==2141891242)break t;if(u=(Dt(2,r),Bt()),u!=u)return m(Yt);if(u=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function de(r,a,h){var u=m(0),y=0;r=r+44|0,y=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Ur(r,4,y,2140081935);break t}r=Br(r,y,2140081935)}t:{if((r|0)!=2139156720){if((r|0)==2140081935|(r|0)==2141891242)break t;if(u=(Dt(2,r),Bt()),u!=u)return m(Yt);if(u=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function GE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,k=0,S=0;return y=l[r+84>>2],A=l[y>>2],u=l[y+4>>2],S=l[r+28>>2],k=l[r+20>>2]-S|0,k=u>>>0<k>>>0?u:k,k&&(Fi(A,S,k),A=k+l[y>>2]|0,l[y>>2]=A,u=l[y+4>>2]-k|0,l[y+4>>2]=u),u=h>>>0>u>>>0?u:h,u&&(Fi(A,a,u),A=u+l[y>>2]|0,l[y>>2]=A,l[y+4>>2]=l[y+4>>2]-u),ft[A|0]=0,a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,h|0}function Se(r,a){var h=m(0),u=0;r=r+152|0,u=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Ur(r,5,u,2140081935);break t}r=Br(r,u,2140081935)}h=m(0);t:{if((r|0)==2139156720||(h=m(0),(r|0)==2140081935))break t;r:{if((r|0)==2141891242||(h=(Dt(2,r),Bt()),h!=h))break r;h=(Dt(2,(r&-1073741825)+536870912|0),Bt());break t}h=m(Yt)}return ce(h,m(0))}function fe(r,a){var h=m(0),u=0;r=r+152|0,u=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Ur(r,4,u,2140081935);break t}r=Br(r,u,2140081935)}h=m(0);t:{if((r|0)==2139156720||(h=m(0),(r|0)==2140081935))break t;r:{if((r|0)==2141891242||(h=(Dt(2,r),Bt()),h!=h))break r;h=(Dt(2,(r&-1073741825)+536870912|0),Bt());break t}h=m(Yt)}return ce(h,m(0))}function HE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=m(0);u=2,a=l[a>>2]+(h<<2)|0,A=I[a+116>>2];t:{r:{if(a=l[a+116>>2],(a|0)!=2139156720){if(y=Yt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(A!=A){u=0;break t}u=a&1073741824?2:1,y=(Dt(2,(a&-1073741825)+536870912|0),+Bt())}Ne[r+8>>3]=y,l[r>>2]=u}function VE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=m(0);u=2,a=l[a>>2]+(h<<2)|0,A=I[a+80>>2];t:{r:{if(a=l[a+80>>2],(a|0)!=2139156720){if(y=Yt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(A!=A){u=0;break t}u=a&1073741824?2:1,y=(Dt(2,(a&-1073741825)+536870912|0),+Bt())}Ne[r+8>>3]=y,l[r>>2]=u}function WE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=m(0);u=2,a=l[a>>2]+(h<<2)|0,A=I[a+44>>2];t:{r:{if(a=l[a+44>>2],(a|0)!=2139156720){if(y=Yt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(A!=A){u=0;break t}u=a&1073741824?2:1,y=(Dt(2,(a&-1073741825)+536870912|0),+Bt())}Ne[r+8>>3]=y,l[r>>2]=u}function Gr(r,a,h,u){var y=0,A=0,k=0;r=r*a,y=kh(r),y=y<0?y+1:y,k=y!=y;t:{if(!(k|!(Ge(y)<1e-4))){r=r-y;break t}r:{if(y!=y){r=r-y;break r}if(r=r-y,!(Ge(y+-1)<1e-4))break r;r=r+1;break t}if(h){r=r+1;break t}if(u)break t;A=0;r:{if(k||(A=1,y>.5))break r;A=Ge(y+-.5)<1e-4?1:0}r=r+A}return r!=r|a!=a?m(Yt):m(r/a)}function xp(r,a){var h=m(0);t:{if((a|0)!=2139156720){if((a|0)!=2140081935){if((a|0)!=2141891242)break t;l[r>>2]=2143289344,l[r+4>>2]=3;return}l[r>>2]=0,l[r+4>>2]=1;return}l[r>>2]=0,l[r+4>>2]=2;return}if(h=(Dt(2,a),Bt()),h!=h){l[r>>2]=2143289344,l[r+4>>2]=0;return}l[r+4>>2]=a&1073741824?2:1,l[r>>2]=(a&-1073741825)+536870912}function Dp(r){var a=0,h=0,u=0;h=l[r+24>>2];t:{if(!(h&8)||(a=1,(h&7168)==5120)||(a=0,u=l[r+560>>2],h=l[r+556>>2],(u|0)==(h|0)))break t;for(r=u-h>>2,u=r>>>0<=1?1:r,r=0;;){if(a=l[l[h+(r<<2)>>2]+24>>2],a=(a&196608)!=131072&(a&57344)==40960,a)break t;if(r=r+1|0,(u|0)==(r|0))break}}return a}function jE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+220>>2];t:{r:{if(a=l[a+220>>2],(a|0)!=2139156720){if(u=Yt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ne[r+8>>3]=u,l[r>>2]=a}function KE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+200>>2];t:{r:{if(a=l[a+200>>2],(a|0)!=2139156720){if(u=Yt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ne[r+8>>3]=u,l[r>>2]=a}function YE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+204>>2];t:{r:{if(a=l[a+204>>2],(a|0)!=2139156720){if(u=Yt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ne[r+8>>3]=u,l[r>>2]=a}function zE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+208>>2];t:{r:{if(a=l[a+208>>2],(a|0)!=2139156720){if(u=Yt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ne[r+8>>3]=u,l[r>>2]=a}function XE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+212>>2];t:{r:{if(a=l[a+212>>2],(a|0)!=2139156720){if(u=Yt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ne[r+8>>3]=u,l[r>>2]=a}function ZE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+216>>2];t:{r:{if(a=l[a+216>>2],(a|0)!=2139156720){if(u=Yt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ne[r+8>>3]=u,l[r>>2]=a}function qE(r,a){r=r|0,a=a|0;var h=0;if(h=Et-16|0,Et=h,r=l[r>>2],(a|0)<6){Et=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+260|0,(At[r+300|0]&3)==2)break t;a=r+252|0;break t;case 1:if(a=r+252|0,(At[r+300|0]&3)==2)break t;a=r+260|0;break t;default:break r}a=(r+(a<<2)|0)+252|0}return+I[a>>2]}l[h>>2]=1872,sr(r,h),qi(),he()}function QE(r,a){r=r|0,a=a|0;var h=0;if(h=Et-16|0,Et=h,r=l[r>>2],(a|0)<6){Et=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+276|0,(At[r+300|0]&3)==2)break t;a=r+268|0;break t;case 1:if(a=r+268|0,(At[r+300|0]&3)==2)break t;a=r+276|0;break t;default:break r}a=(r+(a<<2)|0)+268|0}return+I[a>>2]}l[h>>2]=1872,sr(r,h),qi(),he()}function JE(r,a){r=r|0,a=a|0;var h=0;if(h=Et-16|0,Et=h,r=l[r>>2],(a|0)<6){Et=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+292|0,(At[r+300|0]&3)==2)break t;a=r+284|0;break t;case 1:if(a=r+284|0,(At[r+300|0]&3)==2)break t;a=r+292|0;break t;default:break r}a=(r+(a<<2)|0)+284|0}return+I[a>>2]}l[h>>2]=1872,sr(r,h),qi(),he()}function tT(r,a){r=r|0,a=a|0;var h=0,u=m(0),y=m(0);u=m(Yt),a=l[a>>2],y=I[a+40>>2],a=l[a+40>>2],h=3;t:{if((a|0)==2141891242)break t;if((a|0)==2140081935){u=m(0),h=1;break t}if((a|0)==2139156720){u=m(0),h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),h=a&1073741824?2:1}l[r>>2]=h,Ne[r+8>>3]=u}function Hr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Ge(r))==m(cp)|r!=r||(a=2139156720,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(Dt(2,(Zi(r),te(2)&-2147483648|1602224127)),Bt()),a=(Zi(r>m(0xffffff0000000000)||r<m(-0xffffff0000000000)?h:r),te(2)-536870912|1073741824)}return a}function vr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Ge(r))==m(cp)|r!=r||(a=2140081935,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(Dt(2,(Zi(r),te(2)&-2147483648|1610612735)),Bt()),a=(Zi(r>m(36893485948395848e3)||r<m(-36893485948395848e3)?h:r),te(2)-536870912|0)}return a}function eT(r,a){r=r|0,a=a|0;var h=m(0),u=m(0);r=l[r>>2]+(a<<2)|0,u=I[r+188>>2];t:{r:{if(r=l[r+188>>2],(r|0)==2139156720|(r|0)==2140081935)break r;if(h=m(Yt),(r|0)==2141891242|u!=u)break t;if((r|0)==2139156720)break r;return m((Dt(2,(r&-1073741825)+536870912|0),Bt()))}h=m(0)}return m(h)}function iT(r,a,h,u,y,A){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),A=A|0;var k=0,S=0;return k=Et-16|0,Et=k,S=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(S=l[S+l[a>>2]>>2]),Pt[S|0](k,a,h,u,y,A),r=ht(16),a=l[k+12>>2],l[r+8>>2]=l[k+8>>2],l[r+12>>2]=a,a=l[k+4>>2],l[r>>2]=l[k>>2],l[r+4>>2]=a,Et=k+16|0,r|0}function Pp(r,a){t:{if(a){a=Jp(l[a>>2]);break t}r:{if(At[7016]){a=l[1753];break r}a=ht(28),l[a+20>>2]=1065353216,l[a+24>>2]=0,l[a+12>>2]=0,l[a+16>>2]=0,l[a>>2]=0,ft[a+8|0]=0,l[a+4>>2]=1,l[1753]=a,ft[7016]=1,l[1752]=l[1752]+1}a=Jp(a)}return l[r+4>>2]=0,l[r+8>>2]=0,l[r>>2]=a,l[a>>2]=r,r}function rT(r,a,h){r=r|0,a=a|0,h=+h;var u=0,y=0;t:{if(r=l[r>>2],a=r+(a<<2)|0,y=l[a+152>>2],u=vr(m(h)),(y|0)==(u|0))break t;for(l[a+152>>2]=u;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function sT(r,a,h){r=r|0,a=a|0,h=+h;var u=0,y=0;t:{if(r=l[r>>2],a=r+(a<<2)|0,y=l[a+188>>2],u=vr(m(h)),(y|0)==(u|0))break t;for(l[a+188>>2]=u;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function nT(r,a){r=r|0,a=a|0;var h=0,u=m(0);r=l[r>>2]+(a<<2)|0,u=I[r+152>>2];t:{r:{if(r=l[r+152>>2],(r|0)==2139156720|(r|0)==2140081935)break r;if(h=Yt,(r|0)==2141891242|u!=u)break t;if((r|0)==2139156720)break r;return Dt(2,(r&-1073741825)+536870912|0),+Bt()}h=0}return+h}function aT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>20&3)==(a|0))break t;for(l[r+24>>2]=h&-3145729|a<<20&3145728;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Bn(r,a,h){var u=0,y=0,A=0;t:{if(!a){u=r;break t}for(;u=Tp(r,a,10),y=Ni,r=Ch(u,y,246,0)+r|0,h=h-1|0,ft[h|0]=r|48,A=a>>>0>9,r=u,a=y,!!A;);}if(u)for(;h=h-1|0,r=(u>>>0)/10|0,ft[h|0]=Fe(r,246)+u|48,a=u>>>0>9,u=r,!!a;);return h}function oT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>22&1)==(a|0))break t;for(l[r+24>>2]=h&-4194305|a<<22&4194304;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function lT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>18&3)==(a|0))break t;for(l[r+24>>2]=h&-786433|a<<18&786432;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function cT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>16&3)==(a|0))break t;for(l[r+24>>2]=h&-196609|a<<16&196608;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function hT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+224>>2],u==y|u!=u&y!=y)break t;for(I[r+224>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(ft[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function dT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+28>>2],u==y|u!=u&y!=y)break t;for(I[r+28>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(ft[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function uT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+32>>2],u==y|u!=u&y!=y)break t;for(I[r+32>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(ft[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function fT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+36>>2],u==y|u!=u&y!=y)break t;for(I[r+36>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(ft[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function pT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>4&7)==(a|0))break t;for(l[r+24>>2]=h&-113|a<<4&112;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function gT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>2&3)==(a|0))break t;for(l[r+24>>2]=h&-13|a<<2&12;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function mT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=At[r+4|0],((h&2)>>>1|0)==(a|0))break t;for(ft[r+4|0]=h&253|(a?2:0);;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function vT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;return u=Et-16|0,Et=u,y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Pt[y|0](u,a,h),r=ht(16),a=l[u+12>>2],l[r+8>>2]=l[u+8>>2],l[r+12>>2]=a,a=l[u+4>>2],l[r>>2]=l[u>>2],l[r+4>>2]=a,Et=u+16|0,r|0}function Op(r,a){var h=0,u=0;t:{r:{if(h=l[r+556>>2],u=l[r+560>>2],(h|0)==(u|0))break r;for(;;){if(l[h>>2]==(a|0))break r;if(h=h+4|0,(u|0)==(h|0))break}break t}if((h|0)==(u|0))break t;return a=h+4|0,Ps(h,a,u-a|0),l[r+560>>2]=u-4,1}return 0}function yT(r){r=r|0;var a=0,h=0;if(h=Et-16|0,Et=h,r=l[r>>2],l[r+8>>2]){for(;a=At[r+4|0],!!(!(a&4)&&(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],r)););Et=h+16|0;return}l[h>>2]=1024,sr(r,h),qi(),he()}function Mp(r,a){var h=0,u=0,y=0;if(pi(+r),u=te(1)|0,y=te(0)|0,h=u>>>20&2047,(h|0)!=2047){if(!h)return r==0?h=0:(r=Mp(r*18446744073709552e3,a),h=l[a>>2]+-64|0),l[a>>2]=h,r;l[a>>2]=h-1022,Dt(0,y|0),Dt(1,u&-2146435073|1071644672),r=+Ae()}return r}function bT(r,a){r=r|0,a=a|0;var h=0,u=0;return h=Et-16|0,Et=h,u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](h,a),r=ht(16),a=l[h+12>>2],l[r+8>>2]=l[h+8>>2],l[r+12>>2]=a,a=l[h+4>>2],l[r>>2]=l[h>>2],l[r+4>>2]=a,Et=h+16|0,r|0}function tl(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+184>>2]==(h|0))break t;for(l[((a<<2)+u|0)+184>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function el(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+192>>2]==(h|0))break t;for(l[((a<<2)+u|0)+192>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Gn(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+176>>2]==(h|0))break t;for(l[((a<<2)+u|0)+176>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function _h(r,a){var h=0,u=0,y=0;t:{if(h=r+24|0,l[h+16>>2]==(a|0))break t;for(u=Pt[9](h)|0,y=a,l[u+16>>2]=y;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function $p(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+92>>2]==(h|0))break t;for(l[((a<<2)+u|0)+92>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Lh(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+20>>2]==(h|0))break t;for(l[((a<<2)+u|0)+20>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Np(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+56>>2]==(h|0))break t;for(l[((a<<2)+u|0)+56>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function AT(){for(var r=0,a=0,h=0;a=r<<4,h=a+5968|0,l[a+5972>>2]=h,l[a+5976>>2]=h,r=r+1|0,(r|0)!=64;);wh(48),l[1756]=16,l[1757]=0,mp(),l[1757]=l[1768],l[1768]=7024,l[1769]=198,l[1770]=0,Sp(),l[1770]=l[1768],l[1768]=7076}function nr(r,a){var h=0,u=m(0);r=r+80|0,h=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Ur(r,4,h,2143289344);break t}r=Br(r,h,2143289344)}return(r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242?r=1:(u=(Dt(2,r),Bt()),r=u==u),r}function il(r,a){var h=0,u=m(0);r=r+80|0,h=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Ur(r,5,h,2143289344);break t}r=Br(r,h,2143289344)}return(r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242?r=1:(u=(Dt(2,r),Bt()),r=u==u),r}function Ch(r,a,h,u){var y=0,A=0,k=0,S=0,P=0,K=0;return y=h>>>16|0,A=r>>>16|0,K=Fe(y,A),k=h&65535,S=r&65535,P=Fe(k,S),A=(P>>>16|0)+Fe(A,k)|0,y=(A&65535)+Fe(y,S)|0,Ni=(Fe(a,h)+K|0)+Fe(r,u)+(A>>>16)+(y>>>16)|0,P&65535|y<<16}function Fp(r,a){var h=0,u=0,y=0;u=Et-16|0,Et=u,h=At[r+4|0],y=h&-17,ft[r+4|0]=y;t:{if(a){if(l[r+560>>2]!=l[r+556>>2])break t;h=y|8}else h=h&231;l[r+8>>2]=a,ft[r+4|0]=h,Et=u+16|0;return}l[u>>2]=4128,sr(r,u),qi(),he()}function Up(r){var a=0,h=m(0);a=0;t:{if((l[r+24>>2]&196608)==131072)break t;r:{if(!l[r+552>>2]||(h=I[r+32>>2],h!=h&&(h=I[r+28>>2],!(h>m(0)))))break r;if(a=1,h!=m(0))break t}a=Hn(r)!=m(0)}return a}function mi(r,a,h,u,y){var A=0;if(A=Et-256|0,Et=A,!(y&73728|(h|0)<=(u|0))){if(u=h-u|0,h=u>>>0<256,Ui(A,a&255,h?u:256),!h)for(;hi(r,A,256),u=u-256|0,u>>>0>255;);hi(r,A,u)}Et=A+256|0}function fn(r,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=a- -64|0,y=I[u>>2],u=l[u>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=l[((l[(h<<2)+4304>>2]<<2)+a|0)+44>>2]}xp(r,u)}function pn(r,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=l[a+60>>2],y=I[a+60>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=l[((l[(h<<2)+4288>>2]<<2)+a|0)+44>>2]}xp(r,u)}function Hn(r){var a=m(0),h=m(0);if(!l[r+552>>2])return m(0);a=I[r+36>>2];t:{if(a==a||(a=m(1),ft[l[r+568>>2]+8|0]&1)||(a=m(0),h=I[r+28>>2],!(h<m(0))))break t;a=m(-h)}return a}function Bp(r){var a=0,h=0,u=0;for(u=l[r>>2];;){if(h=ft[u|0],sl(h)){u=u+1|0,l[r>>2]=u,a>>>0<=214748364?(h=h-48|0,a=Fe(a,10),a=(h|0)>(a^2147483647)?-1:h+a|0):a=-1;continue}break}return a}function Na(r,a,h,u){var y=0;l[r+12>>2]=0,l[r+16>>2]=u;t:{if(a){if(a>>>0>=1073741824)break t;y=ht(a<<2)}return l[r>>2]=y,h=(h<<2)+y|0,l[r+8>>2]=h,l[r+12>>2]=(a<<2)+y,l[r+4>>2]=h,r}Mh(),he()}function Gp(r){var a=0;return a=l[r+72>>2],l[r+72>>2]=a-1|a,a=l[r>>2],a&8?(l[r>>2]=a|32,-1):(l[r+4>>2]=0,l[r+8>>2]=0,a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,l[r+16>>2]=a+l[r+48>>2],0)}function ET(r,a,h,u,y,A){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),A=A|0;var k=0;k=Et-16|0,Et=k,a=l[l[a>>2]+4>>2],Pt[l[l[a>>2]+8>>2]](k,a,h,u,y,A),I[r>>2]=Ne[k>>3],I[r+4>>2]=Ne[k+8>>3],Et=k+16|0}function TT(){var r=0,a=0;return a=ht(4),r=ht(28),l[r+20>>2]=1065353216,l[r+24>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r>>2]=0,ft[r+8|0]=0,l[r+4>>2]=1,l[1752]=l[1752]+1,l[a>>2]=r,a|0}function kT(r,a){r=r|0,a=a|0,a=l[a>>2],Ne[r>>3]=I[a+228>>2],Ne[r+8>>3]=I[a+236>>2],Ne[r+16>>3]=I[a+232>>2],Ne[r+24>>3]=I[a+240>>2],Ne[r+32>>3]=I[a+244>>2],Ne[r+40>>3]=I[a+248>>2]}function wT(r,a){r=r|0,a=a|0;var h=0,u=0;return h=Et-48|0,Et=h,u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](h,a),r=Fi(ht(48),h,48),Et=h+48|0,r|0}function ST(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;return y=Et-16|0,Et=y,r=t2(AE(l[r+60>>2],a|0,h|0,u&255,y+8|0)|0),Et=y+16|0,Ni=r?-1:l[y+12>>2],(r?-1:l[y+8>>2])|0}function RT(r,a){r=r|0,a=a|0;var h=0,u=0;h=l[r>>2],r=l[h+556>>2];t:{if(l[h+560>>2]-r>>2>>>0<=a>>>0||(r=l[r+(a<<2)>>2],!r))break t;u=l[r>>2]}return u|0}function _T(r,a,h){if(r=r|0,a=a|0,h=h|0,a>>>0<3){a=1<<a,r=l[r>>2],h?a=a|l[r+12>>2]:a=l[r+12>>2]&(a^-1),l[r+12>>2]=a;return}Ds(),he()}function LT(r,a,h,u,y){r=r|0,a=a|0,h=+h,u=+u,y=y|0;var A=0;A=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(A=l[A+l[a>>2]>>2]),Pt[A|0](a,h,u,y)}function CT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),m(m(Pt[u|0](a,h)))}function Hp(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Pt[y|0](a,h,u)}function Vp(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)|0}function IT(r,a,h,u){r=r|0,a=a|0,h=h|0,u=+u;var y=0;y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Pt[y|0](a,h,u)}function xT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),+Pt[u|0](a,h)}function ht(r){var a=0;r=r||1;t:{for(;;){if(a=Th(r),a)break t;if(a=l[2042],a){Pt[a|0]();continue}break}Ds(),he()}return a}function DT(r,a,h){r=r|0,a=a|0,h=m(h);var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)}function Ms(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)}function gn(r,a){r=r|0,a=a|0;var h=0;return h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),Pt[h|0](a)|0}function Ih(r,a){return Zi(r),(te(2)&2147483647)>>>0<=2139095040?(Zi(a),(te(2)&2147483647)>>>0>2139095040?r:m(pE(r,a))):a}function ce(r,a){return Zi(r),(te(2)&2147483647)>>>0<=2139095040?(Zi(a),(te(2)&2147483647)>>>0>2139095040?r:m(gE(r,a))):a}function Wp(r,a){r=r|0,a=a|0;var h=0;return h=Et-16|0,Et=h,l[h+8>>2]=a,r=Pt[r|0](h+8|0)|0,Ma(l[h+8>>2]),Et=h+16|0,r|0}function PT(r,a,h){r=r|0,a=a|0,h=+h;var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)}function OT(r,a,h,u,y){return h=h|0,u=u|0,y=y|0,h&&(h|0)!=5?s2(5816,u,y)|0:s2(5672,u,y)|0}function jp(r,a){if(!r)return 0;t:{if(!((a&-128)==57216|a>>>0<=127)){l[1781]=25,r=-1;break t}ft[r|0]=a,r=1}return r}function MT(r,a){r=r|0,a=a|0;var h=0;return h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),+Pt[h|0](a)}function Kp(r,a){var h=0,u=0;h=ht(4),l[h>>2]=a,u=ht(4),l[u>>2]=a,qo(7035,r|0,7098,4714,196,h|0,7098,4718,197,u|0)}function Vn(r,a){var h=0,u=0;h=ht(4),l[h>>2]=a,u=ht(4),l[u>>2]=a,qo(7065,r|0,7098,4714,194,h|0,7098,4718,195,u|0)}function xh(r,a){var h=0;t:{if(ft[7044]&1){h=l[1760];break t}h=hp(1,4464)|0,ft[7044]=1,l[1760]=h}bE(h|0,r|0,a|0,0)}function $T(r,a){r=r|0,a=a|0;var h=0;h=l[r+8>>2],l[r+8>>2]=a,h&&Pt[l[l[h>>2]+4>>2]](h),l[l[r>>2]+20>>2]=15}function NT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=pp((ft[a+11|0]<0?l[a>>2]:a)|0,7036,l[h>>2])|0,l[u>>2]=y}function FT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=pp((ft[a+11|0]<0?l[a>>2]:a)|0,7059,l[h>>2])|0,l[u>>2]=y}function Yp(r,a){r=r|0,a=a|0;var h=0;h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),Pt[h|0](a)}function UT(r){r=r|0;var a=m(0);return r=l[r>>2],a=I[r+36>>2],a!=a&&(a=ft[l[r+568>>2]+8|0]&1?m(1):m(0)),+a}function BT(r,a){r=r|0,a=a|0;var h=0;h=l[r+4>>2],l[r+4>>2]=a,h&&Pt[l[l[h>>2]+4>>2]](h),Fp(l[r>>2],14)}function GT(r){r=r|0;var a=0;a=l[r+8>>2],l[r+8>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),l[l[r>>2]+20>>2]=0}function HT(r){r=r|0;var a=0;return a=ht(12),ft[a+4|0]=0,l[a+8>>2]=l[r>>2],l[r>>2]=0,l[a>>2]=4432,a|0}function VT(r){r=r|0;var a=0;return a=ht(12),ft[a+4|0]=0,l[a+8>>2]=l[r>>2],l[r>>2]=0,l[a>>2]=4552,a|0}function WT(){var r=0;if(r=l[1768],r)for(;Pt[l[r>>2]](),r=l[r+4>>2],!!r;);}function jT(r){r=r|0;var a=0;a=l[r+4>>2],l[r+4>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),Fp(l[r>>2],0)}function zp(r){return r=r|0,l[r>>2]=4572,At[r+4|0]&&xh(l[r+8>>2],1759),Ma(l[r+8>>2]),r|0}function Xp(r){return r=r|0,l[r>>2]=4452,At[r+4|0]&&xh(l[r+8>>2],1759),Ma(l[r+8>>2]),r|0}function KT(){var r=0;return r=ht(16),l[r>>2]=0,l[r+4>>2]=0,l[r+8>>2]=0,l[r+12>>2]=0,r|0}function Zp(r,a,h){return nr(r,a)?Os(r,a,h):(h=$a(r,a,h),h==h&&(h=m(-h)),h)}function qp(r,a){var h=0;h=Et-16|0,Et=h,r||(l[h>>2]=a,sr(0,h),qi(),he()),Et=h+16|0}function Qp(r){r=r|0;var a=0;r&&(a=l[r>>2],a&&gi(a),l[1752]=l[1752]-1,gi(r))}function YT(r,a){return r=r|0,a=a|0,a>>>0>=3&&(Ds(),he()),l[l[r>>2]+12>>2]>>>a&1}function zT(r,a,h,u,y){return r=r|0,a=a|0,h=h|0,u=u|0,y=y|0,Pt[r|0](a,h,u,y)|0}function XT(){var r=0;return r=ht(16),l[r+8>>2]=0,l[r+12>>2]=0,l[r>>2]=0,r|0}function ZT(r){r=r|0;var a=m(0);return a=I[l[r>>2]+224>>2],+(a!=a?m(Yt):a)}function qT(r){return r=r|0,r=l[l[r>>2]+552>>2],r?l[r>>2]:0}function QT(r){r=r|0;var a=m(0);return a=I[l[r>>2]+32>>2],+(a==a?a:m(0))}function Jp(r){var a=0;return a=yp(ht(588),r),qp((r|0)!=0,2808),a}function JT(r,a){r=r|0,a=a|0,r=l[r>>2],l[r+16>>2]=l[r+16>>2]&-2|a}function t3(r){return r=r|0,r=l[r>>2],l[r+560>>2]-l[r+556>>2]>>2}function e3(r,a){r=r|0,a=a|0,r=l[r>>2],ft[r+8|0]=At[r+8|0]&254|a}function i3(r){r=r|0,r=l[l[r>>2]+8>>2],Pt[l[l[r>>2]+8>>2]](r)}function r3(r,a,h){r=r|0,a=a|0,h=+h,Lh(l[r>>2],a,vr(m(h)))}function s3(r,a,h){r=r|0,a=a|0,h=+h,Lh(l[r>>2],a,Hr(m(h)))}function n3(r,a,h,u){return Ni=0,0}function a3(r,a,h){r=r|0,a=a|0,h=+h,$p(l[r>>2],a,vr(m(h)))}function o3(r,a,h){r=r|0,a=a|0,h=+h,$p(l[r>>2],a,Hr(m(h)))}function l3(r,a,h){r=r|0,a=a|0,h=+h,Np(l[r>>2],a,vr(m(h)))}function c3(r,a,h){r=r|0,a=a|0,h=+h,Np(l[r>>2],a,Hr(m(h)))}function h3(r,a,h){r=r|0,a=a|0,h=h|0,l[l[r>>2]+a>>2]=h}function d3(r,a){r=r|0,a=a|0,Lh(l[r>>2],a,2141891242)}function Dh(r,a,h){r=r|0,a=a|0,h=+h,Ne[l[r>>2]+a>>3]=h}function u3(r){return r=r|0,(At[l[r>>2]+4|0]&2)>>>1|0}function f3(r){return r=r|0,(At[l[r>>2]+4|0]&4)>>>2|0}function p3(r,a){r=r|0,a=a|0,l[r+4>>2]=10,l[r>>2]=a}function g3(r,a){r=r|0,a=a|0,l[r+4>>2]=13,l[r>>2]=a}function m3(r){return r=r|0,l[l[r>>2]+24>>2]>>>10&7}function v3(r){return r=r|0,l[l[r>>2]+24>>2]>>>13&7}function Ph(r,a){return r=r|0,a=a|0,+Ne[l[r>>2]+a>>3]}function y3(r){return r=r|0,l[l[r>>2]+24>>2]>>>18&3}function b3(r){return r=r|0,l[l[r>>2]+24>>2]>>>20&3}function A3(r){return r=r|0,l[l[r>>2]+24>>2]>>>22&1}function E3(r,a){return r=r|0,a=a|0,l[l[r>>2]+a>>2]}function T3(r,a){r=r|0,a=+a,Gn(l[r>>2],0,vr(m(a)))}function k3(r,a){r=r|0,a=+a,Gn(l[r>>2],0,Hr(m(a)))}function w3(r,a){r=r|0,a=+a,Gn(l[r>>2],1,vr(m(a)))}function S3(r,a){r=r|0,a=+a,Gn(l[r>>2],1,Hr(m(a)))}function R3(r,a){r=r|0,a=a|0,l[r+4>>2]=7,l[r>>2]=a}function _3(r,a){r=r|0,a=+a,tl(l[r>>2],0,vr(m(a)))}function L3(r,a){r=r|0,a=+a,tl(l[r>>2],0,Hr(m(a)))}function C3(r,a){r=r|0,a=+a,tl(l[r>>2],1,vr(m(a)))}function I3(r,a){r=r|0,a=+a,tl(l[r>>2],1,Hr(m(a)))}function x3(r,a){r=r|0,a=+a,el(l[r>>2],0,vr(m(a)))}function D3(r,a){r=r|0,a=+a,el(l[r>>2],1,vr(m(a)))}function P3(r,a){r=r|0,a=+a,el(l[r>>2],1,Hr(m(a)))}function O3(r){return r=r|0,l[l[r>>2]+24>>2]>>>7&7}function M3(r){return r=r|0,l[l[r>>2]+24>>2]>>>2&3}function $3(r){return r=r|0,l[l[r>>2]+24>>2]>>>4&7}function rl(r){r=r|0,r&&Pt[l[l[r>>2]+4>>2]](r)}function N3(r,a){r=r|0,a=+a,el(l[r>>2],0,Hr(m(a)))}function t2(r){return r?(l[1781]=r,-1):0}function F3(r,a){r=r|0,a=+a,_h(l[r>>2],vr(m(a)))}function U3(r,a){r=r|0,a=+a,_h(l[r>>2],Hr(m(a)))}function e2(r,a,h){return m(de(r,a,h)+we(r,a,h))}function B3(r,a){return r=r|0,a=a|0,Pt[r|0](a)|0}function i2(r,a,h,u){EE(r|0,a|0,8,0,h|0,-1,u|0)}function G3(r,a){r=r|0,a=a|0,l[l[r>>2]+16>>2]=a}function H3(r){return r=r|0,l[l[r>>2]+16>>2]&1}function V3(r){return r=r|0,Nn[l[r>>2]+26>>1]&3}function W3(r){r=r|0,Gn(l[r>>2],0,2141891242)}function j3(r){r=r|0,Gn(l[r>>2],1,2141891242)}function K3(r){return r=r|0,+I[l[r>>2]+228>>2]}function Y3(r){return r=r|0,+I[l[r>>2]+236>>2]}function z3(r){return r=r|0,+I[l[r>>2]+232>>2]}function X3(r){return r=r|0,+I[l[r>>2]+240>>2]}function Z3(r){return r=r|0,+I[l[r>>2]+244>>2]}function q3(r){return r=r|0,+I[l[r>>2]+248>>2]}function Q3(r){return r=r|0,SE(l[r+60>>2])|0}function J3(r){return r=r|0,l[l[r>>2]+16>>2]}function tk(r){return r=r|0,ft[l[r>>2]+8|0]&1}function ek(r,a){r=r|0,a=a|0,Rh(l[r>>2],5,a)}function ik(r,a){r=r|0,a=a|0,Rh(l[r>>2],6,a)}function rk(r,a){r=r|0,a=a|0,Rh(l[r>>2],7,a)}function sk(r){r=r|0,_h(l[r>>2],2141891242)}function r2(r,a){r=r|0,a=a|0,Pt[l[r>>2]](a)}function nk(r){return r=r|0,Pp(ht(12),r)|0}function ak(r){r=r|0,xh(l[r+8>>2],3293)}function s2(r,a,h){return Lp(r,a,h,2,3)}function n2(r){return r=r|0,Pt[r|0]()|0}function a2(r,a){r=r|0,a=a|0,Pt[r|0](a)}function ok(){return Ui(ht(48),0,48)|0}function qi(){Pt[l[1490]](),Mh(),he()}function lk(){return Pp(ht(12),0)|0}function Oh(r){r=r|0,r&&gi(r)}function sl(r){return r-48>>>0<10}function ck(r){return 7032}function hk(r){return 7036}function dk(r){return 7056}function uk(r){return 7059}function fk(r){return 7062}function pk(r){return 7067}function Sr(r){return r=r|0,r|0}function o2(r){r=r|0,ft[r+4|0]=1}function gk(r){r=r|0,gi(zp(r))}function mk(r){r=r|0,gi(Xp(r))}function vk(r){return 0}function l2(r){he()}function c2(){Mh(),he()}function Mh(){Ds(),he()}G=At,Rt();var Pt=B([null,OT,CE,DE,Sr,R3,p3,g3,Sr,Sr,Sr,Sr,Sr,Sr,ET,i3,mp,ck,rl,iT,hk,Sr,Sr,rl,o2,r2,Wp,HT,BE,NT,dk,rl,Yp,uk,Sr,Sr,rl,o2,r2,Wp,VT,FT,fk,Qp,n2,TT,a2,Qp,_T,Hp,FE,DT,JT,Ms,G3,Ms,e3,YT,Vp,H3,gn,J3,gn,tk,ok,Oh,KT,Oh,XT,Oh,Ph,Dh,E3,h3,pk,wp,n2,lk,B3,nk,a2,wp,ME,Yp,xE,Ms,cT,Ms,l3,IT,c3,ek,ik,rk,gT,lT,pT,r3,s3,d3,aT,oT,dT,PT,F3,U3,sk,uT,fT,T3,k3,W3,w3,S3,j3,_3,L3,C3,I3,x3,N3,D3,P3,hT,rT,a3,o3,sT,V3,gn,VE,vT,O3,m3,v3,M3,y3,$3,WE,tT,bT,QT,MT,UT,KE,YE,zE,XE,ZE,jE,ZT,nT,xT,b3,A3,HE,eT,CT,PE,Hp,OE,Ms,t3,gn,qT,gn,RT,Vp,u3,gn,mT,Ms,BT,Ms,jT,$T,Ms,GT,yT,f3,gn,IE,LT,K3,Y3,z3,X3,Z3,q3,kT,wT,qE,QE,JE,Ph,Dh,Ph,Dh,Sp,Xp,mk,UE,l2,c2,zp,gk,ak,l2,Q3,$E,ST,vk,n3,GE,c2]);function h2(){return $i.byteLength/65536|0}function yk(r){r=r|0;var a=h2()|0,h=a+r|0;if(a<h&&h<65536){var u=new ArrayBuffer(Fe(h,65536)),y=new Int8Array(u);y.set(ft),ft=new Int8Array(u),Fr=new Int16Array(u),l=new Int32Array(u),At=new Uint8Array(u),Nn=new Uint16Array(u),lp=new Uint32Array(u),I=new Float32Array(u),Ne=new Float64Array(u),$i=u,rr.buffer=$i,G=At}return a}return{E:AT,F:NE,G:WT,H:Th,I:Pt,J:gi,K:zT}}return Zo(C)}(L)}var _=Error,D={};b=[],typeof D!="object"&&xt("no native wasm support detected");var M,F=!1;function x(L,C,B){B=C+B;for(var G="";!(C>=B);){var it=L[C++];if(!it)break;if(it&128){var vt=L[C++]&63;if((it&224)==192)G+=String.fromCharCode((it&31)<<6|vt);else{var lt=L[C++]&63;it=(it&240)==224?(it&15)<<12|vt<<6|lt:(it&7)<<18|vt<<12|lt<<6|L[C++]&63,65536>it?G+=String.fromCharCode(it):(it-=65536,G+=String.fromCharCode(55296|it>>10,56320|it&1023))}}else G+=String.fromCharCode(it)}return G}var N,V,j,rt,nt,Q,Tt,gt,$t;function Wt(L){N=L,o.HEAP8=V=new Int8Array(L),o.HEAP16=rt=new Int16Array(L),o.HEAP32=Q=new Int32Array(L),o.HEAPU8=j=new Uint8Array(L),o.HEAPU16=nt=new Uint16Array(L),o.HEAPU32=Tt=new Uint32Array(L),o.HEAPF32=gt=new Float32Array(L),o.HEAPF64=$t=new Float64Array(L)}var H=o.INITIAL_MEMORY||16777216;o.wasmMemory?M=o.wasmMemory:M=new E,M&&(N=M.buffer),H=N.byteLength,Wt(N);var J,St=[],$=[],U=[];function X(){var L=o.preRun.shift();St.unshift(L)}var mt=0,bt=null;function xt(L){throw o.onAbort&&o.onAbort(L),L="Aborted("+L+")",v(L),F=!0,L=new _(L+". Build with -sASSERTIONS for more info."),d(L),L}function Ut(L){return L.startsWith("data:application/octet-stream;base64,")}var Qt;if(Qt="<<< WASM_BINARY_FILE >>>",!Ut(Qt)){var ue=Qt;Qt=o.locateFile?o.locateFile(ue,p):p+ue}function se(L){var C=Qt;try{try{if(C==Qt&&b)new Uint8Array(b);else{if(Ut(C)){try{var B=dE(C.slice(37)),G=new Uint8Array(B.length);for(C=0;C<B.length;++C)G[C]=B.charCodeAt(C);var it=G}catch{throw Error("Converting base64 string to bytes failed.")}var vt=it}else vt=void 0;if(!vt)throw"sync fetching of the wasm failed: you can preload it to Module['wasmBinary'] manually, or emcc.py will do that for you when generating HTML (but not JS)"}}catch(Lt){xt(Lt)}var lt=new T,Rt=new w(L)}catch(Lt){throw L=Lt.toString(),v("failed to compile wasm module: "+L),(L.includes("imported Memory")||L.includes("memory import"))&&v("Memory size incompatibility issues may be due to changing INITIAL_MEMORY at runtime to something too large. Use ALLOW_MEMORY_GROWTH to allow any size memory (and also make sure not to set INITIAL_MEMORY at runtime to something smaller than it was at compile time)."),Lt}return[Rt,lt]}function zt(L){for(;0<L.length;)L.shift()(o)}function Oe(L){if(L===void 0)return"_unknown";L=L.replace(/[^a-zA-Z0-9_]/g,"$");var C=L.charCodeAt(0);return 48<=C&&57>=C?"_"+L:L}function be(L,C){return L=Oe(L),function(){return C.apply(this,arguments)}}var jt=[{},{value:void 0},{value:null},{value:!0},{value:!1}],ge=[];function oe(L){var C=Error,B=be(L,function(G){this.name=L,this.message=G,G=Error(G).stack,G!==void 0&&(this.stack=this.toString()+`
94
+ `+G.replace(/^Error(:[^\n]*)?\n/,""))});return B.prototype=Object.create(C.prototype),B.prototype.constructor=B,B.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},B}var Ce=void 0;function Ft(L){throw new Ce(L)}var Xe=L=>(L||Ft("Cannot use deleted val. handle = "+L),jt[L].value),qe=L=>{switch(L){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var C=ge.length?ge.pop():jt.length;return jt[C]={fa:1,value:L},C}},Mi=void 0,Tr=void 0;function ke(L){for(var C="";j[L];)C+=Tr[j[L++]];return C}var li=[];function me(){for(;li.length;){var L=li.pop();L.L.Z=!1,L.delete()}}var Je=void 0,ti={};function Xi(L,C){for(C===void 0&&Ft("ptr should not be undefined");L.P;)C=L.aa(C),L=L.P;return C}var $e={};function Ci(L){L=fE(L);var C=ke(L);return xs(L),C}function ss(L,C){var B=$e[L];return B===void 0&&Ft(C+" has unknown type "+Ci(L)),B}function ci(){}var kr=!1;function _s(L){--L.count.value,L.count.value===0&&(L.S?L.T.V(L.S):L.O.M.V(L.N))}function Ls(L,C,B){return C===B?L:B.P===void 0?null:(L=Ls(L,C,B.P),L===null?null:B.ma(L))}var ir={};function ct(L,C){return C=Xi(L,C),ti[C]}var Gt=void 0;function Xt(L){throw new Gt(L)}function ve(L,C){return C.O&&C.N||Xt("makeClassHandle requires ptr and ptrType"),!!C.T!=!!C.S&&Xt("Both smartPtrType and smartPtr must be specified"),C.count={value:1},ae(Object.create(L,{L:{value:C}}))}function ae(L){return typeof FinalizationRegistry>"u"?(ae=C=>C,L):(kr=new FinalizationRegistry(C=>{_s(C.L)}),ae=C=>{var B=C.L;return B.S&&kr.register(C,{L:B},C),C},ci=C=>{kr.unregister(C)},ae(L))}var ni={};function Ii(L){for(;L.length;){var C=L.pop();L.pop()(C)}}function ur(L){return this.fromWireType(Q[L>>2])}var ns={},fr={};function pr(L,C,B){function G(Rt){Rt=B(Rt),Rt.length!==L.length&&Xt("Mismatched type converter count");for(var Lt=0;Lt<L.length;++Lt)xi(L[Lt],Rt[Lt])}L.forEach(function(Rt){fr[Rt]=C});var it=Array(C.length),vt=[],lt=0;C.forEach((Rt,Lt)=>{$e.hasOwnProperty(Rt)?it[Lt]=$e[Rt]:(vt.push(Rt),ns.hasOwnProperty(Rt)||(ns[Rt]=[]),ns[Rt].push(()=>{it[Lt]=$e[Rt],++lt,lt===vt.length&&G(it)}))}),vt.length===0&&G(it)}function Cs(L){switch(L){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+L)}}function xi(L,C,B={}){if(!("argPackAdvance"in C))throw new TypeError("registerType registeredInstance requires argPackAdvance");var G=C.name;if(L||Ft('type "'+G+'" must have a positive integer typeid pointer'),$e.hasOwnProperty(L)){if(B.ta)return;Ft("Cannot register type '"+G+"' twice")}$e[L]=C,delete fr[L],ns.hasOwnProperty(L)&&(C=ns[L],delete ns[L],C.forEach(it=>it()))}function Oa(L){Ft(L.L.O.M.name+" instance already deleted")}function gr(){}function Is(L,C,B){if(L[C].R===void 0){var G=L[C];L[C]=function(){return L[C].R.hasOwnProperty(arguments.length)||Ft("Function '"+B+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+L[C].R+")!"),L[C].R[arguments.length].apply(this,arguments)},L[C].R=[],L[C].R[G.Y]=G}}function KA(L,C){o.hasOwnProperty(L)?(Ft("Cannot register public name '"+L+"' twice"),Is(o,L,L),o.hasOwnProperty(void 0)&&Ft("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),o[L].R[void 0]=C):o[L]=C}function YA(L,C,B,G,it,vt,lt,Rt){this.name=L,this.constructor=C,this.W=B,this.V=G,this.P=it,this.oa=vt,this.aa=lt,this.ma=Rt,this.ia=[]}function ph(L,C,B){for(;C!==B;)C.aa||Ft("Expected null or instance of "+B.name+", got an instance of "+C.name),L=C.aa(L),C=C.P;return L}function zA(L,C){return C===null?(this.da&&Ft("null is not a valid "+this.name),0):(C.L||Ft('Cannot pass "'+yh(C)+'" as a '+this.name),C.L.N||Ft("Cannot pass deleted object as a pointer of type "+this.name),ph(C.L.N,C.L.O.M,this.M))}function XA(L,C){if(C===null){if(this.da&&Ft("null is not a valid "+this.name),this.ca){var B=this.ea();return L!==null&&L.push(this.V,B),B}return 0}if(C.L||Ft('Cannot pass "'+yh(C)+'" as a '+this.name),C.L.N||Ft("Cannot pass deleted object as a pointer of type "+this.name),!this.ba&&C.L.O.ba&&Ft("Cannot convert argument of type "+(C.L.T?C.L.T.name:C.L.O.name)+" to parameter type "+this.name),B=ph(C.L.N,C.L.O.M,this.M),this.ca)switch(C.L.S===void 0&&Ft("Passing raw pointer to smart pointer is illegal"),this.Aa){case 0:C.L.T===this?B=C.L.S:Ft("Cannot convert argument of type "+(C.L.T?C.L.T.name:C.L.O.name)+" to parameter type "+this.name);break;case 1:B=C.L.S;break;case 2:if(C.L.T===this)B=C.L.S;else{var G=C.clone();B=this.wa(B,qe(function(){G.delete()})),L!==null&&L.push(this.V,B)}break;default:Ft("Unsupporting sharing policy")}return B}function ZA(L,C){return C===null?(this.da&&Ft("null is not a valid "+this.name),0):(C.L||Ft('Cannot pass "'+yh(C)+'" as a '+this.name),C.L.N||Ft("Cannot pass deleted object as a pointer of type "+this.name),C.L.O.ba&&Ft("Cannot convert argument of type "+C.L.O.name+" to parameter type "+this.name),ph(C.L.N,C.L.O.M,this.M))}function as(L,C,B,G){this.name=L,this.M=C,this.da=B,this.ba=G,this.ca=!1,this.V=this.wa=this.ea=this.ja=this.Aa=this.va=void 0,C.P!==void 0?this.toWireType=XA:(this.toWireType=G?zA:ZA,this.U=null)}function qA(L,C){o.hasOwnProperty(L)||Xt("Replacing nonexistant public symbol"),o[L]=C,o[L].Y=void 0}function QA(L,C){var B=[];return function(){if(B.length=0,Object.assign(B,arguments),L.includes("j")){var G=o["dynCall_"+L];G=B&&B.length?G.apply(null,[C].concat(B)):G.call(null,C)}else G=J.get(C).apply(null,B);return G}}function wr(L,C){L=ke(L);var B=L.includes("j")?QA(L,C):J.get(C);return typeof B!="function"&&Ft("unknown function pointer with signature "+L+": "+C),B}var ip=void 0;function Ko(L,C){function B(vt){it[vt]||$e[vt]||(fr[vt]?fr[vt].forEach(B):(G.push(vt),it[vt]=!0))}var G=[],it={};throw C.forEach(B),new ip(L+": "+G.map(Ci).join([", "]))}function gh(L,C,B,G,it){var vt=C.length;2>vt&&Ft("argTypes array size mismatch! Must at least get return value and 'this' types!");var lt=C[1]!==null&&B!==null,Rt=!1;for(B=1;B<C.length;++B)if(C[B]!==null&&C[B].U===void 0){Rt=!0;break}var Lt=C[0].name!=="void",Ct=vt-2,Nt=Array(Ct),Kt=[],te=[];return function(){if(arguments.length!==Ct&&Ft("function "+L+" called with "+arguments.length+" arguments, expected "+Ct+" args!"),te.length=0,Kt.length=lt?2:1,Kt[0]=it,lt){var Dt=C[1].toWireType(te,this);Kt[1]=Dt}for(var Ae=0;Ae<Ct;++Ae)Nt[Ae]=C[Ae+2].toWireType(te,arguments[Ae]),Kt.push(Nt[Ae]);if(Ae=G.apply(null,Kt),Rt)Ii(te);else for(var pi=lt?1:2;pi<C.length;pi++){var he=pi===1?Dt:Nt[pi-2];C[pi].U!==null&&C[pi].U(he)}return Dt=Lt?C[0].fromWireType(Ae):void 0,Dt}}function mh(L,C){for(var B=[],G=0;G<L;G++)B.push(Tt[C+4*G>>2]);return B}function vh(L){4<L&&--jt[L].fa===0&&(jt[L]=void 0,ge.push(L))}function yh(L){if(L===null)return"null";var C=typeof L;return C==="object"||C==="array"||C==="function"?L.toString():""+L}function JA(L,C){switch(C){case 2:return function(B){return this.fromWireType(gt[B>>2])};case 3:return function(B){return this.fromWireType($t[B>>3])};default:throw new TypeError("Unknown float type: "+L)}}function tE(L,C,B){switch(C){case 0:return B?function(G){return V[G]}:function(G){return j[G]};case 1:return B?function(G){return rt[G>>1]}:function(G){return nt[G>>1]};case 2:return B?function(G){return Q[G>>2]}:function(G){return Tt[G>>2]};default:throw new TypeError("Unknown integer type: "+L)}}function eE(L,C){for(var B="",G=0;!(G>=C/2);++G){var it=rt[L+2*G>>1];if(it==0)break;B+=String.fromCharCode(it)}return B}function iE(L,C,B){if(B===void 0&&(B=2147483647),2>B)return 0;B-=2;var G=C;B=B<2*L.length?B/2:L.length;for(var it=0;it<B;++it)rt[C>>1]=L.charCodeAt(it),C+=2;return rt[C>>1]=0,C-G}function rE(L){return 2*L.length}function sE(L,C){for(var B=0,G="";!(B>=C/4);){var it=Q[L+4*B>>2];if(it==0)break;++B,65536<=it?(it-=65536,G+=String.fromCharCode(55296|it>>10,56320|it&1023)):G+=String.fromCharCode(it)}return G}function nE(L,C,B){if(B===void 0&&(B=2147483647),4>B)return 0;var G=C;B=G+B-4;for(var it=0;it<L.length;++it){var vt=L.charCodeAt(it);if(55296<=vt&&57343>=vt){var lt=L.charCodeAt(++it);vt=65536+((vt&1023)<<10)|lt&1023}if(Q[C>>2]=vt,C+=4,C+4>B)break}return Q[C>>2]=0,C-G}function aE(L){for(var C=0,B=0;B<L.length;++B){var G=L.charCodeAt(B);55296<=G&&57343>=G&&++B,C+=4}return C}var oE={};function rp(L){var C=oE[L];return C===void 0?ke(L):C}var Yo=[];function lE(L){var C=Yo.length;return Yo.push(L),C}function cE(L,C){for(var B=Array(L),G=0;G<L;++G)B[G]=ss(Tt[C+4*G>>2],"parameter "+G);return B}var sp=[],hE=[null,[],[]];Ce=o.BindingError=oe("BindingError"),o.count_emval_handles=function(){for(var L=0,C=5;C<jt.length;++C)jt[C]!==void 0&&++L;return L},o.get_first_emval=function(){for(var L=5;L<jt.length;++L)if(jt[L]!==void 0)return jt[L];return null},Mi=o.PureVirtualError=oe("PureVirtualError");for(var np=Array(256),zo=0;256>zo;++zo)np[zo]=String.fromCharCode(zo);Tr=np,o.getInheritedInstanceCount=function(){return Object.keys(ti).length},o.getLiveInheritedInstances=function(){var L=[],C;for(C in ti)ti.hasOwnProperty(C)&&L.push(ti[C]);return L},o.flushPendingDeletes=me,o.setDelayFunction=function(L){Je=L,li.length&&Je&&Je(me)},Gt=o.InternalError=oe("InternalError"),gr.prototype.isAliasOf=function(L){if(!(this instanceof gr&&L instanceof gr))return!1;var C=this.L.O.M,B=this.L.N,G=L.L.O.M;for(L=L.L.N;C.P;)B=C.aa(B),C=C.P;for(;G.P;)L=G.aa(L),G=G.P;return C===G&&B===L},gr.prototype.clone=function(){if(this.L.N||Oa(this),this.L.$)return this.L.count.value+=1,this;var L=ae,C=Object,B=C.create,G=Object.getPrototypeOf(this),it=this.L;return L=L(B.call(C,G,{L:{value:{count:it.count,Z:it.Z,$:it.$,N:it.N,O:it.O,S:it.S,T:it.T}}})),L.L.count.value+=1,L.L.Z=!1,L},gr.prototype.delete=function(){this.L.N||Oa(this),this.L.Z&&!this.L.$&&Ft("Object already scheduled for deletion"),ci(this),_s(this.L),this.L.$||(this.L.S=void 0,this.L.N=void 0)},gr.prototype.isDeleted=function(){return!this.L.N},gr.prototype.deleteLater=function(){return this.L.N||Oa(this),this.L.Z&&!this.L.$&&Ft("Object already scheduled for deletion"),li.push(this),li.length===1&&Je&&Je(me),this.L.Z=!0,this},as.prototype.pa=function(L){return this.ja&&(L=this.ja(L)),L},as.prototype.ga=function(L){this.V&&this.V(L)},as.prototype.argPackAdvance=8,as.prototype.readValueFromPointer=ur,as.prototype.deleteObject=function(L){L!==null&&L.delete()},as.prototype.fromWireType=function(L){function C(){return this.ca?ve(this.M.W,{O:this.va,N:B,T:this,S:L}):ve(this.M.W,{O:this,N:L})}var B=this.pa(L);if(!B)return this.ga(L),null;var G=ct(this.M,B);if(G!==void 0)return G.L.count.value===0?(G.L.N=B,G.L.S=L,G.clone()):(G=G.clone(),this.ga(L),G);if(G=this.M.oa(B),G=ir[G],!G)return C.call(this);G=this.ba?G.ka:G.pointerType;var it=Ls(B,this.M,G.M);return it===null?C.call(this):this.ca?ve(G.M.W,{O:G,N:it,T:this,S:L}):ve(G.M.W,{O:G,N:it})},ip=o.UnboundTypeError=oe("UnboundTypeError");var dE=typeof atob=="function"?atob:function(L){var C="",B=0;L=L.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(L.charAt(B++)),it="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(L.charAt(B++)),vt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(L.charAt(B++)),lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(L.charAt(B++));G=G<<2|it>>4,it=(it&15)<<4|vt>>2;var Rt=(vt&3)<<6|lt;C+=String.fromCharCode(G),vt!==64&&(C+=String.fromCharCode(it)),lt!==64&&(C+=String.fromCharCode(Rt))}while(B<L.length);return C},uE={q:function(L,C,B){L=ke(L),C=ss(C,"wrapper"),B=Xe(B);var G=[].slice,it=C.M,vt=it.W,lt=it.P.W,Rt=it.P.constructor;L=be(L,function(){it.P.ia.forEach((function(Ct){if(this[Ct]===lt[Ct])throw new Mi("Pure virtual function "+Ct+" must be implemented in JavaScript")}).bind(this)),Object.defineProperty(this,"__parent",{value:vt}),this.__construct.apply(this,G.call(arguments))}),vt.__construct=function(){this===vt&&Ft("Pass correct 'this' to __construct");var Ct=Rt.implement.apply(void 0,[this].concat(G.call(arguments)));ci(Ct);var Nt=Ct.L;Ct.notifyOnDestruction(),Nt.$=!0,Object.defineProperties(this,{L:{value:Nt}}),ae(this),Ct=Nt.N,Ct=Xi(it,Ct),ti.hasOwnProperty(Ct)?Ft("Tried to register registered instance: "+Ct):ti[Ct]=this},vt.__destruct=function(){this===vt&&Ft("Pass correct 'this' to __destruct"),ci(this);var Ct=this.L.N;Ct=Xi(it,Ct),ti.hasOwnProperty(Ct)?delete ti[Ct]:Ft("Tried to unregister unregistered instance: "+Ct)},L.prototype=Object.create(vt);for(var Lt in B)L.prototype[Lt]=B[Lt];return qe(L)},k:function(L){var C=ni[L];delete ni[L];var B=C.ea,G=C.V,it=C.ha,vt=it.map(lt=>lt.sa).concat(it.map(lt=>lt.ya));pr([L],vt,lt=>{var Rt={};return it.forEach((Lt,Ct)=>{var Nt=lt[Ct],Kt=Lt.qa,te=Lt.ra,Dt=lt[Ct+it.length],Ae=Lt.xa,pi=Lt.za;Rt[Lt.na]={read:he=>Nt.fromWireType(Kt(te,he)),write:(he,Zi)=>{var Bt=[];Ae(pi,he,Dt.toWireType(Bt,Zi)),Ii(Bt)}}}),[{name:C.name,fromWireType:function(Lt){var Ct={},Nt;for(Nt in Rt)Ct[Nt]=Rt[Nt].read(Lt);return G(Lt),Ct},toWireType:function(Lt,Ct){for(var Nt in Rt)if(!(Nt in Ct))throw new TypeError('Missing field: "'+Nt+'"');var Kt=B();for(Nt in Rt)Rt[Nt].write(Kt,Ct[Nt]);return Lt!==null&&Lt.push(G,Kt),Kt},argPackAdvance:8,readValueFromPointer:ur,U:G}]})},w:function(){},C:function(L,C,B,G,it){var vt=Cs(B);C=ke(C),xi(L,{name:C,fromWireType:function(lt){return!!lt},toWireType:function(lt,Rt){return Rt?G:it},argPackAdvance:8,readValueFromPointer:function(lt){if(B===1)var Rt=V;else if(B===2)Rt=rt;else if(B===4)Rt=Q;else throw new TypeError("Unknown boolean type size: "+C);return this.fromWireType(Rt[lt>>vt])},U:null})},g:function(L,C,B,G,it,vt,lt,Rt,Lt,Ct,Nt,Kt,te){Nt=ke(Nt),vt=wr(it,vt),Rt&&(Rt=wr(lt,Rt)),Ct&&(Ct=wr(Lt,Ct)),te=wr(Kt,te);var Dt=Oe(Nt);KA(Dt,function(){Ko("Cannot construct "+Nt+" due to unbound types",[G])}),pr([L,C,B],G?[G]:[],function(Ae){if(Ae=Ae[0],G)var pi=Ae.M,he=pi.W;else he=gr.prototype;Ae=be(Dt,function(){if(Object.getPrototypeOf(this)!==Zi)throw new Ce("Use 'new' to construct "+Nt);if(Bt.X===void 0)throw new Ce(Nt+" has no accessible constructor");var ei=Bt.X[arguments.length];if(ei===void 0)throw new Ce("Tried to invoke ctor of "+Nt+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(Bt.X).toString()+") parameters instead!");return ei.apply(this,arguments)});var Zi=Object.create(he,{constructor:{value:Ae}});Ae.prototype=Zi;var Bt=new YA(Nt,Ae,Zi,te,pi,vt,Rt,Ct);pi=new as(Nt,Bt,!0,!1),he=new as(Nt+"*",Bt,!1,!1);var Zo=new as(Nt+" const*",Bt,!1,!0);return ir[L]={pointerType:he,ka:Zo},qA(Dt,Ae),[pi,he,Zo]})},d:function(L,C,B,G,it,vt,lt){var Rt=mh(B,G);C=ke(C),vt=wr(it,vt),pr([],[L],function(Lt){function Ct(){Ko("Cannot call "+Nt+" due to unbound types",Rt)}Lt=Lt[0];var Nt=Lt.name+"."+C;C.startsWith("@@")&&(C=Symbol[C.substring(2)]);var Kt=Lt.M.constructor;return Kt[C]===void 0?(Ct.Y=B-1,Kt[C]=Ct):(Is(Kt,C,Nt),Kt[C].R[B-1]=Ct),pr([],Rt,function(te){return te=gh(Nt,[te[0],null].concat(te.slice(1)),null,vt,lt),Kt[C].R===void 0?(te.Y=B-1,Kt[C]=te):Kt[C].R[B-1]=te,[]}),[]})},p:function(L,C,B,G,it,vt){0<C||xt();var lt=mh(C,B);it=wr(G,it),pr([],[L],function(Rt){Rt=Rt[0];var Lt="constructor "+Rt.name;if(Rt.M.X===void 0&&(Rt.M.X=[]),Rt.M.X[C-1]!==void 0)throw new Ce("Cannot register multiple constructors with identical number of parameters ("+(C-1)+") for class '"+Rt.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return Rt.M.X[C-1]=()=>{Ko("Cannot construct "+Rt.name+" due to unbound types",lt)},pr([],lt,function(Ct){return Ct.splice(1,0,null),Rt.M.X[C-1]=gh(Lt,Ct,null,it,vt),[]}),[]})},b:function(L,C,B,G,it,vt,lt,Rt){var Lt=mh(B,G);C=ke(C),vt=wr(it,vt),pr([],[L],function(Ct){function Nt(){Ko("Cannot call "+Kt+" due to unbound types",Lt)}Ct=Ct[0];var Kt=Ct.name+"."+C;C.startsWith("@@")&&(C=Symbol[C.substring(2)]),Rt&&Ct.M.ia.push(C);var te=Ct.M.W,Dt=te[C];return Dt===void 0||Dt.R===void 0&&Dt.className!==Ct.name&&Dt.Y===B-2?(Nt.Y=B-2,Nt.className=Ct.name,te[C]=Nt):(Is(te,C,Kt),te[C].R[B-2]=Nt),pr([],Lt,function(Ae){return Ae=gh(Kt,Ae,Ct,vt,lt),te[C].R===void 0?(Ae.Y=B-2,te[C]=Ae):te[C].R[B-2]=Ae,[]}),[]})},B:function(L,C){C=ke(C),xi(L,{name:C,fromWireType:function(B){var G=Xe(B);return vh(B),G},toWireType:function(B,G){return qe(G)},argPackAdvance:8,readValueFromPointer:ur,U:null})},n:function(L,C,B){B=Cs(B),C=ke(C),xi(L,{name:C,fromWireType:function(G){return G},toWireType:function(G,it){return it},argPackAdvance:8,readValueFromPointer:JA(C,B),U:null})},e:function(L,C,B,G,it){C=ke(C),it===-1&&(it=4294967295),it=Cs(B);var vt=Rt=>Rt;if(G===0){var lt=32-8*B;vt=Rt=>Rt<<lt>>>lt}B=C.includes("unsigned")?function(Rt,Lt){return Lt>>>0}:function(Rt,Lt){return Lt},xi(L,{name:C,fromWireType:vt,toWireType:B,argPackAdvance:8,readValueFromPointer:tE(C,it,G!==0),U:null})},c:function(L,C,B){function G(vt){vt>>=2;var lt=Tt;return new it(N,lt[vt+1],lt[vt])}var it=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][C];B=ke(B),xi(L,{name:B,fromWireType:G,argPackAdvance:8,readValueFromPointer:G},{ta:!0})},o:function(L,C){C=ke(C);var B=C==="std::string";xi(L,{name:C,fromWireType:function(G){var it=Tt[G>>2],vt=G+4;if(B)for(var lt=vt,Rt=0;Rt<=it;++Rt){var Lt=vt+Rt;if(Rt==it||j[Lt]==0){if(lt=lt?x(j,lt,Lt-lt):"",Ct===void 0)var Ct=lt;else Ct+=String.fromCharCode(0),Ct+=lt;lt=Lt+1}}else{for(Ct=Array(it),Rt=0;Rt<it;++Rt)Ct[Rt]=String.fromCharCode(j[vt+Rt]);Ct=Ct.join("")}return xs(G),Ct},toWireType:function(G,it){it instanceof ArrayBuffer&&(it=new Uint8Array(it));var vt,lt=typeof it=="string";if(lt||it instanceof Uint8Array||it instanceof Uint8ClampedArray||it instanceof Int8Array||Ft("Cannot pass non-string to std::string"),B&&lt){var Rt=0;for(vt=0;vt<it.length;++vt){var Lt=it.charCodeAt(vt);127>=Lt?Rt++:2047>=Lt?Rt+=2:55296<=Lt&&57343>=Lt?(Rt+=4,++vt):Rt+=3}vt=Rt}else vt=it.length;if(Rt=ap(4+vt+1),Lt=Rt+4,Tt[Rt>>2]=vt,B&&lt){if(lt=Lt,Lt=vt+1,vt=j,0<Lt){Lt=lt+Lt-1;for(var Ct=0;Ct<it.length;++Ct){var Nt=it.charCodeAt(Ct);if(55296<=Nt&&57343>=Nt){var Kt=it.charCodeAt(++Ct);Nt=65536+((Nt&1023)<<10)|Kt&1023}if(127>=Nt){if(lt>=Lt)break;vt[lt++]=Nt}else{if(2047>=Nt){if(lt+1>=Lt)break;vt[lt++]=192|Nt>>6}else{if(65535>=Nt){if(lt+2>=Lt)break;vt[lt++]=224|Nt>>12}else{if(lt+3>=Lt)break;vt[lt++]=240|Nt>>18,vt[lt++]=128|Nt>>12&63}vt[lt++]=128|Nt>>6&63}vt[lt++]=128|Nt&63}}vt[lt]=0}}else if(lt)for(lt=0;lt<vt;++lt)Ct=it.charCodeAt(lt),255<Ct&&(xs(Lt),Ft("String has UTF-16 code units that do not fit in 8 bits")),j[Lt+lt]=Ct;else for(lt=0;lt<vt;++lt)j[Lt+lt]=it[lt];return G!==null&&G.push(xs,Rt),Rt},argPackAdvance:8,readValueFromPointer:ur,U:function(G){xs(G)}})},j:function(L,C,B){if(B=ke(B),C===2)var G=eE,it=iE,vt=rE,lt=()=>nt,Rt=1;else C===4&&(G=sE,it=nE,vt=aE,lt=()=>Tt,Rt=2);xi(L,{name:B,fromWireType:function(Lt){for(var Ct=Tt[Lt>>2],Nt=lt(),Kt,te=Lt+4,Dt=0;Dt<=Ct;++Dt){var Ae=Lt+4+Dt*C;(Dt==Ct||Nt[Ae>>Rt]==0)&&(te=G(te,Ae-te),Kt===void 0?Kt=te:(Kt+=String.fromCharCode(0),Kt+=te),te=Ae+C)}return xs(Lt),Kt},toWireType:function(Lt,Ct){typeof Ct!="string"&&Ft("Cannot pass non-string to C++ string type "+B);var Nt=vt(Ct),Kt=ap(4+Nt+C);return Tt[Kt>>2]=Nt>>Rt,it(Ct,Kt+4,Nt+C),Lt!==null&&Lt.push(xs,Kt),Kt},argPackAdvance:8,readValueFromPointer:ur,U:function(Lt){xs(Lt)}})},l:function(L,C,B,G,it,vt){ni[L]={name:ke(C),ea:wr(B,G),V:wr(it,vt),ha:[]}},i:function(L,C,B,G,it,vt,lt,Rt,Lt,Ct){ni[L].ha.push({na:ke(C),sa:B,qa:wr(G,it),ra:vt,ya:lt,xa:wr(Rt,Lt),za:Ct})},D:function(L,C){C=ke(C),xi(L,{ua:!0,name:C,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},t:function(L,C,B,G,it){L=Yo[L],C=Xe(C),B=rp(B);var vt=[];return Tt[G>>2]=qe(vt),L(C,B,vt,it)},u:function(L,C,B,G){L=Yo[L],C=Xe(C),B=rp(B),L(C,B,null,G)},h:vh,m:function(L,C){var B=cE(L,C),G=B[0];C=G.name+"_$"+B.slice(1).map(function(lt){return lt.name}).join("_")+"$";var it=sp[C];if(it!==void 0)return it;var vt=Array(L-1);return it=lE((lt,Rt,Lt,Ct)=>{for(var Nt=0,Kt=0;Kt<L-1;++Kt)vt[Kt]=B[Kt+1].readValueFromPointer(Ct+Nt),Nt+=B[Kt+1].argPackAdvance;for(lt=lt[Rt].apply(lt,vt),Kt=0;Kt<L-1;++Kt)B[Kt+1].la&&B[Kt+1].la(vt[Kt]);if(!G.ua)return G.toWireType(Lt,lt)}),sp[C]=it},r:function(L){4<L&&(jt[L].fa+=1)},s:function(L){var C=Xe(L);Ii(C),vh(L)},f:function(){xt("")},y:function(L,C,B){j.copyWithin(L,C,C+B)},x:function(L){var C=j.length;if(L>>>=0,2147483648<L)return!1;for(var B=1;4>=B;B*=2){var G=C*(1+.2/B);G=Math.min(G,L+100663296);var it=Math;G=Math.max(L,G),it=it.min.call(it,2147483648,G+(65536-G%65536)%65536);t:{try{M.grow(it-N.byteLength+65535>>>16),Wt(M.buffer);var vt=1;break t}catch{}vt=void 0}if(vt)return!0}return!1},A:function(){return 52},v:function(){return 70},z:function(L,C,B,G){for(var it=0,vt=0;vt<B;vt++){var lt=Tt[C>>2],Rt=Tt[C+4>>2];C+=8;for(var Lt=0;Lt<Rt;Lt++){var Ct=j[lt+Lt],Nt=hE[L];Ct===0||Ct===10?((L===1?g:v)(x(Nt,0)),Nt.length=0):Nt.push(Ct)}it+=Rt}return Tt[G>>2]=it,0},a:M},$n=function(){function L(B){o.asm=B.exports,J=o.asm.I,$.unshift(o.asm.E),mt--,o.monitorRunDependencies&&o.monitorRunDependencies(mt),mt==0&&bt&&(B=bt,bt=null,B())}var C={a:uE};if(mt++,o.monitorRunDependencies&&o.monitorRunDependencies(mt),o.instantiateWasm)try{return o.instantiateWasm(C,L)}catch(B){v("Module.instantiateWasm callback failed with error: "+B),d(B)}return C=se(C),L(C[0]),o.asm}();o.___wasm_call_ctors=$n.E;var fE=o.___getTypeName=$n.F;o.__embind_initialize_bindings=$n.G;var ap=o._malloc=$n.H,xs=o._free=$n.J;o.dynCall_jiji=$n.K;var Xo;bt=function L(){Xo||op(),Xo||(bt=L)};function op(){function L(){if(!Xo&&(Xo=!0,o.calledRun=!0,!F)){if(zt($),c(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;){var C=o.postRun.shift();U.unshift(C)}zt(U)}}if(!(0<mt)){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)X();zt(St),0<mt||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),L()},1)):L())}}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);0<o.preInit.length;)o.preInit.pop()();return op(),s}})();n.exports=e})(Kd);var pm=Kd.exports;(function(n){Object.defineProperty(n,"__esModule",{value:!0});var t={};n.default=void 0;var e=s($l),i=re;Object.keys(i).forEach(function(d){d==="default"||d==="__esModule"||Object.prototype.hasOwnProperty.call(t,d)||d in n&&n[d]===i[d]||Object.defineProperty(n,d,{enumerable:!0,get:function(){return i[d]}})});function s(d){return d&&d.__esModule?d:{default:d}}const o=pm;var c=(0,e.default)(o());n.default=c})(Ee);const Yd=hm(Ee),Zr=1.8;function gm(n,t){return typeof n=="number"?{top:n*t,right:n*t,bottom:n*t,left:n*t}:{top:typeof n.top=="number"?n.top*t:n.top,right:typeof n.right=="number"?n.right*t:n.right,bottom:typeof n.bottom=="number"?n.bottom*t:n.bottom,left:typeof n.left=="number"?n.left*t:n.left}}function zd(n,t){return typeof n=="number"?{top:n*t,right:n*t,bottom:n*t,left:n*t}:{top:(typeof n.top=="number"?n.top*t:n.top)??0,right:(typeof n.right=="number"?n.right*t:n.right)??0,bottom:(typeof n.bottom=="number"?n.bottom*t:n.bottom)??0,left:(typeof n.left=="number"?n.left*t:n.left)??0}}function mm(n,t=1){return typeof n=="number"?{topLeft:n*t,topRight:n*t,bottomRight:n*t,bottomLeft:n*t}:{topLeft:((n==null?void 0:n.topLeft)??0)*t,topRight:((n==null?void 0:n.topRight)??0)*t,bottomRight:((n==null?void 0:n.bottomRight)??0)*t,bottomLeft:((n==null?void 0:n.bottomLeft)??0)*t}}function Xd(n,{layout:t,scale:e=1}){const{position:i="static",inset:s,width:o,height:c,minWidth:d,minHeight:f,maxWidth:p,maxHeight:g,flex:v,gap:b,margin:E,padding:T,direction:w="column",align:_="start",justify:D="start"}=t,M={static:Ee.PositionType.Static,relative:Ee.PositionType.Relative,absolute:Ee.PositionType.Absolute};if(n.setPositionType(M[i]),s){const{top:V,right:j,bottom:rt,left:nt}=gm(s,e);V&&n.setPosition(Ee.Edge.Top,V),j&&n.setPosition(Ee.Edge.Right,j),rt&&n.setPosition(Ee.Edge.Bottom,rt),nt&&n.setPosition(Ee.Edge.Left,nt)}const F={row:Ee.FlexDirection.Row,column:Ee.FlexDirection.Column,"row-reverse":Ee.FlexDirection.RowReverse,"column-reverse":Ee.FlexDirection.ColumnReverse};n.setFlexDirection(F[w]);const x={start:Ee.Align.FlexStart,end:Ee.Align.FlexEnd,center:Ee.Align.Center,stretch:Ee.Align.Stretch};n.setAlignItems(x[_]);const N={start:Ee.Justify.FlexStart,end:Ee.Justify.FlexEnd,center:Ee.Justify.Center,"space-between":Ee.Justify.SpaceBetween,"space-around":Ee.Justify.SpaceAround,"space-evenly":Ee.Justify.SpaceEvenly};if(n.setJustifyContent(N[D]),E){const{top:V,right:j,bottom:rt,left:nt}=zd(E,e);n.setMargin(Ee.Edge.Top,V),n.setMargin(Ee.Edge.Right,j),n.setMargin(Ee.Edge.Bottom,rt),n.setMargin(Ee.Edge.Left,nt)}if(T){const{top:V,right:j,bottom:rt,left:nt}=zd(T,e);n.setPadding(Ee.Edge.Top,V),n.setPadding(Ee.Edge.Right,j),n.setPadding(Ee.Edge.Bottom,rt),n.setPadding(Ee.Edge.Left,nt)}v&&n.setFlex(v),n.setGap(Ee.Gutter.All,(b??0)*e),o&&n.setWidth(typeof o=="number"?o*e:o),c&&(typeof c=="function"?n.setHeight("100%"):n.setHeight(typeof c=="number"?c*e:c)),d&&n.setMinWidth(typeof d=="number"?d*e:d),f&&n.setMinHeight(typeof f=="number"?f*e:f),p&&n.setMaxWidth(typeof p=="number"?p*e:p),g&&n.setMaxHeight(typeof g=="number"?g*e:g)}function Zd({canvas:n,cropCanvas:t,letterboxCanvas:e,debug:i=!1,scale:s=1,position:o=[]}){o.forEach(({x:c,y:d,width:f,height:p,childNodes:g,element:v})=>{const b=n.getContext("2d",{alpha:!1});if(b){const{radius:E,draw:T}=v;if(T){if(b.save(),E){const{topLeft:w,topRight:_,bottomRight:D,bottomLeft:M}=mm(E,s);b.beginPath(),b.moveTo(c+Math.min(p/Zr,w),d),b.lineTo(c+f-Math.min(p/Zr,_),d),b.quadraticCurveTo(c+f,d,c+f,d+Math.min(p/Zr,_)),b.lineTo(c+f,d+p-Math.min(p/Zr,D)),b.quadraticCurveTo(c+f,d+p,c+f-Math.min(p/Zr,D),d+p),b.lineTo(c+Math.min(p/Zr,M),d+p),b.quadraticCurveTo(c,d+p,c,d+p-Math.min(p/Zr,M)),b.lineTo(c,d+Math.min(p/Zr,w)),b.quadraticCurveTo(c,d,c+Math.min(p/Zr,w),d),b.closePath(),i&&(b.strokeStyle="blue",b.stroke()),b.clip()}T({scale:s,canvas:n,context:b,cropCanvas:t,letterboxCanvas:e,dx:c,dy:d,dw:f,dh:p}),i&&(b.strokeStyle="red",b.strokeRect(c,d,f,p)),b.restore()}}Zd({canvas:n,cropCanvas:t,letterboxCanvas:e,debug:i,scale:s,position:g})})}function qd(n,t,e){const i=t.map((s,o)=>{const c=Yd.Node.create(),{radius:d,elements:f=[],draw:p,...g}=s;return Xd(c,{layout:g,scale:e}),n.insertChild(c,o),{node:c,element:s,childNodes:qd(c,f,e)}});return n.calculateLayout(),i}function Qd(n,t,e=0,i=0){const{top:s,left:o}=n.getComputedLayout();return t.map(({node:c,element:d,childNodes:f})=>{const{top:p,left:g,width:v,height:b}=c.getComputedLayout(),E=e+g,T=i+p;return{x:o+E,y:s+T,width:v,height:b,element:d,childNodes:Qd(n,f,E,T)}})}function Jd(n,t){n.forEach(({node:e,element:i,childNodes:s})=>{const{height:o}=i;if(o&&typeof o=="function"){const c=e.getComputedWidth(),d=e.getComputedHeight(),f=o({width:c,maxHeight:d,scale:t});e.setHeight(f)}Jd(s,t)})}function vm({canvas:n,origin:t,elements:e,...i}){const s={inset:{top:0,left:0},width:n.width,height:n.height,...t},o=Yd.Node.create();Xd(o,{layout:s}),o.calculateLayout();const{width:c,height:d}=o.getComputedLayout(),f=Math.min(c,d)/1080,p=qd(o,e,f);Jd(p,f),o.calculateLayout();const g=Qd(o,p);return Zd({...i,scale:f,canvas:n,position:g})}const ho=/(?<value>\d+\.?\d*)(?=px)/;function tu(n){const{visible:t=!0,node:e}=n,i=[...(e==null?void 0:e.elements)??[],...(n==null?void 0:n.elements)??[]];return t?e&&e.type!=="box"&&e.type!=="gradient"?!!e.value:i==null?void 0:i.some(s=>tu(s)):!1}function eu({canvas:n,debug:t=!1,elements:e=[],currentTime:i,relativeTime:s}){return e.map(o=>{var c,d,f,p,g,v,b,E;const{node:T}=o,w=n.getContext("2d");if(w&&tu(o)){let _=o.width,D=o.height;if((T==null?void 0:T.type)==="text"&&T.value){const M=to({text:T.value,font:T.font});w.save(),T.wrap?D=({width:F,maxHeight:x,scale:N})=>{var V,j;const rt=Wd({font:M,scale:N,context:w,maxW:F,maxH:x,text:T.value??"",minSize:(V=T.fill)==null?void 0:V.minSize,maxSize:(j=T.fill)==null?void 0:j.maxSize});return Ml({context:w,font:M,fontSize:rt,text:T.value??"",maxW:F}).length*rt}:(w.font=M,_=w.measureText(T.value).width,D=parseFloat(((d=(c=M.match(ho))==null?void 0:c.groups)==null?void 0:d.value)??"0")),w.restore()}if((T==null?void 0:T.type)==="image"&&T.image&&T.size){const M=((f=T.image)==null?void 0:f.naturalWidth)??((p=T.image)==null?void 0:p.width),F=((g=T.image)==null?void 0:g.naturalHeight)??((v=T.image)==null?void 0:v.height),x=M/F,N=(b=T.size)==null?void 0:b.width,V=(E=T.size)==null?void 0:E.height;_=N??(x>=1?(V??0)*x:(V??0)/x),D=V??(x<1?(N??0)*x:(N??0)/x)}return{...o,width:_,height:D,elements:eu({canvas:n,debug:t,elements:o.elements,currentTime:i,relativeTime:s}),draw:({canvas:M,cropCanvas:F,letterboxCanvas:x,context:N,dx:V,dy:j,dw:rt,dh:nt,scale:Q})=>{var Tt,gt,$t,Wt,H,J,St,$,U,X,mt,bt,xt;if(T){const{type:Ut,from:Qt=0,to:ue=1/0}=T;if(s>=Qt&&s<=ue){if(N.save(),s&&ue-.3333333333333333<=s&&(N.globalAlpha=1-(.16666666666666666-(ue-s))/.16666666666666666),Ut==="box"&&(N.fillStyle=T.background,N.fillRect(V,j,rt,nt)),Ut==="text"&&T.value){const se=to({text:T.value,font:T.font}),zt=Wd({font:se,scale:Q,context:N,maxW:rt,maxH:nt,text:T.value??"",minSize:(Tt=T.fill)==null?void 0:Tt.minSize,maxSize:(gt=T.fill)==null?void 0:gt.maxSize});N.font=se.replace(ho,zt.toString()),N.textBaseline="top",N.fillStyle=T.color,T.wrap?Ml({context:N,font:se,fontSize:zt,text:T.value,maxW:rt}).forEach((Oe,be)=>{N.fillText(Oe.text,V,j+zt*be)}):N.fillText(T.value,V,j)}if(Ut==="image"&&T.image&&N.drawImage(T.image,V,j,rt,nt),Ut==="video"&&(($t=T.video)!=null&&$t.node||(Wt=T.video)!=null&&Wt.getSource)){const se=T.format??"letterbox",zt=((J=(H=T.video)==null?void 0:H.getSource)==null?void 0:J.call(H,s))??T.video.node,Oe=(zt==null?void 0:zt.videoWidth)??(zt==null?void 0:zt.naturalWidth)??(zt==null?void 0:zt.width),be=(zt==null?void 0:zt.videoHeight)??(zt==null?void 0:zt.naturalHeight)??(zt==null?void 0:zt.height);if(Oe&&be){const{dx:ge,dy:oe,dw:Ce,dh:Ft}=Fd({context:N,cropCanvas:F,letterboxCanvas:x,source:zt,format:se,crop:(St=T==null?void 0:T.value)==null?void 0:St.crop,sourceWidth:Oe,sourceHeight:be,posX:V,posY:j,drawAreaWidth:rt,drawAreaHeight:nt});T.elements&&Bl({debug:t,canvas:M,cropCanvas:F,letterboxCanvas:x,currentTime:i,relativeTime:s,origin:{inset:{top:Math.max(j,j+oe),left:Math.max(V,V+ge)},width:Math.min(rt,Ce),height:Math.min(nt,Ft)},elements:T.elements})}const jt=1/3;if(T.poster&&i>=0&&i<=jt){N.save(),N.globalAlpha=1-i/jt;const ge=(($=T.poster)==null?void 0:$.naturalWidth)??((U=T.poster)==null?void 0:U.width),oe=((X=T.poster)==null?void 0:X.naturalHeight)??((mt=T.poster)==null?void 0:mt.height);if(ge&&oe){const{dx:Ce,dy:Ft,dw:Xe,dh:qe}=Fd({context:N,cropCanvas:F,letterboxCanvas:x,source:T.poster,format:se,crop:(bt=T==null?void 0:T.value)==null?void 0:bt.crop,sourceWidth:ge,sourceHeight:oe,posX:V,posY:j,drawAreaWidth:rt,drawAreaHeight:nt});T.elements&&Bl({debug:t,canvas:M,cropCanvas:F,letterboxCanvas:x,currentTime:i,relativeTime:s,origin:{inset:{top:Math.max(j,j+Ft),left:Math.max(V,V+Ce)},width:Math.min(rt,Xe),height:Math.min(nt,qe)},elements:T.elements})}N.restore()}}if(Ut==="gradient"&&T.value){const se=N.createLinearGradient(V+rt,j,V+rt,j+nt);(xt=T.value)==null||xt.forEach(zt=>{se.addColorStop(zt.percent,zt.color)}),N.fillStyle=se,N.fillRect(V,j,rt,nt)}N.restore()}}}}}}).filter(Boolean)}function Bl({canvas:n,debug:t,elements:e,currentTime:i,relativeTime:s,...o}){return vm({...o,debug:t,canvas:n,elements:eu({canvas:n,debug:t,elements:e,currentTime:i,relativeTime:s})})}const ym={id:"default",name:"None",template:{id:"basic",name:"Basic",layouts:[{name:"basic",tree:`[
88
95
  {
89
- "w": "fill",
90
- "h": "fill",
96
+ "width": "100%",
97
+ "height": "100%",
91
98
  "node": {
92
99
  "type": "video",
93
100
  "format": {{@ parse(it.videoFormat) /}},
94
101
  "value": {
95
102
  "id": {{@ parse(it.id) /}},
103
+ "key": {{@ parse(it.key) /}},
96
104
  "src": {{@async resolve-source({ sources: [it.mp4, it.input] }) /}},
97
105
  "playlist": {{@async resolve-source({ sources: [it.playlist] }) /}},
98
106
  "poster": {{@ parse(it.poster) /}},
99
107
  "captions": {{@ parse(it.captions) /}},
100
108
  "duration": {{@ parse(it.duration) /}},
101
109
  "startOffset": {{@ parse(it.startOffset) /}},
102
- "endOffset": {{@ parse(it.endOffset) /}}
110
+ "endOffset": {{@ parse(it.endOffset) /}},
111
+ "crop": {
112
+ "x": {{@ parse(it.crop?.x) /}},
113
+ "y": {{@ parse(it.crop?.y) /}},
114
+ "width": {{@ parse(it.crop?.width) /}},
115
+ "height": {{@ parse(it.crop?.height) /}}
116
+ }
103
117
  }
104
118
  }
105
119
  }
106
120
  ]`}],content:[{scenes:[{layout:"basic",data:`{
107
- "id": "{{ it.root?.answer?.id }}-intro",
121
+ "id": {{@ parse(it.root?.answer?.id) /}},
122
+ "key": "{{ it.root?.answer?.id }}-intro",
108
123
  "mp4": {{@ parse(it.root?.answer?.media?.video) /}},
109
124
  "input": {{@ parse(it.root?.answer?.media?.input) /}},
110
125
  "playlist": {{@ parse(it.root?.answer?.media?.playlist) /}},
111
- "poster": {{@ parse(it.root?.answer?.media?.preview) /}},
126
+ "poster": {{@ parse(it.root?.answer?.media?.thumbnail) /}},
112
127
  "captions": {{@ parse(it.root?.answer?.captions?.current) /}},
113
128
  "duration": {{@ parse(it.root?.answer?.metadata?.duration) /}},
114
129
  "startOffset": {{@ parse(it.root?.answer?.settings?.startOffset) /}},
115
- "endOffset": {{@ parse(it.root?.answer?.settings?.endOffset) /}}
130
+ "endOffset": {{@ parse(it.root?.answer?.settings?.endOffset) /}},
131
+ "crop": {
132
+ "x": {{@ parse(it.root?.answer?.settings?.crop?.x) /}},
133
+ "y": {{@ parse(it.root?.answer?.settings?.crop?.y) /}},
134
+ "width": {{@ parse(it.root?.answer?.settings?.crop?.width) /}},
135
+ "height": {{@ parse(it.root?.answer?.settings?.crop?.height) /}}
136
+ }
116
137
  }`}],root:"{{ it.intro?.questions?.items | stringify }}"},{scenes:[{layout:"basic",data:`{
117
138
  "id": {{@ parse(it.root?.answer?.id) /}},
139
+ "key": "{{ it.root?.answer?.id }}-{{ it.index }}",
118
140
  "mp4": {{@ parse(it.root?.answer?.media?.video) /}},
119
141
  "input": {{@ parse(it.root?.answer?.media?.input) /}},
120
142
  "playlist": {{@ parse(it.root?.answer?.media?.playlist) /}},
121
- "poster": {{@ parse(it.root?.answer?.media?.preview) /}},
143
+ "poster": {{@ parse(it.root?.answer?.media?.thumbnail) /}},
122
144
  "captions": {{@ parse(it.root?.answer?.captions?.current) /}},
123
145
  "duration": {{@ parse(it.root?.answer?.metadata?.duration) /}},
124
146
  "startOffset": {{@ parse(it.root?.answer?.settings?.startOffset) /}},
125
- "endOffset": {{@ parse(it.root?.answer?.settings?.endOffset) /}}
147
+ "endOffset": {{@ parse(it.root?.answer?.settings?.endOffset) /}},
148
+ "crop": {
149
+ "x": {{@ parse(it.root?.answer?.settings?.crop?.x) /}},
150
+ "y": {{@ parse(it.root?.answer?.settings?.crop?.y) /}},
151
+ "width": {{@ parse(it.root?.answer?.settings?.crop?.width) /}},
152
+ "height": {{@ parse(it.root?.answer?.settings?.crop?.height) /}}
153
+ }
126
154
  }`}],root:"{{ it.questions?.items | stringify }}"},{scenes:[{layout:"basic",data:`{
127
- "id": "{{ it.root?.answer?.id }}-outro",
155
+ "id": {{@ parse(it.root?.answer?.id) /}},
156
+ "key": "{{ it.root?.answer?.id }}-outro",
128
157
  "mp4": {{@ parse(it.root?.answer?.media?.video) /}},
129
158
  "input": {{@ parse(it.root?.answer?.media?.input) /}},
130
159
  "playlist": {{@ parse(it.root?.answer?.media?.playlist) /}},
131
- "poster": {{@ parse(it.root?.answer?.media?.preview) /}},
160
+ "poster": {{@ parse(it.root?.answer?.media?.thumbnail) /}},
132
161
  "captions": {{@ parse(it.root?.answer?.captions?.current) /}},
133
162
  "duration": {{@ parse(it.root?.answer?.metadata?.duration) /}},
134
163
  "startOffset": {{@ parse(it.root?.answer?.settings?.startOffset) /}},
135
- "endOffset": {{@ parse(it.root?.answer?.settings?.endOffset) /}}
136
- }`}],root:"{{ it.outro?.questions?.items | stringify }}"}]},meta:{frameRate:30,resolution:720,transitionDuration:1/3}};async function lu(){if(typeof window>"u"){const r=await Promise.resolve().then(()=>_c);return new r.Image}return new Image}const Io=ko(async function(r){return r?new Promise((t,e)=>{lu().then(i=>{i.onload=()=>{t(i)},i.onerror=s=>{e(s)},i.src=r})}):null});async function Jr({element:r},t,e){var i,s,n;let a={...r};const{node:o}=r;if((o==null?void 0:o.type)==="video"&&((i=o==null?void 0:o.value)!=null&&i.src||(s=o==null?void 0:o.value)!=null&&s.playlist)){const l=await t(o.value);let h;try{h=await Io(o.value.poster)}catch{h=null}a={...a,node:{...o,video:l,poster:h,meta:await e(o.value,l.node)}}}if((o==null?void 0:o.type)==="image"&&o.value){let l;try{l=await Io(o.value)}catch{l=null}a={...a,node:{...o,image:l}}}return a.node&&(n=r.node)!=null&&n.elements&&(a.node.elements=await Promise.all(r.node.elements.map(l=>Jr({element:l},t,e)))),r.elements&&(a.elements=await Promise.all(r.elements.map(l=>Jr({element:l},t,e)))),a}async function Do(){if(typeof window>"u"){const r=await Promise.resolve().then(()=>_c),t=new r.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function hu(r){var t;try{if((t=await Bd(r,{method:"HEAD"}))!=null&&t.ok)return r}catch{return}}async function cu({sources:r}){let t=null;if(r){const e=r.filter(Boolean).map(i=>hu(i));t=(await Promise.all(e)).find(Boolean)}return t}ei.filters.define("stringify",r=>JSON.stringify(r)),ei.filters.define("nullify",r=>typeof r>"u"?null:r),ei.filters.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))}),ei.helpers.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}),ei.helpers.define("resolve-source",ko(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 cu({sources:t});return n?`"${n}"`:"null"},{cacheKey:([r])=>JSON.stringify(r.params[0]??{})}));const Ks=(r,t,e)=>ei.render(r,t,ei.getConfig({autoEscape:!1,defaultFilter:"nullify",async:!0,asyncHelpers:["resolve-source"],...e}));function tn(r=[]){var t;for(const e of r){if(((t=e==null?void 0:e.node)==null?void 0:t.type)==="video")return e.node;const i=tn(e==null?void 0:e.elements);if(i)return i}}async function Co({data:r,template:t,burnCaptions:e=!1},i,s){var n,a,o;const l=t??ou,h=(await Promise.all(l.template.content.map(async({scenes:p,root:g})=>{const v={...l.options,...r,intro:l.intro,outro:l.outro};async function E(A){return Promise.all(p.map(async({layout:L,duration:y,data:S,options:R})=>{var D,M,C;const I=S?JSON.parse(await Ks(S,{...v,root:A})):{},G=R?JSON.parse(await Ks(R,v)):{},F=(D=l.template.layouts.find(P=>P.name===L))==null?void 0:D.tree,V=JSON.parse(await Ks(F,{...I,...G})),q=await Promise.all(V.flatMap(P=>Jr({element:P},i,s))),w=tn(q);return{duration:y??((M=w==null?void 0:w.meta)==null?void 0:M.duration)??0,captions:(C=w==null?void 0:w.meta)==null?void 0:C.captions,elements:q}}))}if(g){const A=JSON.parse(await Ks(g,v));return Array.isArray(A)?(await Promise.all(A.map(async L=>E(L)))).flatMap(L=>L):E(A)}return E(r)}))).flatMap(p=>p).filter(p=>p.duration>0),c=((n=l.meta)==null?void 0:n.frameRate)??30,d=((a=l.meta)==null?void 0:a.resolution)??720,u=((o=l.meta)==null?void 0:o.transitionDuration)??1/3,f=await Promise.all(h.map(async({duration:p,captions:g,elements:v},E)=>{var A,L;const y=await Do(),S=await Do(),R=tn(v),D=h.reduce((M,C,I)=>(I<E&&(M+=C.duration-u/2),M),0);return{draw:({canvas:M,currentTime:C})=>{const I=Math.max(0,C-D);Zr({canvas:M,elements:v,currentTime:C,relativeTime:I,offscreenCanvas:y}),g&&e&&Yd({canvas:M,dx:0,dy:0,dw:M.width,dh:M.height,vttCaptions:g,relativeTime:I+((R==null?void 0:R.meta.start)??0)})},duration:p,transitionCanvas:S,start:D,video:R==null?void 0:R.video,videoMeta:R==null?void 0:R.meta,audio:{duration:p,src:(A=R==null?void 0:R.value)==null?void 0:A.src,start:(L=R==null?void 0:R.meta)==null?void 0:L.start}}}));return{scenes:f,frameRate:c,resolution:d,transitionDuration:u,fonts:l.template.fonts??[],duration:Math.max(0,...f.map(({start:p,duration:g})=>p+g))}}/**
137
- * @license
138
- * Copyright 2017 Google LLC
139
- * SPDX-License-Identifier: BSD-3-Clause
140
- */const Ji={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},ts=r=>(...t)=>({_$litDirective$:r,values:t});class js{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)}}/**
164
+ "endOffset": {{@ parse(it.root?.answer?.settings?.endOffset) /}},
165
+ "crop": {
166
+ "x": {{@ parse(it.root?.answer?.settings?.crop?.x) /}},
167
+ "y": {{@ parse(it.root?.answer?.settings?.crop?.y) /}},
168
+ "width": {{@ parse(it.root?.answer?.settings?.crop?.width) /}},
169
+ "height": {{@ parse(it.root?.answer?.settings?.crop?.height) /}}
170
+ }
171
+ }`}],root:"{{ it.outro?.questions?.items | stringify }}"}]},meta:{frameRate:30,resolution:720,transitionDuration:1/3}};async function bm(){if(typeof window>"u"){const n=await Promise.resolve().then(()=>tp);return new n.Image}return new Image}const iu=ys(async function(n){return n?new Promise((t,e)=>{bm().then(i=>{i.onload=()=>{t(i)},i.onerror=s=>{e(s)},i.src=n})}):null});async function Gl({element:n},t,e){var i,s,o;let c={...n};const{node:d}=n;if((d==null?void 0:d.type)==="video"&&((i=d==null?void 0:d.value)!=null&&i.src||(s=d==null?void 0:d.value)!=null&&s.playlist)){const f=await t(d.value);let p;try{p=await iu(d.value.poster)}catch{p=null}c={...c,node:{...d,video:f,poster:p,meta:await e(d.value,f.node)}}}if((d==null?void 0:d.type)==="image"&&d.value){let f;try{f=await iu(d.value)}catch{f=null}c={...c,node:{...d,image:f}}}return c.node&&(o=n.node)!=null&&o.elements&&(c.node.elements=await Promise.all(n.node.elements.map(f=>Gl({element:f},t,e)))),n.elements&&(c.elements=await Promise.all(n.elements.map(f=>Gl({element:f},t,e)))),c}async function Hl(){if(typeof window>"u"){const n=await Promise.resolve().then(()=>tp),t=new n.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function Am(n){var t;try{if((t=await zg(n,{method:"HEAD"}))!=null&&t.ok)return n}catch{return}}async function Em({sources:n}){let t=null;if(n){const e=n.filter(Boolean).map(i=>Am(i));t=(await Promise.all(e)).find(Boolean)}return t}Qs.filters.define("stringify",n=>JSON.stringify(n)),Qs.filters.define("nullify",n=>typeof n>"u"?null:n),Qs.filters.define("filter",(n,t)=>{if(!t)return n;if(!Array.isArray(n))throw new Error("Data for filter must be an array");return n.filter((e,i)=>t.includes(i))}),Qs.helpers.define("parse",n=>{const t=n.params[0];if(typeof t=="string"){let e=t;return e=e.replace(/\n/g,"\\n"),e=e.replace(/\r/g,"\\r"),e=e.replace(/"/g,'\\"'),`"${e}"`}return typeof t>"u"?null:t}),Qs.helpers.define("resolve-source",ys(async n=>{const{sources:t}=n.params[0]??{},e=t==null?void 0:t.filter(Boolean),i=e==null?void 0:e.find(c=>c.includes("blob:")),s=e==null?void 0:e.find(c=>!c.includes("http")),o=i??s??await Em({sources:t});return o?`"${o}"`:"null"},{cacheKey:([n])=>JSON.stringify(n.params[0]??{})}));const fa=(n,t,e)=>Qs.render(n,t,Qs.getConfig({autoEscape:!1,defaultFilter:"nullify",async:!0,asyncHelpers:["resolve-source"],...e}));function Vl(n=[]){var t;for(const e of n){if(((t=e==null?void 0:e.node)==null?void 0:t.type)==="video")return e.node;const i=Vl(e==null?void 0:e.elements);if(i)return i}}async function uo({data:n,template:t,burnCaptions:e=!1,debug:i=!1},s,o){var c,d,f;const p=t??ym,g=(await Promise.all(p.template.content.map(async({scenes:w,root:_})=>{const D={...p.options,...n,intro:p.intro,outro:p.outro};async function M(F,x){return Promise.all(w.map(async({layout:N,duration:V,data:j,options:rt})=>{var nt,Q,Tt;const gt={...D,index:x,root:F},$t=j?JSON.parse(await fa(j,gt)):{},Wt=rt?JSON.parse(await fa(rt,gt)):{},H=V?parseFloat(await fa(V,gt)):NaN,J=(nt=p.template.layouts.find(X=>X.name===N))==null?void 0:nt.tree,St=JSON.parse(await fa(J,{...$t,...Wt})),$=await Promise.all(St.flatMap(X=>Gl({element:X},s,o))),U=Vl($);return{duration:(isNaN(H)?null:H)??((Q=U==null?void 0:U.meta)==null?void 0:Q.duration)??0,captions:(Tt=U==null?void 0:U.meta)==null?void 0:Tt.captions,elements:$}}))}if(_){const F=JSON.parse(await fa(_,D));return Array.isArray(F)?(await Promise.all(F.map(async(x,N)=>M(x,N)))).flatMap(x=>x):M(F,null)}return M(n,null)}))).flatMap(w=>w).filter(w=>w.duration>0),v=((c=p.meta)==null?void 0:c.frameRate)??30,b=((d=p.meta)==null?void 0:d.resolution)??720,E=((f=p.meta)==null?void 0:f.transitionDuration)??1/3,T=await Promise.all(g.map(async({duration:w,captions:_,elements:D},M)=>{var F,x;const N=await Hl(),V=await Hl(),j=await Hl(),rt=Vl(D),nt=g.reduce((Q,Tt,gt)=>(gt<M&&(Q+=Tt.duration-E/2),Q),0);return{draw:({canvas:Q,currentTime:Tt})=>{const gt=Math.max(0,Tt-nt);Bl({debug:i,canvas:Q,elements:D,currentTime:Tt,relativeTime:gt,cropCanvas:N,letterboxCanvas:V}),_&&e&&tm({canvas:Q,dx:0,dy:0,dw:Q.width,dh:Q.height,vttCaptions:_,relativeTime:gt+((rt==null?void 0:rt.meta.start)??0)})},duration:w,transitionCanvas:j,start:nt,video:rt==null?void 0:rt.video,videoMeta:rt==null?void 0:rt.meta,audio:{duration:w,src:(F=rt==null?void 0:rt.value)==null?void 0:F.src,start:(x=rt==null?void 0:rt.meta)==null?void 0:x.start}}}));return{scenes:T,frameRate:v,resolution:b,transitionDuration:E,fonts:p.template.fonts??[],duration:Math.max(0,...T.map(({start:w,duration:_})=>w+_))}}/**
141
172
  * @license
142
173
  * Copyright 2018 Google LLC
143
174
  * SPDX-License-Identifier: BSD-3-Clause
144
- */const wt=ts(class extends js{constructor(r){var t;if(super(r),r.type!==Ji.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 Ee}});/**
175
+ */const Ke=An(class extends na{constructor(n){var t;if(super(n),n.type!==bn.ATTRIBUTE||n.name!=="class"||((t=n.strings)==null?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(n){return" "+Object.keys(n).filter(t=>n[t]).join(" ")+" "}update(n,[t]){var i,s;if(this.it===void 0){this.it=new Set,n.strings!==void 0&&(this.st=new Set(n.strings.join(" ").split(/\s/).filter(o=>o!=="")));for(const o in t)t[o]&&!((i=this.st)!=null&&i.has(o))&&this.it.add(o);return this.render(t)}const e=n.element.classList;for(const o of this.it)o in t||(e.remove(o),this.it.delete(o));for(const o in t){const c=!!t[o];c===this.it.has(o)||(s=this.st)!=null&&s.has(o)||(c?(e.add(o),this.it.add(o)):(e.remove(o),this.it.delete(o)))}return fs}});/**
145
176
  * @license
146
177
  * Copyright 2018 Google LLC
147
178
  * SPDX-License-Identifier: BSD-3-Clause
148
- */const es=r=>r??It;/**
149
- * @license
150
- * Copyright 2020 Google LLC
151
- * SPDX-License-Identifier: BSD-3-Clause
152
- */const{I:du}=Yc,uu=r=>r.strings===void 0,xo=()=>document.createComment(""),is=(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(xo(),n),o=s.insertBefore(xo(),n);e=new du(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 c=h.nextSibling;s.insertBefore(h,n),h=c}}}return e},ii=(r,t,e=r)=>(r._$AI(t,e),r),fu={},pu=(r,t=fu)=>r._$AH=t,gu=r=>r._$AH,en=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}};/**
179
+ */const ru="important",Tm=" !"+ru,Wl=An(class extends na{constructor(n){var t;if(super(n),n.type!==bn.ATTRIBUTE||n.name!=="style"||((t=n.strings)==null?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(n){return Object.keys(n).reduce((t,e)=>{const i=n[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(n,[t]){const{style:e}=n.element;if(this.ut===void 0)return this.ut=new Set(Object.keys(t)),this.render(t);for(const i of this.ut)t[i]==null&&(this.ut.delete(i),i.includes("-")?e.removeProperty(i):e[i]=null);for(const i in t){const s=t[i];if(s!=null){this.ut.add(i);const o=typeof s=="string"&&s.endsWith(Tm);i.includes("-")||o?e.setProperty(i,o?s.slice(0,-11):s,o?ru:""):e[i]=s}}return fs}});var km=pa;pa.flatten=pa,pa.unflatten=au;function su(n){return n&&n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function nu(n){return n}function pa(n,t){t=t||{};const e=t.delimiter||".",i=t.maxDepth,s=t.transformKey||nu,o={};function c(d,f,p){p=p||1,Object.keys(d).forEach(function(g){const v=d[g],b=t.safe&&Array.isArray(v),E=Object.prototype.toString.call(v),T=su(v),w=E==="[object Object]"||E==="[object Array]",_=f?f+e+s(g):s(g);if(!b&&!T&&w&&Object.keys(v).length&&(!t.maxDepth||p<i))return c(v,_,p+1);o[_]=v})}return c(n),o}function au(n,t){t=t||{};const e=t.delimiter||".",i=t.overwrite||!1,s=t.transformKey||nu,o={};if(su(n)||Object.prototype.toString.call(n)!=="[object Object]")return n;function d(g){const v=Number(g);return isNaN(v)||g.indexOf(".")!==-1||t.object?g:v}function f(g,v,b){return Object.keys(b).reduce(function(E,T){return E[g+e+T]=b[T],E},v)}function p(g){const v=Object.prototype.toString.call(g),b=v==="[object Array]",E=v==="[object Object]";if(g){if(b)return!g.length;if(E)return!Object.keys(g).length}else return!0}return n=Object.keys(n).reduce(function(g,v){const b=Object.prototype.toString.call(n[v]);return!(b==="[object Object]"||b==="[object Array]")||p(n[v])?(g[v]=n[v],g):f(v,g,pa(n[v],t))},{}),Object.keys(n).forEach(function(g){const v=g.split(e).map(s);let b=d(v.shift()),E=d(v[0]),T=o;for(;E!==void 0;){if(b==="__proto__")return;const w=Object.prototype.toString.call(T[b]),_=w==="[object Object]"||w==="[object Array]";if(!i&&!_&&typeof T[b]<"u")return;(i&&!_||!i&&T[b]==null)&&(T[b]=typeof E=="number"&&!t.object?[]:{}),T=T[b],v.length>0&&(b=d(v.shift()),E=d(v[0]))}T[b]=au(n[g],t)}),o}const wm=Il(km);/**
153
180
  * @license
154
181
  * Copyright 2017 Google LLC
155
182
  * SPDX-License-Identifier: BSD-3-Clause
156
- */const ss=(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),ss(n,t);return!0},Ws=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)},Po=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),yu(t)}};function mu(r){this._$AN!==void 0?(Ws(this),this._$AM=r,Po(this)):this._$AM=r}function vu(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++)ss(i[n],!1),Ws(i[n]);else i!=null&&(ss(i,!1),Ws(i));else ss(this,r)}const yu=r=>{var t,e,i,s;r.type==Ji.CHILD&&((t=(i=r)._$AP)!==null&&t!==void 0||(i._$AP=vu),(e=(s=r)._$AQ)!==null&&e!==void 0||(s._$AQ=mu))};let Oo=class extends js{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),Po(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&&(ss(this,t),Ws(this))}setValue(t){if(uu(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(){}};/**
157
- * @license
158
- * Copyright 2020 Google LLC
159
- * SPDX-License-Identifier: BSD-3-Clause
160
- */const be=()=>new Eu;class Eu{}const sn=new WeakMap,Te=ts(class extends Oo{render(r){return It}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)),It}ot(r){var t;if(typeof this.G=="function"){const e=(t=this.ct)!==null&&t!==void 0?t:globalThis;let i=sn.get(e);i===void 0&&(i=new WeakMap,sn.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=sn.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 bu=rs;rs.flatten=rs,rs.unflatten=Fo;function $o(r){return r&&r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function Mo(r){return r}function rs(r,t){t=t||{};const e=t.delimiter||".",i=t.maxDepth,s=t.transformKey||Mo,n={};function a(o,l,h){h=h||1,Object.keys(o).forEach(function(c){const d=o[c],u=t.safe&&Array.isArray(d),f=Object.prototype.toString.call(d),p=$o(d),g=f==="[object Object]"||f==="[object Array]",v=l?l+e+s(c):s(c);if(!u&&!p&&g&&Object.keys(d).length&&(!t.maxDepth||h<i))return a(d,v,h+1);n[v]=d})}return a(r),n}function Fo(r,t){t=t||{};const e=t.delimiter||".",i=t.overwrite||!1,s=t.transformKey||Mo,n={};if($o(r)||Object.prototype.toString.call(r)!=="[object Object]")return r;function o(c){const d=Number(c);return isNaN(d)||c.indexOf(".")!==-1||t.object?c:d}function l(c,d,u){return Object.keys(u).reduce(function(f,p){return f[c+e+p]=u[p],f},d)}function h(c){const d=Object.prototype.toString.call(c),u=d==="[object Array]",f=d==="[object Object]";if(c){if(u)return!c.length;if(f)return!Object.keys(c).length}else return!0}return r=Object.keys(r).reduce(function(c,d){const u=Object.prototype.toString.call(r[d]);return!(u==="[object Object]"||u==="[object Array]")||h(r[d])?(c[d]=r[d],c):l(d,c,rs(r[d],t))},{}),Object.keys(r).forEach(function(c){const d=c.split(e).map(s);let u=o(d.shift()),f=o(d[0]),p=n;for(;f!==void 0;){if(u==="__proto__")return;const g=Object.prototype.toString.call(p[u]),v=g==="[object Object]"||g==="[object Array]";if(!i&&!v&&typeof p[u]<"u")return;(i&&!v||!i&&p[u]==null)&&(p[u]=typeof f=="number"&&!t.object?[]:{}),p=p[u],d.length>0&&(u=o(d.shift()),f=o(d[0]))}p[u]=Fo(r[c],t)}),n}const Tu=zr(bu);/**
161
- * @license
162
- * Copyright 2017 Google LLC
163
- * SPDX-License-Identifier: BSD-3-Clause
164
- */const No=(r,t,e)=>{const i=new Map;for(let s=t;s<=e;s++)i.set(r[s],s);return i},Uo=ts(class extends js{constructor(r){if(super(r),r.type!==Ji.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=gu(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 c,d,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]=ii(n[u],a[p]),u++,p++;else if(l[f]===o[g])h[g]=ii(n[f],a[g]),f--,g--;else if(l[u]===o[g])h[g]=ii(n[u],a[g]),is(r,h[g+1],n[u]),u++,g--;else if(l[f]===o[p])h[p]=ii(n[f],a[p]),is(r,n[u],n[f]),f--,p++;else if(c===void 0&&(c=No(o,p,g),d=No(l,u,f)),c.has(l[u]))if(c.has(l[f])){const v=d.get(o[p]),E=v!==void 0?n[v]:null;if(E===null){const A=is(r,n[u]);ii(A,a[p]),h[p]=A}else h[p]=ii(E,a[p]),is(r,n[u],E),n[v]=null;p++}else en(n[f]),f--;else en(n[u]),u++;for(;p<=g;){const v=is(r,h[g+1]);ii(v,a[p]),h[p++]=v}for(;u<=f;){const v=n[u++];v!==null&&en(v)}return this.ht=o,pu(r,h),Ee}});var zt="top",ae="bottom",oe="right",Xt="left",rn="auto",ns=[zt,ae,oe,Xt],Ti="start",as="end",Au="clippingParents",Bo="viewport",os="popper",wu="reference",Ho=ns.reduce(function(r,t){return r.concat([t+"-"+Ti,t+"-"+as])},[]),Go=[].concat(ns,[rn]).reduce(function(r,t){return r.concat([t,t+"-"+Ti,t+"-"+as])},[]),Su="beforeRead",Lu="read",Ru="afterRead",_u="beforeMain",ku="main",Iu="afterMain",Du="beforeWrite",Cu="write",xu="afterWrite",Pu=[Su,Lu,Ru,_u,ku,Iu,Du,Cu,xu];function Ae(r){return r?(r.nodeName||"").toLowerCase():null}function ie(r){if(r==null)return window;if(r.toString()!=="[object Window]"){var t=r.ownerDocument;return t&&t.defaultView||window}return r}function si(r){var t=ie(r).Element;return r instanceof t||r instanceof Element}function le(r){var t=ie(r).HTMLElement;return r instanceof t||r instanceof HTMLElement}function nn(r){if(typeof ShadowRoot>"u")return!1;var t=ie(r).ShadowRoot;return r instanceof t||r instanceof ShadowRoot}function Ou(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];!le(n)||!Ae(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 $u(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},{});!le(s)||!Ae(s)||(Object.assign(s.style,o),Object.keys(n).forEach(function(l){s.removeAttribute(l)}))})}}const Vo={name:"applyStyles",enabled:!0,phase:"write",fn:Ou,effect:$u,requires:["computeStyles"]};function we(r){return r.split("-")[0]}var ri=Math.max,Ys=Math.min,Ai=Math.round;function an(){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 Ko(){return!/^((?!chrome|android).)*safari/i.test(an())}function wi(r,t,e){t===void 0&&(t=!1),e===void 0&&(e=!1);var i=r.getBoundingClientRect(),s=1,n=1;t&&le(r)&&(s=r.offsetWidth>0&&Ai(i.width)/r.offsetWidth||1,n=r.offsetHeight>0&&Ai(i.height)/r.offsetHeight||1);var a=si(r)?ie(r):window,o=a.visualViewport,l=!Ko()&&e,h=(i.left+(l&&o?o.offsetLeft:0))/s,c=(i.top+(l&&o?o.offsetTop:0))/n,d=i.width/s,u=i.height/n;return{width:d,height:u,top:c,right:h+d,bottom:c+u,left:h,x:h,y:c}}function on(r){var t=wi(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 jo(r,t){var e=t.getRootNode&&t.getRootNode();if(r.contains(t))return!0;if(e&&nn(e)){var i=t;do{if(i&&r.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function $e(r){return ie(r).getComputedStyle(r)}function Mu(r){return["table","td","th"].indexOf(Ae(r))>=0}function Ge(r){return((si(r)?r.ownerDocument:r.document)||window.document).documentElement}function qs(r){return Ae(r)==="html"?r:r.assignedSlot||r.parentNode||(nn(r)?r.host:null)||Ge(r)}function Wo(r){return!le(r)||$e(r).position==="fixed"?null:r.offsetParent}function Fu(r){var t=/firefox/i.test(an()),e=/Trident/i.test(an());if(e&&le(r)){var i=$e(r);if(i.position==="fixed")return null}var s=qs(r);for(nn(s)&&(s=s.host);le(s)&&["html","body"].indexOf(Ae(s))<0;){var n=$e(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 ls(r){for(var t=ie(r),e=Wo(r);e&&Mu(e)&&$e(e).position==="static";)e=Wo(e);return e&&(Ae(e)==="html"||Ae(e)==="body"&&$e(e).position==="static")?t:e||Fu(r)||t}function ln(r){return["top","bottom"].indexOf(r)>=0?"x":"y"}function hs(r,t,e){return ri(r,Ys(t,e))}function Nu(r,t,e){var i=hs(r,t,e);return i>e?e:i}function Yo(){return{top:0,right:0,bottom:0,left:0}}function qo(r){return Object.assign({},Yo(),r)}function zo(r,t){return t.reduce(function(e,i){return e[i]=r,e},{})}var Uu=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,qo(typeof t!="number"?t:zo(t,ns))};function Bu(r){var t,e=r.state,i=r.name,s=r.options,n=e.elements.arrow,a=e.modifiersData.popperOffsets,o=we(e.placement),l=ln(o),h=[Xt,oe].indexOf(o)>=0,c=h?"height":"width";if(!(!n||!a)){var d=Uu(s.padding,e),u=on(n),f=l==="y"?zt:Xt,p=l==="y"?ae:oe,g=e.rects.reference[c]+e.rects.reference[l]-a[l]-e.rects.popper[c],v=a[l]-e.rects.reference[l],E=ls(n),A=E?l==="y"?E.clientHeight||0:E.clientWidth||0:0,L=g/2-v/2,y=d[f],S=A-u[c]-d[p],R=A/2-u[c]/2+L,D=hs(y,R,S),M=l;e.modifiersData[i]=(t={},t[M]=D,t.centerOffset=D-R,t)}}function Hu(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)||jo(t.elements.popper,s)&&(t.elements.arrow=s))}const Gu={name:"arrow",enabled:!0,phase:"main",fn:Bu,effect:Hu,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Si(r){return r.split("-")[1]}var Vu={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Ku(r,t){var e=r.x,i=r.y,s=t.devicePixelRatio||1;return{x:Ai(e*s)/s||0,y:Ai(i*s)/s||0}}function Xo(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,c=r.roundOffsets,d=r.isFixed,u=a.x,f=u===void 0?0:u,p=a.y,g=p===void 0?0:p,v=typeof c=="function"?c({x:f,y:g}):{x:f,y:g};f=v.x,g=v.y;var E=a.hasOwnProperty("x"),A=a.hasOwnProperty("y"),L=Xt,y=zt,S=window;if(h){var R=ls(e),D="clientHeight",M="clientWidth";if(R===ie(e)&&(R=Ge(e),$e(R).position!=="static"&&o==="absolute"&&(D="scrollHeight",M="scrollWidth")),R=R,s===zt||(s===Xt||s===oe)&&n===as){y=ae;var C=d&&R===S&&S.visualViewport?S.visualViewport.height:R[D];g-=C-i.height,g*=l?1:-1}if(s===Xt||(s===zt||s===ae)&&n===as){L=oe;var I=d&&R===S&&S.visualViewport?S.visualViewport.width:R[M];f-=I-i.width,f*=l?1:-1}}var G=Object.assign({position:o},h&&Vu),F=c===!0?Ku({x:f,y:g},ie(e)):{x:f,y:g};if(f=F.x,g=F.y,l){var V;return Object.assign({},G,(V={},V[y]=A?"0":"",V[L]=E?"0":"",V.transform=(S.devicePixelRatio||1)<=1?"translate("+f+"px, "+g+"px)":"translate3d("+f+"px, "+g+"px, 0)",V))}return Object.assign({},G,(t={},t[y]=A?g+"px":"",t[L]=E?f+"px":"",t.transform="",t))}function ju(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:we(t.placement),variation:Si(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,Xo(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,Xo(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 Wu={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:ju,data:{}};var zs={passive:!0};function Yu(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=ie(t.elements.popper),h=[].concat(t.scrollParents.reference,t.scrollParents.popper);return n&&h.forEach(function(c){c.addEventListener("scroll",e.update,zs)}),o&&l.addEventListener("resize",e.update,zs),function(){n&&h.forEach(function(c){c.removeEventListener("scroll",e.update,zs)}),o&&l.removeEventListener("resize",e.update,zs)}}const qu={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Yu,data:{}};var zu={left:"right",right:"left",bottom:"top",top:"bottom"};function Xs(r){return r.replace(/left|right|bottom|top/g,function(t){return zu[t]})}var Xu={start:"end",end:"start"};function Qo(r){return r.replace(/start|end/g,function(t){return Xu[t]})}function hn(r){var t=ie(r),e=t.pageXOffset,i=t.pageYOffset;return{scrollLeft:e,scrollTop:i}}function cn(r){return wi(Ge(r)).left+hn(r).scrollLeft}function Qu(r,t){var e=ie(r),i=Ge(r),s=e.visualViewport,n=i.clientWidth,a=i.clientHeight,o=0,l=0;if(s){n=s.width,a=s.height;var h=Ko();(h||!h&&t==="fixed")&&(o=s.offsetLeft,l=s.offsetTop)}return{width:n,height:a,x:o+cn(r),y:l}}function Zu(r){var t,e=Ge(r),i=hn(r),s=(t=r.ownerDocument)==null?void 0:t.body,n=ri(e.scrollWidth,e.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),a=ri(e.scrollHeight,e.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),o=-i.scrollLeft+cn(r),l=-i.scrollTop;return $e(s||e).direction==="rtl"&&(o+=ri(e.clientWidth,s?s.clientWidth:0)-n),{width:n,height:a,x:o,y:l}}function dn(r){var t=$e(r),e=t.overflow,i=t.overflowX,s=t.overflowY;return/auto|scroll|overlay|hidden/.test(e+s+i)}function Zo(r){return["html","body","#document"].indexOf(Ae(r))>=0?r.ownerDocument.body:le(r)&&dn(r)?r:Zo(qs(r))}function cs(r,t){var e;t===void 0&&(t=[]);var i=Zo(r),s=i===((e=r.ownerDocument)==null?void 0:e.body),n=ie(i),a=s?[n].concat(n.visualViewport||[],dn(i)?i:[]):i,o=t.concat(a);return s?o:o.concat(cs(qs(a)))}function un(r){return Object.assign({},r,{left:r.x,top:r.y,right:r.x+r.width,bottom:r.y+r.height})}function Ju(r,t){var e=wi(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 Jo(r,t,e){return t===Bo?un(Qu(r,e)):si(t)?Ju(t,e):un(Zu(Ge(r)))}function tf(r){var t=cs(qs(r)),e=["absolute","fixed"].indexOf($e(r).position)>=0,i=e&&le(r)?ls(r):r;return si(i)?t.filter(function(s){return si(s)&&jo(s,i)&&Ae(s)!=="body"}):[]}function ef(r,t,e,i){var s=t==="clippingParents"?tf(r):[].concat(t),n=[].concat(s,[e]),a=n[0],o=n.reduce(function(l,h){var c=Jo(r,h,i);return l.top=ri(c.top,l.top),l.right=Ys(c.right,l.right),l.bottom=Ys(c.bottom,l.bottom),l.left=ri(c.left,l.left),l},Jo(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 tl(r){var t=r.reference,e=r.element,i=r.placement,s=i?we(i):null,n=i?Si(i):null,a=t.x+t.width/2-e.width/2,o=t.y+t.height/2-e.height/2,l;switch(s){case zt:l={x:a,y:t.y-e.height};break;case ae:l={x:a,y:t.y+t.height};break;case oe:l={x:t.x+t.width,y:o};break;case Xt: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 c=h==="y"?"height":"width";switch(n){case Ti:l[h]=l[h]-(t[c]/2-e[c]/2);break;case as:l[h]=l[h]+(t[c]/2-e[c]/2);break}}return l}function ds(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?Au:o,h=e.rootBoundary,c=h===void 0?Bo:h,d=e.elementContext,u=d===void 0?os:d,f=e.altBoundary,p=f===void 0?!1:f,g=e.padding,v=g===void 0?0:g,E=qo(typeof v!="number"?v:zo(v,ns)),A=u===os?wu:os,L=r.rects.popper,y=r.elements[p?A:u],S=ef(si(y)?y:y.contextElement||Ge(r.elements.popper),l,c,a),R=wi(r.elements.reference),D=tl({reference:R,element:L,strategy:"absolute",placement:s}),M=un(Object.assign({},L,D)),C=u===os?M:R,I={top:S.top-C.top+E.top,bottom:C.bottom-S.bottom+E.bottom,left:S.left-C.left+E.left,right:C.right-S.right+E.right},G=r.modifiersData.offset;if(u===os&&G){var F=G[s];Object.keys(I).forEach(function(V){var q=[oe,ae].indexOf(V)>=0?1:-1,w=[zt,ae].indexOf(V)>=0?"y":"x";I[V]+=F[w]*q})}return I}function sf(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?Go:l,c=Si(i),d=c?o?Ho:Ho.filter(function(p){return Si(p)===c}):ns,u=d.filter(function(p){return h.indexOf(p)>=0});u.length===0&&(u=d);var f=u.reduce(function(p,g){return p[g]=ds(r,{placement:g,boundary:s,rootBoundary:n,padding:a})[we(g)],p},{});return Object.keys(f).sort(function(p,g){return f[p]-f[g]})}function rf(r){if(we(r)===rn)return[];var t=Xs(r);return[Qo(r),t,Qo(t)]}function nf(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,c=e.boundary,d=e.rootBoundary,u=e.altBoundary,f=e.flipVariations,p=f===void 0?!0:f,g=e.allowedAutoPlacements,v=t.options.placement,E=we(v),A=E===v,L=l||(A||!p?[Xs(v)]:rf(v)),y=[v].concat(L).reduce(function(W,X){return W.concat(we(X)===rn?sf(t,{placement:X,boundary:c,rootBoundary:d,padding:h,flipVariations:p,allowedAutoPlacements:g}):X)},[]),S=t.rects.reference,R=t.rects.popper,D=new Map,M=!0,C=y[0],I=0;I<y.length;I++){var G=y[I],F=we(G),V=Si(G)===Ti,q=[zt,ae].indexOf(F)>=0,w=q?"width":"height",P=ds(t,{placement:G,boundary:c,rootBoundary:d,altBoundary:u,padding:h}),H=q?V?oe:Xt:V?ae:zt;S[w]>R[w]&&(H=Xs(H));var b=Xs(H),T=[];if(n&&T.push(P[F]<=0),o&&T.push(P[H]<=0,P[b]<=0),T.every(function(W){return W})){C=G,M=!1;break}D.set(G,T)}if(M)for(var k=p?3:1,N=function(X){var lt=y.find(function(rt){var at=D.get(rt);if(at)return at.slice(0,X).every(function(Rt){return Rt})});if(lt)return C=lt,"break"},U=k;U>0;U--){var K=N(U);if(K==="break")break}t.placement!==C&&(t.modifiersData[i]._skip=!0,t.placement=C,t.reset=!0)}}const af={name:"flip",enabled:!0,phase:"main",fn:nf,requiresIfExists:["offset"],data:{_skip:!1}};function el(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 il(r){return[zt,oe,ae,Xt].some(function(t){return r[t]>=0})}function of(r){var t=r.state,e=r.name,i=t.rects.reference,s=t.rects.popper,n=t.modifiersData.preventOverflow,a=ds(t,{elementContext:"reference"}),o=ds(t,{altBoundary:!0}),l=el(a,i),h=el(o,s,n),c=il(l),d=il(h);t.modifiersData[e]={referenceClippingOffsets:l,popperEscapeOffsets:h,isReferenceHidden:c,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":c,"data-popper-escaped":d})}const lf={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:of};function hf(r,t,e){var i=we(r),s=[Xt,zt].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,[Xt,oe].indexOf(i)>=0?{x:o,y:a}:{x:a,y:o}}function cf(r){var t=r.state,e=r.options,i=r.name,s=e.offset,n=s===void 0?[0,0]:s,a=Go.reduce(function(c,d){return c[d]=hf(d,t.rects,n),c},{}),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 df={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:cf};function uf(r){var t=r.state,e=r.name;t.modifiersData[e]=tl({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const ff={name:"popperOffsets",enabled:!0,phase:"read",fn:uf,data:{}};function pf(r){return r==="x"?"y":"x"}function gf(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,c=e.altBoundary,d=e.padding,u=e.tether,f=u===void 0?!0:u,p=e.tetherOffset,g=p===void 0?0:p,v=ds(t,{boundary:l,rootBoundary:h,padding:d,altBoundary:c}),E=we(t.placement),A=Si(t.placement),L=!A,y=ln(E),S=pf(y),R=t.modifiersData.popperOffsets,D=t.rects.reference,M=t.rects.popper,C=typeof g=="function"?g(Object.assign({},t.rects,{placement:t.placement})):g,I=typeof C=="number"?{mainAxis:C,altAxis:C}:Object.assign({mainAxis:0,altAxis:0},C),G=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,F={x:0,y:0};if(R){if(n){var V,q=y==="y"?zt:Xt,w=y==="y"?ae:oe,P=y==="y"?"height":"width",H=R[y],b=H+v[q],T=H-v[w],k=f?-M[P]/2:0,N=A===Ti?D[P]:M[P],U=A===Ti?-M[P]:-D[P],K=t.elements.arrow,W=f&&K?on(K):{width:0,height:0},X=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:Yo(),lt=X[q],rt=X[w],at=hs(0,D[P],W[P]),Rt=L?D[P]/2-k-at-lt-I.mainAxis:N-at-lt-I.mainAxis,nt=L?-D[P]/2+k+at+rt+I.mainAxis:U+at+rt+I.mainAxis,it=t.elements.arrow&&ls(t.elements.arrow),vt=it?y==="y"?it.clientTop||0:it.clientLeft||0:0,dt=(V=G==null?void 0:G[y])!=null?V:0,Ct=H+Rt-dt-vt,et=H+nt-dt,ut=hs(f?Ys(b,Ct):b,H,f?ri(T,et):T);R[y]=ut,F[y]=ut-H}if(o){var bt,pt=y==="x"?zt:Xt,Tt=y==="x"?ae:oe,_t=R[S],Ot=S==="y"?"height":"width",ft=_t+v[pt],Yt=_t-v[Tt],ve=[zt,Xt].indexOf(E)!==-1,De=(bt=G==null?void 0:G[S])!=null?bt:0,Ht=ve?ft:_t-D[Ot]-M[Ot]-De+I.altAxis,ne=ve?_t+D[Ot]+M[Ot]-De-I.altAxis:Yt,Mi=f&&ve?Nu(Ht,_t,ne):hs(f?Ht:ft,_t,f?ne:Yt);R[S]=Mi,F[S]=Mi-_t}t.modifiersData[i]=F}}const mf={name:"preventOverflow",enabled:!0,phase:"main",fn:gf,requiresIfExists:["offset"]};function vf(r){return{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}}function yf(r){return r===ie(r)||!le(r)?hn(r):vf(r)}function Ef(r){var t=r.getBoundingClientRect(),e=Ai(t.width)/r.offsetWidth||1,i=Ai(t.height)/r.offsetHeight||1;return e!==1||i!==1}function bf(r,t,e){e===void 0&&(e=!1);var i=le(t),s=le(t)&&Ef(t),n=Ge(t),a=wi(r,s,e),o={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(i||!i&&!e)&&((Ae(t)!=="body"||dn(n))&&(o=yf(t)),le(t)?(l=wi(t,!0),l.x+=t.clientLeft,l.y+=t.clientTop):n&&(l.x=cn(n))),{x:a.left+o.scrollLeft-l.x,y:a.top+o.scrollTop-l.y,width:a.width,height:a.height}}function Tf(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 Af(r){var t=Tf(r);return Pu.reduce(function(e,i){return e.concat(t.filter(function(s){return s.phase===i}))},[])}function wf(r){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(r())})})),t}}function Sf(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 sl={placement:"bottom",modifiers:[],strategy:"absolute"};function rl(){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 Lf(r){r===void 0&&(r={});var t=r,e=t.defaultModifiers,i=e===void 0?[]:e,s=t.defaultOptions,n=s===void 0?sl:s;return function(o,l,h){h===void 0&&(h=n);var c={placement:"bottom",orderedModifiers:[],options:Object.assign({},sl,n),modifiersData:{},elements:{reference:o,popper:l},attributes:{},styles:{}},d=[],u=!1,f={state:c,setOptions:function(E){var A=typeof E=="function"?E(c.options):E;g(),c.options=Object.assign({},n,c.options,A),c.scrollParents={reference:si(o)?cs(o):o.contextElement?cs(o.contextElement):[],popper:cs(l)};var L=Af(Sf([].concat(i,c.options.modifiers)));return c.orderedModifiers=L.filter(function(y){return y.enabled}),p(),f.update()},forceUpdate:function(){if(!u){var E=c.elements,A=E.reference,L=E.popper;if(rl(A,L)){c.rects={reference:bf(A,ls(L),c.options.strategy==="fixed"),popper:on(L)},c.reset=!1,c.placement=c.options.placement,c.orderedModifiers.forEach(function(I){return c.modifiersData[I.name]=Object.assign({},I.data)});for(var y=0;y<c.orderedModifiers.length;y++){if(c.reset===!0){c.reset=!1,y=-1;continue}var S=c.orderedModifiers[y],R=S.fn,D=S.options,M=D===void 0?{}:D,C=S.name;typeof R=="function"&&(c=R({state:c,options:M,name:C,instance:f})||c)}}}},update:wf(function(){return new Promise(function(v){f.forceUpdate(),v(c)})}),destroy:function(){g(),u=!0}};if(!rl(o,l))return f;f.setOptions(h).then(function(v){!u&&h.onFirstUpdate&&h.onFirstUpdate(v)});function p(){c.orderedModifiers.forEach(function(v){var E=v.name,A=v.options,L=A===void 0?{}:A,y=v.effect;if(typeof y=="function"){var S=y({state:c,name:E,instance:f,options:L}),R=function(){};d.push(S||R)}})}function g(){d.forEach(function(v){return v()}),d=[]}return f}}var Rf=[qu,ff,Wu,Vo,df,af,mf,Gu,lf],_f=Lf({defaultModifiers:Rf}),kf="tippy-box",nl="tippy-content",If="tippy-backdrop",al="tippy-arrow",ol="tippy-svg-arrow",ni={passive:!0,capture:!0},ll=function(){return document.body};function fn(r,t,e){if(Array.isArray(r)){var i=r[t];return i??(Array.isArray(e)?e[t]:e)}return r}function pn(r,t){var e={}.toString.call(r);return e.indexOf("[object")===0&&e.indexOf(t+"]")>-1}function hl(r,t){return typeof r=="function"?r.apply(void 0,t):r}function cl(r,t){if(t===0)return r;var e;return function(i){clearTimeout(e),e=setTimeout(function(){r(i)},t)}}function Df(r){return r.split(/\s+/).filter(Boolean)}function Li(r){return[].concat(r)}function dl(r,t){r.indexOf(t)===-1&&r.push(t)}function Cf(r){return r.filter(function(t,e){return r.indexOf(t)===e})}function xf(r){return r.split("-")[0]}function Qs(r){return[].slice.call(r)}function ul(r){return Object.keys(r).reduce(function(t,e){return r[e]!==void 0&&(t[e]=r[e]),t},{})}function us(){return document.createElement("div")}function Zs(r){return["Element","Fragment"].some(function(t){return pn(r,t)})}function Pf(r){return pn(r,"NodeList")}function Of(r){return pn(r,"MouseEvent")}function $f(r){return!!(r&&r._tippy&&r._tippy.reference===r)}function Mf(r){return Zs(r)?[r]:Pf(r)?Qs(r):Array.isArray(r)?r:Qs(document.querySelectorAll(r))}function gn(r,t){r.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function fl(r,t){r.forEach(function(e){e&&e.setAttribute("data-state",t)})}function Ff(r){var t,e=Li(r),i=e[0];return i!=null&&(t=i.ownerDocument)!=null&&t.body?i.ownerDocument:document}function Nf(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=xf(a.placement),c=a.modifiersData.offset;if(!c)return!0;var d=h==="bottom"?c.top.y:0,u=h==="top"?c.bottom.y:0,f=h==="right"?c.left.x:0,p=h==="left"?c.right.x:0,g=n.top-i+d>l,v=i-n.bottom-u>l,E=n.left-e+f>l,A=e-n.right-p>l;return g||v||E||A})}function mn(r,t,e){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(s){r[i](s,e)})}function pl(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 Se={isTouch:!1},gl=0;function Uf(){Se.isTouch||(Se.isTouch=!0,window.performance&&document.addEventListener("mousemove",ml))}function ml(){var r=performance.now();r-gl<20&&(Se.isTouch=!1,document.removeEventListener("mousemove",ml)),gl=r}function Bf(){var r=document.activeElement;if($f(r)){var t=r._tippy;r.blur&&!t.state.isVisible&&r.blur()}}function Hf(){document.addEventListener("touchstart",Uf,ni),window.addEventListener("blur",Bf)}var Gf=typeof window<"u"&&typeof document<"u",Vf=Gf?!!window.msCrypto:!1,Kf={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},jf={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},fe=Object.assign({appendTo:ll,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},Kf,jf),Wf=Object.keys(fe),Yf=function(t){var e=Object.keys(t);e.forEach(function(i){fe[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=fe[n])!=null?o:a}return i},{});return Object.assign({},r,e)}function qf(r,t){var e=t?Object.keys(vl(Object.assign({},fe,{plugins:t}))):Wf,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 yl(r,t){var e=Object.assign({},t,{content:hl(t.content,[r])},t.ignoreAttributes?{}:qf(r,t.plugins));return e.aria=Object.assign({},fe.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 zf=function(){return"innerHTML"};function vn(r,t){r[zf()]=t}function El(r){var t=us();return r===!0?t.className=al:(t.className=ol,Zs(r)?t.appendChild(r):vn(t,r)),t}function bl(r,t){Zs(t.content)?(vn(r,""),r.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?vn(r,t.content):r.textContent=t.content)}function yn(r){var t=r.firstElementChild,e=Qs(t.children);return{box:t,content:e.find(function(i){return i.classList.contains(nl)}),arrow:e.find(function(i){return i.classList.contains(al)||i.classList.contains(ol)}),backdrop:e.find(function(i){return i.classList.contains(If)})}}function Tl(r){var t=us(),e=us();e.className=kf,e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var i=us();i.className=nl,i.setAttribute("data-state","hidden"),bl(i,r.props),t.appendChild(e),e.appendChild(i),s(r.props,r.props);function s(n,a){var o=yn(t),l=o.box,h=o.content,c=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)&&bl(h,r.props),a.arrow?c?n.arrow!==a.arrow&&(l.removeChild(c),l.appendChild(El(a.arrow))):l.appendChild(El(a.arrow)):c&&l.removeChild(c)}return{popper:t,onUpdate:s}}Tl.$$tippy=!0;var Xf=1,Js=[],En=[];function Qf(r,t){var e=yl(r,Object.assign({},fe,vl(ul(t)))),i,s,n,a=!1,o=!1,l=!1,h=!1,c,d,u,f=[],p=cl(Ct,e.interactiveDebounce),g,v=Xf++,E=null,A=Cf(e.plugins),L={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},y={id:v,reference:r,popper:us(),popperInstance:E,props:e,state:L,plugins:A,clearDelayTimeouts:Ht,setProps:ne,setContent:Mi,show:ee,hide:fi,hideWithInteractivity:Ss,enable:ve,disable:De,unmount:Ls,destroy:Ce};if(!e.render)return y;var S=e.render(y),R=S.popper,D=S.onUpdate;R.setAttribute("data-tippy-root",""),R.id="tippy-"+y.id,y.popper=R,r._tippy=y,R._tippy=y;var M=A.map(function(O){return O.fn(y)}),C=r.hasAttribute("aria-expanded");return it(),k(),H(),b("onCreate",[y]),e.showOnCreate&&ft(),R.addEventListener("mouseenter",function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()}),R.addEventListener("mouseleave",function(){y.props.interactive&&y.props.trigger.indexOf("mouseenter")>=0&&q().addEventListener("mousemove",p)}),y;function I(){var O=y.props.touch;return Array.isArray(O)?O:[O,0]}function G(){return I()[0]==="hold"}function F(){var O;return!!((O=y.props.render)!=null&&O.$$tippy)}function V(){return g||r}function q(){var O=V().parentNode;return O?Ff(O):document}function w(){return yn(R)}function P(O){return y.state.isMounted&&!y.state.isVisible||Se.isTouch||c&&c.type==="focus"?0:fn(y.props.delay,O?0:1,fe.delay)}function H(O){O===void 0&&(O=!1),R.style.pointerEvents=y.props.interactive&&!O?"":"none",R.style.zIndex=""+y.props.zIndex}function b(O,Y,tt){if(tt===void 0&&(tt=!0),M.forEach(function(ht){ht[O]&&ht[O].apply(ht,Y)}),tt){var gt;(gt=y.props)[O].apply(gt,Y)}}function T(){var O=y.props.aria;if(O.content){var Y="aria-"+O.content,tt=R.id,gt=Li(y.props.triggerTarget||r);gt.forEach(function(ht){var qt=ht.getAttribute(Y);if(y.state.isVisible)ht.setAttribute(Y,qt?qt+" "+tt:tt);else{var ue=qt&&qt.replace(tt,"").trim();ue?ht.setAttribute(Y,ue):ht.removeAttribute(Y)}})}}function k(){if(!(C||!y.props.aria.expanded)){var O=Li(y.props.triggerTarget||r);O.forEach(function(Y){y.props.interactive?Y.setAttribute("aria-expanded",y.state.isVisible&&Y===V()?"true":"false"):Y.removeAttribute("aria-expanded")})}}function N(){q().removeEventListener("mousemove",p),Js=Js.filter(function(O){return O!==p})}function U(O){if(!(Se.isTouch&&(l||O.type==="mousedown"))){var Y=O.composedPath&&O.composedPath()[0]||O.target;if(!(y.props.interactive&&pl(R,Y))){if(Li(y.props.triggerTarget||r).some(function(tt){return pl(tt,Y)})){if(Se.isTouch||y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else b("onClickOutside",[y,O]);y.props.hideOnClick===!0&&(y.clearDelayTimeouts(),y.hide(),o=!0,setTimeout(function(){o=!1}),y.state.isMounted||lt())}}}function K(){l=!0}function W(){l=!1}function X(){var O=q();O.addEventListener("mousedown",U,!0),O.addEventListener("touchend",U,ni),O.addEventListener("touchstart",W,ni),O.addEventListener("touchmove",K,ni)}function lt(){var O=q();O.removeEventListener("mousedown",U,!0),O.removeEventListener("touchend",U,ni),O.removeEventListener("touchstart",W,ni),O.removeEventListener("touchmove",K,ni)}function rt(O,Y){Rt(O,function(){!y.state.isVisible&&R.parentNode&&R.parentNode.contains(R)&&Y()})}function at(O,Y){Rt(O,Y)}function Rt(O,Y){var tt=w().box;function gt(ht){ht.target===tt&&(mn(tt,"remove",gt),Y())}if(O===0)return Y();mn(tt,"remove",d),mn(tt,"add",gt),d=gt}function nt(O,Y,tt){tt===void 0&&(tt=!1);var gt=Li(y.props.triggerTarget||r);gt.forEach(function(ht){ht.addEventListener(O,Y,tt),f.push({node:ht,eventType:O,handler:Y,options:tt})})}function it(){G()&&(nt("touchstart",dt,{passive:!0}),nt("touchend",et,{passive:!0})),Df(y.props.trigger).forEach(function(O){if(O!=="manual")switch(nt(O,dt),O){case"mouseenter":nt("mouseleave",et);break;case"focus":nt(Vf?"focusout":"blur",ut);break;case"focusin":nt("focusout",ut);break}})}function vt(){f.forEach(function(O){var Y=O.node,tt=O.eventType,gt=O.handler,ht=O.options;Y.removeEventListener(tt,gt,ht)}),f=[]}function dt(O){var Y,tt=!1;if(!(!y.state.isEnabled||bt(O)||o)){var gt=((Y=c)==null?void 0:Y.type)==="focus";c=O,g=O.currentTarget,k(),!y.state.isVisible&&Of(O)&&Js.forEach(function(ht){return ht(O)}),O.type==="click"&&(y.props.trigger.indexOf("mouseenter")<0||a)&&y.props.hideOnClick!==!1&&y.state.isVisible?tt=!0:ft(O),O.type==="click"&&(a=!tt),tt&&!gt&&Yt(O)}}function Ct(O){var Y=O.target,tt=V().contains(Y)||R.contains(Y);if(!(O.type==="mousemove"&&tt)){var gt=Ot().concat(R).map(function(ht){var qt,ue=ht._tippy,Fi=(qt=ue.popperInstance)==null?void 0:qt.state;return Fi?{popperRect:ht.getBoundingClientRect(),popperState:Fi,props:e}:null}).filter(Boolean);Nf(gt,O)&&(N(),Yt(O))}}function et(O){var Y=bt(O)||y.props.trigger.indexOf("click")>=0&&a;if(!Y){if(y.props.interactive){y.hideWithInteractivity(O);return}Yt(O)}}function ut(O){y.props.trigger.indexOf("focusin")<0&&O.target!==V()||y.props.interactive&&O.relatedTarget&&R.contains(O.relatedTarget)||Yt(O)}function bt(O){return Se.isTouch?G()!==O.type.indexOf("touch")>=0:!1}function pt(){Tt();var O=y.props,Y=O.popperOptions,tt=O.placement,gt=O.offset,ht=O.getReferenceClientRect,qt=O.moveTransition,ue=F()?yn(R).arrow:null,Fi=ht?{getBoundingClientRect:ht,contextElement:ht.contextElement||V()}:r,kc={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Lr){var Ni=Lr.state;if(F()){var Y0=w(),Ia=Y0.box;["placement","reference-hidden","escaped"].forEach(function(Rr){Rr==="placement"?Ia.setAttribute("data-placement",Ni.placement):Ni.attributes.popper["data-popper-"+Rr]?Ia.setAttribute("data-"+Rr,""):Ia.removeAttribute("data-"+Rr)}),Ni.attributes.popper={}}}},pi=[{name:"offset",options:{offset:gt}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!qt}},kc];F()&&ue&&pi.push({name:"arrow",options:{element:ue,padding:3}}),pi.push.apply(pi,(Y==null?void 0:Y.modifiers)||[]),y.popperInstance=_f(Fi,R,Object.assign({},Y,{placement:tt,onFirstUpdate:u,modifiers:pi}))}function Tt(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function _t(){var O=y.props.appendTo,Y,tt=V();y.props.interactive&&O===ll||O==="parent"?Y=tt.parentNode:Y=hl(O,[tt]),Y.contains(R)||Y.appendChild(R),y.state.isMounted=!0,pt()}function Ot(){return Qs(R.querySelectorAll("[data-tippy-root]"))}function ft(O){y.clearDelayTimeouts(),O&&b("onTrigger",[y,O]),X();var Y=P(!0),tt=I(),gt=tt[0],ht=tt[1];Se.isTouch&&gt==="hold"&&ht&&(Y=ht),Y?i=setTimeout(function(){y.show()},Y):y.show()}function Yt(O){if(y.clearDelayTimeouts(),b("onUntrigger",[y,O]),!y.state.isVisible){lt();return}if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(O.type)>=0&&a)){var Y=P(!1);Y?s=setTimeout(function(){y.state.isVisible&&y.hide()},Y):n=requestAnimationFrame(function(){y.hide()})}}function ve(){y.state.isEnabled=!0}function De(){y.hide(),y.state.isEnabled=!1}function Ht(){clearTimeout(i),clearTimeout(s),cancelAnimationFrame(n)}function ne(O){if(!y.state.isDestroyed){b("onBeforeUpdate",[y,O]),vt();var Y=y.props,tt=yl(r,Object.assign({},Y,ul(O),{ignoreAttributes:!0}));y.props=tt,it(),Y.interactiveDebounce!==tt.interactiveDebounce&&(N(),p=cl(Ct,tt.interactiveDebounce)),Y.triggerTarget&&!tt.triggerTarget?Li(Y.triggerTarget).forEach(function(gt){gt.removeAttribute("aria-expanded")}):tt.triggerTarget&&r.removeAttribute("aria-expanded"),k(),H(),D&&D(Y,tt),y.popperInstance&&(pt(),Ot().forEach(function(gt){requestAnimationFrame(gt._tippy.popperInstance.forceUpdate)})),b("onAfterUpdate",[y,O])}}function Mi(O){y.setProps({content:O})}function ee(){var O=y.state.isVisible,Y=y.state.isDestroyed,tt=!y.state.isEnabled,gt=Se.isTouch&&!y.props.touch,ht=fn(y.props.duration,0,fe.duration);if(!(O||Y||tt||gt)&&!V().hasAttribute("disabled")&&(b("onShow",[y],!1),y.props.onShow(y)!==!1)){if(y.state.isVisible=!0,F()&&(R.style.visibility="visible"),H(),X(),y.state.isMounted||(R.style.transition="none"),F()){var qt=w(),ue=qt.box,Fi=qt.content;gn([ue,Fi],0)}u=function(){var pi;if(!(!y.state.isVisible||h)){if(h=!0,R.offsetHeight,R.style.transition=y.props.moveTransition,F()&&y.props.animation){var ka=w(),Lr=ka.box,Ni=ka.content;gn([Lr,Ni],ht),fl([Lr,Ni],"visible")}T(),k(),dl(En,y),(pi=y.popperInstance)==null||pi.forceUpdate(),b("onMount",[y]),y.props.animation&&F()&&at(ht,function(){y.state.isShown=!0,b("onShown",[y])})}},_t()}}function fi(){var O=!y.state.isVisible,Y=y.state.isDestroyed,tt=!y.state.isEnabled,gt=fn(y.props.duration,1,fe.duration);if(!(O||Y||tt)&&(b("onHide",[y],!1),y.props.onHide(y)!==!1)){if(y.state.isVisible=!1,y.state.isShown=!1,h=!1,a=!1,F()&&(R.style.visibility="hidden"),N(),lt(),H(!0),F()){var ht=w(),qt=ht.box,ue=ht.content;y.props.animation&&(gn([qt,ue],gt),fl([qt,ue],"hidden"))}T(),k(),y.props.animation?F()&&rt(gt,y.unmount):y.unmount()}}function Ss(O){q().addEventListener("mousemove",p),dl(Js,p),p(O)}function Ls(){y.state.isVisible&&y.hide(),y.state.isMounted&&(Tt(),Ot().forEach(function(O){O._tippy.unmount()}),R.parentNode&&R.parentNode.removeChild(R),En=En.filter(function(O){return O!==y}),y.state.isMounted=!1,b("onHidden",[y]))}function Ce(){y.state.isDestroyed||(y.clearDelayTimeouts(),y.unmount(),vt(),delete r._tippy,y.state.isDestroyed=!0,b("onDestroy",[y]))}}function ai(r,t){t===void 0&&(t={});var e=fe.plugins.concat(t.plugins||[]);Hf();var i=Object.assign({},t,{plugins:e}),s=Mf(r),n=s.reduce(function(a,o){var l=o&&Qf(o,i);return l&&a.push(l),a},[]);return Zs(r)?n[0]:n}ai.defaultProps=fe,ai.setDefaultProps=Yf,ai.currentInput=Se,Object.assign({},Vo,{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)}}),ai.setDefaultProps({render:Tl});const Zf=5;class Jf{constructor(t){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._fakeBufferSegments=[],this._canvas=be(),this._controls=be(),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:c,duration:d})=>o>=c&&o<=c+d))??[],this._upcomingScenes=((i=this.host.scenes)==null?void 0:i.filter(({start:c})=>o>=c-Zf&&o<c))??[],this.loadScenes(),this.syncVideoState(),(s=this._controls.value)==null||s.setAttribute("currentTime",o.toString());const l=this.activeScenes[0],h=So((n=l==null?void 0:l.videoMeta)==null?void 0:n.captions);this.caption=((a=h.find(({start:c,end:d})=>{var u;const f=o-l.start+(((u=l.videoMeta)==null?void 0:u.start)??0);return c&&d&&f>=Us(c)&&f<=Us(d)}))==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 Te(this._canvas)}controls(){return Te(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,videoMeta:h}=i,c=this.activeScenes.includes(i),d=(this._upcomingScenes.includes(i)||c)&&(this.host.currentTime>0||this.host.preload==="auto"||!this.host.paused);if(l&&h){const{id:u,hls:f,node:p}=l,{start:g,duration:v}=h,E=this.host.videoState[u];p&&E&&(p.currentTime>=g+v||p.ended||d&&(f?(s=f.startLoadOnce)==null||s.call(f,p.currentTime):E.initialised||(n=p.startLoadOnce)==null||n.call(p)))}else if(d){const u={start:Math.max(0,a/this.host.duration*100),end:Math.min((a+o)/this.host.duration*100,100)};this.fakeBufferSegments.find(({start:f})=>f===u.start)||(e=[...e,u])}}),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 tp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Al={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,c){if(c=c||{},l=l.trim(),h=h.trim(),!h){if(!c.alwaysNormalize)return l;var d=o.parseURL(l);if(!d)throw new Error("Error trying to parse base URL.");return d.path=o.normalizePath(d.path),o.buildURLFromParts(d)}var u=o.parseURL(h);if(!u)throw new Error("Error trying to parse relative URL.");if(u.scheme)return c.alwaysNormalize?(u.path=o.normalizePath(u.path),o.buildURLFromParts(u)):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 v=f.path,E=v.substring(0,v.lastIndexOf("/")+1)+u.path;g.path=o.normalizePath(E)}return g.path===null&&(g.path=c.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})()})(Al);var bn=Al.exports;function wl(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 Qt(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?wl(Object(e),!0).forEach(function(i){ep(r,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):wl(Object(e)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i))})}return r}function ep(r,t,e){return t=sp(t),t in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function xt(){return xt=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},xt.apply(this,arguments)}function ip(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 sp(r){var t=ip(r,"string");return typeof t=="symbol"?t:String(t)}const z=Number.isFinite||function(r){return typeof r=="number"&&isFinite(r)};let m=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}({}),Q=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}({}),$=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 oi=function(){},Tn={trace:oi,debug:oi,log:oi,warn:oi,info:oi,error:oi};let fs=Tn;function rp(r){const t=self.console[r];return t?t.bind(self.console,`[${r}] >`):oi}function np(r,...t){t.forEach(function(e){fs[e]=r[e]?r[e].bind(r):rp(e)})}function ap(r,t){if(self.console&&r===!0||typeof r=="object"){np(r,"debug","log","info","warn","error");try{fs.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch{fs=Tn}}else fs=Tn}const _=fs,op=/^(\d+)x(\d+)$/,Sl=/(.+?)=(".*?"|.*?)(?:,|$)/g;class St{constructor(t){typeof t=="string"&&(t=St.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=op.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(Sl.lastIndex=0;(e=Sl.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 lp(r){return r!=="ID"&&r!=="CLASS"&&r!=="START-DATE"&&r!=="DURATION"&&r!=="END-DATE"&&r!=="END-ON-NEXT"}function hp(r){return r==="SCTE35-OUT"||r==="SCTE35-IN"}class Ll{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]){_.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=s;break}t=xt(new St({}),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"]);z(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(z(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&&z(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class tr{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 mt={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Rl{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[mt.AUDIO]:null,[mt.VIDEO]:null,[mt.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=bn.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class An extends Rl{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 tr,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||!z(this.programDateTime))return null;const t=z(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[mt.AUDIO]=null,t[mt.VIDEO]=null,t[mt.AUDIOVIDEO]=null}}class cp extends Rl{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 tr,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 dp=10;class up{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?z(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||dp}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 wn(r){return Uint8Array.from(atob(r),t=>t.charCodeAt(0))}function fp(r){const t=_l(r).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e}function pp(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 gp(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=wn(a)):e=fp(a)}}return e}function _l(r){return Uint8Array.from(unescape(encodeURIComponent(r)),t=>t.charCodeAt(0))}var Lt={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 kl(r){switch(r){case Zt.FAIRPLAY:return Lt.FAIRPLAY;case Zt.PLAYREADY:return Lt.PLAYREADY;case Zt.WIDEVINE:return Lt.WIDEVINE;case Zt.CLEARKEY:return Lt.CLEARKEY}}var Il={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function mp(r){if(r===Il.WIDEVINE)return Lt.WIDEVINE}function Dl(r){switch(r){case Lt.FAIRPLAY:return Zt.FAIRPLAY;case Lt.PLAYREADY:return Zt.PLAYREADY;case Lt.WIDEVINE:return Zt.WIDEVINE;case Lt.CLEARKEY:return Zt.CLEARKEY}}function Sn(r){const{drmSystems:t,widevineLicenseUrl:e}=r,i=t?[Lt.FAIRPLAY,Lt.WIDEVINE,Lt.PLAYREADY,Lt.CLEARKEY].filter(s=>!!t[s]):[];return!i[Lt.WIDEVINE]&&e&&i.push(Lt.WIDEVINE),i}const Cl=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function vp(r,t,e,i){let s;switch(r){case Lt.FAIRPLAY:s=["cenc","sinf"];break;case Lt.WIDEVINE:case Lt.PLAYREADY:s=["cenc"];break;case Lt.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${r}`)}return yp(s,t,e,i)}function yp(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 li(r,t,e){return Uint8Array.prototype.slice?r.slice(t,e):new Uint8Array(Array.prototype.slice.call(r,t,e))}const Ln=(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,xl=(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,er=(r,t)=>{const e=t;let i=0;for(;Ln(r,t);){i+=10;const s=ir(r,t+6);i+=s,xl(r,t+10)&&(i+=10),t+=i}if(i>0)return r.subarray(e,e+i)},ir=(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},Ep=(r,t)=>Ln(r,t)&&ir(r,t+6)+10<=r.length-t,bp=r=>{const t=Ol(r);for(let e=0;e<t.length;e++){const i=t[e];if(Pl(i))return Rp(i)}},Pl=r=>r&&r.key==="PRIV"&&r.info==="com.apple.streaming.transportStreamTimestamp",Tp=r=>{const t=String.fromCharCode(r[0],r[1],r[2],r[3]),e=ir(r,4),i=10;return{type:t,size:e,data:r.subarray(i,i+e)}},Ol=r=>{let t=0;const e=[];for(;Ln(r,t);){const i=ir(r,t+6);t+=10;const s=t+i;for(;t+8<s;){const n=Tp(r.subarray(t)),a=Ap(n);a&&e.push(a),t+=n.size+10}xl(r,t)&&(t+=10)}return e},Ap=r=>r.type==="PRIV"?wp(r):r.type[0]==="W"?Lp(r):Sp(r),wp=r=>{if(r.size<2)return;const t=Le(r.data,!0),e=new Uint8Array(r.data.subarray(t.length+1));return{key:r.type,info:t,data:e.buffer}},Sp=r=>{if(r.size<2)return;if(r.type==="TXXX"){let e=1;const i=Le(r.data.subarray(e),!0);e+=i.length+1;const s=Le(r.data.subarray(e));return{key:r.type,info:i,data:s}}const t=Le(r.data.subarray(1));return{key:r.type,data:t}},Lp=r=>{if(r.type==="WXXX"){if(r.size<2)return;let e=1;const i=Le(r.data.subarray(e),!0);e+=i.length+1;const s=Le(r.data.subarray(e));return{key:r.type,info:i,data:s}}const t=Le(r.data);return{key:r.type,data:t}},Rp=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)}},Le=(r,t=!1)=>{const e=_p();if(e){const h=e.decode(r);if(t){const c=h.indexOf("\0");return c!==-1?h.substring(0,c):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 Rn;function _p(){return!Rn&&typeof self.TextDecoder<"u"&&(Rn=new self.TextDecoder("utf-8")),Rn}const Re={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}},sr=Math.pow(2,32)-1,kp=[].push,$l={video:1,audio:2,id3:3,text:4};function Ut(r){return String.fromCharCode.apply(null,r)}function Ml(r,t){const e=r[t]<<8|r[t+1];return e<0?65536+e:e}function J(r,t){const e=Fl(r,t);return e<0?4294967296+e:e}function Fl(r,t){return r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3]}function _n(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 ot(r,t){const e=[];if(!t.length)return e;const i=r.byteLength;for(let s=0;s<i;){const n=J(r,s),a=Ut(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=ot(r.subarray(s+8,o),t.slice(1));l.length&&kp.apply(e,l)}s=o}return e}function Ip(r){const t=[],e=r[0];let i=8;const s=J(r,i);i+=4;const n=0,a=0;e===0?i+=8:i+=16,i+=2;let o=r.length+a;const l=Ml(r,i);i+=2;for(let h=0;h<l;h++){let c=i;const d=J(r,c);c+=4;const u=d&2147483647;if((d&2147483648)>>>31===1)return _.warn("SIDX has hierarchical references (not supported)"),null;const f=J(r,c);c+=4,t.push({referenceSize:u,subsegmentDuration:f,info:{duration:f/s,start:o,end:o+u-1}}),o+=u,c+=4,i=c}return{earliestPresentationTime:n,timescale:s,version:e,referencesCount:l,references:t}}function Nl(r){const t=[],e=ot(r,["moov","trak"]);for(let i=0;i<e.length;i++){const s=e[i],n=ot(s,["tkhd"])[0];if(n){let a=n[0],o=a===0?12:20;const l=J(n,o),h=ot(s,["mdia","mdhd"])[0];if(h){a=h[0],o=a===0?12:20;const c=J(h,o),d=ot(s,["mdia","hdlr"])[0];if(d){const u=Ut(d.subarray(8,12)),f={soun:mt.AUDIO,vide:mt.VIDEO}[u];if(f){const p=ot(s,["mdia","minf","stbl","stsd"])[0];let g;p&&(g=Ut(p.subarray(12,16))),t[l]={timescale:c,type:f},t[f]={timescale:c,id:l,codec:g}}}}}}return ot(r,["moov","mvex","trex"]).forEach(i=>{const s=J(i,4),n=t[s];n&&(n.default={duration:J(i,12),flags:J(i,20)})}),t}function Dp(r,t){if(!r||!t)return r;const e=t.keyId;return e&&t.isCommonEncryption&&ot(r,["moov","trak"]).forEach(i=>{const s=ot(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let n=ot(s,["enca"]);const a=n.length>0;a||(n=ot(s,["encv"])),n.forEach(o=>{const l=a?o.subarray(28):o.subarray(78);ot(l,["sinf"]).forEach(h=>{const c=Ul(h);if(c){const d=c.subarray(8,24);d.some(u=>u!==0)||(_.log(`[eme] Patching keyId in 'enc${a?"a":"v"}>sinf>>tenc' box: ${Re.hexDump(d)} -> ${Re.hexDump(e)}`),c.set(e,8))}})})}),r}function Ul(r){const t=ot(r,["schm"])[0];if(t){const e=Ut(t.subarray(4,8));if(e==="cbcs"||e==="cenc")return ot(r,["schi","tenc"])[0]}return _.error("[eme] missing 'schm' box"),null}function Cp(r,t){return ot(t,["moof","traf"]).reduce((e,i)=>{const s=ot(i,["tfdt"])[0],n=s[0],a=ot(i,["tfhd"]).reduce((o,l)=>{const h=J(l,4),c=r[h];if(c){let d=J(s,4);if(n===1){if(d===sr)return _.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;d*=sr+1,d+=J(s,8)}const u=c.timescale||9e4,f=d/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 xp(r,t){let e=0,i=0,s=0;const n=ot(r,["moof","traf"]);for(let a=0;a<n.length;a++){const o=n[a],l=ot(o,["tfhd"])[0],h=J(l,4),c=t[h];if(!c)continue;const d=c.default,u=J(l,0)|(d==null?void 0:d.flags);let f=d==null?void 0:d.duration;u&8&&(u&2?f=J(l,12):f=J(l,8));const p=c.timescale||9e4,g=ot(o,["trun"]);for(let v=0;v<g.length;v++){if(e=Pp(g[v]),!e&&f){const E=J(g[v],4);e=f*E}c.type===mt.VIDEO?i+=e/p:c.type===mt.AUDIO&&(s+=e/p)}}if(i===0&&s===0){let a=0;const o=ot(r,["sidx"]);for(let l=0;l<o.length;l++){const h=Ip(o[l]);h!=null&&h.references&&(a+=h.references.reduce((c,d)=>c+d.info.duration||0,0))}return a}return i||s}function Pp(r){const t=J(r,0);let e=8;t&1&&(e+=4),t&4&&(e+=4);let i=0;const s=J(r,4);for(let n=0;n<s;n++){if(t&256){const a=J(r,e);i+=a,e+=4}t&512&&(e+=4),t&1024&&(e+=4),t&2048&&(e+=4)}return i}function Op(r,t,e){ot(t,["moof","traf"]).forEach(i=>{ot(i,["tfhd"]).forEach(s=>{const n=J(s,4),a=r[n];if(!a)return;const o=a.timescale||9e4;ot(i,["tfdt"]).forEach(l=>{const h=l[0];let c=J(l,4);if(h===0)c-=e*o,c=Math.max(c,0),_n(l,4,c);else{c*=Math.pow(2,32),c+=J(l,8),c-=e*o,c=Math.max(c,0);const d=Math.floor(c/(sr+1)),u=Math.floor(c%(sr+1));_n(l,4,d),_n(l,8,u)}})})})}function $p(r){const t={valid:null,remainder:null},e=ot(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=li(r,0,i.byteOffset-8),t.remainder=li(r,i.byteOffset-8),t}function hi(r,t){const e=new Uint8Array(r.length+t.length);return e.set(r),e.set(t,r.length),e}function Bl(r,t){const e=[],i=t.samples,s=t.timescale,n=t.id;let a=!1;return ot(i,["moof"]).map(o=>{const l=o.byteOffset-8;ot(o,["traf"]).map(h=>{const c=ot(h,["tfdt"]).map(d=>{const u=d[0];let f=J(d,4);return u===1&&(f*=Math.pow(2,32),f+=J(d,8)),f/s})[0];return c!==void 0&&(r=c),ot(h,["tfhd"]).map(d=>{const u=J(d,4),f=J(d,0)&16777215,p=(f&1)!==0,g=(f&2)!==0,v=(f&8)!==0;let E=0;const A=(f&16)!==0;let L=0;const y=(f&32)!==0;let S=8;u===n&&(p&&(S+=8),g&&(S+=4),v&&(E=J(d,S),S+=4),A&&(L=J(d,S),S+=4),y&&(S+=4),t.type==="video"&&(a=Mp(t.codec)),ot(h,["trun"]).map(R=>{const D=R[0],M=J(R,0)&16777215,C=(M&1)!==0;let I=0;const G=(M&4)!==0,F=(M&256)!==0;let V=0;const q=(M&512)!==0;let w=0;const P=(M&1024)!==0,H=(M&2048)!==0;let b=0;const T=J(R,4);let k=8;C&&(I=J(R,k),k+=4),G&&(k+=4);let N=I+l;for(let U=0;U<T;U++){if(F?(V=J(R,k),k+=4):V=E,q?(w=J(R,k),k+=4):w=L,P&&(k+=4),H&&(D===0?b=J(R,k):b=Fl(R,k),k+=4),t.type===mt.VIDEO){let K=0;for(;K<w;){const W=J(i,N);if(N+=4,Fp(a,i[N])){const X=i.subarray(N,N+W);Hl(X,a?2:1,r+b/s,e)}N+=W,K+=W+4}}r+=V/s}}))})})}),e}function Mp(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 Fp(r,t){if(r){const e=t>>1&63;return e===39||e===40}else return(t&31)===6}function Hl(r,t,e,i){const s=Gl(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 c=s.length-n;if(!l&&a===4&&n<s.length){if(l=!0,s[n++]===181){const d=Ml(s,n);if(n+=2,d===49){const u=J(s,n);if(n+=4,u===1195456820){const f=s[n++];if(f===3){const p=s[n++],g=31&p,v=64&p,E=v?2+g*3:0,A=new Uint8Array(E);if(v){A[0]=p;for(let L=1;L<E;L++)A[L]=s[n++]}i.push({type:f,payloadType:a,pts:e,bytes:A})}}}}}else if(a===5&&o<c){if(l=!0,o>16){const d=[];for(let p=0;p<16;p++){const g=s[n++].toString(16);d.push(g.length==1?"0"+g:g),(p===3||p===5||p===7||p===9)&&d.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:d.join(""),userData:Le(f),userDataBytes:f})}}else if(o<c)n+=o;else if(o>c)break}}function Gl(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 Np(r){const t=r[0];let e="",i="",s=0,n=0,a=0,o=0,l=0,h=0;if(t===0){for(;Ut(r.subarray(h,h+1))!=="\0";)e+=Ut(r.subarray(h,h+1)),h+=1;for(e+=Ut(r.subarray(h,h+1)),h+=1;Ut(r.subarray(h,h+1))!=="\0";)i+=Ut(r.subarray(h,h+1)),h+=1;i+=Ut(r.subarray(h,h+1)),h+=1,s=J(r,12),n=J(r,16),o=J(r,20),l=J(r,24),h=28}else if(t===1){h+=4,s=J(r,h),h+=4;const d=J(r,h);h+=4;const u=J(r,h);for(h+=4,a=4294967296*d+u,Number.isSafeInteger(a)||(a=Number.MAX_SAFE_INTEGER,_.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=J(r,h),h+=4,l=J(r,h),h+=4;Ut(r.subarray(h,h+1))!=="\0";)e+=Ut(r.subarray(h,h+1)),h+=1;for(e+=Ut(r.subarray(h,h+1)),h+=1;Ut(r.subarray(h,h+1))!=="\0";)i+=Ut(r.subarray(h,h+1)),h+=1;i+=Ut(r.subarray(h,h+1)),h+=1}const c=r.subarray(h,r.byteLength);return{schemeIdUri:e,value:i,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:c}}function Up(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 Bp(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),Up([112,115,115,104],new Uint8Array([i,0,0,0]),r,n,s,a,e||new Uint8Array)}function Hp(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=Re.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 rr={};class ps{static clearKeyUriToKeyIdMap(){rr={}}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&&_.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const i=Gp(t);return new ps(this.method,this.uri,"identity",this.keyFormatVersions,i)}const e=gp(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=Bp(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=wn(l).subarray(0,16);pp(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=rr[this.uri];if(!i){const s=Object.keys(rr).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,s),rr[this.uri]=i}this.keyId=i}return this}}function Gp(r){const t=new Uint8Array(16);for(let e=12;e<16;e++)t[e]=r>>8*(15-e)&255;return t}const Vl=/\{\$([a-zA-Z0-9-_]+)\}/g;function Kl(r){return Vl.test(r)}function Jt(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]=kn(r,n))}}function kn(r,t){if(r.variableList!==null||r.hasVariableRefs){const e=r.variableList;return t.replace(Vl,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 jl(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 Vp(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 nr(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const Kp={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}},Wl=nr();function jp(r,t){const e=Kp[t];return!!e&&e[r.slice(0,4)]===!0}function In(r,t){var e;return(e=Wl==null?void 0:Wl.isTypeSupported(`${t||"video"}/mp4;codecs="${r}"`))!=null?e:!1}const Yl=/#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,ql=/#EXT-X-MEDIA:(.*)/g,Wp=/^#EXT(?:INF|-X-TARGETDURATION):/m,zl=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Yp=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 pe{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 bn.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return Wp.test(t)}static parseMasterPlaylist(t,e){const i=Kl(t),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];Yl.lastIndex=0;let a;for(;(a=Yl.exec(t))!=null;)if(a[1]){var o;const h=new St(a[1]);Jt(s,h,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const c=kn(s,a[2]),d={attrs:h,bitrate:h.decimalInteger("AVERAGE-BANDWIDTH")||h.decimalInteger("BANDWIDTH"),name:h.NAME,url:pe.resolve(c,e)},u=h.decimalResolution("RESOLUTION");u&&(d.width=u.width,d.height=u.height),qp((h.CODECS||"").split(/[ ,]+/).filter(f=>f),d),d.videoCodec&&d.videoCodec.indexOf("avc1")!==-1&&(d.videoCodec=pe.convertAVC1ToAVCOTI(d.videoCodec)),(o=d.unknownCodecs)!=null&&o.length||n.push(d),s.levels.push(d)}else if(a[3]){const h=a[3],c=a[4];switch(h){case"SESSION-DATA":{const d=new St(c);Jt(s,d,["DATA-ID","LANGUAGE","VALUE","URI"]);const u=d["DATA-ID"];u&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[u]=d);break}case"SESSION-KEY":{const d=Xl(c,e,s);d.encrypted&&d.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(d)):_.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${c}"`);break}case"DEFINE":{{const d=new St(c);Jt(s,d,["NAME","VALUE","QUERYPARAM"]),jl(s,d,e)}break}case"CONTENT-STEERING":{const d=new St(c);Jt(s,d,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:pe.resolve(d["SERVER-URI"],e),pathwayId:d["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=Ql(c);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(ql.lastIndex=0;(s=ql.exec(t))!==null;){const h=new St(s[1]),c=h.TYPE;if(c){const d=o[c],u=n[c]||[];n[c]=u,Jt(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:c,default:h.bool("DEFAULT"),autoselect:h.bool("AUTOSELECT"),forced:h.bool("FORCED"),lang:h.LANGUAGE,url:h.URI?pe.resolve(h.URI,e):""};if(d!=null&&d.length){const p=pe.findGroup(d,f.groupId)||d[0];Zl(f,p,"audioCodec"),Zl(f,p,"textCodec")}u.push(f)}}return n}static parseLevelPlaylist(t,e,i,s,n,a){const o=new up(e),l=o.fragments;let h=null,c=0,d=0,u=0,f=0,p=null,g=new An(s,e),v,E,A,L=-1,y=!1;for(zl.lastIndex=0,o.m3u8=t,o.hasVariableRefs=Kl(t);(v=zl.exec(t))!==null;){y&&(y=!1,g=new An(s,e),g.start=u,g.sn=c,g.cc=f,g.level=i,h&&(g.initSegment=h,g.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null));const M=v[1];if(M){g.duration=parseFloat(M);const C=(" "+v[2]).slice(1);g.title=C||null,g.tagList.push(C?["INF",M,C]:["INF",M])}else if(v[3]){if(z(g.duration)){g.start=u,A&&eh(g,A,o),g.sn=c,g.level=i,g.cc=f,g.urlId=n,l.push(g);const C=(" "+v[3]).slice(1);g.relurl=kn(o,C),Jl(g,p),p=g,u+=g.duration,c++,d=0,y=!0}}else if(v[4]){const C=(" "+v[4]).slice(1);p?g.setByteRange(C,p):g.setByteRange(C)}else if(v[5])g.rawProgramDateTime=(" "+v[5]).slice(1),g.tagList.push(["PROGRAM-DATE-TIME",g.rawProgramDateTime]),L===-1&&(L=l.length);else{if(v=v[0].match(Yp),!v){_.warn("No matches on slow regex match for level playlist!");continue}for(E=1;E<v.length&&!(typeof v[E]<"u");E++);const C=(" "+v[E]).slice(1),I=(" "+v[E+1]).slice(1),G=v[E+2]?(" "+v[E+2]).slice(1):"";switch(C){case"PLAYLIST-TYPE":o.type=I.toUpperCase();break;case"MEDIA-SEQUENCE":c=o.startSN=parseInt(I);break;case"SKIP":{const F=new St(I);Jt(o,F,["RECENTLY-REMOVED-DATERANGES"]);const V=F.decimalInteger("SKIPPED-SEGMENTS");if(z(V)){o.skippedSegments=V;for(let w=V;w--;)l.unshift(null);c+=V}const q=F.enumeratedString("RECENTLY-REMOVED-DATERANGES");q&&(o.recentlyRemovedDateranges=q.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(I),1);break;case"VERSION":o.version=parseInt(I);break;case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(I||G)&&g.tagList.push(G?[I,G]:[I]);break;case"DISCONTINUITY":f++,g.tagList.push(["DIS"]);break;case"GAP":g.gap=!0,g.tagList.push([C]);break;case"BITRATE":g.tagList.push([C,I]);break;case"DATERANGE":{const F=new St(I);Jt(o,F,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Jt(o,F,F.clientAttrs);const V=new Ll(F,o.dateRanges[F.ID]);V.isValid||o.skippedSegments?o.dateRanges[V.id]=V:_.warn(`Ignoring invalid DATERANGE tag: "${I}"`),g.tagList.push(["EXT-X-DATERANGE",I]);break}case"DEFINE":{{const F=new St(I);Jt(o,F,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in F?Vp(o,F,a):jl(o,F,e)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(I);break;case"KEY":{const F=Xl(I,e,o);if(F.isSupported()){if(F.method==="NONE"){A=void 0;break}A||(A={}),A[F.keyFormat]&&(A=xt({},A)),A[F.keyFormat]=F}else _.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${I}"`);break}case"START":o.startTimeOffset=Ql(I);break;case"MAP":{const F=new St(I);if(Jt(o,F,["BYTERANGE","URI"]),g.duration){const V=new An(s,e);th(V,F,i,A),h=V,g.initSegment=h,h.rawProgramDateTime&&!g.rawProgramDateTime&&(g.rawProgramDateTime=h.rawProgramDateTime)}else th(g,F,i,A),h=g,y=!0;break}case"SERVER-CONTROL":{const F=new St(I);o.canBlockReload=F.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=F.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&F.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=F.optionalFloat("PART-HOLD-BACK",0),o.holdBack=F.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const F=new St(I);o.partTarget=F.decimalFloatingPoint("PART-TARGET");break}case"PART":{let F=o.partList;F||(F=o.partList=[]);const V=d>0?F[F.length-1]:void 0,q=d++,w=new St(I);Jt(o,w,["BYTERANGE","URI"]);const P=new cp(w,g,e,q,V);F.push(P),g.duration+=P.duration;break}case"PRELOAD-HINT":{const F=new St(I);Jt(o,F,["URI"]),o.preloadHint=F;break}case"RENDITION-REPORT":{const F=new St(I);Jt(o,F,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(F);break}default:_.warn(`line parsed but not handled: ${v}`);break}}}p&&!p.relurl?(l.pop(),u-=p.duration,o.partList&&(o.fragmentHint=p)):o.partList&&(Jl(g,p),g.cc=f,o.fragmentHint=g,A&&eh(g,A,o));const S=l.length,R=l[0],D=l[S-1];if(u+=o.skippedSegments*o.targetduration,u>0&&S&&D){o.averagetargetduration=u/S;const M=D.sn;o.endSN=M!=="initSegment"?M:0,o.live||(D.endList=!0),R&&(o.startCC=R.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(u+=o.fragmentHint.duration),o.totalduration=u,o.endCC=f,L>0&&zp(l,L),o}}function Xl(r,t,e){var i,s;const n=new St(r);Jt(e,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const a=(i=n.METHOD)!=null?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),h=n.KEYFORMATVERSIONS,c=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&_.error(`Invalid IV: ${n.IV}`);const d=o?pe.resolve(o,t):"",u=(h||"1").split("/").map(Number).filter(Number.isFinite);return new ps(a,d,c,u,l)}function Ql(r){const t=new St(r).decimalFloatingPoint("TIME-OFFSET");return z(t)?t:null}function qp(r,t){["video","audio","text"].forEach(e=>{const i=r.filter(s=>jp(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 Zl(r,t,e){const i=t[e];i&&(r[e]=i)}function zp(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 Jl(r,t){r.rawProgramDateTime?r.programDateTime=Date.parse(r.rawProgramDateTime):t!=null&&t.programDateTime&&(r.programDateTime=t.endProgramDateTime),z(r.programDateTime)||(r.programDateTime=null,r.rawProgramDateTime=null)}function th(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 eh(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 ct={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Z={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function ih(r){const{type:t}=r;switch(t){case ct.AUDIO_TRACK:return Z.AUDIO;case ct.SUBTITLE_TRACK:return Z.SUBTITLE;default:return Z.MAIN}}function Dn(r,t){let e=r.url;return(e===void 0||e.indexOf("data:")===0)&&(e=t.url),e}class Xp{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(m.MANIFEST_LOADING,this.onManifestLoading,this),t.on(m.LEVEL_LOADING,this.onLevelLoading,this),t.on(m.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(m.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(m.MANIFEST_LOADING,this.onManifestLoading,this),t.off(m.LEVEL_LOADING,this.onLevelLoading,this),t.off(m.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(m.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:ct.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:ct.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:ct.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:ct.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){_.trace("[playlist-loader]: playlist request ongoing");return}_.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),s.abort()}let n;if(t.type===ct.MANIFEST?n=i.manifestLoadPolicy.default:n=xt({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(t),(e=t.deliveryDirectives)!=null&&e.part){let h;if(t.type===ct.LEVEL&&t.level!==null?h=this.hls.levels[t.level].details:t.type===ct.AUDIO_TRACK&&t.id!==null?h=this.hls.audioTracks[t.id].details:t.type===ct.SUBTITLE_TRACK&&t.id!==null&&(h=this.hls.subtitleTracks[t.id].details),h){const c=h.partTarget,d=h.targetduration;if(c&&d){const u=Math.max(c*3,d*.8)*1e3;n=xt({},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,c,d,u)=>{const f=this.getInternalLoader(d);this.resetInternalLoader(d.type);const p=h.data;if(p.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(h,d,new Error("no EXTM3U delimiter"),u||null,c);return}c.parsing.start=performance.now(),pe.isMediaPlaylist(p)?this.handleTrackOrLevelPlaylist(h,c,d,u||null,f):this.handleMasterPlaylist(h,c,d,u)},onError:(h,c,d,u)=>{this.handleNetworkError(c,d,!1,h,u)},onTimeout:(h,c,d)=>{this.handleNetworkError(c,d,!0,void 0,h)}};s.load(t,o,l)}handleMasterPlaylist(t,e,i,s){const n=this.hls,a=t.data,o=Dn(t,i),l=pe.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(t,i,l.playlistParsingError,s,e);return}const{contentSteering:h,levels:c,sessionData:d,sessionKeys:u,startTimeOffset:f,variableList:p}=l;this.variableList=p;const{AUDIO:g=[],SUBTITLES:v,"CLOSED-CAPTIONS":E}=pe.parseMasterPlaylistMedia(a,o,l);g.length&&!g.some(A=>!A.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(_.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 St({}),bitrate:0,url:""})),n.trigger(m.MANIFEST_LOADED,{levels:c,audioTracks:g,subtitles:v,captions:E,contentSteering:h,url:o,stats:e,networkDetails:s,sessionData:d,sessionKeys:u,startTimeOffset:f,variableList:p})}handleTrackOrLevelPlaylist(t,e,i,s,n){const a=this.hls,{id:o,level:l,type:h}=i,c=Dn(t,i),d=z(o)?o:0,u=z(l)?l:d,f=ih(i),p=pe.parseLevelPlaylist(t.data,c,u,f,d,this.variableList);if(h===ct.MANIFEST){const g={attrs:new St({}),bitrate:0,details:p,name:"",url:c};a.trigger(m.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:c,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(m.ERROR,{type:Q.NETWORK_ERROR,details:$.MANIFEST_PARSING_ERROR,fatal:e.type===ct.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===ct.LEVEL?a+=`: ${t.level} id: ${t.id}`:(t.type===ct.AUDIO_TRACK||t.type===ct.SUBTITLE_TRACK)&&(a+=` id: ${t.id} group-id: "${t.groupId}"`);const o=new Error(a);_.warn(`[playlist-loader]: ${a}`);let l=$.UNKNOWN,h=!1;const c=this.getInternalLoader(t);switch(t.type){case ct.MANIFEST:l=i?$.MANIFEST_LOAD_TIMEOUT:$.MANIFEST_LOAD_ERROR,h=!0;break;case ct.LEVEL:l=i?$.LEVEL_LOAD_TIMEOUT:$.LEVEL_LOAD_ERROR,h=!1;break;case ct.AUDIO_TRACK:l=i?$.AUDIO_TRACK_LOAD_TIMEOUT:$.AUDIO_TRACK_LOAD_ERROR,h=!1;break;case ct.SUBTITLE_TRACK:l=i?$.SUBTITLE_TRACK_LOAD_TIMEOUT:$.SUBTITLE_LOAD_ERROR,h=!1;break}c&&this.resetInternalLoader(t.type);const d={type:Q.NETWORK_ERROR,details:l,fatal:h,url:t.url,loader:c,context:t,error:o,networkDetails:e,stats:n};if(s){const u=(e==null?void 0:e.url)||t.url;d.response=Qt({url:u,data:void 0},s)}this.hls.trigger(m.ERROR,d)}handlePlaylistLoaded(t,e,i,s,n,a){const o=this.hls,{type:l,level:h,id:c,groupId:d,deliveryDirectives:u}=s,f=Dn(e,s),p=ih(s),g=typeof s.level=="number"&&p===Z.MAIN?h:void 0;if(!t.fragments.length){const E=new Error("No Segments found in Playlist");o.trigger(m.ERROR,{type:Q.NETWORK_ERROR,details:$.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:E,reason:E.message,response:e,context:s,level:g,parent:p,networkDetails:n,stats:i});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const v=t.playlistParsingError;if(v){o.trigger(m.ERROR,{type:Q.NETWORK_ERROR,details:$.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:v,reason:v.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 ct.MANIFEST:case ct.LEVEL:o.trigger(m.LEVEL_LOADED,{details:t,level:g||0,id:c||0,stats:i,networkDetails:n,deliveryDirectives:u});break;case ct.AUDIO_TRACK:o.trigger(m.AUDIO_TRACK_LOADED,{details:t,id:c||0,groupId:d||"",stats:i,networkDetails:n,deliveryDirectives:u});break;case ct.SUBTITLE_TRACK:o.trigger(m.SUBTITLE_TRACK_LOADED,{details:t,id:c||0,groupId:d||"",stats:i,networkDetails:n,deliveryDirectives:u});break}}}function sh(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 rh(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){_.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){_.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}e==="disabled"&&(r.mode=e)}function Ri(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 Cn(r,t,e,i){const s=r.mode;if(s==="disabled"&&(r.mode="hidden"),r.cues&&r.cues.length>0){const n=Zp(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 Qp(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 Zp(r,t,e){const i=[],s=Qp(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 ge={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const Jp=.25;function xn(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const ar=(()=>{const r=xn();try{new r(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Pn(r,t){return r.getTime()/1e3-t}function tg(r){return Uint8Array.from(r.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class eg{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(m.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(m.MANIFEST_LOADING,this.onManifestLoading,this),t.on(m.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(m.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(m.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(m.MANIFEST_LOADING,this.onManifestLoading,this),t.off(m.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(m.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(m.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(Ri(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 sh(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=xn();for(let o=0;o<n.length;o++){const l=n[o].type;if(l===ge.emsg&&!i||!s)continue;const h=Ol(n[o].data);if(h){const c=n[o].pts;let d=c+n[o].duration;d>ar&&(d=ar),d-c<=0&&(d=c+Jp);for(let u=0;u<h.length;u++){const f=h[u];if(!Pl(f)){this.updateId3CueEnds(c,l);const p=new a(c,d,"");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===ar&&(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=c=>c.type===ge.audioId3&&l:s==="video"?h=c=>c.type===ge.emsg&&o:h=c=>c.type===ge.audioId3&&l||c.type===ge.emsg&&o,Cn(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 c=Object.keys(i).filter(d=>!a.includes(d));for(let d=c.length;d--;){const u=c[d];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||!z(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=o.programDateTime/1e3-o.start,h=xn();for(let c=0;c<a.length;c++){const d=a[c],u=n[d],f=i[d],p=(f==null?void 0:f.cues)||{};let g=(f==null?void 0:f.durationKnown)||!1;const v=Pn(u.startDate,l);let E=ar;const A=u.endDate;if(A)E=Pn(A,l),g=!0;else if(u.endOnNext&&!g){const y=a.reduce((S,R)=>{const D=n[R];return D.class===u.class&&D.id!==R&&D.startDate>u.startDate&&S.push(D),S},[]).sort((S,R)=>S.startDate.getTime()-R.startDate.getTime())[0];y&&(E=Pn(y.startDate,l),g=!0)}const L=Object.keys(u.attr);for(let y=0;y<L.length;y++){const S=L[y];if(!lp(S))continue;let R=p[S];if(R)g&&!f.durationKnown&&(R.endTime=E);else{let D=u.attr[S];R=new h(v,E,""),hp(S)&&(D=tg(D)),R.value={key:S,data:D},R.type=ge.dateRange,R.id=d,this.id3Track.addCue(R),p[S]=R}}i[d]={cues:p,dateRange:u,durationKnown:g}}}}class ig{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 c=s,d=1;return h+Math.min(this.stallCount*d,c)}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(m.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(m.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(m.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(m.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(m.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(m.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(m.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===$.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&_.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 c=Math.min(2,Math.max(1,n)),d=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;t.playbackRate=Math.min(c,Math.max(1,d))}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 On=["NONE","TYPE-0","TYPE-1",null];var gs={No:"",Yes:"YES",v2:"v2"};function sg(r,t){const{canSkipUntil:e,canSkipDateRanges:i,endSN:s}=r,n=t!==void 0?t-s:0;return e&&n<e?i?gs.v2:gs.Yes:gs.No}class nh{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 ms{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(z(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 ah(r,t,e,i,s,n){i-e<=0&&(_.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(z(l)){const g=Math.abs(l-e);z(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 c=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 d=t.sn;if(!r||d<r.startSN||d>r.endSN)return 0;let u;const f=d-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,c}function rg(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(og(r,t,(l,h)=>{l.relurl&&(s=l.cc-h.cc),z(l.startPTS)&&z(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){_.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=ng(r.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const a=t.fragments;if(s){_.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),ag(r.partList,t.partList,(l,h)=>{h.elementaryStreams=l.elementaryStreams,h.stats=l.stats}),n?ah(t,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):oh(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 ng(r,t,e){const i=xt({},r);return e&&e.forEach(s=>{delete i[s]}),Object.keys(t).forEach(s=>{const n=new Ll(t[s].attr,i[s]);n.isValid?i[s]=n:_.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[s].attr)}"`)}),i}function ag(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 og(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 c=l[a+h];let d=o[h];i&&!d&&h<i&&(d=t.fragments[h]=c),c&&d&&e(c,d)}}function oh(r,t){const e=t.startSN+t.skippedSegments-r.startSN,i=r.fragments;e<0||e>=i.length||Mn(t,i[e].start)}function Mn(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 lg(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 hg(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 lh(r,t,e){var i;return r!=null&&r.details?hh((i=r.details)==null?void 0:i.partList,t,e):null}function hh(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 or(r){switch(r.details){case $.FRAG_LOAD_TIMEOUT:case $.KEY_LOAD_TIMEOUT:case $.LEVEL_LOAD_TIMEOUT:case $.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function ch(r,t){const e=or(t);return r.default[`${e?"timeout":"error"}Retry`]}function Fn(r,t){const e=r.backoff==="linear"?1:Math.pow(2,t);return Math.min(e*r.retryDelayMs,r.maxRetryDelayMs)}function dh(r){return Qt(Qt({},r),{errorRetry:null,timeoutRetry:null})}function lr(r,t,e,i){return!!r&&t<r.maxNumRetry&&(cg(i)||!!e)}function cg(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 dg(r,t,e){if(t===null||!Array.isArray(r)||!r.length||!z(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(ug(t,e,a))return a}return null}function vs(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&&Nn(e,i,s)===0)return s;const n=uh.search(t,Nn.bind(null,e,i));return n&&(n!==r||!s)?n:s}function Nn(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 ug(r,t,e){const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0))*1e3;return(e.endProgramDateTime||0)-i>r}function fg(r,t){return uh.search(r,e=>e.cc<t?1:e.cc>t?-1:0)}const pg=3e5;var Gt={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},he={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class gg{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=_.log.bind(_,"[info]:"),this.warn=_.warn.bind(_,"[warning]:"),this.error=_.error.bind(_,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(m.ERROR,this.onError,this),t.on(m.MANIFEST_LOADING,this.onManifestLoading,this),t.on(m.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(m.ERROR,this.onError,this),t.off(m.ERROR,this.onErrorOut,this),t.off(m.MANIFEST_LOADING,this.onManifestLoading,this),t.off(m.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)===Z.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 $.FRAG_LOAD_ERROR:case $.FRAG_LOAD_TIMEOUT:case $.KEY_LOAD_ERROR:case $.KEY_LOAD_TIMEOUT:e.errorAction=this.getFragRetryOrSwitchAction(e);return;case $.FRAG_PARSING_ERROR:if((i=e.frag)!=null&&i.gap){e.errorAction={action:Gt.DoNothing,flags:he.None};return}case $.FRAG_GAP:case $.FRAG_DECRYPT_ERROR:{e.errorAction=this.getFragRetryOrSwitchAction(e),e.errorAction.action=Gt.SendAlternateToPenaltyBox;return}case $.LEVEL_EMPTY_ERROR:case $.LEVEL_PARSING_ERROR:{var o,l;const h=e.parent===Z.MAIN?e.level:n.loadLevel;e.details===$.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 $.LEVEL_LOAD_ERROR:case $.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,a.level));return;case $.AUDIO_TRACK_LOAD_ERROR:case $.AUDIO_TRACK_LOAD_TIMEOUT:case $.SUBTITLE_LOAD_ERROR:case $.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){const h=n.levels[n.loadLevel];if(h&&(a.type===ct.AUDIO_TRACK&&a.groupId===h.audioGroupId||a.type===ct.SUBTITLE_TRACK&&a.groupId===h.textGroupId)){e.errorAction=this.getPlaylistRetryOrSwitchAction(e,n.loadLevel),e.errorAction.action=Gt.SendAlternateToPenaltyBox,e.errorAction.flags=he.MoveAllAlternatesMatchingHost;return}}return;case $.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const h=n.levels[n.loadLevel],c=h==null?void 0:h.attrs["HDCP-LEVEL"];c&&(e.errorAction={action:Gt.SendAlternateToPenaltyBox,flags:he.MoveAllAlternatesMatchingHDCP,hdcpLevel:c})}return;case $.BUFFER_ADD_CODEC_ERROR:case $.REMUX_ALLOC_ERROR:e.errorAction=this.getLevelSwitchAction(e,(s=e.level)!=null?s:n.loadLevel);return;case $.INTERNAL_EXCEPTION:case $.BUFFER_APPENDING_ERROR:case $.BUFFER_APPEND_ERROR:case $.BUFFER_FULL_ERROR:case $.LEVEL_SWITCH_ERROR:case $.BUFFER_STALLED_ERROR:case $.BUFFER_SEEK_OVER_HOLE:case $.BUFFER_NUDGE_ON_STALL:e.errorAction={action:Gt.DoNothing,flags:he.None};return}if(e.type===Q.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=ch(s.config.playlistLoadPolicy,t),a=this.playlistError++,o=(i=t.response)==null?void 0:i.code;if(lr(n,a,or(t),o))return{action:Gt.RetryRequest,flags:he.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=ch(t.details.startsWith("key")?a:n,t),l=e.levels.reduce((d,u)=>d+u.fragmentError,0);if(s){var h;t.details!==$.FRAG_GAP&&s.fragmentError++;const d=(h=t.response)==null?void 0:h.code;if(lr(o,l,or(t),d))return{action:Gt.RetryRequest,flags:he.None,retryConfig:o,retryCount:l}}const c=this.getLevelSwitchAction(t,i);return o&&(c.retryConfig=o,c.retryCount=l),c}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:c,maxAutoLevel:d}=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 v=(g+h)%l.length;if(v!==h&&v>=c&&v<=d&&l[v].loadError===0){const E=l[v];if(t.details===$.FRAG_GAP&&t.frag){const A=l[v].details;if(A){const L=vs(t.frag,A.fragments,t.frag.start);if(L!=null&&L.gap)continue}}else if(f===ct.AUDIO_TRACK&&p===E.audioGroupId||f===ct.SUBTITLE_TRACK&&p===E.textGroupId||u===Z.AUDIO&&s.audioGroupId===E.audioGroupId||u===Z.SUBTITLE&&s.textGroupId===E.textGroupId)continue;o=v;break}}if(o>-1&&i.loadLevel!==o)return t.levelRetry=!0,this.playlistError=0,{action:Gt.SendAlternateToPenaltyBox,flags:he.None,nextAutoLevel:o}}return{action:Gt.SendAlternateToPenaltyBox,flags:he.MoveAllAlternatesMatchingHost}}onErrorOut(t,e){var i;switch((i=e.errorAction)==null?void 0:i.action){case Gt.DoNothing:break;case Gt.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),!e.errorAction.resolved&&e.details!==$.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 he.None:this.switchLevel(t,a);break;case he.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(t));break;case he.MoveAllAlternatesMatchingHDCP:n&&(e.maxHdcpLevel=On[On.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===Z.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,c=i[h];if(!c||mg(c,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(d=>{d.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 mg(r,t,e){if(performance.now()-r.lastErrorPerfMs>pg)return!0;const i=r.details;if(t.details===$.FRAG_GAP&&i&&t.frag){const s=t.frag.start,n=vs(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 Un{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=_.log.bind(_,`${e}:`),this.warn=_.warn.bind(_,`${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){_.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 nh(a,o>=0?o:void 0,gs.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&&rg(i,s),!this.canLoad||!s.live)return;let l,h,c;if(s.canBlockReload&&s.endSN&&s.advanced){const v=this.hls.config.lowLatencyMode,E=s.lastPartSn,A=s.endSN,L=s.lastPartIndex,y=L!==-1,S=E===A,R=v?0:L;y?(h=S?A+1:E,c=S?R:L+1):h=A+1;const D=s.age,M=D+s.ageHeader;let C=Math.min(M-s.partTarget,s.targetduration*1.5);if(C>0){if(i&&C>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${C} with playlist age: ${s.age}`),C=0;else{const I=Math.floor(C/s.targetduration);if(h+=I,c!==void 0){const G=Math.round(C%s.targetduration/s.partTarget);c+=G}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${D.toFixed(2)}s goal: ${C} skip sn ${I} to part ${c}`)}s.tuneInGoal=C}if(l=this.getDeliveryDirectives(s,e.deliveryDirectives,h,c),v||!S){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,e.deliveryDirectives,h,c));const d=this.hls.mainForwardBufferInfo,u=d?d.end-d.len:0,f=(s.edge-u)*1e3,p=lg(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=sg(t,i);return e!=null&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,s=e.part,n=gs.No),new nh(i,s,n)}checkRetry(t){const e=t.details,i=or(t),s=t.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===Gt.RetryRequest||!s.resolved&&n===Gt.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 c=Fn(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${e}" in ${c}ms`)}t.levelRetry=!0,s.resolved=!0}return l}}let Bn;class vg extends Un{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(m.MANIFEST_LOADING,this.onManifestLoading,this),t.on(m.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(m.LEVEL_LOADED,this.onLevelLoaded,this),t.on(m.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(m.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(m.FRAG_LOADED,this.onFragLoaded,this),t.on(m.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(m.MANIFEST_LOADING,this.onManifestLoading,this),t.off(m.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(m.LEVEL_LOADED,this.onLevelLoaded,this),t.off(m.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(m.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(m.FRAG_LOADED,this.onFragLoaded,this),t.off(m.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&&(Bn||(Bn=/chrome|firefox/i.test(navigator.userAgent)),Bn&&(a.audioCodec=void 0));const{AUDIO:h,CODECS:c,"FRAME-RATE":d,"PATHWAY-ID":u,RESOLUTION:f,SUBTITLES:p}=l,g=`${`${u||"."}-`}${a.bitrate}-${f}-${d}-${c}`;n=s[g],n?n.addFallback(a):(n=new ms(a),s[g]=n,i.push(n)),hr(n,"audio",h),hr(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:v,unknownCodecs:E})=>(n||(n=!!(g&&v)),a||(a=!!p),o||(o=!!f),!(E!=null&&E.length)&&(!f||In(f,"audio"))&&(!p||In(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(m.ERROR,{type:Q.MEDIA_ERROR,details:$.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:f,reason:f.message})}});return}e.audioTracks&&(i=e.audioTracks.filter(f=>!f.audioCodec||In(f.audioCodec,"audio")),fh(i)),e.subtitles&&(s=e.subtitles,fh(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 c=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){c=h[f];break}}this._levels=l;for(let f=0;f<l.length;f++)if(l[f]===c){this._firstLevel=f,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${c.bitrate}`);break}const d=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:!d&&i.some(f=>!!f.url)};this.hls.trigger(m.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 c=new Error("invalid level idx"),d=t<0;if(this.hls.trigger(m.ERROR,{type:Q.OTHER_ERROR,details:$.LEVEL_SWITCH_ERROR,level:t,fatal:d,error:c,reason:c.message}),d)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=xt({},a,{level:t,maxBitrate:a.maxBitrate,attrs:a.attrs,uri:a.uri,urlId:a.urlId});delete l._attrs,delete l._urlId,this.hls.trigger(m.LEVEL_SWITCHING,l);const h=a.details;if(!h||h.live){const c=this.switchParams(a.uri,s==null?void 0:s.details);this.loadPlaylist(c)}}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===ct.LEVEL&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){if(e!==void 0&&e.type===Z.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(m.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(m.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 hr(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 fh(r){const t={};r.forEach(e=>{const i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}var $t={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class yg{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(m.BUFFER_APPENDED,this.onBufferAppended,this),t.on(m.FRAG_BUFFERED,this.onFragBuffered,this),t.on(m.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(m.BUFFER_APPENDED,this.onBufferAppended,this),t.off(m.FRAG_BUFFERED,this.onFragBuffered,this),t.off(m.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 c=!this.isTimeBuffered(h.startPTS,h.endPTS,e);return c&&this.removeFragment(o.body),c})})}detectPartialFragments(t){const e=this.timeRanges,{frag:i,part:s}=t;if(!e||i.sn==="initSegment")return;const n=_i(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 c=e[l],d=o||h.partial===!0;a.range[l]=this.getBufferedTimes(i,s,d,c)}),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),cr(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=_i(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 c=0;c<s.length;c++){const d=s.start(c)-this.bufferPadding,u=s.end(c)+this.bufferPadding;if(h>=d&&l<=u){n.time.push({startPTS:Math.max(a,s.start(c)),endPTS:Math.min(o,s.end(c))});break}else if(a<u&&o>d)n.partial=!0,n.time.push({startPTS:Math.max(a,s.start(c)),endPTS:Math.min(o,s.end(c))});else if(o<=d)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 c=l[h];c&&cr(c)&&(s=c.body.start-o,n=c.body.end+o,t>=s&&t<=n&&(i=Math.min(t-s,n-t),a<=i&&(e=c.body,a=i)))}),e}isEndListAppended(t){const e=this.endListFragments[t];return e!==void 0&&(e.buffered||cr(e))}getState(t){const e=_i(t),i=this.fragments[e];return i?i.buffered?cr(i)?$t.PARTIAL:$t.OK:$t.APPENDING:$t.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=_i(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=_i(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=_i(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 cr(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 _i(r){return`${r.type}_${r.level}_${r.urlId}_${r.sn}`}const ph=Math.pow(2,17);class Eg{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 Me({type:Q.NETWORK_ERROR,details:$.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(mh(t));return}else t.gap=!1;const h=this.loader=t.loader=n?new n(s):new a(s),c=gh(t),d=dh(s.fragLoadPolicy.default),u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:ph};t.stats=h.stats,h.load(c,u,{onSuccess:(f,p,g,v)=>{this.resetLoader(t,h);let E=f.data;g.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(E.slice(0,16)),E=E.slice(16)),o({frag:t,part:null,payload:E,networkDetails:v})},onError:(f,p,g,v)=>{this.resetLoader(t,h),l(new Me({type:Q.NETWORK_ERROR,details:$.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:Qt({url:i,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:g,stats:v}))},onAbort:(f,p,g)=>{this.resetLoader(t,h),l(new Me({type:Q.NETWORK_ERROR,details:$.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:g,stats:f}))},onTimeout:(f,p,g)=>{this.resetLoader(t,h),l(new Me({type:Q.NETWORK_ERROR,details:$.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:g,stats:f}))},onProgress:(f,p,g,v)=>{e&&e({frag:t,part:null,payload:g,networkDetails:v})}})})}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(mh(t,e));return}const h=this.loader=t.loader=n?new n(s):new a(s),c=gh(t,e),d=dh(s.fragLoadPolicy.default),u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ph};e.stats=h.stats,h.load(c,u,{onSuccess:(f,p,g,v)=>{this.resetLoader(t,h),this.updateStatsFromPart(t,e);const E={frag:t,part:e,payload:f.data,networkDetails:v};i(E),o(E)},onError:(f,p,g,v)=>{this.resetLoader(t,h),l(new Me({type:Q.NETWORK_ERROR,details:$.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:Qt({url:c.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:g,stats:v}))},onAbort:(f,p,g)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,h),l(new Me({type:Q.NETWORK_ERROR,details:$.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 Me({type:Q.NETWORK_ERROR,details:$.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),c=(l-h)*Math.round(i.loaded/h);i.total=i.loaded+c}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(z(s)&&z(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 mh(r,t){const e=new Error(`GAP ${r.gap?"tag":"attribute"} found`),i={type:Q.MEDIA_ERROR,details:$.FRAG_GAP,fatal:!1,frag:r,error:e,networkDetails:null};return t&&(i.part=t),(t||r).stats.aborted=!0,new Me(i)}class Me extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class bg{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=$.KEY_LOAD_ERROR,i,s,n){return new Me({type:Q.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,$.KEY_LOAD_ERROR,h))}const a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(t,$.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,$.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,c={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(u,f,p,g)=>{const{frag:v,keyInfo:E,url:A}=p;if(!v.decryptdata||E!==this.keyUriToKeyInfo[A])return o(this.createKeyLoadError(v,$.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),g));E.decryptdata.key=v.decryptdata.key=new Uint8Array(u.data),v.keyLoader=null,E.loader=null,a({frag:v,keyInfo:E})},onError:(u,f,p,g)=>{this.resetLoader(f),o(this.createKeyLoadError(e,$.KEY_LOAD_ERROR,new Error(`HTTP Error ${u.code} loading key ${u.text}`),p,Qt({url:l.url,data:void 0},u)))},onTimeout:(u,f,p)=>{this.resetLoader(f),o(this.createKeyLoadError(e,$.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),p))},onAbort:(u,f,p)=>{this.resetLoader(f),o(this.createKeyLoadError(e,$.INTERNAL_ABORTED,new Error("key loading aborted"),p))}};n.load(l,c,d)})}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 Tg{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 Ag={length:0,start:()=>0,end:()=>0};class Et{static isBuffered(t,e){try{if(t){const i=Et.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=Et.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,c){return h.start-c.start||c.end-h.end});let s=[];if(i)for(let h=0;h<t.length;h++){const c=s.length;if(c){const d=s[c-1].end;t[h].start-d<i?t[h].end>d&&(s[c-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 c=s[h].start,d=s[h].end;if(e+i>=c&&e<d)o=c,l=d,n=l-e;else if(e+i<c){a=c;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(t){try{return t.buffered}catch(e){return _.log("failed to get media.buffered",e),Ag}}}class Hn{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=dr(),this.buffering={audio:dr(),video:dr(),audiovideo:dr()},this.level=t,this.sn=e,this.id=i,this.size=s,this.part=n,this.partial=a}}function dr(){return{start:0,executeStart:0,executeEnd:0,end:0}}function vh(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 wg(r,t,e){return!!(t.details&&(e.endCC>e.startCC||r&&r.cc<e.startCC))}function Sg(r,t,e=0){const i=r.fragments,s=t.fragments;if(!s.length||!i.length){_.log("No fragments to align");return}const n=vh(i,s[0].cc);if(!n||n&&!n.startPTS){_.log("No frag in previous level to align on");return}return n}function yh(r,t){if(r){const e=r.start+t;r.start=r.startPTS=e,r.endPTS=e+r.duration}}function Gn(r,t){const e=t.fragments;for(let i=0,s=e.length;i<s;i++)yh(e[i],r);t.fragmentHint&&yh(t.fragmentHint,r),t.alignedSliding=!0}function Lg(r,t,e){t&&(Rg(r,e,t),!e.alignedSliding&&t.details&&_g(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&oh(t.details,e))}function Rg(r,t,e){if(wg(r,e,t)){const i=Sg(e.details,t);i&&z(i.start)&&(_.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),Gn(i.start,t))}}function _g(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&&z(s)&&(_.log(`Adjusting PTS using programDateTime delta ${i-e}ms, sliding:${s.toFixed(3)} ${r.url} `),Gn(s,r))}function Eh(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=vh(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);Gn(h,r)}class kg{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 Ig{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 Dg(r){const t=r.byteLength,e=t&&new DataView(r.buffer).getUint8(t-1);return e?li(r,0,t-e):r}class Cg{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],c=l[1],d=l[2],u=l[3],f=new Uint32Array(256);let p=0,g=0,v=0;for(v=0;v<256;v++)v<128?f[v]=v<<1:f[v]=v<<1^283;for(v=0;v<256;v++){let E=g^g<<1^g<<2^g<<3^g<<4;E=E>>>8^E&255^99,t[p]=E,e[E]=p;const A=f[p],L=f[A],y=f[L];let S=f[E]*257^E*16843008;s[p]=S<<24|S>>>8,n[p]=S<<16|S>>>16,a[p]=S<<8|S>>>24,o[p]=S,S=y*16843009^L*65537^A*257^p*16843008,h[E]=S<<24|S>>>8,c[E]=S<<16|S>>>16,d[E]=S<<8|S>>>24,u[E]=S,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),c=this.invKeySchedule=new Uint32Array(a),d=this.sBox,u=this.rcon,f=this.invSubMix,p=f[0],g=f[1],v=f[2],E=f[3];let A,L;for(o=0;o<a;o++){if(o<n){A=h[o]=e[o];continue}L=A,o%n===0?(L=L<<8|L>>>24,L=d[L>>>24]<<24|d[L>>>16&255]<<16|d[L>>>8&255]<<8|d[L&255],L^=u[o/n|0]<<24):n>6&&o%n===4&&(L=d[L>>>24]<<24|d[L>>>16&255]<<16|d[L>>>8&255]<<8|d[L&255]),h[o]=A=(h[o-n]^L)>>>0}for(l=0;l<a;l++)o=a-l,l&3?L=h[o]:L=h[o-4],l<4||o<=4?c[l]=L:c[l]=p[d[L>>>24]]^g[d[L>>>16&255]]^v[d[L>>>8&255]]^E[d[L&255]],c[l]=c[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],c=o[2],d=o[3],u=this.uint8ArrayToUint32Array_(i);let f=u[0],p=u[1],g=u[2],v=u[3];const E=new Int32Array(t),A=new Int32Array(E.length);let L,y,S,R,D,M,C,I,G,F,V,q,w,P;const H=this.networkToHostOrderSwap;for(;e<E.length;){for(G=H(E[e]),F=H(E[e+1]),V=H(E[e+2]),q=H(E[e+3]),D=G^n[0],M=q^n[1],C=V^n[2],I=F^n[3],w=4,P=1;P<s;P++)L=l[D>>>24]^h[M>>16&255]^c[C>>8&255]^d[I&255]^n[w],y=l[M>>>24]^h[C>>16&255]^c[I>>8&255]^d[D&255]^n[w+1],S=l[C>>>24]^h[I>>16&255]^c[D>>8&255]^d[M&255]^n[w+2],R=l[I>>>24]^h[D>>16&255]^c[M>>8&255]^d[C&255]^n[w+3],D=L,M=y,C=S,I=R,w=w+4;L=a[D>>>24]<<24^a[M>>16&255]<<16^a[C>>8&255]<<8^a[I&255]^n[w],y=a[M>>>24]<<24^a[C>>16&255]<<16^a[I>>8&255]<<8^a[D&255]^n[w+1],S=a[C>>>24]<<24^a[I>>16&255]<<16^a[D>>8&255]<<8^a[M&255]^n[w+2],R=a[I>>>24]<<24^a[D>>16&255]<<16^a[M>>8&255]<<8^a[C&255]^n[w+3],A[e]=H(L^f),A[e+1]=H(R^p),A[e+2]=H(S^g),A[e+3]=H(y^v),f=G,p=F,g=V,v=q,e=e+4}return A.buffer}}const xg=16;class Vn{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?Dg(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=hi(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 Cg),l.expandKey(e);const h=n;return this.currentResult=l.decrypt(o.buffer,0,i),this.currentIV=li(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 Ig(s,e)),this.fastAesKey.expandKey().then(n=>s?(this.logOnce("WebCrypto AES decrypt"),new kg(s,new Uint8Array(i)).decrypt(t.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(_.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%xg;return i!==t.length&&(e=li(t,0,i),this.remainderData=li(t,i)),e}logOnce(t){this.logEnabled&&(_.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const Pg={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}},B={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 Kn extends Tg{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=B.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=_.log.bind(_,`${s}:`),this.warn=_.warn.bind(_,`${s}:`),this.hls=t,this.fragmentLoader=new Eg(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new Vn(t.config),t.on(m.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=B.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 Et.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===B.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=Et.bufferInfo(s||i,a,t.maxBufferHole);if(this.log(`media seeking to ${z(a)?a.toFixed(3):a}, state: ${n}`),this.state===B.ENDED)this.resetLoadingState();else if(e){const l=t.maxFragLookUpTolerance,h=e.start-l,c=e.start+e.duration+l;if(!o.len||c<o.start||h>o.end){const d=a>c;(a<h||d)&&(d&&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=B.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===B.FRAG_LOADING||!this.fragCurrent&&a===B.PARSING)&&(this.fragmentTracker.removeFragment(t),this.state=B.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(m.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===B.STOPPED||this.state===B.ERROR||(this.warn(n),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===$t.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)===$t.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(m.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(m.ERROR,{type:Q.MEDIA_ERROR,details:$.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:t}),l}).then(l=>{const h=self.performance.now();return s.trigger(m.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=B.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(m.FRAG_BUFFERED,{stats:o,frag:s,part:null,id:t.type}),this.tick()}).catch(i=>{this.state===B.STOPPED||this.state===B.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===Z.MAIN?"level":"track"} ${t.level} (frag:[${((i=t.startPTS)!=null?i:NaN).toFixed(3)}-${((s=t.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?Pg.toString(Et.getBuffered(o)):"(detached)"})`),this.state=B.IDLE,o&&(!this.loadedmetadata&&t.type==Z.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 Hn(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=B.KEY_LOADING,this.fragCurrent=t,o=this.keyLoader.load(t).then(c=>{if(!this.fragContextChanged(c.frag))return this.hls.trigger(m.KEY_LOADED,c),this.state===B.KEY_LOADING&&(this.state=B.IDLE),c}),this.hls.trigger(m.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 c=a.partList;if(c&&s){i>t.end&&a.fragmentHint&&(t=a.fragmentHint);const d=this.getNextPart(c,t,i);if(d>-1){const u=c[d];this.log(`Loading part sn: ${t.sn} p: ${u.index} cc: ${t.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${d}-${c.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=u.start+u.duration,this.state=B.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(m.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(c,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))}`),z(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=B.FRAG_LOADING;const l=this.config.progressive;let h;return l&&o?h=o.then(c=>!c||this.fragContextChanged(c==null?void 0:c.frag)?null:this.fragmentLoader.load(t,s)).catch(c=>this.handleFragLoadError(c)):h=Promise.all([this.fragmentLoader.load(t,l?s:void 0),o]).then(([c])=>(!l&&c&&s&&s(c),c)).catch(c=>this.handleFragLoadError(c)),this.hls.trigger(m.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,c=d=>{this.fragmentLoader.loadPart(t,d,s).then(u=>{l[d.index]=u;const f=u.part;this.hls.trigger(m.FRAG_LOADED,u);const p=lh(i,t.sn,d.index+1)||hh(h,t.sn,d.index+1);if(p)c(p);else return n({frag:t,part:f,partsLoaded:l})}).catch(a)};c(e)})}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===$.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(m.ERROR,e)}else this.hls.trigger(m.ERROR,{type:Q.OTHER_ERROR,details:$.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==B.PARSING){!this.fragCurrent&&this.state!==B.STOPPED&&this.state!==B.ERROR&&(this.state=B.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?lh(o,n,a):null,h=l?l.fragment:hg(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!==B.PARSING)return;const{data1:o,data2:l}=t;let h=o;if(o&&l&&(h=hi(o,l)),!((a=h)!=null&&a.length))return;const c={type:t.type,frag:e,part:i,chunkMeta:s,parent:e.type,data:h};if(this.hls.trigger(m.BUFFER_APPENDING,c),t.dropped&&t.independent&&!i){if(n)return;this.flushBufferGap(e)}}flushBufferGap(t){const e=this.media;if(!e)return;if(!Et.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}const i=e.currentTime,s=Et.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 z(i)?this.getFwdBufferInfoAtPos(t,i,e):null}getFwdBufferInfoAtPos(t,e,i){const{config:{maxBufferHole:s}}=this,n=Et.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 Et.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=Z.MAIN){const i=this.fragmentTracker.getAppendedFrag(t,Z.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===$t.OK||i===$t.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 c=h.loaded;c?s=-1:(n||h.independent||a)&&h.fragment===e&&(s=o),n=c}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=dg(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=fg(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,c=i.partList,d=!!(s.lowLatencyMode&&c!=null&&c.length&&l);d&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let u;if(t<e){const f=t>e-h?0:h;u=vs(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===$t.OK||p===$t.PARTIAL&&u.gap)&&(n=u),n&&u.sn===n.sn&&(!d||c[0].fragment.sn>u.sn)&&n&&u.level===n.level){const g=a[f+1];u.sn<o&&this.fragmentTracker.getState(g)!==$t.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,c=t.alignedSliding&&z(l);if(h||!c&&!l){Lg(n,a,t);const d=t.fragments[0].start;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} prev-sn: ${n?n.sn:"na"} fragments: ${o}`),d}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&&z(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!==B.FRAG_LOADING_WAITING_RETRY)&&(this.state=B.IDLE)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const d=this.getCurrentContext(e.chunkMeta);d&&(e.frag=d.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===$.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);const a=e.errorAction,{action:o,retryCount:l=0,retryConfig:h}=a||{};if(a&&o===Gt.RetryRequest&&h){var c;this.resetStartWhenNotLoaded((c=this.levelLastLoaded)!=null?c:i.level);const d=Fn(h,l);this.warn(`Fragment ${i.sn} of ${t} ${i.level} errored with ${e.details}, retrying loading ${l+1}/${h.maxNumRetry} in ${d}ms`),a.resolved=!0,this.retryDate=self.performance.now()+d,this.state=B.FRAG_LOADING_WAITING_RETRY}else h&&a?(this.resetFragmentErrors(t),l<h.maxNumRetry?n||(a.resolved=!0):_.warn(`${e.details} reached or exceeded max retry (${l})`)):(a==null?void 0:a.action)===Gt.SendAlternateToPenaltyBox?this.state=B.WAITING_LEVEL:this.state=B.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===B.PARSING||this.state===B.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===Z.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==B.STOPPED&&(this.state=B.IDLE)}afterBufferFlushed(t,e,i){if(!t)return;const s=Et.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,s,i),this.state===B.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=B.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 c=h.endPTS-h.startPTS;if(c<=0)return this.warn(`Could not parse fragment ${t.sn} ${l} duration reliably (${c})`),o||!1;const d=s?0:ah(a,t,h.startPTS,h.endPTS,h.startDTS,h.endDTS);return this.hls.trigger(m.LEVEL_PTS_UPDATED,{details:a,level:i,drift:d,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(m.ERROR,{type:Q.MEDIA_ERROR,details:$.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=B.PARSED,this.hls.trigger(m.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 bh(){return self.SourceBuffer||self.WebKitSourceBuffer}function Og(){const r=nr();if(!r)return!1;const t=bh(),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 $g(){var r;const t=bh();return typeof(t==null||(r=t.prototype)==null?void 0:r.changeType)=="function"}function Mg(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Fg(){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 Ng(r){const t=new self.URL(r,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}function _e(r="",t=9e4){return{type:r,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class Th{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=hi(this.cachedData,t),this.cachedData=null);let i=er(t,0),s=i?i.length:0,n;const a=this._audioTrack,o=this._id3Track,l=i?bp(i):void 0,h=t.length;for((this.basePTS===null||this.frameIndex===0&&z(l))&&(this.basePTS=Ug(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:ge.audioId3,duration:Number.POSITIVE_INFINITY});s<h;){if(this.canParse(t,s)){const c=this.appendFrame(a,t,s);c?(this.frameIndex++,this.lastPTS=c.sample.pts,s+=c.length,n=s):s=h}else Ep(t,s)?(i=er(t,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ge.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,n=s):s++;if(s===h&&n!==h){const c=li(t,n);this.cachedData?this.cachedData=hi(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:_e(),id3Track:o,textTrack:_e()}}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:_e(),id3Track:this._id3Track,textTrack:_e()}}destroy(){}}const Ug=(r,t,e)=>{if(z(r))return r*90;const i=e?e.baseTime*9e4/e.timescale:0;return t*9e4+i};function Bg(r,t,e,i){let s,n,a,o;const l=navigator.userAgent.toLowerCase(),h=i,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((t[e+2]&192)>>>6)+1;const d=(t[e+2]&60)>>>2;if(d>c.length-1){r.trigger(m.ERROR,{type:Q.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${d}`});return}return a=(t[e+2]&1)<<2,a|=(t[e+3]&192)>>>6,_.log(`manifest codec:${i}, ADTS type:${s}, samplingIndex:${d}`),/firefox/i.test(l)?d>=6?(s=5,o=new Array(4),n=d-3):(s=2,o=new Array(2),n=d):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=d):(s=5,o=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&d>=6?n=d-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(d>=6&&a===1||/vivaldi/i.test(l))||!i&&a===1)&&(s=2,o=new Array(2)),n=d)),o[0]=s<<3,o[0]|=(d&14)>>1,o[1]|=(d&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:c[d],channelCount:a,codec:"mp4a.40."+s,manifestCodec:h}}function Ah(r,t){return r[t]===255&&(r[t+1]&246)===240}function wh(r,t){return r[t+1]&1?7:9}function jn(r,t){return(r[t+3]&3)<<11|r[t+4]<<3|(r[t+5]&224)>>>5}function Hg(r,t){return t+5<r.length}function ur(r,t){return t+1<r.length&&Ah(r,t)}function Gg(r,t){return Hg(r,t)&&Ah(r,t)&&jn(r,t)<=r.length-t}function Vg(r,t){if(ur(r,t)){const e=wh(r,t);if(t+e>=r.length)return!1;const i=jn(r,t);if(i<=e)return!1;const s=t+i;return s===r.length||ur(r,s)}return!1}function Sh(r,t,e,i,s){if(!r.samplerate){const n=Bg(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,_.log(`parsed codec:${r.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function Lh(r){return 9216e4/r}function Kg(r,t){const e=wh(r,t);if(t+e<=r.length){const i=jn(r,t)-e;if(i>0)return{headerLength:e,frameLength:i}}}function Rh(r,t,e,i,s){const n=Lh(r.samplerate),a=i+s*n,o=Kg(t,e);let l;if(o){const{frameLength:c,headerLength:d}=o,u=d+c,f=Math.max(0,e+u-t.length);f?(l=new Uint8Array(u-d),l.set(t.subarray(e+d,t.length),0)):l=t.subarray(e+d,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 jg extends Th{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=(er(t,0)||[]).length;for(let i=t.length;e<i;e++)if(Vg(t,e))return _.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return Gg(t,e)}appendFrame(t,e,i){Sh(t,this.observer,e,i,t.manifestCodec);const s=Rh(t,e,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const Wg=/\/emsg[-/]ID3/i;class Yg{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=_e("video",1),a=this.audioTrack=_e("audio",1),o=this.txtTrack=_e("text",1);if(this.id3Track=_e("id3",1),this.timeOffset=0,!(t!=null&&t.byteLength))return;const l=Nl(t);if(l.video){const{id:h,timescale:c,codec:d}=l.video;n.id=h,n.timescale=o.timescale=c,n.codec=d}if(l.audio){const{id:h,timescale:c,codec:d}=l.audio;a.id=h,a.timescale=c,a.codec=d}o.id=$l.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,ot(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=hi(this.remainderData,t));const o=$p(i);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=i;const a=this.extractID3Track(s,e);return n.samples=Bl(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=Bl(t,e),{videoTrack:e,audioTrack:_e(),id3Track:s,textTrack:_e()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const s=ot(t.samples,["emsg"]);s&&s.forEach(n=>{const a=Np(n);if(Wg.test(a.schemeIdUri)){const o=z(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:ge.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 fr=null;const qg=[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],zg=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Xg=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Qg=[0,1,1,4];function _h(r,t,e,i,s){if(e+24>t.length)return;const n=kh(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 kh(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=qg[l*14+s-1]*1e3,c=zg[(e===3?0:e===2?1:2)*3+n],d=o===3?1:2,u=Xg[e][i],f=Qg[i],p=u*8*f,g=Math.floor(u*h/c+a)*f;if(fr===null){const v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);fr=v?parseInt(v[1]):0}return fr&&fr<=87&&i===2&&h>=224e3&&o===0&&(r[t+3]=r[t+3]|128),{sampleRate:c,channelCount:d,frameLength:g,samplesPerFrame:p}}}function Wn(r,t){return r[t]===255&&(r[t+1]&224)===224&&(r[t+1]&6)!==0}function Ih(r,t){return t+1<r.length&&Wn(r,t)}function Zg(r,t){return Wn(r,t)&&4<=r.length-t}function Jg(r,t){if(t+1<r.length&&Wn(r,t)){const e=kh(r,t);let i=4;e!=null&&e.frameLength&&(i=e.frameLength);const s=t+i;return s===r.length||Ih(r,s)}return!1}class Dh{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&&_.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),c=this.readUEG.bind(this),d=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 v=l();if(h(5),u(3),l(),p(),v===100||v===110||v===122||v===244||v===44||v===83||v===86||v===118||v===128){const R=c();if(R===3&&u(1),p(),p(),u(1),d())for(a=R!==3?8:12,o=0;o<a;o++)d()&&(o<6?g(16):g(64))}p();const E=c();if(E===0)c();else if(E===1)for(u(1),f(),f(),n=c(),o=0;o<n;o++)f();p(),u(1);const A=c(),L=c(),y=h(1);y===0&&u(1),u(1),d()&&(t=c(),e=c(),i=c(),s=c());let S=[1,1];if(d()&&d())switch(l()){case 1:S=[1,1];break;case 2:S=[12,11];break;case 3:S=[10,11];break;case 4:S=[16,11];break;case 5:S=[40,33];break;case 6:S=[24,11];break;case 7:S=[20,11];break;case 8:S=[32,11];break;case 9:S=[80,33];break;case 10:S=[18,11];break;case 11:S=[15,11];break;case 12:S=[64,33];break;case 13:S=[160,99];break;case 14:S=[4,3];break;case 15:S=[3,2];break;case 16:S=[2,1];break;case 255:{S=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((A+1)*16-t*2-e*2),height:(2-y)*(L+1)*16-(y?2:4)*(i+s),pixelRatio:S}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class tm{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Vn(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=Gl(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 Vt=188;class Ve{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=Ve.syncOffset(t);return e>0&&_.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),e!==-1}static syncOffset(t){const e=t.length;let i=Math.min(Vt*5,t.length-Vt)+1,s=0;for(;s<i;){let n=!1,a=-1,o=0;for(let l=s;l<e;l+=Vt)if(t[l]===71){if(o++,a===-1&&(a=l,a!==0&&(i=Math.min(a+Vt*99,t.length-Vt)+1)),n||(n=Yn(t,l)===0),n&&o>1&&(a===0&&o>2||l+Vt>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:$l[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=Ve.createTrack("video"),this._audioTrack=Ve.createTrack("audio",s),this._id3Track=Ve.createTrack("id3"),this._txtTrack=Ve.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 c=a.pid,d=a.pesData,u=o.pid,f=l.pid,p=o.pesData,g=l.pesData,v=null,E=this.pmtParsed,A=this._pmtId,L=t.length;if(this.remainderData&&(t=hi(this.remainderData,t),L=t.length,this.remainderData=null),L<Vt&&!s)return this.remainderData=t,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:h};const y=Math.max(0,Ve.syncOffset(t));L-=(L-y)%Vt,L<t.byteLength&&!s&&(this.remainderData=new Uint8Array(t.buffer,L,t.buffer.byteLength-L));let S=0;for(let D=y;D<L;D+=Vt)if(t[D]===71){const M=!!(t[D+1]&64),C=Yn(t,D),I=(t[D+3]&48)>>4;let G;if(I>1){if(G=D+5+t[D+4],G===D+Vt)continue}else G=D+4;switch(C){case c:M&&(d&&(n=ki(d))&&this.parseAVCPES(a,h,n,!1),d={data:[],size:0}),d&&(d.data.push(t.subarray(G,D+Vt)),d.size+=D+Vt-G);break;case u:if(M){if(p&&(n=ki(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(G,D+Vt)),p.size+=D+Vt-G);break;case f:M&&(g&&(n=ki(g))&&this.parseID3PES(l,n),g={data:[],size:0}),g&&(g.data.push(t.subarray(G,D+Vt)),g.size+=D+Vt-G);break;case 0:M&&(G+=t[G]+1),A=this._pmtId=em(t,G);break;case A:{M&&(G+=t[G]+1);const F=im(t,G,this.typeSupported,i);c=F.avc,c>0&&(a.pid=c),u=F.audio,u>0&&(o.pid=u,o.segmentCodec=F.segmentCodec),f=F.id3,f>0&&(l.pid=f),v!==null&&!E&&(_.warn(`MPEG-TS PMT found at ${D} after unknown PID '${v}'. Backtracking to sync byte @${y} to parse all TS packets.`),v=null,D=y-188),E=this.pmtParsed=!0;break}case 17:case 8191:break;default:v=C;break}}else S++;if(S>0){const D=new Error(`Found ${S} TS packet/s that do not start with 0x47`);this.observer.emit(m.ERROR,m.ERROR,{type:Q.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!1,error:D,reason:D.message})}a.pesData=d,o.pesData=p,l.pesData=g;const R={audioTrack:o,videoTrack:a,id3Track:l,textTrack:h};return s&&this.extractRemainingSamples(R),R}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=ki(a))?(this.parseAVCPES(i,n,h,!0),i.pesData=null):i.pesData=a,o&&(h=ki(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&&_.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=o;l&&(h=ki(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 tm(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&&(ys(a,t),a=this.avcSample=pr(!1,i.pts,i.dts,"")),n.forEach(h=>{var c;switch(h.type){case 1:{let u=!1;o=!0;const f=h.data;if(l&&f.length>4){const p=new Dh(f).readSliceType();(p===2||p===4||p===7||p===9)&&(u=!0)}if(u){var d;(d=a)!=null&&d.frame&&!a.key&&(ys(a,t),a=this.avcSample=null)}a||(a=this.avcSample=pr(!0,i.pts,i.dts,"")),a.frame=!0,a.key=u;break}case 5:o=!0,(c=a)!=null&&c.frame&&!a.key&&(ys(a,t),a=this.avcSample=null),a||(a=this.avcSample=pr(!0,i.pts,i.dts,"")),a.key=!0,a.frame=!0;break;case 6:{o=!0,Hl(h.data,1,i.pts,e.samples);break}case 7:if(o=!0,l=!0,!t.sps){const u=h.data,f=new Dh(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 v=0;v<3;v++){let E=p[v].toString(16);E.length<2&&(E="0"+E),g+=E}t.codec=g}break;case 8:o=!0,t.pps||(t.pps=[h.data]);break;case 9:o=!1,t.audFound=!0,a&&ys(a,t),a=this.avcSample=pr(!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&&(ys(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,c,d=-1,u=0;for(s===-1&&(d=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(d>=0){const f={data:e.subarray(d,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?(c=e[o]&31,d=o,u=c,s=0):s=-1}else s=0}if(d>=0&&s>=0){const f={data:e.subarray(d,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 d=s.missing,u=s.sample.unit.byteLength;if(d===-1){const f=new Uint8Array(u+n.byteLength);f.set(s.sample.unit,0),f.set(n,u),n=f}else{const f=u-d;s.sample.unit.set(n.subarray(0,d),f),t.samples.push(s.sample),i=s.missing}}let a,o;for(a=i,o=n.length;a<o-1&&!ur(n,a);a++);if(a!==i){let d;const u=a<o-1;u?d=`AAC PES did not start with ADTS header,offset:${a}`:d="No ADTS header found in AAC PES";const f=new Error(d);if(_.warn(`parsing error: ${d}`),this.observer.emit(m.ERROR,m.ERROR,{type:Q.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!1,levelRetry:u,error:f,reason:d}),!u)return}Sh(t,this.observer,n,a,this.audioCodec);let l;if(e.pts!==void 0)l=e.pts;else if(s){const d=Lh(t.samplerate);l=s.sample.pts+d}else{_.warn("[tsdemuxer]: AAC PES unknown PTS");return}let h=0,c;for(;a<o;)if(c=Rh(t,n,a,l,h),a+=c.length,c.missing){this.aacOverFlow=c;break}else for(h++;a<o-1&&!ur(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){_.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(Ih(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){_.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=xt({},e,{type:this._avcTrack?ge.emsg:ge.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function pr(r,t,e,i){return{key:r,frame:!1,pts:t,dts:e,units:[],debug:i,length:0}}function Yn(r,t){return((r[t+1]&31)<<8)+r[t+2]}function em(r,t){return(r[t+10]&31)<<8|r[t+11]}function im(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=Yn(r,t);switch(r[t]){case 207:if(!i){_.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){_.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?_.log("MPEG audio found, not supported in this browser"):s.audio===-1&&(s.audio=l,s.segmentCodec="mp3");break;case 36:_.warn("Unsupported HEVC stream type found");break}t+=((r[t+3]&15)<<8|r[t+4])+5}return s}function ki(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&&(_.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 c=new Uint8Array(r.size);for(let d=0,u=o.length;d<u;d++){e=o[d];let f=e.byteLength;if(h)if(h>f){h-=f;continue}else e=e.subarray(h),f-=h,h=0;c.set(e,t),t+=f}return i&&(i-=s+3),{data:c,pts:n,dts:a,len:i}}return null}function ys(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&&_.log(r.pts+"/"+r.dts+":"+r.debug)}class sm extends Th{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=(er(t,0)||[]).length;for(let i=t.length;e<i;e++)if(Jg(t,e))return _.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return Zg(t,e)}appendFrame(t,e,i){if(this.basePTS!==null)return _h(t,e,i,this.basePTS,this.frameIndex)}}class Ch{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 Ke=Math.pow(2,32)-1;class x{static init(){x.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 x.types)x.types.hasOwnProperty(t)&&(x.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]);x.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]);x.STTS=x.STSC=x.STCO=n,x.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),x.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),x.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),x.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]);x.FTYP=x.box(x.types.ftyp,a,l,a,o),x.DINF=x.box(x.types.dinf,x.box(x.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 x.box(x.types.hdlr,x.HDLR_TYPES[t])}static mdat(t){return x.box(x.types.mdat,t)}static mdhd(t,e){e*=t;const i=Math.floor(e/(Ke+1)),s=Math.floor(e%(Ke+1));return x.box(x.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 x.box(x.types.mdia,x.mdhd(t.timescale,t.duration),x.hdlr(t.type),x.minf(t))}static mfhd(t){return x.box(x.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"?x.box(x.types.minf,x.box(x.types.smhd,x.SMHD),x.DINF,x.stbl(t)):x.box(x.types.minf,x.box(x.types.vmhd,x.VMHD),x.DINF,x.stbl(t))}static moof(t,e,i){return x.box(x.types.moof,x.mfhd(t),x.traf(i,e))}static moov(t){let e=t.length;const i=[];for(;e--;)i[e]=x.trak(t[e]);return x.box.apply(null,[x.types.moov,x.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(x.mvex(t)))}static mvex(t){let e=t.length;const i=[];for(;e--;)i[e]=x.trex(t[e]);return x.box.apply(null,[x.types.mvex,...i])}static mvhd(t,e){e*=t;const i=Math.floor(e/(Ke+1)),s=Math.floor(e%(Ke+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 x.box(x.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 x.box(x.types.sdtp,i)}static stbl(t){return x.box(x.types.stbl,x.stsd(t),x.box(x.types.stts,x.STTS),x.box(x.types.stsc,x.STSC),x.box(x.types.stsz,x.STSZ),x.box(x.types.stco,x.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=x.box(x.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,c=t.pixelRatio[0],d=t.pixelRatio[1];return x.box(x.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,x.box(x.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),x.box(x.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,c&255,d>>24,d>>16&255,d>>8&255,d&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 x.box(x.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]),x.box(x.types.esds,x.esds(t)))}static mp3(t){const e=t.samplerate;return x.box(x.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"?x.box(x.types.stsd,x.STSD,x.mp3(t)):x.box(x.types.stsd,x.STSD,x.mp4a(t)):x.box(x.types.stsd,x.STSD,x.avc1(t))}static tkhd(t){const e=t.id,i=t.duration*t.timescale,s=t.width,n=t.height,a=Math.floor(i/(Ke+1)),o=Math.floor(i%(Ke+1));return x.box(x.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=x.sdtp(t),s=t.id,n=Math.floor(e/(Ke+1)),a=Math.floor(e%(Ke+1));return x.box(x.types.traf,x.box(x.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),x.box(x.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])),x.trun(t,i.length+16+20+8+16+8+8),i)}static trak(t){return t.duration=t.duration||4294967295,x.box(x.types.trak,x.tkhd(t),x.mdia(t))}static trex(t){const e=t.id;return x.box(x.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,c,d,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,c=l.size,d=l.flags,u=l.cts,a.set([h>>>24&255,h>>>16&255,h>>>8&255,h&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|d.isNonSync,d.degradPrio&61440,d.degradPrio&15,u>>>24&255,u>>>16&255,u>>>8&255,u&255],12+16*o);return x.box(x.types.trun,a)}static initSegment(t){x.types||x.init();const e=x.moov(t),i=new Uint8Array(x.FTYP.byteLength+e.byteLength);return i.set(x.FTYP),i.set(e,x.FTYP.byteLength),i}}x.types=void 0,x.HDLR_TYPES=void 0,x.STTS=void 0,x.STSC=void 0,x.STCO=void 0,x.STSZ=void 0,x.VMHD=void 0,x.SMHD=void 0,x.STSD=void 0,x.FTYP=void 0,x.DINF=void 0;const xh=9e4;function qn(r,t,e=1,i=!1){const s=r*t*e;return i?Math.round(s):s}function rm(r,t,e=1,i=!1){return qn(r,t,1/e,i)}function Es(r,t=!1){return qn(r,1e3,1/xh,t)}function nm(r,t=1){return qn(r,xh,1/t)}const am=10*1e3,Ph=1024,om=1152;let gr=null,zn=null;class Xn{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,gr===null){const n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);gr=n?parseInt(n[1]):0}if(zn===null){const n=navigator.userAgent.match(/Safari\/(\d+)/i);zn=n?parseInt(n[1]):0}}destroy(){}resetTimeStamp(t){_.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){_.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){_.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,ce(s,n.pts)):a>0?s:n.pts},t[0].pts);return e&&_.debug("PTS rollover detected"),i}remux(t,e,i,s,n,a,o,l){let h,c,d,u,f,p,g=n,v=n;const E=t.pid>-1,A=e.pid>-1,L=e.samples.length,y=t.samples.length>0,S=o&&L>0||L>1;if((!E||y)&&(!A||S)||this.ISGenerated||o){this.ISGenerated||(d=this.generateIS(t,e,n,a));const R=this.isVideoContiguous;let D=-1,M;if(S&&(D=lm(e.samples),!R&&this.config.forceKeyFrameOnDiscontinuity))if(p=!0,D>0){_.warn(`[mp4-remuxer]: Dropped ${D} out of ${L} video samples due to a missing keyframe`);const C=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(D),e.dropped+=D,v+=(e.samples[0].pts-C)/e.inputTimeScale,M=v}else D===-1&&(_.warn(`[mp4-remuxer]: No keyframe found out of ${L} video samples`),p=!1);if(this.ISGenerated){if(y&&S){const C=this.getVideoStartPts(e.samples),I=(ce(t.samples[0].pts,C)-C)/e.inputTimeScale;g+=Math.max(0,I),v+=Math.max(0,-I)}if(y){if(t.samplerate||(_.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(t,e,n,a)),c=this.remuxAudio(t,g,this.isAudioContiguous,a,A||S||l===Z.AUDIO?v:void 0),S){const C=c?c.endPTS-c.startPTS:0;e.inputTimeScale||(_.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(t,e,n,a)),h=this.remuxVideo(e,v,R,C)}}else S&&(h=this.remuxVideo(e,v,R,0));h&&(h.firstKeyFrame=D,h.independent=D!==-1,h.firstKeyFramePTS=M)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(f=Oh(i,n,this._initPTS,this._initDTS)),s.samples.length&&(u=$h(s,n,this._initPTS))),{audio:c,video:h,initSegment:d,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 c=!h||s,d="audio/mp4",u,f,p;if(c&&(u=f=1/0),t.config&&n.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":o.mpeg?(d="audio/mpeg",t.codec=""):o.mp3&&(t.codec="mp3");break}l.audio={id:"audio",container:d,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):x.initSegment([t]),metadata:{channelCount:t.channelCount}},c&&(p=t.inputTimeScale,!h||p!==h.timescale?u=f=n[0].pts-Math.round(p*i):c=!1)}if(e.sps&&e.pps&&a.length&&(e.timescale=e.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:x.initSegment([e]),metadata:{width:e.width,height:e.height}},c))if(p=e.inputTimeScale,!h||p!==h.timescale){const g=this.getVideoStartPts(a),v=Math.round(p*i);f=Math.min(f,ce(a[0].dts,g)-v),u=Math.min(u,g-v)}else c=!1;if(Object.keys(l).length)return this.ISGenerated=!0,c?(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 c=this.nextAvcDts,d=8,u=this.videoSampleDuration,f,p,g=Number.POSITIVE_INFINITY,v=Number.NEGATIVE_INFINITY,E=!1;if(!i||c===null){const b=e*n,T=a[0].pts-ce(a[0].dts,a[0].pts);c=b-T}const A=h.baseTime*n/h.timescale;for(let b=0;b<l;b++){const T=a[b];T.pts=ce(T.pts-A,c),T.dts=ce(T.dts-A,c),T.dts<a[b>0?b-1:b].dts&&(E=!0)}E&&a.sort(function(b,T){const k=b.dts-T.dts,N=b.pts-T.pts;return k||N}),f=a[0].dts,p=a[a.length-1].dts;const L=p-f,y=L?Math.round(L/(l-1)):u||t.inputTimeScale/30;if(i){const b=f-c,T=b>y,k=b<-1;if((T||k)&&(T?_.warn(`AVC: ${Es(b,!0)} ms (${b}dts) hole between fragments detected, filling it`):_.warn(`AVC: ${Es(-b,!0)} ms (${b}dts) overlapping between fragments detected`),!k||c>=a[0].pts)){f=c;const N=a[0].pts-b;a[0].dts=f,a[0].pts=N,_.log(`Video: First PTS/DTS adjusted: ${Es(N,!0)}/${Es(f,!0)}, delta: ${Es(b,!0)} ms`)}}f=Math.max(0,f);let S=0,R=0;for(let b=0;b<l;b++){const T=a[b],k=T.units,N=k.length;let U=0;for(let K=0;K<N;K++)U+=k[K].data.length;R+=U,S+=N,T.length=U,T.dts=Math.max(T.dts,f),g=Math.min(T.pts,g),v=Math.max(T.pts,v)}p=a[l-1].dts;const D=R+4*S+8;let M;try{M=new Uint8Array(D)}catch(b){this.observer.emit(m.ERROR,m.ERROR,{type:Q.MUX_ERROR,details:$.REMUX_ALLOC_ERROR,fatal:!1,error:b,bytes:D,reason:`fail allocating video mdat ${D}`});return}const C=new DataView(M.buffer);C.setUint32(0,D),M.set(x.types.mdat,4);let I=!1,G=Number.POSITIVE_INFINITY,F=Number.POSITIVE_INFINITY,V=Number.NEGATIVE_INFINITY,q=Number.NEGATIVE_INFINITY;for(let b=0;b<l;b++){const T=a[b],k=T.units;let N=0;for(let W=0,X=k.length;W<X;W++){const lt=k[W],rt=lt.data,at=lt.data.byteLength;C.setUint32(d,at),d+=4,M.set(rt,d),d+=at,N+=4+at}let U;if(b<l-1)u=a[b+1].dts-T.dts,U=a[b+1].pts-T.pts;else{const W=this.config,X=b>0?T.dts-a[b-1].dts:y;if(U=b>0?T.pts-a[b-1].pts:y,W.stretchShortVideoTrack&&this.nextAudioPts!==null){const lt=Math.floor(W.maxBufferHole*n),rt=(s?g+s*n:this.nextAudioPts)-T.pts;rt>lt?(u=rt-X,u<0?u=X:I=!0,_.log(`[mp4-remuxer]: It is approximately ${rt/90} ms to the next segment; using duration ${u/90} ms for the last video frame.`)):u=X}else u=X}const K=Math.round(T.pts-T.dts);G=Math.min(G,u),V=Math.max(V,u),F=Math.min(F,U),q=Math.max(q,U),o.push(new Mh(T.key,u,N,K))}if(o.length){if(gr){if(gr<70){const b=o[0].flags;b.dependsOn=2,b.isNonSync=0}}else if(zn&&q-F<V-G&&y/V<.025&&o[0].cts===0){_.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let b=f;for(let T=0,k=o.length;T<k;T++){const N=b+o[T].duration,U=b+o[T].cts;if(T<k-1){const K=N+o[T+1].cts;o[T].duration=K-U}else o[T].duration=T?o[T-1].duration:y;o[T].cts=0,b=N}}}u=I||!u?y:u,this.nextAvcDts=c=p+u,this.videoSampleDuration=u,this.isVideoContiguous=!0;const w=x.moof(t.sequenceNumber++,f,xt({},t,{samples:o})),P="video",H={data1:w,data2:M,startPTS:g/n,endPTS:(v+u)/n,startDTS:f/n,endDTS:c/n,type:P,hasAudio:!1,hasVideo:!0,nb:o.length,dropped:t.dropped};return t.samples=[],t.dropped=0,H}remuxAudio(t,e,i,s,n){const a=t.inputTimeScale,o=t.samplerate?t.samplerate:a,l=a/o,h=t.segmentCodec==="aac"?Ph:om,c=h*l,d=this._initPTS,u=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],p=n!==void 0;let g=t.samples,v=u?0:8,E=this.nextAudioPts||-1;const A=e*a,L=d.baseTime*a/d.timescale;if(this.isAudioContiguous=i=i||g.length&&E>0&&(s&&Math.abs(A-E)<9e3||Math.abs(ce(g[0].pts-L,A)-E)<20*c),g.forEach(function(w){w.pts=ce(w.pts-L,A)}),!i||E<0){if(g=g.filter(w=>w.pts>=0),!g.length)return;n===0?E=0:s&&!p?E=Math.max(0,A):E=g[0].pts}if(t.segmentCodec==="aac"){const w=this.config.maxAudioFramesDrift;for(let P=0,H=E;P<g.length;P++){const b=g[P],T=b.pts,k=T-H,N=Math.abs(1e3*k/a);if(k<=-w*c&&p)P===0&&(_.warn(`Audio frame @ ${(T/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*k/a)} ms.`),this.nextAudioPts=E=H=T);else if(k>=w*c&&N<am&&p){let U=Math.round(k/c);H=T-U*c,H<0&&(U--,H+=c),P===0&&(this.nextAudioPts=E=H),_.warn(`[mp4-remuxer]: Injecting ${U} audio frame @ ${(H/a).toFixed(3)}s due to ${Math.round(1e3*k/a)} ms gap.`);for(let K=0;K<U;K++){const W=Math.max(H,0);let X=Ch.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);X||(_.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),X=b.unit.subarray()),g.splice(P,0,{unit:X,pts:W}),H+=c,P++}}b.pts=H,H+=c}}let y=null,S=null,R,D=0,M=g.length;for(;M--;)D+=g[M].unit.byteLength;for(let w=0,P=g.length;w<P;w++){const H=g[w],b=H.unit;let T=H.pts;if(S!==null){const N=f[w-1];N.duration=Math.round((T-S)/l)}else if(i&&t.segmentCodec==="aac"&&(T=E),y=T,D>0){D+=v;try{R=new Uint8Array(D)}catch(N){this.observer.emit(m.ERROR,m.ERROR,{type:Q.MUX_ERROR,details:$.REMUX_ALLOC_ERROR,fatal:!1,error:N,bytes:D,reason:`fail allocating audio mdat ${D}`});return}u||(new DataView(R.buffer).setUint32(0,D),R.set(x.types.mdat,4))}else return;R.set(b,v);const k=b.byteLength;v+=k,f.push(new Mh(!0,h,k,0)),S=T}const C=f.length;if(!C)return;const I=f[f.length-1];this.nextAudioPts=E=S+l*I.duration;const G=u?new Uint8Array(0):x.moof(t.sequenceNumber++,y/l,xt({},t,{samples:f}));t.samples=[];const F=y/a,V=E/a,q={data1:G,data2:R,startPTS:F,endPTS:V,startDTS:F,endDTS:V,type:"audio",hasAudio:!0,hasVideo:!1,nb:C};return this.isAudioContiguous=!0,q}remuxEmptyAudio(t,e,i,s){const n=t.inputTimeScale,a=t.samplerate?t.samplerate:n,o=n/a,l=this.nextAudioPts,h=this._initDTS,c=h.baseTime*9e4/h.timescale,d=(l!==null?l:s.startDTS*n)+c,u=s.endDTS*n+c,f=o*Ph,p=Math.ceil((u-d)/f),g=Ch.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(_.warn("[mp4-remuxer]: remux empty Audio"),!g){_.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const v=[];for(let E=0;E<p;E++){const A=d+E*f;v.push({unit:g,pts:A,dts:A})}return t.samples=v,this.remuxAudio(t,e,i,!1)}}function ce(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 lm(r){for(let t=0;t<r.length;t++)if(r[t].key)return t;return-1}function Oh(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=ce(l.pts-e.baseTime*n/e.timescale,t*n)/n,l.dts=ce(l.dts-i.baseTime*n/i.timescale,t*n)/n}const a=r.samples;return r.samples=[],{samples:a}}function $h(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=ce(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 Mh{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 hm(t)}}class hm{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 cm{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(Dp(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=Nl(t);e||(e=Fh(s.audio,mt.AUDIO)),i||(i=Fh(s.video,mt.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"}:_.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:c}=this;const d={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};z(c)||(c=this.lastEndTime=n||0);const u=e.samples;if(!(u!=null&&u.length))return d;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 _.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const g=xp(u,p),v=Cp(p,u),E=v===null?n:v;(dm(h,E,n,g)||f.timescale!==h.timescale&&a)&&(f.initPTS=E-n,h&&h.timescale===1&&_.warn(`Adjusting initPTS by ${f.initPTS-h.baseTime}`),this.initPTS=h={baseTime:f.initPTS,timescale:1});const A=t?E-h.baseTime/h.timescale:c,L=A+g;Op(p,u,h.baseTime/h.timescale),g>0?this.lastEndTime=L:(_.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const y=!!p.audio,S=!!p.video;let R="";y&&(R+="audio"),S&&(R+="video");const D={data1:u,startPTS:A,startDTS:A,endPTS:L,endDTS:L,type:R,hasAudio:y,hasVideo:S,nb:1,dropped:0};return d.audio=D.type==="audio"?D:void 0,d.video=D.type!=="audio"?D:void 0,d.initSegment=f,d.id3=Oh(i,n,h,h),s.samples.length&&(d.text=$h(s,n,h)),d}}function dm(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 Fh(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===mt.VIDEO?"avc1.42e01e":"mp4a.40.5"}let Fe;try{Fe=self.performance.now.bind(self.performance)}catch{_.debug("Unable to use Performance API on this environment"),Fe=typeof self<"u"&&self.Date.now}const Qn=[{demux:Yg,remux:cm},{demux:Ve,remux:Xn},{demux:jg,remux:Xn},{demux:sm,remux:Xn}];class Nh{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=Fe();let a=new Uint8Array(t);const{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);const{contiguous:h,discontinuity:c,trackSwitch:d,accurateTimeOffset:u,timeOffset:f,initSegmentChange:p}=s||o,{audioCodec:g,videoCodec:v,defaultInitPts:E,duration:A,initSegmentData:L}=l,y=um(a,e);if(y&&y.method==="AES-128"){const M=this.getDecrypter();if(M.isSync()){let C=M.softwareDecrypt(a,y.key.buffer,y.iv.buffer);if(i.part>-1&&(C=M.flush()),!C)return n.executeEnd=Fe(),Zn(i);a=new Uint8Array(C)}else return this.decryptionPromise=M.webCryptoDecrypt(a,y.key.buffer,y.iv.buffer).then(C=>{const I=this.push(C,null,i);return this.decryptionPromise=null,I}),this.decryptionPromise}const S=this.needsProbing(c,d);if(S){const M=this.configureTransmuxer(a);if(M)return _.warn(`[transmuxer] ${M.message}`),this.observer.emit(m.ERROR,m.ERROR,{type:Q.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!1,error:M,reason:M.message}),n.executeEnd=Fe(),Zn(i)}(c||d||p||S)&&this.resetInitSegment(L,g,v,A,e),(c||p||S)&&this.resetInitialTimestamp(E),h||this.resetContiguity();const R=this.transmux(a,y,f,u,i),D=this.currentTransmuxState;return D.contiguous=!0,D.discontinuity=!1,D.trackSwitch=!1,n.executeEnd=Fe(),R}flush(t){const e=t.transmuxing;e.executeStart=Fe();const{decrypter:i,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(t));const a=[],{timeOffset:o}=s;if(i){const d=i.flush();d&&a.push(this.push(d,null,t))}const{demuxer:l,remuxer:h}=this;if(!l||!h)return e.executeEnd=Fe(),[Zn(t)];const c=l.flush(o);return mr(c)?c.then(d=>(this.flushRemux(a,d,t),a)):(this.flushRemux(a,c,t),a)}flushRemux(t,e,i){const{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=e,{accurateTimeOffset:l,timeOffset:h}=this.currentTransmuxState;_.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const c=this.remuxer.remux(s,n,a,o,h,l,!0,this.id);t.push({remuxResult:c,chunkMeta:i}),i.transmuxing.executeEnd=Fe()}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 d=0,u=Qn.length;d<u;d++)if(Qn[d].demux.probe(t)){a=Qn[d];break}if(!a)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,l=this.remuxer,h=a.remux,c=a.demux;(!l||!(l instanceof h))&&(this.remuxer=new h(i,e,s,n)),(!o||!(o instanceof c))&&(this.demuxer=new c(i,e,s),this.probe=c.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new Vn(this.config)),t}}function um(r,t){let e=null;return r.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(e=t),e}const Zn=r=>({remuxResult:{},chunkMeta:r});function mr(r){return"then"in r&&r.then instanceof Function}class fm{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 pm{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 Uh={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,c){this.fn=l,this.context=h,this.once=c||!1}function n(l,h,c,d,u){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,d||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,c;if(this._eventsCount===0)return l;for(c in h=this._events)t.call(h,c)&&l.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(h)):l},o.prototype.listeners=function(l){var h=e?e+l:l,c=this._events[h];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,u=c.length,f=new Array(u);d<u;d++)f[d]=c[d].fn;return f},o.prototype.listenerCount=function(l){var h=e?e+l:l,c=this._events[h];return c?c.fn?1:c.length:0},o.prototype.emit=function(l,h,c,d,u,f){var p=e?e+l:l;if(!this._events[p])return!1;var g=this._events[p],v=arguments.length,E,A;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),v){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,c),!0;case 4:return g.fn.call(g.context,h,c,d),!0;case 5:return g.fn.call(g.context,h,c,d,u),!0;case 6:return g.fn.call(g.context,h,c,d,u,f),!0}for(A=1,E=new Array(v-1);A<v;A++)E[A-1]=arguments[A];g.fn.apply(g.context,E)}else{var L=g.length,y;for(A=0;A<L;A++)switch(g[A].once&&this.removeListener(l,g[A].fn,void 0,!0),v){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,c);break;case 4:g[A].fn.call(g[A].context,h,c,d);break;default:if(!E)for(y=1,E=new Array(v-1);y<v;y++)E[y-1]=arguments[y];g[A].fn.apply(g[A].context,E)}}return!0},o.prototype.on=function(l,h,c){return n(this,l,h,c,!1)},o.prototype.once=function(l,h,c){return n(this,l,h,c,!0)},o.prototype.removeListener=function(l,h,c,d){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&&(!d||f.once)&&(!c||f.context===c)&&a(this,u);else{for(var p=0,g=[],v=f.length;p<v;p++)(f[p].fn!==h||d&&!f[p].once||c&&f[p].context!==c)&&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})(Uh);var gm=Uh.exports,Jn=tp(gm);const ta=nr()||{isTypeSupported:()=>!1};class Bh{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,c)=>{c=c||{},c.frag=this.frag,c.id=this.id,h===m.ERROR&&(this.error=c.error),this.hls.trigger(h,c)};this.observer=new Jn,this.observer.on(m.FRAG_DECRYPTED,a),this.observer.on(m.ERROR,a);const o={mp4:ta.isTypeSupported("video/mp4"),mpeg:ta.isTypeSupported("audio/mpeg"),mp3:ta.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(n.workerPath||Mg())){try{n.workerPath?(_.log(`loading Web Worker ${n.workerPath} for "${e}"`),this.workerContext=Ng(n.workerPath)):(_.log(`injecting Web Worker for "${e}"`),this.workerContext=Fg()),this.onwmsg=c=>this.onWorkerMessage(c);const{worker:h}=this.workerContext;h.addEventListener("message",this.onwmsg),h.onerror=c=>{const d=new Error(`${c.message} (${c.filename}:${c.lineno})`);n.enableWorker=!1,_.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(m.ERROR,{type:Q.OTHER_ERROR,details:$.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:d})},h.postMessage({cmd:"init",typeSupported:o,vendor:l,id:e,config:JSON.stringify(n)})}catch(h){_.warn(`Error setting up "${e}" Web Worker, fallback to inline`,h),this.resetWorker(),this.error=null,this.transmuxer=new Nh(this.observer,o,n,l,e)}return}this.transmuxer=new Nh(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,c){var d,u;h.transmuxing.start=self.performance.now();const{transmuxer:f}=this,p=a?a.start:n.start,g=n.decryptdata,v=this.frag,E=!(v&&n.cc===v.cc),A=!(v&&h.level===v.level),L=v?h.sn-v.sn:-1,y=this.part?h.part-this.part.index:-1,S=L===0&&h.id>1&&h.id===(v==null?void 0:v.stats.chunkCount),R=!A&&(L===1||L===0&&(y===1||S&&y<=0)),D=self.performance.now();(A||L||n.stats.parsing.start===0)&&(n.stats.parsing.start=D),a&&(y||!R)&&(a.stats.parsing.start=D);const M=!(v&&((d=n.initSegment)==null?void 0:d.url)===((u=v.initSegment)==null?void 0:u.url)),C=new pm(E,R,l,A,p,M);if(!R||E||M){_.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${h.sn} p: ${h.part} level: ${h.level} id: ${h.id}
165
- discontinuity: ${E}
166
- trackSwitch: ${A}
167
- contiguous: ${R}
168
- accurateTimeOffset: ${l}
169
- timeOffset: ${p}
170
- initSegmentChange: ${M}`);const I=new fm(i,s,e,o,c);this.configureTransmuxer(I)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:g,chunkMeta:h,state:C},t instanceof ArrayBuffer?[t]:[]);else if(f){const I=f.push(t,g,h,C);mr(I)?(f.async=!0,I.then(G=>{this.handleTransmuxComplete(G)}).catch(G=>{this.transmuxerError(G,h,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(I))}}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);mr(i)||e.async?(mr(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(m.ERROR,{type:Q.MEDIA_ERROR,details:$.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":_[e.data.logType]&&_[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 mm=250,ea=2,vm=.1,ym=.05;class Em{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 E=self.performance.now()-n;_.warn(`playback not stuck anymore @${a}, after ${Math.round(E)}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||!Et.getBuffered(s).length)return;const c=Et.bufferInfo(s,a,0),d=c.len>0,u=c.nextStart||0;if(!d&&!u)return;if(o){const E=c.len>ea,A=!u||e&&e.start<=a||u-a>ea&&!this.fragmentTracker.getPartialFragment(a);if(E||A)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var f;const E=Math.max(u,c.start||0)-a,A=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,L=!(A==null||(f=A.details)==null)&&f.live?A.details.targetduration*2:ea,y=this.fragmentTracker.getPartialFragment(a);if(E>0&&(E<=L||y)){this._trySkipBufferHole(y);return}}const p=self.performance.now();if(n===null){this.stalled=p;return}const g=p-n;if(!o&&g>=mm&&(this._reportStall(c),!this.media))return;const v=Et.bufferInfo(s,a,i.maxBufferHole);this._tryFixBufferStall(v,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&&(_.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)})`);_.warn(n.message),e.trigger(m.ERROR,{type:Q.MEDIA_ERROR,details:$.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=Et.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,c=o-n;if(c>0&&(l||h)){if(c>e.maxBufferHole){const{fragmentTracker:u}=this;let f=!1;if(n===0){const p=u.getAppendedFrag(0,Z.MAIN);p&&o<p.end&&(f=!0)}if(!f){const p=t||u.getAppendedFrag(n,Z.MAIN);if(p){let g=!1,v=p.end;for(;v<o;){const E=u.getPartialFragment(v);if(E)v+=E.duration;else{g=!0;break}}if(g)return 0}}}const d=Math.max(o+ym,n+vm);if(_.warn(`skipping hole, adjusting currentTime from ${n} to ${d}`),this.moved=!0,this.stalled=null,s.currentTime=d,t&&!t.gap){const u=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${d}`);i.trigger(m.ERROR,{type:Q.MEDIA_ERROR,details:$.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:u,reason:u.message,frag:t})}return d}}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}`);_.warn(o.message),i.currentTime=a,e.trigger(m.ERROR,{type:Q.MEDIA_ERROR,details:$.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`);_.error(a.message),e.trigger(m.ERROR,{type:Q.MEDIA_ERROR,details:$.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}}const bm=100;class Tm extends Kn{constructor(t,e,i){super(t,e,i,"[stream-controller]",Z.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(m.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(m.MANIFEST_LOADING,this.onManifestLoading,this),t.on(m.MANIFEST_PARSED,this.onManifestParsed,this),t.on(m.LEVEL_LOADING,this.onLevelLoading,this),t.on(m.LEVEL_LOADED,this.onLevelLoaded,this),t.on(m.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(m.ERROR,this.onError,this),t.on(m.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(m.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(m.BUFFER_CREATED,this.onBufferCreated,this),t.on(m.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(m.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(m.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(m.MANIFEST_LOADING,this.onManifestLoading,this),t.off(m.MANIFEST_PARSED,this.onManifestParsed,this),t.off(m.LEVEL_LOADED,this.onLevelLoaded,this),t.off(m.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(m.ERROR,this.onError,this),t.off(m.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(m.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(m.BUFFER_CREATED,this.onBufferCreated,this),t.off(m.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(m.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(m.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(bm),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=B.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=B.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case B.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=B.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=B.IDLE;break}break}case B.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=B.IDLE)}break}this.state===B.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 v={};this.altAudio&&(v.type="video"),this.hls.trigger(m.BUFFER_EOS,v),this.state=B.ENDED;return}t.loadLevel!==a&&t.manualLevel===-1&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=t.nextLoadLevel=a;const c=o.details;if(!c||this.state===B.WAITING_LEVEL||c.live&&this.levelLastLoaded!==a){this.level=a,this.state=B.WAITING_LEVEL;return}const d=l.len,u=this.getMaxBufferLength(o.maxBitrate);if(d>=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,c);if(this.couldBacktrack&&!this.fragPrevious&&p&&p.sn!=="initSegment"&&this.fragmentTracker.getState(p)!==$t.OK){var g;const v=((g=this.backtrackFragment)!=null?g:p).sn-c.startSN,E=c.fragments[v-1];E&&p.cc===E.cc&&(p=E,this.fragmentTracker.removeFragment(E))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,f)){if(!p.gap){const v=this.audioOnly&&!this.altAudio?mt.AUDIO:mt.VIDEO,E=(v===mt.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,v,Z.MAIN)}p=this.getNextFragmentLoopLoading(p,c,l,Z.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===$t.NOT_LOADED||s===$t.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,Z.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,c=Math.max(a.end,l+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*.5),h*.75));this.flushMainBuffer(c,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 B.KEY_LOADING:case B.FRAG_LOADING:case B.FRAG_LOADING_WAITING_RETRY:case B.PARSING:case B.PARSED:this.state=B.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 Em(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;z(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(m.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&&!$g(),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!==B.IDLE)return;const s=i[e.level];(!s.details||s.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(s.details))&&(this.state=B.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===B.FRAG_LOADING||this.state===B.FRAG_LOADING_WAITING_RETRY)&&(h.level!==e.level||h.urlId!==l.urlId)&&h.loader&&this.abortCurrentFrag();let c=0;if(a.live||(i=l.details)!=null&&i.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;c=this.alignPlaylists(a,l.details)}if(l.details=a,this.levelLastLoaded=n,this.hls.trigger(m.LEVEL_UPDATED,{details:a,level:n}),this.state===B.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=B.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,c),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,c=l.PTSKnown||!l.live,d=(e=i.initSegment)==null?void 0:e.data,u=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new Bh(this.hls,Z.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),p=s?s.index:-1,g=p!==-1,v=new Hn(i.level,i.sn,i.stats.chunkCount,n.byteLength,p,g),E=this.initPTS[i.cc];f.push(n,d,u,h,i,s,l.totalduration,c,v,E)}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(m.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),s.trigger(m.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!==Z.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===B.PARSED&&(this.state=B.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=B.ERROR;return}switch(e.details){case $.FRAG_GAP:case $.FRAG_PARSING_ERROR:case $.FRAG_DECRYPT_ERROR:case $.FRAG_LOAD_ERROR:case $.FRAG_LOAD_TIMEOUT:case $.KEY_LOAD_ERROR:case $.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Z.MAIN,e);break;case $.LEVEL_LOAD_ERROR:case $.LEVEL_LOAD_TIMEOUT:case $.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===B.WAITING_LEVEL&&((i=e.context)==null?void 0:i.type)===ct.LEVEL&&(this.state=B.IDLE);break;case $.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="main")return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case $.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}checkBuffer(){const{media:t,gapController:e}=this;if(!(!t||!e||!t.readyState)){if(this.loadedmetadata||!Et.getBuffered(t).length){const i=this.state!==B.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=B.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==mt.AUDIO||this.audioOnly&&!this.altAudio){const i=(e===mt.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,e,Z.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=Et.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=B.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(m.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:c}=o,{video:d,text:u,id3:f,initSegment:p}=n,{details:g}=c,v=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=B.PARSING,p){if(p!=null&&p.tracks){const L=l.initSegment||l;this._bufferInitSegment(c,p.tracks,L,a),s.trigger(m.FRAG_PARSING_INIT_SEGMENT,{frag:L,id:i,tracks:p.tracks})}const E=p.initPTS,A=p.timescale;z(E)&&(this.initPTS[l.cc]={baseTime:E,timescale:A},s.trigger(m.INIT_PTS_FOUND,{frag:l,id:i,initPTS:E,timescale:A}))}if(d&&g&&l.sn!=="initSegment"){const E=g.fragments[l.sn-1-g.startSN],A=l.sn===g.startSN,L=!E||l.cc>E.cc;if(n.independent!==!1){const{startPTS:y,endPTS:S,startDTS:R,endDTS:D}=d;if(h)h.elementaryStreams[d.type]={startPTS:y,endPTS:S,startDTS:R,endDTS:D};else if(d.firstKeyFrame&&d.independent&&a.id===1&&!L&&(this.couldBacktrack=!0),d.dropped&&d.independent){const M=this.getMainFwdBufferInfo(),C=(M?M.end:this.getLoadPosition())+this.config.maxBufferHole,I=d.firstKeyFramePTS?d.firstKeyFramePTS:y;if(!A&&C<I-this.config.maxBufferHole&&!L){this.backtrack(l);return}else L&&(l.gap=!0);l.setElementaryStreamInfo(d.type,l.start,S,l.start,D,!0)}l.setElementaryStreamInfo(d.type,y,S,R,D),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(d,l,h,a,A||L)}else if(A||L)l.gap=!0;else{this.backtrack(l);return}}if(v){const{startPTS:E,endPTS:A,startDTS:L,endDTS:y}=v;h&&(h.elementaryStreams[mt.AUDIO]={startPTS:E,endPTS:A,startDTS:L,endDTS:y}),l.setElementaryStreamInfo(mt.AUDIO,E,A,L,y),this.bufferFragmentData(v,l,h,a)}if(g&&f!=null&&(e=f.samples)!=null&&e.length){const E={id:i,frag:l,details:g,samples:f.samples};s.trigger(m.FRAG_PARSING_METADATA,E)}if(g&&u){const E={id:i,frag:l,details:g,samples:u.samples};s.trigger(m.FRAG_PARSING_USERDATA,E)}}_bufferInitSegment(t,e,i,s){if(this.state!==B.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(m.BUFFER_CODECS,e),Object.keys(e).forEach(l=>{const h=e[l].initSegment;h!=null&&h.byteLength&&this.hls.trigger(m.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,Z.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=B.IDLE}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&t.seeking===!1){const i=t.currentTime;if(Et.isBuffered(t,i)?e=this.getAppendedFrag(i):Et.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(m.FRAG_CHANGED,{frag:e}),(!s||s.level!==n)&&this.hls.trigger(m.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&&z(e)&&z(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 Ii{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 Am{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 Ii(t),this.fast_=new Ii(e),this.defaultTTFB_=s,this.ttfb_=new Ii(t)}update(t,e){const{slow_:i,fast_:s,ttfb_:n}=this;i.halfLife!==t&&(this.slow_=new Ii(t,i.getEstimate(),i.getTotalWeight())),s.halfLife!==e&&(this.fast_=new Ii(e,s.getEstimate(),s.getTotalWeight())),n.halfLife!==t&&(this.ttfb_=new Ii(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 wm{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 Am(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(m.FRAG_LOADING,this.onFragLoading,this),t.on(m.FRAG_LOADED,this.onFragLoaded,this),t.on(m.FRAG_BUFFERED,this.onFragBuffered,this),t.on(m.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(m.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:t}=this;t.off(m.FRAG_LOADING,this.onFragLoading,this),t.off(m.FRAG_LOADED,this.onFragLoaded,this),t.off(m.FRAG_BUFFERED,this.onFragBuffered,this),t.off(m.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(m.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;z(s)&&z(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 c=i.mainForwardBufferInfo;if(c===null)return;const d=this.bwEstimator.getEstimateTTFB(),u=Math.abs(n.playbackRate);if(h<=Math.max(d,1e3*(l/(u*2))))return;const f=c.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,v=this.bwEstimator.getEstimate(),{levels:E,minAutoLevel:A}=i,L=E[t.level],y=o.total||Math.max(o.loaded,Math.round(l*L.maxBitrate/8));let S=h-p;S<1&&g&&(S=Math.min(h,o.loaded*8/v));const R=g?o.loaded*1e3/S:0,D=R?(y-o.loaded)/R:y*8/v+d/1e3;if(D<=f)return;const M=R?R*8:v;let C=Number.POSITIVE_INFINITY,I;for(I=t.level-1;I>A;I--){const G=E[I].maxBitrate;if(C=this.getTimeToLoadFrag(d/1e3,M,l*G,!E[I].details),C<f)break}C>=D||C>l*10||(i.nextLoadLevel=I,g?this.bwEstimator.sample(h-Math.min(d,p),o.loaded):this.bwEstimator.sampleTTFB(h),this.clearTimer(),_.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;
171
- Time to underbuffer: ${f.toFixed(3)} s
172
- Estimated load time for current fragment: ${D.toFixed(3)} s
173
- Estimated load time for down switch fragment: ${C.toFixed(3)} s
174
- TTFB estimate: ${p}
175
- Current BW estimate: ${z(v)?(v/1024).toFixed(3):"Unknown"} Kb/s
183
+ */const ou=(n,t,e)=>{const i=new Map;for(let s=t;s<=e;s++)i.set(n[s],s);return i},lu=An(class extends na{constructor(n){if(super(n),n.type!==bn.CHILD)throw Error("repeat() can only be used in text expressions")}ht(n,t,e){let i;e===void 0?e=t:t!==void 0&&(i=t);const s=[],o=[];let c=0;for(const d of n)s[c]=i?i(d,c):c,o[c]=e(d,c),c++;return{values:o,keys:s}}render(n,t,e){return this.ht(n,t,e).values}update(n,[t,e,i]){const s=ng(n),{values:o,keys:c}=this.ht(t,e,i);if(!Array.isArray(s))return this.dt=c,o;const d=this.dt??(this.dt=[]),f=[];let p,g,v=0,b=s.length-1,E=0,T=o.length-1;for(;v<=b&&E<=T;)if(s[v]===null)v++;else if(s[b]===null)b--;else if(d[v]===c[E])f[E]=Zs(s[v],o[E]),v++,E++;else if(d[b]===c[T])f[T]=Zs(s[b],o[T]),b--,T--;else if(d[v]===c[T])f[T]=Zs(s[v],o[T]),sa(n,f[T+1],s[v]),v++,T--;else if(d[b]===c[E])f[E]=Zs(s[b],o[E]),sa(n,s[v],s[b]),b--,E++;else if(p===void 0&&(p=ou(c,E,T),g=ou(d,v,b)),p.has(d[v]))if(p.has(d[b])){const w=g.get(c[E]),_=w!==void 0?s[w]:null;if(_===null){const D=sa(n,s[v]);Zs(D,o[E]),f[E]=D}else f[E]=Zs(_,o[E]),sa(n,s[v],_),s[w]=null;E++}else kl(s[b]),b--;else kl(s[v]),v++;for(;E<=T;){const w=sa(n,f[T+1]);Zs(w,o[E]),f[E++]=w}for(;v<=b;){const w=s[v++];w!==null&&kl(w)}return this.dt=c,sg(n,f),fs}});var Gi="top",ar="bottom",or="right",Hi="left",jl="auto",ga=[Gi,ar,or,Hi],En="start",ma="end",Sm="clippingParents",cu="viewport",va="popper",Rm="reference",hu=ga.reduce(function(n,t){return n.concat([t+"-"+En,t+"-"+ma])},[]),du=[].concat(ga,[jl]).reduce(function(n,t){return n.concat([t,t+"-"+En,t+"-"+ma])},[]),_m="beforeRead",Lm="read",Cm="afterRead",Im="beforeMain",xm="main",Dm="afterMain",Pm="beforeWrite",Om="write",Mm="afterWrite",$m=[_m,Lm,Cm,Im,xm,Dm,Pm,Om,Mm];function Ir(n){return n?(n.nodeName||"").toLowerCase():null}function er(n){if(n==null)return window;if(n.toString()!=="[object Window]"){var t=n.ownerDocument;return t&&t.defaultView||window}return n}function en(n){var t=er(n).Element;return n instanceof t||n instanceof Element}function lr(n){var t=er(n).HTMLElement;return n instanceof t||n instanceof HTMLElement}function Kl(n){if(typeof ShadowRoot>"u")return!1;var t=er(n).ShadowRoot;return n instanceof t||n instanceof ShadowRoot}function Nm(n){var t=n.state;Object.keys(t.elements).forEach(function(e){var i=t.styles[e]||{},s=t.attributes[e]||{},o=t.elements[e];!lr(o)||!Ir(o)||(Object.assign(o.style,i),Object.keys(s).forEach(function(c){var d=s[c];d===!1?o.removeAttribute(c):o.setAttribute(c,d===!0?"":d)}))})}function Fm(n){var t=n.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],o=t.attributes[i]||{},c=Object.keys(t.styles.hasOwnProperty(i)?t.styles[i]:e[i]),d=c.reduce(function(f,p){return f[p]="",f},{});!lr(s)||!Ir(s)||(Object.assign(s.style,d),Object.keys(o).forEach(function(f){s.removeAttribute(f)}))})}}const uu={name:"applyStyles",enabled:!0,phase:"write",fn:Nm,effect:Fm,requires:["computeStyles"]};function xr(n){return n.split("-")[0]}var rn=Math.max,fo=Math.min,Tn=Math.round;function Yl(){var n=navigator.userAgentData;return n!=null&&n.brands&&Array.isArray(n.brands)?n.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function fu(){return!/^((?!chrome|android).)*safari/i.test(Yl())}function kn(n,t,e){t===void 0&&(t=!1),e===void 0&&(e=!1);var i=n.getBoundingClientRect(),s=1,o=1;t&&lr(n)&&(s=n.offsetWidth>0&&Tn(i.width)/n.offsetWidth||1,o=n.offsetHeight>0&&Tn(i.height)/n.offsetHeight||1);var c=en(n)?er(n):window,d=c.visualViewport,f=!fu()&&e,p=(i.left+(f&&d?d.offsetLeft:0))/s,g=(i.top+(f&&d?d.offsetTop:0))/o,v=i.width/s,b=i.height/o;return{width:v,height:b,top:g,right:p+v,bottom:g+b,left:p,x:p,y:g}}function zl(n){var t=kn(n),e=n.offsetWidth,i=n.offsetHeight;return Math.abs(t.width-e)<=1&&(e=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:n.offsetLeft,y:n.offsetTop,width:e,height:i}}function pu(n,t){var e=t.getRootNode&&t.getRootNode();if(n.contains(t))return!0;if(e&&Kl(e)){var i=t;do{if(i&&n.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function qr(n){return er(n).getComputedStyle(n)}function Um(n){return["table","td","th"].indexOf(Ir(n))>=0}function As(n){return((en(n)?n.ownerDocument:n.document)||window.document).documentElement}function po(n){return Ir(n)==="html"?n:n.assignedSlot||n.parentNode||(Kl(n)?n.host:null)||As(n)}function gu(n){return!lr(n)||qr(n).position==="fixed"?null:n.offsetParent}function Bm(n){var t=/firefox/i.test(Yl()),e=/Trident/i.test(Yl());if(e&&lr(n)){var i=qr(n);if(i.position==="fixed")return null}var s=po(n);for(Kl(s)&&(s=s.host);lr(s)&&["html","body"].indexOf(Ir(s))<0;){var o=qr(s);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||t&&o.willChange==="filter"||t&&o.filter&&o.filter!=="none")return s;s=s.parentNode}return null}function ya(n){for(var t=er(n),e=gu(n);e&&Um(e)&&qr(e).position==="static";)e=gu(e);return e&&(Ir(e)==="html"||Ir(e)==="body"&&qr(e).position==="static")?t:e||Bm(n)||t}function Xl(n){return["top","bottom"].indexOf(n)>=0?"x":"y"}function ba(n,t,e){return rn(n,fo(t,e))}function Gm(n,t,e){var i=ba(n,t,e);return i>e?e:i}function mu(){return{top:0,right:0,bottom:0,left:0}}function vu(n){return Object.assign({},mu(),n)}function yu(n,t){return t.reduce(function(e,i){return e[i]=n,e},{})}var Hm=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,vu(typeof t!="number"?t:yu(t,ga))};function Vm(n){var t,e=n.state,i=n.name,s=n.options,o=e.elements.arrow,c=e.modifiersData.popperOffsets,d=xr(e.placement),f=Xl(d),p=[Hi,or].indexOf(d)>=0,g=p?"height":"width";if(!(!o||!c)){var v=Hm(s.padding,e),b=zl(o),E=f==="y"?Gi:Hi,T=f==="y"?ar:or,w=e.rects.reference[g]+e.rects.reference[f]-c[f]-e.rects.popper[g],_=c[f]-e.rects.reference[f],D=ya(o),M=D?f==="y"?D.clientHeight||0:D.clientWidth||0:0,F=w/2-_/2,x=v[E],N=M-b[g]-v[T],V=M/2-b[g]/2+F,j=ba(x,V,N),rt=f;e.modifiersData[i]=(t={},t[rt]=j,t.centerOffset=j-V,t)}}function Wm(n){var t=n.state,e=n.options,i=e.element,s=i===void 0?"[data-popper-arrow]":i;s!=null&&(typeof s=="string"&&(s=t.elements.popper.querySelector(s),!s)||pu(t.elements.popper,s)&&(t.elements.arrow=s))}const jm={name:"arrow",enabled:!0,phase:"main",fn:Vm,effect:Wm,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function wn(n){return n.split("-")[1]}var Km={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Ym(n,t){var e=n.x,i=n.y,s=t.devicePixelRatio||1;return{x:Tn(e*s)/s||0,y:Tn(i*s)/s||0}}function bu(n){var t,e=n.popper,i=n.popperRect,s=n.placement,o=n.variation,c=n.offsets,d=n.position,f=n.gpuAcceleration,p=n.adaptive,g=n.roundOffsets,v=n.isFixed,b=c.x,E=b===void 0?0:b,T=c.y,w=T===void 0?0:T,_=typeof g=="function"?g({x:E,y:w}):{x:E,y:w};E=_.x,w=_.y;var D=c.hasOwnProperty("x"),M=c.hasOwnProperty("y"),F=Hi,x=Gi,N=window;if(p){var V=ya(e),j="clientHeight",rt="clientWidth";if(V===er(e)&&(V=As(e),qr(V).position!=="static"&&d==="absolute"&&(j="scrollHeight",rt="scrollWidth")),V=V,s===Gi||(s===Hi||s===or)&&o===ma){x=ar;var nt=v&&V===N&&N.visualViewport?N.visualViewport.height:V[j];w-=nt-i.height,w*=f?1:-1}if(s===Hi||(s===Gi||s===ar)&&o===ma){F=or;var Q=v&&V===N&&N.visualViewport?N.visualViewport.width:V[rt];E-=Q-i.width,E*=f?1:-1}}var Tt=Object.assign({position:d},p&&Km),gt=g===!0?Ym({x:E,y:w},er(e)):{x:E,y:w};if(E=gt.x,w=gt.y,f){var $t;return Object.assign({},Tt,($t={},$t[x]=M?"0":"",$t[F]=D?"0":"",$t.transform=(N.devicePixelRatio||1)<=1?"translate("+E+"px, "+w+"px)":"translate3d("+E+"px, "+w+"px, 0)",$t))}return Object.assign({},Tt,(t={},t[x]=M?w+"px":"",t[F]=D?E+"px":"",t.transform="",t))}function zm(n){var t=n.state,e=n.options,i=e.gpuAcceleration,s=i===void 0?!0:i,o=e.adaptive,c=o===void 0?!0:o,d=e.roundOffsets,f=d===void 0?!0:d,p={placement:xr(t.placement),variation:wn(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,bu(Object.assign({},p,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:c,roundOffsets:f})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,bu(Object.assign({},p,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:f})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const Xm={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:zm,data:{}};var go={passive:!0};function Zm(n){var t=n.state,e=n.instance,i=n.options,s=i.scroll,o=s===void 0?!0:s,c=i.resize,d=c===void 0?!0:c,f=er(t.elements.popper),p=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&p.forEach(function(g){g.addEventListener("scroll",e.update,go)}),d&&f.addEventListener("resize",e.update,go),function(){o&&p.forEach(function(g){g.removeEventListener("scroll",e.update,go)}),d&&f.removeEventListener("resize",e.update,go)}}const qm={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Zm,data:{}};var Qm={left:"right",right:"left",bottom:"top",top:"bottom"};function mo(n){return n.replace(/left|right|bottom|top/g,function(t){return Qm[t]})}var Jm={start:"end",end:"start"};function Au(n){return n.replace(/start|end/g,function(t){return Jm[t]})}function Zl(n){var t=er(n),e=t.pageXOffset,i=t.pageYOffset;return{scrollLeft:e,scrollTop:i}}function ql(n){return kn(As(n)).left+Zl(n).scrollLeft}function t1(n,t){var e=er(n),i=As(n),s=e.visualViewport,o=i.clientWidth,c=i.clientHeight,d=0,f=0;if(s){o=s.width,c=s.height;var p=fu();(p||!p&&t==="fixed")&&(d=s.offsetLeft,f=s.offsetTop)}return{width:o,height:c,x:d+ql(n),y:f}}function e1(n){var t,e=As(n),i=Zl(n),s=(t=n.ownerDocument)==null?void 0:t.body,o=rn(e.scrollWidth,e.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),c=rn(e.scrollHeight,e.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),d=-i.scrollLeft+ql(n),f=-i.scrollTop;return qr(s||e).direction==="rtl"&&(d+=rn(e.clientWidth,s?s.clientWidth:0)-o),{width:o,height:c,x:d,y:f}}function Ql(n){var t=qr(n),e=t.overflow,i=t.overflowX,s=t.overflowY;return/auto|scroll|overlay|hidden/.test(e+s+i)}function Eu(n){return["html","body","#document"].indexOf(Ir(n))>=0?n.ownerDocument.body:lr(n)&&Ql(n)?n:Eu(po(n))}function Aa(n,t){var e;t===void 0&&(t=[]);var i=Eu(n),s=i===((e=n.ownerDocument)==null?void 0:e.body),o=er(i),c=s?[o].concat(o.visualViewport||[],Ql(i)?i:[]):i,d=t.concat(c);return s?d:d.concat(Aa(po(c)))}function Jl(n){return Object.assign({},n,{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height})}function i1(n,t){var e=kn(n,!1,t==="fixed");return e.top=e.top+n.clientTop,e.left=e.left+n.clientLeft,e.bottom=e.top+n.clientHeight,e.right=e.left+n.clientWidth,e.width=n.clientWidth,e.height=n.clientHeight,e.x=e.left,e.y=e.top,e}function Tu(n,t,e){return t===cu?Jl(t1(n,e)):en(t)?i1(t,e):Jl(e1(As(n)))}function r1(n){var t=Aa(po(n)),e=["absolute","fixed"].indexOf(qr(n).position)>=0,i=e&&lr(n)?ya(n):n;return en(i)?t.filter(function(s){return en(s)&&pu(s,i)&&Ir(s)!=="body"}):[]}function s1(n,t,e,i){var s=t==="clippingParents"?r1(n):[].concat(t),o=[].concat(s,[e]),c=o[0],d=o.reduce(function(f,p){var g=Tu(n,p,i);return f.top=rn(g.top,f.top),f.right=fo(g.right,f.right),f.bottom=fo(g.bottom,f.bottom),f.left=rn(g.left,f.left),f},Tu(n,c,i));return d.width=d.right-d.left,d.height=d.bottom-d.top,d.x=d.left,d.y=d.top,d}function ku(n){var t=n.reference,e=n.element,i=n.placement,s=i?xr(i):null,o=i?wn(i):null,c=t.x+t.width/2-e.width/2,d=t.y+t.height/2-e.height/2,f;switch(s){case Gi:f={x:c,y:t.y-e.height};break;case ar:f={x:c,y:t.y+t.height};break;case or:f={x:t.x+t.width,y:d};break;case Hi:f={x:t.x-e.width,y:d};break;default:f={x:t.x,y:t.y}}var p=s?Xl(s):null;if(p!=null){var g=p==="y"?"height":"width";switch(o){case En:f[p]=f[p]-(t[g]/2-e[g]/2);break;case ma:f[p]=f[p]+(t[g]/2-e[g]/2);break}}return f}function Ea(n,t){t===void 0&&(t={});var e=t,i=e.placement,s=i===void 0?n.placement:i,o=e.strategy,c=o===void 0?n.strategy:o,d=e.boundary,f=d===void 0?Sm:d,p=e.rootBoundary,g=p===void 0?cu:p,v=e.elementContext,b=v===void 0?va:v,E=e.altBoundary,T=E===void 0?!1:E,w=e.padding,_=w===void 0?0:w,D=vu(typeof _!="number"?_:yu(_,ga)),M=b===va?Rm:va,F=n.rects.popper,x=n.elements[T?M:b],N=s1(en(x)?x:x.contextElement||As(n.elements.popper),f,g,c),V=kn(n.elements.reference),j=ku({reference:V,element:F,strategy:"absolute",placement:s}),rt=Jl(Object.assign({},F,j)),nt=b===va?rt:V,Q={top:N.top-nt.top+D.top,bottom:nt.bottom-N.bottom+D.bottom,left:N.left-nt.left+D.left,right:nt.right-N.right+D.right},Tt=n.modifiersData.offset;if(b===va&&Tt){var gt=Tt[s];Object.keys(Q).forEach(function($t){var Wt=[or,ar].indexOf($t)>=0?1:-1,H=[Gi,ar].indexOf($t)>=0?"y":"x";Q[$t]+=gt[H]*Wt})}return Q}function n1(n,t){t===void 0&&(t={});var e=t,i=e.placement,s=e.boundary,o=e.rootBoundary,c=e.padding,d=e.flipVariations,f=e.allowedAutoPlacements,p=f===void 0?du:f,g=wn(i),v=g?d?hu:hu.filter(function(T){return wn(T)===g}):ga,b=v.filter(function(T){return p.indexOf(T)>=0});b.length===0&&(b=v);var E=b.reduce(function(T,w){return T[w]=Ea(n,{placement:w,boundary:s,rootBoundary:o,padding:c})[xr(w)],T},{});return Object.keys(E).sort(function(T,w){return E[T]-E[w]})}function a1(n){if(xr(n)===jl)return[];var t=mo(n);return[Au(n),t,Au(t)]}function o1(n){var t=n.state,e=n.options,i=n.name;if(!t.modifiersData[i]._skip){for(var s=e.mainAxis,o=s===void 0?!0:s,c=e.altAxis,d=c===void 0?!0:c,f=e.fallbackPlacements,p=e.padding,g=e.boundary,v=e.rootBoundary,b=e.altBoundary,E=e.flipVariations,T=E===void 0?!0:E,w=e.allowedAutoPlacements,_=t.options.placement,D=xr(_),M=D===_,F=f||(M||!T?[mo(_)]:a1(_)),x=[_].concat(F).reduce(function(Ut,Qt){return Ut.concat(xr(Qt)===jl?n1(t,{placement:Qt,boundary:g,rootBoundary:v,padding:p,flipVariations:T,allowedAutoPlacements:w}):Qt)},[]),N=t.rects.reference,V=t.rects.popper,j=new Map,rt=!0,nt=x[0],Q=0;Q<x.length;Q++){var Tt=x[Q],gt=xr(Tt),$t=wn(Tt)===En,Wt=[Gi,ar].indexOf(gt)>=0,H=Wt?"width":"height",J=Ea(t,{placement:Tt,boundary:g,rootBoundary:v,altBoundary:b,padding:p}),St=Wt?$t?or:Hi:$t?ar:Gi;N[H]>V[H]&&(St=mo(St));var $=mo(St),U=[];if(o&&U.push(J[gt]<=0),d&&U.push(J[St]<=0,J[$]<=0),U.every(function(Ut){return Ut})){nt=Tt,rt=!1;break}j.set(Tt,U)}if(rt)for(var X=T?3:1,mt=function(Qt){var ue=x.find(function(se){var zt=j.get(se);if(zt)return zt.slice(0,Qt).every(function(Oe){return Oe})});if(ue)return nt=ue,"break"},bt=X;bt>0;bt--){var xt=mt(bt);if(xt==="break")break}t.placement!==nt&&(t.modifiersData[i]._skip=!0,t.placement=nt,t.reset=!0)}}const l1={name:"flip",enabled:!0,phase:"main",fn:o1,requiresIfExists:["offset"],data:{_skip:!1}};function wu(n,t,e){return e===void 0&&(e={x:0,y:0}),{top:n.top-t.height-e.y,right:n.right-t.width+e.x,bottom:n.bottom-t.height+e.y,left:n.left-t.width-e.x}}function Su(n){return[Gi,or,ar,Hi].some(function(t){return n[t]>=0})}function c1(n){var t=n.state,e=n.name,i=t.rects.reference,s=t.rects.popper,o=t.modifiersData.preventOverflow,c=Ea(t,{elementContext:"reference"}),d=Ea(t,{altBoundary:!0}),f=wu(c,i),p=wu(d,s,o),g=Su(f),v=Su(p);t.modifiersData[e]={referenceClippingOffsets:f,popperEscapeOffsets:p,isReferenceHidden:g,hasPopperEscaped:v},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":g,"data-popper-escaped":v})}const h1={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:c1};function d1(n,t,e){var i=xr(n),s=[Hi,Gi].indexOf(i)>=0?-1:1,o=typeof e=="function"?e(Object.assign({},t,{placement:n})):e,c=o[0],d=o[1];return c=c||0,d=(d||0)*s,[Hi,or].indexOf(i)>=0?{x:d,y:c}:{x:c,y:d}}function u1(n){var t=n.state,e=n.options,i=n.name,s=e.offset,o=s===void 0?[0,0]:s,c=du.reduce(function(g,v){return g[v]=d1(v,t.rects,o),g},{}),d=c[t.placement],f=d.x,p=d.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=f,t.modifiersData.popperOffsets.y+=p),t.modifiersData[i]=c}const f1={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:u1};function p1(n){var t=n.state,e=n.name;t.modifiersData[e]=ku({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const g1={name:"popperOffsets",enabled:!0,phase:"read",fn:p1,data:{}};function m1(n){return n==="x"?"y":"x"}function v1(n){var t=n.state,e=n.options,i=n.name,s=e.mainAxis,o=s===void 0?!0:s,c=e.altAxis,d=c===void 0?!1:c,f=e.boundary,p=e.rootBoundary,g=e.altBoundary,v=e.padding,b=e.tether,E=b===void 0?!0:b,T=e.tetherOffset,w=T===void 0?0:T,_=Ea(t,{boundary:f,rootBoundary:p,padding:v,altBoundary:g}),D=xr(t.placement),M=wn(t.placement),F=!M,x=Xl(D),N=m1(x),V=t.modifiersData.popperOffsets,j=t.rects.reference,rt=t.rects.popper,nt=typeof w=="function"?w(Object.assign({},t.rects,{placement:t.placement})):w,Q=typeof nt=="number"?{mainAxis:nt,altAxis:nt}:Object.assign({mainAxis:0,altAxis:0},nt),Tt=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,gt={x:0,y:0};if(V){if(o){var $t,Wt=x==="y"?Gi:Hi,H=x==="y"?ar:or,J=x==="y"?"height":"width",St=V[x],$=St+_[Wt],U=St-_[H],X=E?-rt[J]/2:0,mt=M===En?j[J]:rt[J],bt=M===En?-rt[J]:-j[J],xt=t.elements.arrow,Ut=E&&xt?zl(xt):{width:0,height:0},Qt=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:mu(),ue=Qt[Wt],se=Qt[H],zt=ba(0,j[J],Ut[J]),Oe=F?j[J]/2-X-zt-ue-Q.mainAxis:mt-zt-ue-Q.mainAxis,be=F?-j[J]/2+X+zt+se+Q.mainAxis:bt+zt+se+Q.mainAxis,jt=t.elements.arrow&&ya(t.elements.arrow),ge=jt?x==="y"?jt.clientTop||0:jt.clientLeft||0:0,oe=($t=Tt==null?void 0:Tt[x])!=null?$t:0,Ce=St+Oe-oe-ge,Ft=St+be-oe,Xe=ba(E?fo($,Ce):$,St,E?rn(U,Ft):U);V[x]=Xe,gt[x]=Xe-St}if(d){var qe,Mi=x==="x"?Gi:Hi,Tr=x==="x"?ar:or,ke=V[N],li=N==="y"?"height":"width",me=ke+_[Mi],Je=ke-_[Tr],ti=[Gi,Hi].indexOf(D)!==-1,Xi=(qe=Tt==null?void 0:Tt[N])!=null?qe:0,$e=ti?me:ke-j[li]-rt[li]-Xi+Q.altAxis,Ci=ti?ke+j[li]+rt[li]-Xi-Q.altAxis:Je,ss=E&&ti?Gm($e,ke,Ci):ba(E?$e:me,ke,E?Ci:Je);V[N]=ss,gt[N]=ss-ke}t.modifiersData[i]=gt}}const y1={name:"preventOverflow",enabled:!0,phase:"main",fn:v1,requiresIfExists:["offset"]};function b1(n){return{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}}function A1(n){return n===er(n)||!lr(n)?Zl(n):b1(n)}function E1(n){var t=n.getBoundingClientRect(),e=Tn(t.width)/n.offsetWidth||1,i=Tn(t.height)/n.offsetHeight||1;return e!==1||i!==1}function T1(n,t,e){e===void 0&&(e=!1);var i=lr(t),s=lr(t)&&E1(t),o=As(t),c=kn(n,s,e),d={scrollLeft:0,scrollTop:0},f={x:0,y:0};return(i||!i&&!e)&&((Ir(t)!=="body"||Ql(o))&&(d=A1(t)),lr(t)?(f=kn(t,!0),f.x+=t.clientLeft,f.y+=t.clientTop):o&&(f.x=ql(o))),{x:c.left+d.scrollLeft-f.x,y:c.top+d.scrollTop-f.y,width:c.width,height:c.height}}function k1(n){var t=new Map,e=new Set,i=[];n.forEach(function(o){t.set(o.name,o)});function s(o){e.add(o.name);var c=[].concat(o.requires||[],o.requiresIfExists||[]);c.forEach(function(d){if(!e.has(d)){var f=t.get(d);f&&s(f)}}),i.push(o)}return n.forEach(function(o){e.has(o.name)||s(o)}),i}function w1(n){var t=k1(n);return $m.reduce(function(e,i){return e.concat(t.filter(function(s){return s.phase===i}))},[])}function S1(n){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(n())})})),t}}function R1(n){var t=n.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 Ru={placement:"bottom",modifiers:[],strategy:"absolute"};function _u(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];return!t.some(function(i){return!(i&&typeof i.getBoundingClientRect=="function")})}function _1(n){n===void 0&&(n={});var t=n,e=t.defaultModifiers,i=e===void 0?[]:e,s=t.defaultOptions,o=s===void 0?Ru:s;return function(d,f,p){p===void 0&&(p=o);var g={placement:"bottom",orderedModifiers:[],options:Object.assign({},Ru,o),modifiersData:{},elements:{reference:d,popper:f},attributes:{},styles:{}},v=[],b=!1,E={state:g,setOptions:function(D){var M=typeof D=="function"?D(g.options):D;w(),g.options=Object.assign({},o,g.options,M),g.scrollParents={reference:en(d)?Aa(d):d.contextElement?Aa(d.contextElement):[],popper:Aa(f)};var F=w1(R1([].concat(i,g.options.modifiers)));return g.orderedModifiers=F.filter(function(x){return x.enabled}),T(),E.update()},forceUpdate:function(){if(!b){var D=g.elements,M=D.reference,F=D.popper;if(_u(M,F)){g.rects={reference:T1(M,ya(F),g.options.strategy==="fixed"),popper:zl(F)},g.reset=!1,g.placement=g.options.placement,g.orderedModifiers.forEach(function(Q){return g.modifiersData[Q.name]=Object.assign({},Q.data)});for(var x=0;x<g.orderedModifiers.length;x++){if(g.reset===!0){g.reset=!1,x=-1;continue}var N=g.orderedModifiers[x],V=N.fn,j=N.options,rt=j===void 0?{}:j,nt=N.name;typeof V=="function"&&(g=V({state:g,options:rt,name:nt,instance:E})||g)}}}},update:S1(function(){return new Promise(function(_){E.forceUpdate(),_(g)})}),destroy:function(){w(),b=!0}};if(!_u(d,f))return E;E.setOptions(p).then(function(_){!b&&p.onFirstUpdate&&p.onFirstUpdate(_)});function T(){g.orderedModifiers.forEach(function(_){var D=_.name,M=_.options,F=M===void 0?{}:M,x=_.effect;if(typeof x=="function"){var N=x({state:g,name:D,instance:E,options:F}),V=function(){};v.push(N||V)}})}function w(){v.forEach(function(_){return _()}),v=[]}return E}}var L1=[qm,g1,Xm,uu,f1,l1,y1,jm,h1],C1=_1({defaultModifiers:L1}),I1="tippy-box",Lu="tippy-content",x1="tippy-backdrop",Cu="tippy-arrow",Iu="tippy-svg-arrow",sn={passive:!0,capture:!0},xu=function(){return document.body};function tc(n,t,e){if(Array.isArray(n)){var i=n[t];return i??(Array.isArray(e)?e[t]:e)}return n}function ec(n,t){var e={}.toString.call(n);return e.indexOf("[object")===0&&e.indexOf(t+"]")>-1}function Du(n,t){return typeof n=="function"?n.apply(void 0,t):n}function Pu(n,t){if(t===0)return n;var e;return function(i){clearTimeout(e),e=setTimeout(function(){n(i)},t)}}function D1(n){return n.split(/\s+/).filter(Boolean)}function Sn(n){return[].concat(n)}function Ou(n,t){n.indexOf(t)===-1&&n.push(t)}function P1(n){return n.filter(function(t,e){return n.indexOf(t)===e})}function O1(n){return n.split("-")[0]}function vo(n){return[].slice.call(n)}function Mu(n){return Object.keys(n).reduce(function(t,e){return n[e]!==void 0&&(t[e]=n[e]),t},{})}function Ta(){return document.createElement("div")}function yo(n){return["Element","Fragment"].some(function(t){return ec(n,t)})}function M1(n){return ec(n,"NodeList")}function $1(n){return ec(n,"MouseEvent")}function N1(n){return!!(n&&n._tippy&&n._tippy.reference===n)}function F1(n){return yo(n)?[n]:M1(n)?vo(n):Array.isArray(n)?n:vo(document.querySelectorAll(n))}function ic(n,t){n.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function $u(n,t){n.forEach(function(e){e&&e.setAttribute("data-state",t)})}function U1(n){var t,e=Sn(n),i=e[0];return i!=null&&(t=i.ownerDocument)!=null&&t.body?i.ownerDocument:document}function B1(n,t){var e=t.clientX,i=t.clientY;return n.every(function(s){var o=s.popperRect,c=s.popperState,d=s.props,f=d.interactiveBorder,p=O1(c.placement),g=c.modifiersData.offset;if(!g)return!0;var v=p==="bottom"?g.top.y:0,b=p==="top"?g.bottom.y:0,E=p==="right"?g.left.x:0,T=p==="left"?g.right.x:0,w=o.top-i+v>f,_=i-o.bottom-b>f,D=o.left-e+E>f,M=e-o.right-T>f;return w||_||D||M})}function rc(n,t,e){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(s){n[i](s,e)})}function Nu(n,t){for(var e=t;e;){var i;if(n.contains(e))return!0;e=e.getRootNode==null||(i=e.getRootNode())==null?void 0:i.host}return!1}var Dr={isTouch:!1},Fu=0;function G1(){Dr.isTouch||(Dr.isTouch=!0,window.performance&&document.addEventListener("mousemove",Uu))}function Uu(){var n=performance.now();n-Fu<20&&(Dr.isTouch=!1,document.removeEventListener("mousemove",Uu)),Fu=n}function H1(){var n=document.activeElement;if(N1(n)){var t=n._tippy;n.blur&&!t.state.isVisible&&n.blur()}}function V1(){document.addEventListener("touchstart",G1,sn),window.addEventListener("blur",H1)}var W1=typeof window<"u"&&typeof document<"u",j1=W1?!!window.msCrypto:!1,K1={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},Y1={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},yr=Object.assign({appendTo:xu,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},K1,Y1),z1=Object.keys(yr),X1=function(t){var e=Object.keys(t);e.forEach(function(i){yr[i]=t[i]})};function Bu(n){var t=n.plugins||[],e=t.reduce(function(i,s){var o=s.name,c=s.defaultValue;if(o){var d;i[o]=n[o]!==void 0?n[o]:(d=yr[o])!=null?d:c}return i},{});return Object.assign({},n,e)}function Z1(n,t){var e=t?Object.keys(Bu(Object.assign({},yr,{plugins:t}))):z1,i=e.reduce(function(s,o){var c=(n.getAttribute("data-tippy-"+o)||"").trim();if(!c)return s;if(o==="content")s[o]=c;else try{s[o]=JSON.parse(c)}catch{s[o]=c}return s},{});return i}function Gu(n,t){var e=Object.assign({},t,{content:Du(t.content,[n])},t.ignoreAttributes?{}:Z1(n,t.plugins));return e.aria=Object.assign({},yr.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 q1=function(){return"innerHTML"};function sc(n,t){n[q1()]=t}function Hu(n){var t=Ta();return n===!0?t.className=Cu:(t.className=Iu,yo(n)?t.appendChild(n):sc(t,n)),t}function Vu(n,t){yo(t.content)?(sc(n,""),n.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?sc(n,t.content):n.textContent=t.content)}function nc(n){var t=n.firstElementChild,e=vo(t.children);return{box:t,content:e.find(function(i){return i.classList.contains(Lu)}),arrow:e.find(function(i){return i.classList.contains(Cu)||i.classList.contains(Iu)}),backdrop:e.find(function(i){return i.classList.contains(x1)})}}function Wu(n){var t=Ta(),e=Ta();e.className=I1,e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var i=Ta();i.className=Lu,i.setAttribute("data-state","hidden"),Vu(i,n.props),t.appendChild(e),e.appendChild(i),s(n.props,n.props);function s(o,c){var d=nc(t),f=d.box,p=d.content,g=d.arrow;c.theme?f.setAttribute("data-theme",c.theme):f.removeAttribute("data-theme"),typeof c.animation=="string"?f.setAttribute("data-animation",c.animation):f.removeAttribute("data-animation"),c.inertia?f.setAttribute("data-inertia",""):f.removeAttribute("data-inertia"),f.style.maxWidth=typeof c.maxWidth=="number"?c.maxWidth+"px":c.maxWidth,c.role?f.setAttribute("role",c.role):f.removeAttribute("role"),(o.content!==c.content||o.allowHTML!==c.allowHTML)&&Vu(p,n.props),c.arrow?g?o.arrow!==c.arrow&&(f.removeChild(g),f.appendChild(Hu(c.arrow))):f.appendChild(Hu(c.arrow)):g&&f.removeChild(g)}return{popper:t,onUpdate:s}}Wu.$$tippy=!0;var Q1=1,bo=[],ac=[];function J1(n,t){var e=Gu(n,Object.assign({},yr,Bu(Mu(t)))),i,s,o,c=!1,d=!1,f=!1,p=!1,g,v,b,E=[],T=Pu(Ce,e.interactiveDebounce),w,_=Q1++,D=null,M=P1(e.plugins),F={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},x={id:_,reference:n,popper:Ta(),popperInstance:D,props:e,state:F,plugins:M,clearDelayTimeouts:$e,setProps:Ci,setContent:ss,show:ci,hide:kr,hideWithInteractivity:_s,enable:ti,disable:Xi,unmount:Ls,destroy:ir};if(!e.render)return x;var N=e.render(x),V=N.popper,j=N.onUpdate;V.setAttribute("data-tippy-root",""),V.id="tippy-"+x.id,x.popper=V,n._tippy=x,V._tippy=x;var rt=M.map(function(ct){return ct.fn(x)}),nt=n.hasAttribute("aria-expanded");return jt(),X(),St(),$("onCreate",[x]),e.showOnCreate&&me(),V.addEventListener("mouseenter",function(){x.props.interactive&&x.state.isVisible&&x.clearDelayTimeouts()}),V.addEventListener("mouseleave",function(){x.props.interactive&&x.props.trigger.indexOf("mouseenter")>=0&&Wt().addEventListener("mousemove",T)}),x;function Q(){var ct=x.props.touch;return Array.isArray(ct)?ct:[ct,0]}function Tt(){return Q()[0]==="hold"}function gt(){var ct;return!!((ct=x.props.render)!=null&&ct.$$tippy)}function $t(){return w||n}function Wt(){var ct=$t().parentNode;return ct?U1(ct):document}function H(){return nc(V)}function J(ct){return x.state.isMounted&&!x.state.isVisible||Dr.isTouch||g&&g.type==="focus"?0:tc(x.props.delay,ct?0:1,yr.delay)}function St(ct){ct===void 0&&(ct=!1),V.style.pointerEvents=x.props.interactive&&!ct?"":"none",V.style.zIndex=""+x.props.zIndex}function $(ct,Gt,Xt){if(Xt===void 0&&(Xt=!0),rt.forEach(function(ae){ae[ct]&&ae[ct].apply(ae,Gt)}),Xt){var ve;(ve=x.props)[ct].apply(ve,Gt)}}function U(){var ct=x.props.aria;if(ct.content){var Gt="aria-"+ct.content,Xt=V.id,ve=Sn(x.props.triggerTarget||n);ve.forEach(function(ae){var ni=ae.getAttribute(Gt);if(x.state.isVisible)ae.setAttribute(Gt,ni?ni+" "+Xt:Xt);else{var Ii=ni&&ni.replace(Xt,"").trim();Ii?ae.setAttribute(Gt,Ii):ae.removeAttribute(Gt)}})}}function X(){if(!(nt||!x.props.aria.expanded)){var ct=Sn(x.props.triggerTarget||n);ct.forEach(function(Gt){x.props.interactive?Gt.setAttribute("aria-expanded",x.state.isVisible&&Gt===$t()?"true":"false"):Gt.removeAttribute("aria-expanded")})}}function mt(){Wt().removeEventListener("mousemove",T),bo=bo.filter(function(ct){return ct!==T})}function bt(ct){if(!(Dr.isTouch&&(f||ct.type==="mousedown"))){var Gt=ct.composedPath&&ct.composedPath()[0]||ct.target;if(!(x.props.interactive&&Nu(V,Gt))){if(Sn(x.props.triggerTarget||n).some(function(Xt){return Nu(Xt,Gt)})){if(Dr.isTouch||x.state.isVisible&&x.props.trigger.indexOf("click")>=0)return}else $("onClickOutside",[x,ct]);x.props.hideOnClick===!0&&(x.clearDelayTimeouts(),x.hide(),d=!0,setTimeout(function(){d=!1}),x.state.isMounted||ue())}}}function xt(){f=!0}function Ut(){f=!1}function Qt(){var ct=Wt();ct.addEventListener("mousedown",bt,!0),ct.addEventListener("touchend",bt,sn),ct.addEventListener("touchstart",Ut,sn),ct.addEventListener("touchmove",xt,sn)}function ue(){var ct=Wt();ct.removeEventListener("mousedown",bt,!0),ct.removeEventListener("touchend",bt,sn),ct.removeEventListener("touchstart",Ut,sn),ct.removeEventListener("touchmove",xt,sn)}function se(ct,Gt){Oe(ct,function(){!x.state.isVisible&&V.parentNode&&V.parentNode.contains(V)&&Gt()})}function zt(ct,Gt){Oe(ct,Gt)}function Oe(ct,Gt){var Xt=H().box;function ve(ae){ae.target===Xt&&(rc(Xt,"remove",ve),Gt())}if(ct===0)return Gt();rc(Xt,"remove",v),rc(Xt,"add",ve),v=ve}function be(ct,Gt,Xt){Xt===void 0&&(Xt=!1);var ve=Sn(x.props.triggerTarget||n);ve.forEach(function(ae){ae.addEventListener(ct,Gt,Xt),E.push({node:ae,eventType:ct,handler:Gt,options:Xt})})}function jt(){Tt()&&(be("touchstart",oe,{passive:!0}),be("touchend",Ft,{passive:!0})),D1(x.props.trigger).forEach(function(ct){if(ct!=="manual")switch(be(ct,oe),ct){case"mouseenter":be("mouseleave",Ft);break;case"focus":be(j1?"focusout":"blur",Xe);break;case"focusin":be("focusout",Xe);break}})}function ge(){E.forEach(function(ct){var Gt=ct.node,Xt=ct.eventType,ve=ct.handler,ae=ct.options;Gt.removeEventListener(Xt,ve,ae)}),E=[]}function oe(ct){var Gt,Xt=!1;if(!(!x.state.isEnabled||qe(ct)||d)){var ve=((Gt=g)==null?void 0:Gt.type)==="focus";g=ct,w=ct.currentTarget,X(),!x.state.isVisible&&$1(ct)&&bo.forEach(function(ae){return ae(ct)}),ct.type==="click"&&(x.props.trigger.indexOf("mouseenter")<0||c)&&x.props.hideOnClick!==!1&&x.state.isVisible?Xt=!0:me(ct),ct.type==="click"&&(c=!Xt),Xt&&!ve&&Je(ct)}}function Ce(ct){var Gt=ct.target,Xt=$t().contains(Gt)||V.contains(Gt);if(!(ct.type==="mousemove"&&Xt)){var ve=li().concat(V).map(function(ae){var ni,Ii=ae._tippy,ur=(ni=Ii.popperInstance)==null?void 0:ni.state;return ur?{popperRect:ae.getBoundingClientRect(),popperState:ur,props:e}:null}).filter(Boolean);B1(ve,ct)&&(mt(),Je(ct))}}function Ft(ct){var Gt=qe(ct)||x.props.trigger.indexOf("click")>=0&&c;if(!Gt){if(x.props.interactive){x.hideWithInteractivity(ct);return}Je(ct)}}function Xe(ct){x.props.trigger.indexOf("focusin")<0&&ct.target!==$t()||x.props.interactive&&ct.relatedTarget&&V.contains(ct.relatedTarget)||Je(ct)}function qe(ct){return Dr.isTouch?Tt()!==ct.type.indexOf("touch")>=0:!1}function Mi(){Tr();var ct=x.props,Gt=ct.popperOptions,Xt=ct.placement,ve=ct.offset,ae=ct.getReferenceClientRect,ni=ct.moveTransition,Ii=gt()?nc(V).arrow:null,ur=ae?{getBoundingClientRect:ae,contextElement:ae.contextElement||$t()}:n,ns={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Cs){var xi=Cs.state;if(gt()){var Oa=H(),gr=Oa.box;["placement","reference-hidden","escaped"].forEach(function(Is){Is==="placement"?gr.setAttribute("data-placement",xi.placement):xi.attributes.popper["data-popper-"+Is]?gr.setAttribute("data-"+Is,""):gr.removeAttribute("data-"+Is)}),xi.attributes.popper={}}}},fr=[{name:"offset",options:{offset:ve}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!ni}},ns];gt()&&Ii&&fr.push({name:"arrow",options:{element:Ii,padding:3}}),fr.push.apply(fr,(Gt==null?void 0:Gt.modifiers)||[]),x.popperInstance=C1(ur,V,Object.assign({},Gt,{placement:Xt,onFirstUpdate:b,modifiers:fr}))}function Tr(){x.popperInstance&&(x.popperInstance.destroy(),x.popperInstance=null)}function ke(){var ct=x.props.appendTo,Gt,Xt=$t();x.props.interactive&&ct===xu||ct==="parent"?Gt=Xt.parentNode:Gt=Du(ct,[Xt]),Gt.contains(V)||Gt.appendChild(V),x.state.isMounted=!0,Mi()}function li(){return vo(V.querySelectorAll("[data-tippy-root]"))}function me(ct){x.clearDelayTimeouts(),ct&&$("onTrigger",[x,ct]),Qt();var Gt=J(!0),Xt=Q(),ve=Xt[0],ae=Xt[1];Dr.isTouch&&ve==="hold"&&ae&&(Gt=ae),Gt?i=setTimeout(function(){x.show()},Gt):x.show()}function Je(ct){if(x.clearDelayTimeouts(),$("onUntrigger",[x,ct]),!x.state.isVisible){ue();return}if(!(x.props.trigger.indexOf("mouseenter")>=0&&x.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(ct.type)>=0&&c)){var Gt=J(!1);Gt?s=setTimeout(function(){x.state.isVisible&&x.hide()},Gt):o=requestAnimationFrame(function(){x.hide()})}}function ti(){x.state.isEnabled=!0}function Xi(){x.hide(),x.state.isEnabled=!1}function $e(){clearTimeout(i),clearTimeout(s),cancelAnimationFrame(o)}function Ci(ct){if(!x.state.isDestroyed){$("onBeforeUpdate",[x,ct]),ge();var Gt=x.props,Xt=Gu(n,Object.assign({},Gt,Mu(ct),{ignoreAttributes:!0}));x.props=Xt,jt(),Gt.interactiveDebounce!==Xt.interactiveDebounce&&(mt(),T=Pu(Ce,Xt.interactiveDebounce)),Gt.triggerTarget&&!Xt.triggerTarget?Sn(Gt.triggerTarget).forEach(function(ve){ve.removeAttribute("aria-expanded")}):Xt.triggerTarget&&n.removeAttribute("aria-expanded"),X(),St(),j&&j(Gt,Xt),x.popperInstance&&(Mi(),li().forEach(function(ve){requestAnimationFrame(ve._tippy.popperInstance.forceUpdate)})),$("onAfterUpdate",[x,ct])}}function ss(ct){x.setProps({content:ct})}function ci(){var ct=x.state.isVisible,Gt=x.state.isDestroyed,Xt=!x.state.isEnabled,ve=Dr.isTouch&&!x.props.touch,ae=tc(x.props.duration,0,yr.duration);if(!(ct||Gt||Xt||ve)&&!$t().hasAttribute("disabled")&&($("onShow",[x],!1),x.props.onShow(x)!==!1)){if(x.state.isVisible=!0,gt()&&(V.style.visibility="visible"),St(),Qt(),x.state.isMounted||(V.style.transition="none"),gt()){var ni=H(),Ii=ni.box,ur=ni.content;ic([Ii,ur],0)}b=function(){var fr;if(!(!x.state.isVisible||p)){if(p=!0,V.offsetHeight,V.style.transition=x.props.moveTransition,gt()&&x.props.animation){var pr=H(),Cs=pr.box,xi=pr.content;ic([Cs,xi],ae),$u([Cs,xi],"visible")}U(),X(),Ou(ac,x),(fr=x.popperInstance)==null||fr.forceUpdate(),$("onMount",[x]),x.props.animation&&gt()&&zt(ae,function(){x.state.isShown=!0,$("onShown",[x])})}},ke()}}function kr(){var ct=!x.state.isVisible,Gt=x.state.isDestroyed,Xt=!x.state.isEnabled,ve=tc(x.props.duration,1,yr.duration);if(!(ct||Gt||Xt)&&($("onHide",[x],!1),x.props.onHide(x)!==!1)){if(x.state.isVisible=!1,x.state.isShown=!1,p=!1,c=!1,gt()&&(V.style.visibility="hidden"),mt(),ue(),St(!0),gt()){var ae=H(),ni=ae.box,Ii=ae.content;x.props.animation&&(ic([ni,Ii],ve),$u([ni,Ii],"hidden"))}U(),X(),x.props.animation?gt()&&se(ve,x.unmount):x.unmount()}}function _s(ct){Wt().addEventListener("mousemove",T),Ou(bo,T),T(ct)}function Ls(){x.state.isVisible&&x.hide(),x.state.isMounted&&(Tr(),li().forEach(function(ct){ct._tippy.unmount()}),V.parentNode&&V.parentNode.removeChild(V),ac=ac.filter(function(ct){return ct!==x}),x.state.isMounted=!1,$("onHidden",[x]))}function ir(){x.state.isDestroyed||(x.clearDelayTimeouts(),x.unmount(),ge(),delete n._tippy,x.state.isDestroyed=!0,$("onDestroy",[x]))}}function nn(n,t){t===void 0&&(t={});var e=yr.plugins.concat(t.plugins||[]);V1();var i=Object.assign({},t,{plugins:e}),s=F1(n),o=s.reduce(function(c,d){var f=d&&J1(d,i);return f&&c.push(f),c},[]);return yo(n)?o[0]:o}nn.defaultProps=yr,nn.setDefaultProps=X1,nn.currentInput=Dr,Object.assign({},uu,{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)}}),nn.setDefaultProps({render:Wu});class Qr extends Error{constructor(t,e=!1){super(),this.fatal=!1,this.message=t,this.fatal=e}}const tv=5;class ev{constructor(t){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._canvas=wi(),this._controls=wi(),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,o,c;const d=Math.min(this.host.duration,Math.max(0,t));this._currentTime=d,this.activeScenes=((e=this.host.scenes)==null?void 0:e.filter(({start:g,duration:v})=>d>=g&&d<=g+v))??[],this._upcomingScenes=((i=this.host.scenes)==null?void 0:i.filter(({start:g})=>d>=g-tv&&d<g))??[],this.loadScenes(),this.syncVideoState(),(s=this._controls.value)==null||s.setAttribute("currentTime",d.toString());const f=this.activeScenes[0],p=Bd((o=f==null?void 0:f.videoMeta)==null?void 0:o.captions);this.caption=((c=p.find(({start:g,end:v})=>{var b;const E=d-f.start+(((b=f.videoMeta)==null?void 0:b.start)??0);return g&&v&&E>=eo(g)&&E<=eo(v)}))==null?void 0:c.text)??"",this.draw(d),!this.host.paused&&!this.host.loading&&!this.host.processing&&!this.host.waiting&&this.host.dispatchEvent(new CustomEvent("timeupdate",{detail:d}))}get currentTime(){return this._currentTime}set caption(t){t!==this._caption&&(this._caption=t,this.host.requestUpdate())}get caption(){return this._caption}canvas(){return Si(this._canvas)}controls(){return Si(this._controls)}loadScenes(){[...this.activeScenes,...this._upcomingScenes].forEach(t=>{var e,i,s;const{start:o,duration:c,video:d,videoMeta:f}=t,p=this.host.currentTime>0||this.host.preload==="auto"||!this.host.paused;if(d&&f){const{key:g,hls:v,node:b}=d,{start:E,duration:T}=f,w=this.host.videoState[g];b&&w&&(b.currentTime>=E+T||b.ended||p&&(v?(e=v.startLoadOnce)==null||e.call(v,b.currentTime):w.initialised||(i=b.startLoadOnce)==null||i.call(b)))}else if(p){const g=`${o}-${c}`,v=this.host._sceneController.videoState[g];this.host.duration&&!((s=v==null?void 0:v.buffered)!=null&&s.length)&&(this.host._sceneController.videoState={...this.host._sceneController.videoState,[g]:{...v,buffered:[{start:Math.max(0,o/this.host.duration*100),end:Math.min((o+c)/this.host.duration*100,100)}]}})}})}syncVideoState(){var t;(t=this.host.scenes)==null||t.forEach(e=>{if(e.video){const{key:i,node:s}=e.video,o=this.host.videoState[i],c=this.activeScenes.includes(e);if(s&&o)if(c&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(s.paused&&o.initialised)try{return s.play()}catch(d){throw new Qr(`Video play error: ${d.message}`,!0)}}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 iv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ju={exports:{}};(function(n,t){(function(e){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,o=/(?:\/|^)\.(?=\/)/g,c=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,d={buildAbsoluteURL:function(f,p,g){if(g=g||{},f=f.trim(),p=p.trim(),!p){if(!g.alwaysNormalize)return f;var v=d.parseURL(f);if(!v)throw new Error("Error trying to parse base URL.");return v.path=d.normalizePath(v.path),d.buildURLFromParts(v)}var b=d.parseURL(p);if(!b)throw new Error("Error trying to parse relative URL.");if(b.scheme)return g.alwaysNormalize?(b.path=d.normalizePath(b.path),d.buildURLFromParts(b)):p;var E=d.parseURL(f);if(!E)throw new Error("Error trying to parse base URL.");if(!E.netLoc&&E.path&&E.path[0]!=="/"){var T=s.exec(E.path);E.netLoc=T[1],E.path=T[2]}E.netLoc&&!E.path&&(E.path="/");var w={scheme:E.scheme,netLoc:b.netLoc,path:null,params:b.params,query:b.query,fragment:b.fragment};if(!b.netLoc&&(w.netLoc=E.netLoc,b.path[0]!=="/"))if(!b.path)w.path=E.path,b.params||(w.params=E.params,b.query||(w.query=E.query));else{var _=E.path,D=_.substring(0,_.lastIndexOf("/")+1)+b.path;w.path=d.normalizePath(D)}return w.path===null&&(w.path=g.alwaysNormalize?d.normalizePath(b.path):b.path),d.buildURLFromParts(w)},parseURL:function(f){var p=i.exec(f);return p?{scheme:p[1]||"",netLoc:p[2]||"",path:p[3]||"",params:p[4]||"",query:p[5]||"",fragment:p[6]||""}:null},normalizePath:function(f){for(f=f.split("").reverse().join("").replace(o,"");f.length!==(f=f.replace(c,"")).length;);return f.split("").reverse().join("")},buildURLFromParts:function(f){return f.scheme+f.netLoc+f.path+f.params+f.query+f.fragment}};n.exports=d})()})(ju);var oc=ju.exports;function Ku(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),e.push.apply(e,i)}return e}function Vi(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Ku(Object(e),!0).forEach(function(i){rv(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Ku(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function rv(n,t,e){return t=nv(t),t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function ai(){return ai=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},ai.apply(this,arguments)}function sv(n,t){if(typeof n!="object"||n===null)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var i=e.call(n,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function nv(n){var t=sv(n,"string");return typeof t=="symbol"?t:String(t)}const Vt=Number.isFinite||function(n){return typeof n=="number"&&isFinite(n)};let R=function(n){return n.MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached",n}({}),qt=function(n){return n.NETWORK_ERROR="networkError",n.MEDIA_ERROR="mediaError",n.KEY_SYSTEM_ERROR="keySystemError",n.MUX_ERROR="muxError",n.OTHER_ERROR="otherError",n}({}),ut=function(n){return n.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",n.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",n.KEY_SYSTEM_NO_SESSION="keySystemNoSession",n.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",n.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",n.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",n.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",n.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",n.MANIFEST_LOAD_ERROR="manifestLoadError",n.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",n.MANIFEST_PARSING_ERROR="manifestParsingError",n.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",n.LEVEL_EMPTY_ERROR="levelEmptyError",n.LEVEL_LOAD_ERROR="levelLoadError",n.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",n.LEVEL_PARSING_ERROR="levelParsingError",n.LEVEL_SWITCH_ERROR="levelSwitchError",n.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",n.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",n.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",n.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",n.FRAG_LOAD_ERROR="fragLoadError",n.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",n.FRAG_DECRYPT_ERROR="fragDecryptError",n.FRAG_PARSING_ERROR="fragParsingError",n.FRAG_GAP="fragGap",n.REMUX_ALLOC_ERROR="remuxAllocError",n.KEY_LOAD_ERROR="keyLoadError",n.KEY_LOAD_TIMEOUT="keyLoadTimeOut",n.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",n.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",n.BUFFER_APPEND_ERROR="bufferAppendError",n.BUFFER_APPENDING_ERROR="bufferAppendingError",n.BUFFER_STALLED_ERROR="bufferStalledError",n.BUFFER_FULL_ERROR="bufferFullError",n.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",n.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",n.INTERNAL_EXCEPTION="internalException",n.INTERNAL_ABORTED="aborted",n.UNKNOWN="unknown",n}({});const an=function(){},lc={trace:an,debug:an,log:an,warn:an,info:an,error:an};let ka=lc;function av(n){const t=self.console[n];return t?t.bind(self.console,`[${n}] >`):an}function ov(n,...t){t.forEach(function(e){ka[e]=n[e]?n[e].bind(n):av(e)})}function lv(n,t){if(self.console&&n===!0||typeof n=="object"){ov(n,"debug","log","info","warn","error");try{ka.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch{ka=lc}}else ka=lc}const z=ka,cv=/^(\d+)x(\d+)$/,Yu=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Ye{constructor(t){typeof t=="string"&&(t=Ye.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=cv.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(Yu.lastIndex=0;(e=Yu.exec(t))!==null;){let o=e[2];o.indexOf(s)===0&&o.lastIndexOf(s)===o.length-1&&(o=o.slice(1,-1));const c=e[1].trim();i[c]=o}return i}}function hv(n){return n!=="ID"&&n!=="CLASS"&&n!=="START-DATE"&&n!=="DURATION"&&n!=="END-DATE"&&n!=="END-ON-NEXT"}function dv(n){return n==="SCTE35-OUT"||n==="SCTE35-IN"}class zu{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]){z.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=s;break}t=ai(new Ye({}),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"]);Vt(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(Vt(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&&Vt(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Ao{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 Le={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Xu{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Le.AUDIO]:null,[Le.VIDEO]:null,[Le.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=oc.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class cc extends Xu{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 Ao,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||!Vt(this.programDateTime))return null;const t=Vt(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,o,c=!1){const{elementaryStreams:d}=this,f=d[t];if(!f){d[t]={startPTS:e,endPTS:i,startDTS:s,endDTS:o,partial:c};return}f.startPTS=Math.min(f.startPTS,e),f.endPTS=Math.max(f.endPTS,i),f.startDTS=Math.min(f.startDTS,s),f.endDTS=Math.max(f.endDTS,o)}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[Le.AUDIO]=null,t[Le.VIDEO]=null,t[Le.AUDIOVIDEO]=null}}class uv extends Xu{constructor(t,e,i,s,o){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 Ao,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 c=t.enumeratedString("BYTERANGE");c&&this.setByteRange(c,o),o&&(this.fragOffset=o.fragOffset+o.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 fv=10;class pv{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?Vt(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||fv}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 hc(n){return Uint8Array.from(atob(n),t=>t.charCodeAt(0))}function gv(n){const t=Zu(n).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e}function mv(n){const t=function(e,i,s){const o=e[i];e[i]=e[s],e[s]=o};t(n,0,3),t(n,1,2),t(n,4,5),t(n,6,7)}function vv(n){const t=n.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 o=s[0]==="base64",c=s[1];o?(i.splice(-1,1),e=hc(c)):e=gv(c)}}return e}function Zu(n){return Uint8Array.from(unescape(encodeURIComponent(n)),t=>t.charCodeAt(0))}var ze={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Wi={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function qu(n){switch(n){case Wi.FAIRPLAY:return ze.FAIRPLAY;case Wi.PLAYREADY:return ze.PLAYREADY;case Wi.WIDEVINE:return ze.WIDEVINE;case Wi.CLEARKEY:return ze.CLEARKEY}}var Qu={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function yv(n){if(n===Qu.WIDEVINE)return ze.WIDEVINE}function Ju(n){switch(n){case ze.FAIRPLAY:return Wi.FAIRPLAY;case ze.PLAYREADY:return Wi.PLAYREADY;case ze.WIDEVINE:return Wi.WIDEVINE;case ze.CLEARKEY:return Wi.CLEARKEY}}function dc(n){const{drmSystems:t,widevineLicenseUrl:e}=n,i=t?[ze.FAIRPLAY,ze.WIDEVINE,ze.PLAYREADY,ze.CLEARKEY].filter(s=>!!t[s]):[];return!i[ze.WIDEVINE]&&e&&i.push(ze.WIDEVINE),i}const t0=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function bv(n,t,e,i){let s;switch(n){case ze.FAIRPLAY:s=["cenc","sinf"];break;case ze.WIDEVINE:case ze.PLAYREADY:s=["cenc"];break;case ze.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${n}`)}return Av(s,t,e,i)}function Av(n,t,e,i){return[{initDataTypes:n,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 on(n,t,e){return Uint8Array.prototype.slice?n.slice(t,e):new Uint8Array(Array.prototype.slice.call(n,t,e))}const uc=(n,t)=>t+10<=n.length&&n[t]===73&&n[t+1]===68&&n[t+2]===51&&n[t+3]<255&&n[t+4]<255&&n[t+6]<128&&n[t+7]<128&&n[t+8]<128&&n[t+9]<128,e0=(n,t)=>t+10<=n.length&&n[t]===51&&n[t+1]===68&&n[t+2]===73&&n[t+3]<255&&n[t+4]<255&&n[t+6]<128&&n[t+7]<128&&n[t+8]<128&&n[t+9]<128,Eo=(n,t)=>{const e=t;let i=0;for(;uc(n,t);){i+=10;const s=To(n,t+6);i+=s,e0(n,t+10)&&(i+=10),t+=i}if(i>0)return n.subarray(e,e+i)},To=(n,t)=>{let e=0;return e=(n[t]&127)<<21,e|=(n[t+1]&127)<<14,e|=(n[t+2]&127)<<7,e|=n[t+3]&127,e},Ev=(n,t)=>uc(n,t)&&To(n,t+6)+10<=n.length-t,Tv=n=>{const t=r0(n);for(let e=0;e<t.length;e++){const i=t[e];if(i0(i))return Lv(i)}},i0=n=>n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp",kv=n=>{const t=String.fromCharCode(n[0],n[1],n[2],n[3]),e=To(n,4),i=10;return{type:t,size:e,data:n.subarray(i,i+e)}},r0=n=>{let t=0;const e=[];for(;uc(n,t);){const i=To(n,t+6);t+=10;const s=t+i;for(;t+8<s;){const o=kv(n.subarray(t)),c=wv(o);c&&e.push(c),t+=o.size+10}e0(n,t)&&(t+=10)}return e},wv=n=>n.type==="PRIV"?Sv(n):n.type[0]==="W"?_v(n):Rv(n),Sv=n=>{if(n.size<2)return;const t=Pr(n.data,!0),e=new Uint8Array(n.data.subarray(t.length+1));return{key:n.type,info:t,data:e.buffer}},Rv=n=>{if(n.size<2)return;if(n.type==="TXXX"){let e=1;const i=Pr(n.data.subarray(e),!0);e+=i.length+1;const s=Pr(n.data.subarray(e));return{key:n.type,info:i,data:s}}const t=Pr(n.data.subarray(1));return{key:n.type,data:t}},_v=n=>{if(n.type==="WXXX"){if(n.size<2)return;let e=1;const i=Pr(n.data.subarray(e),!0);e+=i.length+1;const s=Pr(n.data.subarray(e));return{key:n.type,info:i,data:s}}const t=Pr(n.data);return{key:n.type,data:t}},Lv=n=>{if(n.data.byteLength===8){const t=new Uint8Array(n.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)}},Pr=(n,t=!1)=>{const e=Cv();if(e){const p=e.decode(n);if(t){const g=p.indexOf("\0");return g!==-1?p.substring(0,g):p}return p.replace(/\0/g,"")}const i=n.length;let s,o,c,d="",f=0;for(;f<i;){if(s=n[f++],s===0&&t)return d;if(!(s===0||s===3))switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(s);break;case 12:case 13:o=n[f++],d+=String.fromCharCode((s&31)<<6|o&63);break;case 14:o=n[f++],c=n[f++],d+=String.fromCharCode((s&15)<<12|(o&63)<<6|(c&63)<<0);break}}return d};let fc;function Cv(){return!fc&&typeof self.TextDecoder<"u"&&(fc=new self.TextDecoder("utf-8")),fc}const Or={hexDump:function(n){let t="";for(let e=0;e<n.length;e++){let i=n[e].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},ko=Math.pow(2,32)-1,Iv=[].push,s0={video:1,audio:2,id3:3,text:4};function bi(n){return String.fromCharCode.apply(null,n)}function n0(n,t){const e=n[t]<<8|n[t+1];return e<0?65536+e:e}function ee(n,t){const e=a0(n,t);return e<0?4294967296+e:e}function a0(n,t){return n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3]}function pc(n,t,e){n[t]=e>>24,n[t+1]=e>>16&255,n[t+2]=e>>8&255,n[t+3]=e&255}function ye(n,t){const e=[];if(!t.length)return e;const i=n.byteLength;for(let s=0;s<i;){const o=ee(n,s),c=bi(n.subarray(s+4,s+8)),d=o>1?s+o:i;if(c===t[0])if(t.length===1)e.push(n.subarray(s+8,d));else{const f=ye(n.subarray(s+8,d),t.slice(1));f.length&&Iv.apply(e,f)}s=d}return e}function xv(n){const t=[],e=n[0];let i=8;const s=ee(n,i);i+=4;const o=0,c=0;e===0?i+=8:i+=16,i+=2;let d=n.length+c;const f=n0(n,i);i+=2;for(let p=0;p<f;p++){let g=i;const v=ee(n,g);g+=4;const b=v&2147483647;if((v&2147483648)>>>31===1)return z.warn("SIDX has hierarchical references (not supported)"),null;const E=ee(n,g);g+=4,t.push({referenceSize:b,subsegmentDuration:E,info:{duration:E/s,start:d,end:d+b-1}}),d+=b,g+=4,i=g}return{earliestPresentationTime:o,timescale:s,version:e,referencesCount:f,references:t}}function o0(n){const t=[],e=ye(n,["moov","trak"]);for(let i=0;i<e.length;i++){const s=e[i],o=ye(s,["tkhd"])[0];if(o){let c=o[0],d=c===0?12:20;const f=ee(o,d),p=ye(s,["mdia","mdhd"])[0];if(p){c=p[0],d=c===0?12:20;const g=ee(p,d),v=ye(s,["mdia","hdlr"])[0];if(v){const b=bi(v.subarray(8,12)),E={soun:Le.AUDIO,vide:Le.VIDEO}[b];if(E){const T=ye(s,["mdia","minf","stbl","stsd"])[0];let w;T&&(w=bi(T.subarray(12,16))),t[f]={timescale:g,type:E},t[E]={timescale:g,id:f,codec:w}}}}}}return ye(n,["moov","mvex","trex"]).forEach(i=>{const s=ee(i,4),o=t[s];o&&(o.default={duration:ee(i,12),flags:ee(i,20)})}),t}function Dv(n,t){if(!n||!t)return n;const e=t.keyId;return e&&t.isCommonEncryption&&ye(n,["moov","trak"]).forEach(i=>{const s=ye(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=ye(s,["enca"]);const c=o.length>0;c||(o=ye(s,["encv"])),o.forEach(d=>{const f=c?d.subarray(28):d.subarray(78);ye(f,["sinf"]).forEach(p=>{const g=l0(p);if(g){const v=g.subarray(8,24);v.some(b=>b!==0)||(z.log(`[eme] Patching keyId in 'enc${c?"a":"v"}>sinf>>tenc' box: ${Or.hexDump(v)} -> ${Or.hexDump(e)}`),g.set(e,8))}})})}),n}function l0(n){const t=ye(n,["schm"])[0];if(t){const e=bi(t.subarray(4,8));if(e==="cbcs"||e==="cenc")return ye(n,["schi","tenc"])[0]}return z.error("[eme] missing 'schm' box"),null}function Pv(n,t){return ye(t,["moof","traf"]).reduce((e,i)=>{const s=ye(i,["tfdt"])[0],o=s[0],c=ye(i,["tfhd"]).reduce((d,f)=>{const p=ee(f,4),g=n[p];if(g){let v=ee(s,4);if(o===1){if(v===ko)return z.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),d;v*=ko+1,v+=ee(s,8)}const b=g.timescale||9e4,E=v/b;if(isFinite(E)&&(d===null||E<d))return E}return d},null);return c!==null&&isFinite(c)&&(e===null||c<e)?c:e},null)}function Ov(n,t){let e=0,i=0,s=0;const o=ye(n,["moof","traf"]);for(let c=0;c<o.length;c++){const d=o[c],f=ye(d,["tfhd"])[0],p=ee(f,4),g=t[p];if(!g)continue;const v=g.default,b=ee(f,0)|(v==null?void 0:v.flags);let E=v==null?void 0:v.duration;b&8&&(b&2?E=ee(f,12):E=ee(f,8));const T=g.timescale||9e4,w=ye(d,["trun"]);for(let _=0;_<w.length;_++){if(e=Mv(w[_]),!e&&E){const D=ee(w[_],4);e=E*D}g.type===Le.VIDEO?i+=e/T:g.type===Le.AUDIO&&(s+=e/T)}}if(i===0&&s===0){let c=0;const d=ye(n,["sidx"]);for(let f=0;f<d.length;f++){const p=xv(d[f]);p!=null&&p.references&&(c+=p.references.reduce((g,v)=>g+v.info.duration||0,0))}return c}return i||s}function Mv(n){const t=ee(n,0);let e=8;t&1&&(e+=4),t&4&&(e+=4);let i=0;const s=ee(n,4);for(let o=0;o<s;o++){if(t&256){const c=ee(n,e);i+=c,e+=4}t&512&&(e+=4),t&1024&&(e+=4),t&2048&&(e+=4)}return i}function $v(n,t,e){ye(t,["moof","traf"]).forEach(i=>{ye(i,["tfhd"]).forEach(s=>{const o=ee(s,4),c=n[o];if(!c)return;const d=c.timescale||9e4;ye(i,["tfdt"]).forEach(f=>{const p=f[0];let g=ee(f,4);if(p===0)g-=e*d,g=Math.max(g,0),pc(f,4,g);else{g*=Math.pow(2,32),g+=ee(f,8),g-=e*d,g=Math.max(g,0);const v=Math.floor(g/(ko+1)),b=Math.floor(g%(ko+1));pc(f,4,v),pc(f,8,b)}})})})}function Nv(n){const t={valid:null,remainder:null},e=ye(n,["moof"]);if(e){if(e.length<2)return t.remainder=n,t}else return t;const i=e[e.length-1];return t.valid=on(n,0,i.byteOffset-8),t.remainder=on(n,i.byteOffset-8),t}function ln(n,t){const e=new Uint8Array(n.length+t.length);return e.set(n),e.set(t,n.length),e}function c0(n,t){const e=[],i=t.samples,s=t.timescale,o=t.id;let c=!1;return ye(i,["moof"]).map(d=>{const f=d.byteOffset-8;ye(d,["traf"]).map(p=>{const g=ye(p,["tfdt"]).map(v=>{const b=v[0];let E=ee(v,4);return b===1&&(E*=Math.pow(2,32),E+=ee(v,8)),E/s})[0];return g!==void 0&&(n=g),ye(p,["tfhd"]).map(v=>{const b=ee(v,4),E=ee(v,0)&16777215,T=(E&1)!==0,w=(E&2)!==0,_=(E&8)!==0;let D=0;const M=(E&16)!==0;let F=0;const x=(E&32)!==0;let N=8;b===o&&(T&&(N+=8),w&&(N+=4),_&&(D=ee(v,N),N+=4),M&&(F=ee(v,N),N+=4),x&&(N+=4),t.type==="video"&&(c=Fv(t.codec)),ye(p,["trun"]).map(V=>{const j=V[0],rt=ee(V,0)&16777215,nt=(rt&1)!==0;let Q=0;const Tt=(rt&4)!==0,gt=(rt&256)!==0;let $t=0;const Wt=(rt&512)!==0;let H=0;const J=(rt&1024)!==0,St=(rt&2048)!==0;let $=0;const U=ee(V,4);let X=8;nt&&(Q=ee(V,X),X+=4),Tt&&(X+=4);let mt=Q+f;for(let bt=0;bt<U;bt++){if(gt?($t=ee(V,X),X+=4):$t=D,Wt?(H=ee(V,X),X+=4):H=F,J&&(X+=4),St&&(j===0?$=ee(V,X):$=a0(V,X),X+=4),t.type===Le.VIDEO){let xt=0;for(;xt<H;){const Ut=ee(i,mt);if(mt+=4,Uv(c,i[mt])){const Qt=i.subarray(mt,mt+Ut);h0(Qt,c?2:1,n+$/s,e)}mt+=Ut,xt+=Ut+4}}n+=$t/s}}))})})}),e}function Fv(n){if(!n)return!1;const t=n.indexOf("."),e=t<0?n:n.substring(0,t);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function Uv(n,t){if(n){const e=t>>1&63;return e===39||e===40}else return(t&31)===6}function h0(n,t,e,i){const s=d0(n);let o=0;o+=t;let c=0,d=0,f=!1,p=0;for(;o<s.length;){c=0;do{if(o>=s.length)break;p=s[o++],c+=p}while(p===255);d=0;do{if(o>=s.length)break;p=s[o++],d+=p}while(p===255);const g=s.length-o;if(!f&&c===4&&o<s.length){if(f=!0,s[o++]===181){const v=n0(s,o);if(o+=2,v===49){const b=ee(s,o);if(o+=4,b===1195456820){const E=s[o++];if(E===3){const T=s[o++],w=31&T,_=64&T,D=_?2+w*3:0,M=new Uint8Array(D);if(_){M[0]=T;for(let F=1;F<D;F++)M[F]=s[o++]}i.push({type:E,payloadType:c,pts:e,bytes:M})}}}}}else if(c===5&&d<g){if(f=!0,d>16){const v=[];for(let T=0;T<16;T++){const w=s[o++].toString(16);v.push(w.length==1?"0"+w:w),(T===3||T===5||T===7||T===9)&&v.push("-")}const b=d-16,E=new Uint8Array(b);for(let T=0;T<b;T++)E[T]=s[o++];i.push({payloadType:c,pts:e,uuid:v.join(""),userData:Pr(E),userDataBytes:E})}}else if(d<g)o+=d;else if(d>g)break}}function d0(n){const t=n.byteLength,e=[];let i=1;for(;i<t-2;)n[i]===0&&n[i+1]===0&&n[i+2]===3?(e.push(i+2),i+=2):i++;if(e.length===0)return n;const s=t-e.length,o=new Uint8Array(s);let c=0;for(i=0;i<s;c++,i++)c===e[0]&&(c++,e.shift()),o[i]=n[c];return o}function Bv(n){const t=n[0];let e="",i="",s=0,o=0,c=0,d=0,f=0,p=0;if(t===0){for(;bi(n.subarray(p,p+1))!=="\0";)e+=bi(n.subarray(p,p+1)),p+=1;for(e+=bi(n.subarray(p,p+1)),p+=1;bi(n.subarray(p,p+1))!=="\0";)i+=bi(n.subarray(p,p+1)),p+=1;i+=bi(n.subarray(p,p+1)),p+=1,s=ee(n,12),o=ee(n,16),d=ee(n,20),f=ee(n,24),p=28}else if(t===1){p+=4,s=ee(n,p),p+=4;const v=ee(n,p);p+=4;const b=ee(n,p);for(p+=4,c=4294967296*v+b,Number.isSafeInteger(c)||(c=Number.MAX_SAFE_INTEGER,z.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),d=ee(n,p),p+=4,f=ee(n,p),p+=4;bi(n.subarray(p,p+1))!=="\0";)e+=bi(n.subarray(p,p+1)),p+=1;for(e+=bi(n.subarray(p,p+1)),p+=1;bi(n.subarray(p,p+1))!=="\0";)i+=bi(n.subarray(p,p+1)),p+=1;i+=bi(n.subarray(p,p+1)),p+=1}const g=n.subarray(p,n.byteLength);return{schemeIdUri:e,value:i,timeScale:s,presentationTime:c,presentationTimeDelta:o,eventDuration:d,id:f,payload:g}}function Gv(n,...t){const e=t.length;let i=8,s=e;for(;s--;)i+=t[s].byteLength;const o=new Uint8Array(i);for(o[0]=i>>24&255,o[1]=i>>16&255,o[2]=i>>8&255,o[3]=i&255,o.set(n,4),s=0,i=8;s<e;s++)o.set(t[s],i),i+=t[s].byteLength;return o}function Hv(n,t,e){if(n.byteLength!==16)throw new RangeError("Invalid system id");let i,s;if(t){i=1,s=new Uint8Array(t.length*16);for(let d=0;d<t.length;d++){const f=t[d];if(f.byteLength!==16)throw new RangeError("Invalid key");s.set(f,d*16)}}else i=0,s=new Uint8Array;let o;i>0?(o=new Uint8Array(4),t.length>0&&new DataView(o.buffer).setUint32(0,t.length,!1)):o=new Uint8Array;const c=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(c.buffer).setUint32(0,e.byteLength,!1),Gv([112,115,115,104],new Uint8Array([i,0,0,0]),n,o,s,c,e||new Uint8Array)}function Vv(n){if(!(n instanceof ArrayBuffer)||n.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},e=new DataView(n),i=e.getUint32(0);if(n.byteLength!==i&&i>44||e.getUint32(4)!==1886614376||(t.version=e.getUint32(8)>>>24,t.version>1))return null;t.systemId=Or.hexDump(new Uint8Array(n,12,16));const s=e.getUint32(28);if(t.version===0){if(i-32<s)return null;t.data=new Uint8Array(n,32,s)}else if(t.version===1){t.kids=[];for(let o=0;o<s;o++)t.kids.push(new Uint8Array(n,32+o*16,16))}return t}let wo={};class wa{static clearKeyUriToKeyIdMap(){wo={}}constructor(t,e,i,s=[1],o=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=o,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 Wi.FAIRPLAY:case Wi.WIDEVINE:case Wi.PLAYREADY:case Wi.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&&z.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const i=Wv(t);return new wa(this.method,this.uri,"identity",this.keyFormatVersions,i)}const e=vv(this.uri);if(e)switch(this.keyFormat){case Wi.WIDEVINE:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case Wi.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Hv(i,null,e);const s=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),o=String.fromCharCode.apply(null,Array.from(s)),c=o.substring(o.indexOf("<"),o.length),d=new DOMParser().parseFromString(c,"text/xml").getElementsByTagName("KID")[0];if(d){const f=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(f){const p=hc(f).subarray(0,16);mv(p),this.keyId=p}}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=wo[this.uri];if(!i){const s=Object.keys(wo).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,s),wo[this.uri]=i}this.keyId=i}return this}}function Wv(n){const t=new Uint8Array(16);for(let e=12;e<16;e++)t[e]=n>>8*(15-e)&255;return t}const u0=/\{\$([a-zA-Z0-9-_]+)\}/g;function f0(n){return u0.test(n)}function ji(n,t,e){if(n.variableList!==null||n.hasVariableRefs)for(let i=e.length;i--;){const s=e[i],o=t[s];o&&(t[s]=gc(n,o))}}function gc(n,t){if(n.variableList!==null||n.hasVariableRefs){const e=n.variableList;return t.replace(u0,i=>{const s=i.substring(2,i.length-1),o=e==null?void 0:e[s];return o===void 0?(n.playlistParsingError||(n.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),i):o})}return t}function p0(n,t,e){let i=n.variableList;i||(n.variableList=i={});let s,o;if("QUERYPARAM"in t){s=t.QUERYPARAM;try{const c=new self.URL(e).searchParams;if(c.has(s))o=c.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${e}"`)}catch(c){n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${c.message}`))}}else s=t.NAME,o=t.VALUE;s in i?n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):i[s]=o||""}function jv(n,t,e){const i=t.IMPORT;if(e&&i in e){let s=n.variableList;s||(n.variableList=s={}),s[i]=e[i]}else n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function So(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const Kv={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}},g0=So();function Yv(n,t){const e=Kv[t];return!!e&&e[n.slice(0,4)]===!0}function mc(n,t){var e;return(e=g0==null?void 0:g0.isTypeSupported(`${t||"video"}/mp4;codecs="${n}"`))!=null?e:!1}const m0=/#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,v0=/#EXT-X-MEDIA:(.*)/g,zv=/^#EXT(?:INF|-X-TARGETDURATION):/m,y0=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Xv=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 br{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 oc.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return zv.test(t)}static parseMasterPlaylist(t,e){const i=f0(t),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},o=[];m0.lastIndex=0;let c;for(;(c=m0.exec(t))!=null;)if(c[1]){var d;const p=new Ye(c[1]);ji(s,p,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const g=gc(s,c[2]),v={attrs:p,bitrate:p.decimalInteger("AVERAGE-BANDWIDTH")||p.decimalInteger("BANDWIDTH"),name:p.NAME,url:br.resolve(g,e)},b=p.decimalResolution("RESOLUTION");b&&(v.width=b.width,v.height=b.height),Zv((p.CODECS||"").split(/[ ,]+/).filter(E=>E),v),v.videoCodec&&v.videoCodec.indexOf("avc1")!==-1&&(v.videoCodec=br.convertAVC1ToAVCOTI(v.videoCodec)),(d=v.unknownCodecs)!=null&&d.length||o.push(v),s.levels.push(v)}else if(c[3]){const p=c[3],g=c[4];switch(p){case"SESSION-DATA":{const v=new Ye(g);ji(s,v,["DATA-ID","LANGUAGE","VALUE","URI"]);const b=v["DATA-ID"];b&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[b]=v);break}case"SESSION-KEY":{const v=b0(g,e,s);v.encrypted&&v.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(v)):z.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${g}"`);break}case"DEFINE":{{const v=new Ye(g);ji(s,v,["NAME","VALUE","QUERYPARAM"]),p0(s,v,e)}break}case"CONTENT-STEERING":{const v=new Ye(g);ji(s,v,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:br.resolve(v["SERVER-URI"],e),pathwayId:v["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=A0(g);break}}}const f=o.length>0&&o.length<s.levels.length;return s.levels=f?o:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(t,e,i){let s;const o={},c=i.levels,d={AUDIO:c.map(p=>({id:p.attrs.AUDIO,audioCodec:p.audioCodec})),SUBTITLES:c.map(p=>({id:p.attrs.SUBTITLES,textCodec:p.textCodec})),"CLOSED-CAPTIONS":[]};let f=0;for(v0.lastIndex=0;(s=v0.exec(t))!==null;){const p=new Ye(s[1]),g=p.TYPE;if(g){const v=d[g],b=o[g]||[];o[g]=b,ji(i,p,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const E={attrs:p,bitrate:0,id:f++,groupId:p["GROUP-ID"]||"",instreamId:p["INSTREAM-ID"],name:p.NAME||p.LANGUAGE||"",type:g,default:p.bool("DEFAULT"),autoselect:p.bool("AUTOSELECT"),forced:p.bool("FORCED"),lang:p.LANGUAGE,url:p.URI?br.resolve(p.URI,e):""};if(v!=null&&v.length){const T=br.findGroup(v,E.groupId)||v[0];E0(E,T,"audioCodec"),E0(E,T,"textCodec")}b.push(E)}}return o}static parseLevelPlaylist(t,e,i,s,o,c){const d=new pv(e),f=d.fragments;let p=null,g=0,v=0,b=0,E=0,T=null,w=new cc(s,e),_,D,M,F=-1,x=!1;for(y0.lastIndex=0,d.m3u8=t,d.hasVariableRefs=f0(t);(_=y0.exec(t))!==null;){x&&(x=!1,w=new cc(s,e),w.start=b,w.sn=g,w.cc=E,w.level=i,p&&(w.initSegment=p,w.rawProgramDateTime=p.rawProgramDateTime,p.rawProgramDateTime=null));const rt=_[1];if(rt){w.duration=parseFloat(rt);const nt=(" "+_[2]).slice(1);w.title=nt||null,w.tagList.push(nt?["INF",rt,nt]:["INF",rt])}else if(_[3]){if(Vt(w.duration)){w.start=b,M&&w0(w,M,d),w.sn=g,w.level=i,w.cc=E,w.urlId=o,f.push(w);const nt=(" "+_[3]).slice(1);w.relurl=gc(d,nt),T0(w,T),T=w,b+=w.duration,g++,v=0,x=!0}}else if(_[4]){const nt=(" "+_[4]).slice(1);T?w.setByteRange(nt,T):w.setByteRange(nt)}else if(_[5])w.rawProgramDateTime=(" "+_[5]).slice(1),w.tagList.push(["PROGRAM-DATE-TIME",w.rawProgramDateTime]),F===-1&&(F=f.length);else{if(_=_[0].match(Xv),!_){z.warn("No matches on slow regex match for level playlist!");continue}for(D=1;D<_.length&&!(typeof _[D]<"u");D++);const nt=(" "+_[D]).slice(1),Q=(" "+_[D+1]).slice(1),Tt=_[D+2]?(" "+_[D+2]).slice(1):"";switch(nt){case"PLAYLIST-TYPE":d.type=Q.toUpperCase();break;case"MEDIA-SEQUENCE":g=d.startSN=parseInt(Q);break;case"SKIP":{const gt=new Ye(Q);ji(d,gt,["RECENTLY-REMOVED-DATERANGES"]);const $t=gt.decimalInteger("SKIPPED-SEGMENTS");if(Vt($t)){d.skippedSegments=$t;for(let H=$t;H--;)f.unshift(null);g+=$t}const Wt=gt.enumeratedString("RECENTLY-REMOVED-DATERANGES");Wt&&(d.recentlyRemovedDateranges=Wt.split(" "));break}case"TARGETDURATION":d.targetduration=Math.max(parseInt(Q),1);break;case"VERSION":d.version=parseInt(Q);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(Q||Tt)&&w.tagList.push(Tt?[Q,Tt]:[Q]);break;case"DISCONTINUITY":E++,w.tagList.push(["DIS"]);break;case"GAP":w.gap=!0,w.tagList.push([nt]);break;case"BITRATE":w.tagList.push([nt,Q]);break;case"DATERANGE":{const gt=new Ye(Q);ji(d,gt,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),ji(d,gt,gt.clientAttrs);const $t=new zu(gt,d.dateRanges[gt.ID]);$t.isValid||d.skippedSegments?d.dateRanges[$t.id]=$t:z.warn(`Ignoring invalid DATERANGE tag: "${Q}"`),w.tagList.push(["EXT-X-DATERANGE",Q]);break}case"DEFINE":{{const gt=new Ye(Q);ji(d,gt,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in gt?jv(d,gt,c):p0(d,gt,e)}break}case"DISCONTINUITY-SEQUENCE":E=parseInt(Q);break;case"KEY":{const gt=b0(Q,e,d);if(gt.isSupported()){if(gt.method==="NONE"){M=void 0;break}M||(M={}),M[gt.keyFormat]&&(M=ai({},M)),M[gt.keyFormat]=gt}else z.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${Q}"`);break}case"START":d.startTimeOffset=A0(Q);break;case"MAP":{const gt=new Ye(Q);if(ji(d,gt,["BYTERANGE","URI"]),w.duration){const $t=new cc(s,e);k0($t,gt,i,M),p=$t,w.initSegment=p,p.rawProgramDateTime&&!w.rawProgramDateTime&&(w.rawProgramDateTime=p.rawProgramDateTime)}else k0(w,gt,i,M),p=w,x=!0;break}case"SERVER-CONTROL":{const gt=new Ye(Q);d.canBlockReload=gt.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=gt.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&gt.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=gt.optionalFloat("PART-HOLD-BACK",0),d.holdBack=gt.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const gt=new Ye(Q);d.partTarget=gt.decimalFloatingPoint("PART-TARGET");break}case"PART":{let gt=d.partList;gt||(gt=d.partList=[]);const $t=v>0?gt[gt.length-1]:void 0,Wt=v++,H=new Ye(Q);ji(d,H,["BYTERANGE","URI"]);const J=new uv(H,w,e,Wt,$t);gt.push(J),w.duration+=J.duration;break}case"PRELOAD-HINT":{const gt=new Ye(Q);ji(d,gt,["URI"]),d.preloadHint=gt;break}case"RENDITION-REPORT":{const gt=new Ye(Q);ji(d,gt,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(gt);break}default:z.warn(`line parsed but not handled: ${_}`);break}}}T&&!T.relurl?(f.pop(),b-=T.duration,d.partList&&(d.fragmentHint=T)):d.partList&&(T0(w,T),w.cc=E,d.fragmentHint=w,M&&w0(w,M,d));const N=f.length,V=f[0],j=f[N-1];if(b+=d.skippedSegments*d.targetduration,b>0&&N&&j){d.averagetargetduration=b/N;const rt=j.sn;d.endSN=rt!=="initSegment"?rt:0,d.live||(j.endList=!0),V&&(d.startCC=V.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(b+=d.fragmentHint.duration),d.totalduration=b,d.endCC=E,F>0&&qv(f,F),d}}function b0(n,t,e){var i,s;const o=new Ye(n);ji(e,o,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const c=(i=o.METHOD)!=null?i:"",d=o.URI,f=o.hexadecimalInteger("IV"),p=o.KEYFORMATVERSIONS,g=(s=o.KEYFORMAT)!=null?s:"identity";d&&o.IV&&!f&&z.error(`Invalid IV: ${o.IV}`);const v=d?br.resolve(d,t):"",b=(p||"1").split("/").map(Number).filter(Number.isFinite);return new wa(c,v,g,b,f)}function A0(n){const t=new Ye(n).decimalFloatingPoint("TIME-OFFSET");return Vt(t)?t:null}function Zv(n,t){["video","audio","text"].forEach(e=>{const i=n.filter(s=>Yv(s,e));if(i.length){const s=i.filter(o=>o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0);t[`${e}Codec`]=s.length>0?s[0]:i[0],n=n.filter(o=>i.indexOf(o)===-1)}}),t.unknownCodecs=n}function E0(n,t,e){const i=t[e];i&&(n[e]=i)}function qv(n,t){let e=n[t];for(let i=t;i--;){const s=n[i];if(!s)return;s.programDateTime=e.programDateTime-s.duration*1e3,e=s}}function T0(n,t){n.rawProgramDateTime?n.programDateTime=Date.parse(n.rawProgramDateTime):t!=null&&t.programDateTime&&(n.programDateTime=t.endProgramDateTime),Vt(n.programDateTime)||(n.programDateTime=null,n.rawProgramDateTime=null)}function k0(n,t,e,i){n.relurl=t.URI,t.BYTERANGE&&n.setByteRange(t.BYTERANGE),n.level=e,n.sn="initSegment",i&&(n.levelkeys=i),n.initSegment=null}function w0(n,t,e){n.levelkeys=t;const{encryptedFragments:i}=e;(!i.length||i[i.length-1].levelkeys!==t)&&Object.keys(t).some(s=>t[s].isCommonEncryption)&&i.push(n)}var Te={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Jt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function S0(n){const{type:t}=n;switch(t){case Te.AUDIO_TRACK:return Jt.AUDIO;case Te.SUBTITLE_TRACK:return Jt.SUBTITLE;default:return Jt.MAIN}}function vc(n,t){let e=n.url;return(e===void 0||e.indexOf("data:")===0)&&(e=t.url),e}class Qv{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(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,i=e.pLoader,s=e.loader,o=i||s,c=new o(e);return this.loaders[t.type]=c,c}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:Te.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(t,e){const{id:i,level:s,url:o,deliveryDirectives:c}=e;this.load({id:i,level:s,responseType:"text",type:Te.LEVEL,url:o,deliveryDirectives:c})}onAudioTrackLoading(t,e){const{id:i,groupId:s,url:o,deliveryDirectives:c}=e;this.load({id:i,groupId:s,level:null,responseType:"text",type:Te.AUDIO_TRACK,url:o,deliveryDirectives:c})}onSubtitleTrackLoading(t,e){const{id:i,groupId:s,url:o,deliveryDirectives:c}=e;this.load({id:i,groupId:s,level:null,responseType:"text",type:Te.SUBTITLE_TRACK,url:o,deliveryDirectives:c})}load(t){var e;const i=this.hls.config;let s=this.getInternalLoader(t);if(s){const p=s.context;if(p&&p.url===t.url){z.trace("[playlist-loader]: playlist request ongoing");return}z.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),s.abort()}let o;if(t.type===Te.MANIFEST?o=i.manifestLoadPolicy.default:o=ai({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(t),(e=t.deliveryDirectives)!=null&&e.part){let p;if(t.type===Te.LEVEL&&t.level!==null?p=this.hls.levels[t.level].details:t.type===Te.AUDIO_TRACK&&t.id!==null?p=this.hls.audioTracks[t.id].details:t.type===Te.SUBTITLE_TRACK&&t.id!==null&&(p=this.hls.subtitleTracks[t.id].details),p){const g=p.partTarget,v=p.targetduration;if(g&&v){const b=Math.max(g*3,v*.8)*1e3;o=ai({},o,{maxTimeToFirstByteMs:Math.min(b,o.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(b,o.maxTimeToFirstByteMs)})}}}const c=o.errorRetry||o.timeoutRetry||{},d={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},f={onSuccess:(p,g,v,b)=>{const E=this.getInternalLoader(v);this.resetInternalLoader(v.type);const T=p.data;if(T.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(p,v,new Error("no EXTM3U delimiter"),b||null,g);return}g.parsing.start=performance.now(),br.isMediaPlaylist(T)?this.handleTrackOrLevelPlaylist(p,g,v,b||null,E):this.handleMasterPlaylist(p,g,v,b)},onError:(p,g,v,b)=>{this.handleNetworkError(g,v,!1,p,b)},onTimeout:(p,g,v)=>{this.handleNetworkError(g,v,!0,void 0,p)}};s.load(t,d,f)}handleMasterPlaylist(t,e,i,s){const o=this.hls,c=t.data,d=vc(t,i),f=br.parseMasterPlaylist(c,d);if(f.playlistParsingError){this.handleManifestParsingError(t,i,f.playlistParsingError,s,e);return}const{contentSteering:p,levels:g,sessionData:v,sessionKeys:b,startTimeOffset:E,variableList:T}=f;this.variableList=T;const{AUDIO:w=[],SUBTITLES:_,"CLOSED-CAPTIONS":D}=br.parseMasterPlaylistMedia(c,d,f);w.length&&!w.some(M=>!M.url)&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(z.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),w.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Ye({}),bitrate:0,url:""})),o.trigger(R.MANIFEST_LOADED,{levels:g,audioTracks:w,subtitles:_,captions:D,contentSteering:p,url:d,stats:e,networkDetails:s,sessionData:v,sessionKeys:b,startTimeOffset:E,variableList:T})}handleTrackOrLevelPlaylist(t,e,i,s,o){const c=this.hls,{id:d,level:f,type:p}=i,g=vc(t,i),v=Vt(d)?d:0,b=Vt(f)?f:v,E=S0(i),T=br.parseLevelPlaylist(t.data,g,b,E,v,this.variableList);if(p===Te.MANIFEST){const w={attrs:new Ye({}),bitrate:0,details:T,name:"",url:g};c.trigger(R.MANIFEST_LOADED,{levels:[w],audioTracks:[],url:g,stats:e,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),i.levelDetails=T,this.handlePlaylistLoaded(T,t,e,i,s,o)}handleManifestParsingError(t,e,i,s,o){this.hls.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:ut.MANIFEST_PARSING_ERROR,fatal:e.type===Te.MANIFEST,url:t.url,err:i,error:i,reason:i.message,response:t,context:e,networkDetails:s,stats:o})}handleNetworkError(t,e,i=!1,s,o){let c=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${t.type}`;t.type===Te.LEVEL?c+=`: ${t.level} id: ${t.id}`:(t.type===Te.AUDIO_TRACK||t.type===Te.SUBTITLE_TRACK)&&(c+=` id: ${t.id} group-id: "${t.groupId}"`);const d=new Error(c);z.warn(`[playlist-loader]: ${c}`);let f=ut.UNKNOWN,p=!1;const g=this.getInternalLoader(t);switch(t.type){case Te.MANIFEST:f=i?ut.MANIFEST_LOAD_TIMEOUT:ut.MANIFEST_LOAD_ERROR,p=!0;break;case Te.LEVEL:f=i?ut.LEVEL_LOAD_TIMEOUT:ut.LEVEL_LOAD_ERROR,p=!1;break;case Te.AUDIO_TRACK:f=i?ut.AUDIO_TRACK_LOAD_TIMEOUT:ut.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Te.SUBTITLE_TRACK:f=i?ut.SUBTITLE_TRACK_LOAD_TIMEOUT:ut.SUBTITLE_LOAD_ERROR,p=!1;break}g&&this.resetInternalLoader(t.type);const v={type:qt.NETWORK_ERROR,details:f,fatal:p,url:t.url,loader:g,context:t,error:d,networkDetails:e,stats:o};if(s){const b=(e==null?void 0:e.url)||t.url;v.response=Vi({url:b,data:void 0},s)}this.hls.trigger(R.ERROR,v)}handlePlaylistLoaded(t,e,i,s,o,c){const d=this.hls,{type:f,level:p,id:g,groupId:v,deliveryDirectives:b}=s,E=vc(e,s),T=S0(s),w=typeof s.level=="number"&&T===Jt.MAIN?p:void 0;if(!t.fragments.length){const D=new Error("No Segments found in Playlist");d.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:ut.LEVEL_EMPTY_ERROR,fatal:!1,url:E,error:D,reason:D.message,response:e,context:s,level:w,parent:T,networkDetails:o,stats:i});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const _=t.playlistParsingError;if(_){d.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:ut.LEVEL_PARSING_ERROR,fatal:!1,url:E,error:_,reason:_.message,response:e,context:s,level:w,parent:T,networkDetails:o,stats:i});return}switch(t.live&&c&&(c.getCacheAge&&(t.ageHeader=c.getCacheAge()||0),(!c.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),f){case Te.MANIFEST:case Te.LEVEL:d.trigger(R.LEVEL_LOADED,{details:t,level:w||0,id:g||0,stats:i,networkDetails:o,deliveryDirectives:b});break;case Te.AUDIO_TRACK:d.trigger(R.AUDIO_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:b});break;case Te.SUBTITLE_TRACK:d.trigger(R.SUBTITLE_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:b});break}}}function R0(n,t){let e;try{e=new Event("addtrack")}catch{e=document.createEvent("Event"),e.initEvent("addtrack",!1,!1)}e.track=n,t.dispatchEvent(e)}function _0(n,t){const e=n.mode;if(e==="disabled"&&(n.mode="hidden"),n.cues&&!n.cues.getCueById(t.id))try{if(n.addCue(t),!n.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){z.debug(`[texttrack-utils]: ${i}`);try{const s=new self.TextTrackCue(t.startTime,t.endTime,t.text);s.id=t.id,n.addCue(s)}catch(s){z.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}e==="disabled"&&(n.mode=e)}function Rn(n){const t=n.mode;if(t==="disabled"&&(n.mode="hidden"),n.cues)for(let e=n.cues.length;e--;)n.removeCue(n.cues[e]);t==="disabled"&&(n.mode=t)}function yc(n,t,e,i){const s=n.mode;if(s==="disabled"&&(n.mode="hidden"),n.cues&&n.cues.length>0){const o=ty(n.cues,t,e);for(let c=0;c<o.length;c++)(!i||i(o[c]))&&n.removeCue(o[c])}s==="disabled"&&(n.mode=s)}function Jv(n,t){if(t<n[0].startTime)return 0;const e=n.length-1;if(t>n[e].endTime)return-1;let i=0,s=e;for(;i<=s;){const o=Math.floor((s+i)/2);if(t<n[o].startTime)s=o-1;else if(t>n[o].startTime&&i<e)i=o+1;else return o}return n[i].startTime-t<t-n[s].startTime?i:s}function ty(n,t,e){const i=[],s=Jv(n,t);if(s>-1)for(let o=s,c=n.length;o<c;o++){const d=n[o];if(d.startTime>=t&&d.endTime<=e)i.push(d);else if(d.startTime>e)return i}return i}var Ar={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const ey=.25;function bc(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const Ro=(()=>{const n=bc();try{new n(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Ac(n,t){return n.getTime()/1e3-t}function iy(n){return Uint8Array.from(n.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class ry{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(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(Rn(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 R0(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:o}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const c=bc();for(let d=0;d<o.length;d++){const f=o[d].type;if(f===Ar.emsg&&!i||!s)continue;const p=r0(o[d].data);if(p){const g=o[d].pts;let v=g+o[d].duration;v>Ro&&(v=Ro),v-g<=0&&(v=g+ey);for(let b=0;b<p.length;b++){const E=p[b];if(!i0(E)){this.updateId3CueEnds(g,f);const T=new c(g,v,"");T.value=E,f&&(T.type=f),this.id3Track.addCue(T)}}}}}updateId3CueEnds(t,e){var i;const s=(i=this.id3Track)==null?void 0:i.cues;if(s)for(let o=s.length;o--;){const c=s[o];c.type===e&&c.startTime<t&&c.endTime===Ro&&(c.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:i,type:s}){const{id3Track:o,hls:c}=this;if(!c)return;const{config:{enableEmsgMetadataCues:d,enableID3MetadataCues:f}}=c;if(o&&(d||f)){let p;s==="audio"?p=g=>g.type===Ar.audioId3&&f:s==="video"?p=g=>g.type===Ar.emsg&&d:p=g=>g.type===Ar.audioId3&&f||g.type===Ar.emsg&&d,yc(o,e,i,p)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:s}=this,{dateRanges:o}=e,c=Object.keys(o);if(s){const g=Object.keys(i).filter(v=>!c.includes(v));for(let v=g.length;v--;){const b=g[v];Object.keys(i[b].cues).forEach(E=>{s.removeCue(i[b].cues[E])}),delete i[b]}}const d=e.fragments[e.fragments.length-1];if(c.length===0||!Vt(d==null?void 0:d.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const f=d.programDateTime/1e3-d.start,p=bc();for(let g=0;g<c.length;g++){const v=c[g],b=o[v],E=i[v],T=(E==null?void 0:E.cues)||{};let w=(E==null?void 0:E.durationKnown)||!1;const _=Ac(b.startDate,f);let D=Ro;const M=b.endDate;if(M)D=Ac(M,f),w=!0;else if(b.endOnNext&&!w){const x=c.reduce((N,V)=>{const j=o[V];return j.class===b.class&&j.id!==V&&j.startDate>b.startDate&&N.push(j),N},[]).sort((N,V)=>N.startDate.getTime()-V.startDate.getTime())[0];x&&(D=Ac(x.startDate,f),w=!0)}const F=Object.keys(b.attr);for(let x=0;x<F.length;x++){const N=F[x];if(!hv(N))continue;let V=T[N];if(V)w&&!E.durationKnown&&(V.endTime=D);else{let j=b.attr[N];V=new p(_,D,""),dv(N)&&(j=iy(j)),V.value={key:N,data:j},V.type=Ar.dateRange,V.id=v,this.id3Track.addCue(V),T[N]=V}}i[v]={cues:T,dateRange:b,durationKnown:w}}}}class sy{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:o,liveSyncDurationCount:c,lowLatencyMode:d}=this.config,f=this.hls.userConfig;let p=d&&i||e;(f.liveSyncDuration||f.liveSyncDurationCount||p===0)&&(p=o!==void 0?o:c*s);const g=s,v=1;return p+Math.min(this.stallCount*v,g)}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,o=t-e-this.edgeStalled,c=s-i.totalduration,d=s-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(c,o),d)}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(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(R.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(R.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===ut.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&z.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:o}=this.config;if(!s||o===1)return;const c=this.targetLatency;if(c===null)return;const d=i-c,f=Math.min(this.maxLatency,c+e.targetduration),p=d<f;if(e.live&&p&&d>.05&&this.forwardBufferLength>1){const g=Math.min(2,Math.max(1,o)),v=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;t.playbackRate=Math.min(g,Math.max(1,v))}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 Ec=["NONE","TYPE-0","TYPE-1",null];var Sa={No:"",Yes:"YES",v2:"v2"};function ny(n,t){const{canSkipUntil:e,canSkipDateRanges:i,endSN:s}=n,o=t!==void 0?t-s:0;return e&&o<e?i?Sa.v2:Sa.Yes:Sa.No}class L0{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 Ra{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 Tc(n,t){const e=t.startPTS;if(Vt(e)){let i=0,s;t.sn>n.sn?(i=e-n.start,s=n):(i=n.start-e,s=t),s.duration!==i&&(s.duration=i)}else t.sn>n.sn?n.cc===t.cc&&n.minEndPTS?t.start=n.start+(n.minEndPTS-n.start):t.start=n.start+n.duration:t.start=Math.max(n.start-t.duration,0)}function C0(n,t,e,i,s,o){i-e<=0&&(z.warn("Fragment should have a positive duration",t),i=e+t.duration,o=s+t.duration);let c=e,d=i;const f=t.startPTS,p=t.endPTS;if(Vt(f)){const w=Math.abs(f-e);Vt(t.deltaPTS)?t.deltaPTS=Math.max(w,t.deltaPTS):t.deltaPTS=w,c=Math.max(e,f),e=Math.min(e,f),s=Math.min(s,t.startDTS),d=Math.min(i,p),i=Math.max(i,p),o=Math.max(o,t.endDTS)}const g=e-t.start;t.start!==0&&(t.start=e),t.duration=i-t.start,t.startPTS=e,t.maxStartPTS=c,t.startDTS=s,t.endPTS=i,t.minEndPTS=d,t.endDTS=o;const v=t.sn;if(!n||v<n.startSN||v>n.endSN)return 0;let b;const E=v-n.startSN,T=n.fragments;for(T[E]=t,b=E;b>0;b--)Tc(T[b],T[b-1]);for(b=E;b<T.length-1;b++)Tc(T[b],T[b+1]);return n.fragmentHint&&Tc(T[T.length-1],n.fragmentHint),n.PTSKnown=n.alignedSliding=!0,g}function ay(n,t){let e=null;const i=n.fragments;for(let f=i.length-1;f>=0;f--){const p=i[f].initSegment;if(p){e=p;break}}n.fragmentHint&&delete n.fragmentHint.endPTS;let s=0,o;if(cy(n,t,(f,p)=>{f.relurl&&(s=f.cc-p.cc),Vt(f.startPTS)&&Vt(f.endPTS)&&(p.start=p.startPTS=f.startPTS,p.startDTS=f.startDTS,p.maxStartPTS=f.maxStartPTS,p.endPTS=f.endPTS,p.endDTS=f.endDTS,p.minEndPTS=f.minEndPTS,p.duration=f.endPTS-f.startPTS,p.duration&&(o=p),t.PTSKnown=t.alignedSliding=!0),p.elementaryStreams=f.elementaryStreams,p.loader=f.loader,p.stats=f.stats,p.urlId=f.urlId,f.initSegment&&(p.initSegment=f.initSegment,e=f.initSegment)}),e&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach(f=>{var p;(!f.initSegment||f.initSegment.relurl===((p=e)==null?void 0:p.relurl))&&(f.initSegment=e)}),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(f=>!f),t.deltaUpdateFailed){z.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let f=t.skippedSegments;f--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=oy(n.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const c=t.fragments;if(s){z.warn("discontinuity sliding from playlist, take drift into account");for(let f=0;f<c.length;f++)c[f].cc+=s}t.skippedSegments&&(t.startCC=t.fragments[0].cc),ly(n.partList,t.partList,(f,p)=>{p.elementaryStreams=f.elementaryStreams,p.stats=f.stats}),o?C0(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):I0(n,t),c.length&&(t.totalduration=t.edge-c[0].start),t.driftStartTime=n.driftStartTime,t.driftStart=n.driftStart;const d=t.advancedDateTime;if(t.advanced&&d){const f=t.edge;t.driftStart||(t.driftStartTime=d,t.driftStart=f),t.driftEndTime=d,t.driftEnd=f}else t.driftEndTime=n.driftEndTime,t.driftEnd=n.driftEnd,t.advancedDateTime=n.advancedDateTime}function oy(n,t,e){const i=ai({},n);return e&&e.forEach(s=>{delete i[s]}),Object.keys(t).forEach(s=>{const o=new zu(t[s].attr,i[s]);o.isValid?i[s]=o:z.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[s].attr)}"`)}),i}function ly(n,t,e){if(n&&t){let i=0;for(let s=0,o=n.length;s<=o;s++){const c=n[s],d=t[s+i];c&&d&&c.index===d.index&&c.fragment.sn===d.fragment.sn?e(c,d):i--}}}function cy(n,t,e){const i=t.skippedSegments,s=Math.max(n.startSN,t.startSN)-t.startSN,o=(n.fragmentHint?1:0)+(i?t.endSN:Math.min(n.endSN,t.endSN))-t.startSN,c=t.startSN-n.startSN,d=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,f=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments;for(let p=s;p<=o;p++){const g=f[c+p];let v=d[p];i&&!v&&p<i&&(v=t.fragments[p]=g),g&&v&&e(g,v)}}function I0(n,t){const e=t.startSN+t.skippedSegments-n.startSN,i=n.fragments;e<0||e>=i.length||kc(t,i[e].start)}function kc(n,t){if(t){const e=n.fragments;for(let i=n.skippedSegments;i<e.length;i++)e[i].start+=t;n.fragmentHint&&(n.fragmentHint.start+=t)}}function hy(n,t=1/0){let e=1e3*n.targetduration;if(n.updated){const i=n.fragments,s=4;if(i.length&&e*s>t){const o=i[i.length-1].duration*1e3;o<e&&(e=o)}}else e/=2;return Math.round(e)}function dy(n,t,e){if(!(n!=null&&n.details))return null;const i=n.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 x0(n,t,e){var i;return n!=null&&n.details?D0((i=n.details)==null?void 0:i.partList,t,e):null}function D0(n,t,e){if(n)for(let i=n.length;i--;){const s=n[i];if(s.index===e&&s.fragment.sn===t)return s}return null}function _o(n){switch(n.details){case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_TIMEOUT:case ut.LEVEL_LOAD_TIMEOUT:case ut.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function P0(n,t){const e=_o(t);return n.default[`${e?"timeout":"error"}Retry`]}function wc(n,t){const e=n.backoff==="linear"?1:Math.pow(2,t);return Math.min(e*n.retryDelayMs,n.maxRetryDelayMs)}function O0(n){return Vi(Vi({},n),{errorRetry:null,timeoutRetry:null})}function Lo(n,t,e,i){return!!n&&t<n.maxNumRetry&&(uy(i)||!!e)}function uy(n){return n===0&&navigator.onLine===!1||!!n&&(n<400||n>499)}const M0={search:function(n,t){let e=0,i=n.length-1,s=null,o=null;for(;e<=i;){s=(e+i)/2|0,o=n[s];const c=t(o);if(c>0)e=s+1;else if(c<0)i=s-1;else return o}return null}};function fy(n,t,e){if(t===null||!Array.isArray(n)||!n.length||!Vt(t))return null;const i=n[0].programDateTime;if(t<(i||0))return null;const s=n[n.length-1].endProgramDateTime;if(t>=(s||0))return null;e=e||0;for(let o=0;o<n.length;++o){const c=n[o];if(py(t,e,c))return c}return null}function _a(n,t,e=0,i=0){let s=null;if(n?s=t[n.sn-t[0].sn+1]||null:e===0&&t[0].start===0&&(s=t[0]),s&&Sc(e,i,s)===0)return s;const o=M0.search(t,Sc.bind(null,e,i));return o&&(o!==n||!s)?o:s}function Sc(n=0,t=0,e){if(e.start<=n&&e.start+e.duration>n)return 0;const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-i<=n?1:e.start-i>n&&e.start?-1:0}function py(n,t,e){const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0))*1e3;return(e.endProgramDateTime||0)-i>n}function gy(n,t){return M0.search(n,e=>e.cc<t?1:e.cc>t?-1:0)}const my=3e5;var Ri={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},cr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class vy{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=z.log.bind(z,"[info]:"),this.warn=z.warn.bind(z,"[warning]:"),this.error=z.error.bind(z,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(R.ERROR,this.onError,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(R.ERROR,this.onError,this),t.off(R.ERROR,this.onErrorOut,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.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)===Jt.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 o=this.hls,c=e.context;switch(e.details){case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:e.errorAction=this.getFragRetryOrSwitchAction(e);return;case ut.FRAG_PARSING_ERROR:if((i=e.frag)!=null&&i.gap){e.errorAction={action:Ri.DoNothing,flags:cr.None};return}case ut.FRAG_GAP:case ut.FRAG_DECRYPT_ERROR:{e.errorAction=this.getFragRetryOrSwitchAction(e),e.errorAction.action=Ri.SendAlternateToPenaltyBox;return}case ut.LEVEL_EMPTY_ERROR:case ut.LEVEL_PARSING_ERROR:{var d,f;const p=e.parent===Jt.MAIN?e.level:o.loadLevel;e.details===ut.LEVEL_EMPTY_ERROR&&(d=e.context)!=null&&(f=d.levelDetails)!=null&&f.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,p):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,p))}return;case ut.LEVEL_LOAD_ERROR:case ut.LEVEL_LOAD_TIMEOUT:typeof(c==null?void 0:c.level)=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,c.level));return;case ut.AUDIO_TRACK_LOAD_ERROR:case ut.AUDIO_TRACK_LOAD_TIMEOUT:case ut.SUBTITLE_LOAD_ERROR:case ut.SUBTITLE_TRACK_LOAD_TIMEOUT:if(c){const p=o.levels[o.loadLevel];if(p&&(c.type===Te.AUDIO_TRACK&&c.groupId===p.audioGroupId||c.type===Te.SUBTITLE_TRACK&&c.groupId===p.textGroupId)){e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o.loadLevel),e.errorAction.action=Ri.SendAlternateToPenaltyBox,e.errorAction.flags=cr.MoveAllAlternatesMatchingHost;return}}return;case ut.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const p=o.levels[o.loadLevel],g=p==null?void 0:p.attrs["HDCP-LEVEL"];g&&(e.errorAction={action:Ri.SendAlternateToPenaltyBox,flags:cr.MoveAllAlternatesMatchingHDCP,hdcpLevel:g})}return;case ut.BUFFER_ADD_CODEC_ERROR:case ut.REMUX_ALLOC_ERROR:e.errorAction=this.getLevelSwitchAction(e,(s=e.level)!=null?s:o.loadLevel);return;case ut.INTERNAL_EXCEPTION:case ut.BUFFER_APPENDING_ERROR:case ut.BUFFER_APPEND_ERROR:case ut.BUFFER_FULL_ERROR:case ut.LEVEL_SWITCH_ERROR:case ut.BUFFER_STALLED_ERROR:case ut.BUFFER_SEEK_OVER_HOLE:case ut.BUFFER_NUDGE_ON_STALL:e.errorAction={action:Ri.DoNothing,flags:cr.None};return}if(e.type===qt.KEY_SYSTEM_ERROR){const p=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,p);return}}getPlaylistRetryOrSwitchAction(t,e){var i;const s=this.hls,o=P0(s.config.playlistLoadPolicy,t),c=this.playlistError++,d=(i=t.response)==null?void 0:i.code;if(Lo(o,c,_o(t),d))return{action:Ri.RetryRequest,flags:cr.None,retryConfig:o,retryCount:c};const f=this.getLevelSwitchAction(t,e);return o&&(f.retryConfig=o,f.retryCount=c),f}getFragRetryOrSwitchAction(t){const e=this.hls,i=this.getVariantLevelIndex(t.frag),s=e.levels[i],{fragLoadPolicy:o,keyLoadPolicy:c}=e.config,d=P0(t.details.startsWith("key")?c:o,t),f=e.levels.reduce((v,b)=>v+b.fragmentError,0);if(s){var p;t.details!==ut.FRAG_GAP&&s.fragmentError++;const v=(p=t.response)==null?void 0:p.code;if(Lo(d,f,_o(t),v))return{action:Ri.RetryRequest,flags:cr.None,retryConfig:d,retryCount:f}}const g=this.getLevelSwitchAction(t,i);return d&&(g.retryConfig=d,g.retryCount=f),g}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 o,c;let d=-1;const{levels:f,loadLevel:p,minAutoLevel:g,maxAutoLevel:v}=i,b=(o=t.frag)==null?void 0:o.type,{type:E,groupId:T}=(c=t.context)!=null?c:{};for(let w=f.length;w--;){const _=(w+p)%f.length;if(_!==p&&_>=g&&_<=v&&f[_].loadError===0){const D=f[_];if(t.details===ut.FRAG_GAP&&t.frag){const M=f[_].details;if(M){const F=_a(t.frag,M.fragments,t.frag.start);if(F!=null&&F.gap)continue}}else if(E===Te.AUDIO_TRACK&&T===D.audioGroupId||E===Te.SUBTITLE_TRACK&&T===D.textGroupId||b===Jt.AUDIO&&s.audioGroupId===D.audioGroupId||b===Jt.SUBTITLE&&s.textGroupId===D.textGroupId)continue;d=_;break}}if(d>-1&&i.loadLevel!==d)return t.levelRetry=!0,this.playlistError=0,{action:Ri.SendAlternateToPenaltyBox,flags:cr.None,nextAutoLevel:d}}return{action:Ri.SendAlternateToPenaltyBox,flags:cr.MoveAllAlternatesMatchingHost}}onErrorOut(t,e){var i;switch((i=e.errorAction)==null?void 0:i.action){case Ri.DoNothing:break;case Ri.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),!e.errorAction.resolved&&e.details!==ut.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:o,nextAutoLevel:c}=i;switch(s){case cr.None:this.switchLevel(t,c);break;case cr.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(t));break;case cr.MoveAllAlternatesMatchingHDCP:o&&(e.maxHdcpLevel=Ec[Ec.indexOf(o)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(t,c)}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===Jt.MAIN?t.level:e.loadLevel,o=e.levels[s],c=o.url.length,d=t.frag?t.frag.urlId:o.urlId;o.urlId===d&&(!t.frag||o.details)&&this.penalizeRendition(o,t);for(let f=1;f<c;f++){const p=(d+f)%c,g=i[p];if(!g||yy(g,t,i[d]))return this.warn(`Switching to Redundant Stream ${p+1}/${c}: "${o.url[p]}" after ${t.details}`),this.playlistError=0,e.levels.forEach(v=>{v.urlId=p}),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 yy(n,t,e){if(performance.now()-n.lastErrorPerfMs>my)return!0;const i=n.details;if(t.details===ut.FRAG_GAP&&i&&t.frag){const s=t.frag.start,o=_a(null,i.fragments,s);if(o&&!o.gap)return!0}if(e&&n.errors.length<e.errors.length){const s=n.errors[n.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 Rc{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=z.log.bind(z,`${e}:`),this.warn=z.warn.bind(z,`${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 o=0;o<i.length;o++){const c=i[o];let d;try{d=new self.URL(c.URI,e.url).href}catch(f){z.warn(`Could not construct new URL for Rendition Report: ${f}`),d=c.URI||""}if(d===t){s=o;break}else d===t.substring(0,d.length)&&(s=o)}if(s!==-1){const o=i[s],c=parseInt(o["LAST-MSN"])||(e==null?void 0:e.lastPartSn);let d=parseInt(o["LAST-PART"])||(e==null?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){const f=Math.min(e.age-e.partTarget,e.targetduration);d>=0&&f>e.partTarget&&(d+=1)}return new L0(c,d>=0?d:void 0,Sa.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:o}=e,c=self.performance.now(),d=o.loading.first?Math.max(0,c-o.loading.first):0;if(s.advancedDateTime=Date.now()-d,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&&ay(i,s),!this.canLoad||!s.live)return;let f,p,g;if(s.canBlockReload&&s.endSN&&s.advanced){const _=this.hls.config.lowLatencyMode,D=s.lastPartSn,M=s.endSN,F=s.lastPartIndex,x=F!==-1,N=D===M,V=_?0:F;x?(p=N?M+1:D,g=N?V:F+1):p=M+1;const j=s.age,rt=j+s.ageHeader;let nt=Math.min(rt-s.partTarget,s.targetduration*1.5);if(nt>0){if(i&&nt>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${nt} with playlist age: ${s.age}`),nt=0;else{const Q=Math.floor(nt/s.targetduration);if(p+=Q,g!==void 0){const Tt=Math.round(nt%s.targetduration/s.partTarget);g+=Tt}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${j.toFixed(2)}s goal: ${nt} skip sn ${Q} to part ${g}`)}s.tuneInGoal=nt}if(f=this.getDeliveryDirectives(s,e.deliveryDirectives,p,g),_||!N){this.loadPlaylist(f);return}}else(s.canBlockReload||s.canSkipUntil)&&(f=this.getDeliveryDirectives(s,e.deliveryDirectives,p,g));const v=this.hls.mainForwardBufferInfo,b=v?v.end-v.len:0,E=(s.edge-b)*1e3,T=hy(s,E);s.updated&&c>this.requestScheduled+T&&(this.requestScheduled=o.loading.start),p!==void 0&&s.canBlockReload?this.requestScheduled=o.loading.first+T-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+T<c?this.requestScheduled=c:this.requestScheduled-c<=0&&(this.requestScheduled+=T);let w=this.requestScheduled-c;w=Math.max(0,w),this.log(`reload live playlist ${t} in ${Math.round(w)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(f),w)}else this.clearTimer()}getDeliveryDirectives(t,e,i,s){let o=ny(t,i);return e!=null&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,s=e.part,o=Sa.No),new L0(i,s,o)}checkRetry(t){const e=t.details,i=_o(t),s=t.errorAction,{action:o,retryCount:c=0,retryConfig:d}=s||{},f=!!s&&!!d&&(o===Ri.RetryRequest||!s.resolved&&o===Ri.SendAlternateToPenaltyBox);if(f){var p;if(this.requestScheduled=-1,c>=d.maxNumRetry)return!1;if(i&&(p=t.context)!=null&&p.deliveryDirectives)this.warn(`Retrying playlist loading ${c+1}/${d.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const g=wc(d,c);this.timer=self.setTimeout(()=>this.loadPlaylist(),g),this.warn(`Retrying playlist loading ${c+1}/${d.maxNumRetry} after "${e}" in ${g}ms`)}t.levelRetry=!0,s.resolved=!0}return f}}let _c;class by extends Rc{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(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.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 o;e.levels.forEach(c=>{var d;const f=c.attrs;((d=c.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(_c||(_c=/chrome|firefox/i.test(navigator.userAgent)),_c&&(c.audioCodec=void 0));const{AUDIO:p,CODECS:g,"FRAME-RATE":v,"PATHWAY-ID":b,RESOLUTION:E,SUBTITLES:T}=f,w=`${`${b||"."}-`}${c.bitrate}-${E}-${v}-${g}`;o=s[w],o?o.addFallback(c):(o=new Ra(c),s[w]=o,i.push(o)),Co(o,"audio",p),Co(o,"text",T)}),this.filterAndSortMediaOptions(i,e)}filterAndSortMediaOptions(t,e){let i=[],s=[],o=!1,c=!1,d=!1,f=t.filter(({audioCodec:E,videoCodec:T,width:w,height:_,unknownCodecs:D})=>(o||(o=!!(w&&_)),c||(c=!!T),d||(d=!!E),!(D!=null&&D.length)&&(!E||mc(E,"audio"))&&(!T||mc(T,"video"))));if((o||c)&&d&&(f=f.filter(({videoCodec:E,width:T,height:w})=>!!E||!!(T&&w))),f.length===0){Promise.resolve().then(()=>{if(this.hls){const E=new Error("no level with compatible codecs found in manifest");this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:E,reason:E.message})}});return}e.audioTracks&&(i=e.audioTracks.filter(E=>!E.audioCodec||mc(E.audioCodec,"audio")),$0(i)),e.subtitles&&(s=e.subtitles,$0(s));const p=f.slice(0);f.sort((E,T)=>E.attrs["HDCP-LEVEL"]!==T.attrs["HDCP-LEVEL"]?(E.attrs["HDCP-LEVEL"]||"")>(T.attrs["HDCP-LEVEL"]||"")?1:-1:E.bitrate!==T.bitrate?E.bitrate-T.bitrate:E.attrs["FRAME-RATE"]!==T.attrs["FRAME-RATE"]?E.attrs.decimalFloatingPoint("FRAME-RATE")-T.attrs.decimalFloatingPoint("FRAME-RATE"):E.attrs.SCORE!==T.attrs.SCORE?E.attrs.decimalFloatingPoint("SCORE")-T.attrs.decimalFloatingPoint("SCORE"):o&&E.height!==T.height?E.height-T.height:0);let g=p[0];if(this.steering&&(f=this.steering.filterParsedLevels(f),f.length!==p.length)){for(let E=0;E<p.length;E++)if(p[E].pathwayId===f[0].pathwayId){g=p[E];break}}this._levels=f;for(let E=0;E<f.length;E++)if(f[E]===g){this._firstLevel=E,this.log(`manifest loaded, ${f.length} level(s) found, first bitrate: ${g.bitrate}`);break}const v=d&&!c,b={levels:f,audioTracks:i,subtitleTracks:s,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:d,video:c,altAudio:!v&&i.some(E=>!!E.url)};this.hls.trigger(R.MANIFEST_PARSED,b),(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 g=new Error("invalid level idx"),v=t<0;if(this.hls.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.LEVEL_SWITCH_ERROR,level:t,fatal:v,error:g,reason:g.message}),v)return;t=Math.min(t,e.length-1)}const i=this.currentLevelIndex,s=this.currentLevel,o=s?s.attrs["PATHWAY-ID"]:void 0,c=e[t],d=c.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=c,i===t&&c.details&&s&&o===d)return;this.log(`Switching to level ${t}${d?" with Pathway "+d:""} from level ${i}${o?" with Pathway "+o:""}`);const f=ai({},c,{level:t,maxBitrate:c.maxBitrate,attrs:c.attrs,uri:c.uri,urlId:c.urlId});delete f._attrs,delete f._urlId,this.hls.trigger(R.LEVEL_SWITCHING,f);const p=c.details;if(!p||p.live){const g=this.switchParams(c.uri,s==null?void 0:s.details);this.loadPlaylist(g)}}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===Te.LEVEL&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){if(e!==void 0&&e.type===Jt.MAIN){const i=this._levels[e.level];i!==void 0&&(i.loadError=0)}}onLevelLoaded(t,e){var i;const{level:s,details:o}=e,c=this._levels[s];if(!c){var d;this.warn(`Invalid level index ${s}`),(d=e.deliveryDirectives)!=null&&d.skip&&(o.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0),this.playlistLoaded(s,e,c.details)):(i=e.deliveryDirectives)!=null&&i.skip&&(o.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 o=-1;for(let c=0;c<i.audioGroupIds.length;c++)if(i.audioGroupIds[c]===s){o=c;break}o!==-1&&o!==i.urlId&&(i.urlId=o,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 o=i.uri;if(t)try{o=t.addDirectives(o)}catch(d){this.warn(`Could not construct new URL with HLS Delivery Directives: ${d}`)}const c=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${c?" Pathway "+c:""} URI ${s+1}/${i.url.length} ${o}`),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:o,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=(o,c)=>c!==e,s=this._levels.filter((o,c)=>c!==t?!0:o.url.length>1&&e!==void 0?(o.url=o.url.filter(i),o.audioGroupIds&&(o.audioGroupIds=o.audioGroupIds.filter(i)),o.textGroupIds&&(o.textGroupIds=o.textGroupIds.filter(i)),o.urlId=0,!0):(this.steering&&this.steering.removeLevel(o),!1));this.hls.trigger(R.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(t,{levels:e}){e.forEach((i,s)=>{const{details:o}=i;o!=null&&o.fragments&&o.fragments.forEach(c=>{c.level=s})}),this._levels=e}}function Co(n,t,e){e&&(t==="audio"?(n.audioGroupIds||(n.audioGroupIds=[]),n.audioGroupIds[n.url.length-1]=e):t==="text"&&(n.textGroupIds||(n.textGroupIds=[]),n.textGroupIds[n.url.length-1]=e))}function $0(n){const t={};n.forEach(e=>{const i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}var ui={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Ay{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(R.BUFFER_APPENDED,this.onBufferAppended,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.BUFFER_APPENDED,this.onBufferAppended,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this),t.off(R.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 o=i[s];if(!o)break;const c=o.end;if(o.start<=t&&c!==null&&t<=c)return o}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:i}=this,s=Object.keys(i);for(let o=s.length;o--;){const c=i[s[o]];if((c==null?void 0:c.body.type)===e&&c.buffered){const d=c.body;if(d.start<=t&&t<=d.end)return d}}return null}detectEvictedFragments(t,e,i,s){this.timeRanges&&(this.timeRanges[t]=e);const o=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(c=>{const d=this.fragments[c];if(!d||o>=d.body.sn)return;if(!d.buffered&&!d.loaded){d.body.type===i&&this.removeFragment(d.body);return}const f=d.range[t];f&&f.time.some(p=>{const g=!this.isTimeBuffered(p.startPTS,p.endPTS,e);return g&&this.removeFragment(d.body),g})})}detectPartialFragments(t){const e=this.timeRanges,{frag:i,part:s}=t;if(!e||i.sn==="initSegment")return;const o=_n(i),c=this.fragments[o];if(!c||c.buffered&&i.gap)return;const d=!i.relurl;Object.keys(e).forEach(f=>{const p=i.elementaryStreams[f];if(!p)return;const g=e[f],v=d||p.partial===!0;c.range[f]=this.getBufferedTimes(i,s,v,g)}),c.loaded=null,Object.keys(c.range).length?(c.buffered=!0,(c.body.endList=i.endList||c.body.endList)&&(this.endListFragments[c.body.type]=c),Io(c)||this.removeParts(i.sn-1,i.type)):this.removeFragment(c.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=_n(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 o={time:[],partial:i},c=t.start,d=t.end,f=t.minEndPTS||d,p=t.maxStartPTS||c;for(let g=0;g<s.length;g++){const v=s.start(g)-this.bufferPadding,b=s.end(g)+this.bufferPadding;if(p>=v&&f<=b){o.time.push({startPTS:Math.max(c,s.start(g)),endPTS:Math.min(d,s.end(g))});break}else if(c<b&&d>v)o.partial=!0,o.time.push({startPTS:Math.max(c,s.start(g)),endPTS:Math.min(d,s.end(g))});else if(d<=v)break}return o}getPartialFragment(t){let e=null,i,s,o,c=0;const{bufferPadding:d,fragments:f}=this;return Object.keys(f).forEach(p=>{const g=f[p];g&&Io(g)&&(s=g.body.start-d,o=g.body.end+d,t>=s&&t<=o&&(i=Math.min(t-s,o-t),c<=i&&(e=g.body,c=i)))}),e}isEndListAppended(t){const e=this.endListFragments[t];return e!==void 0&&(e.buffered||Io(e))}getState(t){const e=_n(t),i=this.fragments[e];return i?i.buffered?Io(i)?ui.PARTIAL:ui.OK:ui.APPENDING:ui.NOT_LOADED}isTimeBuffered(t,e,i){let s,o;for(let c=0;c<i.length;c++){if(s=i.start(c)-this.bufferPadding,o=i.end(c)+this.bufferPadding,t>=s&&e<=o)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 o=s?null:e,c=_n(i);this.fragments[c]={body:i,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:i,part:s,timeRanges:o}=e;if(i.sn==="initSegment")return;const c=i.type;if(s){let d=this.activePartLists[c];d||(this.activePartLists[c]=d=[]),d.push(s)}this.timeRanges=o,Object.keys(o).forEach(d=>{const f=o[d];this.detectEvictedFragments(d,f,c,s)})}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=_n(t);return!!this.fragments[e]}hasParts(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)}removeFragmentsInRange(t,e,i,s,o){s&&!this.hasGaps||Object.keys(this.fragments).forEach(c=>{const d=this.fragments[c];if(!d)return;const f=d.body;f.type!==i||s&&!f.gap||f.start<e&&f.end>t&&(d.buffered||o)&&this.removeFragment(f)})}removeFragment(t){const e=_n(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(o=>o.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 Io(n){var t,e,i;return n.buffered&&(n.body.gap||((t=n.range.video)==null?void 0:t.partial)||((e=n.range.audio)==null?void 0:e.partial)||((i=n.range.audiovideo)==null?void 0:i.partial))}function _n(n){return`${n.type}_${n.level}_${n.urlId}_${n.sn}`}const N0=Math.pow(2,17);class Ey{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 Jr({type:qt.NETWORK_ERROR,details:ut.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,o=s.fLoader,c=s.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap)if(t.tagList.some(E=>E[0]==="GAP")){f(U0(t));return}else t.gap=!1;const p=this.loader=t.loader=o?new o(s):new c(s),g=F0(t),v=O0(s.fragLoadPolicy.default),b={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:N0};t.stats=p.stats,p.load(g,b,{onSuccess:(E,T,w,_)=>{this.resetLoader(t,p);let D=E.data;w.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(D.slice(0,16)),D=D.slice(16)),d({frag:t,part:null,payload:D,networkDetails:_})},onError:(E,T,w,_)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:Vi({url:i,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:_}))},onAbort:(E,T,w)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:w,stats:E}))},onTimeout:(E,T,w)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${b.timeout}ms`),networkDetails:w,stats:E}))},onProgress:(E,T,w,_)=>{e&&e({frag:t,part:null,payload:w,networkDetails:_})}})})}loadPart(t,e,i){this.abort();const s=this.config,o=s.fLoader,c=s.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap){f(U0(t,e));return}const p=this.loader=t.loader=o?new o(s):new c(s),g=F0(t,e),v=O0(s.fragLoadPolicy.default),b={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:N0};e.stats=p.stats,p.load(g,b,{onSuccess:(E,T,w,_)=>{this.resetLoader(t,p),this.updateStatsFromPart(t,e);const D={frag:t,part:e,payload:E.data,networkDetails:_};i(D),d(D)},onError:(E,T,w,_)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:Vi({url:g.url,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:_}))},onAbort:(E,T,w)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:w,stats:E}))},onTimeout:(E,T,w)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${b.timeout}ms`),networkDetails:w,stats:E}))}})})}updateStatsFromPart(t,e){const i=t.stats,s=e.stats,o=s.total;if(i.loaded+=s.loaded,o){const f=Math.round(t.duration/e.duration),p=Math.min(Math.round(i.loaded/o),f),g=(f-p)*Math.round(i.loaded/p);i.total=i.loaded+g}else i.total=Math.max(i.loaded,i.total);const c=i.loading,d=s.loading;c.start?c.first+=d.first-d.start:(c.start=d.start,c.first=d.first),c.end=d.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function F0(n,t=null){const e=t||n,i={frag:n,part:t,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},s=e.byteRangeStartOffset,o=e.byteRangeEndOffset;if(Vt(s)&&Vt(o)){var c;let d=s,f=o;if(n.sn==="initSegment"&&((c=n.decryptdata)==null?void 0:c.method)==="AES-128"){const p=o-s;p%16&&(f=o+(16-p%16)),s!==0&&(i.resetIV=!0,d=s-16)}i.rangeStart=d,i.rangeEnd=f}return i}function U0(n,t){const e=new Error(`GAP ${n.gap?"tag":"attribute"} found`),i={type:qt.MEDIA_ERROR,details:ut.FRAG_GAP,fatal:!1,frag:n,error:e,networkDetails:null};return t&&(i.part=t),(t||n).stats.aborted=!0,new Jr(i)}class Jr extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class Ty{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=ut.KEY_LOAD_ERROR,i,s,o){return new Jr({type:qt.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:o,error:i,networkDetails:s})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:s}=t;for(let o=0;o<e.length;o++){const c=e[o];if(s<=c.cc&&(i==="initSegment"||c.sn==="initSegment"||i<c.sn)){this.emeController.selectKeySystemFormat(c).then(d=>{c.setKeyFormat(d)});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 o=t.decryptdata;if(!o){const p=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,ut.KEY_LOAD_ERROR,p))}const c=o.uri;if(!c)return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${c}"`)));let d=this.keyUriToKeyInfo[c];if((i=d)!=null&&i.decryptdata.key)return o.key=d.decryptdata.key,Promise.resolve({frag:t,keyInfo:d});if((s=d)!=null&&s.keyLoadPromise){var f;switch((f=d.mediaKeySessionContext)==null?void 0:f.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return d.keyLoadPromise.then(p=>(o.key=p.keyInfo.decryptdata.key,{frag:t,keyInfo:d}))}}switch(d=this.keyUriToKeyInfo[c]={decryptdata:o,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},o.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return o.keyFormat==="identity"?this.loadKeyHTTP(d,t):this.loadKeyEME(d,t);case"AES-128":return this.loadKeyHTTP(d,t);default:return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${o.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(o=>(t.mediaKeySessionContext=o,i))).catch(o=>{throw t.keyLoadPromise=null,o})}return Promise.resolve(i)}loadKeyHTTP(t,e){const i=this.config,s=i.loader,o=new s(i);return e.keyLoader=t.loader=o,t.keyLoadPromise=new Promise((c,d)=>{const f={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},p=i.keyLoadPolicy.default,g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:(b,E,T,w)=>{const{frag:_,keyInfo:D,url:M}=T;if(!_.decryptdata||D!==this.keyUriToKeyInfo[M])return d(this.createKeyLoadError(_,ut.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));D.decryptdata.key=_.decryptdata.key=new Uint8Array(b.data),_.keyLoader=null,D.loader=null,c({frag:_,keyInfo:D})},onError:(b,E,T,w)=>{this.resetLoader(E),d(this.createKeyLoadError(e,ut.KEY_LOAD_ERROR,new Error(`HTTP Error ${b.code} loading key ${b.text}`),T,Vi({url:f.url,data:void 0},b)))},onTimeout:(b,E,T)=>{this.resetLoader(E),d(this.createKeyLoadError(e,ut.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:(b,E,T)=>{this.resetLoader(E),d(this.createKeyLoadError(e,ut.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};o.load(f,g,v)})}resetLoader(t){const{frag:e,keyInfo:i,url:s}=t,o=i.loader;e.keyLoader===o&&(e.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[s],o&&o.destroy()}}class ky{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 wy={length:0,start:()=>0,end:()=>0};class Me{static isBuffered(t,e){try{if(t){const i=Me.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=Me.getBuffered(t),o=[];let c;for(c=0;c<s.length;c++)o.push({start:s.start(c),end:s.end(c)});return this.bufferedInfo(o,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(p,g){return p.start-g.start||g.end-p.end});let s=[];if(i)for(let p=0;p<t.length;p++){const g=s.length;if(g){const v=s[g-1].end;t[p].start-v<i?t[p].end>v&&(s[g-1].end=t[p].end):s.push(t[p])}else s.push(t[p])}else s=t;let o=0,c,d=e,f=e;for(let p=0;p<s.length;p++){const g=s[p].start,v=s[p].end;if(e+i>=g&&e<v)d=g,f=v,o=f-e;else if(e+i<g){c=g;break}}return{len:o,start:d||0,end:f||0,nextStart:c}}static getBuffered(t){try{return t.buffered}catch(e){return z.log("failed to get media.buffered",e),wy}}}class Lc{constructor(t,e,i,s=0,o=-1,c=!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=xo(),this.buffering={audio:xo(),video:xo(),audiovideo:xo()},this.level=t,this.sn=e,this.id=i,this.size=s,this.part=o,this.partial=c}}function xo(){return{start:0,executeStart:0,executeEnd:0,end:0}}function B0(n,t){let e=null;for(let i=0,s=n.length;i<s;i++){const o=n[i];if(o&&o.cc===t){e=o;break}}return e}function Sy(n,t,e){return!!(t.details&&(e.endCC>e.startCC||n&&n.cc<e.startCC))}function Ry(n,t,e=0){const i=n.fragments,s=t.fragments;if(!s.length||!i.length){z.log("No fragments to align");return}const o=B0(i,s[0].cc);if(!o||o&&!o.startPTS){z.log("No frag in previous level to align on");return}return o}function G0(n,t){if(n){const e=n.start+t;n.start=n.startPTS=e,n.endPTS=e+n.duration}}function Cc(n,t){const e=t.fragments;for(let i=0,s=e.length;i<s;i++)G0(e[i],n);t.fragmentHint&&G0(t.fragmentHint,n),t.alignedSliding=!0}function _y(n,t,e){t&&(Ly(n,e,t),!e.alignedSliding&&t.details&&Cy(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&I0(t.details,e))}function Ly(n,t,e){if(Sy(n,e,t)){const i=Ry(e.details,t);i&&Vt(i.start)&&(z.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),Cc(i.start,t))}}function Cy(n,t){if(!t.fragments.length||!n.hasProgramDateTime||!t.hasProgramDateTime)return;const e=t.fragments[0].programDateTime,i=n.fragments[0].programDateTime,s=(i-e)/1e3+t.fragments[0].start;s&&Vt(s)&&(z.log(`Adjusting PTS using programDateTime delta ${i-e}ms, sliding:${s.toFixed(3)} ${n.url} `),Cc(s,n))}function H0(n,t){if(!n.hasProgramDateTime||!t.hasProgramDateTime)return;const e=n.fragments,i=t.fragments;if(!e.length||!i.length)return;const s=Math.round(i.length/2)-1,o=i[s],c=B0(e,o.cc)||e[Math.round(e.length/2)-1],d=o.programDateTime,f=c.programDateTime;if(d===null||f===null)return;const p=(f-d)/1e3-(c.start-o.start);Cc(p,n)}class Iy{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 xy{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 Dy(n){const t=n.byteLength,e=t&&new DataView(n.buffer).getUint8(t-1);return e?on(n,0,t-e):n}class Py{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],o=i[1],c=i[2],d=i[3],f=this.invSubMix,p=f[0],g=f[1],v=f[2],b=f[3],E=new Uint32Array(256);let T=0,w=0,_=0;for(_=0;_<256;_++)_<128?E[_]=_<<1:E[_]=_<<1^283;for(_=0;_<256;_++){let D=w^w<<1^w<<2^w<<3^w<<4;D=D>>>8^D&255^99,t[T]=D,e[D]=T;const M=E[T],F=E[M],x=E[F];let N=E[D]*257^D*16843008;s[T]=N<<24|N>>>8,o[T]=N<<16|N>>>16,c[T]=N<<8|N>>>24,d[T]=N,N=x*16843009^F*65537^M*257^T*16843008,p[D]=N<<24|N>>>8,g[D]=N<<16|N>>>16,v[D]=N<<8|N>>>24,b[D]=N,T?(T=M^E[E[E[x^M]]],w^=E[E[w]]):T=w=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 o=this.keySize=e.length;if(o!==4&&o!==6&&o!==8)throw new Error("Invalid aes key size="+o);const c=this.ksRows=(o+6+1)*4;let d,f;const p=this.keySchedule=new Uint32Array(c),g=this.invKeySchedule=new Uint32Array(c),v=this.sBox,b=this.rcon,E=this.invSubMix,T=E[0],w=E[1],_=E[2],D=E[3];let M,F;for(d=0;d<c;d++){if(d<o){M=p[d]=e[d];continue}F=M,d%o===0?(F=F<<8|F>>>24,F=v[F>>>24]<<24|v[F>>>16&255]<<16|v[F>>>8&255]<<8|v[F&255],F^=b[d/o|0]<<24):o>6&&d%o===4&&(F=v[F>>>24]<<24|v[F>>>16&255]<<16|v[F>>>8&255]<<8|v[F&255]),p[d]=M=(p[d-o]^F)>>>0}for(f=0;f<c;f++)d=c-f,f&3?F=p[d]:F=p[d-4],f<4||d<=4?g[f]=F:g[f]=T[v[F>>>24]]^w[v[F>>>16&255]]^_[v[F>>>8&255]]^D[v[F&255]],g[f]=g[f]>>>0}networkToHostOrderSwap(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24}decrypt(t,e,i){const s=this.keySize+6,o=this.invKeySchedule,c=this.invSBox,d=this.invSubMix,f=d[0],p=d[1],g=d[2],v=d[3],b=this.uint8ArrayToUint32Array_(i);let E=b[0],T=b[1],w=b[2],_=b[3];const D=new Int32Array(t),M=new Int32Array(D.length);let F,x,N,V,j,rt,nt,Q,Tt,gt,$t,Wt,H,J;const St=this.networkToHostOrderSwap;for(;e<D.length;){for(Tt=St(D[e]),gt=St(D[e+1]),$t=St(D[e+2]),Wt=St(D[e+3]),j=Tt^o[0],rt=Wt^o[1],nt=$t^o[2],Q=gt^o[3],H=4,J=1;J<s;J++)F=f[j>>>24]^p[rt>>16&255]^g[nt>>8&255]^v[Q&255]^o[H],x=f[rt>>>24]^p[nt>>16&255]^g[Q>>8&255]^v[j&255]^o[H+1],N=f[nt>>>24]^p[Q>>16&255]^g[j>>8&255]^v[rt&255]^o[H+2],V=f[Q>>>24]^p[j>>16&255]^g[rt>>8&255]^v[nt&255]^o[H+3],j=F,rt=x,nt=N,Q=V,H=H+4;F=c[j>>>24]<<24^c[rt>>16&255]<<16^c[nt>>8&255]<<8^c[Q&255]^o[H],x=c[rt>>>24]<<24^c[nt>>16&255]<<16^c[Q>>8&255]<<8^c[j&255]^o[H+1],N=c[nt>>>24]<<24^c[Q>>16&255]<<16^c[j>>8&255]<<8^c[rt&255]^o[H+2],V=c[Q>>>24]<<24^c[j>>16&255]<<16^c[rt>>8&255]<<8^c[nt&255]^o[H+3],M[e]=St(F^E),M[e+1]=St(V^T),M[e+2]=St(N^w),M[e+3]=St(x^_),E=Tt,T=gt,w=$t,_=Wt,e=e+4}return M.buffer}}const Oy=16;class Ic{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?Dy(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,o)=>{this.softwareDecrypt(new Uint8Array(t),e,i);const c=this.flush();c?s(c.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,i)}softwareDecrypt(t,e,i){const{currentIV:s,currentResult:o,remainderData:c}=this;this.logOnce("JS AES decrypt"),c&&(t=ln(c,t),this.remainderData=null);const d=this.getValidChunk(t);if(!d.length)return null;s&&(i=s);let f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new Py),f.expandKey(e);const p=o;return this.currentResult=f.decrypt(d.buffer,0,i),this.currentIV=on(d,-16).buffer,p||null}webCryptoDecrypt(t,e,i){const s=this.subtle;return(this.key!==e||!this.fastAesKey)&&(this.key=e,this.fastAesKey=new xy(s,e)),this.fastAesKey.expandKey().then(o=>s?(this.logOnce("WebCrypto AES decrypt"),new Iy(s,new Uint8Array(i)).decrypt(t.buffer,o)):Promise.reject(new Error("web crypto not initialized"))).catch(o=>(z.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${o.name}: ${o.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%Oy;return i!==t.length&&(e=on(t,0,i),this.remainderData=on(t,i)),e}logOnce(t){this.logEnabled&&(z.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const My={toString:function(n){let t="";const e=n.length;for(let i=0;i<e;i++)t+=`[${n.start(i).toFixed(3)}-${n.end(i).toFixed(3)}]`;return t}},kt={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 xc extends ky{constructor(t,e,i,s,o){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=kt.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=o,this.logPrefix=s,this.log=z.log.bind(z,`${s}:`),this.warn=z.warn.bind(z,`${s}:`),this.hls=t,this.fragmentLoader=new Ey(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new Ic(t.config),t.on(R.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=kt.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 o=i[i.length-1];return Me.isBuffered(this.media,o.start+o.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===kt.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:o}=this,c=i?i.currentTime:0,d=Me.bufferInfo(s||i,c,t.maxBufferHole);if(this.log(`media seeking to ${Vt(c)?c.toFixed(3):c}, state: ${o}`),this.state===kt.ENDED)this.resetLoadingState();else if(e){const f=t.maxFragLookUpTolerance,p=e.start-f,g=e.start+e.duration+f;if(!d.len||g<d.start||p>d.end){const v=c>g;(c<p||v)&&(v&&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(c,1/0,this.playlistType,!0),this.lastCurrentTime=c),!this.loadedmetadata&&!d.len&&(this.nextLoadPosition=this.startPosition=c),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=kt.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=o=>{if(this.fragContextChanged(t)){this.warn(`Fragment ${t.sn}${o.part?" p: "+o.part.index:""} of level ${t.level} was dropped during download.`),this.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,this._handleFragmentLoadProgress(o)};this._doFragLoad(t,e,i,s).then(o=>{if(!o)return;const c=this.state;if(this.fragContextChanged(t)){(c===kt.FRAG_LOADING||!this.fragCurrent&&c===kt.PARSING)&&(this.fragmentTracker.removeFragment(t),this.state=kt.IDLE);return}"payload"in o&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(R.FRAG_LOADED,o)),this._handleFragmentLoadComplete(o)}).catch(o=>{this.state===kt.STOPPED||this.state===kt.ERROR||(this.warn(o),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===ui.APPENDING){const s=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,s),c=Math.max(t.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(c)&&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)===ui.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(R.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:o}=i,c=t.decryptdata;if(o&&o.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){const d=self.performance.now();return this.decrypter.decrypt(new Uint8Array(o),c.key.buffer,c.iv.buffer).catch(f=>{throw s.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_DECRYPT_ERROR,fatal:!1,error:f,reason:f.message,frag:t}),f}).then(f=>{const p=self.performance.now();return s.trigger(R.FRAG_DECRYPTED,{frag:t,payload:f,stats:{tstart:d,tdecrypt:p}}),i.payload=f,i})}return i}).then(i=>{const{fragCurrent:s,hls:o,levels:c}=this;if(!c)throw new Error("init load aborted, missing levels");const d=t.stats;this.state=kt.IDLE,e.fragmentError=0,t.data=new Uint8Array(i.payload),d.parsing.start=d.buffering.start=self.performance.now(),d.parsing.end=d.buffering.end=self.performance.now(),i.frag===s&&o.trigger(R.FRAG_BUFFERED,{stats:d,frag:s,part:null,id:t.type}),this.tick()}).catch(i=>{this.state===kt.STOPPED||this.state===kt.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,o,c;const d=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===Jt.MAIN?"level":"track"} ${t.level} (frag:[${((i=t.startPTS)!=null?i:NaN).toFixed(3)}-${((s=t.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${d?My.toString(Me.getBuffered(d)):"(detached)"})`),this.state=kt.IDLE,d&&(!this.loadedmetadata&&t.type==Jt.MAIN&&d.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((c=this.fragPrevious)==null?void 0:c.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:i,part:s,partsLoaded:o}=t,c=!o||o.length===0||o.some(f=>!f),d=new Lc(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!c);e.flush(d)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,i=null,s){var o;const c=e==null?void 0:e.details;if(!this.levels||!c)throw new Error(`frag load aborted, missing level${c?"":" detail"}s`);let d=null;if(t.encrypted&&!((o=t.decryptdata)!=null&&o.key)?(this.log(`Loading key for ${t.sn} of [${c.startSN}-${c.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${t.level}`),this.state=kt.KEY_LOADING,this.fragCurrent=t,d=this.keyLoader.load(t).then(g=>{if(!this.fragContextChanged(g.frag))return this.hls.trigger(R.KEY_LOADED,g),this.state===kt.KEY_LOADING&&(this.state=kt.IDLE),g}),this.hls.trigger(R.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(d=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&c.encryptedFragments.length&&this.keyLoader.loadClear(t,c.encryptedFragments),i=Math.max(t.start,i||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){const g=c.partList;if(g&&s){i>t.end&&c.fragmentHint&&(t=c.fragmentHint);const v=this.getNextPart(g,t,i);if(v>-1){const b=g[v];this.log(`Loading part sn: ${t.sn} p: ${b.index} cc: ${t.cc} of playlist [${c.startSN}-${c.endSN}] parts [0-${v}-${g.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=b.start+b.duration,this.state=kt.FRAG_LOADING;let E;return d?E=d.then(T=>!T||this.fragContextChanged(T.frag)?null:this.doFragPartsLoad(t,b,e,s)).catch(T=>this.handleFragLoadError(T)):E=this.doFragPartsLoad(t,b,e,s).catch(T=>this.handleFragLoadError(T)),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:b,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):E}else if(!t.url||this.loadedEndOfParts(g,i))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${c?"of ["+c.startSN+"-"+c.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),Vt(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=kt.FRAG_LOADING;const f=this.config.progressive;let p;return f&&d?p=d.then(g=>!g||this.fragContextChanged(g==null?void 0:g.frag)?null:this.fragmentLoader.load(t,s)).catch(g=>this.handleFragLoadError(g)):p=Promise.all([this.fragmentLoader.load(t,f?s:void 0),d]).then(([g])=>(!f&&g&&s&&s(g),g)).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(R.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):p}doFragPartsLoad(t,e,i,s){return new Promise((o,c)=>{var d;const f=[],p=(d=i.details)==null?void 0:d.partList,g=v=>{this.fragmentLoader.loadPart(t,v,s).then(b=>{f[v.index]=b;const E=b.part;this.hls.trigger(R.FRAG_LOADED,b);const T=x0(i,t.sn,v.index+1)||D0(p,t.sn,v.index+1);if(T)g(T);else return o({frag:t,part:E,partsLoaded:f})}).catch(c)};g(e)})}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===ut.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(R.ERROR,e)}else this.hls.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==kt.PARSING){!this.fragCurrent&&this.state!==kt.STOPPED&&this.state!==kt.ERROR&&(this.state=kt.IDLE);return}const{frag:i,part:s,level:o}=e,c=self.performance.now();i.stats.parsing.end=c,s&&(s.stats.parsing.end=c),this.updateLevelTiming(i,s,o,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:i}=this,{level:s,sn:o,part:c}=t;if(!(e!=null&&e[s]))return this.warn(`Levels object was unset while buffering fragment ${o} of level ${s}. The current chunk will not be buffered.`),null;const d=e[s],f=c>-1?x0(d,o,c):null,p=f?f.fragment:dy(d,o,i);return p?(i&&i!==p&&(p.stats=i.stats),{frag:p,part:f,level:d}):null}bufferFragmentData(t,e,i,s,o){var c;if(!t||this.state!==kt.PARSING)return;const{data1:d,data2:f}=t;let p=d;if(d&&f&&(p=ln(d,f)),!((c=p)!=null&&c.length))return;const g={type:t.type,frag:e,part:i,chunkMeta:s,parent:e.type,data:p};if(this.hls.trigger(R.BUFFER_APPENDING,g),t.dropped&&t.independent&&!i){if(o)return;this.flushBufferGap(e)}}flushBufferGap(t){const e=this.media;if(!e)return;if(!Me.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}const i=e.currentTime,s=Me.bufferInfo(e,i,0),o=t.duration,c=Math.min(this.config.maxFragLookUpTolerance*2,o*.25),d=Math.max(Math.min(t.start-c,s.end-c),i+c);t.start-d>c&&this.flushMainBuffer(d,t.start)}getFwdBufferInfo(t,e){const i=this.getLoadPosition();return Vt(i)?this.getFwdBufferInfoAtPos(t,i,e):null}getFwdBufferInfoAtPos(t,e,i){const{config:{maxBufferHole:s}}=this,o=Me.bufferInfo(t,e,s);if(o.len===0&&o.nextStart!==void 0){const c=this.fragmentTracker.getBufferedFrag(e,i);if(c&&o.nextStart<c.end)return Me.bufferInfo(t,e,Math.max(o.nextStart,s))}return o}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=Jt.MAIN){const i=this.fragmentTracker.getAppendedFrag(t,Jt.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:o}=this,c=i[0].start;let d;if(e.live){const f=o.initialLiveManifestSize;if(s<f)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${f})`),null;!e.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(d=this.getInitialLiveFragment(e,i),this.startPosition=d?this.hls.liveSyncPosition||d.start:t)}else t<=c&&(d=i[0]);if(!d){const f=o.lowLatencyMode?e.partEnd:e.fragmentEnd;d=this.getFragmentAtPosition(t,f,e)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(t,e){const i=this.fragmentTracker.getState(t);return(i===ui.OK||i===ui.PARTIAL&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,i,s,o){const c=t.gap,d=this.getNextFragment(this.nextLoadPosition,e);if(d===null)return d;if(t=d,c&&t&&!t.gap&&i.nextStart){const f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s);if(f!==null&&i.len+f.len>=o)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,o=!1,c=!0;for(let d=0,f=t.length;d<f;d++){const p=t[d];if(c=c&&!p.independent,s>-1&&i<p.start)break;const g=p.loaded;g?s=-1:(o||p.independent||c)&&p.fragment===e&&(s=d),o=g}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=fy(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){const c=e[o-t.startSN];i.cc===c.cc&&(s=c,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=gy(e,i.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const o=this.hls.liveSyncPosition;o!==null&&(s=this.getFragmentAtPosition(o,this.bitrateTest?t.fragmentEnd:t.edge,t))}return s}getFragmentAtPosition(t,e,i){const{config:s}=this;let{fragPrevious:o}=this,{fragments:c,endSN:d}=i;const{fragmentHint:f}=i,p=s.maxFragLookUpTolerance,g=i.partList,v=!!(s.lowLatencyMode&&g!=null&&g.length&&f);v&&f&&!this.bitrateTest&&(c=c.concat(f),d=f.sn);let b;if(t<e){const E=t>e-p?0:p;b=_a(o,c,t,E)}else b=c[c.length-1];if(b){const E=b.sn-i.startSN,T=this.fragmentTracker.getState(b);if((T===ui.OK||T===ui.PARTIAL&&b.gap)&&(o=b),o&&b.sn===o.sn&&(!v||g[0].fragment.sn>b.sn)&&o&&b.level===o.level){const w=c[E+1];b.sn<d&&this.fragmentTracker.getState(w)!==ui.OK?b=w:b=null}}return b}synchronizeToLiveEdge(t){const{config:e,media:i}=this;if(!i)return;const s=this.hls.liveSyncPosition,o=i.currentTime,c=t.fragments[0].start,d=t.edge,f=o>=c-e.maxFragLookUpTolerance&&o<=d;if(s!==null&&i.duration>s&&(o<s||!f)){const p=e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!f&&i.readyState<4||o<d-p)&&(this.loadedmetadata||(this.nextLoadPosition=s),i.readyState&&(this.warn(`Playback: ${o.toFixed(3)} is located too far from the end of live sliding playlist: ${d}, reset currentTime to : ${s.toFixed(3)}`),i.currentTime=s))}}alignPlaylists(t,e){const{levels:i,levelLastLoaded:s,fragPrevious:o}=this,c=s!==null?i[s]:null,d=t.fragments.length;if(!d)return this.warn("No fragments in live playlist"),0;const f=t.fragments[0].start,p=!e,g=t.alignedSliding&&Vt(f);if(p||!g&&!f){_y(o,c,t);const v=t.fragments[0].start;return this.log(`Live playlist sliding: ${v.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} prev-sn: ${o?o.sn:"na"} fragments: ${d}`),v}return f}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,o=s?this.startTimeOffset:t.startTimeOffset;o!==null&&Vt(o)?(i=e+o,o<0&&(i+=t.totalduration),i=Math.min(Math.max(e,i),e+t.totalduration),this.log(`Start time offset ${o} 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!==kt.FRAG_LOADING_WAITING_RETRY)&&(this.state=kt.IDLE)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const v=this.getCurrentContext(e.chunkMeta);v&&(e.frag=v.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 o=e.details===ut.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(i,!0);const c=e.errorAction,{action:d,retryCount:f=0,retryConfig:p}=c||{};if(c&&d===Ri.RetryRequest&&p){var g;this.resetStartWhenNotLoaded((g=this.levelLastLoaded)!=null?g:i.level);const v=wc(p,f);this.warn(`Fragment ${i.sn} of ${t} ${i.level} errored with ${e.details}, retrying loading ${f+1}/${p.maxNumRetry} in ${v}ms`),c.resolved=!0,this.retryDate=self.performance.now()+v,this.state=kt.FRAG_LOADING_WAITING_RETRY}else p&&c?(this.resetFragmentErrors(t),f<p.maxNumRetry?o||(c.resolved=!0):z.warn(`${e.details} reached or exceeded max retry (${f})`)):(c==null?void 0:c.action)===Ri.SendAlternateToPenaltyBox?this.state=kt.WAITING_LEVEL:this.state=kt.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===kt.PARSING||this.state===kt.PARSED){const e=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,e),s=i&&i.len>.5;s&&this.reduceMaxBufferLength(i.len);const o=!s;return o&&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(),o}return!1}resetFragmentErrors(t){t===Jt.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==kt.STOPPED&&(this.state=kt.IDLE)}afterBufferFlushed(t,e,i){if(!t)return;const s=Me.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,s,i),this.state===kt.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=kt.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 o;const c=i.details;if(!c){this.warn("level.details undefined");return}if(Object.keys(t.elementaryStreams).reduce((d,f)=>{const p=t.elementaryStreams[f];if(p){const g=p.endPTS-p.startPTS;if(g<=0)return this.warn(`Could not parse fragment ${t.sn} ${f} duration reliably (${g})`),d||!1;const v=s?0:C0(c,t,p.startPTS,p.endPTS,p.startDTS,p.endDTS);return this.hls.trigger(R.LEVEL_PTS_UPDATED,{details:c,level:i,drift:v,type:f,frag:t,start:p.startPTS,end:p.endPTS}),!0}return d},!1))i.fragmentError=0;else if(((o=this.transmuxer)==null?void 0:o.error)===null){const d=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(d.message),this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:d,frag:t,reason:`Found no media in msn ${t.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=kt.PARSED,this.hls.trigger(R.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 V0(){return self.SourceBuffer||self.WebKitSourceBuffer}function $y(){const n=So();if(!n)return!1;const t=V0(),e=n&&typeof n.isTypeSupported=="function"&&n.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 Ny(){var n;const t=V0();return typeof(t==null||(n=t.prototype)==null?void 0:n.changeType)=="function"}function Fy(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Uy(){const n=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(n);return{worker:new self.Worker(t),objectURL:t}}function By(n){const t=new self.URL(n,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}function Mr(n="",t=9e4){return{type:n,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class W0{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=ln(this.cachedData,t),this.cachedData=null);let i=Eo(t,0),s=i?i.length:0,o;const c=this._audioTrack,d=this._id3Track,f=i?Tv(i):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&Vt(f))&&(this.basePTS=Gy(f,e,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ar.audioId3,duration:Number.POSITIVE_INFINITY});s<p;){if(this.canParse(t,s)){const g=this.appendFrame(c,t,s);g?(this.frameIndex++,this.lastPTS=g.sample.pts,s+=g.length,o=s):s=p}else Ev(t,s)?(i=Eo(t,s),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ar.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,o=s):s++;if(s===p&&o!==p){const g=on(t,o);this.cachedData?this.cachedData=ln(this.cachedData,g):this.cachedData=g}}return{audioTrack:c,videoTrack:Mr(),id3Track:d,textTrack:Mr()}}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:Mr(),id3Track:this._id3Track,textTrack:Mr()}}destroy(){}}const Gy=(n,t,e)=>{if(Vt(n))return n*90;const i=e?e.baseTime*9e4/e.timescale:0;return t*9e4+i};function Hy(n,t,e,i){let s,o,c,d;const f=navigator.userAgent.toLowerCase(),p=i,g=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((t[e+2]&192)>>>6)+1;const v=(t[e+2]&60)>>>2;if(v>g.length-1){n.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${v}`});return}return c=(t[e+2]&1)<<2,c|=(t[e+3]&192)>>>6,z.log(`manifest codec:${i}, ADTS type:${s}, samplingIndex:${v}`),/firefox/i.test(f)?v>=6?(s=5,d=new Array(4),o=v-3):(s=2,d=new Array(2),o=v):f.indexOf("android")!==-1?(s=2,d=new Array(2),o=v):(s=5,d=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&v>=6?o=v-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(v>=6&&c===1||/vivaldi/i.test(f))||!i&&c===1)&&(s=2,d=new Array(2)),o=v)),d[0]=s<<3,d[0]|=(v&14)>>1,d[1]|=(v&1)<<7,d[1]|=c<<3,s===5&&(d[1]|=(o&14)>>1,d[2]=(o&1)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:g[v],channelCount:c,codec:"mp4a.40."+s,manifestCodec:p}}function j0(n,t){return n[t]===255&&(n[t+1]&246)===240}function K0(n,t){return n[t+1]&1?7:9}function Dc(n,t){return(n[t+3]&3)<<11|n[t+4]<<3|(n[t+5]&224)>>>5}function Vy(n,t){return t+5<n.length}function Do(n,t){return t+1<n.length&&j0(n,t)}function Wy(n,t){return Vy(n,t)&&j0(n,t)&&Dc(n,t)<=n.length-t}function jy(n,t){if(Do(n,t)){const e=K0(n,t);if(t+e>=n.length)return!1;const i=Dc(n,t);if(i<=e)return!1;const s=t+i;return s===n.length||Do(n,s)}return!1}function Y0(n,t,e,i,s){if(!n.samplerate){const o=Hy(t,e,i,s);if(!o)return;n.config=o.config,n.samplerate=o.samplerate,n.channelCount=o.channelCount,n.codec=o.codec,n.manifestCodec=o.manifestCodec,z.log(`parsed codec:${n.codec}, rate:${o.samplerate}, channels:${o.channelCount}`)}}function z0(n){return 9216e4/n}function Ky(n,t){const e=K0(n,t);if(t+e<=n.length){const i=Dc(n,t)-e;if(i>0)return{headerLength:e,frameLength:i}}}function X0(n,t,e,i,s){const o=z0(n.samplerate),c=i+s*o,d=Ky(t,e);let f;if(d){const{frameLength:g,headerLength:v}=d,b=v+g,E=Math.max(0,e+b-t.length);E?(f=new Uint8Array(b-v),f.set(t.subarray(e+v,t.length),0)):f=t.subarray(e+v,e+b);const T={unit:f,pts:c};return E||n.samples.push(T),{sample:T,length:b,missing:E}}const p=t.length-e;return f=new Uint8Array(p),f.set(t.subarray(e,t.length),0),{sample:{unit:f,pts:c},length:p,missing:-1}}class Yy extends W0{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=(Eo(t,0)||[]).length;for(let i=t.length;e<i;e++)if(jy(t,e))return z.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return Wy(t,e)}appendFrame(t,e,i){Y0(t,this.observer,e,i,t.manifestCodec);const s=X0(t,e,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const zy=/\/emsg[-/]ID3/i;class Xy{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 o=this.videoTrack=Mr("video",1),c=this.audioTrack=Mr("audio",1),d=this.txtTrack=Mr("text",1);if(this.id3Track=Mr("id3",1),this.timeOffset=0,!(t!=null&&t.byteLength))return;const f=o0(t);if(f.video){const{id:p,timescale:g,codec:v}=f.video;o.id=p,o.timescale=d.timescale=g,o.codec=v}if(f.audio){const{id:p,timescale:g,codec:v}=f.audio;c.id=p,c.timescale=g,c.codec=v}d.id=s0.text,o.sampleDuration=0,o.duration=c.duration=s}resetContiguity(){this.remainderData=null}static probe(t){return t=t.length>16384?t.subarray(0,16384):t,ye(t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let i=t;const s=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=ln(this.remainderData,t));const d=Nv(i);this.remainderData=d.remainder,s.samples=d.valid||new Uint8Array}else s.samples=i;const c=this.extractID3Track(s,e);return o.samples=c0(e,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:c,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=c0(t,e),{videoTrack:e,audioTrack:Mr(),id3Track:s,textTrack:Mr()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const s=ye(t.samples,["emsg"]);s&&s.forEach(o=>{const c=Bv(o);if(zy.test(c.schemeIdUri)){const d=Vt(c.presentationTime)?c.presentationTime/c.timeScale:e+c.presentationTimeDelta/c.timeScale;let f=c.eventDuration===4294967295?Number.POSITIVE_INFINITY:c.eventDuration/c.timeScale;f<=.001&&(f=Number.POSITIVE_INFINITY);const p=c.payload;i.samples.push({data:p,len:p.byteLength,dts:d,pts:d,type:Ar.emsg,duration:f})}})}return i}demuxSampleAes(t,e,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}let Po=null;const Zy=[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],qy=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Qy=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Jy=[0,1,1,4];function Z0(n,t,e,i,s){if(e+24>t.length)return;const o=q0(t,e);if(o&&e+o.frameLength<=t.length){const c=o.samplesPerFrame*9e4/o.sampleRate,d=i+s*c,f={unit:t.subarray(e,e+o.frameLength),pts:d,dts:d};return n.config=[],n.channelCount=o.channelCount,n.samplerate=o.sampleRate,n.samples.push(f),{sample:f,length:o.frameLength,missing:0}}}function q0(n,t){const e=n[t+1]>>3&3,i=n[t+1]>>1&3,s=n[t+2]>>4&15,o=n[t+2]>>2&3;if(e!==1&&s!==0&&s!==15&&o!==3){const c=n[t+2]>>1&1,d=n[t+3]>>6,f=e===3?3-i:i===3?3:4,p=Zy[f*14+s-1]*1e3,g=qy[(e===3?0:e===2?1:2)*3+o],v=d===3?1:2,b=Qy[e][i],E=Jy[i],T=b*8*E,w=Math.floor(b*p/g+c)*E;if(Po===null){const _=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Po=_?parseInt(_[1]):0}return Po&&Po<=87&&i===2&&p>=224e3&&d===0&&(n[t+3]=n[t+3]|128),{sampleRate:g,channelCount:v,frameLength:w,samplesPerFrame:T}}}function Pc(n,t){return n[t]===255&&(n[t+1]&224)===224&&(n[t+1]&6)!==0}function Q0(n,t){return t+1<n.length&&Pc(n,t)}function tb(n,t){return Pc(n,t)&&4<=n.length-t}function eb(n,t){if(t+1<n.length&&Pc(n,t)){const e=q0(n,t);let i=4;e!=null&&e.frameLength&&(i=e.frameLength);const s=t+i;return s===n.length||Q0(n,s)}return!1}class J0{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),o=Math.min(4,e);if(o===0)throw new Error("no bytes available");s.set(t.subarray(i,i+o)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=o*8,this.bytesAvailable-=o}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&&z.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 o=0;o<t;o++)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,o,c,d;const f=this.readUByte.bind(this),p=this.readBits.bind(this),g=this.readUEG.bind(this),v=this.readBoolean.bind(this),b=this.skipBits.bind(this),E=this.skipEG.bind(this),T=this.skipUEG.bind(this),w=this.skipScalingList.bind(this);f();const _=f();if(p(5),b(3),f(),T(),_===100||_===110||_===122||_===244||_===44||_===83||_===86||_===118||_===128){const V=g();if(V===3&&b(1),T(),T(),b(1),v())for(c=V!==3?8:12,d=0;d<c;d++)v()&&(d<6?w(16):w(64))}T();const D=g();if(D===0)g();else if(D===1)for(b(1),E(),E(),o=g(),d=0;d<o;d++)E();T(),b(1);const M=g(),F=g(),x=p(1);x===0&&b(1),b(1),v()&&(t=g(),e=g(),i=g(),s=g());let N=[1,1];if(v()&&v())switch(f()){case 1:N=[1,1];break;case 2:N=[12,11];break;case 3:N=[10,11];break;case 4:N=[16,11];break;case 5:N=[40,33];break;case 6:N=[24,11];break;case 7:N=[20,11];break;case 8:N=[32,11];break;case 9:N=[80,33];break;case 10:N=[18,11];break;case 11:N=[15,11];break;case 12:N=[64,33];break;case 13:N=[160,99];break;case 14:N=[4,3];break;case 15:N=[3,2];break;case 16:N=[2,1];break;case 255:{N=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil((M+1)*16-t*2-e*2),height:(2-x)*(F+1)*16-(x?2:4)*(i+s),pixelRatio:N}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class ib{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Ic(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 o=s.subarray(16,s.length-s.length%16),c=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(c).then(d=>{const f=new Uint8Array(d);s.set(f,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 o=32;o<t.length-16;o+=160,s+=16)i.set(t.subarray(o,o+16),s);return i}getAvcDecryptedUnit(t,e){const i=new Uint8Array(e);let s=0;for(let o=32;o<t.length-16;o+=160,s+=16)t.set(i.subarray(s,s+16),o);return t}decryptAvcSample(t,e,i,s,o){const c=d0(o.data),d=this.getAvcEncryptedData(c);this.decryptBuffer(d.buffer).then(f=>{o.data=this.getAvcDecryptedUnit(c,f),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 o=t[e].units;for(;!(i>=o.length);i++){const c=o[i];if(!(c.data.length<=48||c.type!==1&&c.type!==5)&&(this.decryptAvcSample(t,e,i,s,c),!this.decrypter.isSync()))return}}}}const _i=188;class Es{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=Es.syncOffset(t);return e>0&&z.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),e!==-1}static syncOffset(t){const e=t.length;let i=Math.min(_i*5,t.length-_i)+1,s=0;for(;s<i;){let o=!1,c=-1,d=0;for(let f=s;f<e;f+=_i)if(t[f]===71){if(d++,c===-1&&(c=f,c!==0&&(i=Math.min(c+_i*99,t.length-_i)+1)),o||(o=Oc(t,f)===0),o&&d>1&&(c===0&&d>2||f+_i>i))return c}else{if(d)return-1;break}s++}return-1}static createTrack(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:s0[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=Es.createTrack("video"),this._audioTrack=Es.createTrack("audio",s),this._id3Track=Es.createTrack("id3"),this._txtTrack=Es.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 o;const c=this._avcTrack,d=this._audioTrack,f=this._id3Track,p=this._txtTrack;let g=c.pid,v=c.pesData,b=d.pid,E=f.pid,T=d.pesData,w=f.pesData,_=null,D=this.pmtParsed,M=this._pmtId,F=t.length;if(this.remainderData&&(t=ln(this.remainderData,t),F=t.length,this.remainderData=null),F<_i&&!s)return this.remainderData=t,{audioTrack:d,videoTrack:c,id3Track:f,textTrack:p};const x=Math.max(0,Es.syncOffset(t));F-=(F-x)%_i,F<t.byteLength&&!s&&(this.remainderData=new Uint8Array(t.buffer,F,t.buffer.byteLength-F));let N=0;for(let j=x;j<F;j+=_i)if(t[j]===71){const rt=!!(t[j+1]&64),nt=Oc(t,j),Q=(t[j+3]&48)>>4;let Tt;if(Q>1){if(Tt=j+5+t[j+4],Tt===j+_i)continue}else Tt=j+4;switch(nt){case g:rt&&(v&&(o=Ln(v))&&this.parseAVCPES(c,p,o,!1),v={data:[],size:0}),v&&(v.data.push(t.subarray(Tt,j+_i)),v.size+=j+_i-Tt);break;case b:if(rt){if(T&&(o=Ln(T)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,o);break;case"mp3":this.parseMPEGPES(d,o);break}T={data:[],size:0}}T&&(T.data.push(t.subarray(Tt,j+_i)),T.size+=j+_i-Tt);break;case E:rt&&(w&&(o=Ln(w))&&this.parseID3PES(f,o),w={data:[],size:0}),w&&(w.data.push(t.subarray(Tt,j+_i)),w.size+=j+_i-Tt);break;case 0:rt&&(Tt+=t[Tt]+1),M=this._pmtId=rb(t,Tt);break;case M:{rt&&(Tt+=t[Tt]+1);const gt=sb(t,Tt,this.typeSupported,i);g=gt.avc,g>0&&(c.pid=g),b=gt.audio,b>0&&(d.pid=b,d.segmentCodec=gt.segmentCodec),E=gt.id3,E>0&&(f.pid=E),_!==null&&!D&&(z.warn(`MPEG-TS PMT found at ${j} after unknown PID '${_}'. Backtracking to sync byte @${x} to parse all TS packets.`),_=null,j=x-188),D=this.pmtParsed=!0;break}case 17:case 8191:break;default:_=nt;break}}else N++;if(N>0){const j=new Error(`Found ${N} TS packet/s that do not start with 0x47`);this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:j,reason:j.message})}c.pesData=v,d.pesData=T,f.pesData=w;const V={audioTrack:d,videoTrack:c,id3Track:f,textTrack:p};return s&&this.extractRemainingSamples(V),V}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:o}=t,c=i.pesData,d=e.pesData,f=s.pesData;let p;if(c&&(p=Ln(c))?(this.parseAVCPES(i,o,p,!0),i.pesData=null):i.pesData=c,d&&(p=Ln(d))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,p);break;case"mp3":this.parseMPEGPES(e,p);break}e.pesData=null}else d!=null&&d.size&&z.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=d;f&&(p=Ln(f))?(this.parseID3PES(s,p),s.pesData=null):s.pesData=f}demuxSampleAes(t,e,i){const s=this.demux(t,i,!0,!this.config.progressive),o=this.sampleAes=new ib(this.observer,this.config,e);return this.decrypt(s,o)}decrypt(t,e){return new Promise(i=>{const{audioTrack:s,videoTrack:o}=t;s.samples&&s.segmentCodec==="aac"?e.decryptAacSamples(s.samples,0,()=>{o.samples?e.decryptAvcSamples(o.samples,0,0,()=>{i(t)}):i(t)}):o.samples&&e.decryptAvcSamples(o.samples,0,0,()=>{i(t)})})}destroy(){this._duration=0}parseAVCPES(t,e,i,s){const o=this.parseAVCNALu(t,i.data);let c=this.avcSample,d,f=!1;i.data=null,c&&o.length&&!t.audFound&&(La(c,t),c=this.avcSample=Oo(!1,i.pts,i.dts,"")),o.forEach(p=>{var g;switch(p.type){case 1:{let b=!1;d=!0;const E=p.data;if(f&&E.length>4){const T=new J0(E).readSliceType();(T===2||T===4||T===7||T===9)&&(b=!0)}if(b){var v;(v=c)!=null&&v.frame&&!c.key&&(La(c,t),c=this.avcSample=null)}c||(c=this.avcSample=Oo(!0,i.pts,i.dts,"")),c.frame=!0,c.key=b;break}case 5:d=!0,(g=c)!=null&&g.frame&&!c.key&&(La(c,t),c=this.avcSample=null),c||(c=this.avcSample=Oo(!0,i.pts,i.dts,"")),c.key=!0,c.frame=!0;break;case 6:{d=!0,h0(p.data,1,i.pts,e.samples);break}case 7:if(d=!0,f=!0,!t.sps){const b=p.data,E=new J0(b).readSPS();t.width=E.width,t.height=E.height,t.pixelRatio=E.pixelRatio,t.sps=[b],t.duration=this._duration;const T=b.subarray(1,4);let w="avc1.";for(let _=0;_<3;_++){let D=T[_].toString(16);D.length<2&&(D="0"+D),w+=D}t.codec=w}break;case 8:d=!0,t.pps||(t.pps=[p.data]);break;case 9:d=!1,t.audFound=!0,c&&La(c,t),c=this.avcSample=Oo(!1,i.pts,i.dts,"");break;case 12:d=!0;break;default:d=!1,c&&(c.debug+="unknown NAL "+p.type+" ");break}c&&d&&c.units.push(p)}),s&&c&&(La(c,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 o=i.units;s=o[o.length-1]}return s}parseAVCNALu(t,e){const i=e.byteLength;let s=t.naluState||0;const o=s,c=[];let d=0,f,p,g,v=-1,b=0;for(s===-1&&(v=0,b=e[0]&31,s=0,d=1);d<i;){if(f=e[d++],!s){s=f?0:1;continue}if(s===1){s=f?0:2;continue}if(!f)s=3;else if(f===1){if(v>=0){const E={data:e.subarray(v,d-s-1),type:b};c.push(E)}else{const E=this.getLastNalUnit(t.samples);if(E&&(o&&d<=4-o&&E.state&&(E.data=E.data.subarray(0,E.data.byteLength-o)),p=d-s-1,p>0)){const T=new Uint8Array(E.data.byteLength+p);T.set(E.data,0),T.set(e.subarray(0,p),E.data.byteLength),E.data=T,E.state=0}}d<i?(g=e[d]&31,v=d,b=g,s=0):s=-1}else s=0}if(v>=0&&s>=0){const E={data:e.subarray(v,i),type:b,state:s};c.push(E)}if(c.length===0){const E=this.getLastNalUnit(t.samples);if(E){const T=new Uint8Array(E.data.byteLength+e.byteLength);T.set(E.data,0),T.set(e,E.data.byteLength),E.data=T}}return t.naluState=s,c}parseAACPES(t,e){let i=0;const s=this.aacOverFlow;let o=e.data;if(s){this.aacOverFlow=null;const v=s.missing,b=s.sample.unit.byteLength;if(v===-1){const E=new Uint8Array(b+o.byteLength);E.set(s.sample.unit,0),E.set(o,b),o=E}else{const E=b-v;s.sample.unit.set(o.subarray(0,v),E),t.samples.push(s.sample),i=s.missing}}let c,d;for(c=i,d=o.length;c<d-1&&!Do(o,c);c++);if(c!==i){let v;const b=c<d-1;b?v=`AAC PES did not start with ADTS header,offset:${c}`:v="No ADTS header found in AAC PES";const E=new Error(v);if(z.warn(`parsing error: ${v}`),this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,levelRetry:b,error:E,reason:v}),!b)return}Y0(t,this.observer,o,c,this.audioCodec);let f;if(e.pts!==void 0)f=e.pts;else if(s){const v=z0(t.samplerate);f=s.sample.pts+v}else{z.warn("[tsdemuxer]: AAC PES unknown PTS");return}let p=0,g;for(;c<d;)if(g=X0(t,o,c,f,p),c+=g.length,g.missing){this.aacOverFlow=g;break}else for(p++;c<d-1&&!Do(o,c);c++);}parseMPEGPES(t,e){const i=e.data,s=i.length;let o=0,c=0;const d=e.pts;if(d===void 0){z.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;c<s;)if(Q0(i,c)){const f=Z0(t,i,c,d,o);if(f)c+=f.length,o++;else break}else c++}parseID3PES(t,e){if(e.pts===void 0){z.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=ai({},e,{type:this._avcTrack?Ar.emsg:Ar.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function Oo(n,t,e,i){return{key:n,frame:!1,pts:t,dts:e,units:[],debug:i,length:0}}function Oc(n,t){return((n[t+1]&31)<<8)+n[t+2]}function rb(n,t){return(n[t+10]&31)<<8|n[t+11]}function sb(n,t,e,i){const s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},o=(n[t+1]&15)<<8|n[t+2],c=t+3+o-4,d=(n[t+10]&15)<<8|n[t+11];for(t+=12+d;t<c;){const f=Oc(n,t);switch(n[t]){case 207:if(!i){z.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:s.audio===-1&&(s.audio=f);break;case 21:s.id3===-1&&(s.id3=f);break;case 219:if(!i){z.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:s.avc===-1&&(s.avc=f);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?z.log("MPEG audio found, not supported in this browser"):s.audio===-1&&(s.audio=f,s.segmentCodec="mp3");break;case 36:z.warn("Unsupported HEVC stream type found");break}t+=((n[t+3]&15)<<8|n[t+4])+5}return s}function Ln(n){let t=0,e,i,s,o,c;const d=n.data;if(!n||n.size===0)return null;for(;d[0].length<19&&d.length>1;){const f=new Uint8Array(d[0].length+d[1].length);f.set(d[0]),f.set(d[1],d[0].length),d[0]=f,d.splice(1,1)}if(e=d[0],(e[0]<<16)+(e[1]<<8)+e[2]===1){if(i=(e[4]<<8)+e[5],i&&i>n.size-6)return null;const f=e[7];f&192&&(o=(e[9]&14)*536870912+(e[10]&255)*4194304+(e[11]&254)*16384+(e[12]&255)*128+(e[13]&254)/2,f&64?(c=(e[14]&14)*536870912+(e[15]&255)*4194304+(e[16]&254)*16384+(e[17]&255)*128+(e[18]&254)/2,o-c>54e5&&(z.warn(`${Math.round((o-c)/9e4)}s delta between PTS and DTS, align them`),o=c)):c=o),s=e[8];let p=s+9;if(n.size<=p)return null;n.size-=p;const g=new Uint8Array(n.size);for(let v=0,b=d.length;v<b;v++){e=d[v];let E=e.byteLength;if(p)if(p>E){p-=E;continue}else e=e.subarray(p),E-=p,p=0;g.set(e,t),t+=E}return i&&(i-=s+3),{data:g,pts:o,dts:c,len:i}}return null}function La(n,t){if(n.units.length&&n.frame){if(n.pts===void 0){const e=t.samples,i=e.length;if(i){const s=e[i-1];n.pts=s.pts,n.dts=s.dts}else{t.dropped++;return}}t.samples.push(n)}n.debug.length&&z.log(n.pts+"/"+n.dts+":"+n.debug)}class nb extends W0{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=(Eo(t,0)||[]).length;for(let i=t.length;e<i;e++)if(eb(t,e))return z.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return tb(t,e)}appendFrame(t,e,i){if(this.basePTS!==null)return Z0(t,e,i,this.basePTS,this.frameIndex)}}class tf{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 Ts=Math.pow(2,32)-1;class st{static init(){st.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 st.types)st.types.hasOwnProperty(t)&&(st.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]);st.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]),o=new Uint8Array([0,0,0,0,0,0,0,0]);st.STTS=st.STSC=st.STCO=o,st.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),st.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),st.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),st.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const c=new Uint8Array([105,115,111,109]),d=new Uint8Array([97,118,99,49]),f=new Uint8Array([0,0,0,1]);st.FTYP=st.box(st.types.ftyp,c,f,c,d),st.DINF=st.box(st.types.dinf,st.box(st.types.dref,s))}static box(t,...e){let i=8,s=e.length;const o=s;for(;s--;)i+=e[s].byteLength;const c=new Uint8Array(i);for(c[0]=i>>24&255,c[1]=i>>16&255,c[2]=i>>8&255,c[3]=i&255,c.set(t,4),s=0,i=8;s<o;s++)c.set(e[s],i),i+=e[s].byteLength;return c}static hdlr(t){return st.box(st.types.hdlr,st.HDLR_TYPES[t])}static mdat(t){return st.box(st.types.mdat,t)}static mdhd(t,e){e*=t;const i=Math.floor(e/(Ts+1)),s=Math.floor(e%(Ts+1));return st.box(st.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 st.box(st.types.mdia,st.mdhd(t.timescale,t.duration),st.hdlr(t.type),st.minf(t))}static mfhd(t){return st.box(st.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"?st.box(st.types.minf,st.box(st.types.smhd,st.SMHD),st.DINF,st.stbl(t)):st.box(st.types.minf,st.box(st.types.vmhd,st.VMHD),st.DINF,st.stbl(t))}static moof(t,e,i){return st.box(st.types.moof,st.mfhd(t),st.traf(i,e))}static moov(t){let e=t.length;const i=[];for(;e--;)i[e]=st.trak(t[e]);return st.box.apply(null,[st.types.moov,st.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(st.mvex(t)))}static mvex(t){let e=t.length;const i=[];for(;e--;)i[e]=st.trex(t[e]);return st.box.apply(null,[st.types.mvex,...i])}static mvhd(t,e){e*=t;const i=Math.floor(e/(Ts+1)),s=Math.floor(e%(Ts+1)),o=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 st.box(st.types.mvhd,o)}static sdtp(t){const e=t.samples||[],i=new Uint8Array(4+e.length);let s,o;for(s=0;s<e.length;s++)o=e[s].flags,i[s+4]=o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy;return st.box(st.types.sdtp,i)}static stbl(t){return st.box(st.types.stbl,st.stsd(t),st.box(st.types.stts,st.STTS),st.box(st.types.stsc,st.STSC),st.box(st.types.stsz,st.STSZ),st.box(st.types.stco,st.STCO))}static avc1(t){let e=[],i=[],s,o,c;for(s=0;s<t.sps.length;s++)o=t.sps[s],c=o.byteLength,e.push(c>>>8&255),e.push(c&255),e=e.concat(Array.prototype.slice.call(o));for(s=0;s<t.pps.length;s++)o=t.pps[s],c=o.byteLength,i.push(c>>>8&255),i.push(c&255),i=i.concat(Array.prototype.slice.call(o));const d=st.box(st.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|t.sps.length].concat(e).concat([t.pps.length]).concat(i))),f=t.width,p=t.height,g=t.pixelRatio[0],v=t.pixelRatio[1];return st.box(st.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,f>>8&255,f&255,p>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d,st.box(st.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),st.box(st.types.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,g&255,v>>24,v>>16&255,v>>8&255,v&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 st.box(st.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]),st.box(st.types.esds,st.esds(t)))}static mp3(t){const e=t.samplerate;return st.box(st.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"?st.box(st.types.stsd,st.STSD,st.mp3(t)):st.box(st.types.stsd,st.STSD,st.mp4a(t)):st.box(st.types.stsd,st.STSD,st.avc1(t))}static tkhd(t){const e=t.id,i=t.duration*t.timescale,s=t.width,o=t.height,c=Math.floor(i/(Ts+1)),d=Math.floor(i%(Ts+1));return st.box(st.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,c>>24,c>>16&255,c>>8&255,c&255,d>>24,d>>16&255,d>>8&255,d&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,o>>8&255,o&255,0,0]))}static traf(t,e){const i=st.sdtp(t),s=t.id,o=Math.floor(e/(Ts+1)),c=Math.floor(e%(Ts+1));return st.box(st.types.traf,st.box(st.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),st.box(st.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,c>>24,c>>16&255,c>>8&255,c&255])),st.trun(t,i.length+16+20+8+16+8+8),i)}static trak(t){return t.duration=t.duration||4294967295,st.box(st.types.trak,st.tkhd(t),st.mdia(t))}static trex(t){const e=t.id;return st.box(st.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,o=12+16*s,c=new Uint8Array(o);let d,f,p,g,v,b;for(e+=8+o,c.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),d=0;d<s;d++)f=i[d],p=f.duration,g=f.size,v=f.flags,b=f.cts,c.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,g>>>24&255,g>>>16&255,g>>>8&255,g&255,v.isLeading<<2|v.dependsOn,v.isDependedOn<<6|v.hasRedundancy<<4|v.paddingValue<<1|v.isNonSync,v.degradPrio&61440,v.degradPrio&15,b>>>24&255,b>>>16&255,b>>>8&255,b&255],12+16*d);return st.box(st.types.trun,c)}static initSegment(t){st.types||st.init();const e=st.moov(t),i=new Uint8Array(st.FTYP.byteLength+e.byteLength);return i.set(st.FTYP),i.set(e,st.FTYP.byteLength),i}}st.types=void 0,st.HDLR_TYPES=void 0,st.STTS=void 0,st.STSC=void 0,st.STCO=void 0,st.STSZ=void 0,st.VMHD=void 0,st.SMHD=void 0,st.STSD=void 0,st.FTYP=void 0,st.DINF=void 0;const ef=9e4;function Mc(n,t,e=1,i=!1){const s=n*t*e;return i?Math.round(s):s}function ab(n,t,e=1,i=!1){return Mc(n,t,1/e,i)}function Ca(n,t=!1){return Mc(n,1e3,1/ef,t)}function ob(n,t=1){return Mc(n,ef,1/t)}const lb=10*1e3,rf=1024,cb=1152;let Mo=null,$c=null;class Nc{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,Mo===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Mo=o?parseInt(o[1]):0}if($c===null){const o=navigator.userAgent.match(/Safari\/(\d+)/i);$c=o?parseInt(o[1]):0}}destroy(){}resetTimeStamp(t){z.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){z.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){z.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const i=t.reduce((s,o)=>{const c=o.pts-s;return c<-4294967296?(e=!0,hr(s,o.pts)):c>0?s:o.pts},t[0].pts);return e&&z.debug("PTS rollover detected"),i}remux(t,e,i,s,o,c,d,f){let p,g,v,b,E,T,w=o,_=o;const D=t.pid>-1,M=e.pid>-1,F=e.samples.length,x=t.samples.length>0,N=d&&F>0||F>1;if((!D||x)&&(!M||N)||this.ISGenerated||d){this.ISGenerated||(v=this.generateIS(t,e,o,c));const V=this.isVideoContiguous;let j=-1,rt;if(N&&(j=hb(e.samples),!V&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,j>0){z.warn(`[mp4-remuxer]: Dropped ${j} out of ${F} video samples due to a missing keyframe`);const nt=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(j),e.dropped+=j,_+=(e.samples[0].pts-nt)/e.inputTimeScale,rt=_}else j===-1&&(z.warn(`[mp4-remuxer]: No keyframe found out of ${F} video samples`),T=!1);if(this.ISGenerated){if(x&&N){const nt=this.getVideoStartPts(e.samples),Q=(hr(t.samples[0].pts,nt)-nt)/e.inputTimeScale;w+=Math.max(0,Q),_+=Math.max(0,-Q)}if(x){if(t.samplerate||(z.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),v=this.generateIS(t,e,o,c)),g=this.remuxAudio(t,w,this.isAudioContiguous,c,M||N||f===Jt.AUDIO?_:void 0),N){const nt=g?g.endPTS-g.startPTS:0;e.inputTimeScale||(z.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),v=this.generateIS(t,e,o,c)),p=this.remuxVideo(e,_,V,nt)}}else N&&(p=this.remuxVideo(e,_,V,0));p&&(p.firstKeyFrame=j,p.independent=j!==-1,p.firstKeyFramePTS=rt)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(E=sf(i,o,this._initPTS,this._initDTS)),s.samples.length&&(b=nf(s,o,this._initPTS))),{audio:g,video:p,initSegment:v,independent:T,text:b,id3:E}}generateIS(t,e,i,s){const o=t.samples,c=e.samples,d=this.typeSupported,f={},p=this._initPTS;let g=!p||s,v="audio/mp4",b,E,T;if(g&&(b=E=1/0),t.config&&o.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":d.mpeg?(v="audio/mpeg",t.codec=""):d.mp3&&(t.codec="mp3");break}f.audio={id:"audio",container:v,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&d.mpeg?new Uint8Array(0):st.initSegment([t]),metadata:{channelCount:t.channelCount}},g&&(T=t.inputTimeScale,!p||T!==p.timescale?b=E=o[0].pts-Math.round(T*i):g=!1)}if(e.sps&&e.pps&&c.length&&(e.timescale=e.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:st.initSegment([e]),metadata:{width:e.width,height:e.height}},g))if(T=e.inputTimeScale,!p||T!==p.timescale){const w=this.getVideoStartPts(c),_=Math.round(T*i);E=Math.min(E,hr(c[0].dts,w)-_),b=Math.min(b,w-_)}else g=!1;if(Object.keys(f).length)return this.ISGenerated=!0,g?(this._initPTS={baseTime:b,timescale:T},this._initDTS={baseTime:E,timescale:T}):b=T=void 0,{tracks:f,initPTS:b,timescale:T}}remuxVideo(t,e,i,s){const o=t.inputTimeScale,c=t.samples,d=[],f=c.length,p=this._initPTS;let g=this.nextAvcDts,v=8,b=this.videoSampleDuration,E,T,w=Number.POSITIVE_INFINITY,_=Number.NEGATIVE_INFINITY,D=!1;if(!i||g===null){const $=e*o,U=c[0].pts-hr(c[0].dts,c[0].pts);g=$-U}const M=p.baseTime*o/p.timescale;for(let $=0;$<f;$++){const U=c[$];U.pts=hr(U.pts-M,g),U.dts=hr(U.dts-M,g),U.dts<c[$>0?$-1:$].dts&&(D=!0)}D&&c.sort(function($,U){const X=$.dts-U.dts,mt=$.pts-U.pts;return X||mt}),E=c[0].dts,T=c[c.length-1].dts;const F=T-E,x=F?Math.round(F/(f-1)):b||t.inputTimeScale/30;if(i){const $=E-g,U=$>x,X=$<-1;if((U||X)&&(U?z.warn(`AVC: ${Ca($,!0)} ms (${$}dts) hole between fragments detected, filling it`):z.warn(`AVC: ${Ca(-$,!0)} ms (${$}dts) overlapping between fragments detected`),!X||g>=c[0].pts)){E=g;const mt=c[0].pts-$;c[0].dts=E,c[0].pts=mt,z.log(`Video: First PTS/DTS adjusted: ${Ca(mt,!0)}/${Ca(E,!0)}, delta: ${Ca($,!0)} ms`)}}E=Math.max(0,E);let N=0,V=0;for(let $=0;$<f;$++){const U=c[$],X=U.units,mt=X.length;let bt=0;for(let xt=0;xt<mt;xt++)bt+=X[xt].data.length;V+=bt,N+=mt,U.length=bt,U.dts=Math.max(U.dts,E),w=Math.min(U.pts,w),_=Math.max(U.pts,_)}T=c[f-1].dts;const j=V+4*N+8;let rt;try{rt=new Uint8Array(j)}catch($){this.observer.emit(R.ERROR,R.ERROR,{type:qt.MUX_ERROR,details:ut.REMUX_ALLOC_ERROR,fatal:!1,error:$,bytes:j,reason:`fail allocating video mdat ${j}`});return}const nt=new DataView(rt.buffer);nt.setUint32(0,j),rt.set(st.types.mdat,4);let Q=!1,Tt=Number.POSITIVE_INFINITY,gt=Number.POSITIVE_INFINITY,$t=Number.NEGATIVE_INFINITY,Wt=Number.NEGATIVE_INFINITY;for(let $=0;$<f;$++){const U=c[$],X=U.units;let mt=0;for(let Ut=0,Qt=X.length;Ut<Qt;Ut++){const ue=X[Ut],se=ue.data,zt=ue.data.byteLength;nt.setUint32(v,zt),v+=4,rt.set(se,v),v+=zt,mt+=4+zt}let bt;if($<f-1)b=c[$+1].dts-U.dts,bt=c[$+1].pts-U.pts;else{const Ut=this.config,Qt=$>0?U.dts-c[$-1].dts:x;if(bt=$>0?U.pts-c[$-1].pts:x,Ut.stretchShortVideoTrack&&this.nextAudioPts!==null){const ue=Math.floor(Ut.maxBufferHole*o),se=(s?w+s*o:this.nextAudioPts)-U.pts;se>ue?(b=se-Qt,b<0?b=Qt:Q=!0,z.log(`[mp4-remuxer]: It is approximately ${se/90} ms to the next segment; using duration ${b/90} ms for the last video frame.`)):b=Qt}else b=Qt}const xt=Math.round(U.pts-U.dts);Tt=Math.min(Tt,b),$t=Math.max($t,b),gt=Math.min(gt,bt),Wt=Math.max(Wt,bt),d.push(new af(U.key,b,mt,xt))}if(d.length){if(Mo){if(Mo<70){const $=d[0].flags;$.dependsOn=2,$.isNonSync=0}}else if($c&&Wt-gt<$t-Tt&&x/$t<.025&&d[0].cts===0){z.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let $=E;for(let U=0,X=d.length;U<X;U++){const mt=$+d[U].duration,bt=$+d[U].cts;if(U<X-1){const xt=mt+d[U+1].cts;d[U].duration=xt-bt}else d[U].duration=U?d[U-1].duration:x;d[U].cts=0,$=mt}}}b=Q||!b?x:b,this.nextAvcDts=g=T+b,this.videoSampleDuration=b,this.isVideoContiguous=!0;const H=st.moof(t.sequenceNumber++,E,ai({},t,{samples:d})),J="video",St={data1:H,data2:rt,startPTS:w/o,endPTS:(_+b)/o,startDTS:E/o,endDTS:g/o,type:J,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:t.dropped};return t.samples=[],t.dropped=0,St}remuxAudio(t,e,i,s,o){const c=t.inputTimeScale,d=t.samplerate?t.samplerate:c,f=c/d,p=t.segmentCodec==="aac"?rf:cb,g=p*f,v=this._initPTS,b=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,E=[],T=o!==void 0;let w=t.samples,_=b?0:8,D=this.nextAudioPts||-1;const M=e*c,F=v.baseTime*c/v.timescale;if(this.isAudioContiguous=i=i||w.length&&D>0&&(s&&Math.abs(M-D)<9e3||Math.abs(hr(w[0].pts-F,M)-D)<20*g),w.forEach(function(H){H.pts=hr(H.pts-F,M)}),!i||D<0){if(w=w.filter(H=>H.pts>=0),!w.length)return;o===0?D=0:s&&!T?D=Math.max(0,M):D=w[0].pts}if(t.segmentCodec==="aac"){const H=this.config.maxAudioFramesDrift;for(let J=0,St=D;J<w.length;J++){const $=w[J],U=$.pts,X=U-St,mt=Math.abs(1e3*X/c);if(X<=-H*g&&T)J===0&&(z.warn(`Audio frame @ ${(U/c).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*X/c)} ms.`),this.nextAudioPts=D=St=U);else if(X>=H*g&&mt<lb&&T){let bt=Math.round(X/g);St=U-bt*g,St<0&&(bt--,St+=g),J===0&&(this.nextAudioPts=D=St),z.warn(`[mp4-remuxer]: Injecting ${bt} audio frame @ ${(St/c).toFixed(3)}s due to ${Math.round(1e3*X/c)} ms gap.`);for(let xt=0;xt<bt;xt++){const Ut=Math.max(St,0);let Qt=tf.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);Qt||(z.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Qt=$.unit.subarray()),w.splice(J,0,{unit:Qt,pts:Ut}),St+=g,J++}}$.pts=St,St+=g}}let x=null,N=null,V,j=0,rt=w.length;for(;rt--;)j+=w[rt].unit.byteLength;for(let H=0,J=w.length;H<J;H++){const St=w[H],$=St.unit;let U=St.pts;if(N!==null){const mt=E[H-1];mt.duration=Math.round((U-N)/f)}else if(i&&t.segmentCodec==="aac"&&(U=D),x=U,j>0){j+=_;try{V=new Uint8Array(j)}catch(mt){this.observer.emit(R.ERROR,R.ERROR,{type:qt.MUX_ERROR,details:ut.REMUX_ALLOC_ERROR,fatal:!1,error:mt,bytes:j,reason:`fail allocating audio mdat ${j}`});return}b||(new DataView(V.buffer).setUint32(0,j),V.set(st.types.mdat,4))}else return;V.set($,_);const X=$.byteLength;_+=X,E.push(new af(!0,p,X,0)),N=U}const nt=E.length;if(!nt)return;const Q=E[E.length-1];this.nextAudioPts=D=N+f*Q.duration;const Tt=b?new Uint8Array(0):st.moof(t.sequenceNumber++,x/f,ai({},t,{samples:E}));t.samples=[];const gt=x/c,$t=D/c,Wt={data1:Tt,data2:V,startPTS:gt,endPTS:$t,startDTS:gt,endDTS:$t,type:"audio",hasAudio:!0,hasVideo:!1,nb:nt};return this.isAudioContiguous=!0,Wt}remuxEmptyAudio(t,e,i,s){const o=t.inputTimeScale,c=t.samplerate?t.samplerate:o,d=o/c,f=this.nextAudioPts,p=this._initDTS,g=p.baseTime*9e4/p.timescale,v=(f!==null?f:s.startDTS*o)+g,b=s.endDTS*o+g,E=d*rf,T=Math.ceil((b-v)/E),w=tf.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(z.warn("[mp4-remuxer]: remux empty Audio"),!w){z.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const _=[];for(let D=0;D<T;D++){const M=v+D*E;_.push({unit:w,pts:M,dts:M})}return t.samples=_,this.remuxAudio(t,e,i,!1)}}function hr(n,t){let e;if(t===null)return n;for(t<n?e=-8589934592:e=8589934592;Math.abs(n-t)>4294967296;)n+=e;return n}function hb(n){for(let t=0;t<n.length;t++)if(n[t].key)return t;return-1}function sf(n,t,e,i){const s=n.samples.length;if(!s)return;const o=n.inputTimeScale;for(let d=0;d<s;d++){const f=n.samples[d];f.pts=hr(f.pts-e.baseTime*o/e.timescale,t*o)/o,f.dts=hr(f.dts-i.baseTime*o/i.timescale,t*o)/o}const c=n.samples;return n.samples=[],{samples:c}}function nf(n,t,e){const i=n.samples.length;if(!i)return;const s=n.inputTimeScale;for(let c=0;c<i;c++){const d=n.samples[c];d.pts=hr(d.pts-e.baseTime*s/e.timescale,t*s)/s}n.samples.sort((c,d)=>c.pts-d.pts);const o=n.samples;return n.samples=[],{samples:o}}class af{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 db(t)}}class db{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 ub{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(Dv(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=o0(t);e||(e=of(s.audio,Le.AUDIO)),i||(i=of(s.video,Le.VIDEO));const o={};s.audio&&s.video?o.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:s.audio?o.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:s.video?o.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:z.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(t,e,i,s,o,c){var d,f;let{initPTS:p,lastEndTime:g}=this;const v={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};Vt(g)||(g=this.lastEndTime=o||0);const b=e.samples;if(!(b!=null&&b.length))return v;const E={initPTS:void 0,timescale:1};let T=this.initData;if((d=T)!=null&&d.length||(this.generateInitSegment(b),T=this.initData),!((f=T)!=null&&f.length))return z.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),v;this.emitInitSegment&&(E.tracks=this.initTracks,this.emitInitSegment=!1);const w=Ov(b,T),_=Pv(T,b),D=_===null?o:_;(fb(p,D,o,w)||E.timescale!==p.timescale&&c)&&(E.initPTS=D-o,p&&p.timescale===1&&z.warn(`Adjusting initPTS by ${E.initPTS-p.baseTime}`),this.initPTS=p={baseTime:E.initPTS,timescale:1});const M=t?D-p.baseTime/p.timescale:g,F=M+w;$v(T,b,p.baseTime/p.timescale),w>0?this.lastEndTime=F:(z.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const x=!!T.audio,N=!!T.video;let V="";x&&(V+="audio"),N&&(V+="video");const j={data1:b,startPTS:M,startDTS:M,endPTS:F,endDTS:F,type:V,hasAudio:x,hasVideo:N,nb:1,dropped:0};return v.audio=j.type==="audio"?j:void 0,v.video=j.type!=="audio"?j:void 0,v.initSegment=E,v.id3=sf(i,o,p,p),s.samples.length&&(v.text=nf(s,o,p)),v}}function fb(n,t,e,i){if(n===null)return!0;const s=Math.max(i,1),o=t-n.baseTime/n.timescale;return Math.abs(o-e)>s}function of(n,t){const e=n==null?void 0:n.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===Le.VIDEO?"avc1.42e01e":"mp4a.40.5"}let ts;try{ts=self.performance.now.bind(self.performance)}catch{z.debug("Unable to use Performance API on this environment"),ts=typeof self<"u"&&self.Date.now}const Fc=[{demux:Xy,remux:ub},{demux:Es,remux:Nc},{demux:Yy,remux:Nc},{demux:nb,remux:Nc}];class lf{constructor(t,e,i,s,o){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=o}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,i,s){const o=i.transmuxing;o.executeStart=ts();let c=new Uint8Array(t);const{currentTransmuxState:d,transmuxConfig:f}=this;s&&(this.currentTransmuxState=s);const{contiguous:p,discontinuity:g,trackSwitch:v,accurateTimeOffset:b,timeOffset:E,initSegmentChange:T}=s||d,{audioCodec:w,videoCodec:_,defaultInitPts:D,duration:M,initSegmentData:F}=f,x=pb(c,e);if(x&&x.method==="AES-128"){const rt=this.getDecrypter();if(rt.isSync()){let nt=rt.softwareDecrypt(c,x.key.buffer,x.iv.buffer);if(i.part>-1&&(nt=rt.flush()),!nt)return o.executeEnd=ts(),Uc(i);c=new Uint8Array(nt)}else return this.decryptionPromise=rt.webCryptoDecrypt(c,x.key.buffer,x.iv.buffer).then(nt=>{const Q=this.push(nt,null,i);return this.decryptionPromise=null,Q}),this.decryptionPromise}const N=this.needsProbing(g,v);if(N){const rt=this.configureTransmuxer(c);if(rt)return z.warn(`[transmuxer] ${rt.message}`),this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:rt,reason:rt.message}),o.executeEnd=ts(),Uc(i)}(g||v||T||N)&&this.resetInitSegment(F,w,_,M,e),(g||T||N)&&this.resetInitialTimestamp(D),p||this.resetContiguity();const V=this.transmux(c,x,E,b,i),j=this.currentTransmuxState;return j.contiguous=!0,j.discontinuity=!1,j.trackSwitch=!1,o.executeEnd=ts(),V}flush(t){const e=t.transmuxing;e.executeStart=ts();const{decrypter:i,currentTransmuxState:s,decryptionPromise:o}=this;if(o)return o.then(()=>this.flush(t));const c=[],{timeOffset:d}=s;if(i){const v=i.flush();v&&c.push(this.push(v,null,t))}const{demuxer:f,remuxer:p}=this;if(!f||!p)return e.executeEnd=ts(),[Uc(t)];const g=f.flush(d);return $o(g)?g.then(v=>(this.flushRemux(c,v,t),c)):(this.flushRemux(c,g,t),c)}flushRemux(t,e,i){const{audioTrack:s,videoTrack:o,id3Track:c,textTrack:d}=e,{accurateTimeOffset:f,timeOffset:p}=this.currentTransmuxState;z.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const g=this.remuxer.remux(s,o,c,d,p,f,!0,this.id);t.push({remuxResult:g,chunkMeta:i}),i.transmuxing.executeEnd=ts()}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,o){const{demuxer:c,remuxer:d}=this;!c||!d||(c.resetInitSegment(t,e,i,s),d.resetInitSegment(t,e,i,o))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,i,s,o){let c;return e&&e.method==="SAMPLE-AES"?c=this.transmuxSampleAes(t,e,i,s,o):c=this.transmuxUnencrypted(t,i,s,o),c}transmuxUnencrypted(t,e,i,s){const{audioTrack:o,videoTrack:c,id3Track:d,textTrack:f}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(o,c,d,f,e,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(t,e,i,s,o){return this.demuxer.demuxSampleAes(t,e,i).then(c=>({remuxResult:this.remuxer.remux(c.audioTrack,c.videoTrack,c.id3Track,c.textTrack,i,s,!1,this.id),chunkMeta:o}))}configureTransmuxer(t){const{config:e,observer:i,typeSupported:s,vendor:o}=this;let c;for(let v=0,b=Fc.length;v<b;v++)if(Fc[v].demux.probe(t)){c=Fc[v];break}if(!c)return new Error("Failed to find demuxer by probing fragment data");const d=this.demuxer,f=this.remuxer,p=c.remux,g=c.demux;(!f||!(f instanceof p))&&(this.remuxer=new p(i,e,s,o)),(!d||!(d instanceof g))&&(this.demuxer=new g(i,e,s),this.probe=g.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new Ic(this.config)),t}}function pb(n,t){let e=null;return n.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(e=t),e}const Uc=n=>({remuxResult:{},chunkMeta:n});function $o(n){return"then"in n&&n.then instanceof Function}class gb{constructor(t,e,i,s,o){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=o||null}}class mb{constructor(t,e,i,s,o,c){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=o,this.initSegmentChange=c}}var cf={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(f,p,g){this.fn=f,this.context=p,this.once=g||!1}function o(f,p,g,v,b){if(typeof g!="function")throw new TypeError("The listener must be a function");var E=new s(g,v||f,b),T=e?e+p:p;return f._events[T]?f._events[T].fn?f._events[T]=[f._events[T],E]:f._events[T].push(E):(f._events[T]=E,f._eventsCount++),f}function c(f,p){--f._eventsCount===0?f._events=new i:delete f._events[p]}function d(){this._events=new i,this._eventsCount=0}d.prototype.eventNames=function(){var f=[],p,g;if(this._eventsCount===0)return f;for(g in p=this._events)t.call(p,g)&&f.push(e?g.slice(1):g);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(p)):f},d.prototype.listeners=function(f){var p=e?e+f:f,g=this._events[p];if(!g)return[];if(g.fn)return[g.fn];for(var v=0,b=g.length,E=new Array(b);v<b;v++)E[v]=g[v].fn;return E},d.prototype.listenerCount=function(f){var p=e?e+f:f,g=this._events[p];return g?g.fn?1:g.length:0},d.prototype.emit=function(f,p,g,v,b,E){var T=e?e+f:f;if(!this._events[T])return!1;var w=this._events[T],_=arguments.length,D,M;if(w.fn){switch(w.once&&this.removeListener(f,w.fn,void 0,!0),_){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,p),!0;case 3:return w.fn.call(w.context,p,g),!0;case 4:return w.fn.call(w.context,p,g,v),!0;case 5:return w.fn.call(w.context,p,g,v,b),!0;case 6:return w.fn.call(w.context,p,g,v,b,E),!0}for(M=1,D=new Array(_-1);M<_;M++)D[M-1]=arguments[M];w.fn.apply(w.context,D)}else{var F=w.length,x;for(M=0;M<F;M++)switch(w[M].once&&this.removeListener(f,w[M].fn,void 0,!0),_){case 1:w[M].fn.call(w[M].context);break;case 2:w[M].fn.call(w[M].context,p);break;case 3:w[M].fn.call(w[M].context,p,g);break;case 4:w[M].fn.call(w[M].context,p,g,v);break;default:if(!D)for(x=1,D=new Array(_-1);x<_;x++)D[x-1]=arguments[x];w[M].fn.apply(w[M].context,D)}}return!0},d.prototype.on=function(f,p,g){return o(this,f,p,g,!1)},d.prototype.once=function(f,p,g){return o(this,f,p,g,!0)},d.prototype.removeListener=function(f,p,g,v){var b=e?e+f:f;if(!this._events[b])return this;if(!p)return c(this,b),this;var E=this._events[b];if(E.fn)E.fn===p&&(!v||E.once)&&(!g||E.context===g)&&c(this,b);else{for(var T=0,w=[],_=E.length;T<_;T++)(E[T].fn!==p||v&&!E[T].once||g&&E[T].context!==g)&&w.push(E[T]);w.length?this._events[b]=w.length===1?w[0]:w:c(this,b)}return this},d.prototype.removeAllListeners=function(f){var p;return f?(p=e?e+f:f,this._events[p]&&c(this,p)):(this._events=new i,this._eventsCount=0),this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prefixed=e,d.EventEmitter=d,n.exports=d})(cf);var vb=cf.exports,Bc=iv(vb);const Gc=So()||{isTypeSupported:()=>!1};class hf{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 o=t.config;this.hls=t,this.id=e,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const c=(p,g)=>{g=g||{},g.frag=this.frag,g.id=this.id,p===R.ERROR&&(this.error=g.error),this.hls.trigger(p,g)};this.observer=new Bc,this.observer.on(R.FRAG_DECRYPTED,c),this.observer.on(R.ERROR,c);const d={mp4:Gc.isTypeSupported("video/mp4"),mpeg:Gc.isTypeSupported("audio/mpeg"),mp3:Gc.isTypeSupported('audio/mp4; codecs="mp3"')},f=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(o.workerPath||Fy())){try{o.workerPath?(z.log(`loading Web Worker ${o.workerPath} for "${e}"`),this.workerContext=By(o.workerPath)):(z.log(`injecting Web Worker for "${e}"`),this.workerContext=Uy()),this.onwmsg=g=>this.onWorkerMessage(g);const{worker:p}=this.workerContext;p.addEventListener("message",this.onwmsg),p.onerror=g=>{const v=new Error(`${g.message} (${g.filename}:${g.lineno})`);o.enableWorker=!1,z.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:v})},p.postMessage({cmd:"init",typeSupported:d,vendor:f,id:e,config:JSON.stringify(o)})}catch(p){z.warn(`Error setting up "${e}" Web Worker, fallback to inline`,p),this.resetWorker(),this.error=null,this.transmuxer=new lf(this.observer,d,o,f,e)}return}this.transmuxer=new lf(this.observer,d,o,f,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,o,c,d,f,p,g){var v,b;p.transmuxing.start=self.performance.now();const{transmuxer:E}=this,T=c?c.start:o.start,w=o.decryptdata,_=this.frag,D=!(_&&o.cc===_.cc),M=!(_&&p.level===_.level),F=_?p.sn-_.sn:-1,x=this.part?p.part-this.part.index:-1,N=F===0&&p.id>1&&p.id===(_==null?void 0:_.stats.chunkCount),V=!M&&(F===1||F===0&&(x===1||N&&x<=0)),j=self.performance.now();(M||F||o.stats.parsing.start===0)&&(o.stats.parsing.start=j),c&&(x||!V)&&(c.stats.parsing.start=j);const rt=!(_&&((v=o.initSegment)==null?void 0:v.url)===((b=_.initSegment)==null?void 0:b.url)),nt=new mb(D,V,f,M,T,rt);if(!V||D||rt){z.log(`[transmuxer-interface, ${o.type}]: Starting new transmux session for sn: ${p.sn} p: ${p.part} level: ${p.level} id: ${p.id}
184
+ discontinuity: ${D}
185
+ trackSwitch: ${M}
186
+ contiguous: ${V}
187
+ accurateTimeOffset: ${f}
188
+ timeOffset: ${T}
189
+ initSegmentChange: ${rt}`);const Q=new gb(i,s,e,d,g);this.configureTransmuxer(Q)}if(this.frag=o,this.part=c,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:w,chunkMeta:p,state:nt},t instanceof ArrayBuffer?[t]:[]);else if(E){const Q=E.push(t,w,p,nt);$o(Q)?(E.async=!0,Q.then(Tt=>{this.handleTransmuxComplete(Tt)}).catch(Tt=>{this.transmuxerError(Tt,p,"transmuxer-interface push error")})):(E.async=!1,this.handleTransmuxComplete(Q))}}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);$o(i)||e.async?($o(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(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.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 o=(s=this.workerContext)==null?void 0:s.objectURL;o&&self.URL.revokeObjectURL(o);break}case"transmuxComplete":{this.handleTransmuxComplete(e.data);break}case"flush":{this.onFlush(e.data);break}case"workerLog":z[e.data.logType]&&z[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 yb=250,Hc=2,bb=.1,Ab=.05;class Eb{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:o}=this;if(s===null)return;const{currentTime:c,seeking:d}=s,f=this.seeking&&!d,p=!this.seeking&&d;if(this.seeking=d,c!==t){if(this.moved=!0,o!==null){if(this.stallReported){const D=self.performance.now()-o;z.warn(`playback not stuck anymore @${c}, after ${Math.round(D)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(p||f){this.stalled=null;return}if(s.paused&&!d||s.ended||s.playbackRate===0||!Me.getBuffered(s).length)return;const g=Me.bufferInfo(s,c,0),v=g.len>0,b=g.nextStart||0;if(!v&&!b)return;if(d){const D=g.len>Hc,M=!b||e&&e.start<=c||b-c>Hc&&!this.fragmentTracker.getPartialFragment(c);if(D||M)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var E;const D=Math.max(b,g.start||0)-c,M=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,F=!(M==null||(E=M.details)==null)&&E.live?M.details.targetduration*2:Hc,x=this.fragmentTracker.getPartialFragment(c);if(D>0&&(D<=F||x)){this._trySkipBufferHole(x);return}}const T=self.performance.now();if(o===null){this.stalled=T;return}const w=T-o;if(!d&&w>=yb&&(this._reportStall(g),!this.media))return;const _=Me.bufferInfo(s,c,i.maxBufferHole);this._tryFixBufferStall(_,w)}_tryFixBufferStall(t,e){const{config:i,fragmentTracker:s,media:o}=this;if(o===null)return;const c=o.currentTime,d=s.getPartialFragment(c);d&&(this._trySkipBufferHole(d)||!this.media)||(t.len>i.maxBufferHole||t.nextStart&&t.nextStart-c<i.maxBufferHole)&&e>i.highBufferWatchdogPeriod*1e3&&(z.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 o=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(t)})`);z.warn(o.message),e.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_STALLED_ERROR,fatal:!1,error:o,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:i,media:s}=this;if(s===null)return 0;const o=s.currentTime,c=Me.bufferInfo(s,o,0),d=o<c.start?c.start:c.nextStart;if(d){const f=c.len<=e.maxBufferHole,p=c.len>0&&c.len<1&&s.readyState<3,g=d-o;if(g>0&&(f||p)){if(g>e.maxBufferHole){const{fragmentTracker:b}=this;let E=!1;if(o===0){const T=b.getAppendedFrag(0,Jt.MAIN);T&&d<T.end&&(E=!0)}if(!E){const T=t||b.getAppendedFrag(o,Jt.MAIN);if(T){let w=!1,_=T.end;for(;_<d;){const D=b.getPartialFragment(_);if(D)_+=D.duration;else{w=!0;break}}if(w)return 0}}}const v=Math.max(d+Ab,o+bb);if(z.warn(`skipping hole, adjusting currentTime from ${o} to ${v}`),this.moved=!0,this.stalled=null,s.currentTime=v,t&&!t.gap){const b=new Error(`fragment loaded with buffer holes, seeking from ${o} to ${v}`);i.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:b,reason:b.message,frag:t})}return v}}return 0}_tryNudgeBuffer(){const{config:t,hls:e,media:i,nudgeRetry:s}=this;if(i===null)return;const o=i.currentTime;if(this.nudgeRetry++,s<t.nudgeMaxRetry){const c=o+(s+1)*t.nudgeOffset,d=new Error(`Nudging 'currentTime' from ${o} to ${c}`);z.warn(d.message),i.currentTime=c,e.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1})}else{const c=new Error(`Playhead still not moving while enough data buffered @${o} after ${t.nudgeMaxRetry} nudges`);z.error(c.message),e.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_STALLED_ERROR,error:c,fatal:!0})}}}const Tb=100;class kb extends xc{constructor(t,e,i){super(t,e,i,"[stream-controller]",Jt.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(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(R.ERROR,this.onError,this),t.on(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this),t.on(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(R.ERROR,this.onError,this),t.off(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this),t.off(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.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(Tb),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=kt.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=kt.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case kt.WAITING_LEVEL:{var t;const{levels:i,level:s}=this,o=i==null||(t=i[s])==null?void 0:t.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=kt.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=kt.IDLE;break}break}case kt.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=kt.IDLE)}break}this.state===kt.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:i,media:s}=this,{config:o,nextLoadLevel:c}=t;if(e===null||!s&&(this.startFragRequested||!o.startFragPrefetch)||this.altAudio&&this.audioOnly||!(i!=null&&i[c]))return;const d=i[c],f=this.getMainFwdBufferInfo();if(f===null)return;const p=this.getLevelDetails();if(p&&this._streamEnded(f,p)){const _={};this.altAudio&&(_.type="video"),this.hls.trigger(R.BUFFER_EOS,_),this.state=kt.ENDED;return}t.loadLevel!==c&&t.manualLevel===-1&&this.log(`Adapting to level ${c} from level ${this.level}`),this.level=t.nextLoadLevel=c;const g=d.details;if(!g||this.state===kt.WAITING_LEVEL||g.live&&this.levelLastLoaded!==c){this.level=c,this.state=kt.WAITING_LEVEL;return}const v=f.len,b=this.getMaxBufferLength(d.maxBitrate);if(v>=b)return;this.backtrackFragment&&this.backtrackFragment.start>f.end&&(this.backtrackFragment=null);const E=this.backtrackFragment?this.backtrackFragment.start:f.end;let T=this.getNextFragment(E,g);if(this.couldBacktrack&&!this.fragPrevious&&T&&T.sn!=="initSegment"&&this.fragmentTracker.getState(T)!==ui.OK){var w;const _=((w=this.backtrackFragment)!=null?w:T).sn-g.startSN,D=g.fragments[_-1];D&&T.cc===D.cc&&(T=D,this.fragmentTracker.removeFragment(D))}else this.backtrackFragment&&f.len&&(this.backtrackFragment=null);if(T&&this.isLoopLoading(T,E)){if(!T.gap){const _=this.audioOnly&&!this.altAudio?Le.AUDIO:Le.VIDEO,D=(_===Le.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;D&&this.afterBufferFlushed(D,_,Jt.MAIN)}T=this.getNextFragmentLoopLoading(T,g,f,Jt.MAIN,b)}T&&(T.initSegment&&!T.initSegment.data&&!this.bitrateTest&&(T=T.initSegment),this.loadFragment(T,d,E))}loadFragment(t,e,i){const s=this.fragmentTracker.getState(t);this.fragCurrent=t,s===ui.NOT_LOADED||s===ui.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,Jt.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 o=this.getLevelDetails();if(o!=null&&o.live){const d=this.getMainFwdBufferInfo();if(!d||d.len<o.targetduration*2)return}if(!e.paused&&t){const d=this.hls.nextLoadLevel,f=t[d],p=this.fragLastKbps;p&&this.fragCurrent?i=this.fragCurrent.duration*f.maxBitrate/(1e3*p)+1:i=0}else i=0;const c=this.getBufferedFrag(e.currentTime+i);if(c){const d=this.followingBufferedFrag(c);if(d){this.abortCurrentFrag();const f=d.maxStartPTS?d.maxStartPTS:d.start,p=d.duration,g=Math.max(c.end,f+Math.min(Math.max(p-this.config.maxFragLookUpTolerance,p*.5),p*.75));this.flushMainBuffer(g,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 kt.KEY_LOADING:case kt.FRAG_LOADING:case kt.FRAG_LOADING_WAITING_RETRY:case kt.PARSING:case kt.PARSED:this.state=kt.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 Eb(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;Vt(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(R.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,o;e.levels.forEach(c=>{o=c.audioCodec,o&&(o.indexOf("mp4a.40.2")!==-1&&(i=!0),o.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=i&&s&&!Ny(),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!==kt.IDLE)return;const s=i[e.level];(!s.details||s.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(s.details))&&(this.state=kt.WAITING_LEVEL)}onLevelLoaded(t,e){var i;const{levels:s}=this,o=e.level,c=e.details,d=c.totalduration;if(!s){this.warn(`Levels were reset while loading level ${o}`);return}this.log(`Level ${o} loaded [${c.startSN},${c.endSN}]${c.lastPartSn?`[part-${c.lastPartSn}-${c.lastPartIndex}]`:""}, cc [${c.startCC}, ${c.endCC}] duration:${d}`);const f=s[o],p=this.fragCurrent;p&&(this.state===kt.FRAG_LOADING||this.state===kt.FRAG_LOADING_WAITING_RETRY)&&(p.level!==e.level||p.urlId!==f.urlId)&&p.loader&&this.abortCurrentFrag();let g=0;if(c.live||(i=f.details)!=null&&i.live){if(this.checkLiveUpdate(c),c.deltaUpdateFailed)return;g=this.alignPlaylists(c,f.details)}if(f.details=c,this.levelLastLoaded=o,this.hls.trigger(R.LEVEL_UPDATED,{details:c,level:o}),this.state===kt.WAITING_LEVEL){if(this.waitForCdnTuneIn(c))return;this.state=kt.IDLE}this.startFragRequested?c.live&&this.synchronizeToLiveEdge(c):this.setStartPosition(c,g),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:s,payload:o}=t,{levels:c}=this;if(!c){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const d=c[i.level],f=d.details;if(!f){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const p=d.videoCodec,g=f.PTSKnown||!f.live,v=(e=i.initSegment)==null?void 0:e.data,b=this._getAudioCodec(d),E=this.transmuxer=this.transmuxer||new hf(this.hls,Jt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),T=s?s.index:-1,w=T!==-1,_=new Lc(i.level,i.sn,i.stats.chunkCount,o.byteLength,T,w),D=this.initPTS[i.cc];E.push(o,v,b,p,i,s,f.totalduration,g,_,D)}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 o=this.fragCurrent;o&&(this.log("Switching to main audio track, cancel main fragment load"),o.abortRequests(),this.fragmentTracker.removeFragment(o)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const s=this.hls;i&&(s.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),s.trigger(R.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const i=e.id,s=!!this.hls.audioTracks[i].url;if(s){const o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=s,this.tick()}onBufferCreated(t,e){const i=e.tracks;let s,o,c=!1;for(const d in i){const f=i[d];if(f.id==="main"){if(o=d,s=f,d==="video"){const p=i[d];p&&(this.videoBuffer=p.buffer)}}else c=!0}c&&s?(this.log(`Alternate track found, use ${o}.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!==Jt.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===kt.PARSED&&(this.state=kt.IDLE);return}const o=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}onError(t,e){var i;if(e.fatal){this.state=kt.ERROR;return}switch(e.details){case ut.FRAG_GAP:case ut.FRAG_PARSING_ERROR:case ut.FRAG_DECRYPT_ERROR:case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Jt.MAIN,e);break;case ut.LEVEL_LOAD_ERROR:case ut.LEVEL_LOAD_TIMEOUT:case ut.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===kt.WAITING_LEVEL&&((i=e.context)==null?void 0:i.type)===Te.LEVEL&&(this.state=kt.IDLE);break;case ut.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="main")return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case ut.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}checkBuffer(){const{media:t,gapController:e}=this;if(!(!t||!e||!t.readyState)){if(this.loadedmetadata||!Me.getBuffered(t).length){const i=this.state!==kt.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=kt.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==Le.AUDIO||this.audioOnly&&!this.altAudio){const i=(e===Le.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,e,Jt.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=Me.getBuffered(t),o=(s.length?s.start(0):0)-i;o>0&&(o<this.config.maxBufferHole||o<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${o} to match buffer start`),i+=o,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=kt.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const o=t.stats;o.parsing.start=o.parsing.end=o.buffering.start=o.buffering.end=self.performance.now(),s.trigger(R.FRAG_LOADED,i),t.bitrateTest=!1})}_handleTransmuxComplete(t){var e;const i="main",{hls:s}=this,{remuxResult:o,chunkMeta:c}=t,d=this.getCurrentContext(c);if(!d){this.resetWhenMissingContext(c);return}const{frag:f,part:p,level:g}=d,{video:v,text:b,id3:E,initSegment:T}=o,{details:w}=g,_=this.altAudio?void 0:o.audio;if(this.fragContextChanged(f)){this.fragmentTracker.removeFragment(f);return}if(this.state=kt.PARSING,T){if(T!=null&&T.tracks){const F=f.initSegment||f;this._bufferInitSegment(g,T.tracks,F,c),s.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:F,id:i,tracks:T.tracks})}const D=T.initPTS,M=T.timescale;Vt(D)&&(this.initPTS[f.cc]={baseTime:D,timescale:M},s.trigger(R.INIT_PTS_FOUND,{frag:f,id:i,initPTS:D,timescale:M}))}if(v&&w&&f.sn!=="initSegment"){const D=w.fragments[f.sn-1-w.startSN],M=f.sn===w.startSN,F=!D||f.cc>D.cc;if(o.independent!==!1){const{startPTS:x,endPTS:N,startDTS:V,endDTS:j}=v;if(p)p.elementaryStreams[v.type]={startPTS:x,endPTS:N,startDTS:V,endDTS:j};else if(v.firstKeyFrame&&v.independent&&c.id===1&&!F&&(this.couldBacktrack=!0),v.dropped&&v.independent){const rt=this.getMainFwdBufferInfo(),nt=(rt?rt.end:this.getLoadPosition())+this.config.maxBufferHole,Q=v.firstKeyFramePTS?v.firstKeyFramePTS:x;if(!M&&nt<Q-this.config.maxBufferHole&&!F){this.backtrack(f);return}else F&&(f.gap=!0);f.setElementaryStreamInfo(v.type,f.start,N,f.start,j,!0)}f.setElementaryStreamInfo(v.type,x,N,V,j),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(v,f,p,c,M||F)}else if(M||F)f.gap=!0;else{this.backtrack(f);return}}if(_){const{startPTS:D,endPTS:M,startDTS:F,endDTS:x}=_;p&&(p.elementaryStreams[Le.AUDIO]={startPTS:D,endPTS:M,startDTS:F,endDTS:x}),f.setElementaryStreamInfo(Le.AUDIO,D,M,F,x),this.bufferFragmentData(_,f,p,c)}if(w&&E!=null&&(e=E.samples)!=null&&e.length){const D={id:i,frag:f,details:w,samples:E.samples};s.trigger(R.FRAG_PARSING_METADATA,D)}if(w&&b){const D={id:i,frag:f,details:w,samples:b.samples};s.trigger(R.FRAG_PARSING_USERDATA,D)}}_bufferInitSegment(t,e,i,s){if(this.state!==kt.PARSING)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;const{audio:o,video:c,audiovideo:d}=e;if(o){let f=t.audioCodec;const p=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(f&&(f.indexOf("mp4a.40.5")!==-1?f="mp4a.40.2":f="mp4a.40.5"),o.metadata.channelCount!==1&&p.indexOf("firefox")===-1&&(f="mp4a.40.5")),p.indexOf("android")!==-1&&o.container!=="audio/mpeg"&&(f="mp4a.40.2",this.log(`Android: force audio codec to ${f}`)),t.audioCodec&&t.audioCodec!==f&&this.log(`Swapping manifest audio codec "${t.audioCodec}" for "${f}"`),o.levelCodec=f,o.id="main",this.log(`Init audio buffer, container:${o.container}, codecs[selected/level/parsed]=[${f||""}/${t.audioCodec||""}/${o.codec}]`)}c&&(c.levelCodec=t.videoCodec,c.id="main",this.log(`Init video buffer, container:${c.container}, codecs[level/parsed]=[${t.videoCodec||""}/${c.codec}]`)),d&&this.log(`Init audiovideo buffer, container:${d.container}, codecs[level/parsed]=[${t.attrs.CODECS||""}/${d.codec}]`),this.hls.trigger(R.BUFFER_CODECS,e),Object.keys(e).forEach(f=>{const p=e[f].initSegment;p!=null&&p.byteLength&&this.hls.trigger(R.BUFFER_APPENDING,{type:f,data:p,frag:i,part:null,chunkMeta:s,parent:i.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Jt.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=kt.IDLE}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&t.seeking===!1){const i=t.currentTime;if(Me.isBuffered(t,i)?e=this.getAppendedFrag(i):Me.isBuffered(t,i+.1)&&(e=this.getAppendedFrag(i+.1)),e){this.backtrackFragment=null;const s=this.fragPlaying,o=e.level;(!s||e.sn!==s.sn||s.level!==o||e.urlId!==s.urlId)&&(this.fragPlaying=e,this.hls.trigger(R.FRAG_CHANGED,{frag:e}),(!s||s.level!==o)&&this.hls.trigger(R.LEVEL_SWITCHED,{level:o}))}}}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&&Vt(e)&&Vt(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 Cn{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 wb{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 Cn(t),this.fast_=new Cn(e),this.defaultTTFB_=s,this.ttfb_=new Cn(t)}update(t,e){const{slow_:i,fast_:s,ttfb_:o}=this;i.halfLife!==t&&(this.slow_=new Cn(t,i.getEstimate(),i.getTotalWeight())),s.halfLife!==e&&(this.fast_=new Cn(e,s.getEstimate(),s.getTotalWeight())),o.halfLife!==t&&(this.ttfb_=new Cn(t,o.getEstimate(),o.getTotalWeight()))}sample(t,e){t=Math.max(t,this.minDelayMs_);const i=8*e,s=t/1e3,o=i/s;this.fast_.sample(s,o),this.slow_.sample(s,o)}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 Sb{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 wb(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(R.FRAG_LOADING,this.onFragLoading,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this),t.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:t}=this;t.off(R.FRAG_LOADING,this.onFragLoading,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this),t.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(R.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 o=t+i/e,c=s?this.lastLevelLoadSec:0;return o+c}onLevelLoaded(t,e){const i=this.hls.config,{total:s,bwEstimate:o}=e.stats;Vt(s)&&Vt(o)&&(this.lastLevelLoadSec=8*s/o),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:o}=i;if(!t||!o)return;const c=performance.now(),d=e?e.stats:t.stats,f=e?e.duration:t.duration,p=c-d.loading.start;if(d.aborted||d.loaded&&d.loaded===d.total||t.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!s||o.paused||!o.playbackRate||!o.readyState)return;const g=i.mainForwardBufferInfo;if(g===null)return;const v=this.bwEstimator.getEstimateTTFB(),b=Math.abs(o.playbackRate);if(p<=Math.max(v,1e3*(f/(b*2))))return;const E=g.len/b;if(E>=2*f/b)return;const T=d.loading.first?d.loading.first-d.loading.start:-1,w=d.loaded&&T>-1,_=this.bwEstimator.getEstimate(),{levels:D,minAutoLevel:M}=i,F=D[t.level],x=d.total||Math.max(d.loaded,Math.round(f*F.maxBitrate/8));let N=p-T;N<1&&w&&(N=Math.min(p,d.loaded*8/_));const V=w?d.loaded*1e3/N:0,j=V?(x-d.loaded)/V:x*8/_+v/1e3;if(j<=E)return;const rt=V?V*8:_;let nt=Number.POSITIVE_INFINITY,Q;for(Q=t.level-1;Q>M;Q--){const Tt=D[Q].maxBitrate;if(nt=this.getTimeToLoadFrag(v/1e3,rt,f*Tt,!D[Q].details),nt<E)break}nt>=j||nt>f*10||(i.nextLoadLevel=Q,w?this.bwEstimator.sample(p-Math.min(v,T),d.loaded):this.bwEstimator.sampleTTFB(p),this.clearTimer(),z.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;
190
+ Time to underbuffer: ${E.toFixed(3)} s
191
+ Estimated load time for current fragment: ${j.toFixed(3)} s
192
+ Estimated load time for down switch fragment: ${nt.toFixed(3)} s
193
+ TTFB estimate: ${T}
194
+ Current BW estimate: ${Vt(_)?(_/1024).toFixed(3):"Unknown"} Kb/s
176
195
  New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
177
- Aborting and switching to level ${I}`),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),i.trigger(m.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===Z.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(m.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!==Z.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,c=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,d=i.mainForwardBufferInfo,u=(d?d.len:0)/h;let f=this.findBestLevel(c,a,s,u,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(f>=0)return f;_.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,v=n.abrBandWidthUpFactor;if(!u){const E=this.bitrateTestDelay;E&&(p=(l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay)-E,_.trace(`[abr] bitrate test took ${Math.round(1e3*E)}ms, set first fragment max fetchDuration to ${Math.round(1e3*p)} ms`),g=v=1)}return f=this.findBestLevel(c,a,s,u+p,g,v),Math.max(f,0)}findBestLevel(t,e,i,s,n,a){var o;const{fragCurrent:l,partCurrent:h,lastLoadedFragLevel:c}=this,{levels:d}=this.hls,u=d[c],f=!!(u!=null&&(o=u.details)!=null&&o.live),p=u==null?void 0:u.codecSet,g=h?h.duration:l?l.duration:0,v=this.bwEstimator.getEstimateTTFB()/1e3;let E=e,A=-1;for(let L=i;L>=e;L--){const y=d[L];if(!y||p&&y.codecSet!==p){y&&(E=Math.min(L,E),A=Math.max(L,A));continue}A!==-1&&_.trace(`[abr] Skipped level(s) ${E}-${A} with CODECS:"${d[A].attrs.CODECS}"; not compatible with "${u.attrs.CODECS}"`);const S=y.details,R=(h?S==null?void 0:S.partTarget:S==null?void 0:S.averagetargetduration)||g;let D;L<=c?D=n*t:D=a*t;const M=d[L].maxBitrate,C=this.getTimeToLoadFrag(v,D,M*R,S===void 0);if(_.trace(`[abr] level:${L} adjustedbw-bitrate:${Math.round(D-M)} avgDuration:${R.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:${C.toFixed(1)}`),D>M&&(C===0||!z(C)||f&&!this.bitrateTestDelay||C<s))return L}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}}class Hh{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=Sm(t,e);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function Sm(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 Gh=100;class Lm extends Kn{constructor(t,e,i){super(t,e,i,"[audio-stream-controller]",Z.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(m.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(m.MANIFEST_LOADING,this.onManifestLoading,this),t.on(m.LEVEL_LOADED,this.onLevelLoaded,this),t.on(m.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(m.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(m.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(m.ERROR,this.onError,this),t.on(m.BUFFER_RESET,this.onBufferReset,this),t.on(m.BUFFER_CREATED,this.onBufferCreated,this),t.on(m.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(m.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(m.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(m.MANIFEST_LOADING,this.onManifestLoading,this),t.off(m.LEVEL_LOADED,this.onLevelLoaded,this),t.off(m.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(m.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(m.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(m.ERROR,this.onError,this),t.off(m.BUFFER_RESET,this.onBufferReset,this),t.off(m.BUFFER_CREATED,this.onBufferCreated,this),t.off(m.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(m.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(m.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===B.WAITING_INIT_PTS&&this.tick()}}startLoad(t){if(!this.levels){this.startPosition=t,this.state=B.STOPPED;return}const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(Gh),e>0&&t===-1?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=B.IDLE):(this.loadedmetadata=!1,this.state=B.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case B.IDLE:this.doTickIdle();break;case B.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=B.WAITING_INIT_PTS}break}case B.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=B.IDLE);break}case B.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=B.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=Et.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);Nn(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=B.IDLE}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=B.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=B.WAITING_TRACK;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,mt.AUDIO,Z.AUDIO));const h=this.getFwdBufferInfo(l,Z.AUDIO);if(h===null)return;const{bufferedTrack:c,switchingTrack:d}=this;if(!d&&this._streamEnded(h,o)){t.trigger(m.BUFFER_EOS,{type:"audio"}),this.state=B.ENDED;return}const u=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Z.MAIN),f=h.len,p=this.getMaxBufferLength(u==null?void 0:u.len);if(f>=p&&!d)return;const g=o.fragments[0].start;let v=h.end;if(d&&i){const y=this.getLoadPosition();c&&d.attrs!==c.attrs&&(v=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 E=this.getNextFragment(v,o),A=!1;if(E&&this.isLoopLoading(E,v)&&(A=!!E.gap,E=this.getNextFragmentLoopLoading(E,o,h,Z.MAIN,p)),!E){this.bufferFlushed=!0;return}const L=u&&E.start>u.end+o.targetduration;if(L||!(u!=null&&u.len)&&h.len){const y=this.getAppendedFrag(E.start,Z.MAIN);if(y===null||(A||(A=!!y.gap||!!L&&u.len===0),L&&!A||A&&h.nextStart&&h.nextStart<y.end))return}this.loadFragment(E,a,v)}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 ms(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(Gh):this.resetTransmuxer(),i?(this.switchingTrack=e,this.state=B.IDLE):(this.switchingTrack=null,this.bufferedTrack=e,this.state=B.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(m.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?(Eh(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===B.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=B.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 c=h.details;if(!c){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const d=a.defaultAudioCodec||h.audioCodec||"mp4a.40.2";let u=this.transmuxer;u||(u=this.transmuxer=new Bh(this.hls,Z.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,v=g!==-1,E=new Hn(i.level,i.sn,i.stats.chunkCount,n.byteLength,g,v);u.push(n,p,d,"",i,s,c.totalduration,!1,E,f)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);const{cache:g}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new Hh,complete:!1};g.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=B.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!==Z.AUDIO){if(!this.loadedmetadata&&i.type===Z.MAIN){const n=this.videoBuffer||this.media;n&&Et.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(m.AUDIO_TRACK_SWITCHED,Qt({},n)))}this.fragBufferedComplete(i,s)}onError(t,e){var i;if(e.fatal){this.state=B.ERROR;return}switch(e.details){case $.FRAG_GAP:case $.FRAG_PARSING_ERROR:case $.FRAG_DECRYPT_ERROR:case $.FRAG_LOAD_ERROR:case $.FRAG_LOAD_TIMEOUT:case $.KEY_LOAD_ERROR:case $.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Z.AUDIO,e);break;case $.AUDIO_TRACK_LOAD_ERROR:case $.AUDIO_TRACK_LOAD_TIMEOUT:case $.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===B.WAITING_TRACK&&((i=e.context)==null?void 0:i.type)===ct.AUDIO_TRACK&&(this.state=B.IDLE);break;case $.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 $.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}onBufferFlushed(t,{type:e}){e===mt.AUDIO&&(this.bufferFlushed=!0,this.state===B.ENDED&&(this.state=B.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:c}=o,{details:d}=c,{audio:u,text:f,id3:p,initSegment:g}=n;if(this.fragContextChanged(l)||!d){this.fragmentTracker.removeFragment(l);return}if(this.state=B.PARSING,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),g!=null&&g.tracks){const v=l.initSegment||l;this._bufferInitSegment(g.tracks,v,a),s.trigger(m.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:i,tracks:g.tracks})}if(u){const{startPTS:v,endPTS:E,startDTS:A,endDTS:L}=u;h&&(h.elementaryStreams[mt.AUDIO]={startPTS:v,endPTS:E,startDTS:A,endDTS:L}),l.setElementaryStreamInfo(mt.AUDIO,v,E,A,L),this.bufferFragmentData(u,l,h,a)}if(p!=null&&(e=p.samples)!=null&&e.length){const v=xt({id:i,frag:l,details:d},p);s.trigger(m.FRAG_PARSING_METADATA,v)}if(f){const v=xt({id:i,frag:l,details:d},f);s.trigger(m.FRAG_PARSING_USERDATA,v)}}_bufferInitSegment(t,e,i){if(this.state!==B.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(m.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(m.BUFFER_APPENDING,a)}this.tick()}loadFragment(t,e,i){const s=this.fragmentTracker.getState(t);if(this.fragCurrent=t,this.switchingTrack||s===$t.NOT_LOADED||s===$t.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=B.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(m.AUDIO_TRACK_SWITCHED,Qt({},t))}}class Rm extends Un{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(m.MANIFEST_LOADING,this.onManifestLoading,this),t.on(m.MANIFEST_PARSED,this.onManifestParsed,this),t.on(m.LEVEL_LOADING,this.onLevelLoading,this),t.on(m.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(m.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(m.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(m.MANIFEST_LOADING,this.onManifestLoading,this),t.off(m.MANIFEST_PARSED,this.onManifestParsed,this),t.off(m.LEVEL_LOADING,this.onLevelLoading,this),t.off(m.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(m.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(m.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(m.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===ct.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(m.AUDIO_TRACK_SWITCHING,Qt({},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(m.ERROR,{type:Q.MEDIA_ERROR,details:$.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(m.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:t||null})}}}function Vh(r,t){if(r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(!_m(r[e].attrs,t[e].attrs))return!1;return!0}function _m(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 Kh=500;class km extends Kn{constructor(t,e,i){super(t,e,i,"[subtitle-stream-controller]",Z.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(m.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(m.MANIFEST_LOADING,this.onManifestLoading,this),t.on(m.LEVEL_LOADED,this.onLevelLoaded,this),t.on(m.ERROR,this.onError,this),t.on(m.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(m.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(m.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(m.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(m.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(m.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(m.MANIFEST_LOADING,this.onManifestLoading,this),t.off(m.LEVEL_LOADED,this.onLevelLoaded,this),t.off(m.ERROR,this.onError,this),t.off(m.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(m.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(m.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(m.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(m.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(m.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=B.IDLE,this.setInterval(Kh),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=B.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,Z.SUBTITLE)}}onFragBuffered(t,e){if(!this.loadedmetadata&&e.frag.type===Z.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)===Z.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==B.STOPPED&&(this.state=B.IDLE))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){if(Vh(this.levels,e)){this.levels=e.map(i=>new ms(i));return}this.tracksBuffered=[],this.levels=e.map(i=>{const s=new ms(i);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Z.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(Kh)}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 c=this.mainDetails;if(s.deltaUpdateFailed||!c)return;const d=c.fragments[0];l.details?(h=this.alignPlaylists(s,l.details),h===0&&d&&(h=d.start,Mn(s,h))):s.hasProgramDateTime&&c.hasProgramDateTime?(Eh(s,c),h=s.fragments[0].start):d&&(h=d.start,Mn(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===B.IDLE&&(vs(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(m.ERROR,{type:Q.MEDIA_ERROR,details:$.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:e}),o}).then(o=>{const l=performance.now();n.trigger(m.FRAG_DECRYPTED,{frag:e,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=B.IDLE})}}doTick(){if(!this.media){this.state=B.IDLE;return}if(this.state===B.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=Et.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,h=this.getFwdBufferInfo(this.media,Z.MAIN),c=i.details,d=this.getMaxBufferLength(h==null?void 0:h.len)+c.levelTargetDuration;if(l>d)return;const u=c.fragments,f=u.length,p=c.edge;let g=null;const v=this.fragPrevious;if(o<p){const E=s.maxFragLookUpTolerance,A=o>p-E?0:E;g=vs(v,u,Math.max(u[0].start,o),A),!g&&v&&v.start<u[0].start&&(g=u[0])}else g=u[f-1];if(!g)return;if(g=this.mapToInitFragWhenRequired(g),g.sn!=="initSegment"){const E=g.sn-c.startSN,A=u[E-1];A&&A.cc===g.cc&&this.fragmentTracker.getState(A)===$t.NOT_LOADED&&(g=A)}this.fragmentTracker.getState(g)===$t.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 Im(this.tracksBuffered[this.currentTrackId]||[])}}class Im{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 Dm extends Un{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(m.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(m.MANIFEST_LOADING,this.onManifestLoading,this),t.on(m.MANIFEST_PARSED,this.onManifestParsed,this),t.on(m.LEVEL_LOADING,this.onLevelLoading,this),t.on(m.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(m.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(m.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(m.MANIFEST_LOADING,this.onManifestLoading,this),t.off(m.MANIFEST_PARSED,this.onManifestParsed,this),t.off(m.LEVEL_LOADING,this.onLevelLoading,this),t.off(m.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(m.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(m.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),ia(this.media.textTracks).forEach(t=>{Ri(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(m.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===ct.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(m.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=ia(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:c}=n;this.hls.trigger(m.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:h,url:c});const d=this.switchParams(n.url,e==null?void 0:e.details);this.loadPlaylist(d)}else this.hls.trigger(m.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=ia(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 ia(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 Cm{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){_.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 jh=nr(),Wh=/([ha]vc.)(?:\.[^.,]+)+/;class xm{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;_.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(m.MEDIA_ATTACHED,{media:e})),i&&i.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{_.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{_.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:i}=this;e&&e.src!==i&&_.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(m.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(m.MANIFEST_LOADING,this.onManifestLoading,this),t.on(m.MANIFEST_PARSED,this.onManifestParsed,this),t.on(m.BUFFER_RESET,this.onBufferReset,this),t.on(m.BUFFER_APPENDING,this.onBufferAppending,this),t.on(m.BUFFER_CODECS,this.onBufferCodecs,this),t.on(m.BUFFER_EOS,this.onBufferEos,this),t.on(m.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(m.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(m.FRAG_PARSED,this.onFragParsed,this),t.on(m.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:t}=this;t.off(m.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(m.MANIFEST_LOADING,this.onManifestLoading,this),t.off(m.MANIFEST_PARSED,this.onManifestParsed,this),t.off(m.BUFFER_RESET,this.onBufferReset,this),t.off(m.BUFFER_APPENDING,this.onBufferAppending,this),t.off(m.BUFFER_CODECS,this.onBufferCodecs,this),t.off(m.BUFFER_EOS,this.onBufferEos,this),t.off(m.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(m.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(m.FRAG_PARSED,this.onFragParsed,this),t.off(m.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Cm(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,_.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const i=this.media=e.media;if(i&&jh){const s=this.mediaSource=new jh;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(_.log("[buffer-controller]: media source detaching"),e.readyState==="open")try{e.endOfStream()}catch(s){_.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()):_.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(m.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){_.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:c}=e[s],d=(n.levelCodec||n.codec).replace(Wh,"$1"),u=(l||o).replace(Wh,"$1");if(d!==u){const f=`${h};codecs=${l||o}`;this.appendChangeType(s,f),_.log(`[buffer-controller]: switching codec ${d} to ${u}`),this.tracks[s]={buffer:n.buffer,codec:o,container:h,levelCodec:l,metadata:c,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&&(_.log(`[buffer-controller]: changing ${t} sourceBuffer type to ${e}`),n.changeType(e)),i.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:n=>{_.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:c}=e,d=c.buffering[o],u=self.performance.now();d.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 v=!1;o==="audio"&&(g==null?void 0:g.container)==="audio/mpeg"&&(v=!this.lastMpegAudioChunk||c.id===1||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);const E=l.start,A={execute:()=>{if(d.executeStart=self.performance.now(),v){const L=this.sourceBuffer[o];if(L){const y=E-L.timestampOffset;Math.abs(y)>=.1&&(_.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${E} (delta: ${y}) sn: ${l.sn})`),L.timestampOffset=E)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{const L=self.performance.now();d.executeEnd=d.end=L,f.first===0&&(f.first=L),p&&p.first===0&&(p.first=L);const{sourceBuffer:y}=this,S={};for(const R in y)S[R]=Et.getBuffered(y[R]);this.appendError=0,this.hls.trigger(m.BUFFER_APPENDED,{type:o,frag:l,part:h,chunkMeta:c,parent:l.type,timeRanges:S})},onError:L=>{_.error(`[buffer-controller]: Error encountered while trying to append to the ${o} SourceBuffer`,L);const y={type:Q.MEDIA_ERROR,parent:l.type,details:$.BUFFER_APPEND_ERROR,frag:l,part:h,chunkMeta:c,error:L,err:L,fatal:!1};L.code===DOMException.QUOTA_EXCEEDED_ERR?y.details=$.BUFFER_FULL_ERROR:(this.appendError++,y.details=$.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(_.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),y.fatal=!0)),i.trigger(m.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(m.BUFFER_FLUSHED,{type:n})},onError:a=>{_.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[mt.AUDIOVIDEO]?n.push("audiovideo"):(a[mt.AUDIO]&&n.push("audio"),a[mt.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(m.FRAG_BUFFERED,{frag:i,part:s,stats:h,id:i.type})};n.length===0&&_.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,_.log(`[buffer-controller]: ${s} sourceBuffer now EOS`))),i&&!!(!n||n.ended)},!0)&&(_.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&&_.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${i.readyState}`);return}_.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(!z(a)||a<0)return;const o=i.currentTime,l=e.levelTargetDuration,h=Math.max(a,l),c=Math.floor(o/l)*l-h;n.forEach(d=>{const u=s[d];if(u){const f=Et.getBuffered(u);if(f.length>0&&c>f.start(0)){if(t.trigger(m.BACK_BUFFER_REACHED,{bufferEnd:c}),e.live)t.trigger(m.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(u.ended&&f.end(f.length-1)-o<l*2){_.info(`[buffer-controller]: Cannot flush ${d} back buffer while SourceBuffer is in ended state`);return}t.trigger(m.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:d})}}})}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=z(s.duration)?s.duration:0;t.live&&e.config.liveDurationInfinity?(_.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(t)):(n>o&&n>a||!z(a))&&(_.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(m.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(m.ERROR,{type:Q.MEDIA_ERROR,details:$.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}`;_.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){_.error(`[buffer-controller]: error while trying to add sourceBuffer: ${l.message}`),this.hls.trigger(m.ERROR,{type:Q.MEDIA_ERROR,details:$.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`);_.error(`[buffer-controller]: ${i}`,e),this.hls.trigger(m.ERROR,{type:Q.MEDIA_ERROR,details:$.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){_.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(t);return}const h=z(s.duration)?s.duration:1/0,c=z(n.duration)?n.duration:1/0,d=Math.max(0,e),u=Math.min(i,h,c);u>d&&!l.ending?(l.ended=!1,_.log(`[buffer-controller]: Removing [${d},${u}] from the ${t} SourceBuffer`),l.remove(d,u)):a.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:i,sourceBuffer:s}=this,n=s[e];if(!n){_.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){_.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 Yh={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},qh=function(r){let t=r;return Yh.hasOwnProperty(r)&&(t=Yh[r]),String.fromCharCode(t)},me=15,Ne=100,Pm={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Om={17:2,18:4,21:6,22:8,23:10,19:13,20:15},$m={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Mm={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Fm=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Nm{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const i=typeof e=="function"?e():e;_.log(`${this.time} [${t}] ${i}`)}}}const ci=function(r){const t=[];for(let e=0;e<r.length;e++)t.push(r[e].toString(16));return t};class zh{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 Um{constructor(t,e,i,s,n,a){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new zh(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 Bm{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<Ne;e++)this.chars.push(new Um);this.logger=t,this.pos=0,this.currPenState=new zh}equals(t){let e=!0;for(let i=0;i<Ne;i++)if(!this.chars[i].equals(t.chars[i])){e=!1;break}return e}copy(t){for(let e=0;e<Ne;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<Ne;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>Ne&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Ne)}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=qh(t);if(this.pos>=Ne){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<Ne;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<Ne;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 sa{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<me;e++)this.rows.push(new Bm(t));this.logger=t,this.currRow=me-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let t=0;t<me;t++)this.rows[t].clear();this.currRow=me-1}equals(t){let e=!0;for(let i=0;i<me;i++)if(!this.rows[i].equals(t.rows[i])){e=!1;break}return e}copy(t){for(let e=0;e<me;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<me;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<me;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<me;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(`
178
- `)),i}getTextAndFormat(){return this.rows}}class Xh{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 sa(i),this.nonDisplayedMemory=new sa(i),this.lastOutputScreen=new sa(i),this.currRollUpRow=this.displayedMemory.rows[me-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[me-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 Qh{constructor(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const s=new Nm;this.channels=[null,new Xh(t,e,s),new Xh(t+1,i,s)],this.cmdHistory=Jh(),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,"["+ci([e[o],e[o+1]])+"] -> ("+ci([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 "+ci([s,n])+" orig: "+ci([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(Zh(t,e,i))return Di(null,null,i),this.logger.log(3,"Repeated command ("+ci([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 ("+ci([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(Zh(t,e,s))return Di(null,null,s),!0;const o=t<=23?1:2;e>=64&&e<=95?i=o===1?Pm[t]:$m[t]:i=o===1?Om[t]:Mm[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 '"+qh(a)+"' in channel "+i),s=[a]}else t>=32&&t<=127&&(s=e===0?[t]:[t,e]);if(s){const a=ci(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=Fm[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=Jh()}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 Zh(r,t,e){return e.a===r&&e.b===t}function Jh(){return{a:null,b:null}}class vr{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 ra=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 c=arguments[h];for(const d in c)o[d]=c[d]}return o}function a(o,l,h){const c=this,d={enumerable:!0};c.hasBeenReset=!1;let u="",f=!1,p=o,g=l,v=h,E=null,A="",L=!0,y="auto",S="start",R=50,D="middle",M=50,C="middle";Object.defineProperty(c,"id",n({},d,{get:function(){return u},set:function(I){u=""+I}})),Object.defineProperty(c,"pauseOnExit",n({},d,{get:function(){return f},set:function(I){f=!!I}})),Object.defineProperty(c,"startTime",n({},d,{get:function(){return p},set:function(I){if(typeof I!="number")throw new TypeError("Start time must be set to a number.");p=I,this.hasBeenReset=!0}})),Object.defineProperty(c,"endTime",n({},d,{get:function(){return g},set:function(I){if(typeof I!="number")throw new TypeError("End time must be set to a number.");g=I,this.hasBeenReset=!0}})),Object.defineProperty(c,"text",n({},d,{get:function(){return v},set:function(I){v=""+I,this.hasBeenReset=!0}})),Object.defineProperty(c,"region",n({},d,{get:function(){return E},set:function(I){E=I,this.hasBeenReset=!0}})),Object.defineProperty(c,"vertical",n({},d,{get:function(){return A},set:function(I){const G=i(I);if(G===!1)throw new SyntaxError("An invalid or illegal string was specified.");A=G,this.hasBeenReset=!0}})),Object.defineProperty(c,"snapToLines",n({},d,{get:function(){return L},set:function(I){L=!!I,this.hasBeenReset=!0}})),Object.defineProperty(c,"line",n({},d,{get:function(){return y},set:function(I){if(typeof I!="number"&&I!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");y=I,this.hasBeenReset=!0}})),Object.defineProperty(c,"lineAlign",n({},d,{get:function(){return S},set:function(I){const G=s(I);if(!G)throw new SyntaxError("An invalid or illegal string was specified.");S=G,this.hasBeenReset=!0}})),Object.defineProperty(c,"position",n({},d,{get:function(){return R},set:function(I){if(I<0||I>100)throw new Error("Position must be between 0 and 100.");R=I,this.hasBeenReset=!0}})),Object.defineProperty(c,"positionAlign",n({},d,{get:function(){return D},set:function(I){const G=s(I);if(!G)throw new SyntaxError("An invalid or illegal string was specified.");D=G,this.hasBeenReset=!0}})),Object.defineProperty(c,"size",n({},d,{get:function(){return M},set:function(I){if(I<0||I>100)throw new Error("Size must be between 0 and 100.");M=I,this.hasBeenReset=!0}})),Object.defineProperty(c,"align",n({},d,{get:function(){return C},set:function(I){const G=s(I);if(!G)throw new SyntaxError("An invalid or illegal string was specified.");C=G,this.hasBeenReset=!0}})),c.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}();class Hm{decode(t,e){if(!t)return"";if(typeof t!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function tc(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 Gm{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 ec(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 na=new ra(0,0,""),yr=na.align==="middle"?"middle":"center";function Vm(r,t,e){const i=r;function s(){const o=tc(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 Gm;ec(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",yr,"end"]);break;case"position":p=f.split(","),h.percent(u,p[0]),p.length===2&&h.alt("positionAlign",p[1],["start",yr,"end","line-left","line-right","auto"]);break;case"size":h.percent(u,f);break;case"align":h.alt(u,f,["start",yr,"end","left","right"]);break}},/:/,/\s/),l.region=h.get("region",null),l.vertical=h.get("vertical","");let c=h.get("line","auto");c==="auto"&&na.line===-1&&(c=-1),l.line=c,l.lineAlign=h.get("lineAlign","start"),l.snapToLines=h.get("snapToLines",!0),l.size=h.get("size",100),l.align=h.get("align",yr);let d=h.get("position","auto");d==="auto"&&na.position===50&&(d=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=d}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 ic(r){return r.replace(/<br(?: \/)?>/gi,`
179
- `)}class Km{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Hm,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=ic(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
180
- `;)++a;const o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
181
- `&&++a,e.buffer=n.slice(a),o}function s(n){ec(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 ra(0,0,""),e.state="CUE",n.indexOf("-->")===-1){e.cue.id=n;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{Vm(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+=`
182
- `),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+=`
183
-
184
- `,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 jm=/\r\n|\n\r|\n|\r/g,aa=function(r,t,e=0){return r.slice(e,e+t.length)===t},Wm=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(!z(t)||!z(e)||!z(i)||!z(s))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${r}`);return t+=1e3*e,t+=60*1e3*i,t+=60*60*1e3*s,t},oa=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 oa(r.toString())+oa(t.toString())+oa(e)}const Ym=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 qm(r,t,e,i,s,n,a){const o=new Km,l=Le(new Uint8Array(r)).trim().replace(jm,`
196
+ Aborting and switching to level ${Q}`),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),i.trigger(R.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:d}))}onFragLoaded(t,{frag:e,part:i}){const s=i?i.stats:e.stats;if(e.type===Jt.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 o=i?i.duration:e.duration,c=this.hls.levels[e.level],d=(c.loaded?c.loaded.bytes:0)+s.loaded,f=(c.loaded?c.loaded.duration:0)+o;c.loaded={bytes:d,duration:f},c.realBitrate=Math.round(8*d/f)}if(e.bitrateTest){const o={stats:s,frag:e,part:i,id:e.type};this.onFragBuffered(R.FRAG_BUFFERED,o),e.bitrateTest=!1}}}onFragBuffered(t,e){const{frag:i,part:s}=e,o=s!=null&&s.stats.loaded?s.stats:i.stats;if(o.aborted||this.ignoreFragment(i))return;const c=o.parsing.end-o.loading.start-Math.min(o.loading.first-o.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(c,o.loaded),o.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=c/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==Jt.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:o,minAutoLevel:c,media:d}=i,f=e?e.duration:t?t.duration:0,p=d&&d.playbackRate!==0?Math.abs(d.playbackRate):1,g=this.bwEstimator?this.bwEstimator.getEstimate():o.abrEwmaDefaultEstimate,v=i.mainForwardBufferInfo,b=(v?v.len:0)/p;let E=this.findBestLevel(g,c,s,b,o.abrBandWidthFactor,o.abrBandWidthUpFactor);if(E>=0)return E;z.trace(`[abr] ${b?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let T=f?Math.min(f,o.maxStarvationDelay):o.maxStarvationDelay,w=o.abrBandWidthFactor,_=o.abrBandWidthUpFactor;if(!b){const D=this.bitrateTestDelay;D&&(T=(f?Math.min(f,o.maxLoadingDelay):o.maxLoadingDelay)-D,z.trace(`[abr] bitrate test took ${Math.round(1e3*D)}ms, set first fragment max fetchDuration to ${Math.round(1e3*T)} ms`),w=_=1)}return E=this.findBestLevel(g,c,s,b+T,w,_),Math.max(E,0)}findBestLevel(t,e,i,s,o,c){var d;const{fragCurrent:f,partCurrent:p,lastLoadedFragLevel:g}=this,{levels:v}=this.hls,b=v[g],E=!!(b!=null&&(d=b.details)!=null&&d.live),T=b==null?void 0:b.codecSet,w=p?p.duration:f?f.duration:0,_=this.bwEstimator.getEstimateTTFB()/1e3;let D=e,M=-1;for(let F=i;F>=e;F--){const x=v[F];if(!x||T&&x.codecSet!==T){x&&(D=Math.min(F,D),M=Math.max(F,M));continue}M!==-1&&z.trace(`[abr] Skipped level(s) ${D}-${M} with CODECS:"${v[M].attrs.CODECS}"; not compatible with "${b.attrs.CODECS}"`);const N=x.details,V=(p?N==null?void 0:N.partTarget:N==null?void 0:N.averagetargetduration)||w;let j;F<=g?j=o*t:j=c*t;const rt=v[F].maxBitrate,nt=this.getTimeToLoadFrag(_,j,rt*V,N===void 0);if(z.trace(`[abr] level:${F} adjustedbw-bitrate:${Math.round(j-rt)} avgDuration:${V.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:${nt.toFixed(1)}`),j>rt&&(nt===0||!Vt(nt)||E&&!this.bitrateTestDelay||nt<s))return F}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}}class df{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=Rb(t,e);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function Rb(n,t){const e=new Uint8Array(t);let i=0;for(let s=0;s<n.length;s++){const o=n[s];e.set(o,i),i+=o.length}return e}const uf=100;class _b extends xc{constructor(t,e,i){super(t,e,i,"[audio-stream-controller]",Jt.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(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(R.ERROR,this.onError,this),t.on(R.BUFFER_RESET,this.onBufferReset,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this),t.on(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(R.ERROR,this.onError,this),t.off(R.BUFFER_RESET,this.onBufferReset,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this),t.off(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(t,{frag:e,id:i,initPTS:s,timescale:o}){if(i==="main"){const c=e.cc;this.initPTS[e.cc]={baseTime:s,timescale:o},this.log(`InitPTS for cc: ${c} found from main: ${s}`),this.videoTrackCC=c,this.state===kt.WAITING_INIT_PTS&&this.tick()}}startLoad(t){if(!this.levels){this.startPosition=t,this.state=kt.STOPPED;return}const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(uf),e>0&&t===-1?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=kt.IDLE):(this.loadedmetadata=!1,this.state=kt.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case kt.IDLE:this.doTickIdle();break;case kt.WAITING_TRACK:{var t;const{levels:i,trackId:s}=this,o=i==null||(t=i[s])==null?void 0:t.details;if(o){if(this.waitForCdnTuneIn(o))break;this.state=kt.WAITING_INIT_PTS}break}case kt.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=kt.IDLE);break}case kt.WAITING_INIT_PTS:{const i=this.waitingData;if(i){const{frag:s,part:o,cache:c,complete:d}=i;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=kt.FRAG_LOADING;const f=c.flush(),p={frag:s,part:o,payload:f,networkDetails:null};this._handleFragmentLoadProgress(p),d&&super._handleFragmentLoadComplete(p)}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 f=this.getLoadPosition(),p=Me.bufferInfo(this.mediaBuffer,f,this.config.maxBufferHole);Sc(p.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${p.end} is needed`),this.clearWaitingFragment())}}else this.state=kt.IDLE}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=kt.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,o=t.config;if(!(e!=null&&e[s])||!i&&(this.startFragRequested||!o.startFragPrefetch))return;const c=e[s],d=c.details;if(!d||d.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(d)){this.state=kt.WAITING_TRACK;return}const f=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&f&&(this.bufferFlushed=!1,this.afterBufferFlushed(f,Le.AUDIO,Jt.AUDIO));const p=this.getFwdBufferInfo(f,Jt.AUDIO);if(p===null)return;const{bufferedTrack:g,switchingTrack:v}=this;if(!v&&this._streamEnded(p,d)){t.trigger(R.BUFFER_EOS,{type:"audio"}),this.state=kt.ENDED;return}const b=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Jt.MAIN),E=p.len,T=this.getMaxBufferLength(b==null?void 0:b.len);if(E>=T&&!v)return;const w=d.fragments[0].start;let _=p.end;if(v&&i){const x=this.getLoadPosition();g&&v.attrs!==g.attrs&&(_=x),d.PTSKnown&&x<w&&(p.end>w||p.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=w+.05)}let D=this.getNextFragment(_,d),M=!1;if(D&&this.isLoopLoading(D,_)&&(M=!!D.gap,D=this.getNextFragmentLoopLoading(D,d,p,Jt.MAIN,T)),!D){this.bufferFlushed=!0;return}const F=b&&D.start>b.end+d.targetduration;if(F||!(b!=null&&b.len)&&p.len){const x=this.getAppendedFrag(D.start,Jt.MAIN);if(x===null||(M||(M=!!x.gap||!!F&&b.len===0),F&&!M||M&&p.nextStart&&p.nextStart<x.end))return}this.loadFragment(D,c,_)}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 Ra(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(uf):this.resetTransmuxer(),i?(this.switchingTrack=e,this.state=kt.IDLE):(this.switchingTrack=null,this.bufferedTrack=e,this.state=kt.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(R.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:o,id:c}=e;if(!s){this.warn(`Audio tracks were reset while loading level ${c}`);return}this.log(`Track ${c} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""},duration:${o.totalduration}`);const d=s[c];let f=0;if(o.live||(i=d.details)!=null&&i.live){this.checkLiveUpdate(o);const p=this.mainDetails;if(o.deltaUpdateFailed||!p)return;!d.details&&o.hasProgramDateTime&&p.hasProgramDateTime?(H0(o,p),f=o.fragments[0].start):f=this.alignPlaylists(o,d.details)}d.details=o,this.levelLastLoaded=c,!this.startFragRequested&&(this.mainDetails||!o.live)&&this.setStartPosition(d.details,f),this.state===kt.WAITING_TRACK&&!this.waitForCdnTuneIn(o)&&(this.state=kt.IDLE),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:s,payload:o}=t,{config:c,trackId:d,levels:f}=this;if(!f){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 p=f[d];if(!p){this.warn("Audio track is undefined on fragment load progress");return}const g=p.details;if(!g){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const v=c.defaultAudioCodec||p.audioCodec||"mp4a.40.2";let b=this.transmuxer;b||(b=this.transmuxer=new hf(this.hls,Jt.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const E=this.initPTS[i.cc],T=(e=i.initSegment)==null?void 0:e.data;if(E!==void 0){const w=s?s.index:-1,_=w!==-1,D=new Lc(i.level,i.sn,i.stats.chunkCount,o.byteLength,w,_);b.push(o,T,v,"",i,s,g.totalduration,!1,D,E)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${g.startSN} ,${g.endSN}],track ${d}`);const{cache:w}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new df,complete:!1};w.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=kt.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!==Jt.AUDIO){if(!this.loadedmetadata&&i.type===Jt.MAIN){const o=this.videoBuffer||this.media;o&&Me.getBuffered(o).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 o=this.switchingTrack;o&&(this.bufferedTrack=o,this.switchingTrack=null,this.hls.trigger(R.AUDIO_TRACK_SWITCHED,Vi({},o)))}this.fragBufferedComplete(i,s)}onError(t,e){var i;if(e.fatal){this.state=kt.ERROR;return}switch(e.details){case ut.FRAG_GAP:case ut.FRAG_PARSING_ERROR:case ut.FRAG_DECRYPT_ERROR:case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Jt.AUDIO,e);break;case ut.AUDIO_TRACK_LOAD_ERROR:case ut.AUDIO_TRACK_LOAD_TIMEOUT:case ut.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===kt.WAITING_TRACK&&((i=e.context)==null?void 0:i.type)===Te.AUDIO_TRACK&&(this.state=kt.IDLE);break;case ut.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 ut.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}onBufferFlushed(t,{type:e}){e===Le.AUDIO&&(this.bufferFlushed=!0,this.state===kt.ENDED&&(this.state=kt.IDLE))}_handleTransmuxComplete(t){var e;const i="audio",{hls:s}=this,{remuxResult:o,chunkMeta:c}=t,d=this.getCurrentContext(c);if(!d){this.resetWhenMissingContext(c);return}const{frag:f,part:p,level:g}=d,{details:v}=g,{audio:b,text:E,id3:T,initSegment:w}=o;if(this.fragContextChanged(f)||!v){this.fragmentTracker.removeFragment(f);return}if(this.state=kt.PARSING,this.switchingTrack&&b&&this.completeAudioSwitch(this.switchingTrack),w!=null&&w.tracks){const _=f.initSegment||f;this._bufferInitSegment(w.tracks,_,c),s.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:_,id:i,tracks:w.tracks})}if(b){const{startPTS:_,endPTS:D,startDTS:M,endDTS:F}=b;p&&(p.elementaryStreams[Le.AUDIO]={startPTS:_,endPTS:D,startDTS:M,endDTS:F}),f.setElementaryStreamInfo(Le.AUDIO,_,D,M,F),this.bufferFragmentData(b,f,p,c)}if(T!=null&&(e=T.samples)!=null&&e.length){const _=ai({id:i,frag:f,details:v},T);s.trigger(R.FRAG_PARSING_METADATA,_)}if(E){const _=ai({id:i,frag:f,details:v},E);s.trigger(R.FRAG_PARSING_USERDATA,_)}}_bufferInitSegment(t,e,i){if(this.state!==kt.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(R.BUFFER_CODECS,t);const o=s.initSegment;if(o!=null&&o.byteLength){const c={type:"audio",frag:e,part:null,chunkMeta:i,parent:e.type,data:o};this.hls.trigger(R.BUFFER_APPENDING,c)}this.tick()}loadFragment(t,e,i){const s=this.fragmentTracker.getState(t);if(this.fragCurrent=t,this.switchingTrack||s===ui.NOT_LOADED||s===ui.PARTIAL){var o;t.sn==="initSegment"?this._loadInitSegment(t,e):(o=e.details)!=null&&o.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=kt.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,o=s==null?void 0:s.attrs,c=t.attrs;i&&o&&(o.CHANNELS!==c.CHANNELS||o.NAME!==c.NAME||o.LANGUAGE!==c.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(R.AUDIO_TRACK_SWITCHED,Vi({},t))}}class Lb extends Rc{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(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(R.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(R.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:o}=e,c=this.tracksInGroup[i];if(!c||c.groupId!==s){this.warn(`Track with id:${i} and group:${s} not found in active group ${c.groupId}`);return}const d=c.details;c.details=e.details,this.log(`audio-track ${i} "${c.name}" lang:${c.lang} group:${s} loaded [${o.startSN}-${o.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,d)}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(c=>!i||c.groupId===i);this.selectDefaultTrack&&!s.some(c=>c.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=s;const o={audioTracks:s};this.log(`Updating audio tracks, ${s.length} track(s) found in group:${i}`),this.hls.trigger(R.AUDIO_TRACKS_UPDATED,o),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(t,e){e.fatal||!e.context||e.context.type===Te.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:o,name:c}=s;if(this.log(`Switching to audio-track ${t} "${c}" lang:${s.lang} group:${o}`),this.trackId=t,this.currentTrack=s,this.selectDefaultTrack=!1,this.hls.trigger(R.AUDIO_TRACK_SWITCHING,Vi({},s)),s.details&&!s.details.live)return;const d=this.switchParams(s.url,i==null?void 0:i.details);this.loadPlaylist(d)}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(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.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 o=e.url;if(t)try{o=t.addDirectives(o)}catch(c){this.warn(`Could not construct new URL with HLS Delivery Directives: ${c}`)}this.log(`loading audio-track playlist ${i} "${e.name}" lang:${e.lang} group:${s}`),this.clearTimer(),this.hls.trigger(R.AUDIO_TRACK_LOADING,{url:o,id:i,groupId:s,deliveryDirectives:t||null})}}}function ff(n,t){if(n.length!==t.length)return!1;for(let e=0;e<n.length;e++)if(!Cb(n[e].attrs,t[e].attrs))return!1;return!0}function Cb(n,t){const e=n["STABLE-RENDITION-ID"];return e?e===t["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>n[i]!==t[i])}const pf=500;class Ib extends xc{constructor(t,e,i){super(t,e,i,"[subtitle-stream-controller]",Jt.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(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.ERROR,this.onError,this),t.on(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(R.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(R.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.ERROR,this.onError,this),t.off(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(R.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(R.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=kt.IDLE,this.setInterval(pf),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=kt.IDLE,!s)return;const o=this.tracksBuffered[this.currentTrackId];if(!o)return;let c;const d=i.start;for(let p=0;p<o.length;p++)if(d>=o[p].start&&d<=o[p].end){c=o[p];break}const f=i.start+i.duration;c?c.end=f:(c={start:d,end:f},o.push(c)),this.fragmentTracker.fragBuffered(i)}onBufferFlushing(t,e){const{startOffset:i,endOffset:s}=e;if(i===0&&s!==Number.POSITIVE_INFINITY){const o=s-1;if(o<=0)return;e.endOffsetSubtitles=Math.max(0,o),this.tracksBuffered.forEach(c=>{for(let d=0;d<c.length;){if(c[d].end<=o){c.shift();continue}else if(c[d].start<o)c[d].start=o;else break;d++}}),this.fragmentTracker.removeFragmentsInRange(i,o,Jt.SUBTITLE)}}onFragBuffered(t,e){if(!this.loadedmetadata&&e.frag.type===Jt.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)===Jt.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==kt.STOPPED&&(this.state=kt.IDLE))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){if(ff(this.levels,e)){this.levels=e.map(i=>new Ra(i));return}this.tracksBuffered=[],this.levels=e.map(i=>{const s=new Ra(i);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Jt.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(pf)}onSubtitleTrackLoaded(t,e){var i;const{details:s,id:o}=e,{currentTrackId:c,levels:d}=this;if(!d.length)return;const f=d[c];if(o>=d.length||o!==c||!f)return;this.mediaBuffer=this.mediaBufferTimeRanges;let p=0;if(s.live||(i=f.details)!=null&&i.live){const g=this.mainDetails;if(s.deltaUpdateFailed||!g)return;const v=g.fragments[0];f.details?(p=this.alignPlaylists(s,f.details),p===0&&v&&(p=v.start,kc(s,p))):s.hasProgramDateTime&&g.hasProgramDateTime?(H0(s,g),p=s.fragments[0].start):v&&(p=v.start,kc(s,p))}f.details=s,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!s.live)&&this.setStartPosition(f.details,p),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===kt.IDLE&&(_a(null,s.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),f.details=void 0))}_handleFragmentLoadComplete(t){const{frag:e,payload:i}=t,s=e.decryptdata,o=this.hls;if(!this.fragContextChanged(e)&&i&&i.byteLength>0&&s&&s.key&&s.iv&&s.method==="AES-128"){const c=performance.now();this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer).catch(d=>{throw o.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_DECRYPT_ERROR,fatal:!1,error:d,reason:d.message,frag:e}),d}).then(d=>{const f=performance.now();o.trigger(R.FRAG_DECRYPTED,{frag:e,payload:d,stats:{tstart:c,tdecrypt:f}})}).catch(d=>{this.warn(`${d.name}: ${d.message}`),this.state=kt.IDLE})}}doTick(){if(!this.media){this.state=kt.IDLE;return}if(this.state===kt.IDLE){const{currentTrackId:t,levels:e}=this,i=e[t];if(!e.length||!i||!i.details)return;const{config:s}=this,o=this.getLoadPosition(),c=Me.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o,s.maxBufferHole),{end:d,len:f}=c,p=this.getFwdBufferInfo(this.media,Jt.MAIN),g=i.details,v=this.getMaxBufferLength(p==null?void 0:p.len)+g.levelTargetDuration;if(f>v)return;const b=g.fragments,E=b.length,T=g.edge;let w=null;const _=this.fragPrevious;if(d<T){const D=s.maxFragLookUpTolerance,M=d>T-D?0:D;w=_a(_,b,Math.max(b[0].start,d),M),!w&&_&&_.start<b[0].start&&(w=b[0])}else w=b[E-1];if(!w)return;if(w=this.mapToInitFragWhenRequired(w),w.sn!=="initSegment"){const D=w.sn-g.startSN,M=b[D-1];M&&M.cc===w.cc&&this.fragmentTracker.getState(M)===ui.NOT_LOADED&&(w=M)}this.fragmentTracker.getState(w)===ui.NOT_LOADED&&this.loadFragment(w,i,d)}}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 xb(this.tracksBuffered[this.currentTrackId]||[])}}class xb{constructor(t){this.buffered=void 0;const e=(i,s,o)=>{if(s=s>>>0,s>o-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${o})`);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 Db extends Rc{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(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(R.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(R.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),Vc(this.media.textTracks).forEach(t=>{Rn(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:o}=this,c=this.tracksInGroup[o];if(!c){this.warn(`Invalid subtitle track id ${i}`);return}const d=c.details;c.details=e.details,this.log(`subtitle track ${i} loaded [${s.startSN}-${s.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,d)}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 o=this.tracks.filter(f=>!i||f.groupId===i);this.tracksInGroup=o;const c=this.findTrackId(s==null?void 0:s.name)||this.findTrackId();this.groupId=i||null;const d={subtitleTracks:o};this.log(`Updating subtitle tracks, ${o.length} track(s) found in "${i}" group-id`),this.hls.trigger(R.SUBTITLE_TRACKS_UPDATED,d),c!==-1&&this.setSubtitleTrack(c,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===Te.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 o=e.url;if(t)try{o=t.addDirectives(o)}catch(c){this.warn(`Could not construct new URL with HLS Delivery Directives: ${c}`)}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(R.SUBTITLE_TRACK_LOADING,{url:o,id:i,groupId:s,deliveryDirectives:t||null})}}toggleTrackModes(t){const{media:e,trackId:i}=this;if(!e)return;const s=Vc(e.textTracks),o=s.filter(d=>d.groupId===this.groupId);if(t===-1)[].slice.call(s).forEach(d=>{d.mode="disabled"});else{const d=o[i];d&&(d.mode="disabled")}const c=o[t];c&&(c.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 o=s[t];if(this.log(`Switching to subtitle-track ${t}`+(o?` "${o.name}" lang:${o.lang} group:${o.groupId}`:"")),this.trackId=t,o){const{id:c,groupId:d="",name:f,type:p,url:g}=o;this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:c,groupId:d,name:f,type:p,url:g});const v=this.switchParams(o.url,e==null?void 0:e.details);this.loadPlaylist(v)}else this.hls.trigger(R.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=Vc(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 Vc(n){const t=[];for(let e=0;e<n.length;e++){const i=n[e];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&t.push(n[e])}return t}class Pb{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(o=>{e=o}),s={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,t),i}executeNext(t){const{buffers:e,queues:i}=this,s=e[t],o=i[t];if(o.length){const c=o[0];try{c.execute()}catch(d){z.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),c.onError(d),s!=null&&s.updating||(o.shift(),this.executeNext(t))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const gf=So(),mf=/([ha]vc.)(?:\.[^.,]+)+/;class Ob{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;z.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(R.MEDIA_ATTACHED,{media:e})),i&&i.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{z.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{z.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:i}=this;e&&e.src!==i&&z.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(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.BUFFER_RESET,this.onBufferReset,this),t.on(R.BUFFER_APPENDING,this.onBufferAppending,this),t.on(R.BUFFER_CODECS,this.onBufferCodecs,this),t.on(R.BUFFER_EOS,this.onBufferEos,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(R.FRAG_PARSED,this.onFragParsed,this),t.on(R.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.BUFFER_RESET,this.onBufferReset,this),t.off(R.BUFFER_APPENDING,this.onBufferAppending,this),t.off(R.BUFFER_CODECS,this.onBufferCodecs,this),t.off(R.BUFFER_EOS,this.onBufferEos,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(R.FRAG_PARSED,this.onFragParsed,this),t.off(R.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Pb(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,z.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const i=this.media=e.media;if(i&&gf){const s=this.mediaSource=new gf;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(z.log("[buffer-controller]: media source detaching"),e.readyState==="open")try{e.endOfStream()}catch(s){z.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()):z.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(R.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){z.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 o=this.tracks[s];if(o&&typeof o.buffer.changeType=="function"){const{id:c,codec:d,levelCodec:f,container:p,metadata:g}=e[s],v=(o.levelCodec||o.codec).replace(mf,"$1"),b=(f||d).replace(mf,"$1");if(v!==b){const E=`${p};codecs=${f||d}`;this.appendChangeType(s,E),z.log(`[buffer-controller]: switching codec ${v} to ${b}`),this.tracks[s]={buffer:o.buffer,codec:d,container:p,levelCodec:f,metadata:g,id:c}}}}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 o=this.sourceBuffer[t];o&&(z.log(`[buffer-controller]: changing ${t} sourceBuffer type to ${e}`),o.changeType(e)),i.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:o=>{z.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,o)}};i.append(s,t)}onBufferAppending(t,e){const{hls:i,operationQueue:s,tracks:o}=this,{data:c,type:d,frag:f,part:p,chunkMeta:g}=e,v=g.buffering[d],b=self.performance.now();v.start=b;const E=f.stats.buffering,T=p?p.stats.buffering:null;E.start===0&&(E.start=b),T&&T.start===0&&(T.start=b);const w=o.audio;let _=!1;d==="audio"&&(w==null?void 0:w.container)==="audio/mpeg"&&(_=!this.lastMpegAudioChunk||g.id===1||this.lastMpegAudioChunk.sn!==g.sn,this.lastMpegAudioChunk=g);const D=f.start,M={execute:()=>{if(v.executeStart=self.performance.now(),_){const F=this.sourceBuffer[d];if(F){const x=D-F.timestampOffset;Math.abs(x)>=.1&&(z.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${D} (delta: ${x}) sn: ${f.sn})`),F.timestampOffset=D)}}this.appendExecutor(c,d)},onStart:()=>{},onComplete:()=>{const F=self.performance.now();v.executeEnd=v.end=F,E.first===0&&(E.first=F),T&&T.first===0&&(T.first=F);const{sourceBuffer:x}=this,N={};for(const V in x)N[V]=Me.getBuffered(x[V]);this.appendError=0,this.hls.trigger(R.BUFFER_APPENDED,{type:d,frag:f,part:p,chunkMeta:g,parent:f.type,timeRanges:N})},onError:F=>{z.error(`[buffer-controller]: Error encountered while trying to append to the ${d} SourceBuffer`,F);const x={type:qt.MEDIA_ERROR,parent:f.type,details:ut.BUFFER_APPEND_ERROR,frag:f,part:p,chunkMeta:g,error:F,err:F,fatal:!1};F.code===DOMException.QUOTA_EXCEEDED_ERR?x.details=ut.BUFFER_FULL_ERROR:(this.appendError++,x.details=ut.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(z.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),x.fatal=!0)),i.trigger(R.ERROR,x)}};s.append(M,d)}onBufferFlushing(t,e){const{operationQueue:i}=this,s=o=>({execute:this.removeExecutor.bind(this,o,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(R.BUFFER_FLUSHED,{type:o})},onError:c=>{z.warn(`[buffer-controller]: Failed to remove from ${o} SourceBuffer`,c)}});e.type?i.append(s(e.type),e.type):this.getSourceBufferTypes().forEach(o=>{i.append(s(o),o)})}onFragParsed(t,e){const{frag:i,part:s}=e,o=[],c=s?s.elementaryStreams:i.elementaryStreams;c[Le.AUDIOVIDEO]?o.push("audiovideo"):(c[Le.AUDIO]&&o.push("audio"),c[Le.VIDEO]&&o.push("video"));const d=()=>{const f=self.performance.now();i.stats.buffering.end=f,s&&(s.stats.buffering.end=f);const p=s?s.stats:i.stats;this.hls.trigger(R.FRAG_BUFFERED,{frag:i,part:s,stats:p,id:i.type})};o.length===0&&z.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(d,o)}onFragChanged(t,e){this.flushBackBuffer()}onBufferEos(t,e){this.getSourceBufferTypes().reduce((i,s)=>{const o=this.sourceBuffer[s];return o&&(!e.type||e.type===s)&&(o.ending=!0,o.ended||(o.ended=!0,z.log(`[buffer-controller]: ${s} sourceBuffer now EOS`))),i&&!!(!o||o.ended)},!0)&&(z.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(s=>{const o=this.sourceBuffer[s];o&&(o.ending=!1)});const{mediaSource:i}=this;if(!i||i.readyState!=="open"){i&&z.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${i.readyState}`);return}z.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 o=this.getSourceBufferTypes();if(!o.length)return;const c=e.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(!Vt(c)||c<0)return;const d=i.currentTime,f=e.levelTargetDuration,p=Math.max(c,f),g=Math.floor(d/f)*f-p;o.forEach(v=>{const b=s[v];if(b){const E=Me.getBuffered(b);if(E.length>0&&g>E.start(0)){if(t.trigger(R.BACK_BUFFER_REACHED,{bufferEnd:g}),e.live)t.trigger(R.LIVE_BACK_BUFFER_REACHED,{bufferEnd:g});else if(b.ended&&E.end(E.length-1)-d<f*2){z.info(`[buffer-controller]: Cannot flush ${v} back buffer while SourceBuffer is in ended state`);return}t.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:g,type:v})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:t,hls:e,media:i,mediaSource:s}=this,o=t.fragments[0].start+t.totalduration,c=i.duration,d=Vt(s.duration)?s.duration:0;t.live&&e.config.liveDurationInfinity?(z.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(t)):(o>d&&o>c||!Vt(c))&&(z.log(`[buffer-controller]: Updating Media Source duration to ${o.toFixed(3)}`),s.duration=o)}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),o=Math.max(s,s+t.totalduration);e.setLiveSeekableRange(s,o)}}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 o=this.getSourceBufferTypes();if(o.length)this.hls.trigger(R.BUFFER_CREATED,{tracks:this.tracks}),o.forEach(c=>{e.executeNext(c)});else{const c=new Error("could not create source buffer for media codec(s)");this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:c,reason:c.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 o=t[s];if(!o)throw Error(`source buffer exists for track ${s}, however track does not`);const c=o.levelCodec||o.codec,d=`${o.container};codecs=${c}`;z.log(`[buffer-controller]: creating sourceBuffer(${d})`);try{const f=e[s]=i.addSourceBuffer(d),p=s;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[s]={buffer:f,codec:c,container:o.container,levelCodec:o.levelCodec,metadata:o.metadata,id:o.id}}catch(f){z.error(`[buffer-controller]: error while trying to add sourceBuffer: ${f.message}`),this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:f,mimeType:d})}}}_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`);z.error(`[buffer-controller]: ${i}`,e),this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.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:o,operationQueue:c,sourceBuffer:d}=this,f=d[t];if(!s||!o||!f){z.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),c.shiftAndExecuteNext(t);return}const p=Vt(s.duration)?s.duration:1/0,g=Vt(o.duration)?o.duration:1/0,v=Math.max(0,e),b=Math.min(i,p,g);b>v&&!f.ending?(f.ended=!1,z.log(`[buffer-controller]: Removing [${v},${b}] from the ${t} SourceBuffer`),f.remove(v,b)):c.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:i,sourceBuffer:s}=this,o=s[e];if(!o){z.warn(`[buffer-controller]: Attempting to append to the ${e} SourceBuffer, but it does not exist`),i.shiftAndExecuteNext(e);return}o.ended=!1,o.appendBuffer(t)}blockBuffers(t,e=this.getSourceBufferTypes()){if(!e.length){z.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);return}const{operationQueue:i}=this,s=e.map(o=>i.appendBlocker(o));Promise.all(s).then(()=>{t(),e.forEach(o=>{const c=this.sourceBuffer[o];c!=null&&c.updating||i.shiftAndExecuteNext(o)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,i){const s=this.sourceBuffer[t];if(!s)return;const o=i.bind(this,t);this.listeners[t].push({event:e,listener:o}),s.addEventListener(e,o)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach(i=>{e.removeEventListener(i.event,i.listener)})}}const vf={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},yf=function(n){let t=n;return vf.hasOwnProperty(n)&&(t=vf[n]),String.fromCharCode(t)},Er=15,es=100,Mb={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},$b={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Nb={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Fb={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ub=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Bb{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const i=typeof e=="function"?e():e;z.log(`${this.time} [${t}] ${i}`)}}}const cn=function(n){const t=[];for(let e=0;e<n.length;e++)t.push(n[e].toString(16));return t};class bf{constructor(t,e,i,s,o){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=o||!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 Gb{constructor(t,e,i,s,o,c){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new bf(e,i,s,o,c)}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 Hb{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<es;e++)this.chars.push(new Gb);this.logger=t,this.pos=0,this.currPenState=new bf}equals(t){let e=!0;for(let i=0;i<es;i++)if(!this.chars[i].equals(t.chars[i])){e=!1;break}return e}copy(t){for(let e=0;e<es;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<es;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>es&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=es)}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=yf(t);if(this.pos>=es){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<es;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<es;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 Wc{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<Er;e++)this.rows.push(new Hb(t));this.logger=t,this.currRow=Er-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let t=0;t<Er;t++)this.rows[t].clear();this.currRow=Er-1}equals(t){let e=!0;for(let i=0;i<Er;i++)if(!this.rows[i].equals(t.rows[i])){e=!1;break}return e}copy(t){for(let e=0;e<Er;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<Er;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 d=0;d<Er;d++)this.rows[d].clear();const o=this.currRow+1-this.nrRollUpRows,c=this.lastOutputScreen;if(c){const d=c.rows[o].cueStartTime,f=this.logger.time;if(d&&f!==null&&d<f)for(let p=0;p<this.nrRollUpRows;p++)this.rows[e-this.nrRollUpRows+p+1].copy(c.rows[o+p])}}this.currRow=e;const i=this.rows[this.currRow];if(t.indent!==null){const o=t.indent,c=Math.max(o-1,0);i.setCursor(t.indent),t.color=i.chars[c].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 o=0;o<Er;o++){const c=this.rows[o].getTextString();c&&(s=o+1,t?e.push("Row "+s+": '"+c+"'"):e.push(c.trim()))}return e.length>0&&(t?i="["+e.join(" | ")+"]":i=e.join(`
197
+ `)),i}getTextAndFormat(){return this.rows}}class Af{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 Wc(i),this.nonDisplayedMemory=new Wc(i),this.lastOutputScreen=new Wc(i),this.currRollUpRow=this.displayedMemory.rows[Er-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[Er-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 Ef{constructor(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const s=new Bb;this.channels=[null,new Af(t,e,s),new Af(t+1,i,s)],this.cmdHistory=kf(),this.logger=s}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let i,s,o,c=!1;this.logger.time=t;for(let d=0;d<e.length;d+=2)if(s=e[d]&127,o=e[d+1]&127,!(s===0&&o===0)){if(this.logger.log(3,"["+cn([e[d],e[d+1]])+"] -> ("+cn([s,o])+")"),i=this.parseCmd(s,o),i||(i=this.parseMidrow(s,o)),i||(i=this.parsePAC(s,o)),i||(i=this.parseBackgroundAttributes(s,o)),!i&&(c=this.parseChars(s,o),c)){const f=this.currentChannel;f&&f>0?this.channels[f].insertChars(c):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!i&&!c&&this.logger.log(2,"Couldn't parse cleaned data "+cn([s,o])+" orig: "+cn([e[d],e[d+1]]))}}parseCmd(t,e){const{cmdHistory:i}=this,s=(t===20||t===28||t===21||t===29)&&e>=32&&e<=47,o=(t===23||t===31)&&e>=33&&e<=35;if(!(s||o))return!1;if(Tf(t,e,i))return In(null,null,i),this.logger.log(3,"Repeated command ("+cn([t,e])+") is dropped"),!0;const c=t===20||t===21||t===23?1:2,d=this.channels[c];return t===20||t===21||t===28||t===29?e===32?d.ccRCL():e===33?d.ccBS():e===34?d.ccAOF():e===35?d.ccAON():e===36?d.ccDER():e===37?d.ccRU(2):e===38?d.ccRU(3):e===39?d.ccRU(4):e===40?d.ccFON():e===41?d.ccRDC():e===42?d.ccTR():e===43?d.ccRTD():e===44?d.ccEDM():e===45?d.ccCR():e===46?d.ccENM():e===47&&d.ccEOC():d.ccTO(e-32),In(t,e,i),this.currentChannel=c,!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 ("+cn([t,e])+")"),!0):!1}return!1}parsePAC(t,e){let i;const s=this.cmdHistory,o=(t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127,c=(t===16||t===24)&&e>=64&&e<=95;if(!(o||c))return!1;if(Tf(t,e,s))return In(null,null,s),!0;const d=t<=23?1:2;e>=64&&e<=95?i=d===1?Mb[t]:Nb[t]:i=d===1?$b[t]:Fb[t];const f=this.channels[d];return f?(f.setPAC(this.interpretPAC(i,e)),In(t,e,s),this.currentChannel=d,!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,o=null;if(t>=25?(i=2,o=t-8):(i=1,o=t),o>=17&&o<=19){let c;o===17?c=e+80:o===18?c=e+112:c=e+144,this.logger.log(2,"Special char '"+yf(c)+"' in channel "+i),s=[c]}else t>=32&&t<=127&&(s=e===0?[t]:[t,e]);if(s){const c=cn(s);this.logger.log(3,"Char codes = "+c.join(",")),In(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 o;const c={};t===16||t===24?(o=Math.floor((e-32)/2),c.background=Ub[o],e%2===1&&(c.background=c.background+"_semi")):e===45?c.background="transparent":(c.foreground="black",e===47&&(c.underline=!0));const d=t<=23?1:2;return this.channels[d].setBkgData(c),In(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=kf()}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const i=this.channels[e];i&&i.cueSplitAtTime(t)}}}function In(n,t,e){e.a=n,e.b=t}function Tf(n,t,e){return e.a===n&&e.b===t}function kf(){return{a:null,b:null}}class No{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 jc=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const n=["","lr","rl"],t=["start","middle","end","left","right"];function e(d,f){if(typeof f!="string"||!Array.isArray(d))return!1;const p=f.toLowerCase();return~d.indexOf(p)?p:!1}function i(d){return e(n,d)}function s(d){return e(t,d)}function o(d,...f){let p=1;for(;p<arguments.length;p++){const g=arguments[p];for(const v in g)d[v]=g[v]}return d}function c(d,f,p){const g=this,v={enumerable:!0};g.hasBeenReset=!1;let b="",E=!1,T=d,w=f,_=p,D=null,M="",F=!0,x="auto",N="start",V=50,j="middle",rt=50,nt="middle";Object.defineProperty(g,"id",o({},v,{get:function(){return b},set:function(Q){b=""+Q}})),Object.defineProperty(g,"pauseOnExit",o({},v,{get:function(){return E},set:function(Q){E=!!Q}})),Object.defineProperty(g,"startTime",o({},v,{get:function(){return T},set:function(Q){if(typeof Q!="number")throw new TypeError("Start time must be set to a number.");T=Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"endTime",o({},v,{get:function(){return w},set:function(Q){if(typeof Q!="number")throw new TypeError("End time must be set to a number.");w=Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"text",o({},v,{get:function(){return _},set:function(Q){_=""+Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"region",o({},v,{get:function(){return D},set:function(Q){D=Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"vertical",o({},v,{get:function(){return M},set:function(Q){const Tt=i(Q);if(Tt===!1)throw new SyntaxError("An invalid or illegal string was specified.");M=Tt,this.hasBeenReset=!0}})),Object.defineProperty(g,"snapToLines",o({},v,{get:function(){return F},set:function(Q){F=!!Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"line",o({},v,{get:function(){return x},set:function(Q){if(typeof Q!="number"&&Q!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");x=Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"lineAlign",o({},v,{get:function(){return N},set:function(Q){const Tt=s(Q);if(!Tt)throw new SyntaxError("An invalid or illegal string was specified.");N=Tt,this.hasBeenReset=!0}})),Object.defineProperty(g,"position",o({},v,{get:function(){return V},set:function(Q){if(Q<0||Q>100)throw new Error("Position must be between 0 and 100.");V=Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"positionAlign",o({},v,{get:function(){return j},set:function(Q){const Tt=s(Q);if(!Tt)throw new SyntaxError("An invalid or illegal string was specified.");j=Tt,this.hasBeenReset=!0}})),Object.defineProperty(g,"size",o({},v,{get:function(){return rt},set:function(Q){if(Q<0||Q>100)throw new Error("Size must be between 0 and 100.");rt=Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"align",o({},v,{get:function(){return nt},set:function(Q){const Tt=s(Q);if(!Tt)throw new SyntaxError("An invalid or illegal string was specified.");nt=Tt,this.hasBeenReset=!0}})),g.displayState=void 0}return c.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},c}();class Vb{decode(t,e){if(!t)return"";if(typeof t!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function wf(n){function t(i,s,o,c){return(i|0)*3600+(s|0)*60+(o|0)+parseFloat(c||0)}const e=n.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 Wb{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 Sf(n,t,e,i){const s=i?n.split(i):[n];for(const o in s){if(typeof s[o]!="string")continue;const c=s[o].split(e);if(c.length!==2)continue;const d=c[0],f=c[1];t(d,f)}}const Kc=new jc(0,0,""),Fo=Kc.align==="middle"?"middle":"center";function jb(n,t,e){const i=n;function s(){const d=wf(n);if(d===null)throw new Error("Malformed timestamp: "+i);return n=n.replace(/^[^\sa-zA-Z-]+/,""),d}function o(d,f){const p=new Wb;Sf(d,function(b,E){let T;switch(b){case"region":for(let w=e.length-1;w>=0;w--)if(e[w].id===E){p.set(b,e[w].region);break}break;case"vertical":p.alt(b,E,["rl","lr"]);break;case"line":T=E.split(","),p.integer(b,T[0]),p.percent(b,T[0])&&p.set("snapToLines",!1),p.alt(b,T[0],["auto"]),T.length===2&&p.alt("lineAlign",T[1],["start",Fo,"end"]);break;case"position":T=E.split(","),p.percent(b,T[0]),T.length===2&&p.alt("positionAlign",T[1],["start",Fo,"end","line-left","line-right","auto"]);break;case"size":p.percent(b,E);break;case"align":p.alt(b,E,["start",Fo,"end","left","right"]);break}},/:/,/\s/),f.region=p.get("region",null),f.vertical=p.get("vertical","");let g=p.get("line","auto");g==="auto"&&Kc.line===-1&&(g=-1),f.line=g,f.lineAlign=p.get("lineAlign","start"),f.snapToLines=p.get("snapToLines",!0),f.size=p.get("size",100),f.align=p.get("align",Fo);let v=p.get("position","auto");v==="auto"&&Kc.position===50&&(v=f.align==="start"||f.align==="left"?0:f.align==="end"||f.align==="right"?100:50),f.position=v}function c(){n=n.replace(/^\s+/,"")}if(c(),t.startTime=s(),c(),n.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);n=n.slice(3),c(),t.endTime=s(),c(),o(n,t)}function Rf(n){return n.replace(/<br(?: \/)?>/gi,`
198
+ `)}class Kb{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Vb,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 o=e.buffer,c=0;for(o=Rf(o);c<o.length&&o[c]!=="\r"&&o[c]!==`
199
+ `;)++c;const d=o.slice(0,c);return o[c]==="\r"&&++c,o[c]===`
200
+ `&&++c,e.buffer=o.slice(c),d}function s(o){Sf(o,function(c,d){},/:/)}try{let o="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;o=i();const d=o.match(/^()?WEBVTT([ \t].*)?$/);if(!(d!=null&&d[0]))throw new Error("Malformed WebVTT signature.");e.state="HEADER"}let c=!1;for(;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(c?c=!1:o=i(),e.state){case"HEADER":/:/.test(o)?s(o):o||(e.state="ID");continue;case"NOTE":o||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(o)){e.state="NOTE";break}if(!o)continue;if(e.cue=new jc(0,0,""),e.state="CUE",o.indexOf("-->")===-1){e.cue.id=o;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{jb(o,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{const d=o.indexOf("-->")!==-1;if(!o||d&&(c=!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+=`
201
+ `),e.cue.text+=o}continue;case"BADCUE":o||(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+=`
202
+
203
+ `,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 Yb=/\r\n|\n\r|\n|\r/g,Yc=function(n,t,e=0){return n.slice(e,e+t.length)===t},zb=function(n){let t=parseInt(n.slice(-3));const e=parseInt(n.slice(-6,-4)),i=parseInt(n.slice(-9,-7)),s=n.length>9?parseInt(n.substring(0,n.indexOf(":"))):0;if(!Vt(t)||!Vt(e)||!Vt(i)||!Vt(s))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${n}`);return t+=1e3*e,t+=60*1e3*i,t+=60*60*1e3*s,t},zc=function(n){let t=5381,e=n.length;for(;e;)t=t*33^n.charCodeAt(--e);return(t>>>0).toString()};function Xc(n,t,e){return zc(n.toString())+zc(t.toString())+zc(e)}const Xb=function(n,t,e){let i=n[t],s=n[i.prevCC];if(!s||!s.new&&i.new){n.ccOffset=n.presentationOffset=i.start,i.new=!1;return}for(;(o=s)!=null&&o.new;){var o;n.ccOffset+=i.start-s.start,i.new=!1,i=s,s=n[i.prevCC]}n.presentationOffset=e};function Zb(n,t,e,i,s,o,c){const d=new Kb,f=Pr(new Uint8Array(n)).trim().replace(Yb,`
185
204
  `).split(`
186
- `),h=[],c=t?nm(t.baseTime,t.timescale):0;let d="00:00.000",u=0,f=0,p,g=!0;o.oncue=function(v){const E=e[i];let A=e.ccOffset;const L=(u-c)/9e4;if(E!=null&&E.new&&(f!==void 0?A=e.ccOffset=E.start:Ym(e,i,L)),L){if(!t){p=new Error("Missing initPTS for VTT MPEGTS");return}A=L-e.presentationOffset}const y=v.endTime-v.startTime,S=ce((v.startTime+A-f)*9e4,s*9e4)/9e4;v.startTime=Math.max(S,0),v.endTime=Math.max(S+y,0);const R=v.text.trim();v.text=decodeURIComponent(encodeURIComponent(R)),v.id||(v.id=la(v.startTime,v.endTime,R)),v.endTime>0&&h.push(v)},o.onparsingerror=function(v){p=v},o.onflush=function(){if(p){a(p);return}n(h)},l.forEach(v=>{if(g)if(aa(v,"X-TIMESTAMP-MAP=")){g=!1,v.slice(16).split(",").forEach(E=>{aa(E,"LOCAL:")?d=E.slice(6):aa(E,"MPEGTS:")&&(u=parseInt(E.slice(7)))});try{f=Wm(d)/1e3}catch(E){p=E}return}else v===""&&(g=!1);o.parse(v+`
187
- `)}),o.flush()}const ha="stpp.ttml.im1t",sc=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,rc=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,zm={left:"start",center:"center",right:"end",start:"start",end:"end"};function nc(r,t,e,i){const s=ot(new Uint8Array(r),["mdat"]);if(s.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const n=s.map(o=>Le(o)),a=rm(t.baseTime,1,t.timescale);try{n.forEach(o=>e(Xm(o,a)))}catch(o){i(o)}}function Xm(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,c)=>(h[c]=e.getAttribute(`ttp:${c}`)||i[c],h),{}),n=e.getAttribute("xml:space")!=="preserve",a=ac(ca(e,"styling","style")),o=ac(ca(e,"layout","region")),l=ca(e,"body","[begin]");return[].map.call(l,h=>{const c=oc(h,n);if(!c||!h.hasAttribute("begin"))return null;const d=ua(h.getAttribute("begin"),s),u=ua(h.getAttribute("dur"),s);let f=ua(h.getAttribute("end"),s);if(d===null)throw lc(h);if(f===null){if(u===null)throw lc(h);f=d+u}const p=new ra(d-t,f-t,c);p.id=la(p.startTime,p.endTime,p.text);const g=o[h.getAttribute("region")],v=a[h.getAttribute("style")],E=Qm(g,v,a),{textAlign:A}=E;if(A){const L=zm[A];L&&(p.lineAlign=L),p.align=A}return xt(p,E),p}).filter(h=>h!==null)}function ca(r,t,e){const i=r.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(e)):[]}function ac(r){return r.reduce((t,e)=>{const i=e.getAttribute("xml:id");return i&&(t[i]=e),t},{})}function oc(r,t){return[].slice.call(r.childNodes).reduce((e,i,s)=>{var n;return i.nodeName==="br"&&s?e+`
188
- `:(n=i.childNodes)!=null&&n.length?oc(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function Qm(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=da(t,i,l)||da(r,i,l)||da(s,i,l);return h&&(o[l]=h),o},{})}function da(r,t,e){return r&&r.hasAttributeNS(t,e)?r.getAttributeNS(t,e):null}function lc(r){return new Error(`Could not parse ttml timestamp ${r}`)}function ua(r,t){if(!r)return null;let e=tc(r);return e===null&&(sc.test(r)?e=Zm(r,t):rc.test(r)&&(e=Jm(r,t))),e}function Zm(r,t){const e=sc.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 Jm(r,t){const e=rc.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 tv{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=hc(),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 vr(this,"textTrack1"),i=new vr(this,"textTrack2"),s=new vr(this,"textTrack3"),n=new vr(this,"textTrack4");this.cea608Parser1=new Qh(1,e,i),this.cea608Parser2=new Qh(3,s,n)}t.on(m.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(m.MANIFEST_LOADING,this.onManifestLoading,this),t.on(m.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(m.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(m.FRAG_LOADING,this.onFragLoading,this),t.on(m.FRAG_LOADED,this.onFragLoaded,this),t.on(m.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(m.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(m.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(m.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(m.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(m.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(m.MANIFEST_LOADING,this.onManifestLoading,this),t.off(m.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(m.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(m.FRAG_LOADING,this.onFragLoading,this),t.off(m.FRAG_LOADED,this.onFragLoaded,this),t.off(m.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(m.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(m.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(m.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(m.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=iv(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(m.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(m.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,Ri(i[t]),sh(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(m.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=>{Ri(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=hc(),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++)Ri(e[i])}onSubtitleTracksUpdated(t,e){const i=e.subtitleTracks||[],s=i.some(n=>n.textCodec===ha);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(Vh(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 c=0;c<n.length;c++)if(ev(n[c],a)){h=n[c];break}h&&(l=h)}if(l)Ri(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(m.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===Z.MAIN){var o,l;const h=e.frag.sn,c=(o=e==null||(l=e.part)==null?void 0:l.index)!=null?o:-1;h===n+1||h===n&&c===a+1||(i.reset(),s.reset()),this.lastSn=h,this.lastPartIndex=c}}onFragLoaded(t,e){const{frag:i,payload:s}=e;if(i.type===Z.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===ha?this._parseIMSC1(i,s):this._parseVTTs(e)}}else this.hls.trigger(m.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const i=this.hls;nc(e,this.initPTS[t.cc],s=>{this._appendCues(s,t.level),i.trigger(m.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},s=>{_.log(`Failed to parse IMSC1: ${s}`),i.trigger(m.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?hi(i.initSegment.data,new Uint8Array(s)):s;qm(h,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,c=>{this._appendCues(c,i.level),l.trigger(m.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},c=>{const d=c.message==="Missing initPTS for VTT MPEGTS";d?a.push(t):this._fallbackToIMSC1(i,s),_.log(`Failed to parse VTT cue: ${c}`),!(d&&o>i.cc)&&l.trigger(m.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:c})})}_fallbackToIMSC1(t,e){const i=this.tracks[t.level];i.textCodec||nc(e,this.initPTS[t.cc],()=>{i.textCodec=ha,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=>rh(s,n))}else{const s=this.tracks[e];if(!s)return;const n=s.default?"default":"subtitles"+e;i.trigger(m.CUES_PARSED,{type:"subtitles",cues:t,track:n})}}onFragDecrypted(t,e){const{frag:i}=e;i.type===Z.SUBTITLE&&this.onFragLoaded(m.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===Z.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=>Cn(o[l],e,i))}if(this.config.renderTextTracksNatively&&e===0&&s!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(l=>Cn(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 ev(r,t){return!!r&&r.label===t.name&&!(r.textTrack1||r.textTrack2)}function iv(r,t,e,i){return Math.min(t,i)-Math.max(r,e)}function hc(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class fa{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(m.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(m.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(m.MANIFEST_PARSED,this.onManifestParsed,this),t.on(m.BUFFER_CODECS,this.onBufferCodecs,this),t.on(m.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(m.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(m.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(m.MANIFEST_PARSED,this.onManifestParsed,this),t.off(m.BUFFER_CODECS,this.onBufferCodecs,this),t.off(m.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,fa.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 sv{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(m.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(m.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(m.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:i}),l>0&&a>h.config.fpsDroppedMonitoringThreshold*o){let c=h.currentLevel;_.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(h.autoLevelCapping===-1||h.autoLevelCapping>=c)&&(c=c-1,h.trigger(m.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:h.currentLevel}),h.autoLevelCapping=c,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 Er="[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=_.debug.bind(_,Er),this.log=_.log.bind(_,Er),this.warn=_.warn.bind(_,Er),this.error=_.error.bind(_,Er),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(m.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(m.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(m.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(m.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(m.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(m.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(m.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:i}=this.config,s=e[t];if(s)return s.licenseUrl;if(t===Lt.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 c=h.shift();this.getMediaKeysPromise(c,s,n).then(d=>a({keySystem:c,mediaKeys:d})).catch(d=>{h.length?l(h):d instanceof de?o(d):o(new de({type:Q.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_ACCESS,error:d,fatal:!0},d.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 Cl===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=vp(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(c=>(this.log(`Media-keys created for "${t}"`),h.then(d=>d?this.setMediaKeysServerCertificate(c,t,d):c))),o.mediaKeys.catch(c=>{this.error(`Failed to create media-keys for "${t}"}: ${c}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:i}){this.log(`Creating key-system session "${e}" keyId: ${Re.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 Re.hexDump(t.keyId)}updateKeySession(t,e){var i;const s=t.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Re.hexDump(((i=t.decryptdata)==null?void 0:i.keyId)||[])}
189
- } (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=Sn(this.config),n=t.map(kl).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{const o=Dl(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 de?this.hls.trigger(m.ERROR,t.data):this.hls.trigger(m.ERROR,{type:Q.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const s=kl(t.keyFormat),n=s?[s]:Sn(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=Sn(this.config)),t.length===0)throw new de({type:Q.KEY_SYSTEM_ERROR,details:$.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[Lt.FAIRPLAY]){const c=Ut(new Uint8Array(i));try{const d=wn(JSON.parse(c).sinf),u=Ul(new Uint8Array(d));if(!u)return;s=u.subarray(8,24),n=Lt.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const c=Hp(i);if(c===null)return;c.version===0&&c.systemId===Il.WIDEVINE&&c.data&&(s=c.data.subarray(8,24)),n=mp(c.systemId)}if(!n||!s)return;const a=Re.hexDump(s),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this;let h=o[a];for(let c=0;c<l.length;c++){const d=l[c],u=d.decryptdata;if(u.pssh||!u.keyId)continue;const f=Re.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(d,e,i,"encrypted-event-key-match"));break}}h||(h=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:c,mediaKeys:d})=>{var u;this.throwIfDestroyed();const f=new ps("ISO-23001-7",a,(u=Dl(c))!=null?u:"");return f.pssh=new Uint8Array(i),f.keyId=s,this.attemptSetMediaKeys(c,d).then(()=>{this.throwIfDestroyed();const p=this.createMediaKeySessionContext({decryptdata:f,keySystem:c,mediaKeys:d});return this.generateRequestWithPreferredKeySession(p,e,i,"encrypted-event-no-match")})})),h.catch(c=>this.handleError(c))}_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 c=new Jn;t.mediaKeysSession.onmessage=u=>{const f=t.mediaKeysSession;if(!f){c.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(v=>{this.handleError(v),c.emit("error",v)}):p==="license-release"?t.keySystem===Lt.FAIRPLAY&&(this.updateKeySession(t,_l("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${p}"`)},t.mediaKeysSession.onkeystatuseschange=u=>{if(!t.mediaKeysSession){c.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(t);const f=t.keyStatus;c.emit("keyStatus",f),f==="expired"&&(this.warn(`${t.keySystem} expired for key ${h}`),this.renewKeySession(t))};const d=new Promise((u,f)=>{c.on("error",f),c.on("keyStatus",p=>{p.startsWith("usable")?u():p==="output-restricted"?f(new de({type:Q.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):p==="internal-error"?f(new de({type:Q.KEY_SYSTEM_ERROR,details:$.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 de({type:Q.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_SESSION,error:u,fatal:!1},`Error generating key-session request: ${u}`)}).then(()=>d).catch(u=>{throw c.removeAllListeners(),this.removeSession(t),u}).then(()=>(c.removeAllListeners(),t))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach((e,i)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${Re.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Re.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,c={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(u,f,p,g)=>{a(u.data)},onError:(u,f,p,g)=>{o(new de({type:Q.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:p,response:Qt({url:l.url,data:void 0},u)},`"${t}" certificate request failed (${n}). Status: ${u.code} (${u.text})`))},onTimeout:(u,f,p)=>{o(new de({type:Q.KEY_SYSTEM_ERROR,details:$.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,c,d)})):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 de({type:Q.KEY_SYSTEM_ERROR,details:$.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 de({type:Q.KEY_SYSTEM_ERROR,details:$.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(c){this.error(c)}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 de({type:Q.KEY_SYSTEM_ERROR,details:$.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 c=h-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${c} 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={},ps.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 de 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 rv=1;var te={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const nv="h";class je{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:te.MANIFEST,su:!this.initialized})}catch(n){_.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===te.VIDEO||o===te.AUDIO||o==te.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){_.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||je.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}registerListeners(){const t=this.hls;t.on(m.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(m.MEDIA_DETACHED,this.onMediaDetached,this),t.on(m.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(m.MEDIA_DETACHED,this.onMediaDetached,this),t.off(m.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:rv,sf:nv,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){xt(e,this.createData());const i=e.ot===te.INIT||e.ot===te.VIDEO||e.ot===te.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=je.toHeaders(e);if(!Object.keys(s).length)return;t.headers||(t.headers={}),xt(t.headers,s)}else{const s=je.toQuery(e);if(!s)return;t.url=je.appendQueryToUri(t.url,s)}}getObjectType(t){const{type:e}=t;if(e==="subtitle")return te.TIMED_TEXT;if(t.sn==="initSegment")return te.INIT;if(e==="audio")return te.AUDIO;if(e==="main")return this.hls.audioTracks.length?te.VIDEO:te.MUXED}getTopBandwidth(t){let e=0,i;const s=this.hls;if(t===te.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===te.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!e?NaN:Et.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 c=a[l];c&&(h=c(h));const d=typeof h;let u;l==="ot"||l==="sf"||l==="st"?u=`${l}=${h}`:d==="boolean"?u=l:d==="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=je.serialize(n[o]);l&&(i[`CMCD-${s[o]}`]=l)}return i}static toQuery(t){return`CMCD=${encodeURIComponent(je.serialize(t))}`}static appendQueryToUri(t,e){if(!e)return t;const i=t.includes("?")?"&":"?";return`${t}${i}${e}`}}const av=3e5;class ov{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=_.log.bind(_,"[content-steering]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(m.MANIFEST_LOADING,this.onManifestLoading,this),t.on(m.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(m.MANIFEST_PARSED,this.onManifestParsed,this),t.on(m.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(m.MANIFEST_LOADING,this.onManifestLoading,this),t.off(m.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(m.MANIFEST_PARSED,this.onManifestParsed,this),t.off(m.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)===Gt.SendAlternateToPenaltyBox&&i.flags===he.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]>av&&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(m.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(c=>c.pathwayId===a))return;const h=this.getLevelsForPathway(o).map(c=>{const d=xt({},c);d.details=void 0,d.url=dc(c.uri,c.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l);const u=new St(c.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),d.attrs=u;const g=new ms(d);return hr(g,"audio",f),hr(g,"text",p),g});e.push(...h),cc(this.audioTracks,i,l,a),cc(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 c=(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+c)}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:(c,d,u,f)=>{this.log(`Loaded steering manifest: "${s}"`);const p=c.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":v,"PATHWAY-PRIORITY":E}=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),v&&this.clonePathways(v),E&&this.updatePathwayPriority(E)},onError:(c,d,u,f)=>{if(this.log(`Error loading steering manifest: ${c.code} ${c.text} (${d.url})`),this.stopLoad(),c.code===410){this.enabled=!1,this.log(`Steering manifest ${d.url} no longer available`);return}let p=this.timeToLoad*1e3;if(c.code===429){const g=this.loader;if(typeof(g==null?void 0:g.getResponseHeader)=="function"){const v=g.getResponseHeader("Retry-After");v&&(p=parseFloat(v)*1e3)}this.log(`Steering manifest ${d.url} rate limited`);return}this.scheduleRefresh(this.uri||d.url,p)},onTimeout:(c,d,u)=>{this.log(`Timeout loading steering manifest (${d.url})`),this.scheduleRefresh(this.uri||d.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 cc(r,t,e,i){r&&Object.keys(t).forEach(s=>{const n=r.filter(a=>a.groupId===s).map(a=>{const o=xt({},a);return o.details=void 0,o.attrs=new St(o.attrs),o.url=o.attrs.URI=dc(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 dc(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 lv=/^age:\s*[\d.]+\s*$/im;class uc{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 tr,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&&z(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 c=this.callbacks.onProgress;if(c&&c(i,t,l,e),!this.callbacks)return;const d={url:e.responseURL,data:l,code:a};this.callbacks.onSuccess(d,i,t,e)}else{const l=n.loadPolicy.errorRetry,h=i.retry;lr(l,h,!1,a)?this.retry(l):(_.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(lr(e,i,!0))this.retry(e);else{_.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=Fn(t,i.retry),i.retry++,_.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&&lv.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 hv(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const cv=/(\d+)-(\d+)\/(\d+)/;class fc{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||pv,this.controller=new self.AbortController,this.stats=new tr}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=dv(t,this.controller.signal),a=i.onProgress,o=t.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:h,maxLoadTimeMs:c}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=i,this.request=this.fetchSetup(t,n),self.clearTimeout(this.requestTimeout),e.timeout=h&&z(h)?h:c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,t,this.response)},e.timeout),self.fetch(this.request).then(d=>{this.response=this.loader=d;const u=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,t,this.response)},c-(u-s.loading.start)),!d.ok){const{status:f,statusText:p}=d;throw new gv(p||"fetch, bad network response",f,d)}return s.loading.first=u,s.total=fv(d.headers)||s.total,a&&z(e.highWaterMark)?this.loadProgressively(d,s,t,e.highWaterMark,a):o?d.arrayBuffer():t.responseType==="json"?d.json():d.text()}).then(d=>{const{response:u}=this;self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const f=d[l];f&&(s.loaded=s.total=f);const p={url:u.url,data:d,code:u.status};a&&!z(e.highWaterMark)&&a(s,t,d,u),i.onSuccess(p,s,t,u)}).catch(d=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;const u=d&&d.code||0,f=d?d.message:null;i.onError({code:u,text:f},t,d?d.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 Hh,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 c=h.value,d=c.length;return e.loaded+=d,d<s||a.dataLength?(a.push(c),a.dataLength>=s&&n(e,i,a.flush(),t)):n(e,i,c,t),l()}).catch(()=>Promise.reject());return l()}}function dv(r,t){const e={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(xt({},r.headers))};return r.rangeEnd&&e.headers.set("Range","bytes="+r.rangeStart+"-"+String(r.rangeEnd-1)),e}function uv(r){const t=cv.exec(r);if(t)return parseInt(t[2])-parseInt(t[1])+1}function fv(r){const t=r.get("Content-Range");if(t){const i=uv(t);if(z(i))return i}const e=r.get("Content-Length");if(e)return parseInt(e)}function pv(r,t){return new self.Request(r.url,t)}class gv extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const mv=/\s/,vv={newCue(r,t,e,i){const s=[];let n,a,o,l,h;const c=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 d;for(let g=0;g<n.chars.length;g++)mv.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=ic(h.trim()),p=la(t,e,f);r!=null&&(d=r.cues)!=null&&d.getCueById(p)||(a=new c(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=>rh(r,u))),s}},yv={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Ev=Qt(Qt({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:uc,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:wm,bufferController:xm,capLevelController:fa,errorController:gg,fpsController:sv,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:Cl,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:yv},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},bv()),{},{subtitleStreamController:km,subtitleTrackController:Dm,timelineController:tv,audioStreamController:Lm,audioTrackController:Rm,emeController:Ci,cmcdController:je,contentSteeringController:ov});function bv(){return{cueHandler:vv,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 Tv(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=pa(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 c=`${n}Loading${h}`,d=t[c];if(d!==void 0&&o){l.push(c);const u=e[a].default;switch(t[a]={default:u},h){case"TimeOut":u.maxLoadTimeMs=d,u.maxTimeToFirstByteMs=d;break;case"MaxRetry":u.errorRetry.maxNumRetry=d,u.timeoutRetry.maxNumRetry=d;break;case"RetryDelay":u.errorRetry.retryDelayMs=d,u.timeoutRetry.retryDelayMs=d;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=d,u.timeoutRetry.maxRetryDelayMs=d;break}}}),l.length&&_.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(t[a])}`)}),Qt(Qt({},e),t)}function pa(r){return r&&typeof r=="object"?Array.isArray(r)?r.map(pa):Object.keys(r).reduce((t,e)=>(t[e]=pa(r[e]),t),{}):r}function Av(r){const t=r.loader;t!==fc&&t!==uc?(_.log("[config]: Custom loader detected, cannot enable progressive streaming"),r.progressive=!1):hv()&&(r.loader=fc,r.progressive=!0,r.enableSoftwareAES=!0,_.log("[config]: Progressive streaming enabled, using FetchLoader"))}class Ue{static get version(){return"1.4.12"}static isSupported(){return Og()}static get Events(){return m}static get ErrorTypes(){return Q}static get ErrorDetails(){return $}static get DefaultConfig(){return Ue.defaultConfig?Ue.defaultConfig:Ev}static set DefaultConfig(t){Ue.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Jn,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,ap(t.debug||!1,"Hls instance");const e=this.config=Tv(Ue.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&Av(e);const{abrController:i,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=e,l=new a(this),h=this.abrController=new i(this),c=this.bufferController=new s(this),d=this.capLevelController=new n(this),u=new o(this),f=new Xp(this),p=new eg(this),g=e.contentSteeringController,v=g?new g(this):null,E=this.levelController=new vg(this,v),A=new yg(this),L=new bg(this.config),y=this.streamController=new Tm(this,A,L);d.setStreamController(y),u.setStreamController(y);const S=[f,E,y];v&&S.splice(1,0,v),this.networkControllers=S;const R=[h,c,d,u,p,A];this.audioTrackController=this.createController(e.audioTrackController,S);const D=e.audioStreamController;D&&S.push(new D(this,A,L)),this.subtitleTrackController=this.createController(e.subtitleTrackController,S);const M=e.subtitleStreamController;M&&S.push(new M(this,A,L)),this.createController(e.timelineController,R),L.emeController=this.emeController=this.createController(e.emeController,R),this.cmcdController=this.createController(e.cmcdController,R),this.latencyController=this.createController(ig,R),this.coreComponents=R,S.push(l);const C=l.onErrorOut;typeof C=="function"&&this.on(m.ERROR,C,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){_.error("An internal error happened while handling event "+t+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(m.ERROR,{type:Q.OTHER_ERROR,details:$.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){_.log("destroy"),this.trigger(m.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){_.log("attachMedia"),this._media=t,this.trigger(m.MEDIA_ATTACHING,{media:t})}detachMedia(){_.log("detachMedia"),this.trigger(m.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,i=this.url,s=this.url=bn.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});_.log(`loadSource:${s}`),e&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(m.MANIFEST_LOADING,{url:t})}startLoad(t=-1){_.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){_.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){_.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){_.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){_.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){_.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){_.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){_.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){_.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&&(_.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){On.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}}Ue.defaultConfig=void 0;const wv=(r,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const s=Object.getOwnPropertyDescriptor(r,e),n=Object.getOwnPropertyDescriptor(t,e);!Sv(s,n)&&i||Object.defineProperty(r,e,n)},Sv=function(r,t){return r===void 0||r.configurable||r.writable===t.writable&&r.enumerable===t.enumerable&&r.configurable===t.configurable&&(r.writable||r.value===t.value)},Lv=(r,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(r)&&Object.setPrototypeOf(r,e)},Rv=(r,t)=>`/* Wrapped ${r}*/
190
- ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Iv=(r,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,s=Rv.bind(null,i,t.toString());Object.defineProperty(s,"name",kv),Object.defineProperty(r,"toString",{..._v,value:s})};function Dv(r,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=r;for(const s of Reflect.ownKeys(t))wv(r,t,s,e);return Lv(r,t),Iv(r,t,i),r}const Cv=new WeakMap;function ga(r,{cacheKey:t=([i])=>i,cache:e=new Map}={}){const i=new Map,s=function(...n){const a=t(n);if(i.has(a))return i.get(a);const o=(async()=>{try{if(e&&await e.has(a))return await e.get(a);const l=await r.apply(this,n);try{return l}finally{e&&await e.set(a,l)}}finally{i.delete(a)}})();return i.set(a,o),o};return Dv(s,r,{ignoreNonConfigurable:!0}),Cv.set(s,e),s}function xv(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Pv(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Ov=ga(async function(r){return new FontFace(r.name,`url(${r.url})`,{style:r.style,weight:r.weight}).load()},{cacheKey:([r])=>JSON.stringify(r)});async function $v(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 Mv{constructor(t){this._memoKey=null,this._lastDeps=null,this._duration=0,this._processing=!1,this._scenes=null,this._videos={},this._videoMeta={},this._videoState={},this._resolveVideo=ga(e=>{const{id:i,src:s,playlist:n,duration:a}=e;return this._cleanupVideo(i),new Promise(o=>{let l=null;const h=document.createElement("video");h.playsInline=!0,h.muted=!0,h.loop=!1,h.volume=this.host.volume,h.playbackRate=this.host.playbackRate;const c={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},d=Object.keys(c).reduce((u,f)=>{const p=f,g=c[p](i,h);return u[p]=g,h.addEventListener(f,g),u},{});if(n&&!xv()&&Ue.isSupported()){let u=!1;l=new Ue({autoStartLoad:!0,xhrSetup:f=>{const{open:p}=f,g=n.split("?")[1];f.open=function(v,E,A){E.toString().includes("?")||(E+="?"+g),p.apply(this,[v,E,A])}}}),l.loadSource(n),l.attachMedia(h),l.startLoadOnce=(f=-1)=>{l&&!u&&(l.startLoad(f),u=!0)},l.on(Ue.Events.LEVEL_LOADED,async()=>{u||l==null||l.stopLoad(),o({id:i,hls:l,node:h})})}else{h.src=s;let u=!1;if(h.startLoadOnce=()=>{u||(h.preload="auto",h.load(),u=!0)},a)h.preload="none",o({id:i,hls:l,node:h});else{h.preload="metadata";const f=async()=>{o({id:i,hls:l,node:h}),h.removeEventListener("loadedmetadata",f)};h.addEventListener("loadedmetadata",f)}}this.videos[i]={id:i,hls:l,node:h,listeners:d},this.videoState[i]={initialised:!1,waiting:!0,buffered:[]}})},{cacheKey:([{id:e,src:i,playlist:s}])=>JSON.stringify({id:e,src:i.split("?")[0],playlist:s==null?void 0:s.split("?")[0]})}),this._resolveVideoMeta=ga(async(e,i)=>{const{id:s,captions:n,duration:a,startOffset:o,endOffset:l}=e,h=a??await $v(i),c=(o??0)*h,d=(1-(l??0))*h,u={id:s,captions:n,start:c,duration:d};return this.videoMeta[s]=u,u},{cacheKey:([{id:e,captions:i,duration:s,startOffset:n,endOffset:a}])=>JSON.stringify({id:e,captions:i,duration:s,startOffset:n,endOffset:a})}),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,videoMeta:h}=((s=this.scenes)==null?void 0:s.scenes.find(({video:c})=>e===(c==null?void 0:c.id)))??{};if(i&&n&&l&&h&&typeof o<"u"){for(let d=0;d<n.length;d++){const u=n.start(d),f=n.end(d);Math.max(u,h.start)<=Math.min(f,h.start+h.duration)&&a.push({start:Math.max(0,(Math.max(u-h.start,0)+o)/this.host.duration*100),end:Math.min((Math.min(f-h.start,h.duration)+o)/this.host.duration*100,100)})}const c=this.videoState[e];this.videoState={...this.videoState,[e]:{...c,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 videoMeta(t){this._videoMeta=t,this.host.requestUpdate()}get videoMeta(){return this._videoMeta}set videoState(t){this._videoState=t,this.host.requestUpdate()}get videoState(){return this._videoState}_setupTask(){new To(this.host,async([t,e,i,s,n])=>{try{if(i||t){if(this.processing=!0,i){let a=null;if(s)try{a=await(await fetch(s,{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 Co({data:{questions:{items:[{answer:{id:"source",media:{[o]:i},captions:{current:a}}}]}},template:e,burnCaptions:n},this._resolveVideo,this._resolveVideoMeta)}else this.scenes=await Co({data:t,template:e,burnCaptions:n},this._resolveVideo,this._resolveVideoMeta);(await Promise.all(this.scenes.fonts.map(a=>Ov(a)))).forEach(a=>{document.fonts.add(a)}),this.duration=this.scenes.duration,this.host.paused&&this.host.reset(this.host.currentTime,!this.host.paused),this.host.autoplay&&this.host.play()}}catch(a){this.scenes=null,this.duration=0,this.host.dispatchEvent(new ErrorEvent("error",a))}finally{this.processing=!1}},()=>{const t=JSON.stringify({data:this.host.data,template:this.host.template,src:this.host.src,track:this.host.track,burnCaptions:this.host.burnCaptions});if(this._lastDeps&&this._memoKey===t)return this._lastDeps;const e=[this.host.data,this.host.template,this.host.src,this.host.track,this.host.burnCaptions];return this._memoKey=t,this._lastDeps=e,e})}_setVideoCurrentTime({time:t,scene:e}){const{start:i,video:s,videoMeta:n}=e;if(s&&s.node&&n&&typeof i<"u"){const a=t-i;s.node.currentTime=Math.max(n.start,Math.min(n.start+n.duration,a+n.start))}}setVideosCurrentTime(t){var e;(e=this.scenes)==null||e.scenes.forEach(i=>{this._setVideoCurrentTime({time:t,scene:i})})}_cleanupVideo(t){var e;const i=this.videos[t];i&&((e=i.hls)==null||e.destroy(),i.node.pause(),i.node.src="",Object.keys(i.listeners).forEach(s=>{var n;if((n=this.videos)!=null&&n[t]){const a=i.listeners[s];i.node.removeEventListener(s,a)}}),delete this.videos[t])}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(t=>{this._cleanupVideo(t)}),this.videos={}}}function Fv(r){r.requestFullscreen?r.requestFullscreen():r.mozRequestFullScreen?r.mozRequestFullScreen():r.webkitRequestFullscreen?r.webkitRequestFullscreen():r.msRequestFullscreen&&r.msRequestFullscreen()}function Nv(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const ma=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen"],Uv={id:"captions",event:"captions:click",label:"Closed Captions"},Bv={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},pc={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}]},Hv={id:"playbackRate",label:"Playback playbackRate",subItems:pc};class Gv extends Oo{constructor(t){if(super(t),this.element=null,this.observer=void 0,t.type!==Ji.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)),Ee}}const va=ts(Gv),ke={"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"},Vv={colors:ke,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:600},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 ${ke["dark-100"]}`,medium:`0 .125rem .625rem ${ke["dark-100"]}`,large:`0 .25rem 1rem ${ke["dark-50"]}`,xl:`.25rem .25rem 1rem ${ke["dark-250"]}`,xxl:`0 .25rem 2rem ${ke["dark-100"]}`,xxxl:`.25rem .25rem 3rem ${ke["dark-250"]}`,toolbar:`0 -.625rem .625rem ${ke["dark-50"]}`,text:`0 0 .25rem ${ke["dark-250"]}`},timings:{fast:".1s",normal:".2s",slow:".3s"},easings:{linear:"linear"},focusOutline:{width:".2rem",color:ke["dark-400"]},iconSizes:{small:"0.75rem",medium:"1rem",large:"1.5rem"}},gc=Tu.flatten(Vv,{delimiter:"-"}),Kv=Object.keys(gc).map(r=>Ui(`:host { --${r}: ${gc[r]}; }`)),jv=r=>{class t extends r{firstUpdated(){const i=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),s=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-SemiBold.woff2)",{style:"normal",weight:"600"});document.fonts.add(i),document.fonts.add(s)}}return t.styles=[(r==null?void 0:r.styles)??[],Kv,jt`
205
+ `),p=[],g=t?ob(t.baseTime,t.timescale):0;let v="00:00.000",b=0,E=0,T,w=!0;d.oncue=function(_){const D=e[i];let M=e.ccOffset;const F=(b-g)/9e4;if(D!=null&&D.new&&(E!==void 0?M=e.ccOffset=D.start:Xb(e,i,F)),F){if(!t){T=new Error("Missing initPTS for VTT MPEGTS");return}M=F-e.presentationOffset}const x=_.endTime-_.startTime,N=hr((_.startTime+M-E)*9e4,s*9e4)/9e4;_.startTime=Math.max(N,0),_.endTime=Math.max(N+x,0);const V=_.text.trim();_.text=decodeURIComponent(encodeURIComponent(V)),_.id||(_.id=Xc(_.startTime,_.endTime,V)),_.endTime>0&&p.push(_)},d.onparsingerror=function(_){T=_},d.onflush=function(){if(T){c(T);return}o(p)},f.forEach(_=>{if(w)if(Yc(_,"X-TIMESTAMP-MAP=")){w=!1,_.slice(16).split(",").forEach(D=>{Yc(D,"LOCAL:")?v=D.slice(6):Yc(D,"MPEGTS:")&&(b=parseInt(D.slice(7)))});try{E=zb(v)/1e3}catch(D){T=D}return}else _===""&&(w=!1);d.parse(_+`
206
+ `)}),d.flush()}const Zc="stpp.ttml.im1t",_f=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Lf=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,qb={left:"start",center:"center",right:"end",start:"start",end:"end"};function Cf(n,t,e,i){const s=ye(new Uint8Array(n),["mdat"]);if(s.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const o=s.map(d=>Pr(d)),c=ab(t.baseTime,1,t.timescale);try{o.forEach(d=>e(Qb(d,c)))}catch(d){i(d)}}function Qb(n,t){const e=new DOMParser().parseFromString(n,"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((p,g)=>(p[g]=e.getAttribute(`ttp:${g}`)||i[g],p),{}),o=e.getAttribute("xml:space")!=="preserve",c=If(qc(e,"styling","style")),d=If(qc(e,"layout","region")),f=qc(e,"body","[begin]");return[].map.call(f,p=>{const g=xf(p,o);if(!g||!p.hasAttribute("begin"))return null;const v=Jc(p.getAttribute("begin"),s),b=Jc(p.getAttribute("dur"),s);let E=Jc(p.getAttribute("end"),s);if(v===null)throw Df(p);if(E===null){if(b===null)throw Df(p);E=v+b}const T=new jc(v-t,E-t,g);T.id=Xc(T.startTime,T.endTime,T.text);const w=d[p.getAttribute("region")],_=c[p.getAttribute("style")],D=Jb(w,_,c),{textAlign:M}=D;if(M){const F=qb[M];F&&(T.lineAlign=F),T.align=M}return ai(T,D),T}).filter(p=>p!==null)}function qc(n,t,e){const i=n.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(e)):[]}function If(n){return n.reduce((t,e)=>{const i=e.getAttribute("xml:id");return i&&(t[i]=e),t},{})}function xf(n,t){return[].slice.call(n.childNodes).reduce((e,i,s)=>{var o;return i.nodeName==="br"&&s?e+`
207
+ `:(o=i.childNodes)!=null&&o.length?xf(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function Jb(n,t,e){const i="http://www.w3.org/ns/ttml#styling";let s=null;const o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],c=n!=null&&n.hasAttribute("style")?n.getAttribute("style"):null;return c&&e.hasOwnProperty(c)&&(s=e[c]),o.reduce((d,f)=>{const p=Qc(t,i,f)||Qc(n,i,f)||Qc(s,i,f);return p&&(d[f]=p),d},{})}function Qc(n,t,e){return n&&n.hasAttributeNS(t,e)?n.getAttributeNS(t,e):null}function Df(n){return new Error(`Could not parse ttml timestamp ${n}`)}function Jc(n,t){if(!n)return null;let e=wf(n);return e===null&&(_f.test(n)?e=t4(n,t):Lf.test(n)&&(e=e4(n,t))),e}function t4(n,t){const e=_f.exec(n),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 e4(n,t){const e=Lf.exec(n),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 i4{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=Pf(),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 No(this,"textTrack1"),i=new No(this,"textTrack2"),s=new No(this,"textTrack3"),o=new No(this,"textTrack4");this.cea608Parser1=new Ef(1,e,i),this.cea608Parser2=new Ef(3,s,o)}t.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(R.FRAG_LOADING,this.onFragLoading,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(R.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(R.FRAG_LOADING,this.onFragLoading,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(R.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(t,e,i,s,o){let c=!1;for(let d=o.length;d--;){const f=o[d],p=s4(f[0],f[1],e,i);if(p>=0&&(f[0]=Math.min(f[0],e),f[1]=Math.max(f[1],i),c=!0,p/(i-e)>.5))return}if(c||o.push([e,i]),this.config.renderTextTracksNatively){const d=this.captionsTracks[t];this.Cues.newCue(d,e,i,s)}else{const d=this.Cues.newCue(null,e,i,s);this.hls.trigger(R.CUES_PARSED,{type:"captions",cues:d,track:t})}}onInitPtsFound(t,{frag:e,id:i,initPTS:s,timescale:o}){const{unparsedVttFrags:c}=this;i==="main"&&(this.initPTS[e.cc]={baseTime:s,timescale:o}),c.length&&(this.unparsedVttFrags=[],c.forEach(d=>{this.onFragLoaded(R.FRAG_LOADED,d)}))}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:o,languageCode:c}=e[t],d=this.getExistingTrack(t);if(d)i[t]=d,Rn(i[t]),R0(i[t],s);else{const f=this.createTextTrack("captions",o,c);f&&(f[t]=!0,i[t]=f)}}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(R.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=>{Rn(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Pf(),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++)Rn(e[i])}onSubtitleTracksUpdated(t,e){const i=e.subtitleTracks||[],s=i.some(o=>o.textCodec===Zc);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(ff(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const o=this.media?this.media.textTracks:null;this.tracks.forEach((c,d)=>{let f;if(o&&d<o.length){let p=null;for(let g=0;g<o.length;g++)if(r4(o[g],c)){p=o[g];break}p&&(f=p)}if(f)Rn(f);else{const p=this._captionsOrSubtitlesFromCharacteristics(c);f=this.createTextTrack(p,c.name,c.lang),f&&(f.mode="disabled")}f&&(f.groupId=c.groupId,this.textTracks.push(f))})}else if(this.tracks.length){const o=this.tracks.map(c=>({label:c.name,kind:c.type.toLowerCase(),default:c.default,subtitleTrack:c}));this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:o})}}}_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 o=`textTrack${s[1]}`,c=this.captionsProperties[o];c&&(c.label=i.name,i.lang&&(c.languageCode=i.lang),c.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:o,lastPartIndex:c}=this;if(!(!this.enabled||!(i&&s))&&e.frag.type===Jt.MAIN){var d,f;const p=e.frag.sn,g=(d=e==null||(f=e.part)==null?void 0:f.index)!=null?d:-1;p===o+1||p===o&&g===c+1||(i.reset(),s.reset()),this.lastSn=p,this.lastPartIndex=g}}onFragLoaded(t,e){const{frag:i,payload:s}=e;if(i.type===Jt.SUBTITLE)if(s.byteLength){const o=i.decryptdata,c="stats"in e;if(o==null||!o.encrypted||c){const d=this.tracks[i.level],f=this.vttCCs;f[i.cc]||(f[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),d&&d.textCodec===Zc?this._parseIMSC1(i,s):this._parseVTTs(e)}}else this.hls.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const i=this.hls;Cf(e,this.initPTS[t.cc],s=>{this._appendCues(s,t.level),i.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},s=>{z.log(`Failed to parse IMSC1: ${s}`),i.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:s})})}_parseVTTs(t){var e;const{frag:i,payload:s}=t,{initPTS:o,unparsedVttFrags:c}=this,d=o.length-1;if(!o[i.cc]&&d===-1){c.push(t);return}const f=this.hls,p=(e=i.initSegment)!=null&&e.data?ln(i.initSegment.data,new Uint8Array(s)):s;Zb(p,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,g=>{this._appendCues(g,i.level),f.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},g=>{const v=g.message==="Missing initPTS for VTT MPEGTS";v?c.push(t):this._fallbackToIMSC1(i,s),z.log(`Failed to parse VTT cue: ${g}`),!(v&&d>i.cc)&&f.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:g})})}_fallbackToIMSC1(t,e){const i=this.tracks[t.level];i.textCodec||Cf(e,this.initPTS[t.cc],()=>{i.textCodec=Zc,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(o=>_0(s,o))}else{const s=this.tracks[e];if(!s)return;const o=s.default?"default":"subtitles"+e;i.trigger(R.CUES_PARSED,{type:"subtitles",cues:t,track:o})}}onFragDecrypted(t,e){const{frag:i}=e;i.type===Jt.SUBTITLE&&this.onFragLoaded(R.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:o,samples:c}=e;if(!(o.type===Jt.MAIN&&this.closedCaptionsForLevel(o)==="NONE"))for(let d=0;d<c.length;d++){const f=c[d].bytes;if(f){const p=this.extractCea608Data(f);i.addData(c[d].pts,p[0]),s.addData(c[d].pts,p[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:i,endOffsetSubtitles:s,type:o}){const{media:c}=this;if(!(!c||c.currentTime<i)){if(!o||o==="video"){const{captionsTracks:d}=this;Object.keys(d).forEach(f=>yc(d[f],e,i))}if(this.config.renderTextTracksNatively&&e===0&&s!==void 0){const{textTracks:d}=this;Object.keys(d).forEach(f=>yc(d[f],e,s))}}}extractCea608Data(t){const e=[[],[]],i=t[0]&31;let s=2;for(let o=0;o<i;o++){const c=t[s++],d=127&t[s++],f=127&t[s++];if(!(d===0&&f===0)&&4&c){const p=3&c;(p===0||p===1)&&(e[p].push(d),e[p].push(f))}}return e}}function r4(n,t){return!!n&&n.label===t.name&&!(n.textTrack1||n.textTrack2)}function s4(n,t,e,i){return Math.min(t,i)-Math.max(n,e)}function Pf(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class th{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(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.BUFFER_CODECS,this.onBufferCodecs,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.BUFFER_CODECS,this.onBufferCodecs,this),t.off(R.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,o)=>this.isLevelAllowed(s)&&o<=t);return this.clientRect=null,th.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=(c,d)=>d?c.width!==d.width||c.height!==d.height:!0;let o=t.length-1;for(let c=0;c<t.length;c+=1){const d=t[c];if((d.width>=e||d.height>=i)&&s(d,t[c+1])){o=c;break}}return o}}class n4{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(R.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(R.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 o=s-this.lastTime,c=i-this.lastDroppedFrames,d=e-this.lastDecodedFrames,f=1e3*c/o,p=this.hls;if(p.trigger(R.FPS_DROP,{currentDropped:c,currentDecoded:d,totalDroppedFrames:i}),f>0&&c>p.config.fpsDroppedMonitoringThreshold*d){let g=p.currentLevel;z.warn("drop FPS ratio greater than max allowed value for currentLevel: "+g),g>0&&(p.autoLevelCapping===-1||p.autoLevelCapping>=g)&&(g=g-1,p.trigger(R.FPS_DROP_LEVEL_CAPPING,{level:g,droppedLevel:p.currentLevel}),p.autoLevelCapping=g,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 Uo="[eme]";class xn{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=xn.CDMCleanupPromise?[xn.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=z.debug.bind(z,Uo),this.log=z.log.bind(z,Uo),this.warn=z.warn.bind(z,Uo),this.error=z.error.bind(z,Uo),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(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:i}=this.config,s=e[t];if(s)return s.licenseUrl;if(t===ze.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=(c,d,f)=>!!c&&f.indexOf(c)===d,s=e.map(c=>c.audioCodec).filter(i),o=e.map(c=>c.videoCodec).filter(i);return s.length+o.length===0&&o.push("avc1.42e01e"),new Promise((c,d)=>{const f=p=>{const g=p.shift();this.getMediaKeysPromise(g,s,o).then(v=>c({keySystem:g,mediaKeys:v})).catch(v=>{p.length?f(p):v instanceof dr?d(v):d(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_ACCESS,error:v,fatal:!0},v.message))})};f(t)})}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${i}`;return t0===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=bv(t,e,i,this.config.drmSystemOptions),o=this.keySystemAccessPromises[t];let c=o==null?void 0:o.keySystemAccess;if(!c){this.log(`Requesting encrypted media "${t}" key-system access with config: ${JSON.stringify(s)}`),c=this.requestMediaKeySystemAccess(t,s);const d=this.keySystemAccessPromises[t]={keySystemAccess:c};return c.catch(f=>{this.log(`Failed to obtain access to key-system "${t}": ${f}`)}),c.then(f=>{this.log(`Access for key-system "${f.keySystem}" obtained`);const p=this.fetchServerCertificate(t);return this.log(`Create media-keys for "${t}"`),d.mediaKeys=f.createMediaKeys().then(g=>(this.log(`Media-keys created for "${t}"`),p.then(v=>v?this.setMediaKeysServerCertificate(g,t,v):g))),d.mediaKeys.catch(g=>{this.error(`Failed to create media-keys for "${t}"}: ${g}`)}),d.mediaKeys})}return c.then(()=>o.mediaKeys)}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:i}){this.log(`Creating key-system session "${e}" keyId: ${Or.hexDump(t.keyId||[])}`);const s=i.createSession(),o={decryptdata:t,keySystem:e,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(o),o}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const i=this.createMediaKeySessionContext(t),s=this.getKeyIdString(e),o="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(i,o,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 Or.hexDump(t.keyId)}updateKeySession(t,e){var i;const s=t.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Or.hexDump(((i=t.decryptdata)==null?void 0:i.keyId)||[])}
208
+ } (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=dc(this.config),o=t.map(qu).filter(c=>!!c&&s.indexOf(c)!==-1);return this.getKeySystemSelectionPromise(o).then(({keySystem:c})=>{const d=Ju(c);d?e(d):i(new Error(`Unable to find format for key-system "${c}"`))}).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 o=this.keyIdToKeySessionPromise[i];return o||(o=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(e).then(({keySystem:c,mediaKeys:d})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${s}`),this.attemptSetMediaKeys(c,d).then(()=>{this.throwIfDestroyed();const f=this.createMediaKeySessionContext({keySystem:c,mediaKeys:d,decryptdata:e}),p="cenc";return this.generateRequestWithPreferredKeySession(f,p,e.pssh,"playlist-key")}))),o.catch(c=>this.handleError(c))),o}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof dr?this.hls.trigger(R.ERROR,t.data):this.hls.trigger(R.ERROR,{type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const s=qu(t.keyFormat),o=s?[s]:dc(this.config);return this.attemptKeySystemAccess(o)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=dc(this.config)),t.length===0)throw new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.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,o;if(e==="sinf"&&this.config.drmSystems[ze.FAIRPLAY]){const g=bi(new Uint8Array(i));try{const v=hc(JSON.parse(g).sinf),b=l0(new Uint8Array(v));if(!b)return;s=b.subarray(8,24),o=ze.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const g=Vv(i);if(g===null)return;g.version===0&&g.systemId===Qu.WIDEVINE&&g.data&&(s=g.data.subarray(8,24)),o=yv(g.systemId)}if(!o||!s)return;const c=Or.hexDump(s),{keyIdToKeySessionPromise:d,mediaKeySessions:f}=this;let p=d[c];for(let g=0;g<f.length;g++){const v=f[g],b=v.decryptdata;if(b.pssh||!b.keyId)continue;const E=Or.hexDump(b.keyId);if(c===E||b.uri.replace(/-/g,"").indexOf(c)!==-1){p=d[E],delete d[E],b.pssh=new Uint8Array(i),b.keyId=s,p=d[c]=p.then(()=>this.generateRequestWithPreferredKeySession(v,e,i,"encrypted-event-key-match"));break}}p||(p=d[c]=this.getKeySystemSelectionPromise([o]).then(({keySystem:g,mediaKeys:v})=>{var b;this.throwIfDestroyed();const E=new wa("ISO-23001-7",c,(b=Ju(g))!=null?b:"");return E.pssh=new Uint8Array(i),E.keyId=s,this.attemptSetMediaKeys(g,v).then(()=>{this.throwIfDestroyed();const T=this.createMediaKeySessionContext({decryptdata:E,keySystem:g,mediaKeys:v});return this.generateRequestWithPreferredKeySession(T,e,i,"encrypted-event-no-match")})})),p.catch(g=>this.handleError(g))}_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(o=>i.indexOf(o)===-1)})}generateRequestWithPreferredKeySession(t,e,i,s){var o,c;const d=(o=this.config.drmSystems)==null||(c=o[t.keySystem])==null?void 0:c.generateRequest;if(d)try{const b=d.call(this.hls,e,i,t);if(!b)throw new Error("Invalid response from configured generateRequest filter");e=b.initDataType,i=t.decryptdata.pssh=b.initData?new Uint8Array(b.initData):null}catch(b){var f;if(this.warn(b.message),(f=this.hls)!=null&&f.config.debug)throw b}if(i===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(t);const p=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${s}": ${p} (init data type: ${e} length: ${i?i.byteLength:null})`);const g=new Bc;t.mediaKeysSession.onmessage=b=>{const E=t.mediaKeysSession;if(!E){g.emit("error",new Error("invalid state"));return}const{messageType:T,message:w}=b;this.log(`"${T}" message event for session "${E.sessionId}" message size: ${w.byteLength}`),T==="license-request"||T==="license-renewal"?this.renewLicense(t,w).catch(_=>{this.handleError(_),g.emit("error",_)}):T==="license-release"?t.keySystem===ze.FAIRPLAY&&(this.updateKeySession(t,Zu("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${T}"`)},t.mediaKeysSession.onkeystatuseschange=b=>{if(!t.mediaKeysSession){g.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(t);const E=t.keyStatus;g.emit("keyStatus",E),E==="expired"&&(this.warn(`${t.keySystem} expired for key ${p}`),this.renewKeySession(t))};const v=new Promise((b,E)=>{g.on("error",E),g.on("keyStatus",T=>{T.startsWith("usable")?b():T==="output-restricted"?E(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):T==="internal-error"?E(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${T}"`)):T==="expired"?E(new Error("key expired while generating request")):this.warn(`unhandled key status change "${T}"`)})});return t.mediaKeysSession.generateRequest(e,i).then(()=>{var b;this.log(`Request generated for key-session "${(b=t.mediaKeysSession)==null?void 0:b.sessionId}" keyId: ${p}`)}).catch(b=>{throw new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_SESSION,error:b,fatal:!1},`Error generating key-session request: ${b}`)}).then(()=>v).catch(b=>{throw g.removeAllListeners(),this.removeSession(t),b}).then(()=>(g.removeAllListeners(),t))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach((e,i)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${Or.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Or.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),o=this.getServerCertificateUrl(t);return o?(this.log(`Fetching serverCertificate for "${t}"`),new Promise((c,d)=>{const f={responseType:"arraybuffer",url:o},p=e.certLoadPolicy.default,g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:(b,E,T,w)=>{c(b.data)},onError:(b,E,T,w)=>{d(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:Vi({url:f.url,data:void 0},b)},`"${t}" certificate request failed (${o}). Status: ${b.code} (${b.text})`))},onTimeout:(b,E,T)=>{d(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:{url:f.url,data:void 0}},`"${t}" certificate request timed out (${o})`))},onAbort:(b,E,T)=>{d(new Error("aborted"))}};s.load(f,g,v)})):Promise.resolve()}setMediaKeysServerCertificate(t,e,i){return new Promise((s,o)=>{t.setServerCertificate(i).then(c=>{this.log(`setServerCertificate ${c?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${e}"`),s(t)}).catch(c=>{o(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:c,fatal:!0},c.message))})})}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then(i=>this.updateKeySession(t,new Uint8Array(i)).catch(s=>{throw new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}setupLicenseXHR(t,e,i,s){const o=this.config.licenseXhrSetup;return o?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return o.call(this.hls,t,e,i,s)}).catch(c=>{if(!i.decryptdata)throw c;return t.open("POST",e,!0),o.call(this.hls,t,e,i,s)}).then(c=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:c||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,o)=>{const c=this.getLicenseServerUrl(t.keySystem);this.log(`Sending license request to URL: ${c}`);const d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=()=>{if(!this.hls||!t.mediaKeysSession)return o(new Error("invalid state"));if(d.readyState===4)if(d.status===200){this._requestLicenseFailureCount=0;let f=d.response;this.log(`License received ${f instanceof ArrayBuffer?f.byteLength:f}`);const p=this.config.licenseResponseCallback;if(p)try{f=p.call(this.hls,d,c,t)}catch(g){this.error(g)}s(f)}else{const f=i.errorRetry,p=f?f.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>p||d.status>=400&&d.status<500)o(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:d,response:{url:c,data:void 0,code:d.status,text:d.statusText}},`License Request XHR failed (${c}). Status: ${d.status} (${d.statusText})`));else{const g=p-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${g} attempts left`),this.requestLicense(t,e).then(s,o)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=d,this.setupLicenseXHR(d,c,t,e).then(({xhr:f,licenseChallenge:p})=>{f.send(p)})})}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={},wa.clearKeyUriToKeyIdMap();const i=e.length;xn.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,o)=>(s.indexOf(o.keyFormat)===-1&&s.push(o.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(o=>{this.log(`Could not remove session: ${o}`)}).then(()=>e.close()).catch(o=>{this.log(`Could not close session: ${o}`)})}}}xn.CDMCleanupPromise=void 0;class dr 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 a4=1;var Ki={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const o4="h";class ks{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:Ki.MANIFEST,su:!this.initialized})}catch(o){z.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=s=>{try{const o=s.frag,c=this.hls.levels[o.level],d=this.getObjectType(o),f={d:o.duration*1e3,ot:d};(d===Ki.VIDEO||d===Ki.AUDIO||d==Ki.MUXED)&&(f.br=c.bitrate/1e3,f.tb=this.getTopBandwidth(d)/1e3,f.bl=this.getBufferLength(d)),this.apply(s,f)}catch(o){z.warn("Could not generate segment CMCD data.",o)}},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||ks.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}registerListeners(){const t=this.hls;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHED,this.onMediaDetached,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHED,this.onMediaDetached,this),t.off(R.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:a4,sf:o4,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){ai(e,this.createData());const i=e.ot===Ki.INIT||e.ot===Ki.VIDEO||e.ot===Ki.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=ks.toHeaders(e);if(!Object.keys(s).length)return;t.headers||(t.headers={}),ai(t.headers,s)}else{const s=ks.toQuery(e);if(!s)return;t.url=ks.appendQueryToUri(t.url,s)}}getObjectType(t){const{type:e}=t;if(e==="subtitle")return Ki.TIMED_TEXT;if(t.sn==="initSegment")return Ki.INIT;if(e==="audio")return Ki.AUDIO;if(e==="main")return this.hls.audioTracks.length?Ki.VIDEO:Ki.MUXED}getTopBandwidth(t){let e=0,i;const s=this.hls;if(t===Ki.AUDIO)i=s.audioTracks;else{const o=s.maxAutoLevel,c=o>-1?o+1:s.levels.length;i=s.levels.slice(0,c)}for(const o of i)o.bitrate>e&&(e=o.bitrate);return e>0?e:NaN}getBufferLength(t){const e=this.hls.media,i=t===Ki.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!e?NaN:Me.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,o,c){e(s),this.loader.load(s,o,c)}}}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,o,c){e(s),this.loader.load(s,o,c)}}}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=f=>!Number.isNaN(f)&&f!=null&&f!==""&&f!==!1,s=f=>Math.round(f),o=f=>s(f/100)*100,c={br:s,d:s,bl:o,dl:o,mtp:o,nor:f=>encodeURIComponent(f),rtp:o,tb:s},d=Object.keys(t||{}).sort();for(const f of d){let p=t[f];if(!i(p)||f==="v"&&p===1||f=="pr"&&p===1)continue;const g=c[f];g&&(p=g(p));const v=typeof p;let b;f==="ot"||f==="sf"||f==="st"?b=`${f}=${p}`:v==="boolean"?b=f:v==="number"?b=`${f}=${p}`:b=`${f}=${JSON.stringify(p)}`,e.push(b)}return e.join(",")}static toHeaders(t){const e=Object.keys(t),i={},s=["Object","Request","Session","Status"],o=[{},{},{},{}],c={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 d of e){const f=c[d]!=null?c[d]:1;o[f][d]=t[d]}for(let d=0;d<o.length;d++){const f=ks.serialize(o[d]);f&&(i[`CMCD-${s[d]}`]=f)}return i}static toQuery(t){return`CMCD=${encodeURIComponent(ks.serialize(t))}`}static appendQueryToUri(t,e){if(!e)return t;const i=t.includes("?")?"&":"?";return`${t}${i}${e}`}}const l4=3e5;class c4{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=z.log.bind(z,"[content-steering]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.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)===Ri.SendAlternateToPenaltyBox&&i.flags===cr.MoveAllAlternatesMatchingHost){let s=this.pathwayPriority;const o=this.pathwayId;this.penalizedPathways[o]||(this.penalizedPathways[o]=performance.now()),!s&&this.levels&&(s=this.levels.reduce((c,d)=>(c.indexOf(d.pathwayId)===-1&&c.push(d.pathwayId),c),[])),s&&s.length>1&&(this.updatePathwayPriority(s),i.resolved=this.pathwayId!==o)}}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(o=>{s-i[o]>l4&&delete i[o]});for(let o=0;o<t.length;o++){const c=t[o];if(i[c])continue;if(c===this.pathwayId)return;const d=this.hls.nextLoadLevel,f=this.hls.levels[d];if(e=this.getLevelsForPathway(c),e.length>0){this.log(`Setting Pathway to "${c}"`),this.pathwayId=c,this.hls.trigger(R.LEVELS_UPDATED,{levels:e});const p=this.hls.levels[d];f&&p&&this.levels&&(p.attrs["STABLE-VARIANT-ID"]!==f.attrs["STABLE-VARIANT-ID"]&&p.bitrate!==f.bitrate&&this.log(`Unstable Pathways change from bitrate ${f.bitrate} to ${p.bitrate}`),this.hls.nextLoadLevel=d);break}}}clonePathways(t){const e=this.levels;if(!e)return;const i={},s={};t.forEach(o=>{const{ID:c,"BASE-ID":d,"URI-REPLACEMENT":f}=o;if(e.some(g=>g.pathwayId===c))return;const p=this.getLevelsForPathway(d).map(g=>{const v=ai({},g);v.details=void 0,v.url=Mf(g.uri,g.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f);const b=new Ye(g.attrs);b["PATHWAY-ID"]=c;const E=b.AUDIO&&`${b.AUDIO}_clone_${c}`,T=b.SUBTITLES&&`${b.SUBTITLES}_clone_${c}`;E&&(i[b.AUDIO]=E,b.AUDIO=E),T&&(s[b.SUBTITLES]=T,b.SUBTITLES=T),v.attrs=b;const w=new Ra(v);return Co(w,"audio",E),Co(w,"text",T),w});e.push(...p),Of(this.audioTracks,i,f,c),Of(this.subtitleTracks,s,f,c)})}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 g=(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+g)}const o={responseType:"json",url:s.href},c=e.steeringManifestLoadPolicy.default,d=c.errorRetry||c.timeoutRetry||{},f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:d.maxNumRetry||0,retryDelay:d.retryDelayMs||0,maxRetryDelay:d.maxRetryDelayMs||0},p={onSuccess:(g,v,b,E)=>{this.log(`Loaded steering manifest: "${s}"`);const T=g.data;if(T.VERSION!==1){this.log(`Steering VERSION ${T.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=T.TTL;const{"RELOAD-URI":w,"PATHWAY-CLONES":_,"PATHWAY-PRIORITY":D}=T;if(w)try{this.uri=new self.URL(w,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${w}`);return}this.scheduleRefresh(this.uri||b.url),_&&this.clonePathways(_),D&&this.updatePathwayPriority(D)},onError:(g,v,b,E)=>{if(this.log(`Error loading steering manifest: ${g.code} ${g.text} (${v.url})`),this.stopLoad(),g.code===410){this.enabled=!1,this.log(`Steering manifest ${v.url} no longer available`);return}let T=this.timeToLoad*1e3;if(g.code===429){const w=this.loader;if(typeof(w==null?void 0:w.getResponseHeader)=="function"){const _=w.getResponseHeader("Retry-After");_&&(T=parseFloat(_)*1e3)}this.log(`Steering manifest ${v.url} rate limited`);return}this.scheduleRefresh(this.uri||v.url,T)},onTimeout:(g,v,b)=>{this.log(`Timeout loading steering manifest (${v.url})`),this.scheduleRefresh(this.uri||v.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(o,f,p)}scheduleRefresh(t,e=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(t)},e)}}function Of(n,t,e,i){n&&Object.keys(t).forEach(s=>{const o=n.filter(c=>c.groupId===s).map(c=>{const d=ai({},c);return d.details=void 0,d.attrs=new Ye(d.attrs),d.url=d.attrs.URI=Mf(c.url,c.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),d.groupId=d.attrs["GROUP-ID"]=t[s],d.attrs["PATHWAY-ID"]=i,d});n.push(...o)})}function Mf(n,t,e,i){const{HOST:s,PARAMS:o,[e]:c}=i;let d;t&&(d=c==null?void 0:c[t],d&&(n=d));const f=new self.URL(n);return s&&!d&&(f.host=s),o&&Object.keys(o).sort().forEach(p=>{p&&f.searchParams.set(p,o[p])}),f.href}const h4=/^age:\s*[\d.]+\s*$/im;class $f{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 Ao,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 o=this.xhrSetup;o?Promise.resolve().then(()=>{if(!this.stats.aborted)return o(i,e.url)}).catch(c=>(i.open("GET",e.url,!0),o(i,e.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,e,t)}).catch(c=>{this.callbacks.onError({code:i.status,text:c.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:o,maxLoadTimeMs:c}=i.loadPolicy;if(s)for(const d in s)t.setRequestHeader(d,s[d]);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=o&&Vt(o)?o:c,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,o=this.config;if(!i.aborted&&s>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),o.timeout!==o.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),o.timeout=o.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),o.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const c=e.status,d=e.responseType!=="text";if(c>=200&&c<300&&(d&&e.response||e.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const f=d?e.response:e.responseText,p=e.responseType==="arraybuffer"?f.byteLength:f.length;if(i.loaded=i.total=p,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;const g=this.callbacks.onProgress;if(g&&g(i,t,f,e),!this.callbacks)return;const v={url:e.responseURL,data:f,code:c};this.callbacks.onSuccess(v,i,t,e)}else{const f=o.loadPolicy.errorRetry,p=i.retry;Lo(f,p,!1,c)?this.retry(f):(z.error(`${c} while loading ${t.url}`),this.callbacks.onError({code:c,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(Lo(e,i,!0))this.retry(e);else{z.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=wc(t,i.retry),i.retry++,z.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&&h4.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 d4(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const u4=/(\d+)-(\d+)\/(\d+)/;class Nf{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||m4,this.controller=new self.AbortController,this.stats=new Ao}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 o=f4(t,this.controller.signal),c=i.onProgress,d=t.responseType==="arraybuffer",f=d?"byteLength":"length",{maxTimeToFirstByteMs:p,maxLoadTimeMs:g}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=i,this.request=this.fetchSetup(t,o),self.clearTimeout(this.requestTimeout),e.timeout=p&&Vt(p)?p:g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,t,this.response)},e.timeout),self.fetch(this.request).then(v=>{this.response=this.loader=v;const b=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,t,this.response)},g-(b-s.loading.start)),!v.ok){const{status:E,statusText:T}=v;throw new v4(T||"fetch, bad network response",E,v)}return s.loading.first=b,s.total=g4(v.headers)||s.total,c&&Vt(e.highWaterMark)?this.loadProgressively(v,s,t,e.highWaterMark,c):d?v.arrayBuffer():t.responseType==="json"?v.json():v.text()}).then(v=>{const{response:b}=this;self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const E=v[f];E&&(s.loaded=s.total=E);const T={url:b.url,data:v,code:b.status};c&&!Vt(e.highWaterMark)&&c(s,t,v,b),i.onSuccess(T,s,t,b)}).catch(v=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;const b=v&&v.code||0,E=v?v.message:null;i.onError({code:b,text:E},t,v?v.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,o){const c=new df,d=t.body.getReader(),f=()=>d.read().then(p=>{if(p.done)return c.dataLength&&o(e,i,c.flush(),t),Promise.resolve(new ArrayBuffer(0));const g=p.value,v=g.length;return e.loaded+=v,v<s||c.dataLength?(c.push(g),c.dataLength>=s&&o(e,i,c.flush(),t)):o(e,i,g,t),f()}).catch(()=>Promise.reject());return f()}}function f4(n,t){const e={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(ai({},n.headers))};return n.rangeEnd&&e.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),e}function p4(n){const t=u4.exec(n);if(t)return parseInt(t[2])-parseInt(t[1])+1}function g4(n){const t=n.get("Content-Range");if(t){const i=p4(t);if(Vt(i))return i}const e=n.get("Content-Length");if(e)return parseInt(e)}function m4(n,t){return new self.Request(n.url,t)}class v4 extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const y4=/\s/,b4={newCue(n,t,e,i){const s=[];let o,c,d,f,p;const g=self.VTTCue||self.TextTrackCue;for(let b=0;b<i.rows.length;b++)if(o=i.rows[b],d=!0,f=0,p="",!o.isEmpty()){var v;for(let w=0;w<o.chars.length;w++)y4.test(o.chars[w].uchar)&&d?f++:(p+=o.chars[w].uchar,d=!1);o.cueStartTime=t,t===e&&(e+=1e-4),f>=16?f--:f++;const E=Rf(p.trim()),T=Xc(t,e,E);n!=null&&(v=n.cues)!=null&&v.getCueById(T)||(c=new g(t,e,E),c.id=T,c.line=b+1,c.align="left",c.position=10+Math.min(80,Math.floor(f*8/32)*10),s.push(c))}return n&&s.length&&(s.sort((b,E)=>b.line==="auto"||E.line==="auto"?0:b.line>8&&E.line>8?E.line-b.line:b.line-E.line),s.forEach(b=>_0(n,b))),s}},A4={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},E4=Vi(Vi({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:$f,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Sb,bufferController:Ob,capLevelController:th,errorController:vy,fpsController:n4,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:t0,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:A4},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},T4()),{},{subtitleStreamController:Ib,subtitleTrackController:Db,timelineController:i4,audioStreamController:_b,audioTrackController:Lb,emeController:xn,cmcdController:ks,contentSteeringController:c4});function T4(){return{cueHandler:b4,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 k4(n,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=eh(n),i=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(o=>{const c=`${o==="level"?"playlist":o}LoadPolicy`,d=t[c]===void 0,f=[];s.forEach(p=>{const g=`${o}Loading${p}`,v=t[g];if(v!==void 0&&d){f.push(g);const b=e[c].default;switch(t[c]={default:b},p){case"TimeOut":b.maxLoadTimeMs=v,b.maxTimeToFirstByteMs=v;break;case"MaxRetry":b.errorRetry.maxNumRetry=v,b.timeoutRetry.maxNumRetry=v;break;case"RetryDelay":b.errorRetry.retryDelayMs=v,b.timeoutRetry.retryDelayMs=v;break;case"MaxRetryTimeout":b.errorRetry.maxRetryDelayMs=v,b.timeoutRetry.maxRetryDelayMs=v;break}}}),f.length&&z.warn(`hls.js config: "${f.join('", "')}" setting(s) are deprecated, use "${c}": ${JSON.stringify(t[c])}`)}),Vi(Vi({},e),t)}function eh(n){return n&&typeof n=="object"?Array.isArray(n)?n.map(eh):Object.keys(n).reduce((t,e)=>(t[e]=eh(n[e]),t),{}):n}function w4(n){const t=n.loader;t!==Nf&&t!==$f?(z.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1):d4()&&(n.loader=Nf,n.progressive=!0,n.enableSoftwareAES=!0,z.log("[config]: Progressive streaming enabled, using FetchLoader"))}class is{static get version(){return"1.4.12"}static isSupported(){return $y()}static get Events(){return R}static get ErrorTypes(){return qt}static get ErrorDetails(){return ut}static get DefaultConfig(){return is.defaultConfig?is.defaultConfig:E4}static set DefaultConfig(t){is.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Bc,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,lv(t.debug||!1,"Hls instance");const e=this.config=k4(is.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&w4(e);const{abrController:i,bufferController:s,capLevelController:o,errorController:c,fpsController:d}=e,f=new c(this),p=this.abrController=new i(this),g=this.bufferController=new s(this),v=this.capLevelController=new o(this),b=new d(this),E=new Qv(this),T=new ry(this),w=e.contentSteeringController,_=w?new w(this):null,D=this.levelController=new by(this,_),M=new Ay(this),F=new Ty(this.config),x=this.streamController=new kb(this,M,F);v.setStreamController(x),b.setStreamController(x);const N=[E,D,x];_&&N.splice(1,0,_),this.networkControllers=N;const V=[p,g,v,b,T,M];this.audioTrackController=this.createController(e.audioTrackController,N);const j=e.audioStreamController;j&&N.push(new j(this,M,F)),this.subtitleTrackController=this.createController(e.subtitleTrackController,N);const rt=e.subtitleStreamController;rt&&N.push(new rt(this,M,F)),this.createController(e.timelineController,V),F.emeController=this.emeController=this.createController(e.emeController,V),this.cmcdController=this.createController(e.cmcdController,V),this.latencyController=this.createController(sy,V),this.coreComponents=V,N.push(f);const nt=f.onErrorOut;typeof nt=="function"&&this.on(R.ERROR,nt,f)}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){z.error("An internal error happened while handling event "+t+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){z.log("destroy"),this.trigger(R.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){z.log("attachMedia"),this._media=t,this.trigger(R.MEDIA_ATTACHING,{media:t})}detachMedia(){z.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,i=this.url,s=this.url=oc.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});z.log(`loadSource:${s}`),e&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(R.MANIFEST_LOADING,{url:t})}startLoad(t=-1){z.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){z.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){z.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){z.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){z.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){z.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){z.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){z.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){z.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&&(z.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){Ec.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 o=s;o--;){const c=t[o].attrs["HDCP-LEVEL"];if(c&&c<=i)return o}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}}is.defaultConfig=void 0;function S4(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function R4(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Ff(n){const{id:t,key:e,src:i,playlist:s,duration:o}=n;return new Promise(c=>{let d=null;const f=document.createElement("video");if(f.playsInline=!0,f.muted=!0,f.loop=!1,s&&!S4()&&is.isSupported()){let p=!1;d=new is({autoStartLoad:!0,xhrSetup:g=>{const{open:v}=g,b=s.split("?")[1];g.open=function(E,T,w){T.toString().includes("?")||(T+="?"+b),v.apply(this,[E,T,w])}}}),d.loadSource(s),d.attachMedia(f),d.startLoadOnce=(g=-1,v)=>{if(d&&!p){const b=d==null?void 0:d.levels.findIndex(E=>Math.min(E.height,E.width)===v);d.startLevel=d.firstLevel,d.startLoad(g),p=!0,d.currentLevel=b!==-1?b:d.firstLevel}},d.on(is.Events.LEVEL_LOADED,async()=>{p||d==null||d.stopLoad(),c({id:t,key:e,hls:d,config:n,node:f})})}else{f.src=i;let p=!1;if(f.startLoadOnce=()=>{p||(f.preload="auto",f.load(),p=!0)},o)f.preload="none",c({id:t,key:e,hls:d,config:n,node:f});else{f.preload="metadata";const g=async()=>{c({id:t,key:e,hls:d,config:n,node:f}),f.removeEventListener("loadedmetadata",g)};f.addEventListener("loadedmetadata",g)}}})}async function Uf(n){return n.duration===1/0?new Promise(t=>{n.currentTime=Number.MAX_SAFE_INTEGER,n.ontimeupdate=()=>{n.ontimeupdate=null,t(n.duration),n.currentTime=0}}):n.duration}const _4=ys(async function(n){return new FontFace(n.name,`url(${n.url})`,{style:n.style,weight:n.weight}).load()},{cacheKey:([n])=>JSON.stringify(n)});let L4=class{constructor(n){this._hasPlayed=!1,this._memoKey=null,this._lastDeps=null,this._duration=0,this._scenes=null,this._videos={},this._videoMeta={},this._videoState={},this._resolveVideo=ys(async t=>{const{id:e,key:i}=t,s=await Ff(t);s.node.volume=this.host.volume,s.node.playbackRate=this.host.playbackRate;const o={loadeddata:this._handleLoadedData,waiting:this._handleWaiting,canplay:this._handleCanPlay,progress:this._handleProgress,seeking:this._handleSeeking,seeked:this._handleSeeked,play:this._handlePlay,playing:this._handlePlaying,pause:this._handlePause,stalled:this._handleStalled,timeupdate:this._handleTimeUpdate,ended:this._handleEnded,error:this._handleError},c=Object.keys(o).reduce((d,f)=>{const p=f,g=o[p]({id:e,key:i,node:s.node});return d[p]=g,s.node.addEventListener(f,g),d},{});return{...s,listeners:c}},{cacheKey:([{id:t,key:e,src:i,playlist:s}])=>JSON.stringify({id:t,key:e,src:i==null?void 0:i.split("?")[0],playlist:s==null?void 0:s.split("?")[0]})}),this._resolveVideoMeta=ys(async(t,e)=>{const{id:i,captions:s,duration:o,startOffset:c,endOffset:d}=t,f=o??await Uf(e),p=(c??0)*f,g=(1-(d??0))*f;return{id:i,captions:s,start:p,duration:g-p}},{cacheKey:([{id:t,key:e,captions:i,duration:s,startOffset:o,endOffset:c}])=>JSON.stringify({id:t,key:e,captions:i,duration:s,startOffset:o,endOffset:c})}),this._handleLoadedData=({id:t,key:e,node:i})=>()=>{var s,o;const c=this.videoState[e];if(!(c!=null&&c.initialised)){this.videoState={...this.videoState,[e]:{...c,initialised:!0,waiting:!1,buffered:(c==null?void 0:c.buffered)??[]}};const d=(o=(s=this.scenes)==null?void 0:s.scenes)==null?void 0:o.find(({video:f})=>{f==null||f.key});d&&this._setVideoCurrentTime({scene:d,time:this.host.currentTime}),this.host.dispatchEvent(new CustomEvent("video:loadeddata",{detail:{id:t,key:e,node:i}}))}},this._handleWaiting=({key:t})=>()=>{const e=this.videoState[t];e!=null&&e.initialised&&!(e!=null&&e.waiting)&&(this.videoState={...this.videoState,[t]:{...e,waiting:!0}})},this._handleCanPlay=({key:t})=>()=>{const e=this.videoState[t];e!=null&&e.initialised&&e!=null&&e.waiting&&(this.videoState={...this.videoState,[t]:{...e,waiting:!1}}),this.host.paused&&this.host.draw()},this._handleProgress=({key:t,node:e})=>()=>{const i=this.videoState[t],s=this._getBufferSegments({key:t,node:e,duration:this.host.duration});this.videoState={...this.videoState,[t]:{...i,buffered:s}}},this._handleSeeking=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:seeking",{detail:{id:t,key:e,node:i}}))},this._handleSeeked=({id:t,key:e,node:i})=>()=>{const s=this.videoState[e];s!=null&&s.initialised&&(this.host.draw(),this.host.dispatchEvent(new CustomEvent("video:seeked",{detail:{id:t,key:e,node:i}})))},this._handlePlay=({id:t,key:e,node:i})=>()=>{this.hasPlayed=!0,this.host.dispatchEvent(new CustomEvent("video:play",{detail:{id:t,key:e,node:i}}))},this._handlePlaying=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:playing",{detail:{id:t,key:e,node:i}}))},this._handlePause=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:pause",{detail:{id:t,key:e,node:i}}))},this._handleStalled=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:stalled",{detail:{id:t,key:e,node:i}}))},this._handleTimeUpdate=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:timeupdate",{detail:{id:t,key:e,node:i}}))},this._handleEnded=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:ended",{detail:{id:t,key:e,node:i}}))},this._handleError=({id:t,key:e,node:i})=>()=>{const s=new Qr(`Video error - answer ${t} failed to load`);this.host.dispatchEvent(new ErrorEvent("error",{bubbles:!0,composed:!0,error:s,message:s.message})),this.host.dispatchEvent(new CustomEvent("video:error",{detail:{id:t,key:e,node:i}}))},this._cleanupVideo=t=>{var e;const i=this.videos[t];i&&(i.node.pause(),i.node.src="",(e=i.hls)==null||e.destroy(),Object.keys(i.listeners??{}).forEach(s=>{var o,c;if((o=this.videos)!=null&&o[t]){const d=(c=i.listeners)==null?void 0:c[s];d&&i.node.removeEventListener(s,d)}}),delete this.videos[t])},this.host=n,this.host.addController(this)}set hasPlayed(n){n!==this._hasPlayed&&(this._hasPlayed=n,this.host.requestUpdate())}get hasPlayed(){return this._hasPlayed}set duration(n){!isNaN(n)&&n!==this._duration&&(this._duration=n,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(n){n!==this._scenes&&(this._scenes=n,this.host.requestUpdate())}get scenes(){return this._scenes}set videos(n){n!==this._videos&&(this._videos=n,this.host.requestUpdate())}get videos(){return this._videos}set videoMeta(n){n!==this._videoMeta&&(this._videoMeta=n,this.host.requestUpdate())}get videoMeta(){return this._videoMeta}set videoState(n){n!==this._videoState&&(this._videoState=n,this.host.requestUpdate())}get videoState(){return this._videoState}_getBufferSegments({key:n,node:t,duration:e}){var i;const s=t==null?void 0:t.buffered,o=[],{start:c,video:d,videoMeta:f}=((i=this.scenes)==null?void 0:i.scenes.find(({video:p})=>n===(p==null?void 0:p.key)))??{};if(t&&s&&d&&f&&typeof c<"u")for(let p=0;p<s.length;p++){const g=s.start(p),v=s.end(p);Math.max(g,f.start)<=Math.min(v,f.start+f.duration)&&o.push({start:Math.max(0,(Math.max(g-f.start,0)+c)/e*100),end:Math.min((Math.min(v-f.start,f.duration)+c)/e*100,100)})}return o}_setupTask(){new Cl(this.host,async([n,t,e,i,s,o])=>{try{if(e||n){if(this.host._processing=!0,e){let d=null;if(i)try{d=await(await fetch(i,{method:"GET"})).text()}catch{const f=new Qr("Track failed to fetch");this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:f,message:f.message}))}try{const f=e.includes(".m3u8")?"playlist":"video";this.scenes=await uo({data:{questions:{items:[{answer:{id:"source",media:{[f]:e},captions:{current:d}}}]}},template:t,burnCaptions:s,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(f){throw new Qr(`Source template error - ${f.message}`,!0)}}else try{this.scenes=await uo({data:n,template:t,burnCaptions:s,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(d){throw new Qr(`Data template error - ${d.message}`,!0)}if(this.scenes.scenes.length===0)throw new Qr("Template error - no scenes created",!0);Object.keys(this.videos).forEach(d=>{this.scenes.scenes.find(({video:f})=>d===(f==null?void 0:f.key))||this._videos[d].node.pause()});const c=this.scenes.scenes.reduce((d,{video:f})=>(f&&(d[f.key]=f),d),{});Object.keys(this.videos).join("|")!==Object.keys(c).join("|")&&this.host.reset(0,!1),this.videos=c,this.videoState={...this.videoState,...this.scenes.scenes.reduce((d,{video:f,start:p,duration:g})=>{var v;const b=(f==null?void 0:f.key)??`${p}-${g}`,E=this._getBufferSegments({key:b,node:f==null?void 0:f.node,duration:this.scenes.duration});return d[b]={initialised:!f,waiting:!!f,...this.videoState[b],buffered:f?E:(v=this.videoState[b])==null?void 0:v.buffered},d},{})},this.videoMeta=this.scenes.scenes.reduce((d,{video:f,videoMeta:p})=>(f&&p&&(d[f.key]=p),d),{}),(await Promise.all(this.scenes.fonts.map(d=>_4(d)))).forEach(d=>{document.fonts.add(d)}),this.duration=this.scenes.duration,this.host.paused&&this.host.reset(this.host.currentTime,!this.host.paused)}}catch(c){this.scenes=null,this.duration=0,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:c,message:c.message}))}finally{this.host._processing=!1}},()=>{const n=JSON.stringify({data:this.host.data,template:this.host.template,src:this.host.src,track:this.host.track,burnCaptions:this.host.burnCaptions,debug:this.host.debug});if(this._lastDeps&&this._memoKey===n)return this._lastDeps;const t=[this.host.data,this.host.template,this.host.src,this.host.track,this.host.burnCaptions,this.host.debug];return this._memoKey=n,this._lastDeps=t,t})}_setVideoCurrentTime({time:n,scene:t}){const{start:e,video:i,videoMeta:s}=t;if(i&&i.node&&s&&typeof e<"u"){const o=n-e;i.node.currentTime=Math.max(s.start,Math.min(s.start+s.duration,o+s.start))}}setVideosCurrentTime(n){var t;(t=this.scenes)==null||t.scenes.forEach(e=>{this._setVideoCurrentTime({time:n,scene:e})})}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(n=>{this._cleanupVideo(n)}),this.videos={}}};function C4(n){n.requestFullscreen?n.requestFullscreen():n.mozRequestFullScreen?n.mozRequestFullScreen():n.webkitRequestFullscreen?n.webkitRequestFullscreen():n.msRequestFullscreen&&n.msRequestFullscreen()}function I4(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const ih=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen","preview"],x4={id:"captions",event:"captions:click",label:"Closed Captions"},D4={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},Bf={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}]},P4={id:"playbackRate",label:"Playback playbackRate",subItems:Bf};class O4 extends Ld{constructor(t){if(super(t),this.element=null,this.observer=void 0,t.type!==bn.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)),ms}}const Bo=An(O4);var Gf=Number.isNaN||function(n){return typeof n=="number"&&n!==n};function M4(n,t){return!!(n===t||Gf(n)&&Gf(t))}function $4(n,t){if(n.length!==t.length)return!1;for(var e=0;e<n.length;e++)if(!M4(n[e],t[e]))return!1;return!0}function N4(n,t){t===void 0&&(t=$4);var e=null;function i(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];if(e&&e.lastThis===this&&t(s,e.lastArgs))return e.lastResult;var c=n.apply(this,s);return e={lastResult:c,lastArgs:s,lastThis:this},c}return i.clear=function(){e=null},i}const F4=N4(()=>{const n=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),t=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-SemiBold.woff2)",{style:"normal",weight:"600"}),e=new FontFace("Roobert Captions","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),i=Ud.map(s=>new FontFace(s.family,`url(${s.url})`,{style:s.style}));return[n,t,e,...i]}),$r={"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"},U4={colors:$r,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:600},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, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,"Noto Sans", "Noto Color Emoji", sans-serif, "Segoe UI Emoji", "Segoe UI Symbol", "Apple 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 ${$r["dark-100"]}`,medium:`0 .125rem .625rem ${$r["dark-100"]}`,large:`0 .25rem 1rem ${$r["dark-50"]}`,xl:`.25rem .25rem 1rem ${$r["dark-250"]}`,xxl:`0 .25rem 2rem ${$r["dark-100"]}`,xxxl:`.25rem .25rem 3rem ${$r["dark-250"]}`,toolbar:`0 -.625rem .625rem ${$r["dark-50"]}`,text:`0 0 .25rem ${$r["dark-250"]}`},timings:{fast:".1s",normal:".2s",slow:".3s"},easings:{linear:"linear"},focusOutline:{width:".2rem",color:$r["dark-400"]},iconSizes:{small:"0.75rem",medium:"1rem",large:"1.5rem"}},Hf=wm.flatten(U4,{delimiter:"-"}),B4=Object.keys(Hf).map(n=>qn(`:host { --${n}: ${Hf[n]}; }`)),G4=n=>{class t extends n{firstUpdated(){F4().forEach(i=>{document.fonts.add(i)})}}return t.styles=[(n==null?void 0:n.styles)??[],B4,Ti`
191
209
  :host {
192
210
  font-family: var(--fontFamilies-sans);
193
211
  font-size: var(--fontSizes-medium);
194
212
  line-height: var(--lineHeights-medium);
195
213
  font-weight: var(--fontWeights-regular);
196
214
  }
197
- `,jt`
215
+ `,Ti`
198
216
  *,
199
217
  *::before,
200
218
  *::after,
@@ -268,12 +286,12 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
268
286
  scroll-behavior: auto !important;
269
287
  }
270
288
  }
271
- `],t},yt=jv(Ei),Wv=(r,t)=>(typeof window<"u"&&(window.customElements.get(r)??window.customElements.define(r,t)),t),Yv=(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))}}},se=r=>t=>typeof t=="function"?Wv(r,t):Yv(r,t);class qv extends js{constructor(t){if(super(t),t.type!==Ji.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}update(t,[e]){return e==null||e(t.element),Ee}}const mc=ts(qv);class zv{constructor(t){this.hiddenControls=[],this._measureRef=be(),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(c=>this._hideables[c].hideIndex===l.length);if(h){const c=this._hideables[h].element;c&&(c.style.display="none"),l.push(h)}Object.keys(this._showables).forEach(c=>{this._showables[c].showOn.some(d=>l.includes(d))&&(this._showables[c].element.style.display="flex")})}this.hiddenControls=l,this._prevControlsWidth=o,this.host.requestUpdate()}},this.host=t}measure(){return Te(this._measureRef)}contain(){return va(this._onResize)}hide(t,e){return mc(i=>{this._hideables[t]={element:i,hideIndex:e}})}show(t,e){return mc(i=>{this._showables[t]={element:i,showOn:e}})}}function vc(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 Xv=Object.defineProperty,Qv=Object.getOwnPropertyDescriptor,xi=(r,t,e,i)=>{for(var s=i>1?void 0:i?Qv(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&&Xv(t,e,s),s};let We=class extends yt{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return st`<button
272
- class=${wt({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"})}
289
+ `],t},Re=G4(yn),H4=(n,t)=>(typeof window<"u"&&(window.customElements.get(n)??window.customElements.define(n,t)),t),V4=(n,t)=>{const{kind:e,elements:i}=t;return{kind:e,elements:i,finisher(s){typeof window<"u"&&(window.customElements.get(n)??window.customElements.define(n,s))}}},Oi=n=>t=>typeof t=="function"?H4(n,t):V4(n,t);class W4{constructor(t){this._memoKey=null,this._lastDeps=null,this._scenes=null,this._video=null,this._handleSeeked=()=>{this.host._draw()},this._resolveVideo=ys(async e=>{const i=await Ff(e);return i.node.play=async()=>{},i.node.addEventListener("seeked",this._handleSeeked),i},{cacheKey:([{id:e,src:i,playlist:s}])=>JSON.stringify({id:e,src:i==null?void 0:i.split("?")[0],playlist:s==null?void 0:s.split("?")[0]})}),this._resolveAnswer=ys(async e=>{const{id:i,key:s,poster:o}=e,c=new Image;return{id:i,key:s,config:e,node:null,getSource:()=>(o&&c.src!==o&&(c.onload=()=>{this.host._draw()},c.src=o),c)}},{cacheKey:([{id:e,poster:i}])=>JSON.stringify({id:e,poster:i==null?void 0:i.split("?")[0]})}),this._resolveVideoMeta=ys(async(e,i)=>{const{id:s,duration:o,startOffset:c,endOffset:d}=e,f=o??await Uf(i),p=(c??0)*f,g=(1-(d??0))*f;return{id:s,start:p,duration:g-p}},{cacheKey:([{id:e,duration:i,startOffset:s,endOffset:o}])=>JSON.stringify({id:e,duration:i,startOffset:s,endOffset:o})}),this.host=t,this.host.addController(this)}set scenes(t){t!==this._scenes&&(this._scenes=t,this.host.requestUpdate())}get scenes(){return this._scenes}_setupTask(){new Cl(this.host,async([t,e,i])=>{var s,o;try{if(t){const c=t.includes(".m3u8")?"playlist":"video";try{this.scenes=await uo({data:{questions:{items:[{answer:{id:"source",media:{[c]:t}}}]}},template:i},this._resolveVideo,this._resolveVideoMeta)}catch(d){throw new Qr(`Video preview source template error: ${d.message}`)}this._video=((o=(s=this.scenes.scenes[0])==null?void 0:s.video)==null?void 0:o.node)??null}else if(e)try{this.scenes=await uo({data:e,template:i},this._resolveAnswer,this._resolveVideoMeta)}catch(c){throw new Qr(`Video preview data template error: ${c.message}`)}}catch(c){this.scenes=null,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:c,message:c.message}))}},()=>{const t=JSON.stringify({data:this.host.data,template:this.host.template});if(this._lastDeps&&this._memoKey===t)return this._lastDeps;const e=[this.host.src,this.host.data,this.host.template];return this._memoKey=t,this._lastDeps=e,e})}hostConnected(){this._setupTask()}hostDisconnected(){this._video&&(this._video.pause(),this._video.removeEventListener("seeked",this._handleSeeked),this._video.src="",this._video=null)}}function Vf(n,t,e){return Math.min(Math.max(t,n),e)}function rh(n,t={}){const e=Math.max(0,n||0),i=Math.floor(e/3600),s=Math.floor(e%3600/60),o=Math.floor(e%3600%60),c=Math.floor(e%1*1e3);let d=i?`${i}:${`${s}`.padStart(2,"0")}:${`${o}`.padStart(2,"0")}`:`${s}:${`${o}`.padStart(2,"0")}`;return t.includeMs&&(d+=`:${`${c}`.padStart(3,"0")}`),d}var j4=Object.defineProperty,K4=Object.getOwnPropertyDescriptor,Dn=(n,t,e,i)=>{for(var s=i>1?void 0:i?K4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&j4(t,e,s),s};let ws=class extends Re{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return ie`<button
290
+ class=${Ke({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"})}
273
291
  >
274
292
  <slot></slot>
275
- ${this.icon&&st`<vmp-new-icon icon=${this.icon}></vmp-new-icon>`}
276
- </button>`}};We.styles=[yt.styles??[],jt`
293
+ ${this.icon&&ie`<vmp-new-icon icon=${this.icon}></vmp-new-icon>`}
294
+ </button>`}};ws.styles=[Re.styles??[],Ti`
277
295
  :host {
278
296
  --button-color: var(--vu-button-color, var(--colors-dark-640));
279
297
  --button-background: var(--vu-button-background, var(--colors-light-1000));
@@ -349,37 +367,42 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
349
367
  .weight-light:focus {
350
368
  background: #9d9d9d;
351
369
  }
352
- `],xi([j({type:Boolean})],We.prototype,"active",2),xi([j({type:String})],We.prototype,"size",2),xi([j({type:String})],We.prototype,"rounded",2),xi([j({type:String})],We.prototype,"weight",2),xi([j({type:String})],We.prototype,"icon",2),We=xi([se("vmp-new-button")],We);const yc={"arrow-left":()=>st`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
370
+ `],Dn([It({type:Boolean})],ws.prototype,"active",2),Dn([It({type:String})],ws.prototype,"size",2),Dn([It({type:String})],ws.prototype,"rounded",2),Dn([It({type:String})],ws.prototype,"weight",2),Dn([It({type:String})],ws.prototype,"icon",2),ws=Dn([Oi("vmp-new-button")],ws);const Wf={"arrow-left":()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
353
371
  <path
354
372
  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"
355
373
  fill="currentColor"
356
374
  />
357
- </svg>`,"arrow-right":()=>st`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
375
+ </svg>`,"arrow-right":()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
358
376
  <path
359
377
  d="M3.75 9.21875H13.2578L8.89062 4.85156L10 3.75L16.25 10L10 16.25L8.89844 15.1484L13.2578 10.7812H3.75V9.21875Z"
360
378
  fill="currentColor"
361
379
  />
362
- </svg>`,"captions-cross":()=>st`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
380
+ </svg>`,"captions-cross":()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
363
381
  <path
364
382
  d="M17.0625 19.4167L14.3125 16.6667H3.33333C2.875 16.6667 2.4825 16.5036 2.15583 16.1775C1.82972 15.8509 1.66667 15.4584 1.66667 15V4.16669C1.66667 4.13891 1.66667 4.11446 1.66667 4.09335C1.66667 4.0728 1.66667 4.04863 1.66667 4.02085L0.5625 2.91669L1.75 1.72919L18.25 18.2292L17.0625 19.4167ZM18.3333 15.9375L14.7083 12.3125C14.8056 12.2431 14.8786 12.1495 14.9275 12.0317C14.9758 11.9134 15 11.7917 15 11.6667V10.8334H13.75V11.25H13.6458L12.0833 9.68752V8.75002H13.75V9.16669H15V8.33335C15 8.09724 14.92 7.89919 14.76 7.73919C14.6006 7.57974 14.4028 7.50002 14.1667 7.50002H11.6667C11.4306 7.50002 11.2328 7.57974 11.0733 7.73919C10.9133 7.89919 10.8333 8.09724 10.8333 8.33335V8.43752L5.72917 3.33335H16.6667C17.125 3.33335 17.5175 3.49669 17.8442 3.82335C18.1703 4.14946 18.3333 4.54169 18.3333 5.00002V15.9375ZM5.83333 12.5H8.33333C8.56944 12.5 8.7675 12.42 8.9275 12.26C9.08694 12.1006 9.16667 11.9028 9.16667 11.6667V11.5209L8.47917 10.8334H7.91667V11.25H6.25V8.60419L5.3125 7.66669C5.21528 7.73613 5.13889 7.82974 5.08333 7.94752C5.02778 8.06585 5 8.19446 5 8.33335V11.6667C5 11.9028 5.07972 12.1006 5.23917 12.26C5.39917 12.42 5.59722 12.5 5.83333 12.5Z"
365
383
  fill="currentColor"
366
384
  />
367
- </svg>`,captions:()=>st`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
385
+ </svg>`,captions:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
368
386
  <path
369
387
  d="M5.83342 12.5H8.33342C8.56953 12.5 8.76758 12.42 8.92758 12.26C9.08703 12.1005 9.16675 11.9028 9.16675 11.6666V10.8333H7.91675V11.25H6.25008V8.74998H7.91675V9.16665H9.16675V8.33331C9.16675 8.0972 9.08703 7.89915 8.92758 7.73915C8.76758 7.5797 8.56953 7.49998 8.33342 7.49998H5.83342C5.5973 7.49998 5.39925 7.5797 5.23925 7.73915C5.0798 7.89915 5.00008 8.0972 5.00008 8.33331V11.6666C5.00008 11.9028 5.0798 12.1005 5.23925 12.26C5.39925 12.42 5.5973 12.5 5.83342 12.5ZM11.6667 12.5H14.1667C14.4029 12.5 14.6006 12.42 14.7601 12.26C14.9201 12.1005 15.0001 11.9028 15.0001 11.6666V10.8333H13.7501V11.25H12.0834V8.74998H13.7501V9.16665H15.0001V8.33331C15.0001 8.0972 14.9201 7.89915 14.7601 7.73915C14.6006 7.5797 14.4029 7.49998 14.1667 7.49998H11.6667C11.4306 7.49998 11.2329 7.5797 11.0734 7.73915C10.9134 7.89915 10.8334 8.0972 10.8334 8.33331V11.6666C10.8334 11.9028 10.9134 12.1005 11.0734 12.26C11.2329 12.42 11.4306 12.5 11.6667 12.5ZM3.33341 16.6666C2.87508 16.6666 2.48258 16.5036 2.15591 16.1775C1.8298 15.8508 1.66675 15.4583 1.66675 15V4.99998C1.66675 4.54165 1.8298 4.14942 2.15591 3.82331C2.48258 3.49665 2.87508 3.33331 3.33341 3.33331H16.6667C17.1251 3.33331 17.5176 3.49665 17.8442 3.82331C18.1704 4.14942 18.3334 4.54165 18.3334 4.99998V15C18.3334 15.4583 18.1704 15.8508 17.8442 16.1775C17.5176 16.5036 17.1251 16.6666 16.6667 16.6666H3.33341Z"
370
388
  fill="currentColor"
371
389
  />
372
- </svg>`,"chevron-down":()=>st`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" part="svg">
390
+ </svg>`,"chevron-down":()=>ie`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" part="svg">
373
391
  <path
374
392
  d="M11.8032 7.13666L10.8632 6.19666L7.80322 9.24999L4.74322 6.19666L3.80322 7.13666L7.80322 11.1367L11.8032 7.13666Z"
375
393
  fill="currentColor"
376
394
  />
377
- </svg>`,close:()=>st`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" part="svg">
395
+ </svg>`,close:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" part="svg">
378
396
  <path
379
397
  d="M15.8334 5.34163L14.6584 4.16663L10 8.82496L5.34169 4.16663L4.16669 5.34163L8.82502 9.99996L4.16669 14.6583L5.34169 15.8333L10 11.175L14.6584 15.8333L15.8334 14.6583L11.175 9.99996L15.8334 5.34163Z"
380
398
  fill="currentColor"
381
399
  />
382
- </svg>`,loading:()=>st`<svg class="spinner" width="50" height="50" viewBox="0 0 50 50" part="svg">
400
+ </svg>`,error:()=>ie`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" part="svg">
401
+ <path
402
+ d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm1 15h-2v-2h2v2Zm0-4h-2V7h2v6Z"
403
+ fill="currentColor"
404
+ />
405
+ </svg>`,loading:()=>ie`<svg class="spinner" width="50" height="50" viewBox="0 0 50 50" part="svg">
383
406
  <style>
384
407
  /* SVG spinner icon animation */
385
408
  .spinner {
@@ -439,62 +462,62 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
439
462
  }
440
463
  </style>
441
464
  <circle class="path" cx="25" cy="25" r="20" fill="none" stroke-width="5" />
442
- </svg>`,maximize:()=>st`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
465
+ </svg>`,maximize:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
443
466
  <path
444
467
  fill-rule="evenodd"
445
468
  clip-rule="evenodd"
446
469
  d="M6.66675 3.33331H3.33341H1.66675V4.99998V8.33331H3.33341V4.99998H6.66675V3.33331ZM6.66675 15H3.33341V11.6666H1.66675V15V16.6666H3.33341H6.66675V15ZM13.3334 3.33331H16.6667H18.3334V4.99998V8.33331H16.6667V4.99998H13.3334V3.33331ZM16.6667 15H13.3334V16.6666H16.6667H18.3334V15V11.6666H16.6667V15Z"
447
470
  fill="currentColor"
448
471
  />
449
- </svg>`,minimize:()=>st`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
472
+ </svg>`,minimize:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
450
473
  <path
451
474
  fill-rule="evenodd"
452
475
  clip-rule="evenodd"
453
476
  d="M5.00008 3.33331H6.66675V6.66665V8.33331H5.00008H1.66675V6.66665H5.00008V3.33331ZM5.00008 11.6666H1.66675V13.3333H5.00008V16.6666H6.66675V13.3333V11.6666H5.00008ZM15.0001 6.66665H18.3334V8.33331H15.0001H13.3334V6.66665V3.33331H15.0001V6.66665ZM18.3334 11.6666H15.0001H13.3334V13.3333V16.6666H15.0001V13.3333H18.3334V11.6666Z"
454
477
  fill="currentColor"
455
478
  />
456
- </svg>`,muted:()=>st`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
479
+ </svg>`,muted:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
457
480
  <path
458
481
  d="M13.75 10C13.75 8.525 12.9 7.25833 11.6667 6.64167V8.48333L13.7083 10.525C13.7333 10.3583 13.75 10.1833 13.75 10ZM15.8333 10C15.8333 10.7833 15.6667 11.5167 15.3833 12.2L16.6417 13.4583C17.1917 12.425 17.5 11.25 17.5 10C17.5 6.43333 15.0083 3.45 11.6667 2.69167V4.40833C14.075 5.125 15.8333 7.35833 15.8333 10ZM3.55833 2.5L2.5 3.55833L6.44167 7.5H2.5V12.5H5.83333L10 16.6667V11.0583L13.5417 14.6C12.9833 15.0333 12.3583 15.375 11.6667 15.5833V17.3C12.8167 17.0417 13.8583 16.5083 14.7417 15.7917L16.4417 17.5L17.5 16.4417L10 8.94167L3.55833 2.5ZM10 3.33333L8.25833 5.075L10 6.81667V3.33333Z"
459
482
  fill="currentColor"
460
483
  />
461
- </svg>`,pause:()=>st`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
484
+ </svg>`,pause:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
462
485
  <path
463
486
  fill-rule="evenodd"
464
487
  clip-rule="evenodd"
465
488
  d="M8.33333 2.5H5V17.5H8.33333V2.5ZM15 2.5H11.6667V17.5H15V2.5Z"
466
489
  fill="currentColor"
467
490
  />
468
- </svg>`,"play-large":()=>st`<svg width="45" height="53" viewBox="0 0 45 53" fill="none" part="svg">
491
+ </svg>`,"play-large":()=>ie`<svg width="45" height="53" viewBox="0 0 45 53" fill="none" part="svg">
469
492
  <path
470
493
  d="M43.5 23.8319C45.5 25.0083 45.5 27.9492 43.5 29.1256L4.5 52.0647C2.5 53.2411 0 51.7706 0 49.4179V3.53961C0 1.18687 2.5 -0.283582 4.5 0.892785L43.5 23.8319Z"
471
494
  fill="currentColor"
472
495
  />
473
- </svg>`,play:()=>st`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
496
+ </svg>`,play:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
474
497
  <path d="M17.3803 9.99998L5.83325 16.6666V3.33331L17.3803 9.99998Z" fill="currentColor" />
475
- </svg>`,settings:()=>st`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
498
+ </svg>`,settings:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
476
499
  <path
477
500
  d="M7.70833 18.3334L7.375 15.6667C7.19445 15.5972 7.02444 15.5139 6.865 15.4167C6.705 15.3195 6.54861 15.2153 6.39583 15.1042L3.91667 16.1459L1.625 12.1875L3.77083 10.5625C3.75694 10.4653 3.75 10.3714 3.75 10.2809C3.75 10.1909 3.75 10.0972 3.75 10C3.75 9.9028 3.75 9.80891 3.75 9.71835C3.75 9.62835 3.75694 9.53474 3.77083 9.43752L1.625 7.81252L3.91667 3.85419L6.39583 4.89585C6.54861 4.78474 6.70833 4.68058 6.875 4.58335C7.04167 4.48613 7.20833 4.4028 7.375 4.33335L7.70833 1.66669H12.2917L12.625 4.33335C12.8056 4.4028 12.9758 4.48613 13.1358 4.58335C13.2953 4.68058 13.4514 4.78474 13.6042 4.89585L16.0833 3.85419L18.375 7.81252L16.2292 9.43752C16.2431 9.53474 16.25 9.62835 16.25 9.71835C16.25 9.80891 16.25 9.9028 16.25 10C16.25 10.0972 16.25 10.1909 16.25 10.2809C16.25 10.3714 16.2361 10.4653 16.2083 10.5625L18.3542 12.1875L16.0625 16.1459L13.6042 15.1042C13.4514 15.2153 13.2917 15.3195 13.125 15.4167C12.9583 15.5139 12.7917 15.5972 12.625 15.6667L12.2917 18.3334H7.70833ZM10.0417 12.9167C10.8472 12.9167 11.5347 12.632 12.1042 12.0625C12.6736 11.4931 12.9583 10.8056 12.9583 10C12.9583 9.19447 12.6736 8.50696 12.1042 7.93752C11.5347 7.36808 10.8472 7.08335 10.0417 7.08335C9.22222 7.08335 8.53111 7.36808 7.96833 7.93752C7.40611 8.50696 7.125 9.19447 7.125 10C7.125 10.8056 7.40611 11.4931 7.96833 12.0625C8.53111 12.632 9.22222 12.9167 10.0417 12.9167ZM10.0417 11.25C9.69445 11.25 9.39945 11.1284 9.15667 10.885C8.91333 10.6422 8.79167 10.3472 8.79167 10C8.79167 9.6528 8.91333 9.3578 9.15667 9.11502C9.39945 8.87169 9.69445 8.75002 10.0417 8.75002C10.3889 8.75002 10.6842 8.87169 10.9275 9.11502C11.1703 9.3578 11.2917 9.6528 11.2917 10C11.2917 10.3472 11.1703 10.6422 10.9275 10.885C10.6842 11.1284 10.3889 11.25 10.0417 11.25ZM9.16667 16.6667H10.8125L11.1042 14.4584C11.5347 14.3472 11.9342 14.1839 12.3025 13.9684C12.6703 13.7534 13.0069 13.4931 13.3125 13.1875L15.375 14.0417L16.1875 12.625L14.3958 11.2709C14.4653 11.0764 14.5139 10.8714 14.5417 10.6559C14.5694 10.4409 14.5833 10.2222 14.5833 10C14.5833 9.7778 14.5694 9.55891 14.5417 9.34335C14.5139 9.12835 14.4653 8.92363 14.3958 8.72919L16.1875 7.37502L15.375 5.95835L13.3125 6.83335C13.0069 6.51391 12.6703 6.24641 12.3025 6.03085C11.9342 5.81585 11.5347 5.6528 11.1042 5.54169L10.8333 3.33335H9.1875L8.89583 5.54169C8.46528 5.6528 8.06611 5.81585 7.69833 6.03085C7.33 6.24641 6.99306 6.50697 6.6875 6.81252L4.625 5.95835L3.8125 7.37502L5.60417 8.70835C5.53472 8.91669 5.48611 9.12502 5.45833 9.33335C5.43056 9.54169 5.41667 9.76391 5.41667 10C5.41667 10.2222 5.43056 10.4375 5.45833 10.6459C5.48611 10.8542 5.53472 11.0625 5.60417 11.2709L3.8125 12.625L4.625 14.0417L6.6875 13.1667C6.99306 13.4861 7.33 13.7534 7.69833 13.9684C8.06611 14.1839 8.46528 14.3472 8.89583 14.4584L9.16667 16.6667Z"
478
501
  fill="currentColor"
479
502
  />
480
- </svg>`,tick:()=>st`<svg width="20" height="21" viewBox="0 0 20 21" fill="none" part="svg">
503
+ </svg>`,tick:()=>ie`<svg width="20" height="21" viewBox="0 0 20 21" fill="none" part="svg">
481
504
  <path
482
505
  d="M7.50016 14.0001L4.00016 10.5001L2.8335 11.6667L7.50016 16.3334L17.5002 6.33341L16.3335 5.16675L7.50016 14.0001Z"
483
506
  fill="currentColor"
484
507
  />
485
- </svg>`,"volume-high":()=>st`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
508
+ </svg>`,"volume-high":()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
486
509
  <path
487
510
  d="M2.5 7.49998V12.5H5.83333L10 16.6667V3.33332L5.83333 7.49998H2.5ZM13.75 9.99998C13.75 8.52498 12.9 7.25832 11.6667 6.64165V13.35C12.9 12.7417 13.75 11.475 13.75 9.99998ZM11.6667 2.69165V4.40832C14.075 5.12498 15.8333 7.35832 15.8333 9.99998C15.8333 12.6417 14.075 14.875 11.6667 15.5917V17.3083C15.0083 16.55 17.5 13.5667 17.5 9.99998C17.5 6.43332 15.0083 3.44998 11.6667 2.69165Z"
488
511
  fill="currentColor"
489
512
  />
490
- </svg>`,"volume-low":()=>st`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
513
+ </svg>`,"volume-low":()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
491
514
  <path d="M5.83325 7.49998V12.5H9.16658L13.3333 16.6666V3.33331L9.16658 7.49998H5.83325Z" fill="currentColor" />
492
- </svg>`,"volume-medium":()=>st`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
515
+ </svg>`,"volume-medium":()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
493
516
  <path
494
517
  d="M15.4167 9.99998C15.4167 8.52498 14.5667 7.25831 13.3334 6.64165V13.35C14.5667 12.7416 15.4167 11.475 15.4167 9.99998ZM4.16675 7.49998V12.5H7.50008L11.6667 16.6666V3.33331L7.50008 7.49998H4.16675Z"
495
518
  fill="currentColor"
496
519
  />
497
- </svg>`,vouch:()=>st`<svg
520
+ </svg>`,vouch:()=>ie`<svg
498
521
  xmlns="http://www.w3.org/2000/svg"
499
522
  height="28"
500
523
  width="105"
@@ -505,26 +528,26 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
505
528
  <path
506
529
  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"
507
530
  />
508
- </svg>`};var Zv=Object.defineProperty,Jv=Object.getOwnPropertyDescriptor,Ec=(r,t,e,i)=>{for(var s=i>1?void 0:i?Jv(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&&Zv(t,e,s),s};let br=class extends yt{render(){return!this.icon||!Object.keys(yc).includes(this.icon)?null:yc[this.icon]()}};br.styles=[yt.styles??[],jt`
531
+ </svg>`};var Y4=Object.defineProperty,z4=Object.getOwnPropertyDescriptor,jf=(n,t,e,i)=>{for(var s=i>1?void 0:i?z4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&Y4(t,e,s),s};let Go=class extends Re{render(){return!this.icon||!Object.keys(Wf).includes(this.icon)?null:Wf[this.icon]()}};Go.styles=[Re.styles??[],Ti`
509
532
  :host {
510
533
  display: flex;
511
534
  align-items: center;
512
535
  justify-content: center;
513
536
  flex-shrink: 0;
514
537
  }
515
- `],Ec([j({type:String})],br.prototype,"icon",2),br=Ec([se("vmp-new-icon")],br);var t0=Object.defineProperty,e0=Object.getOwnPropertyDescriptor,Pi=(r,t,e,i)=>{for(var s=i>1?void 0:i?e0(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&&t0(t,e,s),s};let Ye=class extends yt{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return st`
538
+ `],jf([It({type:String})],Go.prototype,"icon",2),Go=jf([Oi("vmp-new-icon")],Go);var X4=Object.defineProperty,Z4=Object.getOwnPropertyDescriptor,Pn=(n,t,e,i)=>{for(var s=i>1?void 0:i?Z4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&X4(t,e,s),s};let Ss=class extends Re{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return ie`
516
539
  <vmp-new-button
517
540
  ?active=${this.active}
518
- size=${es(this.size)}
519
- rounded=${es(this.rounded)}
520
- weight=${es(this.weight)}
541
+ size=${Xs(this.size)}
542
+ rounded=${Xs(this.rounded)}
543
+ weight=${Xs(this.weight)}
521
544
  >
522
545
  <vmp-new-icon
523
- class=${wt({tiny:this.size==="tiny",small:this.size==="small",large:this.size==="large"})}
524
- icon=${es(this.icon)}
546
+ class=${Ke({tiny:this.size==="tiny",small:this.size==="small",large:this.size==="large"})}
547
+ icon=${Xs(this.icon)}
525
548
  ></vmp-new-icon>
526
549
  </vmp-new-button>
527
- `}};Ye.styles=[yt.styles??[],jt`
550
+ `}};Ss.styles=[Re.styles??[],Ti`
528
551
  .tiny::part(svg) {
529
552
  height: 12px;
530
553
  width: 12px;
@@ -539,15 +562,64 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
539
562
  height: 32px;
540
563
  width: 32px;
541
564
  }
542
- `],Pi([j({type:Boolean})],Ye.prototype,"active",2),Pi([j({type:String})],Ye.prototype,"size",2),Pi([j({type:String})],Ye.prototype,"rounded",2),Pi([j({type:String})],Ye.prototype,"weight",2),Pi([j({type:String})],Ye.prototype,"icon",2),Ye=Pi([se("vmp-new-icon-button")],Ye);const ya=`.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)}
543
- `;var i0=Object.defineProperty,s0=Object.getOwnPropertyDescriptor,bs=(r,t,e,i)=>{for(var s=i>1?void 0:i?s0(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&&i0(t,e,s),s};let di=class extends yt{constructor(){super(...arguments),this.semibold=!1,this.truncate=!1,this.size="medium",this.content=""}render(){return st`
565
+ `],Pn([It({type:Boolean})],Ss.prototype,"active",2),Pn([It({type:String})],Ss.prototype,"size",2),Pn([It({type:String})],Ss.prototype,"rounded",2),Pn([It({type:String})],Ss.prototype,"weight",2),Pn([It({type:String})],Ss.prototype,"icon",2),Ss=Pn([Oi("vmp-new-icon-button")],Ss);var q4=Object.defineProperty,Q4=Object.getOwnPropertyDescriptor,Yi=(n,t,e,i)=>{for(var s=i>1?void 0:i?Q4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&q4(t,e,s),s};let rs=class extends Re{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=Pl,this._currentTime=0,this._sceneController=new W4(this),this._canvasRef=wi(),this._previewRef=wi(),this._previewTimeRef=wi(),this._handleScrubberMouseEnter=({detail:{x:n,y:t,elementLeft:e,elementRight:i}})=>{var s,o;if((s=this._previewRef)!=null&&s.value){const c=this._previewRef.value.getBoundingClientRect(),d=(o=this._previewRef.value.getRootNode().host)==null?void 0:o.getBoundingClientRect();c&&d&&(this._previewRef.value.style.opacity="1",this._previewRef.value.style.transform=`translate3d(${Vf(e-d.left,n-d.left-c.width/2,i-d.left-c.width)}px, ${t-d.top-c.height-28}px, 0)`)}},this._handleScrubberMouseMove=({detail:{time:n,x:t,elementLeft:e,elementRight:i}})=>{var s,o,c,d,f,p,g;if(this._currentTime=n,(s=this._sceneController.scenes)!=null&&s.scenes.length){const v=(f=(d=(c=(o=this._sceneController.scenes)==null?void 0:o.scenes)==null?void 0:c.find(({start:b,duration:E,video:T})=>T&&n>=b&&n<=b+E))==null?void 0:d.video)==null?void 0:f.node;if(v&&(v.currentTime=n),this._draw(),(p=this._previewRef)!=null&&p.value){const b=this._previewRef.value.getBoundingClientRect(),E=(g=this._previewRef.value.getRootNode().host)==null?void 0:g.getBoundingClientRect();if(b&&E){const T=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[,w]=Array.from(T.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${Vf(e-E.left,t-E.left-b.width/2,i-E.left-b.width)}px, ${w[1]}px, 0)`}}this._previewTimeRef.value&&this._previewTimeRef.value.setAttribute("content",rh(this._currentTime,{includeMs:!0}))}},this._handleScrubberMouseLeave=()=>{var n;(n=this._previewRef)!=null&&n.value&&(this._previewRef.value.style.opacity="0")},this._handleScrubberResize=({detail:{y:n}})=>{var t,e;if((t=this._previewRef)!=null&&t.value){const i=this._previewRef.value.getBoundingClientRect(),s=(e=this._previewRef.value.getRootNode().host)==null?void 0:e.getBoundingClientRect();if(i&&s){const o=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[c]=Array.from(o.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${c[1]}px, ${n-s.top-i.height-28}px, 0)`}}}}_draw(n=this._currentTime){var t;this._sceneController.scenes&&this._canvasRef.value&&((t=this.compilation)==null||t.call(this,{currentTime:n,scenes:this._sceneController.scenes,canvas:this._canvasRef.value}))}connectedCallback(){super.connectedCallback(),document.addEventListener("scrubber:resize",this._handleScrubberResize),document.addEventListener("scrubber:mouseenter",this._handleScrubberMouseEnter),document.addEventListener("scrubber:mousemove",this._handleScrubberMouseMove),document.addEventListener("scrubber:mouseleave",this._handleScrubberMouseLeave)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("scrubber:resize",this._handleScrubberResize),document.removeEventListener("scrubber:mouseenter",this._handleScrubberMouseEnter),document.removeEventListener("scrubber:mousemove",this._handleScrubberMouseMove),document.removeEventListener("scrubber:mouseleave",this._handleScrubberMouseLeave)}render(){var n;const{height:t,width:e}=Ol({resolution:180,aspectRatio:this.aspectRatio}),i=((n=this._sceneController.scenes)==null?void 0:n.scenes.length)??0;return!this.disabled&&(this.src||i>1)?ie`
566
+ <div
567
+ ${Si(this._previewRef)}
568
+ class="preview"
569
+ style=${Wl({width:this.aspectRatio>1?"140px":void 0,height:this.aspectRatio<=1?"140px":void 0,aspectRatio:this.aspectRatio})}
570
+ >
571
+ <canvas ${Si(this._canvasRef)} class="preview-canvas" width=${e} height=${t}></canvas>
572
+ <vmp-new-text ${Si(this._previewTimeRef)} class="preview-text"></vmp-new-text>
573
+ </div>
574
+ `:null}};rs.styles=[Re.styles??[],Ti`
575
+ .preview {
576
+ position: absolute;
577
+ display: flex;
578
+ top: 0;
579
+ left: 0;
580
+ align-items: center;
581
+ flex-direction: column;
582
+ opacity: 0;
583
+ // Always on top
584
+ z-index: 2147483647;
585
+ pointer-events: none;
586
+ border: 3px solid var(--colors-light-1000);
587
+ background: var(--colors-dark-1000);
588
+ border-radius: var(--radii-medium);
589
+ transition: opacity 150ms ease-out;
590
+ }
591
+
592
+ .preview-canvas {
593
+ width: 100%;
594
+ height: 100%;
595
+ border-radius: var(--radii-small);
596
+ }
597
+
598
+ .preview-text {
599
+ position: absolute;
600
+ bottom: 0;
601
+ transform: translate3d(0, calc(100% + 5px), 0);
602
+ color: var(--colors-light-1000);
603
+ }
604
+ `],Yi([It({type:String})],rs.prototype,"src",2),Yi([It({type:Object})],rs.prototype,"data",2),Yi([It({type:Object})],rs.prototype,"template",2),Yi([It({type:Boolean})],rs.prototype,"disabled",2),Yi([It({type:Number})],rs.prototype,"aspectRatio",2),Yi([It({attribute:!1})],rs.prototype,"compilation",2),rs=Yi([Oi("vmp-new-video-preview-content")],rs);let Rs=class extends Re{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=Pl}render(){return ie`
605
+ <vmp-new-video-preview-content
606
+ ?disabled=${this.disabled}
607
+ .src=${this.src}
608
+ .data=${this.data}
609
+ .template=${this.template}
610
+ .aspectRatio=${this.aspectRatio}
611
+ .compilation=${this.compilation}
612
+ ></vmp-new-video-preview-content>
613
+ `}};Yi([It({type:String})],Rs.prototype,"src",2),Yi([It({type:Object})],Rs.prototype,"data",2),Yi([It({type:Object})],Rs.prototype,"template",2),Yi([It({type:Boolean})],Rs.prototype,"disabled",2),Yi([It({type:Number})],Rs.prototype,"aspectRatio",2),Yi([It({attribute:!1})],Rs.prototype,"compilation",2),Rs=Yi([Oi("vmp-new-video-preview")],Rs);class J4 extends na{constructor(t){if(super(t),t.type!==bn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}update(t,[e]){return e==null||e(t.element),ms}}const Kf=An(J4);class tA{constructor(t){this.hiddenControls=[],this._measureRef=wi(),this._prevControlsWidth=0,this._hideables={},this._showables={},this._onResize=e=>{var i,s,o;const c=this._measureRef.value,d=(o=(s=(i=e==null?void 0:e[0])==null?void 0:i.borderBoxSize)==null?void 0:s[0])==null?void 0:o.inlineSize;if(c&&d&&d!==this._prevControlsWidth){Object.keys(this._hideables).forEach(p=>{this._hideables[p].element.style.display=""}),Object.keys(this._showables).forEach(p=>{this._showables[p].element.style.display="none"});const f=[];for(;c.scrollWidth>c.offsetWidth;){const p=Object.keys(this._hideables).find(g=>this._hideables[g].hideIndex===f.length);if(p){const g=this._hideables[p].element;g&&(g.style.display="none"),f.push(p)}Object.keys(this._showables).forEach(g=>{this._showables[g].showOn.some(v=>f.includes(v))&&(this._showables[g].element.style.display="flex")})}this.hiddenControls=f,this._prevControlsWidth=d,this.host.requestUpdate()}},this.host=t}measure(){return Si(this._measureRef)}contain(){return Bo(this._onResize)}hide(t,e){return Kf(i=>{this._hideables[t]={element:i,hideIndex:e}})}show(t,e){return Kf(i=>{this._showables[t]={element:i,showOn:e}})}}const sh=`.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)}
614
+ `;var eA=Object.defineProperty,iA=Object.getOwnPropertyDescriptor,Ia=(n,t,e,i)=>{for(var s=i>1?void 0:i?iA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&eA(t,e,s),s};let hn=class extends Re{constructor(){super(...arguments),this.semibold=!1,this.truncate=!1,this.size="medium",this.content=""}render(){return ie`
544
615
  <div
545
616
  part="content"
546
- class=${wt({semibold:this.semibold,truncate:this.truncate,[this.size]:!0})}
617
+ class=${Ke({semibold:this.semibold,truncate:this.truncate,[this.size]:!0})}
618
+ style=${Wl({fontFamily:to({text:this.content,font:"var(--fontFamilies-sans)"})})}
547
619
  >
548
620
  ${this.content}
549
621
  </div>
550
- `}};di.styles=[yt.styles??[],jt`
622
+ `}};hn.styles=[Re.styles??[],Ti`
551
623
  :host {
552
624
  --text-size: var(--fontSizes-medium);
553
625
  --text-line-height: var(--lineHeights-medium);
@@ -555,7 +627,6 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
555
627
  }
556
628
 
557
629
  div {
558
- font-family: var(--fontFamilies-sans);
559
630
  font-size: var(--text-size);
560
631
  line-height: var(--text-line-height);
561
632
  font-weight: var(--text-weight);
@@ -585,11 +656,11 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
585
656
  text-overflow: ellipsis;
586
657
  overflow: hidden;
587
658
  }
588
- `],bs([j({type:Boolean})],di.prototype,"semibold",2),bs([j({type:Boolean})],di.prototype,"truncate",2),bs([j({type:String})],di.prototype,"size",2),bs([j({type:String})],di.prototype,"content",2),di=bs([se("vmp-new-text")],di);var r0=Object.defineProperty,n0=Object.getOwnPropertyDescriptor,Ts=(r,t,e,i)=>{for(var s=i>1?void 0:i?n0(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 ui=class extends yt{constructor(){super(...arguments),this.activeItems=[],this.visibleItems=null,this.subItemsActive=null,this.tippy=null,this._contentRef=be()}_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=ai(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 st`
659
+ `],Ia([It({type:Boolean})],hn.prototype,"semibold",2),Ia([It({type:Boolean})],hn.prototype,"truncate",2),Ia([It({type:String})],hn.prototype,"size",2),Ia([It({type:String})],hn.prototype,"content",2),hn=Ia([Oi("vmp-new-text")],hn);var rA=Object.defineProperty,sA=Object.getOwnPropertyDescriptor,xa=(n,t,e,i)=>{for(var s=i>1?void 0:i?sA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&rA(t,e,s),s};let dn=class extends Re{constructor(){super(...arguments),this.activeItems=[],this.visibleItems=null,this.subItemsActive=null,this.tippy=null,this._contentRef=wi()}_handleBackClick(){this.subItemsActive=null,this.visibleItems=this.items??null}willUpdate(){this.visibleItems=this.visibleItems??this.items??null}updated(){var n,t;const e=(t=(n=this.items)==null?void 0:n.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 n;const t=(n=this.shadowRoot)==null?void 0:n.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=nn(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 n;super.disconnectedCallback(),(n=this.tippy)==null||n.destroy()}render(){var n,t;return ie`
589
660
  <slot></slot>
590
- <div ${Te(this._contentRef)} class="content">
661
+ <div ${Si(this._contentRef)} class="content">
591
662
  <div class="title">
592
- ${this.subItemsActive?st`
663
+ ${this.subItemsActive?ie`
593
664
  <button class="back" @click=${this._handleBackClick}>
594
665
  <vmp-new-icon icon="chevron-down"></vmp-new-icon>
595
666
  </button>
@@ -598,20 +669,20 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
598
669
  ?bold=${!0}
599
670
  ?truncate=${!0}
600
671
  size="small"
601
- .content=${((r=this.visibleItems)==null?void 0:r.title)??"Sub Menu"}
672
+ .content=${((n=this.visibleItems)==null?void 0:n.title)??"Sub Menu"}
602
673
  ></vmp-new-text>
603
674
  </div>
604
- ${Uo(((t=this.visibleItems)==null?void 0:t.items)??[],({id:e})=>e,e=>st`
675
+ ${lu(((t=this.visibleItems)==null?void 0:t.items)??[],({id:e})=>e,e=>ie`
605
676
  <button
606
677
  class="item"
607
678
  @click=${()=>{e.subItems&&(this.subItemsActive=e.id,this.visibleItems=e.subItems),e.event&&this.dispatchEvent(new CustomEvent(e.event,{detail:e,bubbles:!0,composed:!0}))}}
608
679
  >
609
680
  <vmp-new-text ?semibold=${!0} size="small" content=${e.label}></vmp-new-text>
610
- ${e.subItems?st`<vmp-new-icon class="forward" icon="chevron-down"></vmp-new-icon>`:this.activeItems.includes(e.id)?st`<vmp-new-icon icon="tick"></vmp-new-icon>`:null}
681
+ ${e.subItems?ie`<vmp-new-icon class="forward" icon="chevron-down"></vmp-new-icon>`:this.activeItems.includes(e.id)?ie`<vmp-new-icon icon="tick"></vmp-new-icon>`:null}
611
682
  </button>
612
683
  `)}
613
684
  </div>
614
- `}};ui.styles=[yt.styles??[],Ui(ya),jt`
685
+ `}};dn.styles=[Re.styles??[],qn(sh),Ti`
615
686
  :host {
616
687
  display: flex;
617
688
  }
@@ -669,12 +740,12 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
669
740
  height: 20px;
670
741
  width: 20px;
671
742
  }
672
- `],Ts([j({type:Object})],ui.prototype,"items",2),Ts([j({type:Array})],ui.prototype,"activeItems",2),Ts([Wt()],ui.prototype,"visibleItems",2),Ts([Wt()],ui.prototype,"subItemsActive",2),ui=Ts([se("vmp-new-menu")],ui);var a0=Object.defineProperty,o0=Object.getOwnPropertyDescriptor,Ea=(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&&a0(t,e,s),s};let As=class extends yt{constructor(){super(...arguments),this.content="",this.disabled=!1,this.tippy=null,this._contentRef=be()}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=ai(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 st`
743
+ `],xa([It({type:Object})],dn.prototype,"items",2),xa([It({type:Array})],dn.prototype,"activeItems",2),xa([ki()],dn.prototype,"visibleItems",2),xa([ki()],dn.prototype,"subItemsActive",2),dn=xa([Oi("vmp-new-menu")],dn);var nA=Object.defineProperty,aA=Object.getOwnPropertyDescriptor,nh=(n,t,e,i)=>{for(var s=i>1?void 0:i?aA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&nA(t,e,s),s};let Da=class extends Re{constructor(){super(...arguments),this.content="",this.disabled=!1,this.tippy=null,this._contentRef=wi()}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var n;const t=(n=this.shadowRoot)==null?void 0:n.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=nn(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!1,placement:"top",zIndex:1e4,appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var n;super.disconnectedCallback(),(n=this.tippy)==null||n.destroy()}updated(){var n,t;this.disabled?(n=this.tippy)==null||n.disable():(t=this.tippy)==null||t.enable()}render(){return ie`
673
744
  <slot></slot>
674
- <div ${Te(this._contentRef)} class="content">
745
+ <div ${Si(this._contentRef)} class="content">
675
746
  <vmp-new-text content=${this.content}></vmp-new-text>
676
747
  </div>
677
- `}};As.styles=[yt.styles??[],Ui(ya),jt`
748
+ `}};Da.styles=[Re.styles??[],qn(sh),Ti`
678
749
  :host {
679
750
  display: flex;
680
751
  }
@@ -688,19 +759,19 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
688
759
  background: var(--colors-dark-800);
689
760
  border-radius: var(--radii-medium);
690
761
  }
691
- `],Ea([j({type:String})],As.prototype,"content",2),Ea([j({type:Boolean})],As.prototype,"disabled",2),As=Ea([se("vmp-new-tooltip")],As);var l0=Object.defineProperty,h0=Object.getOwnPropertyDescriptor,ba=(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&&l0(t,e,s),s};let ws=class extends yt{constructor(){super(...arguments),this.volume=1,this.muted=!1,this.tippy=null,this._contentRef=be(),this._anchorRef=be(),this._menuOpen=!1}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{this._anchorRef.value&&this._contentRef.value&&(this.tippy=ai(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 st`
762
+ `],nh([It({type:String})],Da.prototype,"content",2),nh([It({type:Boolean})],Da.prototype,"disabled",2),Da=nh([Oi("vmp-new-tooltip")],Da);var oA=Object.defineProperty,lA=Object.getOwnPropertyDescriptor,ah=(n,t,e,i)=>{for(var s=i>1?void 0:i?lA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&oA(t,e,s),s};let Pa=class extends Re{constructor(){super(...arguments),this.volume=1,this.muted=!1,this.tippy=null,this._contentRef=wi(),this._anchorRef=wi(),this._menuOpen=!1}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{this._anchorRef.value&&this._contentRef.value&&(this.tippy=nn(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 n;super.disconnectedCallback(),(n=this.tippy)==null||n.destroy()}render(){return ie`
692
763
  <vmp-new-icon-button
693
- ${Te(this._anchorRef)}
764
+ ${Si(this._anchorRef)}
694
765
  icon=${this.muted||this.volume===0?"muted":this.volume<1/3?"volume-low":this.volume<2/3?"volume-medium":"volume-high"}
695
766
  weight="heavy"
696
767
  rounded="full"
697
- @pointerdown=${r=>{this._menuOpen&&r.preventDefault()}}
768
+ @pointerdown=${n=>{this._menuOpen&&n.preventDefault()}}
698
769
  @click=${()=>{this._menuOpen&&this.dispatchEvent(new CustomEvent("volume:click",{bubbles:!0,composed:!0,detail:this.muted}))}}
699
770
  ></vmp-new-icon-button>
700
- <div ${Te(this._contentRef)} class="content">
771
+ <div ${Si(this._contentRef)} class="content">
701
772
  <input key="volume" type="range" min="0" max="1" step="0.01" .value=${this.volume.toString()} />
702
773
  </div>
703
- `}};ws.styles=[yt.styles??[],Ui(ya),jt`
774
+ `}};Pa.styles=[Re.styles??[],qn(sh),Ti`
704
775
  .content {
705
776
  --volume-slider-height: 4px;
706
777
  --volume-slider-width: 78px;
@@ -828,8 +899,15 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
828
899
  --volume-slider-height: 8px;
829
900
  color: var(--colors-light-800);
830
901
  }
831
- `],ba([j({type:Number})],ws.prototype,"volume",2),ba([j({type:Boolean})],ws.prototype,"muted",2),ws=ba([se("vmp-new-volume-button")],ws);var c0=Object.defineProperty,d0=Object.getOwnPropertyDescriptor,Tr=(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&&c0(t,e,s),s};let Oi=class extends yt{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 st`
832
- <div class="container">
902
+ `],ah([It({type:Number})],Pa.prototype,"volume",2),ah([It({type:Boolean})],Pa.prototype,"muted",2),Pa=ah([Oi("vmp-new-volume-button")],Pa);var cA=Object.defineProperty,hA=Object.getOwnPropertyDescriptor,Ho=(n,t,e,i)=>{for(var s=i>1?void 0:i?hA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&cA(t,e,s),s};let On=class extends Re{constructor(){super(...arguments),this.duration=0,this.currentTime=0,this.buffer=[],this._containerRef=wi(),this._handleContainerResize=()=>{var n;const t=(n=this._containerRef.value)==null?void 0:n.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:resize",{detail:t,bubbles:!0,composed:!0}))},this._handleMouseEnter=n=>{var t;const e=(t=this._containerRef.value)==null?void 0:t.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:mouseenter",{detail:{x:n.clientX,y:n.clientY,elementLeft:(e==null?void 0:e.left)??0,elementRight:(e==null?void 0:e.right)??document.body.offsetWidth},bubbles:!0,composed:!0}))},this._handleMouseMove=n=>{var t;const e=(t=this._containerRef.value)==null?void 0:t.getBoundingClientRect(),i=(n.clientX-((e==null?void 0:e.left)??0))/((e==null?void 0:e.width)??1);this.dispatchEvent(new CustomEvent("scrubber:mousemove",{detail:{x:n.clientX,y:n.clientY,time:i*this.duration,elementLeft:(e==null?void 0:e.left)??0,elementRight:(e==null?void 0:e.right)??document.body.offsetWidth},bubbles:!0,composed:!0}))},this._handleMouseLeave=n=>{this.dispatchEvent(new CustomEvent("scrubber:mouseleave",{detail:{x:n.clientX,y:n.clientY},bubbles:!0,composed:!0}))}}render(){var n;const t=((n=this.buffer)==null?void 0:n.sort((e,i)=>e.start<i.start?-1:i.start<e.start?1:0).reduce((e,{start:i,end:s},o)=>{const c=e[o-1],d=Math.floor(i),f=Math.ceil(s);return e.push({id:i,start:Math.max(0,d),end:Math.min(f,100)}),c&&c.end>=i-1&&(e[o].start=c.end),e},[]))??[];return ie`
903
+ <div
904
+ class="container"
905
+ ${Si(this._containerRef)}
906
+ ${Bo(this._handleContainerResize)}
907
+ @mouseenter=${this._handleMouseEnter}
908
+ @mousemove=${this._handleMouseMove}
909
+ @mouseleave=${this._handleMouseLeave}
910
+ >
833
911
  <input
834
912
  key="scrubber"
835
913
  aria-label="Progress scrubber"
@@ -840,11 +918,11 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
840
918
  .value=${this.currentTime.toString()}
841
919
  data-testid="scrubber"
842
920
  />
843
- ${Uo(t,({id:e})=>e,e=>st`
921
+ ${lu(t,({id:e})=>e,e=>ie`
844
922
  <div class="buffer" style=${`left: ${e.start}%; width: ${e.end-e.start}%`}></div>
845
923
  `)}
846
924
  </div>
847
- `}};Oi.styles=[yt.styles??[],jt`
925
+ `}};On.styles=[Re.styles??[],Ti`
848
926
  :host {
849
927
  --player-scrubber-height: 8px;
850
928
  --player-scrubber-shadow-width: 4000px;
@@ -977,17 +1055,17 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
977
1055
  --player-scrubber-height: 16px;
978
1056
  color: var(--colors-light-800);
979
1057
  }
980
- `],Tr([j({type:Number})],Oi.prototype,"duration",2),Tr([j({type:Number})],Oi.prototype,"currentTime",2),Tr([j({type:Array})],Oi.prototype,"buffer",2),Oi=Tr([se("vmp-new-progress-scrubber")],Oi);var u0=Object.defineProperty,f0=Object.getOwnPropertyDescriptor,Bt=(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&&u0(t,e,s),s};let Pt=class extends yt{constructor(){super(...arguments),this.resizeHider=new zv(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=ma,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-new-menu, vmp-new-tooltip, vmp-new-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,c,d,u;const f=((r=this.levels)==null?void 0:r.map((w,P)=>{const H=Math.min(w.width,w.height);return{id:`level-${P.toString()}`,event:"level:click",label:`${H}p`,value:{resolution:H,level:P}}}))??[],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},v=(t=p.items)==null?void 0:t.find(({value:w})=>w.level===this.level),E=["levels","playback-rate","captions","fullscreen"].filter(w=>{var P;return(P=this.controls)==null?void 0:P.includes(w)}),A={title:"Settings",items:[Uv,Bv,g,Hv].filter(({id:w})=>E.includes(w)&&this.resizeHider.hiddenControls.includes(w))},L=(e=this.controls)==null?void 0:e.includes("progress"),y=(i=this.controls)==null?void 0:i.includes("navigation"),S=(s=this.controls)==null?void 0:s.includes("play"),R=(n=this.controls)==null?void 0:n.includes("volume"),D=(a=this.controls)==null?void 0:a.includes("current-time"),M=(o=this.controls)==null?void 0:o.includes("duration"),C=(l=this.controls)==null?void 0:l.includes("levels"),I=(h=this.controls)==null?void 0:h.includes("speed"),G=(c=this.controls)==null?void 0:c.includes("captions"),F=(d=this.controls)==null?void 0:d.includes("fullscreen"),V=S||R||D||M||C||I||G||F,q=[`level-${(u=this.level)==null?void 0:u.toString()}`,`playback-rate-${this.playbackRate.toString()}`,this.captions&&"captions",this.fullscreen&&"fullscreen"].filter(Boolean);return st`
1058
+ `],Ho([It({type:Number})],On.prototype,"duration",2),Ho([It({type:Number})],On.prototype,"currentTime",2),Ho([It({type:Array})],On.prototype,"buffer",2),On=Ho([Oi("vmp-new-progress-scrubber")],On);var dA=Object.defineProperty,uA=Object.getOwnPropertyDescriptor,Ai=(n,t,e,i)=>{for(var s=i>1?void 0:i?uA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&dA(t,e,s),s};let oi=class extends Re{constructor(){super(...arguments),this.resizeHider=new tA(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=ih,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:n}){this.volumeMenuOpen=n}_handleLevelsMenuOpen({detail:n}){this.levelsMenuOpen=n}_handlePlaybackMenuToggle({detail:n}){this.playbackRateMenuOpen=n}_handleSettingsMenuToggle({detail:n}){this.settingsMenuOpen=n}hideMenus(){var n,t;(t=Array.from((n=this.shadowRoot)==null?void 0:n.querySelectorAll("vmp-new-menu, vmp-new-tooltip, vmp-new-volume-button")))==null||t.forEach(e=>{var i;(i=e.tippy)==null||i.hide()})}render(){var n,t,e,i,s,o,c,d,f,p,g,v,b;const E=((n=this.levels)==null?void 0:n.map((H,J)=>{const St=Math.min(H.width,H.height);return{id:`level-${J.toString()}`,event:"level:click",label:`${St}p`,value:{resolution:St,level:J}}}))??[],T={title:"Quality",items:[...E.reverse(),{id:"level--1",event:"level:click",label:"Auto",value:{level:-1,resolution:"auto"}}]},w={id:"levels",label:"Quality",subItems:T},_=(t=T.items)==null?void 0:t.find(({value:H})=>H.level===this.level),D=["levels","playback-rate","captions","fullscreen"].filter(H=>{var J;return(J=this.controls)==null?void 0:J.includes(H)}),M={title:"Settings",items:[x4,D4,w,P4].filter(({id:H})=>D.includes(H)&&this.resizeHider.hiddenControls.includes(H))},F=(e=this.controls)==null?void 0:e.includes("progress"),x=(i=this.controls)==null?void 0:i.includes("navigation"),N=(s=this.controls)==null?void 0:s.includes("play"),V=(o=this.controls)==null?void 0:o.includes("volume"),j=(c=this.controls)==null?void 0:c.includes("current-time"),rt=(d=this.controls)==null?void 0:d.includes("duration"),nt=(f=this.controls)==null?void 0:f.includes("levels"),Q=(p=this.controls)==null?void 0:p.includes("speed"),Tt=(g=this.controls)==null?void 0:g.includes("captions"),gt=(v=this.controls)==null?void 0:v.includes("fullscreen"),$t=N||V||j||rt||nt||Q||Tt||gt,Wt=[`level-${(b=this.level)==null?void 0:b.toString()}`,`playback-rate-${this.playbackRate.toString()}`,this.captions&&"captions",this.fullscreen&&"fullscreen"].filter(Boolean);return ie`
981
1059
  <div
982
1060
  ${this.resizeHider.measure()}
983
1061
  ${this.resizeHider.contain()}
984
- class=${wt({container:!0,hidden:!L&&!V})}
1062
+ class=${Ke({container:!0,hidden:!F&&!$t})}
985
1063
  >
986
1064
  <div
987
- class=${wt({"scrubber-container":!0,hidden:!L})}
1065
+ class=${Ke({"scrubber-container":!0,hidden:!F})}
988
1066
  >
989
1067
  <vmp-new-progress-scrubber
990
- class=${wt({scrubber:!0,invisible:this.volumeMenuOpen||this.levelsMenuOpen||this.playbackRateMenuOpen||this.settingsMenuOpen})}
1068
+ class=${Ke({scrubber:!0,invisible:this.volumeMenuOpen||this.levelsMenuOpen||this.playbackRateMenuOpen||this.settingsMenuOpen})}
991
1069
  duration=${this.duration}
992
1070
  currentTime=${this.currentTime}
993
1071
  .buffer=${this.buffer}
@@ -995,12 +1073,12 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
995
1073
  </div>
996
1074
  <div
997
1075
  ${this.resizeHider.contain()}
998
- class=${wt({buttons:!0,hidden:!V})}
1076
+ class=${Ke({buttons:!0,hidden:!$t})}
999
1077
  >
1000
1078
  <div class="section">
1001
1079
  <div
1002
1080
  ${this.resizeHider.hide("navigation",6)}
1003
- class=${wt({navigation:!0,hidden:!y})}
1081
+ class=${Ke({navigation:!0,hidden:!x})}
1004
1082
  >
1005
1083
  <vmp-new-icon-button
1006
1084
  icon="arrow-left"
@@ -1016,7 +1094,7 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
1016
1094
  ></vmp-new-icon-button>
1017
1095
  </div>
1018
1096
  <vmp-new-icon-button
1019
- class=${wt({hidden:!S})}
1097
+ class=${Ke({hidden:!N})}
1020
1098
  icon=${this.playing?"pause":"play"}
1021
1099
  weight="heavy"
1022
1100
  rounded="full"
@@ -1024,7 +1102,7 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
1024
1102
  @click=${this._handlePlayClick}
1025
1103
  ></vmp-new-icon-button>
1026
1104
  <vmp-new-volume-button
1027
- class=${wt({hidden:!R})}
1105
+ class=${Ke({hidden:!V})}
1028
1106
  ?muted=${this.muted}
1029
1107
  volume=${this.volume}
1030
1108
  @menu:toggle=${this._handleVolumeMenuToggle}
@@ -1032,37 +1110,37 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
1032
1110
  <div class="time">
1033
1111
  <vmp-new-text
1034
1112
  ${this.resizeHider.hide("current-time",1)}
1035
- class=${wt({hidden:!D})}
1113
+ class=${Ke({hidden:!j})}
1036
1114
  ?semibold=${!0}
1037
- content="${vc(this.currentTime)}${M?"/":null}"
1115
+ content="${rh(this.currentTime)}${rt?"/":null}"
1038
1116
  ></vmp-new-text>
1039
1117
  <vmp-new-text
1040
1118
  ${this.resizeHider.hide("duration",5)}
1041
- class=${wt({hidden:!M})}
1119
+ class=${Ke({hidden:!rt})}
1042
1120
  ?semibold=${!0}
1043
- content=${vc(this.duration)}
1121
+ content=${rh(this.duration)}
1044
1122
  ></vmp-new-text>
1045
1123
  </div>
1046
1124
  </div>
1047
1125
  <div class="section">
1048
1126
  <vmp-new-menu
1049
1127
  ${this.resizeHider.hide("levels",0)}
1050
- class=${wt({hidden:!C||f.length<=0})}
1051
- .items=${p}
1052
- .activeItems=${q}
1128
+ class=${Ke({hidden:!nt||E.length<=0})}
1129
+ .items=${T}
1130
+ .activeItems=${Wt}
1053
1131
  @menu:toggle=${this._handleLevelsMenuOpen}
1054
1132
  >
1055
1133
  <vmp-new-tooltip content="Quality" ?disabled=${this.levelsMenuOpen}>
1056
1134
  <vmp-new-button ?active=${this.levelsMenuOpen} icon="chevron-down"
1057
- >${v==null?void 0:v.label}</vmp-new-button
1135
+ >${_==null?void 0:_.label}</vmp-new-button
1058
1136
  >
1059
1137
  </vmp-new-tooltip>
1060
1138
  </vmp-new-menu>
1061
1139
  <vmp-new-menu
1062
1140
  ${this.resizeHider.hide("playback-rate",4)}
1063
- class=${wt({hidden:!I})}
1064
- .items=${pc}
1065
- .activeItems=${q}
1141
+ class=${Ke({hidden:!Q})}
1142
+ .items=${Bf}
1143
+ .activeItems=${Wt}
1066
1144
  @menu:toggle=${this._handlePlaybackMenuToggle}
1067
1145
  >
1068
1146
  <vmp-new-tooltip content="Playback speed" ?disabled=${this.playbackRateMenuOpen}>
@@ -1073,7 +1151,7 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
1073
1151
  </vmp-new-menu>
1074
1152
  <vmp-new-tooltip
1075
1153
  ${this.resizeHider.hide("captions",3)}
1076
- class=${wt({hidden:!G})}
1154
+ class=${Ke({hidden:!Tt})}
1077
1155
  content="Captions"
1078
1156
  >
1079
1157
  <vmp-new-icon-button
@@ -1086,7 +1164,7 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
1086
1164
  <vmp-new-tooltip
1087
1165
  ${this.resizeHider.hide("fullscreen",2)}
1088
1166
  content="Fullscreen"
1089
- class=${wt({hidden:!F})}
1167
+ class=${Ke({hidden:!gt})}
1090
1168
  >
1091
1169
  <vmp-new-icon-button
1092
1170
  ?active=${this.fullscreen}
@@ -1098,8 +1176,8 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
1098
1176
  </vmp-new-tooltip>
1099
1177
  <vmp-new-menu
1100
1178
  ${this.resizeHider.show("settings",["levels","playback-rate","captions","fullscreen"])}
1101
- .items=${A}
1102
- .activeItems=${q}
1179
+ .items=${M}
1180
+ .activeItems=${Wt}
1103
1181
  @menu:toggle=${this._handleSettingsMenuToggle}
1104
1182
  >
1105
1183
  <vmp-new-tooltip content="Settings" ?disabled=${this.settingsMenuOpen}>
@@ -1113,7 +1191,7 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
1113
1191
  </div>
1114
1192
  </div>
1115
1193
  </div>
1116
- `}};Pt.styles=[yt.styles??[],jt`
1194
+ `}};oi.styles=[Re.styles??[],Ti`
1117
1195
  :host {
1118
1196
  --controls-border-radius: var(--player-border-radius, 0px);
1119
1197
 
@@ -1184,17 +1262,17 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
1184
1262
  .hidden {
1185
1263
  display: none;
1186
1264
  }
1187
- `],Bt([j({type:Boolean})],Pt.prototype,"playing",2),Bt([j({type:Number})],Pt.prototype,"volume",2),Bt([j({type:Boolean})],Pt.prototype,"muted",2),Bt([j({type:Number})],Pt.prototype,"currentTime",2),Bt([j({type:Number})],Pt.prototype,"duration",2),Bt([j({type:Number})],Pt.prototype,"level",2),Bt([j({type:Number})],Pt.prototype,"playbackRate",2),Bt([j({type:Array})],Pt.prototype,"buffer",2),Bt([j({type:Array,attribute:!1})],Pt.prototype,"levels",2),Bt([j({type:Boolean})],Pt.prototype,"captions",2),Bt([j({type:Boolean})],Pt.prototype,"fullscreen",2),Bt([j({type:Array})],Pt.prototype,"controls",2),Bt([Wt()],Pt.prototype,"volumeMenuOpen",2),Bt([Wt()],Pt.prototype,"levelsMenuOpen",2),Bt([Wt()],Pt.prototype,"playbackRateMenuOpen",2),Bt([Wt()],Pt.prototype,"settingsMenuOpen",2),Pt=Bt([se("vmp-new-player-controls")],Pt);var p0=Object.defineProperty,g0=Object.getOwnPropertyDescriptor,m0=(r,t,e,i)=>{for(var s=i>1?void 0:i?g0(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 Ta=class extends yt{render(){return st`<vmp-new-icon icon="loading"></vmp-new-icon>`}};Ta.styles=[yt.styles??[],jt`
1265
+ `],Ai([It({type:Boolean})],oi.prototype,"playing",2),Ai([It({type:Number})],oi.prototype,"volume",2),Ai([It({type:Boolean})],oi.prototype,"muted",2),Ai([It({type:Number})],oi.prototype,"currentTime",2),Ai([It({type:Number})],oi.prototype,"duration",2),Ai([It({type:Number})],oi.prototype,"level",2),Ai([It({type:Number})],oi.prototype,"playbackRate",2),Ai([It({type:Array})],oi.prototype,"buffer",2),Ai([It({type:Array,attribute:!1})],oi.prototype,"levels",2),Ai([It({type:Boolean})],oi.prototype,"captions",2),Ai([It({type:Boolean})],oi.prototype,"fullscreen",2),Ai([It({type:Array})],oi.prototype,"controls",2),Ai([ki()],oi.prototype,"volumeMenuOpen",2),Ai([ki()],oi.prototype,"levelsMenuOpen",2),Ai([ki()],oi.prototype,"playbackRateMenuOpen",2),Ai([ki()],oi.prototype,"settingsMenuOpen",2),oi=Ai([Oi("vmp-new-player-controls")],oi);var fA=Object.defineProperty,pA=Object.getOwnPropertyDescriptor,gA=(n,t,e,i)=>{for(var s=i>1?void 0:i?pA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&fA(t,e,s),s};let oh=class extends Re{render(){return ie`<vmp-new-icon icon="loading"></vmp-new-icon>`}};oh.styles=[Re.styles??[],Ti`
1188
1266
  :host {
1189
1267
  display: flex;
1190
1268
  align-items: center;
1191
1269
  justify-content: center;
1192
1270
  }
1193
- `],Ta=m0([se("vmp-new-loading-spinner")],Ta);var v0=Object.defineProperty,y0=Object.getOwnPropertyDescriptor,bc=(r,t,e,i)=>{for(var s=i>1?void 0:i?y0(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&&v0(t,e,s),s};let Ar=class extends yt{constructor(){super(...arguments),this.caption=""}render(){return st`
1271
+ `],oh=gA([Oi("vmp-new-loading-spinner")],oh);var mA=Object.defineProperty,vA=Object.getOwnPropertyDescriptor,Yf=(n,t,e,i)=>{for(var s=i>1?void 0:i?vA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&mA(t,e,s),s};let Vo=class extends Re{constructor(){super(...arguments),this.caption=""}render(){return ie`
1194
1272
  <div class="container">
1195
1273
  <vmp-new-text content=${this.caption} size="large"></vmp-new-text>
1196
1274
  </div>
1197
- `}};Ar.styles=[yt.styles??[],jt`
1275
+ `}};Vo.styles=[Re.styles??[],Ti`
1198
1276
  .container {
1199
1277
  display: block;
1200
1278
  margin: 0 var(--space-small);
@@ -1213,37 +1291,37 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
1213
1291
  /* Line height controls the spacing between the cloned boxes so has to override the default */
1214
1292
  line-height: 2.2;
1215
1293
  }
1216
- `],bc([j({type:String})],Ar.prototype,"caption",2),Ar=bc([se("vmp-new-captions")],Ar);var E0=Object.defineProperty,b0=Object.getOwnPropertyDescriptor,Kt=(r,t,e,i)=>{for(var s=i>1?void 0:i?b0(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&&E0(t,e,s),s};const T0=3e3;let Mt=class extends yt{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=ma,this.showControls=!0,this._hasTouched=!1,this._playerControlsRef=be()}_startHideControls(){clearTimeout(this._controlHideTimeout),this._controlHideTimeout=setTimeout(()=>{this.showControls=!1,this._hasTouched=!1},T0)}_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 st`
1294
+ `],Yf([It({type:String})],Vo.prototype,"caption",2),Vo=Yf([Oi("vmp-new-captions")],Vo);var yA=Object.defineProperty,bA=Object.getOwnPropertyDescriptor,Li=(n,t,e,i)=>{for(var s=i>1?void 0:i?bA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&yA(t,e,s),s};const AA=3e3;let fi=class extends Re{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=ih,this.showControls=!0,this._hasTouched=!1,this._playerControlsRef=wi()}_startHideControls(){clearTimeout(this._controlHideTimeout),this._controlHideTimeout=setTimeout(()=>{this.showControls=!1,this._hasTouched=!1},AA)}_immediateShowControls(){this.showControls=!0,clearTimeout(this._controlHideTimeout)}_immediateHideControls(){this.showControls=!1,this._hasTouched=!1,clearTimeout(this._controlHideTimeout)}willUpdate(n){var t;n.has("playing")&&this.playing&&this._startHideControls(),n.has("showControls")&&this.playing&&!this.showControls&&((t=this._playerControlsRef.value)==null||t.hideMenus())}render(){var n;const t=(n=this.controls)==null?void 0:n.includes("play-large"),e=this.playing&&!this.showControls,i=!!(t&&!this.playing);return ie`
1217
1295
  <div
1218
- class=${wt({container:!0,hide:e})}
1296
+ class=${Ke({container:!0,hide:e})}
1219
1297
  @mousemove=${()=>{this._immediateShowControls(),this._startHideControls()}}
1220
1298
  @mouseleave=${this._immediateHideControls}
1221
1299
  @touchstart=${s=>{this.playing&&!this.showControls&&!this._hasTouched&&(s.preventDefault(),this._hasTouched=!0,this._immediateShowControls(),this._startHideControls())}}
1222
1300
  >
1223
1301
  <div
1224
- class=${wt({fixtures:!0,invisible:!this.loading&&!i})}
1302
+ class=${Ke({fixtures:!0,invisible:!this.loading&&!i})}
1225
1303
  @click=${()=>{this.showControls&&this.dispatchEvent(new CustomEvent("play:click",{bubbles:!0,composed:!0,detail:this.playing}))}}
1226
1304
  >
1227
1305
  <vmp-new-icon
1228
- class=${wt({hidden:!i})}
1306
+ class=${Ke({hidden:!i})}
1229
1307
  icon="play-large"
1230
1308
  ></vmp-new-icon>
1231
1309
  <vmp-new-loading-spinner
1232
- class=${wt({hidden:!this.loading||i})}
1310
+ class=${Ke({hidden:!this.loading||i})}
1233
1311
  ></vmp-new-loading-spinner>
1234
1312
  </div>
1235
1313
  <div
1236
- class=${wt({controls:!0,hide:e})}
1314
+ class=${Ke({controls:!0,hide:e})}
1237
1315
  @focusin=${this._immediateShowControls}
1238
1316
  @mousemove=${s=>{s.stopPropagation(),this._immediateShowControls()}}
1239
1317
  @click=${this._immediateShowControls}
1240
1318
  >
1241
- ${this.captions?st`<vmp-new-captions
1242
- class=${wt({hidden:!this.caption,hiddenControls:e})}
1319
+ ${this.captions?ie`<vmp-new-captions
1320
+ class=${Ke({hidden:!this.caption,hiddenControls:e})}
1243
1321
  caption=${this.caption}
1244
1322
  ></vmp-new-captions>`:null}
1245
1323
  <vmp-new-player-controls
1246
- ${Te(this._playerControlsRef)}
1324
+ ${Si(this._playerControlsRef)}
1247
1325
  ?playing=${this.playing}
1248
1326
  ?muted=${this.muted}
1249
1327
  volume=${this.volume}
@@ -1259,7 +1337,7 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
1259
1337
  ></vmp-new-player-controls>
1260
1338
  </div>
1261
1339
  </div>
1262
- `}};Mt.styles=[yt.styles??[],jt`
1340
+ `}};fi.styles=[Re.styles??[],Ti`
1263
1341
  :host {
1264
1342
  --overlay-border-radius: var(--player-border-radius, 0px);
1265
1343
  }
@@ -1331,49 +1409,68 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
1331
1409
  vmp-new-captions.hiddenControls {
1332
1410
  transform: translateY(calc(var(--space-small) * -1));
1333
1411
  }
1334
- `],Kt([j({type:Boolean})],Mt.prototype,"loading",2),Kt([j({type:Boolean})],Mt.prototype,"playing",2),Kt([j({type:Number})],Mt.prototype,"volume",2),Kt([j({type:Boolean})],Mt.prototype,"muted",2),Kt([j({type:Number})],Mt.prototype,"currentTime",2),Kt([j({type:Number})],Mt.prototype,"duration",2),Kt([j({type:Array,attribute:!1})],Mt.prototype,"levels",2),Kt([j({type:Number})],Mt.prototype,"level",2),Kt([j({type:Number})],Mt.prototype,"playbackRate",2),Kt([j({type:String})],Mt.prototype,"caption",2),Kt([j({type:Array})],Mt.prototype,"buffer",2),Kt([j({type:Boolean})],Mt.prototype,"captions",2),Kt([j({type:Boolean})],Mt.prototype,"fullscreen",2),Kt([j({type:Array})],Mt.prototype,"controls",2),Kt([Wt()],Mt.prototype,"showControls",2),Mt=Kt([se("vmp-new-player-overlay")],Mt);var A0=Object.defineProperty,w0=Object.getOwnPropertyDescriptor,Ft=(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&&A0(t,e,s),s};let Dt=class extends yt{constructor(){super(...arguments),this.burnCaptions=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=Hd,this._sceneController=new Mv(this),this._drawController=new Jf(this),this._wasPlaying=!1,this._manualMute=this.muted,this._seekerRAF=null,this._lastWaiting=!1,this._lastTimestamp=null,this._lastTimeUpdate=null,this._playerRef=be(),this._canvasRef=be(),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-new-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-new-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-new-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-new-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?Nv():this._playerRef.value&&Fv(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.scenes||this.duration<=0,{height:o,width:l}=bi({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]),c=a?[]:(t=this.controls??ma)==null?void 0:t.filter(p=>!(p==="fullscreen"&&Pv()||p==="navigation"&&(!this.scenes||this.scenes.length<=1))),d=(((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 st`
1412
+ `],Li([It({type:Boolean})],fi.prototype,"loading",2),Li([It({type:Boolean})],fi.prototype,"playing",2),Li([It({type:Number})],fi.prototype,"volume",2),Li([It({type:Boolean})],fi.prototype,"muted",2),Li([It({type:Number})],fi.prototype,"currentTime",2),Li([It({type:Number})],fi.prototype,"duration",2),Li([It({type:Array,attribute:!1})],fi.prototype,"levels",2),Li([It({type:Number})],fi.prototype,"level",2),Li([It({type:Number})],fi.prototype,"playbackRate",2),Li([It({type:String})],fi.prototype,"caption",2),Li([It({type:Array})],fi.prototype,"buffer",2),Li([It({type:Boolean})],fi.prototype,"captions",2),Li([It({type:Boolean})],fi.prototype,"fullscreen",2),Li([It({type:Array})],fi.prototype,"controls",2),Li([ki()],fi.prototype,"showControls",2),fi=Li([Oi("vmp-new-player-overlay")],fi);var EA=Object.defineProperty,TA=Object.getOwnPropertyDescriptor,si=(n,t,e,i)=>{for(var s=i>1?void 0:i?TA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&EA(t,e,s),s};let Ze=class extends Re{constructor(){super(...arguments),this.burnCaptions=!1,this.debug=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=Pl,this._sceneController=new L4(this),this._drawController=new ev(this),this._wasPlaying=!1,this._manualMute=this.muted,this._seekerRAF=null,this._lastWaiting=!1,this._lastTimestamp=null,this._playerRef=wi(),this._canvasRef=wi(),this._aspectRatio=this.propAspectRatio,this._processing=!1,this._waiting=!1,this._errors=[],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=n=>{this.sceneConfig&&this.scenes.length>0&&(this._waiting=this._drawController.activeScenes.some(({video:t})=>{if(t){const{key:e}=t,i=this.videoState[e];return!i||!i.initialised||i.waiting||t.node.readyState<3}}),this.waiting?(this._lastTimestamp=null,this._lastWaiting||this.dispatchEvent(new CustomEvent("waiting"))):this._lastWaiting&&this.dispatchEvent(new CustomEvent("playing")),n-(this._lastTimestamp??0)>1e3/this.sceneConfig.frameRate&&(this._drawController.currentTime=this._drawController.currentTime+(n-(this._lastTimestamp??n))/1e3*this.playbackRate,this._lastTimestamp=n),this._lastWaiting=this._waiting,this._drawController.currentTime>=this.duration&&(this.pause(),this.dispatchEvent(new CustomEvent("ended")))),this.paused||(this._seekerRAF=requestAnimationFrame(this._seeker))},this._handleError=n=>{this._errors=[...this.errors,n.error],n.error.fatal&&this.pause()},this._handleFullscreenChange=()=>{document.fullscreenElement?this._fullscreen=!0:this._fullscreen=!1}}get aspectRatio(){return this._aspectRatio}get processing(){return this._processing}get waiting(){return!this.paused&&this._waiting}get errors(){return this._errors}get seeking(){return this._seeking}get captions(){return this._captions}get fullscreen(){return this._fullscreen}get duration(){return this._sceneController.duration}get scene(){return this._drawController.activeScenes[this._drawController.activeScenes.length-1]}get scenes(){var n;return((n=this._sceneController.scenes)==null?void 0:n.scenes)??[]}get sceneConfig(){return this._sceneController.scenes}get videos(){return this._sceneController.videos??{}}get videoState(){return this._sceneController.videoState}get sceneVideoState(){return this.scenes.reduce((n,{video:t,start:e,duration:i})=>{const s=(t==null?void 0:t.key)??`${e}-${i}`;return n[s]=this.videoState[s],n},{})}set paused(n){n!==this._paused&&(this._paused=n,this.requestUpdate(),this.dispatchEvent(new CustomEvent(n?"pause":"play")))}get paused(){return this._paused}set playbackRate(n){n!==this._playbackRate&&(this._playbackRate=n,this.scenes.forEach(({video:t})=>{t&&(t.node.playbackRate=n)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:n})))}get playbackRate(){return this._playbackRate}set volume(n){const t=Math.min(1,Math.max(0,n));t!==this._volume&&(this.scenes.forEach(({video:e})=>{e&&(e.node.volume=t)}),localStorage.setItem("vmp-new-player-volume",t.toString()),this._volume=t,t>0&&(this.muted=!1),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:n})))}get volume(){return this._volume??(this._volume=parseFloat(localStorage.getItem("vmp-new-player-volume")??"1"))}set muted(n){this.scenes.forEach(({video:t})=>{t&&(t.node.muted=n)}),n!==this._muted&&(this._muted=n,localStorage.setItem("vmp-new-player-muted",n.toString()),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:n?0:this.volume})))}get muted(){return this._muted??(this._muted=this.autoplay||localStorage.getItem("vmp-new-player-muted")==="true")}set videoResolution(n){n!==this._videoResolution&&(this._videoResolution=n,this.scenes.forEach(({video:t})=>{if(t!=null&&t.hls){const e=t.hls.levels.findIndex(i=>Math.min(i.height,i.width)===n);t.hls.currentLevel=e??-1}}),this.requestUpdate())}get videoResolution(){return this._videoResolution}set currentTime(n){n!==this._drawController.currentTime&&(this._drawController.currentTime=n,this._sceneController.setVideosCurrentTime(n))}get currentTime(){return this._drawController.currentTime}reset(n=0,t=!1){this._lastTimestamp=null,this._drawController.currentTime=n,this._sceneController.setVideosCurrentTime(n),t?this.play():this.pause()}clear(){this._drawController.clear()}play(){this.paused=!1,this._lastTimestamp=null,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:n})=>{n&&n.node.pause()})}draw(n){return this._drawController.draw(n)}setScene(n){var t,e;if((t=this._sceneController)!=null&&t.scenes){const i=(e=this.scenes)==null?void 0:e[n];if(!i){const s=new Qr(`No scene at index: ${n}`);return this.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:s,message:s.message}))}this.reset(i.start+this._sceneController.scenes.transitionDuration,!this.paused)}}toggleFullscreen(n){n??this.fullscreen?I4():this._playerRef.value&&C4(this._playerRef.value)}connectedCallback(){super.connectedCallback(),this.addEventListener("error",this._handleError),document.addEventListener("fullscreenchange",this._handleFullscreenChange)}willUpdate(){this.propAspectRatio&&(this._aspectRatio=this.propAspectRatio)}updated(n){n.has("propAspectRatio")&&!this.propAspectRatio&&this._handleContainerResize(),this.autoplay&&!this.processing&&!this._sceneController.hasPlayed&&n.has("_processing")&&this.play()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("fullscreenchange",this._handleFullscreenChange)}_renderError(){return ie`<div class="error">
1413
+ <div class="error-icon">
1414
+ <vmp-new-icon icon="error"></vmp-new-icon>
1415
+ </div>
1416
+ <div class="error-text">
1417
+ <vmp-new-text semibold content="An error has occurred when attempting to play this video."></vmp-new-text>
1418
+ <vmp-new-text semibold content="Please try again later."></vmp-new-text>
1419
+ </div>
1420
+ </div>`}render(){var n,t,e,i,s,o;const c=this.loading||this.processing||!this.scenes||this.duration<=0,{height:d,width:f}=Ol({resolution:((n=this.sceneConfig)==null?void 0:n.resolution)??720,aspectRatio:this.aspectRatio}),p=Object.keys(this.sceneVideoState).reduce((D,M)=>D.concat(this.sceneVideoState[M].buffered??[]),[]),g=c?[]:(t=this.controls??ih)==null?void 0:t.filter(D=>!(D==="fullscreen"&&R4()||D==="navigation"&&(!this.scenes||this.scenes.length<=1))),v=!(g!=null&&g.includes("preview")),b=(((e=this.scenes)==null?void 0:e.length)??0)-1,E=((i=this.scenes)==null?void 0:i.findIndex(D=>D===this._drawController.activeScenes[0]))??0,T=(o=(s=this._drawController.activeScenes[0])==null?void 0:s.video)==null?void 0:o.hls,w=!this.src&&!this.data,_=!!this.errors.find(D=>D.fatal);return ie`
1335
1421
  <div
1336
- ${Te(this._playerRef)}
1337
- ${va(this._handleContainerResize)}
1338
- class=${wt({player:!0,responsive:!this.propAspectRatio})}
1422
+ ${Si(this._playerRef)}
1423
+ ${Bo(this._handleContainerResize)}
1424
+ class=${Ke({player:!0,responsive:!this.propAspectRatio})}
1425
+ style=${Wl({aspectRatio:this.aspectRatio})}
1339
1426
  >
1340
- <canvas
1341
- ${Te(this._canvasRef)}
1342
- ${this._drawController.canvas()}
1343
- ${va(this._handleCanvasResize)}
1344
- height=${o}
1345
- width=${l}
1346
- ></canvas>
1347
- <vmp-new-player-overlay
1348
- ${this._drawController.controls()}
1349
- ?disabled=${a}
1350
- ?playing=${!this.paused}
1351
- ?loading=${this.loading||this.waiting||this.stalled}
1352
- ?muted=${this.muted}
1353
- volume=${this.volume}
1354
- duration=${this.duration}
1355
- .levels=${(f==null?void 0:f.levels)??[]}
1356
- level=${es(f!=null&&f.autoLevelEnabled?-1:f==null?void 0:f.currentLevel)}
1357
- playbackRate=${this.playbackRate}
1358
- caption=${this._drawController.caption}
1359
- .buffer=${h}
1360
- .controls=${c}
1361
- ?captions=${this.captions}
1362
- ?fullscreen=${this.fullscreen}
1363
- @navigate:back=${p=>{p.defaultPrevented||this.setScene(u<=0?d:u-1)}}
1364
- @navigate:forward=${p=>{p.defaultPrevented||this.setScene(u>=d?0:u+1)}}
1365
- @play:click=${({detail:p})=>{a||(p?this.pause():(this.muted=this._manualMute,this.play()))}}
1366
- @volume:click=${({detail:p})=>{this.muted=!p,this._manualMute=!p}}
1367
- @level:click=${({detail:p})=>{this.videoResolution=p.value.resolution}}
1368
- @playbackRate:click=${({detail:p})=>{this.playbackRate=p.value??1}}
1369
- @captions:click=${()=>{this._captions=!this._captions}}
1370
- @fullscreen:click=${()=>{this.toggleFullscreen()}}
1371
- @input=${p=>{const g=p.composedPath()[0],v=g.getAttribute("key");if(v==="scrubber"){const E=parseFloat(g.value);this._drawController.currentTime=E,this._sceneController.setVideosCurrentTime(E),this.dispatchEvent(new CustomEvent("seeking",{detail:E}))}v==="volume"&&(this.volume=parseFloat(g.value))}}
1372
- @pointerdown=${p=>{p.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!0,this._wasPlaying=!this.paused,this.paused||this.pause())}}
1373
- @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})))}}
1374
- ></vmp-new-player-overlay>
1427
+ ${w||_?this._renderError():ie`<canvas
1428
+ ${Si(this._canvasRef)}
1429
+ ${this._drawController.canvas()}
1430
+ ${Bo(this._handleCanvasResize)}
1431
+ height=${d}
1432
+ width=${f}
1433
+ ></canvas>
1434
+ <vmp-new-player-overlay
1435
+ ${this._drawController.controls()}
1436
+ .data=${this.data}
1437
+ .template=${this.template}
1438
+ ?disabled=${c}
1439
+ ?playing=${!this.paused}
1440
+ ?loading=${this.loading||this.waiting||this.processing}
1441
+ ?muted=${this.muted}
1442
+ volume=${this.volume}
1443
+ duration=${this.duration}
1444
+ .levels=${(T==null?void 0:T.levels)??[]}
1445
+ level=${Xs(T!=null&&T.autoLevelEnabled?-1:T==null?void 0:T.currentLevel)}
1446
+ playbackRate=${this.playbackRate}
1447
+ caption=${this._drawController.caption}
1448
+ .buffer=${p}
1449
+ .controls=${g}
1450
+ ?captions=${this.captions}
1451
+ ?fullscreen=${this.fullscreen}
1452
+ @navigate:back=${D=>{D.defaultPrevented||this.setScene(E<=0?b:E-1)}}
1453
+ @navigate:forward=${D=>{D.defaultPrevented||this.setScene(E>=b?0:E+1)}}
1454
+ @play:click=${({detail:D})=>{c||(D?this.pause():(this.muted=this._manualMute,this.play()))}}
1455
+ @volume:click=${({detail:D})=>{this.muted=!D,this._manualMute=!D}}
1456
+ @level:click=${({detail:D})=>{this.videoResolution=D.value.resolution}}
1457
+ @playbackRate:click=${({detail:D})=>{this.playbackRate=D.value??1}}
1458
+ @captions:click=${()=>{this._captions=!this._captions}}
1459
+ @fullscreen:click=${()=>{this.toggleFullscreen()}}
1460
+ @input=${D=>{const M=D.composedPath()[0],F=M.getAttribute("key");if(F==="scrubber"){const x=parseFloat(M.value);this._drawController.currentTime=x,this._sceneController.setVideosCurrentTime(x),this.dispatchEvent(new CustomEvent("seeking",{detail:x}))}F==="volume"&&(this.volume=parseFloat(M.value))}}
1461
+ @pointerdown=${D=>{D.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!0,this._wasPlaying=!this.paused,this.paused||this.pause())}}
1462
+ @pointerup=${D=>{D.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!1,this._wasPlaying&&(this.play(),this._wasPlaying=!1),this.dispatchEvent(new CustomEvent("seeked",{detail:this._drawController.currentTime})))}}
1463
+ ></vmp-new-player-overlay>
1464
+ <vmp-new-video-preview
1465
+ ?disabled=${v}
1466
+ .src=${this.src}
1467
+ .data=${this.data}
1468
+ .template=${this.template}
1469
+ .aspectRatio=${this.aspectRatio}
1470
+ .compilation=${this.compilation}
1471
+ ></vmp-new-video-preview>`}
1375
1472
  </div>
1376
- `}};Dt.styles=[yt.styles??[],jt`
1473
+ `}};Ze.styles=[Re.styles??[],Ti`
1377
1474
  :host {
1378
1475
  --player-border-radius: var(--vouch-media-player-border-radius, 0px);
1379
1476
  }
@@ -1388,8 +1485,28 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
1388
1485
  }
1389
1486
 
1390
1487
  .responsive {
1488
+ width: 100%;
1391
1489
  height: 100%;
1490
+ }
1491
+
1492
+ .error {
1493
+ display: flex;
1494
+ align-items: center;
1495
+ justify-content: center;
1496
+ gap: var(--space-xxs);
1497
+ padding: var(--space-medium);
1392
1498
  width: 100%;
1499
+ height: 100%;
1500
+ color: white;
1501
+ }
1502
+
1503
+ .error-icon {
1504
+ color: var(--colors-red-500);
1505
+ }
1506
+
1507
+ .error-text {
1508
+ display: flex;
1509
+ flex-direction: column;
1393
1510
  }
1394
1511
 
1395
1512
  canvas {
@@ -1406,17 +1523,23 @@ ${t}`,_v=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kv=Objec
1406
1523
  right: 0;
1407
1524
  bottom: 0;
1408
1525
  }
1409
- `],Ft([j({type:Object})],Dt.prototype,"data",2),Ft([j({type:Object})],Dt.prototype,"template",2),Ft([j({type:Boolean})],Dt.prototype,"burnCaptions",2),Ft([j({type:String})],Dt.prototype,"src",2),Ft([j({type:String})],Dt.prototype,"track",2),Ft([j({type:Number,attribute:"aspectratio"})],Dt.prototype,"propAspectRatio",2),Ft([j({type:String})],Dt.prototype,"preload",2),Ft([j({type:Boolean})],Dt.prototype,"autoplay",2),Ft([j({type:Boolean})],Dt.prototype,"loading",2),Ft([j({type:Array})],Dt.prototype,"controls",2),Ft([j({attribute:!1})],Dt.prototype,"compilation",2),Ft([Wt()],Dt.prototype,"_aspectRatio",2),Ft([Wt()],Dt.prototype,"_waiting",2),Ft([Wt()],Dt.prototype,"_stalled",2),Ft([Wt()],Dt.prototype,"_seeking",2),Ft([Wt()],Dt.prototype,"_captions",2),Ft([Wt()],Dt.prototype,"_fullscreen",2),Dt=Ft([se("vmp-new-media-player")],Dt);var S0=Object.defineProperty,L0=Object.getOwnPropertyDescriptor,re=(r,t,e,i)=>{for(var s=i>1?void 0:i?L0(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&&S0(t,e,s),s};At.Embed=class extends Ei{constructor(){super(...arguments),this._mediaPlayerRef=po(),this.env="prod",this.apiKey="",this.trackingSource="embed",this.preload="auto",this.autoplay=!1,this.aspectRatio=0,this.eventController=new ld(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 Pd(this),this._trackingController=new Nd(this)}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 st`
1526
+
1527
+ vmp-new-video-preview {
1528
+ position: absolute;
1529
+ top: 0;
1530
+ left: 0;
1531
+ }
1532
+ `],si([It({type:Object})],Ze.prototype,"data",2),si([It({type:Object})],Ze.prototype,"template",2),si([It({type:Boolean})],Ze.prototype,"burnCaptions",2),si([It({type:Boolean})],Ze.prototype,"debug",2),si([It({type:String})],Ze.prototype,"src",2),si([It({type:String})],Ze.prototype,"track",2),si([It({type:Number,attribute:"aspectratio"})],Ze.prototype,"propAspectRatio",2),si([It({type:String})],Ze.prototype,"preload",2),si([It({type:Boolean})],Ze.prototype,"autoplay",2),si([It({type:Boolean})],Ze.prototype,"loading",2),si([It({type:Array})],Ze.prototype,"controls",2),si([It({attribute:!1})],Ze.prototype,"compilation",2),si([ki()],Ze.prototype,"_aspectRatio",2),si([ki()],Ze.prototype,"_processing",2),si([ki()],Ze.prototype,"_waiting",2),si([ki()],Ze.prototype,"_errors",2),si([ki()],Ze.prototype,"_seeking",2),si([ki()],Ze.prototype,"_captions",2),si([ki()],Ze.prototype,"_fullscreen",2),Ze=si([Oi("vmp-new-media-player")],Ze);var kA=Object.defineProperty,wA=Object.getOwnPropertyDescriptor,zi=(n,t,e,i)=>{for(var s=i>1?void 0:i?wA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&kA(t,e,s),s};Be.Embed=class extends yn{constructor(){super(...arguments),this._mediaPlayerRef=wi(),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embed",this.preload="auto",this.autoplay=!1,this.aspectRatio=0,this.eventController=new dg(this,["durationchange","ended","error","loadeddata","pause","stalled","play","playing","ratechange","scenechange","seeking","seeked","timeupdate","volumechange","waiting","video:loadeddata","video:seeking","video:seeked","video:play","video:playing","video:pause","video:stalled","video:timeupdate","video:ended","video:error"]),this._fetcherController=new Mg(this),this._trackingController=new Ng(this)}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 sceneConfig(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.sceneConfig)??null}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 ie`
1410
1533
  <vmp-new-media-player
1411
- ${go(this._mediaPlayerRef)}
1534
+ ${Si(this._mediaPlayerRef)}
1412
1535
  ${this.eventController.register()}
1413
1536
  ?autoplay=${this.autoplay}
1414
1537
  ?loading=${this.fetching}
1415
1538
  .data=${this.vouch}
1416
1539
  .template=${this.template}
1417
- aspectRatio=${uo(this.aspectRatio)}
1418
- preload=${uo(this.preload)}
1540
+ aspectRatio=${Xs(this.aspectRatio)}
1541
+ preload=${Xs(this.preload)}
1419
1542
  .controls=${this.controls}
1420
1543
  ></vmp-new-media-player>
1421
- `}},re([j({type:Object,attribute:"data"})],At.Embed.prototype,"data",2),re([j({type:String})],At.Embed.prototype,"vouchId",2),re([j({type:String})],At.Embed.prototype,"templateId",2),re([j({type:String})],At.Embed.prototype,"env",2),re([j({type:String})],At.Embed.prototype,"apiKey",2),re([j({type:String})],At.Embed.prototype,"trackingSource",2),re([j({type:Array})],At.Embed.prototype,"controls",2),re([j({type:String})],At.Embed.prototype,"preload",2),re([j({type:Boolean})],At.Embed.prototype,"autoplay",2),re([j({type:Number})],At.Embed.prototype,"aspectRatio",2),re([Wt()],At.Embed.prototype,"vouch",2),re([Wt()],At.Embed.prototype,"template",2),At.Embed=re([zc("vouch-embed")],At.Embed);function Ie(r){if(typeof r!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(r))}function Tc(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 R0(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 $i={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),Ie(n),n.length!==0&&(t=n+"/"+t,e=n.charCodeAt(0)===47)}return t=Tc(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(Ie(t),t.length===0)return".";var e=t.charCodeAt(0)===47,i=t.charCodeAt(t.length-1)===47;return t=Tc(t,!e),t.length===0&&!e&&(t="."),t.length>0&&i&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return Ie(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];Ie(i),i.length>0&&(t===void 0?t=i:t+="/"+i)}return t===void 0?".":$i.normalize(t)},relative:function(t,e){if(Ie(t),Ie(e),t===e||(t=$i.resolve(t),e=$i.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,c=-1,d=0;d<=h;++d){if(d===h){if(l>h){if(e.charCodeAt(a+d)===47)return e.slice(a+d+1);if(d===0)return e.slice(a+d)}else n>h&&(t.charCodeAt(i+d)===47?c=d:d===0&&(c=0));break}var u=t.charCodeAt(i+d),f=e.charCodeAt(a+d);if(u!==f)break;u===47&&(c=d)}var p="";for(d=i+c+1;d<=s;++d)(d===s||t.charCodeAt(d)===47)&&(p.length===0?p+="..":p+="/..");return p.length>0?p+e.slice(a+c):(a+=c,e.charCodeAt(a)===47&&++a,e.slice(a))},_makeLong:function(t){return t},dirname:function(t){if(Ie(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');Ie(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){Ie(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 R0("/",t)},parse:function(t){Ie(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,c=t.length-1,d=0;c>=n;--c){if(i=t.charCodeAt(c),i===47){if(!h){o=c+1;break}continue}l===-1&&(h=!1,l=c+1),i===46?a===-1?a=c:d!==1&&(d=1):a!==-1&&(d=-1)}return a===-1||l===-1||d===0||d===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};$i.posix=$i;var _0=$i;const{basename:Ac,extname:k0}=_0;class I0{constructor(){let t=(()=>typeof Fs>"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 D0(r,{filename:t="",extension:e="",format:g,page:s,quality:n,matte:a,density:o,outline:l,archive:f}={}){var{fromMime:c,toMime:d,expected:u}=new I0,f=f||"canvas",p=g||e.replace(/@\d+x$/i,"")||k0(t),g=c(d(p)||p),v=d(g),E=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(!E)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let A,L,y=t.replace(/{(\d*)}/g,(R,D)=>(L=!0,D=parseInt(D,10),A=isFinite(D)?D:isFinite(A)?A:-1,"{}")),S=s>0?s-1:s<0?E+s:void 0;if(isFinite(S)&&S<0||S>=E)throw new RangeError(E==1?`Canvas only has a ‘page 1’ (${S} is out of bounds)`:`Canvas has pages 1–${E} (${S} is out of bounds)`);if(r=isFinite(S)?[r[S]]:L||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 R=(e||Ac(t,p)).match(/@(\d+)x$/i);o=R?parseInt(R[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:v,pages:r,padding:A,quality:n,matte:a,density:o,outline:l,archive:f}}class wr{static for(t){return new wr().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}}wr.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 Aa(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 Sr=class Sr{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=Sr.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,c=Aa(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,wr.for(n)).set32(14,n.length).set32(18,n.length).set16(22,s.length);h+=a;let d=Aa(a+n.length+l).set32(0,67324752).bytes(4,c.array).bytes(30,s).bytes(a,n);h+=n.length,d.set32(o,134695760).bytes(o+4,c.array.slice(10,22)),h+=l,this.files.push({offset:h,folder:i,name:s,header:c,payload:d}),this.offset=h}toBuffer(){let t=this.files.reduce((d,{name:u})=>46+u.length+d,0),e=Aa(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:c}of this.files)l.set(c.array,h),h+=c.size;return l.set(e.array,h),l}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}};Ic(Sr,"encoder",new TextEncoder);let wa=Sr;const Sa=(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))},C0=(...r)=>Sa(...r).then(t=>t.arrayBuffer()),x0=async(r,t,e,i,s)=>{wc(s,await Sa(r,t,e,i))},P0=async(r,t,e,i,s,n,a)=>{let o=c=>n.replace("{}",String(c+1).padStart(a,"0")),l=Ac(s,".zip")||"archive",h=new wa(l);await Promise.all(r.map(async(c,d)=>{let u=o(d);await h.add(u,await Sa(c,t,e,i))})),wc(`${l}.zip`,h.blob)},wc=(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 O0={asBuffer:C0,asDownload:x0,asZipDownload:P0,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:D0};const{asBuffer:La,asDownload:$0,asZipDownload:M0,atScale:Ra,options:_a}=O0,Sc=Symbol.for("toDataURL"),F0=r=>{let t=Object.assign(new Lc,{crossOrigin:"Anonymous",src:r});return t.decode().then(()=>t)};class N0{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:()=>La(i,"image/png"),jpg:()=>La(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:c}=i,l=Object.assign(document.createElement("canvas"),{width:h,height:c});l.getContext("2d").drawImage(i,0,0),s.push(l);var[h,c]=o.length?o:[h,c];return Object.assign(i,{width:h,height:c}).getContext("2d")},saveAs(o,l){l=typeof l=="number"?{quality:l}:l;let h=_a(this.pages,{filename:o,...l}),{pattern:c,padding:d,mime:u,quality:f,matte:p,density:g,archive:v}=h,E=Ra(h.pages,g);return d==null?$0(E[0],u,f,p,o):M0(E,u,f,p,v,c,d)},toBuffer(o="png",l={}){l=typeof l=="number"?{quality:l}:l;let h=_a(this.pages,{extension:o,...l}),{mime:c,quality:d,matte:u,pages:f,density:p}=h,g=Ra(f,p,u)[0];return La(g,c,d,u)},[Sc]:i.toDataURL.bind(i),toDataURL(o="png",l={}){l=typeof l=="number"?{quality:l}:l;let h=_a(this.pages,{extension:o,...l}),{mime:c,quality:d,matte:u,pages:f,density:p}=h,g=Ra(f,p,u)[0],v=g[g===i?Sc:"toDataURL"](c,d);return Promise.resolve(v)}})}}const{CanvasRenderingContext2D:U0,CanvasGradient:B0,CanvasPattern:H0,Image:Lc,ImageData:G0,Path2D:V0,DOMMatrix:K0,DOMRect:j0,DOMPoint:W0}=window;var Rc={Canvas:N0,loadImage:F0,CanvasRenderingContext2D:U0,CanvasGradient:B0,CanvasPattern:H0,Image:Lc,ImageData:G0,Path2D:V0,DOMMatrix:K0,DOMRect:j0,DOMPoint:W0};const _c=xe({__proto__:null,default:zr(Rc)},[Rc]);return Object.defineProperty(At,Symbol.toStringTag,{value:"Module"}),At}({});
1544
+ `}},zi([It({type:Object,attribute:"data"})],Be.Embed.prototype,"data",2),zi([It({type:String})],Be.Embed.prototype,"vouchId",2),zi([It({type:String})],Be.Embed.prototype,"templateId",2),zi([It({type:String})],Be.Embed.prototype,"env",2),zi([It({type:String})],Be.Embed.prototype,"apiKey",2),zi([It({type:Boolean})],Be.Embed.prototype,"disableTracking",2),zi([It({type:String})],Be.Embed.prototype,"trackingSource",2),zi([It({type:Array})],Be.Embed.prototype,"controls",2),zi([It({type:String})],Be.Embed.prototype,"preload",2),zi([It({type:Boolean})],Be.Embed.prototype,"autoplay",2),zi([It({type:Number})],Be.Embed.prototype,"aspectRatio",2),zi([ki()],Be.Embed.prototype,"vouch",2),zi([ki()],Be.Embed.prototype,"template",2),Be.Embed=zi([Q2("vouch-embed")],Be.Embed);function Nr(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}function zf(n,t){for(var e="",i=0,s=-1,o=0,c,d=0;d<=n.length;++d){if(d<n.length)c=n.charCodeAt(d);else{if(c===47)break;c=47}if(c===47){if(!(s===d-1||o===1))if(s!==d-1&&o===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){var f=e.lastIndexOf("/");if(f!==e.length-1){f===-1?(e="",i=0):(e=e.slice(0,f),i=e.length-1-e.lastIndexOf("/")),s=d,o=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=d,o=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+="/"+n.slice(s+1,d):e=n.slice(s+1,d),i=d-s-1;s=d,o=0}else c===46&&o!==-1?++o:o=-1}return e}function SA(n,t){var e=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+i:e+n+i:i}var Mn={resolve:function(){for(var t="",e=!1,i,s=arguments.length-1;s>=-1&&!e;s--){var o;s>=0?o=arguments[s]:(i===void 0&&(i=process.cwd()),o=i),Nr(o),o.length!==0&&(t=o+"/"+t,e=o.charCodeAt(0)===47)}return t=zf(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(Nr(t),t.length===0)return".";var e=t.charCodeAt(0)===47,i=t.charCodeAt(t.length-1)===47;return t=zf(t,!e),t.length===0&&!e&&(t="."),t.length>0&&i&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return Nr(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];Nr(i),i.length>0&&(t===void 0?t=i:t+="/"+i)}return t===void 0?".":Mn.normalize(t)},relative:function(t,e){if(Nr(t),Nr(e),t===e||(t=Mn.resolve(t),e=Mn.resolve(e),t===e))return"";for(var i=1;i<t.length&&t.charCodeAt(i)===47;++i);for(var s=t.length,o=s-i,c=1;c<e.length&&e.charCodeAt(c)===47;++c);for(var d=e.length,f=d-c,p=o<f?o:f,g=-1,v=0;v<=p;++v){if(v===p){if(f>p){if(e.charCodeAt(c+v)===47)return e.slice(c+v+1);if(v===0)return e.slice(c+v)}else o>p&&(t.charCodeAt(i+v)===47?g=v:v===0&&(g=0));break}var b=t.charCodeAt(i+v),E=e.charCodeAt(c+v);if(b!==E)break;b===47&&(g=v)}var T="";for(v=i+g+1;v<=s;++v)(v===s||t.charCodeAt(v)===47)&&(T.length===0?T+="..":T+="/..");return T.length>0?T+e.slice(c+g):(c+=g,e.charCodeAt(c)===47&&++c,e.slice(c))},_makeLong:function(t){return t},dirname:function(t){if(Nr(t),t.length===0)return".";for(var e=t.charCodeAt(0),i=e===47,s=-1,o=!0,c=t.length-1;c>=1;--c)if(e=t.charCodeAt(c),e===47){if(!o){s=c;break}}else o=!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');Nr(t);var i=0,s=-1,o=!0,c;if(e!==void 0&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var d=e.length-1,f=-1;for(c=t.length-1;c>=0;--c){var p=t.charCodeAt(c);if(p===47){if(!o){i=c+1;break}}else f===-1&&(o=!1,f=c+1),d>=0&&(p===e.charCodeAt(d)?--d===-1&&(s=c):(d=-1,s=f))}return i===s?s=f:s===-1&&(s=t.length),t.slice(i,s)}else{for(c=t.length-1;c>=0;--c)if(t.charCodeAt(c)===47){if(!o){i=c+1;break}}else s===-1&&(o=!1,s=c+1);return s===-1?"":t.slice(i,s)}},extname:function(t){Nr(t);for(var e=-1,i=0,s=-1,o=!0,c=0,d=t.length-1;d>=0;--d){var f=t.charCodeAt(d);if(f===47){if(!o){i=d+1;break}continue}s===-1&&(o=!1,s=d+1),f===46?e===-1?e=d:c!==1&&(c=1):e!==-1&&(c=-1)}return e===-1||s===-1||c===0||c===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 SA("/",t)},parse:function(t){Nr(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var i=t.charCodeAt(0),s=i===47,o;s?(e.root="/",o=1):o=0;for(var c=-1,d=0,f=-1,p=!0,g=t.length-1,v=0;g>=o;--g){if(i=t.charCodeAt(g),i===47){if(!p){d=g+1;break}continue}f===-1&&(p=!1,f=g+1),i===46?c===-1?c=g:v!==1&&(v=1):c!==-1&&(v=-1)}return c===-1||f===-1||v===0||v===1&&c===f-1&&c===d+1?f!==-1&&(d===0&&s?e.base=e.name=t.slice(1,f):e.base=e.name=t.slice(d,f)):(d===0&&s?(e.name=t.slice(1,c),e.base=t.slice(1,f)):(e.name=t.slice(d,c),e.base=t.slice(d,f)),e.ext=t.slice(c,f)),d>0?e.dir=t.slice(0,d-1):s&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};Mn.posix=Mn;var RA=Mn;const{basename:Xf,extname:_A}=RA;class LA{constructor(){let t=(()=>typeof Ja>"u")(),e="image/png",i="image/jpeg",s="image/jpeg",o="image/webp",c="application/pdf",d="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:o}:{png:e,jpg:i,jpeg:s,pdf:c,svg:d},mimes:t?{[e]:"png",[i]:"jpg",[o]:"webp"}:{[e]:"png",[i]:"jpg",[c]:"pdf",[d]:"svg"}})}toMime(t){return this.formats[(t||"").replace(/^\./,"").toLowerCase()]}fromMime(t){return this.mimes[t]}}function CA(n,{filename:t="",extension:e="",format:w,page:s,quality:o,matte:c,density:d,outline:f,archive:E}={}){var{fromMime:g,toMime:v,expected:b}=new LA,E=E||"canvas",T=w||e.replace(/@\d+x$/i,"")||_A(t),w=g(v(T)||T),_=v(w),D=n.length;if(!T)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!w)throw new Error(`Unsupported file format "${T}" (expected ${b})`);if(!D)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let M,F,x=t.replace(/{(\d*)}/g,(V,j)=>(F=!0,j=parseInt(j,10),M=isFinite(j)?j:isFinite(M)?M:-1,"{}")),N=s>0?s-1:s<0?D+s:void 0;if(isFinite(N)&&N<0||N>=D)throw new RangeError(D==1?`Canvas only has a ‘page 1’ (${N} is out of bounds)`:`Canvas has pages 1–${D} (${N} is out of bounds)`);if(n=isFinite(N)?[n[N]]:F||w=="pdf"?n:n.slice(-1),o===void 0)o=.92;else if(typeof o!="number"||!isFinite(o)||o<0||o>1)throw new TypeError("The quality option must be an number in the 0.0–1.0 range");if(d===void 0){let V=(e||Xf(t,T)).match(/@(\d+)x$/i);d=V?parseInt(V[1],10):1}else if(typeof d!="number"||!Number.isInteger(d)||d<1)throw new TypeError("The density option must be a non-negative integer");return f===void 0?f=!0:w=="svg"&&(f=!!f),{filename:t,pattern:x,format:w,mime:_,pages:n,padding:M,quality:o,matte:c,density:d,outline:f,archive:E}}class Wo{static for(t){return new Wo().append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=this.crc|0,i=this.table,s=0,o=t.length|0;s<o;s++)e=e>>>8^i[(e^t[s])&255];return this.crc=e,this}}Wo.prototype.table=(()=>{var n,t,e,i=[];for(n=0;n<256;n++){for(e=n,t=0;t<8;t++)e=e&1?e>>>1^3988292384:e>>>1;i[n]=e}return i})();function lh(n){let t=new Uint8Array(n),e=new DataView(t.buffer),i={array:t,view:e,size:n,set8(s,o){return e.setUint8(s,o),i},set16(s,o){return e.setUint16(s,o,!0),i},set32(s,o){return e.setUint32(s,o,!0),i},bytes(s,o){return t.set(o,s),i}};return i}const jo=class jo{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=jo.encoder.encode(`${this.directory}/${i?"":t}`),o=new Uint8Array(i?0:await e.arrayBuffer()),c=30+s.length,d=c+o.length,f=16,{offset:p}=this,g=lh(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,Wo.for(o)).set32(14,o.length).set32(18,o.length).set16(22,s.length);p+=c;let v=lh(c+o.length+f).set32(0,67324752).bytes(4,g.array).bytes(30,s).bytes(c,o);p+=o.length,v.set32(d,134695760).bytes(d+4,g.array.slice(10,22)),p+=f,this.files.push({offset:p,folder:i,name:s,header:g,payload:v}),this.offset=p}toBuffer(){let t=this.files.reduce((v,{name:b})=>46+b.length+v,0),e=lh(t+22),i=0;for(var{offset:s,name:o,header:c,folder:d}of this.files)e.set32(i,33639248).set16(i+4,20).bytes(i+6,c.array).set8(i+38,d?16:0).set32(i+42,s).bytes(i+46,o),i+=46+o.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 f=new Uint8Array(this.offset+e.size),p=0;for(var{payload:g}of this.files)f.set(g.array,p),p+=g.size;return f.set(e.array,p),f}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}};y2(jo,"encoder",new TextEncoder);let ch=jo;const hh=(n,t,e,i)=>{if(i){let{width:s,height:o}=n,c=Object.assign(document.createElement("canvas"),{width:s,height:o}),d=c.getContext("2d");d.fillStyle=i,d.fillRect(0,0,s,o),d.drawImage(n,0,0),n=c}return new Promise((s,o)=>n.toBlob(s,t,e))},IA=(...n)=>hh(...n).then(t=>t.arrayBuffer()),xA=async(n,t,e,i,s)=>{Zf(s,await hh(n,t,e,i))},DA=async(n,t,e,i,s,o,c)=>{let d=g=>o.replace("{}",String(g+1).padStart(c,"0")),f=Xf(s,".zip")||"archive",p=new ch(f);await Promise.all(n.map(async(g,v)=>{let b=d(v);await p.add(b,await hh(g,t,e,i))})),Zf(`${f}.zip`,p.blob)},Zf=(n,t)=>{const e=window.URL.createObjectURL(t),i=document.createElement("a");i.style.display="none",i.href=e,i.setAttribute("download",n),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 PA={asBuffer:IA,asDownload:xA,asZipDownload:DA,atScale:(n,t,e)=>n.map(i=>{if(t==1&&!e)return i.canvas;let s=document.createElement("canvas"),o=s.getContext("2d"),c=i.canvas?i.canvas:i;return s.width=c.width*t,s.height=c.height*t,e&&(o.fillStyle=e,o.fillRect(0,0,s.width,s.height)),o.scale(t,t),o.drawImage(c,0,0),s}),options:CA};const{asBuffer:dh,asDownload:OA,asZipDownload:MA,atScale:uh,options:fh}=PA,qf=Symbol.for("toDataURL"),$A=n=>{let t=Object.assign(new Qf,{crossOrigin:"Anonymous",src:n});return t.decode().then(()=>t)};class NA{constructor(t,e){let i=document.createElement("canvas"),s=[];Object.defineProperty(i,"async",{value:!0,writable:!1,enumerable:!0});for(var[o,c]of Object.entries({png:()=>dh(i,"image/png"),jpg:()=>dh(i,"image/jpeg"),pages:()=>s.concat(i).map(d=>d.getContext("2d"))}))Object.defineProperty(i,o,{get:c});return Object.assign(i,{width:t,height:e,newPage(...d){var{width:p,height:g}=i,f=Object.assign(document.createElement("canvas"),{width:p,height:g});f.getContext("2d").drawImage(i,0,0),s.push(f);var[p,g]=d.length?d:[p,g];return Object.assign(i,{width:p,height:g}).getContext("2d")},saveAs(d,f){f=typeof f=="number"?{quality:f}:f;let p=fh(this.pages,{filename:d,...f}),{pattern:g,padding:v,mime:b,quality:E,matte:T,density:w,archive:_}=p,D=uh(p.pages,w);return v==null?OA(D[0],b,E,T,d):MA(D,b,E,T,_,g,v)},toBuffer(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=fh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:b,pages:E,density:T}=p,w=uh(E,T,b)[0];return dh(w,g,v,b)},[qf]:i.toDataURL.bind(i),toDataURL(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=fh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:b,pages:E,density:T}=p,w=uh(E,T,b)[0],_=w[w===i?qf:"toDataURL"](g,v);return Promise.resolve(_)}})}}const{CanvasRenderingContext2D:FA,CanvasGradient:UA,CanvasPattern:BA,Image:Qf,ImageData:GA,Path2D:HA,DOMMatrix:VA,DOMRect:WA,DOMPoint:jA}=window;var Jf={Canvas:NA,loadImage:$A,CanvasRenderingContext2D:FA,CanvasGradient:UA,CanvasPattern:BA,Image:Qf,ImageData:GA,Path2D:HA,DOMMatrix:VA,DOMRect:WA,DOMPoint:jA};const tp=Yr({__proto__:null,default:Il(Jf)},[Jf]);return Object.defineProperty(Be,Symbol.toStringTag,{value:"Module"}),Be}({});
1422
1545
  //# sourceMappingURL=embeds.iife.js.map