@vouchfor/embeds 1.1.0 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. package/dist/es/{browser-06a0f9c0.js → browser-dfc996c6.js} +2 -2
  2. package/dist/es/{browser-06a0f9c0.js.map → browser-dfc996c6.js.map} +1 -1
  3. package/dist/es/embeds.js +1 -1
  4. package/dist/es/{index-a234952b.js → index-5a5b4566.js} +1781 -1786
  5. package/dist/es/index-5a5b4566.js.map +1 -0
  6. package/dist/iife/dialog-embed/{browser-03872a5a.js → browser-238e2a76.js} +2 -2
  7. package/dist/iife/dialog-embed/{browser-03872a5a.js.map → browser-238e2a76.js.map} +1 -1
  8. package/dist/iife/dialog-embed/embed.iife.js +107 -107
  9. package/dist/iife/dialog-embed/embed.iife.js.map +1 -1
  10. package/dist/iife/dialog-embed/embed.js +1 -1
  11. package/dist/iife/dialog-embed/{index-0caa60dd.js → index-a1b8c2f9.js} +3309 -3283
  12. package/dist/iife/dialog-embed/index-a1b8c2f9.js.map +1 -0
  13. package/dist/iife/embeds.iife.js +107 -107
  14. package/dist/iife/embeds.iife.js.map +1 -1
  15. package/dist/iife/player-embed/{browser-a7c2424d.js → browser-c151f2a1.js} +2 -2
  16. package/dist/iife/player-embed/{browser-a7c2424d.js.map → browser-c151f2a1.js.map} +1 -1
  17. package/dist/iife/player-embed/embed.iife.js +99 -99
  18. package/dist/iife/player-embed/embed.iife.js.map +1 -1
  19. package/dist/iife/player-embed/embed.js +1 -1
  20. package/dist/iife/player-embed/{index-e005869e.js → index-800d9ffb.js} +3307 -3281
  21. package/dist/iife/player-embed/index-800d9ffb.js.map +1 -0
  22. package/package.json +2 -2
  23. package/dist/es/index-a234952b.js.map +0 -1
  24. package/dist/iife/dialog-embed/index-0caa60dd.js.map +0 -1
  25. package/dist/iife/player-embed/index-e005869e.js.map +0 -1
@@ -1,44 +1,44 @@
1
- var Y3=Object.defineProperty;var X3=(ie,Qr,Pr)=>Qr in ie?Y3(ie,Qr,{enumerable:!0,configurable:!0,writable:!0,value:Pr}):ie[Qr]=Pr;var I2=(ie,Qr,Pr)=>(X3(ie,typeof Qr!="symbol"?Qr+"":Qr,Pr),Pr);var embeds=function(ie){var fp;"use strict";function Qr(s,t){for(var e=0;e<t.length;e++){const i=t[e];if(typeof i!="string"&&!Array.isArray(i)){for(const n in i)if(n!=="default"&&!(n in s)){const o=Object.getOwnPropertyDescriptor(i,n);o&&Object.defineProperty(s,n,o.get?o:{enumerable:!0,get:()=>i[n]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}/**
1
+ var Z3=Object.defineProperty;var q3=(ie,Jr,Pr)=>Jr in ie?Z3(ie,Jr,{enumerable:!0,configurable:!0,writable:!0,value:Pr}):ie[Jr]=Pr;var I2=(ie,Jr,Pr)=>(q3(ie,typeof Jr!="symbol"?Jr+"":Jr,Pr),Pr);var embeds=function(ie){var fp;"use strict";function Jr(s,t){for(var e=0;e<t.length;e++){const i=t[e];if(typeof i!="string"&&!Array.isArray(i)){for(const n in i)if(n!=="default"&&!(n in s)){const o=Object.getOwnPropertyDescriptor(i,n);o&&Object.defineProperty(s,n,o.get?o:{enumerable:!0,get:()=>i[n]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}/**
2
2
  * @license
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
- */const Pr=globalThis,ml=Pr.ShadowRoot&&(Pr.ShadyCSS===void 0||Pr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Jh=Symbol(),td=new WeakMap;let O2=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Jh)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(ml&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=td.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&td.set(e,t))}return t}toString(){return this.cssText}};const M2=s=>new O2(typeof s=="string"?s:s+"",void 0,Jh),$2=(s,t)=>{if(ml)s.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),n=Pr.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}},ed=ml?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return M2(e)})(s):s;/**
5
+ */const Pr=globalThis,vl=Pr.ShadowRoot&&(Pr.ShadyCSS===void 0||Pr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Jh=Symbol(),td=new WeakMap;let O2=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Jh)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(vl&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=td.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&td.set(e,t))}return t}toString(){return this.cssText}};const M2=s=>new O2(typeof s=="string"?s:s+"",void 0,Jh),$2=(s,t)=>{if(vl)s.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),n=Pr.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}},ed=vl?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return M2(e)})(s):s;/**
6
6
  * @license
7
7
  * Copyright 2017 Google LLC
8
8
  * SPDX-License-Identifier: BSD-3-Clause
9
- */const{is:F2,defineProperty:N2,getOwnPropertyDescriptor:U2,getOwnPropertyNames:B2,getOwnPropertySymbols:G2,getPrototypeOf:V2}=Object,vs=globalThis,id=vs.trustedTypes,H2=id?id.emptyScript:"",vl=vs.reactiveElementPolyfillSupport,Yn=(s,t)=>s,Ya={toAttribute(s,t){switch(t){case Boolean:s=s?H2:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let e=s;switch(t){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},yl=(s,t)=>!F2(s,t),rd={attribute:!0,type:String,converter:Ya,reflect:!1,hasChanged:yl};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),vs.litPropertyMetadata??(vs.litPropertyMetadata=new WeakMap);let Xn=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=rd){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);n!==void 0&&N2(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=U2(this.prototype,t)??{get(){return this[e]},set(l){this[e]=l}};return{get(){return n==null?void 0:n.call(this)},set(l){const d=n==null?void 0:n.call(this);o.call(this,l),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??rd}static _$Ei(){if(this.hasOwnProperty(Yn("elementProperties")))return;const t=V2(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Yn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Yn("properties"))){const e=this.properties,i=[...B2(e),...G2(e)];for(const n of i)this.createProperty(n,e[n])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,n]of e)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const n=this._$Eu(e,i);n!==void 0&&this._$Eh.set(n,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 n of i)e.unshift(ed(n))}else t!==void 0&&e.push(ed(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 $2(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),n=this.constructor._$Eu(t,i);if(n!==void 0&&i.reflect===!0){const l=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Ya).toAttribute(e,i.type);this._$Em=t,l==null?this.removeAttribute(n):this.setAttribute(n,l),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,n=i._$Eh.get(t);if(n!==void 0&&this._$Em!==n){const l=i.getPropertyOptions(n),d=typeof l.converter=="function"?{fromAttribute:l.converter}:((o=l.converter)==null?void 0:o.fromAttribute)!==void 0?l.converter:Ya;this._$Em=n,this[n]=d.fromAttribute(e,l.type),this._$Em=null}}requestUpdate(t,e,i,n=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??yl)(n?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,l]of this._$Ep)this[o]=l;this._$Ep=void 0}const n=this.constructor.elementProperties;if(n.size>0)for(const[o,l]of n)l.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],l)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$E_)==null||i.forEach(n=>{var o;return(o=n.hostUpdate)==null?void 0:o.call(n)}),this.update(e)):this._$ET()}catch(n){throw t=!1,this._$ET(),n}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$E_)==null||e.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.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){}};Xn.elementStyles=[],Xn.shadowRootOptions={mode:"open"},Xn[Yn("elementProperties")]=new Map,Xn[Yn("finalized")]=new Map,vl==null||vl({ReactiveElement:Xn}),(vs.reactiveElementVersions??(vs.reactiveElementVersions=[])).push("2.0.2");/**
9
+ */const{is:F2,defineProperty:N2,getOwnPropertyDescriptor:U2,getOwnPropertyNames:B2,getOwnPropertySymbols:G2,getPrototypeOf:V2}=Object,vs=globalThis,id=vs.trustedTypes,H2=id?id.emptyScript:"",yl=vs.reactiveElementPolyfillSupport,zn=(s,t)=>s,Xa={toAttribute(s,t){switch(t){case Boolean:s=s?H2:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let e=s;switch(t){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},bl=(s,t)=>!F2(s,t),rd={attribute:!0,type:String,converter:Xa,reflect:!1,hasChanged:bl};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),vs.litPropertyMetadata??(vs.litPropertyMetadata=new WeakMap);let Xn=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=rd){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);n!==void 0&&N2(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=U2(this.prototype,t)??{get(){return this[e]},set(l){this[e]=l}};return{get(){return n==null?void 0:n.call(this)},set(l){const d=n==null?void 0:n.call(this);o.call(this,l),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??rd}static _$Ei(){if(this.hasOwnProperty(zn("elementProperties")))return;const t=V2(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(zn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(zn("properties"))){const e=this.properties,i=[...B2(e),...G2(e)];for(const n of i)this.createProperty(n,e[n])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,n]of e)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const n=this._$Eu(e,i);n!==void 0&&this._$Eh.set(n,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 n of i)e.unshift(ed(n))}else t!==void 0&&e.push(ed(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 $2(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),n=this.constructor._$Eu(t,i);if(n!==void 0&&i.reflect===!0){const l=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Xa).toAttribute(e,i.type);this._$Em=t,l==null?this.removeAttribute(n):this.setAttribute(n,l),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,n=i._$Eh.get(t);if(n!==void 0&&this._$Em!==n){const l=i.getPropertyOptions(n),d=typeof l.converter=="function"?{fromAttribute:l.converter}:((o=l.converter)==null?void 0:o.fromAttribute)!==void 0?l.converter:Xa;this._$Em=n,this[n]=d.fromAttribute(e,l.type),this._$Em=null}}requestUpdate(t,e,i,n=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??bl)(n?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,l]of this._$Ep)this[o]=l;this._$Ep=void 0}const n=this.constructor.elementProperties;if(n.size>0)for(const[o,l]of n)l.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],l)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$E_)==null||i.forEach(n=>{var o;return(o=n.hostUpdate)==null?void 0:o.call(n)}),this.update(e)):this._$ET()}catch(n){throw t=!1,this._$ET(),n}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$E_)==null||e.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.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){}};Xn.elementStyles=[],Xn.shadowRootOptions={mode:"open"},Xn[zn("elementProperties")]=new Map,Xn[zn("finalized")]=new Map,yl==null||yl({ReactiveElement:Xn}),(vs.reactiveElementVersions??(vs.reactiveElementVersions=[])).push("2.0.2");/**
10
10
  * @license
11
11
  * Copyright 2017 Google LLC
12
12
  * SPDX-License-Identifier: BSD-3-Clause
13
- */const Zn=globalThis,Xa=Zn.trustedTypes,sd=Xa?Xa.createPolicy("lit-html",{createHTML:s=>s}):void 0,bl="$lit$",Jr=`lit$${(Math.random()+"").slice(9)}$`,Al="?"+Jr,W2=`<${Al}>`,zs=document,Za=()=>zs.createComment(""),qn=s=>s===null||typeof s!="object"&&typeof s!="function",nd=Array.isArray,ad=s=>nd(s)||typeof(s==null?void 0:s[Symbol.iterator])=="function",El=`[
14
- \f\r]`,Qn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,od=/-->/g,ld=/>/g,Ys=RegExp(`>|${El}(?:([^\\s"'>=/]+)(${El}*=${El}*(?:[^
15
- \f\r"'\`<>=]|("|')|))|$)`,"g"),cd=/'/g,hd=/"/g,dd=/^(?:script|style|textarea|title)$/i,ys=Symbol.for("lit-noChange"),ri=Symbol.for("lit-nothing"),ud=new WeakMap,Xs=zs.createTreeWalker(zs,129);function fd(s,t){if(!Array.isArray(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return sd!==void 0?sd.createHTML(t):t}const pd=(s,t)=>{const e=s.length-1,i=[];let n,o=t===2?"<svg>":"",l=Qn;for(let d=0;d<e;d++){const f=s[d];let p,g,v=-1,A=0;for(;A<f.length&&(l.lastIndex=A,g=l.exec(f),g!==null);)A=l.lastIndex,l===Qn?g[1]==="!--"?l=od:g[1]!==void 0?l=ld:g[2]!==void 0?(dd.test(g[2])&&(n=RegExp("</"+g[2],"g")),l=Ys):g[3]!==void 0&&(l=Ys):l===Ys?g[0]===">"?(l=n??Qn,v=-1):g[1]===void 0?v=-2:(v=l.lastIndex-g[2].length,p=g[1],l=g[3]===void 0?Ys:g[3]==='"'?hd:cd):l===hd||l===cd?l=Ys:l===od||l===ld?l=Qn:(l=Ys,n=void 0);const E=l===Ys&&s[d+1].startsWith("/>")?" ":"";o+=l===Qn?f+W2:v>=0?(i.push(p),f.slice(0,v)+bl+f.slice(v)+Jr+E):f+Jr+(v===-2?d:E)}return[fd(s,o+(s[e]||"<?>")+(t===2?"</svg>":"")),i]};let Tl=class D2{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,l=0;const d=t.length-1,f=this.parts,[p,g]=pd(t,e);if(this.el=D2.createElement(p,i),Xs.currentNode=this.el.content,e===2){const v=this.el.content.firstChild;v.replaceWith(...v.childNodes)}for(;(n=Xs.nextNode())!==null&&f.length<d;){if(n.nodeType===1){if(n.hasAttributes())for(const v of n.getAttributeNames())if(v.endsWith(bl)){const A=g[l++],E=n.getAttribute(v).split(Jr),T=/([.?@])?(.*)/.exec(A);f.push({type:1,index:o,name:T[2],strings:E,ctor:T[1]==="."?md:T[1]==="?"?vd:T[1]==="@"?yd:Jn}),n.removeAttribute(v)}else v.startsWith(Jr)&&(f.push({type:6,index:o}),n.removeAttribute(v));if(dd.test(n.tagName)){const v=n.textContent.split(Jr),A=v.length-1;if(A>0){n.textContent=Xa?Xa.emptyScript:"";for(let E=0;E<A;E++)n.append(v[E],Za()),Xs.nextNode(),f.push({type:2,index:++o});n.append(v[A],Za())}}}else if(n.nodeType===8)if(n.data===Al)f.push({type:2,index:o});else{let v=-1;for(;(v=n.data.indexOf(Jr,v+1))!==-1;)f.push({type:7,index:o}),v+=Jr.length-1}o++}}static createElement(t,e){const i=zs.createElement("template");return i.innerHTML=t,i}};function Zs(s,t,e=s,i){var l,d;if(t===ys)return t;let n=i!==void 0?(l=e._$Co)==null?void 0:l[i]:e._$Cl;const o=qn(t)?void 0:t._$litDirective$;return(n==null?void 0:n.constructor)!==o&&((d=n==null?void 0:n._$AO)==null||d.call(n,!1),o===void 0?n=void 0:(n=new o(s),n._$AT(s,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=n:e._$Cl=n),n!==void 0&&(t=Zs(s,n._$AS(s,t.values),n,i)),t}let gd=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,n=((t==null?void 0:t.creationScope)??zs).importNode(e,!0);Xs.currentNode=n;let o=Xs.nextNode(),l=0,d=0,f=i[0];for(;f!==void 0;){if(l===f.index){let p;f.type===2?p=new kl(o,o.nextSibling,this,t):f.type===1?p=new f.ctor(o,f.name,f.strings,this,t):f.type===6&&(p=new bd(o,this,t)),this._$AV.push(p),f=i[++d]}l!==(f==null?void 0:f.index)&&(o=Xs.nextNode(),l++)}return Xs.currentNode=zs,n}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++}},kl=class x2{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,n){this.type=2,this._$AH=ri,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=n,this._$Cv=(n==null?void 0:n.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=Zs(this,t,e),qn(t)?t===ri||t==null||t===""?(this._$AH!==ri&&this._$AR(),this._$AH=ri):t!==this._$AH&&t!==ys&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):ad(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!==ri&&qn(this._$AH)?this._$AA.nextSibling.data=t:this.$(zs.createTextNode(t)),this._$AH=t}g(t){var o;const{values:e,_$litType$:i}=t,n=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Tl.createElement(fd(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===n)this._$AH.p(e);else{const l=new gd(n,this),d=l.u(this.options);l.p(e),this.$(d),this._$AH=l}}_$AC(t){let e=ud.get(t.strings);return e===void 0&&ud.set(t.strings,e=new Tl(t)),e}T(t){nd(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new x2(this.k(Za()),this.k(Za()),this,this.options)):i=e[n],i._$AI(o),n++;n<e.length&&(this._$AR(i&&i._$AB.nextSibling,n),e.length=n)}_$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 n=t.nextSibling;t.remove(),t=n}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Jn=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,n,o){this.type=1,this._$AH=ri,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ri}_$AI(t,e=this,i,n){const o=this.strings;let l=!1;if(o===void 0)t=Zs(this,t,e,0),l=!qn(t)||t!==this._$AH&&t!==ys,l&&(this._$AH=t);else{const d=t;let f,p;for(t=o[0],f=0;f<o.length-1;f++)p=Zs(this,d[i+f],e,f),p===ys&&(p=this._$AH[f]),l||(l=!qn(p)||p!==this._$AH[f]),p===ri?t=ri:t!==ri&&(t+=(p??"")+o[f+1]),this._$AH[f]=p}l&&!n&&this.O(t)}O(t){t===ri?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},md=class extends Jn{constructor(){super(...arguments),this.type=3}O(t){this.element[this.name]=t===ri?void 0:t}},vd=class extends Jn{constructor(){super(...arguments),this.type=4}O(t){this.element.toggleAttribute(this.name,!!t&&t!==ri)}},yd=class extends Jn{constructor(t,e,i,n,o){super(t,e,i,n,o),this.type=5}_$AI(t,e=this){if((t=Zs(this,t,e,0)??ri)===ys)return;const i=this._$AH,n=t===ri&&i!==ri||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==ri&&(i===ri||n);n&&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)}},bd=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){Zs(this,t)}};const j2={j:bl,P:Jr,A:Al,C:1,M:pd,L:gd,R:ad,V:Zs,D:kl,I:Jn,H:vd,N:yd,U:md,B:bd},wl=Zn.litHtmlPolyfillSupport;wl==null||wl(Tl,kl),(Zn.litHtmlVersions??(Zn.litHtmlVersions=[])).push("3.1.0");/**
13
+ */const Zn=globalThis,Za=Zn.trustedTypes,sd=Za?Za.createPolicy("lit-html",{createHTML:s=>s}):void 0,Al="$lit$",ts=`lit$${(Math.random()+"").slice(9)}$`,El="?"+ts,W2=`<${El}>`,Ys=document,qa=()=>Ys.createComment(""),qn=s=>s===null||typeof s!="object"&&typeof s!="function",nd=Array.isArray,ad=s=>nd(s)||typeof(s==null?void 0:s[Symbol.iterator])=="function",Tl=`[
14
+ \f\r]`,Qn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,od=/-->/g,ld=/>/g,zs=RegExp(`>|${Tl}(?:([^\\s"'>=/]+)(${Tl}*=${Tl}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),cd=/'/g,hd=/"/g,dd=/^(?:script|style|textarea|title)$/i,ys=Symbol.for("lit-noChange"),ri=Symbol.for("lit-nothing"),ud=new WeakMap,Xs=Ys.createTreeWalker(Ys,129);function fd(s,t){if(!Array.isArray(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return sd!==void 0?sd.createHTML(t):t}const pd=(s,t)=>{const e=s.length-1,i=[];let n,o=t===2?"<svg>":"",l=Qn;for(let d=0;d<e;d++){const f=s[d];let p,g,v=-1,A=0;for(;A<f.length&&(l.lastIndex=A,g=l.exec(f),g!==null);)A=l.lastIndex,l===Qn?g[1]==="!--"?l=od:g[1]!==void 0?l=ld:g[2]!==void 0?(dd.test(g[2])&&(n=RegExp("</"+g[2],"g")),l=zs):g[3]!==void 0&&(l=zs):l===zs?g[0]===">"?(l=n??Qn,v=-1):g[1]===void 0?v=-2:(v=l.lastIndex-g[2].length,p=g[1],l=g[3]===void 0?zs:g[3]==='"'?hd:cd):l===hd||l===cd?l=zs:l===od||l===ld?l=Qn:(l=zs,n=void 0);const E=l===zs&&s[d+1].startsWith("/>")?" ":"";o+=l===Qn?f+W2:v>=0?(i.push(p),f.slice(0,v)+Al+f.slice(v)+ts+E):f+ts+(v===-2?d:E)}return[fd(s,o+(s[e]||"<?>")+(t===2?"</svg>":"")),i]};let kl=class x2{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,l=0;const d=t.length-1,f=this.parts,[p,g]=pd(t,e);if(this.el=x2.createElement(p,i),Xs.currentNode=this.el.content,e===2){const v=this.el.content.firstChild;v.replaceWith(...v.childNodes)}for(;(n=Xs.nextNode())!==null&&f.length<d;){if(n.nodeType===1){if(n.hasAttributes())for(const v of n.getAttributeNames())if(v.endsWith(Al)){const A=g[l++],E=n.getAttribute(v).split(ts),T=/([.?@])?(.*)/.exec(A);f.push({type:1,index:o,name:T[2],strings:E,ctor:T[1]==="."?md:T[1]==="?"?vd:T[1]==="@"?yd:Jn}),n.removeAttribute(v)}else v.startsWith(ts)&&(f.push({type:6,index:o}),n.removeAttribute(v));if(dd.test(n.tagName)){const v=n.textContent.split(ts),A=v.length-1;if(A>0){n.textContent=Za?Za.emptyScript:"";for(let E=0;E<A;E++)n.append(v[E],qa()),Xs.nextNode(),f.push({type:2,index:++o});n.append(v[A],qa())}}}else if(n.nodeType===8)if(n.data===El)f.push({type:2,index:o});else{let v=-1;for(;(v=n.data.indexOf(ts,v+1))!==-1;)f.push({type:7,index:o}),v+=ts.length-1}o++}}static createElement(t,e){const i=Ys.createElement("template");return i.innerHTML=t,i}};function Zs(s,t,e=s,i){var l,d;if(t===ys)return t;let n=i!==void 0?(l=e._$Co)==null?void 0:l[i]:e._$Cl;const o=qn(t)?void 0:t._$litDirective$;return(n==null?void 0:n.constructor)!==o&&((d=n==null?void 0:n._$AO)==null||d.call(n,!1),o===void 0?n=void 0:(n=new o(s),n._$AT(s,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=n:e._$Cl=n),n!==void 0&&(t=Zs(s,n._$AS(s,t.values),n,i)),t}let gd=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,n=((t==null?void 0:t.creationScope)??Ys).importNode(e,!0);Xs.currentNode=n;let o=Xs.nextNode(),l=0,d=0,f=i[0];for(;f!==void 0;){if(l===f.index){let p;f.type===2?p=new wl(o,o.nextSibling,this,t):f.type===1?p=new f.ctor(o,f.name,f.strings,this,t):f.type===6&&(p=new bd(o,this,t)),this._$AV.push(p),f=i[++d]}l!==(f==null?void 0:f.index)&&(o=Xs.nextNode(),l++)}return Xs.currentNode=Ys,n}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++}},wl=class D2{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,n){this.type=2,this._$AH=ri,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=n,this._$Cv=(n==null?void 0:n.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=Zs(this,t,e),qn(t)?t===ri||t==null||t===""?(this._$AH!==ri&&this._$AR(),this._$AH=ri):t!==this._$AH&&t!==ys&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):ad(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!==ri&&qn(this._$AH)?this._$AA.nextSibling.data=t:this.$(Ys.createTextNode(t)),this._$AH=t}g(t){var o;const{values:e,_$litType$:i}=t,n=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=kl.createElement(fd(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===n)this._$AH.p(e);else{const l=new gd(n,this),d=l.u(this.options);l.p(e),this.$(d),this._$AH=l}}_$AC(t){let e=ud.get(t.strings);return e===void 0&&ud.set(t.strings,e=new kl(t)),e}T(t){nd(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new D2(this.k(qa()),this.k(qa()),this,this.options)):i=e[n],i._$AI(o),n++;n<e.length&&(this._$AR(i&&i._$AB.nextSibling,n),e.length=n)}_$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 n=t.nextSibling;t.remove(),t=n}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Jn=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,n,o){this.type=1,this._$AH=ri,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ri}_$AI(t,e=this,i,n){const o=this.strings;let l=!1;if(o===void 0)t=Zs(this,t,e,0),l=!qn(t)||t!==this._$AH&&t!==ys,l&&(this._$AH=t);else{const d=t;let f,p;for(t=o[0],f=0;f<o.length-1;f++)p=Zs(this,d[i+f],e,f),p===ys&&(p=this._$AH[f]),l||(l=!qn(p)||p!==this._$AH[f]),p===ri?t=ri:t!==ri&&(t+=(p??"")+o[f+1]),this._$AH[f]=p}l&&!n&&this.O(t)}O(t){t===ri?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},md=class extends Jn{constructor(){super(...arguments),this.type=3}O(t){this.element[this.name]=t===ri?void 0:t}},vd=class extends Jn{constructor(){super(...arguments),this.type=4}O(t){this.element.toggleAttribute(this.name,!!t&&t!==ri)}},yd=class extends Jn{constructor(t,e,i,n,o){super(t,e,i,n,o),this.type=5}_$AI(t,e=this){if((t=Zs(this,t,e,0)??ri)===ys)return;const i=this._$AH,n=t===ri&&i!==ri||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==ri&&(i===ri||n);n&&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)}},bd=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){Zs(this,t)}};const j2={j:Al,P:ts,A:El,C:1,M:pd,L:gd,R:ad,V:Zs,D:wl,I:Jn,H:vd,N:yd,U:md,B:bd},Sl=Zn.litHtmlPolyfillSupport;Sl==null||Sl(kl,wl),(Zn.litHtmlVersions??(Zn.litHtmlVersions=[])).push("3.1.0");/**
16
16
  * @license
17
17
  * Copyright 2019 Google LLC
18
18
  * SPDX-License-Identifier: BSD-3-Clause
19
- */const qa=globalThis,Sl=qa.ShadowRoot&&(qa.ShadyCSS===void 0||qa.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Rl=Symbol(),Ad=new WeakMap;let Ed=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Rl)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=Ad.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Ad.set(e,t))}return t}toString(){return this.cssText}};const ta=s=>new Ed(typeof s=="string"?s:s+"",void 0,Rl),hi=(s,...t)=>{const e=s.length===1?s[0]:t.reduce((i,n,o)=>i+(l=>{if(l._$cssResult$===!0)return l.cssText;if(typeof l=="number")return l;throw Error("Value passed to 'css' function must be a 'css' function result: "+l+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+s[o+1],s[0]);return new Ed(e,s,Rl)},K2=(s,t)=>{if(Sl)s.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),n=qa.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}},Td=Sl?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return ta(e)})(s):s;/**
19
+ */const Qa=globalThis,Rl=Qa.ShadowRoot&&(Qa.ShadyCSS===void 0||Qa.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ll=Symbol(),Ad=new WeakMap;let Ed=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Ll)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(Rl&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=Ad.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Ad.set(e,t))}return t}toString(){return this.cssText}};const ta=s=>new Ed(typeof s=="string"?s:s+"",void 0,Ll),hi=(s,...t)=>{const e=s.length===1?s[0]:t.reduce((i,n,o)=>i+(l=>{if(l._$cssResult$===!0)return l.cssText;if(typeof l=="number")return l;throw Error("Value passed to 'css' function must be a 'css' function result: "+l+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+s[o+1],s[0]);return new Ed(e,s,Ll)},K2=(s,t)=>{if(Rl)s.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),n=Qa.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}},Td=Rl?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return ta(e)})(s):s;/**
20
20
  * @license
21
21
  * Copyright 2017 Google LLC
22
22
  * SPDX-License-Identifier: BSD-3-Clause
23
- */const{is:z2,defineProperty:Y2,getOwnPropertyDescriptor:X2,getOwnPropertyNames:Z2,getOwnPropertySymbols:q2,getPrototypeOf:Q2}=Object,bs=globalThis,kd=bs.trustedTypes,J2=kd?kd.emptyScript:"",_l=bs.reactiveElementPolyfillSupport,ea=(s,t)=>s,Ll={toAttribute(s,t){switch(t){case Boolean:s=s?J2:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let e=s;switch(t){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},wd=(s,t)=>!z2(s,t),Sd={attribute:!0,type:String,converter:Ll,reflect:!1,hasChanged:wd};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),bs.litPropertyMetadata??(bs.litPropertyMetadata=new WeakMap);let bn=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=Sd){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);n!==void 0&&Y2(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=X2(this.prototype,t)??{get(){return this[e]},set(l){this[e]=l}};return{get(){return n==null?void 0:n.call(this)},set(l){const d=n==null?void 0:n.call(this);o.call(this,l),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Sd}static _$Ei(){if(this.hasOwnProperty(ea("elementProperties")))return;const t=Q2(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(ea("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ea("properties"))){const e=this.properties,i=[...Z2(e),...q2(e)];for(const n of i)this.createProperty(n,e[n])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,n]of e)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const n=this._$Eu(e,i);n!==void 0&&this._$Eh.set(n,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 n of i)e.unshift(Td(n))}else t!==void 0&&e.push(Td(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 K2(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),n=this.constructor._$Eu(t,i);if(n!==void 0&&i.reflect===!0){const l=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Ll).toAttribute(e,i.type);this._$Em=t,l==null?this.removeAttribute(n):this.setAttribute(n,l),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,n=i._$Eh.get(t);if(n!==void 0&&this._$Em!==n){const l=i.getPropertyOptions(n),d=typeof l.converter=="function"?{fromAttribute:l.converter}:((o=l.converter)==null?void 0:o.fromAttribute)!==void 0?l.converter:Ll;this._$Em=n,this[n]=d.fromAttribute(e,l.type),this._$Em=null}}requestUpdate(t,e,i,n=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??wd)(n?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,l]of this._$Ep)this[o]=l;this._$Ep=void 0}const n=this.constructor.elementProperties;if(n.size>0)for(const[o,l]of n)l.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],l)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$E_)==null||i.forEach(n=>{var o;return(o=n.hostUpdate)==null?void 0:o.call(n)}),this.update(e)):this._$ET()}catch(n){throw t=!1,this._$ET(),n}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$E_)==null||e.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.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){}};bn.elementStyles=[],bn.shadowRootOptions={mode:"open"},bn[ea("elementProperties")]=new Map,bn[ea("finalized")]=new Map,_l==null||_l({ReactiveElement:bn}),(bs.reactiveElementVersions??(bs.reactiveElementVersions=[])).push("2.0.2");/**
23
+ */const{is:Y2,defineProperty:z2,getOwnPropertyDescriptor:X2,getOwnPropertyNames:Z2,getOwnPropertySymbols:q2,getPrototypeOf:Q2}=Object,bs=globalThis,kd=bs.trustedTypes,J2=kd?kd.emptyScript:"",_l=bs.reactiveElementPolyfillSupport,ea=(s,t)=>s,Cl={toAttribute(s,t){switch(t){case Boolean:s=s?J2:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let e=s;switch(t){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},wd=(s,t)=>!Y2(s,t),Sd={attribute:!0,type:String,converter:Cl,reflect:!1,hasChanged:wd};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),bs.litPropertyMetadata??(bs.litPropertyMetadata=new WeakMap);let bn=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=Sd){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);n!==void 0&&z2(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=X2(this.prototype,t)??{get(){return this[e]},set(l){this[e]=l}};return{get(){return n==null?void 0:n.call(this)},set(l){const d=n==null?void 0:n.call(this);o.call(this,l),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Sd}static _$Ei(){if(this.hasOwnProperty(ea("elementProperties")))return;const t=Q2(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(ea("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ea("properties"))){const e=this.properties,i=[...Z2(e),...q2(e)];for(const n of i)this.createProperty(n,e[n])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,n]of e)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const n=this._$Eu(e,i);n!==void 0&&this._$Eh.set(n,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 n of i)e.unshift(Td(n))}else t!==void 0&&e.push(Td(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 K2(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),n=this.constructor._$Eu(t,i);if(n!==void 0&&i.reflect===!0){const l=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Cl).toAttribute(e,i.type);this._$Em=t,l==null?this.removeAttribute(n):this.setAttribute(n,l),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,n=i._$Eh.get(t);if(n!==void 0&&this._$Em!==n){const l=i.getPropertyOptions(n),d=typeof l.converter=="function"?{fromAttribute:l.converter}:((o=l.converter)==null?void 0:o.fromAttribute)!==void 0?l.converter:Cl;this._$Em=n,this[n]=d.fromAttribute(e,l.type),this._$Em=null}}requestUpdate(t,e,i,n=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??wd)(n?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,l]of this._$Ep)this[o]=l;this._$Ep=void 0}const n=this.constructor.elementProperties;if(n.size>0)for(const[o,l]of n)l.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],l)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$E_)==null||i.forEach(n=>{var o;return(o=n.hostUpdate)==null?void 0:o.call(n)}),this.update(e)):this._$ET()}catch(n){throw t=!1,this._$ET(),n}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$E_)==null||e.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.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){}};bn.elementStyles=[],bn.shadowRootOptions={mode:"open"},bn[ea("elementProperties")]=new Map,bn[ea("finalized")]=new Map,_l==null||_l({ReactiveElement:bn}),(bs.reactiveElementVersions??(bs.reactiveElementVersions=[])).push("2.0.2");/**
24
24
  * @license
25
25
  * Copyright 2017 Google LLC
26
26
  * SPDX-License-Identifier: BSD-3-Clause
27
- */const ia=globalThis,Qa=ia.trustedTypes,Rd=Qa?Qa.createPolicy("lit-html",{createHTML:s=>s}):void 0,_d="$lit$",As=`lit$${(Math.random()+"").slice(9)}$`,Ld="?"+As,tg=`<${Ld}>`,qs=document,ra=()=>qs.createComment(""),sa=s=>s===null||typeof s!="object"&&typeof s!="function",Cd=Array.isArray,eg=s=>Cd(s)||typeof(s==null?void 0:s[Symbol.iterator])=="function",Cl=`[
28
- \f\r]`,na=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Id=/-->/g,Dd=/>/g,Qs=RegExp(`>|${Cl}(?:([^\\s"'>=/]+)(${Cl}*=${Cl}*(?:[^
29
- \f\r"'\`<>=]|("|')|))|$)`,"g"),xd=/'/g,Pd=/"/g,Od=/^(?:script|style|textarea|title)$/i,ig=s=>(t,...e)=>({_$litType$:s,strings:t,values:e}),Xt=ig(1),Es=Symbol.for("lit-noChange"),mi=Symbol.for("lit-nothing"),Md=new WeakMap,Js=qs.createTreeWalker(qs,129);function $d(s,t){if(!Array.isArray(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return Rd!==void 0?Rd.createHTML(t):t}const rg=(s,t)=>{const e=s.length-1,i=[];let n,o=t===2?"<svg>":"",l=na;for(let d=0;d<e;d++){const f=s[d];let p,g,v=-1,A=0;for(;A<f.length&&(l.lastIndex=A,g=l.exec(f),g!==null);)A=l.lastIndex,l===na?g[1]==="!--"?l=Id:g[1]!==void 0?l=Dd:g[2]!==void 0?(Od.test(g[2])&&(n=RegExp("</"+g[2],"g")),l=Qs):g[3]!==void 0&&(l=Qs):l===Qs?g[0]===">"?(l=n??na,v=-1):g[1]===void 0?v=-2:(v=l.lastIndex-g[2].length,p=g[1],l=g[3]===void 0?Qs:g[3]==='"'?Pd:xd):l===Pd||l===xd?l=Qs:l===Id||l===Dd?l=na:(l=Qs,n=void 0);const E=l===Qs&&s[d+1].startsWith("/>")?" ":"";o+=l===na?f+tg:v>=0?(i.push(p),f.slice(0,v)+_d+f.slice(v)+As+E):f+As+(v===-2?d:E)}return[$d(s,o+(s[e]||"<?>")+(t===2?"</svg>":"")),i]};class aa{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,l=0;const d=t.length-1,f=this.parts,[p,g]=rg(t,e);if(this.el=aa.createElement(p,i),Js.currentNode=this.el.content,e===2){const v=this.el.content.firstChild;v.replaceWith(...v.childNodes)}for(;(n=Js.nextNode())!==null&&f.length<d;){if(n.nodeType===1){if(n.hasAttributes())for(const v of n.getAttributeNames())if(v.endsWith(_d)){const A=g[l++],E=n.getAttribute(v).split(As),T=/([.?@])?(.*)/.exec(A);f.push({type:1,index:o,name:T[2],strings:E,ctor:T[1]==="."?ng:T[1]==="?"?ag:T[1]==="@"?og:Ja}),n.removeAttribute(v)}else v.startsWith(As)&&(f.push({type:6,index:o}),n.removeAttribute(v));if(Od.test(n.tagName)){const v=n.textContent.split(As),A=v.length-1;if(A>0){n.textContent=Qa?Qa.emptyScript:"";for(let E=0;E<A;E++)n.append(v[E],ra()),Js.nextNode(),f.push({type:2,index:++o});n.append(v[A],ra())}}}else if(n.nodeType===8)if(n.data===Ld)f.push({type:2,index:o});else{let v=-1;for(;(v=n.data.indexOf(As,v+1))!==-1;)f.push({type:7,index:o}),v+=As.length-1}o++}}static createElement(t,e){const i=qs.createElement("template");return i.innerHTML=t,i}}function An(s,t,e=s,i){var l,d;if(t===Es)return t;let n=i!==void 0?(l=e._$Co)==null?void 0:l[i]:e._$Cl;const o=sa(t)?void 0:t._$litDirective$;return(n==null?void 0:n.constructor)!==o&&((d=n==null?void 0:n._$AO)==null||d.call(n,!1),o===void 0?n=void 0:(n=new o(s),n._$AT(s,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=n:e._$Cl=n),n!==void 0&&(t=An(s,n._$AS(s,t.values),n,i)),t}let sg=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,n=((t==null?void 0:t.creationScope)??qs).importNode(e,!0);Js.currentNode=n;let o=Js.nextNode(),l=0,d=0,f=i[0];for(;f!==void 0;){if(l===f.index){let p;f.type===2?p=new Il(o,o.nextSibling,this,t):f.type===1?p=new f.ctor(o,f.name,f.strings,this,t):f.type===6&&(p=new lg(o,this,t)),this._$AV.push(p),f=i[++d]}l!==(f==null?void 0:f.index)&&(o=Js.nextNode(),l++)}return Js.currentNode=qs,n}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++}},Il=class P2{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,n){this.type=2,this._$AH=mi,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=n,this._$Cv=(n==null?void 0:n.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=An(this,t,e),sa(t)?t===mi||t==null||t===""?(this._$AH!==mi&&this._$AR(),this._$AH=mi):t!==this._$AH&&t!==Es&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):eg(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!==mi&&sa(this._$AH)?this._$AA.nextSibling.data=t:this.$(qs.createTextNode(t)),this._$AH=t}g(t){var o;const{values:e,_$litType$:i}=t,n=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=aa.createElement($d(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===n)this._$AH.p(e);else{const l=new sg(n,this),d=l.u(this.options);l.p(e),this.$(d),this._$AH=l}}_$AC(t){let e=Md.get(t.strings);return e===void 0&&Md.set(t.strings,e=new aa(t)),e}T(t){Cd(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new P2(this.k(ra()),this.k(ra()),this,this.options)):i=e[n],i._$AI(o),n++;n<e.length&&(this._$AR(i&&i._$AB.nextSibling,n),e.length=n)}_$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 n=t.nextSibling;t.remove(),t=n}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}};class Ja{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,n,o){this.type=1,this._$AH=mi,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=mi}_$AI(t,e=this,i,n){const o=this.strings;let l=!1;if(o===void 0)t=An(this,t,e,0),l=!sa(t)||t!==this._$AH&&t!==Es,l&&(this._$AH=t);else{const d=t;let f,p;for(t=o[0],f=0;f<o.length-1;f++)p=An(this,d[i+f],e,f),p===Es&&(p=this._$AH[f]),l||(l=!sa(p)||p!==this._$AH[f]),p===mi?t=mi:t!==mi&&(t+=(p??"")+o[f+1]),this._$AH[f]=p}l&&!n&&this.O(t)}O(t){t===mi?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class ng extends Ja{constructor(){super(...arguments),this.type=3}O(t){this.element[this.name]=t===mi?void 0:t}}let ag=class extends Ja{constructor(){super(...arguments),this.type=4}O(t){this.element.toggleAttribute(this.name,!!t&&t!==mi)}};class og extends Ja{constructor(t,e,i,n,o){super(t,e,i,n,o),this.type=5}_$AI(t,e=this){if((t=An(this,t,e,0)??mi)===Es)return;const i=this._$AH,n=t===mi&&i!==mi||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==mi&&(i===mi||n);n&&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 lg=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){An(this,t)}};const Dl=ia.litHtmlPolyfillSupport;Dl==null||Dl(aa,Il),(ia.litHtmlVersions??(ia.litHtmlVersions=[])).push("3.1.0");const cg=(s,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let n=i._$litPart$;if(n===void 0){const o=(e==null?void 0:e.renderBefore)??null;i._$litPart$=n=new Il(t.insertBefore(ra(),o),o,void 0,e??{})}return n._$AI(s),n};/**
27
+ */const ia=globalThis,Ja=ia.trustedTypes,Rd=Ja?Ja.createPolicy("lit-html",{createHTML:s=>s}):void 0,Ld="$lit$",As=`lit$${(Math.random()+"").slice(9)}$`,_d="?"+As,tg=`<${_d}>`,qs=document,ra=()=>qs.createComment(""),sa=s=>s===null||typeof s!="object"&&typeof s!="function",Cd=Array.isArray,eg=s=>Cd(s)||typeof(s==null?void 0:s[Symbol.iterator])=="function",Il=`[
28
+ \f\r]`,na=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Id=/-->/g,xd=/>/g,Qs=RegExp(`>|${Il}(?:([^\\s"'>=/]+)(${Il}*=${Il}*(?:[^
29
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Dd=/'/g,Pd=/"/g,Od=/^(?:script|style|textarea|title)$/i,ig=s=>(t,...e)=>({_$litType$:s,strings:t,values:e}),Xt=ig(1),Es=Symbol.for("lit-noChange"),mi=Symbol.for("lit-nothing"),Md=new WeakMap,Js=qs.createTreeWalker(qs,129);function $d(s,t){if(!Array.isArray(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return Rd!==void 0?Rd.createHTML(t):t}const rg=(s,t)=>{const e=s.length-1,i=[];let n,o=t===2?"<svg>":"",l=na;for(let d=0;d<e;d++){const f=s[d];let p,g,v=-1,A=0;for(;A<f.length&&(l.lastIndex=A,g=l.exec(f),g!==null);)A=l.lastIndex,l===na?g[1]==="!--"?l=Id:g[1]!==void 0?l=xd:g[2]!==void 0?(Od.test(g[2])&&(n=RegExp("</"+g[2],"g")),l=Qs):g[3]!==void 0&&(l=Qs):l===Qs?g[0]===">"?(l=n??na,v=-1):g[1]===void 0?v=-2:(v=l.lastIndex-g[2].length,p=g[1],l=g[3]===void 0?Qs:g[3]==='"'?Pd:Dd):l===Pd||l===Dd?l=Qs:l===Id||l===xd?l=na:(l=Qs,n=void 0);const E=l===Qs&&s[d+1].startsWith("/>")?" ":"";o+=l===na?f+tg:v>=0?(i.push(p),f.slice(0,v)+Ld+f.slice(v)+As+E):f+As+(v===-2?d:E)}return[$d(s,o+(s[e]||"<?>")+(t===2?"</svg>":"")),i]};class aa{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,l=0;const d=t.length-1,f=this.parts,[p,g]=rg(t,e);if(this.el=aa.createElement(p,i),Js.currentNode=this.el.content,e===2){const v=this.el.content.firstChild;v.replaceWith(...v.childNodes)}for(;(n=Js.nextNode())!==null&&f.length<d;){if(n.nodeType===1){if(n.hasAttributes())for(const v of n.getAttributeNames())if(v.endsWith(Ld)){const A=g[l++],E=n.getAttribute(v).split(As),T=/([.?@])?(.*)/.exec(A);f.push({type:1,index:o,name:T[2],strings:E,ctor:T[1]==="."?ng:T[1]==="?"?ag:T[1]==="@"?og:to}),n.removeAttribute(v)}else v.startsWith(As)&&(f.push({type:6,index:o}),n.removeAttribute(v));if(Od.test(n.tagName)){const v=n.textContent.split(As),A=v.length-1;if(A>0){n.textContent=Ja?Ja.emptyScript:"";for(let E=0;E<A;E++)n.append(v[E],ra()),Js.nextNode(),f.push({type:2,index:++o});n.append(v[A],ra())}}}else if(n.nodeType===8)if(n.data===_d)f.push({type:2,index:o});else{let v=-1;for(;(v=n.data.indexOf(As,v+1))!==-1;)f.push({type:7,index:o}),v+=As.length-1}o++}}static createElement(t,e){const i=qs.createElement("template");return i.innerHTML=t,i}}function An(s,t,e=s,i){var l,d;if(t===Es)return t;let n=i!==void 0?(l=e._$Co)==null?void 0:l[i]:e._$Cl;const o=sa(t)?void 0:t._$litDirective$;return(n==null?void 0:n.constructor)!==o&&((d=n==null?void 0:n._$AO)==null||d.call(n,!1),o===void 0?n=void 0:(n=new o(s),n._$AT(s,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=n:e._$Cl=n),n!==void 0&&(t=An(s,n._$AS(s,t.values),n,i)),t}let sg=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,n=((t==null?void 0:t.creationScope)??qs).importNode(e,!0);Js.currentNode=n;let o=Js.nextNode(),l=0,d=0,f=i[0];for(;f!==void 0;){if(l===f.index){let p;f.type===2?p=new xl(o,o.nextSibling,this,t):f.type===1?p=new f.ctor(o,f.name,f.strings,this,t):f.type===6&&(p=new lg(o,this,t)),this._$AV.push(p),f=i[++d]}l!==(f==null?void 0:f.index)&&(o=Js.nextNode(),l++)}return Js.currentNode=qs,n}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++}},xl=class P2{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,n){this.type=2,this._$AH=mi,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=n,this._$Cv=(n==null?void 0:n.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=An(this,t,e),sa(t)?t===mi||t==null||t===""?(this._$AH!==mi&&this._$AR(),this._$AH=mi):t!==this._$AH&&t!==Es&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):eg(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!==mi&&sa(this._$AH)?this._$AA.nextSibling.data=t:this.$(qs.createTextNode(t)),this._$AH=t}g(t){var o;const{values:e,_$litType$:i}=t,n=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=aa.createElement($d(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===n)this._$AH.p(e);else{const l=new sg(n,this),d=l.u(this.options);l.p(e),this.$(d),this._$AH=l}}_$AC(t){let e=Md.get(t.strings);return e===void 0&&Md.set(t.strings,e=new aa(t)),e}T(t){Cd(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new P2(this.k(ra()),this.k(ra()),this,this.options)):i=e[n],i._$AI(o),n++;n<e.length&&(this._$AR(i&&i._$AB.nextSibling,n),e.length=n)}_$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 n=t.nextSibling;t.remove(),t=n}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}};class to{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,n,o){this.type=1,this._$AH=mi,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=mi}_$AI(t,e=this,i,n){const o=this.strings;let l=!1;if(o===void 0)t=An(this,t,e,0),l=!sa(t)||t!==this._$AH&&t!==Es,l&&(this._$AH=t);else{const d=t;let f,p;for(t=o[0],f=0;f<o.length-1;f++)p=An(this,d[i+f],e,f),p===Es&&(p=this._$AH[f]),l||(l=!sa(p)||p!==this._$AH[f]),p===mi?t=mi:t!==mi&&(t+=(p??"")+o[f+1]),this._$AH[f]=p}l&&!n&&this.O(t)}O(t){t===mi?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class ng extends to{constructor(){super(...arguments),this.type=3}O(t){this.element[this.name]=t===mi?void 0:t}}let ag=class extends to{constructor(){super(...arguments),this.type=4}O(t){this.element.toggleAttribute(this.name,!!t&&t!==mi)}};class og extends to{constructor(t,e,i,n,o){super(t,e,i,n,o),this.type=5}_$AI(t,e=this){if((t=An(this,t,e,0)??mi)===Es)return;const i=this._$AH,n=t===mi&&i!==mi||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==mi&&(i===mi||n);n&&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 lg=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){An(this,t)}};const Dl=ia.litHtmlPolyfillSupport;Dl==null||Dl(aa,xl),(ia.litHtmlVersions??(ia.litHtmlVersions=[])).push("3.1.0");const cg=(s,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let n=i._$litPart$;if(n===void 0){const o=(e==null?void 0:e.renderBefore)??null;i._$litPart$=n=new xl(t.insertBefore(ra(),o),o,void 0,e??{})}return n._$AI(s),n};/**
30
30
  * @license
31
31
  * Copyright 2017 Google LLC
32
32
  * SPDX-License-Identifier: BSD-3-Clause
33
- */let ts=class extends bn{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=cg(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 Es}};ts._$litElement$=!0,ts.finalized=!0,(fp=globalThis.litElementHydrateSupport)==null||fp.call(globalThis,{LitElement:ts});const xl=globalThis.litElementPolyfillSupport;xl==null||xl({LitElement:ts}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.2");/**
33
+ */let es=class extends bn{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=cg(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 Es}};es._$litElement$=!0,es.finalized=!0,(fp=globalThis.litElementHydrateSupport)==null||fp.call(globalThis,{LitElement:es});const Pl=globalThis.litElementPolyfillSupport;Pl==null||Pl({LitElement:es}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.2");/**
34
34
  * @license
35
35
  * Copyright 2017 Google LLC
36
36
  * SPDX-License-Identifier: BSD-3-Clause
37
- */const to=s=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(s,t)}):customElements.define(s,t)};/**
37
+ */const eo=s=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(s,t)}):customElements.define(s,t)};/**
38
38
  * @license
39
39
  * Copyright 2017 Google LLC
40
40
  * SPDX-License-Identifier: BSD-3-Clause
41
- */const hg={attribute:!0,type:String,converter:Ya,reflect:!1,hasChanged:yl},dg=(s=hg,t,e)=>{const{kind:i,metadata:n}=e;let o=globalThis.litPropertyMetadata.get(n);if(o===void 0&&globalThis.litPropertyMetadata.set(n,o=new Map),o.set(e.name,s),i==="accessor"){const{name:l}=e;return{set(d){const f=t.get.call(this);t.set.call(this,d),this.requestUpdate(l,f,s)},init(d){return d!==void 0&&this.C(l,void 0,s),d}}}if(i==="setter"){const{name:l}=e;return function(d){const f=this[l];t.call(this,d),this.requestUpdate(l,f,s)}}throw Error("Unsupported decorator location: "+i)};function Et(s){return(t,e)=>typeof e=="object"?dg(s,t,e):((i,n,o)=>{const l=n.hasOwnProperty(o);return n.constructor.createProperty(o,l?{...i,wrapped:!0}:i),l?Object.getOwnPropertyDescriptor(n,o):void 0})(s,t,e)}/**
41
+ */const hg={attribute:!0,type:String,converter:Xa,reflect:!1,hasChanged:bl},dg=(s=hg,t,e)=>{const{kind:i,metadata:n}=e;let o=globalThis.litPropertyMetadata.get(n);if(o===void 0&&globalThis.litPropertyMetadata.set(n,o=new Map),o.set(e.name,s),i==="accessor"){const{name:l}=e;return{set(d){const f=t.get.call(this);t.set.call(this,d),this.requestUpdate(l,f,s)},init(d){return d!==void 0&&this.C(l,void 0,s),d}}}if(i==="setter"){const{name:l}=e;return function(d){const f=this[l];t.call(this,d),this.requestUpdate(l,f,s)}}throw Error("Unsupported decorator location: "+i)};function Et(s){return(t,e)=>typeof e=="object"?dg(s,t,e):((i,n,o)=>{const l=n.hasOwnProperty(o);return n.constructor.createProperty(o,l?{...i,wrapped:!0}:i),l?Object.getOwnPropertyDescriptor(n,o):void 0})(s,t,e)}/**
42
42
  * @license
43
43
  * Copyright 2017 Google LLC
44
44
  * SPDX-License-Identifier: BSD-3-Clause
@@ -50,7 +50,7 @@ var Y3=Object.defineProperty;var X3=(ie,Qr,Pr)=>Qr in ie?Y3(ie,Qr,{enumerable:!0
50
50
  * @license
51
51
  * Copyright 2020 Google LLC
52
52
  * SPDX-License-Identifier: BSD-3-Clause
53
- */const{D:ug}=j2,fg=s=>s.strings===void 0,Fd=()=>document.createComment(""),oa=(s,t,e)=>{var o;const i=s._$AA.parentNode,n=t===void 0?s._$AB:t._$AA;if(e===void 0){const l=i.insertBefore(Fd(),n),d=i.insertBefore(Fd(),n);e=new ug(l,d,s,s.options)}else{const l=e._$AB.nextSibling,d=e._$AM,f=d!==s;if(f){let p;(o=e._$AQ)==null||o.call(e,s),e._$AM=s,e._$AP!==void 0&&(p=s._$AU)!==d._$AU&&e._$AP(p)}if(l!==n||f){let p=e._$AA;for(;p!==l;){const g=p.nextSibling;i.insertBefore(p,n),p=g}}}return e},tn=(s,t,e=s)=>(s._$AI(t,e),s),pg={},gg=(s,t=pg)=>s._$AH=t,mg=s=>s._$AH,Pl=s=>{var i;(i=s._$AP)==null||i.call(s,!1,!0);let t=s._$AA;const e=s._$AB.nextSibling;for(;t!==e;){const n=t.nextSibling;t.remove(),t=n}};/**
53
+ */const{D:ug}=j2,fg=s=>s.strings===void 0,Fd=()=>document.createComment(""),oa=(s,t,e)=>{var o;const i=s._$AA.parentNode,n=t===void 0?s._$AB:t._$AA;if(e===void 0){const l=i.insertBefore(Fd(),n),d=i.insertBefore(Fd(),n);e=new ug(l,d,s,s.options)}else{const l=e._$AB.nextSibling,d=e._$AM,f=d!==s;if(f){let p;(o=e._$AQ)==null||o.call(e,s),e._$AM=s,e._$AP!==void 0&&(p=s._$AU)!==d._$AU&&e._$AP(p)}if(l!==n||f){let p=e._$AA;for(;p!==l;){const g=p.nextSibling;i.insertBefore(p,n),p=g}}}return e},tn=(s,t,e=s)=>(s._$AI(t,e),s),pg={},gg=(s,t=pg)=>s._$AH=t,mg=s=>s._$AH,Ol=s=>{var i;(i=s._$AP)==null||i.call(s,!1,!0);let t=s._$AA;const e=s._$AB.nextSibling;for(;t!==e;){const n=t.nextSibling;t.remove(),t=n}};/**
54
54
  * @license
55
55
  * Copyright 2017 Google LLC
56
56
  * SPDX-License-Identifier: BSD-3-Clause
@@ -58,40 +58,40 @@ var Y3=Object.defineProperty;var X3=(ie,Qr,Pr)=>Qr in ie?Y3(ie,Qr,{enumerable:!0
58
58
  * @license
59
59
  * Copyright 2017 Google LLC
60
60
  * SPDX-License-Identifier: BSD-3-Clause
61
- */const ca=(s,t)=>{var i;const e=s._$AN;if(e===void 0)return!1;for(const n of e)(i=n._$AO)==null||i.call(n,t,!1),ca(n,t);return!0},eo=s=>{let t,e;do{if((t=s._$AM)===void 0)break;e=t._$AN,e.delete(s),s=t}while((e==null?void 0:e.size)===0)},Nd=s=>{for(let t;t=s._$AM;s=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(s))break;e.add(s),bg(t)}};function vg(s){this._$AN!==void 0?(eo(this),this._$AM=s,Nd(this)):this._$AM=s}function yg(s,t=!1,e=0){const i=this._$AH,n=this._$AN;if(n!==void 0&&n.size!==0)if(t)if(Array.isArray(i))for(let o=e;o<i.length;o++)ca(i[o],!1),eo(i[o]);else i!=null&&(ca(i,!1),eo(i));else ca(this,s)}const bg=s=>{s.type==En.CHILD&&(s._$AP??(s._$AP=yg),s._$AQ??(s._$AQ=vg))};let Ud=class extends la{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),Nd(this),this.isConnected=t._$AU}_$AO(t,e=!0){var i,n;t!==this.isConnected&&(this.isConnected=t,t?(i=this.reconnected)==null||i.call(this):(n=this.disconnected)==null||n.call(this)),e&&(ca(this,t),eo(this))}setValue(t){if(fg(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 ca=(s,t)=>{var i;const e=s._$AN;if(e===void 0)return!1;for(const n of e)(i=n._$AO)==null||i.call(n,t,!1),ca(n,t);return!0},io=s=>{let t,e;do{if((t=s._$AM)===void 0)break;e=t._$AN,e.delete(s),s=t}while((e==null?void 0:e.size)===0)},Nd=s=>{for(let t;t=s._$AM;s=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(s))break;e.add(s),bg(t)}};function vg(s){this._$AN!==void 0?(io(this),this._$AM=s,Nd(this)):this._$AM=s}function yg(s,t=!1,e=0){const i=this._$AH,n=this._$AN;if(n!==void 0&&n.size!==0)if(t)if(Array.isArray(i))for(let o=e;o<i.length;o++)ca(i[o],!1),io(i[o]);else i!=null&&(ca(i,!1),io(i));else ca(this,s)}const bg=s=>{s.type==En.CHILD&&(s._$AP??(s._$AP=yg),s._$AQ??(s._$AQ=vg))};let Ud=class extends la{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),Nd(this),this.isConnected=t._$AU}_$AO(t,e=!0){var i,n;t!==this.isConnected&&(this.isConnected=t,t?(i=this.reconnected)==null||i.call(this):(n=this.disconnected)==null||n.call(this)),e&&(ca(this,t),io(this))}setValue(t){if(fg(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(){}};/**
62
62
  * @license
63
63
  * Copyright 2020 Google LLC
64
64
  * SPDX-License-Identifier: BSD-3-Clause
65
- */const Si=()=>new Ag;let Ag=class{};const Ol=new WeakMap,Ri=Tn(class extends Ud{render(s){return ri}update(s,[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=s.options)==null?void 0:i.host,this.ot(this.lt=s.element)),ri}ot(s){if(typeof this.G=="function"){const t=this.ct??globalThis;let e=Ol.get(t);e===void 0&&(e=new WeakMap,Ol.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ct,void 0),e.set(this.G,s),s!==void 0&&this.G.call(this.ct,s)}else this.G.value=s}get rt(){var s,t;return typeof this.G=="function"?(s=Ol.get(this.ct??globalThis))==null?void 0:s.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 Eg(s,t,e){function i(n){e.dispatchEvent(new CustomEvent(n.type,n))}return t.addEventListener(s,i),()=>{t.removeEventListener(s,i)}}class Tg{constructor(t,e){this._events=[],this._cleanup=[],this._forwardElementRef=Si(),this.host=t,this._events=e,t.addController(this)}register(){return Ri(this._forwardElementRef)}hostConnected(){requestAnimationFrame(()=>{this._events.forEach(t=>{this._forwardElementRef.value&&this._cleanup.push(Eg(t,this._forwardElementRef.value,this.host))})})}hostDisconnected(){this._cleanup.forEach(t=>{t()}),this._cleanup=[]}}/**
65
+ */const Si=()=>new Ag;let Ag=class{};const Ml=new WeakMap,Ri=Tn(class extends Ud{render(s){return ri}update(s,[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=s.options)==null?void 0:i.host,this.ot(this.lt=s.element)),ri}ot(s){if(typeof this.G=="function"){const t=this.ct??globalThis;let e=Ml.get(t);e===void 0&&(e=new WeakMap,Ml.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ct,void 0),e.set(this.G,s),s!==void 0&&this.G.call(this.ct,s)}else this.G.value=s}get rt(){var s,t;return typeof this.G=="function"?(s=Ml.get(this.ct??globalThis))==null?void 0:s.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 Eg(s,t,e){function i(n){e.dispatchEvent(new CustomEvent(n.type,n))}return t.addEventListener(s,i),()=>{t.removeEventListener(s,i)}}class Tg{constructor(t,e){this._events=[],this._cleanup=[],this._forwardElementRef=Si(),this.host=t,this._events=e,t.addController(this)}register(){return Ri(this._forwardElementRef)}hostConnected(){requestAnimationFrame(()=>{this._events.forEach(t=>{this._forwardElementRef.value&&this._cleanup.push(Eg(t,this._forwardElementRef.value,this.host))})})}hostDisconnected(){this._cleanup.forEach(t=>{t()}),this._cleanup=[]}}/**
66
66
  * @license
67
67
  * Copyright 2019 Google LLC
68
68
  * SPDX-License-Identifier: BSD-3-Clause
69
- */const io=globalThis,Ml=io.ShadowRoot&&(io.ShadyCSS===void 0||io.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Bd=Symbol(),Gd=new WeakMap;let kg=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Bd)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(Ml&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=Gd.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Gd.set(e,t))}return t}toString(){return this.cssText}};const wg=s=>new kg(typeof s=="string"?s:s+"",void 0,Bd),Sg=(s,t)=>{if(Ml)s.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),n=io.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}},Vd=Ml?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return wg(e)})(s):s;/**
69
+ */const ro=globalThis,$l=ro.ShadowRoot&&(ro.ShadyCSS===void 0||ro.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Bd=Symbol(),Gd=new WeakMap;let kg=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Bd)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($l&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=Gd.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Gd.set(e,t))}return t}toString(){return this.cssText}};const wg=s=>new kg(typeof s=="string"?s:s+"",void 0,Bd),Sg=(s,t)=>{if($l)s.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),n=ro.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}},Vd=$l?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return wg(e)})(s):s;/**
70
70
  * @license
71
71
  * Copyright 2017 Google LLC
72
72
  * SPDX-License-Identifier: BSD-3-Clause
73
- */const{is:Rg,defineProperty:_g,getOwnPropertyDescriptor:Lg,getOwnPropertyNames:Cg,getOwnPropertySymbols:Ig,getPrototypeOf:Dg}=Object,Ts=globalThis,Hd=Ts.trustedTypes,xg=Hd?Hd.emptyScript:"",$l=Ts.reactiveElementPolyfillSupport,ha=(s,t)=>s,Fl={toAttribute(s,t){switch(t){case Boolean:s=s?xg:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let e=s;switch(t){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},Nl=(s,t)=>!Rg(s,t),Wd={attribute:!0,type:String,converter:Fl,reflect:!1,hasChanged:Nl};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Ts.litPropertyMetadata??(Ts.litPropertyMetadata=new WeakMap);class da 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=Wd){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);n!==void 0&&_g(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=Lg(this.prototype,t)??{get(){return this[e]},set(l){this[e]=l}};return{get(){return n==null?void 0:n.call(this)},set(l){const d=n==null?void 0:n.call(this);o.call(this,l),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Wd}static _$Ei(){if(this.hasOwnProperty(ha("elementProperties")))return;const t=Dg(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(ha("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ha("properties"))){const e=this.properties,i=[...Cg(e),...Ig(e)];for(const n of i)this.createProperty(n,e[n])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,n]of e)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const n=this._$Eu(e,i);n!==void 0&&this._$Eh.set(n,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 n of i)e.unshift(Vd(n))}else t!==void 0&&e.push(Vd(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 Sg(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),n=this.constructor._$Eu(t,i);if(n!==void 0&&i.reflect===!0){const l=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Fl).toAttribute(e,i.type);this._$Em=t,l==null?this.removeAttribute(n):this.setAttribute(n,l),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,n=i._$Eh.get(t);if(n!==void 0&&this._$Em!==n){const l=i.getPropertyOptions(n),d=typeof l.converter=="function"?{fromAttribute:l.converter}:((o=l.converter)==null?void 0:o.fromAttribute)!==void 0?l.converter:Fl;this._$Em=n,this[n]=d.fromAttribute(e,l.type),this._$Em=null}}requestUpdate(t,e,i,n=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??Nl)(n?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,l]of this._$Ep)this[o]=l;this._$Ep=void 0}const n=this.constructor.elementProperties;if(n.size>0)for(const[o,l]of n)l.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],l)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$ES)==null||i.forEach(n=>{var o;return(o=n.hostUpdate)==null?void 0:o.call(n)}),this.update(e)):this._$ET()}catch(n){throw t=!1,this._$ET(),n}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$ES)==null||e.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.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){}}da.elementStyles=[],da.shadowRootOptions={mode:"open"},da[ha("elementProperties")]=new Map,da[ha("finalized")]=new Map,$l==null||$l({ReactiveElement:da}),(Ts.reactiveElementVersions??(Ts.reactiveElementVersions=[])).push("2.0.0");/**
73
+ */const{is:Rg,defineProperty:Lg,getOwnPropertyDescriptor:_g,getOwnPropertyNames:Cg,getOwnPropertySymbols:Ig,getPrototypeOf:xg}=Object,Ts=globalThis,Hd=Ts.trustedTypes,Dg=Hd?Hd.emptyScript:"",Fl=Ts.reactiveElementPolyfillSupport,ha=(s,t)=>s,Nl={toAttribute(s,t){switch(t){case Boolean:s=s?Dg:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let e=s;switch(t){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},Ul=(s,t)=>!Rg(s,t),Wd={attribute:!0,type:String,converter:Nl,reflect:!1,hasChanged:Ul};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Ts.litPropertyMetadata??(Ts.litPropertyMetadata=new WeakMap);class da 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=Wd){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);n!==void 0&&Lg(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=_g(this.prototype,t)??{get(){return this[e]},set(l){this[e]=l}};return{get(){return n==null?void 0:n.call(this)},set(l){const d=n==null?void 0:n.call(this);o.call(this,l),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Wd}static _$Ei(){if(this.hasOwnProperty(ha("elementProperties")))return;const t=xg(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(ha("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ha("properties"))){const e=this.properties,i=[...Cg(e),...Ig(e)];for(const n of i)this.createProperty(n,e[n])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,n]of e)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const n=this._$Eu(e,i);n!==void 0&&this._$Eh.set(n,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 n of i)e.unshift(Vd(n))}else t!==void 0&&e.push(Vd(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 Sg(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),n=this.constructor._$Eu(t,i);if(n!==void 0&&i.reflect===!0){const l=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Nl).toAttribute(e,i.type);this._$Em=t,l==null?this.removeAttribute(n):this.setAttribute(n,l),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,n=i._$Eh.get(t);if(n!==void 0&&this._$Em!==n){const l=i.getPropertyOptions(n),d=typeof l.converter=="function"?{fromAttribute:l.converter}:((o=l.converter)==null?void 0:o.fromAttribute)!==void 0?l.converter:Nl;this._$Em=n,this[n]=d.fromAttribute(e,l.type),this._$Em=null}}requestUpdate(t,e,i,n=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??Ul)(n?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,l]of this._$Ep)this[o]=l;this._$Ep=void 0}const n=this.constructor.elementProperties;if(n.size>0)for(const[o,l]of n)l.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],l)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$ES)==null||i.forEach(n=>{var o;return(o=n.hostUpdate)==null?void 0:o.call(n)}),this.update(e)):this._$ET()}catch(n){throw t=!1,this._$ET(),n}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$ES)==null||e.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.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){}}da.elementStyles=[],da.shadowRootOptions={mode:"open"},da[ha("elementProperties")]=new Map,da[ha("finalized")]=new Map,Fl==null||Fl({ReactiveElement:da}),(Ts.reactiveElementVersions??(Ts.reactiveElementVersions=[])).push("2.0.0");/**
74
74
  * @license
75
75
  * Copyright 2017 Google LLC
76
76
  * SPDX-License-Identifier: BSD-3-Clause
77
- */const Pg=Symbol();class ro{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 n=typeof e=="object"?e:{task:e,args:i};this._=n.task,this.v=n.args,this.j=n.argsEqual??Og,this.m=n.onComplete,this.g=n.onError,this.autoRun=n.autoRun??!0,"initialValue"in n&&(this.l=n.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 l,d,f,p,g;let e,i;t??(t=this.A()),this.k=t,this.status===1?(l=this.T)==null||l.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 n=++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===n){if(e===Pg)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,n,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(n=t.complete)==null?void 0:n.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 Og=(s,t)=>s===t||s.length===t.length&&s.every((e,i)=>!Nl(e,t[i]));let so;const Mg=new Uint8Array(16);function $g(){if(!so&&(so=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!so))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return so(Mg)}const _i=[];for(let s=0;s<256;++s)_i.push((s+256).toString(16).slice(1));function Fg(s,t=0){return _i[s[t+0]]+_i[s[t+1]]+_i[s[t+2]]+_i[s[t+3]]+"-"+_i[s[t+4]]+_i[s[t+5]]+"-"+_i[s[t+6]]+_i[s[t+7]]+"-"+_i[s[t+8]]+_i[s[t+9]]+"-"+_i[s[t+10]]+_i[s[t+11]]+_i[s[t+12]]+_i[s[t+13]]+_i[s[t+14]]+_i[s[t+15]]}const jd={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function en(s,t,e){if(jd.randomUUID&&!t&&!s)return jd.randomUUID();s=s||{};const i=s.random||(s.rng||$g)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let n=0;n<16;++n)t[e+n]=i[n];return t}return Fg(i)}const Kd="https://d2rxhdlm2q91uk.cloudfront.net",Ng="https://d1ix11aj5kfygl.cloudfront.net",Ug="https://d157jlwnudd93d.cloudfront.net",zd="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",Bg="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",Gg="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",Vg="http://localhost:6060/v2",Hg="https://embed-dev.vouchfor.com/v2",Wg="https://embed-staging.vouchfor.com/v2",jg="https://embed.vouchfor.com/v2";function no(s){if(!["local","dev","staging","prod"].includes(s))throw new Error(`Unknown environment: ${s}`);if(s==="local")return{videoUrl:Kd,publicApiUrl:zd,embedApiUrl:Vg};if(s==="dev")return{videoUrl:Kd,publicApiUrl:zd,embedApiUrl:Hg};if(s==="staging")return{videoUrl:Ng,publicApiUrl:Bg,embedApiUrl:Wg};if(s==="prod")return{videoUrl:Ug,publicApiUrl:Gg,embedApiUrl:jg}}class Kg{constructor(t){this._fetching=!1,this.getVouch=async(e,i,n)=>{var g;const{embedApiUrl:o}=no(e),l=en(),d=await fetch(`${o}/vouches/${n}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",l]]}),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"))!==l&&fetch(`${o}/vouches/${n}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.getTemplate=async(e,i,n)=>{var g;const{embedApiUrl:o}=no(e),l=en(),d=await fetch(`${o}/templates/${n}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",l]]}),f=await d.json();return((g=d==null?void 0:d.headers)==null?void 0:g.get("X-Cache-Check"))!==l&&fetch(`${o}/templates/${n}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.host=t,new ro(this.host,async([e,i,n,o,l])=>{var d,f,p,g;try{if(t.vouch=void 0,t.template=void 0,n){let v;l&&(this.fetching=!0,v=await this.getTemplate(e,i,l)),this._vouch=n,t.template=v??((f=(d=n==null?void 0:n.settings)==null?void 0:d.template)==null?void 0:f.instance)}else if(o){this.fetching=!0;const[v,A]=await Promise.all([this.getVouch(e,i,o),l?this.getTemplate(e,i,l):null]);this._vouch=v,t.template=A??((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]),new ro(this.host,([e,i])=>{t.vouch=e?{...e,questions:{items:e==null?void 0:e.questions.items.filter((n,o)=>!(i!=null&&i.length)||(i==null?void 0:i.includes(o+1)))}}:void 0},()=>[this._vouch,t.questions])}set fetching(t){this._fetching!==t&&(this._fetching=t,this.host.requestUpdate())}get fetching(){return this._fetching}}const zg=(s,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const n=Object.getOwnPropertyDescriptor(s,e),o=Object.getOwnPropertyDescriptor(t,e);!Yg(n,o)&&i||Object.defineProperty(s,e,o)},Yg=function(s,t){return s===void 0||s.configurable||s.writable===t.writable&&s.enumerable===t.enumerable&&s.configurable===t.configurable&&(s.writable||s.value===t.value)},Xg=(s,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(s)&&Object.setPrototypeOf(s,e)},Zg=(s,t)=>`/* Wrapped ${s}*/
78
- ${t}`,qg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Qg=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Jg=(s,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,n=Zg.bind(null,i,t.toString());Object.defineProperty(n,"name",Qg),Object.defineProperty(s,"toString",{...qg,value:n})};function tm(s,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=s;for(const n of Reflect.ownKeys(t))zg(s,t,n,e);return Xg(s,t),Jg(s,t,i),s}const em=new WeakMap;function ks(s,{cacheKey:t=([i])=>i,cache:e=new Map}={}){const i=new Map,n=function(...o){const l=t(o);if(i.has(l))return i.get(l);const d=(async()=>{try{if(e&&await e.has(l))return await e.get(l);const p=await s.apply(this,o);try{return p}finally{e&&await e.set(l,p)}}finally{i.delete(l)}})();return i.set(l,d),d};return tm(n,s,{ignoreNonConfigurable:!0}),em.set(n,e),n}var ao=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ul(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Bl={exports:{}};(function(s,t){(function(e,i){i(t)})(ao,function(e){function i(N){var F,j,nt=new Error(N);return F=nt,j=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(F,j):F.__proto__=j,nt}function n(N,F,j){var nt=F.slice(0,j).split(/\n/),ct=nt.length,Lt=nt[ct-1].length+1;throw i(N+=" at line "+ct+" col "+Lt+`:
79
-
80
- `+F.split(/\n/)[ct-1]+`
81
- `+Array(Lt).join(" ")+"^")}i.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var o=new Function("return this")().Promise,l=!1;try{l=new Function("return (async function(){}).constructor")()}catch(N){if(!(N instanceof SyntaxError))throw N}function d(N,F){return Object.prototype.hasOwnProperty.call(N,F)}function f(N,F,j){for(var nt in F)d(F,nt)&&(F[nt]==null||typeof F[nt]!="object"||nt!=="storage"&&nt!=="prefixes"||j?N[nt]=F[nt]:N[nt]=f({},F[nt]));return N}var p=/^async +/,g=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,v=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,A=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,E=/[.*+\-?^${}()|[\]\\]/g;function T(N){return E.test(N)?N.replace(E,"\\$&"):N}function w(N,F){F.rmWhitespace&&(N=N.replace(/[\r\n]+/g,`
82
- `).replace(/^\s+|\s+$/gm,"")),g.lastIndex=0,v.lastIndex=0,A.lastIndex=0;var j=F.prefixes,nt=[j.h,j.b,j.i,j.r,j.c,j.e].reduce(function(_e,Kt){return _e&&Kt?_e+"|"+T(Kt):Kt?T(Kt):_e},""),ct=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+T(F.tags[1])+")","g"),Lt=new RegExp("([^]*?)"+T(F.tags[0])+"(-|_)?\\s*("+nt+")?\\s*","g"),Nt=0,jt=!1;function fe(_e,Kt){var Ae,de={f:[]},Me=0,Ut="c";function ze(Ue){var pi=N.slice(Nt,Ue),Ce=pi.trim();if(Ut==="f")Ce==="safe"?de.raw=!0:F.async&&p.test(Ce)?(Ce=Ce.replace(p,""),de.f.push([Ce,"",!0])):de.f.push([Ce,""]);else if(Ut==="fp")de.f[de.f.length-1][1]+=Ce;else if(Ut==="err"){if(Ce){var Ai=pi.search(/\S/);n("invalid syntax",N,Nt+Ai)}}else de[Ut]=Ce;Nt=Ue+1}for(Kt==="h"||Kt==="b"||Kt==="c"?Ut="n":Kt==="r"&&(de.raw=!0,Kt="i"),ct.lastIndex=Nt;(Ae=ct.exec(N))!==null;){var Fe=Ae[1],Ve=Ae[2],we=Ae[3],ue=Ae[4],Ye=Ae[5],le=Ae.index;if(Fe)Fe==="("?(Me===0&&(Ut==="n"?(ze(le),Ut="p"):Ut==="f"&&(ze(le),Ut="fp")),Me++):Fe===")"?--Me===0&&Ut!=="c"&&(ze(le),Ut="err"):Me===0&&Fe==="|"?(ze(le),Ut="f"):Fe==="=>"&&(ze(le),Nt+=1,Ut="res");else if(Ve)if(Ve==="/*"){var Ne=N.indexOf("*/",ct.lastIndex);Ne===-1&&n("unclosed comment",N,Ae.index),ct.lastIndex=Ne+2}else Ve==="'"?(v.lastIndex=Ae.index,v.exec(N)?ct.lastIndex=v.lastIndex:n("unclosed string",N,Ae.index)):Ve==='"'?(A.lastIndex=Ae.index,A.exec(N)?ct.lastIndex=A.lastIndex:n("unclosed string",N,Ae.index)):Ve==="`"&&(g.lastIndex=Ae.index,g.exec(N)?ct.lastIndex=g.lastIndex:n("unclosed string",N,Ae.index));else if(we)return ze(le),Nt=le+Ae[0].length,Lt.lastIndex=Nt,jt=Ye,ue&&Kt==="h"&&(Kt="s"),de.t=Kt,de}return n("unclosed tag",N,_e),de}var ve=function _e(Kt,Ae){Kt.b=[],Kt.d=[];var de,Me=!1,Ut=[];function ze(Ai,_r){Ai&&(Ai=function(ni,Lr,xs,Ps){var ar,dt;return typeof Lr.autoTrim=="string"?ar=dt=Lr.autoTrim:Array.isArray(Lr.autoTrim)&&(ar=Lr.autoTrim[1],dt=Lr.autoTrim[0]),(xs||xs===!1)&&(ar=xs),(Ps||Ps===!1)&&(dt=Ps),ar==="slurp"&&dt==="slurp"?ni.trim():(ar==="_"||ar==="slurp"?ni=String.prototype.trimLeft?ni.trimLeft():ni.replace(/^[\s\uFEFF\xA0]+/,""):ar!=="-"&&ar!=="nl"||(ni=ni.replace(/^(?:\n|\r|\r\n)/,"")),dt==="_"||dt==="slurp"?ni=String.prototype.trimRight?ni.trimRight():ni.replace(/[\s\uFEFF\xA0]+$/,""):dt!=="-"&&dt!=="nl"||(ni=ni.replace(/(?:\n|\r|\r\n)$/,"")),ni)}(Ai,F,jt,_r))&&(Ai=Ai.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),Ut.push(Ai))}for(;(de=Lt.exec(N))!==null;){var Fe,Ve=de[1],we=de[2],ue=de[3]||"";for(var Ye in j)if(j[Ye]===ue){Fe=Ye;break}ze(Ve,we),Nt=de.index+de[0].length,Fe||n("unrecognized tag type: "+ue,N,Nt);var le=fe(de.index,Fe),Ne=le.t;if(Ne==="h"){var Ue=le.n||"";F.async&&p.test(Ue)&&(le.a=!0,le.n=Ue.replace(p,"")),le=_e(le),Ut.push(le)}else if(Ne==="c"){if(Kt.n===le.n)return Me?(Me.d=Ut,Kt.b.push(Me)):Kt.d=Ut,Kt;n("Helper start and end don't match",N,de.index+de[0].length)}else if(Ne==="b"){Me?(Me.d=Ut,Kt.b.push(Me)):Kt.d=Ut;var pi=le.n||"";F.async&&p.test(pi)&&(le.a=!0,le.n=pi.replace(p,"")),Me=le,Ut=[]}else if(Ne==="s"){var Ce=le.n||"";F.async&&p.test(Ce)&&(le.a=!0,le.n=Ce.replace(p,"")),Ut.push(le)}else Ut.push(le)}if(!Ae)throw i('unclosed helper "'+Kt.n+'"');return ze(N.slice(Nt,N.length),!1),Kt.d=Ut,Kt}({f:[]},!0);if(F.plugins)for(var me=0;me<F.plugins.length;me++){var Ke=F.plugins[me];Ke.processAST&&(ve.d=Ke.processAST(ve.d,F))}return ve.d}function C(N,F){var j=w(N,F),nt="var tR='';"+(F.useWith?"with("+F.varName+"||{}){":"")+H(j,F)+"if(cb){cb(null,tR)} return tR"+(F.useWith?"}":"");if(F.plugins)for(var ct=0;ct<F.plugins.length;ct++){var Lt=F.plugins[ct];Lt.processFnString&&(nt=Lt.processFnString(nt,F))}return nt}function x(N,F){for(var j=0;j<F.length;j++){var nt=F[j][0],ct=F[j][1];N=(F[j][2]?"await ":"")+"c.l('F','"+nt+"')("+N,ct&&(N+=","+ct),N+=")"}return N}function O(N,F,j,nt,ct,Lt){var Nt="{exec:"+(ct?"async ":"")+D(j,F,N)+",params:["+nt+"]";return Lt&&(Nt+=",name:'"+Lt+"'"),ct&&(Nt+=",async:true"),Nt+="}"}function U(N,F){for(var j="[",nt=0;nt<N.length;nt++){var ct=N[nt];j+=O(F,ct.res||"",ct.d,ct.p||"",ct.a,ct.n),nt<N.length&&(j+=",")}return j+="]"}function D(N,F,j){return"function("+F+"){var tR='';"+H(N,j)+"return tR}"}function H(N,F){for(var j=0,nt=N.length,ct="";j<nt;j++){var Lt=N[j];if(typeof Lt=="string")ct+="tR+='"+Lt+"';";else{var Nt=Lt.t,jt=Lt.c||"",fe=Lt.f,ve=Lt.n||"",me=Lt.p||"",Ke=Lt.res||"",_e=Lt.b,Kt=!!Lt.a;if(Nt==="i"){F.defaultFilter&&(jt="c.l('F','"+F.defaultFilter+"')("+jt+")");var Ae=x(jt,fe);!Lt.raw&&F.autoEscape&&(Ae="c.l('F','e')("+Ae+")"),ct+="tR+="+Ae+";"}else if(Nt==="h")if(F.storage.nativeHelpers.get(ve))ct+=F.storage.nativeHelpers.get(ve)(Lt,F);else{var de=(Kt?"await ":"")+"c.l('H','"+ve+"')("+O(F,Ke,Lt.d,me,Kt);de+=_e?","+U(_e,F):",[]",ct+="tR+="+x(de+=",c)",fe)+";"}else Nt==="s"?ct+="tR+="+x((Kt?"await ":"")+"c.l('H','"+ve+"')({params:["+me+"]},[],c)",fe)+";":Nt==="e"&&(ct+=jt+`
83
- `)}}return ct}var $=function(){function N(F){this.cache=F}return N.prototype.define=function(F,j){this.cache[F]=j},N.prototype.get=function(F){return this.cache[F]},N.prototype.remove=function(F){delete this.cache[F]},N.prototype.reset=function(){this.cache={}},N.prototype.load=function(F){f(this.cache,F,!0)},N}();function z(N,F,j,nt){if(F&&F.length>0)throw i((nt?"Native":"")+"Helper '"+N+"' doesn't accept blocks");if(j&&j.length>0)throw i((nt?"Native":"")+"Helper '"+N+"' doesn't accept filters")}var tt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function at(N){return tt[N]}var J=new $({}),St=new $({each:function(N,F){var j="",nt=N.params[0];if(z("each",F,!1),N.async)return new Promise(function(Lt){(function Nt(jt,fe,ve,me,Ke){ve(jt[fe],fe).then(function(_e){me+=_e,fe===jt.length-1?Ke(me):Nt(jt,fe+1,ve,me,Ke)})})(nt,0,N.exec,j,Lt)});for(var ct=0;ct<nt.length;ct++)j+=N.exec(nt[ct],ct);return j},foreach:function(N,F){var j=N.params[0];if(z("foreach",F,!1),N.async)return new Promise(function(Lt){(function Nt(jt,fe,ve,me,Ke,_e){me(fe[ve],jt[fe[ve]]).then(function(Kt){Ke+=Kt,ve===fe.length-1?_e(Ke):Nt(jt,fe,ve+1,me,Ke,_e)})})(j,Object.keys(j),0,N.exec,"",Lt)});var nt="";for(var ct in j)d(j,ct)&&(nt+=N.exec(ct,j[ct]));return nt},include:function(N,F,j){z("include",F,!1);var nt=j.storage.templates.get(N.params[0]);if(!nt)throw i('Could not fetch template "'+N.params[0]+'"');return nt(N.params[1],j)},extends:function(N,F,j){var nt=N.params[1]||{};nt.content=N.exec();for(var ct=0;ct<F.length;ct++){var Lt=F[ct];nt[Lt.name]=Lt.exec()}var Nt=j.storage.templates.get(N.params[0]);if(!Nt)throw i('Could not fetch template "'+N.params[0]+'"');return Nt(nt,j)},useScope:function(N,F){return z("useScope",F,!1),N.exec(N.params[0])}}),mt=new $({if:function(N,F){z("if",!1,N.f,!0);var j="if("+N.p+"){"+H(N.d,F)+"}";if(N.b)for(var nt=0;nt<N.b.length;nt++){var ct=N.b[nt];ct.n==="else"?j+="else{"+H(ct.d,F)+"}":ct.n==="elif"&&(j+="else if("+ct.p+"){"+H(ct.d,F)+"}")}return j},try:function(N,F){if(z("try",!1,N.f,!0),!N.b||N.b.length!==1||N.b[0].n!=="catch")throw i("native helper 'try' only accepts 1 block, 'catch'");var j="try{"+H(N.d,F)+"}",nt=N.b[0];return j+="catch"+(nt.res?"("+nt.res+")":"")+"{"+H(nt.d,F)+"}"},block:function(N,F){return z("block",N.b,N.f,!0),"if(!"+F.varName+"["+N.p+"]){tR+=("+D(N.d,"",F)+")()}else{tR+="+F.varName+"["+N.p+"]}"}}),Ot=new $({e:function(N){var F=String(N);return/[&<>"']/.test(F)?F.replace(/[&<>"']/g,at):F}}),Vt={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(N,F){if(N==="H"){var j=this.storage.helpers.get(F);if(j)return j;throw i("Can't find helper '"+F+"'")}if(N==="F"){var nt=this.storage.filters.get(F);if(nt)return nt;throw i("Can't find filter '"+F+"'")}},async:!1,storage:{helpers:St,nativeHelpers:mt,filters:Ot,templates:J},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function G(N,F){var j={};return f(j,Vt),F&&f(j,F),N&&f(j,N),j.l.bind(j),j}function q(N,F){var j=G(F||{}),nt=Function;if(j.async){if(!l)throw i("This environment doesn't support async/await");nt=l}try{return new nt(j.varName,"c","cb",C(N,j))}catch(ct){throw ct instanceof SyntaxError?i(`Bad template syntax
84
-
85
- `+ct.message+`
86
- `+Array(ct.message.length+1).join("=")+`
87
- `+C(N,j)):ct}}function At(N,F){var j;return F.cache&&F.name&&F.storage.templates.get(F.name)?F.storage.templates.get(F.name):(j=typeof N=="function"?N:q(N,F),F.cache&&F.name&&F.storage.templates.define(F.name,j),j)}Vt.l.bind(Vt),e.compile=q,e.compileScope=H,e.compileScopeIntoFunction=D,e.compileToString=C,e.defaultConfig=Vt,e.filters=Ot,e.getConfig=G,e.helpers=St,e.nativeHelpers=mt,e.parse=w,e.render=function(N,F,j,nt){var ct=G(j||{});if(!ct.async)return At(N,ct)(F,ct);if(!nt){if(typeof o=="function")return new o(function(Lt,Nt){try{Lt(At(N,ct)(F,ct))}catch(jt){Nt(jt)}});throw i("Please provide a callback function, this env doesn't support Promises")}try{At(N,ct)(F,ct,nt)}catch(Lt){return nt(Lt)}},e.templates=J,Object.defineProperty(e,"__esModule",{value:!0})})})(Bl,Bl.exports);var oo=Bl.exports,Gl={exports:{}};(function(s,t){var e=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof ao<"u"&&ao,i=function(){function o(){this.fetch=!1,this.DOMException=e.DOMException}return o.prototype=e,new o}();(function(o){(function(l){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(G){return G&&DataView.prototype.isPrototypeOf(G)}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(G){return G&&g.indexOf(Object.prototype.toString.call(G))>-1};function A(G){if(typeof G!="string"&&(G=String(G)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(G)||G==="")throw new TypeError('Invalid character in header field name: "'+G+'"');return G.toLowerCase()}function E(G){return typeof G!="string"&&(G=String(G)),G}function T(G){var q={next:function(){var At=G.shift();return{done:At===void 0,value:At}}};return f.iterable&&(q[Symbol.iterator]=function(){return q}),q}function w(G){this.map={},G instanceof w?G.forEach(function(q,At){this.append(At,q)},this):Array.isArray(G)?G.forEach(function(q){this.append(q[0],q[1])},this):G&&Object.getOwnPropertyNames(G).forEach(function(q){this.append(q,G[q])},this)}w.prototype.append=function(G,q){G=A(G),q=E(q);var At=this.map[G];this.map[G]=At?At+", "+q:q},w.prototype.delete=function(G){delete this.map[A(G)]},w.prototype.get=function(G){return G=A(G),this.has(G)?this.map[G]:null},w.prototype.has=function(G){return this.map.hasOwnProperty(A(G))},w.prototype.set=function(G,q){this.map[A(G)]=E(q)},w.prototype.forEach=function(G,q){for(var At in this.map)this.map.hasOwnProperty(At)&&G.call(q,this.map[At],At,this)},w.prototype.keys=function(){var G=[];return this.forEach(function(q,At){G.push(At)}),T(G)},w.prototype.values=function(){var G=[];return this.forEach(function(q){G.push(q)}),T(G)},w.prototype.entries=function(){var G=[];return this.forEach(function(q,At){G.push([At,q])}),T(G)},f.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function C(G){if(G.bodyUsed)return Promise.reject(new TypeError("Already read"));G.bodyUsed=!0}function x(G){return new Promise(function(q,At){G.onload=function(){q(G.result)},G.onerror=function(){At(G.error)}})}function O(G){var q=new FileReader,At=x(q);return q.readAsArrayBuffer(G),At}function U(G){var q=new FileReader,At=x(q);return q.readAsText(G),At}function D(G){for(var q=new Uint8Array(G),At=new Array(q.length),N=0;N<q.length;N++)At[N]=String.fromCharCode(q[N]);return At.join("")}function H(G){if(G.slice)return G.slice(0);var q=new Uint8Array(G.byteLength);return q.set(new Uint8Array(G)),q.buffer}function $(){return this.bodyUsed=!1,this._initBody=function(G){this.bodyUsed=this.bodyUsed,this._bodyInit=G,G?typeof G=="string"?this._bodyText=G:f.blob&&Blob.prototype.isPrototypeOf(G)?this._bodyBlob=G:f.formData&&FormData.prototype.isPrototypeOf(G)?this._bodyFormData=G:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(G)?this._bodyText=G.toString():f.arrayBuffer&&f.blob&&p(G)?(this._bodyArrayBuffer=H(G.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(G)||v(G))?this._bodyArrayBuffer=H(G):this._bodyText=G=Object.prototype.toString.call(G):this._bodyText="",this.headers.get("content-type")||(typeof G=="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(G)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var G=C(this);if(G)return G;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 G=C(this);return G||(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(O)}),this.text=function(){var G=C(this);if(G)return G;if(this._bodyBlob)return U(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(D(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(J)}),this.json=function(){return this.text().then(JSON.parse)},this}var z=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function tt(G){var q=G.toUpperCase();return z.indexOf(q)>-1?q:G}function at(G,q){if(!(this instanceof at))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');q=q||{};var At=q.body;if(G instanceof at){if(G.bodyUsed)throw new TypeError("Already read");this.url=G.url,this.credentials=G.credentials,q.headers||(this.headers=new w(G.headers)),this.method=G.method,this.mode=G.mode,this.signal=G.signal,!At&&G._bodyInit!=null&&(At=G._bodyInit,G.bodyUsed=!0)}else this.url=String(G);if(this.credentials=q.credentials||this.credentials||"same-origin",(q.headers||!this.headers)&&(this.headers=new w(q.headers)),this.method=tt(q.method||this.method||"GET"),this.mode=q.mode||this.mode||null,this.signal=q.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&At)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(At),(this.method==="GET"||this.method==="HEAD")&&(q.cache==="no-store"||q.cache==="no-cache")){var N=/([?&])_=[^&]*/;if(N.test(this.url))this.url=this.url.replace(N,"$1_="+new Date().getTime());else{var F=/\?/;this.url+=(F.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}at.prototype.clone=function(){return new at(this,{body:this._bodyInit})};function J(G){var q=new FormData;return G.trim().split("&").forEach(function(At){if(At){var N=At.split("="),F=N.shift().replace(/\+/g," "),j=N.join("=").replace(/\+/g," ");q.append(decodeURIComponent(F),decodeURIComponent(j))}}),q}function St(G){var q=new w,At=G.replace(/\r?\n[\t ]+/g," ");return At.split("\r").map(function(N){return N.indexOf(`
88
- `)===0?N.substr(1,N.length):N}).forEach(function(N){var F=N.split(":"),j=F.shift().trim();if(j){var nt=F.join(":").trim();q.append(j,nt)}}),q}$.call(at.prototype);function mt(G,q){if(!(this instanceof mt))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');q||(q={}),this.type="default",this.status=q.status===void 0?200:q.status,this.ok=this.status>=200&&this.status<300,this.statusText=q.statusText===void 0?"":""+q.statusText,this.headers=new w(q.headers),this.url=q.url||"",this._initBody(G)}$.call(mt.prototype),mt.prototype.clone=function(){return new mt(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new w(this.headers),url:this.url})},mt.error=function(){var G=new mt(null,{status:0,statusText:""});return G.type="error",G};var Ot=[301,302,303,307,308];mt.redirect=function(G,q){if(Ot.indexOf(q)===-1)throw new RangeError("Invalid status code");return new mt(null,{status:q,headers:{location:G}})},l.DOMException=d.DOMException;try{new l.DOMException}catch{l.DOMException=function(q,At){this.message=q,this.name=At;var N=Error(q);this.stack=N.stack},l.DOMException.prototype=Object.create(Error.prototype),l.DOMException.prototype.constructor=l.DOMException}function Vt(G,q){return new Promise(function(At,N){var F=new at(G,q);if(F.signal&&F.signal.aborted)return N(new l.DOMException("Aborted","AbortError"));var j=new XMLHttpRequest;function nt(){j.abort()}j.onload=function(){var Lt={status:j.status,statusText:j.statusText,headers:St(j.getAllResponseHeaders()||"")};Lt.url="responseURL"in j?j.responseURL:Lt.headers.get("X-Request-URL");var Nt="response"in j?j.response:j.responseText;setTimeout(function(){At(new mt(Nt,Lt))},0)},j.onerror=function(){setTimeout(function(){N(new TypeError("Network request failed"))},0)},j.ontimeout=function(){setTimeout(function(){N(new TypeError("Network request failed"))},0)},j.onabort=function(){setTimeout(function(){N(new l.DOMException("Aborted","AbortError"))},0)};function ct(Lt){try{return Lt===""&&d.location.href?d.location.href:Lt}catch{return Lt}}j.open(F.method,ct(F.url),!0),F.credentials==="include"?j.withCredentials=!0:F.credentials==="omit"&&(j.withCredentials=!1),"responseType"in j&&(f.blob?j.responseType="blob":f.arrayBuffer&&F.headers.get("Content-Type")&&F.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(j.responseType="arraybuffer")),q&&typeof q.headers=="object"&&!(q.headers instanceof w)?Object.getOwnPropertyNames(q.headers).forEach(function(Lt){j.setRequestHeader(Lt,E(q.headers[Lt]))}):F.headers.forEach(function(Lt,Nt){j.setRequestHeader(Nt,Lt)}),F.signal&&(F.signal.addEventListener("abort",nt),j.onreadystatechange=function(){j.readyState===4&&F.signal.removeEventListener("abort",nt)}),j.send(typeof F._bodyInit>"u"?null:F._bodyInit)})}return Vt.polyfill=!0,d.fetch||(d.fetch=Vt,d.Headers=w,d.Request=at,d.Response=mt),l.Headers=w,l.Request=at,l.Response=mt,l.fetch=Vt,l})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var n=e.fetch?e:i;t=n.fetch,t.default=n.fetch,t.fetch=n.fetch,t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response,s.exports=t})(Gl,Gl.exports);var im=Gl.exports;const rm=Ul(im);function Vl({canvas:s,scenes:t,currentTime:e}){if(t&&s){const i=t.scenes.filter(({start:o,duration:l})=>e>=o&&e<=o+l);if(i.length<=0)return;const n=s.getContext("2d");if(n){const o=t.transitionDuration,l=Math.max(...t.scenes.map(({start:d,duration:f})=>d+f));n.globalCompositeOperation="lighter",n.clearRect(0,0,s.width,s.height),i.forEach(({start:d,duration:f,draw:p,transitionCanvas:g})=>{if(n.globalAlpha=1,g.width=g.height=0,g.width=s.width,g.height=s.height,g.getContext("2d")){const v=d+f,A=d===0,E=v===l;p({currentTime:e,canvas:g}),!A&&e>=d&&e<=d+o/2?n.globalAlpha=Math.max(0,Math.min(1,(e-d)/(o/2))):!E&&e>=v-o/2&&e<=v&&(n.globalAlpha=Math.max(0,Math.min(1,(v-e)/(o/2)))),n.drawImage(g,0,0,s.width,s.height)}})}}}function sm(s){if(typeof s=="string"){const[t,e]=s.split(":");return Math.min(parseFloat(t),parseFloat(e))}return s}function nm(s){if(typeof s=="string"){const[t,e]=s.split(":"),i=parseFloat(t),n=parseFloat(e);return i/n}return s}function Hl({resolution:s,aspectRatio:t}){const e=sm(s),i=nm(t),n=i>=1,o=Math.min(n?e*i:e/i,e),l=Math.max(n?e*i:e/i,e);return{resolution:e,aspectRatio:i,height:n?o:l,width:n?l:o}}function am({format:s,resolution:t,aspectRatio:e,sourceWidth:i,sourceHeight:n}){const{width:o,height:l}=Hl({resolution:t,aspectRatio:e}),d=i/n,f=e>d;let p=1;if(s==="letterbox"||s==="letterbox-video")p=f?l/n:o/i;else if(s==="squarebox"){const T=Math.min(l,o);p=i>=n?T/n:T/i}else s==="crop"&&(p=f?o/i:l/n);const g=o/p,v=l/p,A=(i-g)/2,E=(n-v)/2;return{sx:A,sy:E,sWidth:g,sHeight:v,scale:p}}function ua({source:s,sx:t,sy:e,sw:i,sh:n,dx:o,dy:l,dw:d,dh:f}){const p=(s==null?void 0:s.naturalWidth)??(s==null?void 0:s.videoWidth)??(s==null?void 0:s.width),g=(s==null?void 0:s.naturalHeight)??(s==null?void 0:s.videoHeight)??(s==null?void 0:s.height);t=t??0,e=e??0,i=i??p,n=n??g,i<0&&(t+=i,i=Math.abs(i)),n<0&&(e+=n,n=Math.abs(n)),d<0&&(o+=d,d=Math.abs(d)),f<0&&(l+=f,f=Math.abs(f));const v=Math.max(t,0),A=Math.min(t+i,p),E=Math.max(e,0),T=Math.min(e+n,g),w=d/i,C=f/n;return[s,v,E,A-v,T-E,t<0?o-t*w:o,e<0?l-e*C:l,(A-v)*w,(T-E)*C]}function Yd({context:s,source:t,crop:e,format:i="letterbox",posX:n,posY:o,drawAreaWidth:l,drawAreaHeight:d,sourceWidth:f,sourceHeight:p,cropCanvas:g,letterboxCanvas:v}){const{x:A,y:E,width:T,height:w}=e??{},C=f*(A??0),x=p*(E??0),O=f*Math.min(1-(A??0),T??1),U=p*Math.min(1-(E??0),w??1),D=g.getContext("2d");if(D){g.width=O,g.height=U;const q=ua({source:t,sx:C,sy:x,sw:O,sh:U,dx:0,dy:0,dw:O,dh:U});D.drawImage(...q)}const H=O/U,{sx:$,sy:z,sWidth:tt,sHeight:at,scale:J}=am({resolution:Math.min(l,d),aspectRatio:l/d,format:i,sourceWidth:O,sourceHeight:U}),St=g&&typeof s.filter<"u";if(i==="letterbox"||i==="squarebox"||i==="letterbox-video"&&!St){if($<0){const q=Math.abs($)*J;s.fillStyle="black",s.beginPath(),s.rect(n,o,q,d),s.rect(n+l-q,o,q,d),s.fill(),s.closePath()}if(z<0){const q=Math.abs(z)*J;s.fillStyle="black",s.beginPath(),s.rect(n,o,l,q),s.rect(n,o+d-q,l,q),s.fill(),s.closePath()}}if(i==="letterbox-video"&&St){const q=v.getContext("2d");if(q){v.width=O,v.height=U,s.save(),s.globalCompositeOperation="destination-out",s.fillRect(n,o,l,d);const At=ua({source:g,sx:$,sy:z,sw:tt,sh:at,dx:n,dy:o,dw:l,dh:d});s.globalCompositeOperation="source-over",s.drawImage(...At),q.save();const N=1.2,F=-(O*N-O)/2,j=-(U*N-U)/2,nt=Math.min(O/20,U/20);if(q.filter=`blur(${nt}px) brightness(20%)`,q.translate(F,j),q.scale(N,N),q.drawImage(g,0,0,O,U),q.restore(),s.globalCompositeOperation="destination-over",$<0){const ct=l/H,Lt=d/ct,Nt=ua({source:v,sy:(1-Lt)*U/2,sh:Lt*U,dx:n,dy:o,dw:l,dh:d});s.drawImage(...Nt)}if(z<0){const ct=d*H,Lt=l/ct,Nt=ua({source:v,sx:(1-Lt)*O/2,sw:Lt*O,dx:n,dy:o,dw:l,dh:d});s.drawImage(...Nt)}s.restore()}}else{const q=ua({source:g,sx:$,sy:z,sw:tt,sh:at,dx:n,dy:o,dw:l,dh:d});s.drawImage(...q)}const mt=$*-1*J,Ot=z*-1*J,Vt=l-mt*2,G=d-Ot*2;return{dx:mt,dy:Ot,dw:Vt,dh:G}}const om=(s,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const n=Object.getOwnPropertyDescriptor(s,e),o=Object.getOwnPropertyDescriptor(t,e);!lm(n,o)&&i||Object.defineProperty(s,e,o)},lm=function(s,t){return s===void 0||s.configurable||s.writable===t.writable&&s.enumerable===t.enumerable&&s.configurable===t.configurable&&(s.writable||s.value===t.value)},cm=(s,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(s)&&Object.setPrototypeOf(s,e)},hm=(s,t)=>`/* Wrapped ${s}*/
89
- ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),fm=(s,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,n=hm.bind(null,i,t.toString());Object.defineProperty(n,"name",um),Object.defineProperty(s,"toString",{...dm,value:n})};function pm(s,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=s;for(const n of Reflect.ownKeys(t))om(s,t,n,e);return cm(s,t),fm(s,t,i),s}const gm=new WeakMap,Xd=new WeakMap;function Zd(s,{cacheKey:t,cache:e=new Map,maxAge:i}={}){if(i===0)return s;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 n=function(...o){var l;const d=t?t(o):o[0],f=e.get(d);if(f)return f.data;const p=s.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);(l=g.unref)==null||l.call(g);const v=Xd.get(s)??new Set;v.add(g),Xd.set(s,v)}return p};return pm(n,s,{ignoreNonConfigurable:!0}),gm.set(n,e),n}function qd({context:s,word:t,maxW:e=1/0}){const i=[],n=s.measureText(t);if(n.width<e)return[{text:t,metrics:n}];for(let o=0;o<t.length;o++){const l=i[i.length-1],d=((l==null?void 0:l.text)??"")+t[o],f=s.measureText(d);f.width<e?i[l?i.length-1:0]={text:d,metrics:f}:i.push({text:t[o],metrics:s.measureText(t[o])})}return i}const Qd=Zd(({font:s,scale:t,context:e,maxW:i,maxH:n,text:o,minSize:l,maxSize:d})=>{var f,p;let g=0;if(d){g=(l??0)*t;let v=0;for(;d*t>g+1;){g+=1;const A=bo({context:e,font:s,fontSize:g,text:o,maxW:i});if(v=A.reduce((E,T)=>(T.metrics.width>E&&(E=T.metrics.width),E),0),v>i||A.length*g>n){g-=1;break}}}else g=parseFloat(((p=(f=s.match(yo))==null?void 0:f.groups)==null?void 0:p.value)??"0")*t;return g},{cacheKey:([{font:s,text:t,minSize:e,maxSize:i,scale:n,maxW:o,maxH:l}])=>`${s}_${t}_${e}_${i}_${n}_${o}_${l}`});function mm(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Te={},Wl={},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 es=function(s){return s[s.Auto=0]="Auto",s[s.FlexStart=1]="FlexStart",s[s.Center=2]="Center",s[s.FlexEnd=3]="FlexEnd",s[s.Stretch=4]="Stretch",s[s.Baseline=5]="Baseline",s[s.SpaceBetween=6]="SpaceBetween",s[s.SpaceAround=7]="SpaceAround",s}({});re.Align=es;let jl=function(s){return s[s.Width=0]="Width",s[s.Height=1]="Height",s}({});re.Dimension=jl;let lo=function(s){return s[s.Inherit=0]="Inherit",s[s.LTR=1]="LTR",s[s.RTL=2]="RTL",s}({});re.Direction=lo;let Kl=function(s){return s[s.Flex=0]="Flex",s[s.None=1]="None",s}({});re.Display=Kl;let Or=function(s){return s[s.Left=0]="Left",s[s.Top=1]="Top",s[s.Right=2]="Right",s[s.Bottom=3]="Bottom",s[s.Start=4]="Start",s[s.End=5]="End",s[s.Horizontal=6]="Horizontal",s[s.Vertical=7]="Vertical",s[s.All=8]="All",s}({});re.Edge=Or;let fa=function(s){return s[s.None=0]="None",s[s.StretchFlexBasis=1]="StretchFlexBasis",s[s.All=2147483647]="All",s[s.Classic=2147483646]="Classic",s}({});re.Errata=fa;let co=function(s){return s[s.WebFlexBasis=0]="WebFlexBasis",s[s.AbsolutePercentageAgainstPaddingEdge=1]="AbsolutePercentageAgainstPaddingEdge",s[s.FixJNILocalRefOverflows=2]="FixJNILocalRefOverflows",s}({});re.ExperimentalFeature=co;let pa=function(s){return s[s.Column=0]="Column",s[s.ColumnReverse=1]="ColumnReverse",s[s.Row=2]="Row",s[s.RowReverse=3]="RowReverse",s}({});re.FlexDirection=pa;let ho=function(s){return s[s.Column=0]="Column",s[s.Row=1]="Row",s[s.All=2]="All",s}({});re.Gutter=ho;let rn=function(s){return s[s.FlexStart=0]="FlexStart",s[s.Center=1]="Center",s[s.FlexEnd=2]="FlexEnd",s[s.SpaceBetween=3]="SpaceBetween",s[s.SpaceAround=4]="SpaceAround",s[s.SpaceEvenly=5]="SpaceEvenly",s}({});re.Justify=rn;let sn=function(s){return s[s.Error=0]="Error",s[s.Warn=1]="Warn",s[s.Info=2]="Info",s[s.Debug=3]="Debug",s[s.Verbose=4]="Verbose",s[s.Fatal=5]="Fatal",s}({});re.LogLevel=sn;let uo=function(s){return s[s.Undefined=0]="Undefined",s[s.Exactly=1]="Exactly",s[s.AtMost=2]="AtMost",s}({});re.MeasureMode=uo;let zl=function(s){return s[s.Default=0]="Default",s[s.Text=1]="Text",s}({});re.NodeType=zl;let fo=function(s){return s[s.Visible=0]="Visible",s[s.Hidden=1]="Hidden",s[s.Scroll=2]="Scroll",s}({});re.Overflow=fo;let po=function(s){return s[s.Static=0]="Static",s[s.Relative=1]="Relative",s[s.Absolute=2]="Absolute",s}({});re.PositionType=po;let go=function(s){return s[s.Layout=1]="Layout",s[s.Style=2]="Style",s[s.Children=4]="Children",s}({});re.PrintOptions=go;let ga=function(s){return s[s.Undefined=0]="Undefined",s[s.Point=1]="Point",s[s.Percent=2]="Percent",s[s.Auto=3]="Auto",s}({});re.Unit=ga;let mo=function(s){return s[s.NoWrap=0]="NoWrap",s[s.Wrap=1]="Wrap",s[s.WrapReverse=2]="WrapReverse",s}({});re.Wrap=mo;var vm={ALIGN_AUTO:es.Auto,ALIGN_FLEX_START:es.FlexStart,ALIGN_CENTER:es.Center,ALIGN_FLEX_END:es.FlexEnd,ALIGN_STRETCH:es.Stretch,ALIGN_BASELINE:es.Baseline,ALIGN_SPACE_BETWEEN:es.SpaceBetween,ALIGN_SPACE_AROUND:es.SpaceAround,DIMENSION_WIDTH:jl.Width,DIMENSION_HEIGHT:jl.Height,DIRECTION_INHERIT:lo.Inherit,DIRECTION_LTR:lo.LTR,DIRECTION_RTL:lo.RTL,DISPLAY_FLEX:Kl.Flex,DISPLAY_NONE:Kl.None,EDGE_LEFT:Or.Left,EDGE_TOP:Or.Top,EDGE_RIGHT:Or.Right,EDGE_BOTTOM:Or.Bottom,EDGE_START:Or.Start,EDGE_END:Or.End,EDGE_HORIZONTAL:Or.Horizontal,EDGE_VERTICAL:Or.Vertical,EDGE_ALL:Or.All,ERRATA_NONE:fa.None,ERRATA_STRETCH_FLEX_BASIS:fa.StretchFlexBasis,ERRATA_ALL:fa.All,ERRATA_CLASSIC:fa.Classic,EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS:co.WebFlexBasis,EXPERIMENTAL_FEATURE_ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE:co.AbsolutePercentageAgainstPaddingEdge,EXPERIMENTAL_FEATURE_FIX_JNILOCAL_REF_OVERFLOWS:co.FixJNILocalRefOverflows,FLEX_DIRECTION_COLUMN:pa.Column,FLEX_DIRECTION_COLUMN_REVERSE:pa.ColumnReverse,FLEX_DIRECTION_ROW:pa.Row,FLEX_DIRECTION_ROW_REVERSE:pa.RowReverse,GUTTER_COLUMN:ho.Column,GUTTER_ROW:ho.Row,GUTTER_ALL:ho.All,JUSTIFY_FLEX_START:rn.FlexStart,JUSTIFY_CENTER:rn.Center,JUSTIFY_FLEX_END:rn.FlexEnd,JUSTIFY_SPACE_BETWEEN:rn.SpaceBetween,JUSTIFY_SPACE_AROUND:rn.SpaceAround,JUSTIFY_SPACE_EVENLY:rn.SpaceEvenly,LOG_LEVEL_ERROR:sn.Error,LOG_LEVEL_WARN:sn.Warn,LOG_LEVEL_INFO:sn.Info,LOG_LEVEL_DEBUG:sn.Debug,LOG_LEVEL_VERBOSE:sn.Verbose,LOG_LEVEL_FATAL:sn.Fatal,MEASURE_MODE_UNDEFINED:uo.Undefined,MEASURE_MODE_EXACTLY:uo.Exactly,MEASURE_MODE_AT_MOST:uo.AtMost,NODE_TYPE_DEFAULT:zl.Default,NODE_TYPE_TEXT:zl.Text,OVERFLOW_VISIBLE:fo.Visible,OVERFLOW_HIDDEN:fo.Hidden,OVERFLOW_SCROLL:fo.Scroll,POSITION_TYPE_STATIC:po.Static,POSITION_TYPE_RELATIVE:po.Relative,POSITION_TYPE_ABSOLUTE:po.Absolute,PRINT_OPTIONS_LAYOUT:go.Layout,PRINT_OPTIONS_STYLE:go.Style,PRINT_OPTIONS_CHILDREN:go.Children,UNIT_UNDEFINED:ga.Undefined,UNIT_POINT:ga.Point,UNIT_PERCENT:ga.Percent,UNIT_AUTO:ga.Auto,WRAP_NO_WRAP:mo.NoWrap,WRAP_WRAP:mo.Wrap,WRAP_WRAP_REVERSE:mo.WrapReverse};re.default=vm,Object.defineProperty(Wl,"__esModule",{value:!0}),Wl.default=bm;var ws=ym(re);function Jd(s){if(typeof WeakMap!="function")return null;var t=new WeakMap,e=new WeakMap;return(Jd=function(i){return i?e:t})(s)}function ym(s,t){if(!t&&s&&s.__esModule)return s;if(s===null||typeof s!="object"&&typeof s!="function")return{default:s};var e=Jd(t);if(e&&e.has(s))return e.get(s);var i={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in s)if(o!=="default"&&Object.prototype.hasOwnProperty.call(s,o)){var l=n?Object.getOwnPropertyDescriptor(s,o):null;l&&(l.get||l.set)?Object.defineProperty(i,o,l):i[o]=s[o]}return i.default=s,e&&e.set(s,i),i}function bm(s){function t(n,o,l){const d=n[o];n[o]=function(){for(var f=arguments.length,p=new Array(f),g=0;g<f;g++)p[g]=arguments[g];return l.call(this,d,...p)}}for(const n of["setPosition","setMargin","setFlexBasis","setWidth","setHeight","setMinWidth","setMinHeight","setMaxWidth","setMaxHeight","setPadding"]){const o={[ws.Unit.Point]:s.Node.prototype[n],[ws.Unit.Percent]:s.Node.prototype[`${n}Percent`],[ws.Unit.Auto]:s.Node.prototype[`${n}Auto`]};t(s.Node.prototype,n,function(l){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,A;if(g==="auto")v=ws.Unit.Auto,A=void 0;else if(typeof g=="object")v=g.unit,A=g.valueOf();else if(v=typeof g=="string"&&g.endsWith("%")?ws.Unit.Percent:ws.Unit.Point,A=parseFloat(g),!Number.isNaN(g)&&Number.isNaN(A))throw new Error(`Invalid value ${g} for ${n}`);if(!o[v])throw new Error(`Failed to execute "${n}": Unsupported unit '${g}'`);return A!==void 0?o[v].call(this,...f,A):o[v].call(this,...f)})}function e(n){return s.MeasureCallback.implement({measure:function(){const{width:o,height:l}=n(...arguments);return{width:o??NaN,height:l??NaN}}})}t(s.Node.prototype,"setMeasureFunc",function(n,o){return o?n.call(this,e(o)):this.unsetMeasureFunc()});function i(n){return s.DirtiedCallback.implement({dirtied:n})}return t(s.Node.prototype,"setDirtiedFunc",function(n,o){n.call(this,i(o))}),t(s.Config.prototype,"free",function(){s.Config.destroy(this)}),t(s.Node,"create",(n,o)=>o?s.Node.createWithConfig(o):s.Node.createDefault()),t(s.Node.prototype,"free",function(){s.Node.destroy(this)}),t(s.Node.prototype,"freeRecursive",function(){for(let n=0,o=this.getChildCount();n<o;++n)this.getChild(0).freeRecursive();this.free()}),t(s.Node.prototype,"calculateLayout",function(n){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:NaN,l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:NaN,d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:ws.Direction.LTR;return n.call(this,o,l,d)}),{Config:s.Config,Node:s.Node,...ws.default}}var tu={exports:{}};(function(s,t){var e=(()=>{var i=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(n){n=n||{};var o;o||(o=typeof n<"u"?n:{});var l,d;o.ready=new Promise(function(_,L){l=_,d=L});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 A;o.wasmBinary&&(A=o.wasmBinary),o.noExitRuntime;function E(){this.buffer=new ArrayBuffer(G/65536*65536)}function T(){}function w(_){this.exports=function(L){function B(ai){return ai.set=function(ae,or){this[ae]=or},ai.get=function(ae){return this[ae]},ai}for(var V,rt=new Uint8Array(123),yt=25;yt>=0;--yt)rt[48+yt]=52+yt,rt[65+yt]=yt,rt[97+yt]=26+yt;rt[43]=62,rt[47]=63;function ht(ai,ae,or){for(var Bi,gt,Hr=0,c=ae,Tt=or.length,Bn=ae+(Tt*3>>2)-(or[Tt-2]=="=")-(or[Tt-1]=="=");Hr<Tt;Hr+=4)Bi=rt[or.charCodeAt(Hr+1)],gt=rt[or.charCodeAt(Hr+2)],ai[c++]=rt[or.charCodeAt(Hr)]<<2|Bi>>4,c<Bn&&(ai[c++]=Bi<<4|gt>>2),c<Bn&&(ai[c++]=gt<<6|rt[or.charCodeAt(Hr+3)])}function _t(ai){ht(V,1024,"T25seSBsZWFmIG5vZGVzIHdpdGggY3VzdG9tIG1lYXN1cmUgZnVuY3Rpb25zIHNob3VsZCBtYW51YWxseSBtYXJrIHRoZW1zZWx2ZXMgYXMgZGlydHkAaXNEaXJ0eQBtYXJrRGlydHkAZGVzdHJveQBzZXREaXNwbGF5AGdldERpc3BsYXkAc2V0RmxleAAtKyAgIDBYMHgALTBYKzBYIDBYLTB4KzB4IDB4AHNldEZsZXhHcm93AGdldEZsZXhHcm93AHNldE92ZXJmbG93AGdldE92ZXJmbG93AGNhbGN1bGF0ZUxheW91dABnZXRDb21wdXRlZExheW91dAB1bnNpZ25lZCBzaG9ydABnZXRDaGlsZENvdW50AHVuc2lnbmVkIGludABzZXRKdXN0aWZ5Q29udGVudABnZXRKdXN0aWZ5Q29udGVudABzZXRBbGlnbkNvbnRlbnQAZ2V0QWxpZ25Db250ZW50AGdldFBhcmVudABpbXBsZW1lbnQAc2V0TWF4SGVpZ2h0UGVyY2VudABzZXRIZWlnaHRQZXJjZW50AHNldE1pbkhlaWdodFBlcmNlbnQAc2V0RmxleEJhc2lzUGVyY2VudABzZXRQb3NpdGlvblBlcmNlbnQAc2V0TWFyZ2luUGVyY2VudABzZXRNYXhXaWR0aFBlcmNlbnQAc2V0V2lkdGhQZXJjZW50AHNldE1pbldpZHRoUGVyY2VudABzZXRQYWRkaW5nUGVyY2VudABjcmVhdGVEZWZhdWx0AHVuaXQAcmlnaHQAaGVpZ2h0AHNldE1heEhlaWdodABnZXRNYXhIZWlnaHQAc2V0SGVpZ2h0AGdldEhlaWdodABzZXRNaW5IZWlnaHQAZ2V0TWluSGVpZ2h0AGdldENvbXB1dGVkSGVpZ2h0AGdldENvbXB1dGVkUmlnaHQAbGVmdABnZXRDb21wdXRlZExlZnQAcmVzZXQAX19kZXN0cnVjdABmbG9hdAB1aW50NjRfdAB1c2VXZWJEZWZhdWx0cwBzZXRVc2VXZWJEZWZhdWx0cwBzZXRBbGlnbkl0ZW1zAGdldEFsaWduSXRlbXMAc2V0RmxleEJhc2lzAGdldEZsZXhCYXNpcwBDYW5ub3QgZ2V0IGxheW91dCBwcm9wZXJ0aWVzIG9mIG11bHRpLWVkZ2Ugc2hvcnRoYW5kcwB1c2VMZWdhY3lTdHJldGNoQmVoYXZpb3VyAHNldFVzZUxlZ2FjeVN0cmV0Y2hCZWhhdmlvdXIAc2V0UG9pbnRTY2FsZUZhY3RvcgBNZWFzdXJlQ2FsbGJhY2tXcmFwcGVyAERpcnRpZWRDYWxsYmFja1dyYXBwZXIAQ2Fubm90IHJlc2V0IGEgbm9kZSBzdGlsbCBhdHRhY2hlZCB0byBhIG93bmVyAHNldEJvcmRlcgBnZXRCb3JkZXIAZ2V0Q29tcHV0ZWRCb3JkZXIAdW5zaWduZWQgY2hhcgB0b3AAZ2V0Q29tcHV0ZWRUb3AAc2V0RmxleFdyYXAAZ2V0RmxleFdyYXAAc2V0R2FwAGdldEdhcAAlcABzZXRIZWlnaHRBdXRvAHNldEZsZXhCYXNpc0F1dG8Ac2V0TWFyZ2luQXV0bwBzZXRXaWR0aEF1dG8AU2NhbGUgZmFjdG9yIHNob3VsZCBub3QgYmUgbGVzcyB0aGFuIHplcm8Ac2V0QXNwZWN0UmF0aW8AZ2V0QXNwZWN0UmF0aW8Ac2V0UG9zaXRpb24AZ2V0UG9zaXRpb24Abm90aWZ5T25EZXN0cnVjdGlvbgBzZXRGbGV4RGlyZWN0aW9uAGdldEZsZXhEaXJlY3Rpb24Ac2V0TWFyZ2luAGdldE1hcmdpbgBnZXRDb21wdXRlZE1hcmdpbgBuYW4AYm90dG9tAGdldENvbXB1dGVkQm90dG9tAGJvb2wAZW1zY3JpcHRlbjo6dmFsAHNldEZsZXhTaHJpbmsAZ2V0RmxleFNocmluawBNZWFzdXJlQ2FsbGJhY2sARGlydGllZENhbGxiYWNrAHdpZHRoAHNldE1heFdpZHRoAGdldE1heFdpZHRoAHNldFdpZHRoAGdldFdpZHRoAHNldE1pbldpZHRoAGdldE1pbldpZHRoAGdldENvbXB1dGVkV2lkdGgAdW5zaWduZWQgbG9uZwBzdGQ6OndzdHJpbmcAc3RkOjpzdHJpbmcAc3RkOjp1MTZzdHJpbmcAc3RkOjp1MzJzdHJpbmcAc2V0UGFkZGluZwBnZXRQYWRkaW5nAGdldENvbXB1dGVkUGFkZGluZwBBdHRlbXB0aW5nIHRvIGNvbnN0cnVjdCBZR05vZGUgd2l0aCBudWxsIGNvbmZpZwBUcmllZCB0byBjb25zdHJ1Y3QgWUdOb2RlIHdpdGggbnVsbCBjb25maWcAY3JlYXRlV2l0aENvbmZpZwBpbmYAc2V0QWxpZ25TZWxmAGdldEFsaWduU2VsZgBTaXplAHZhbHVlAFZhbHVlAGNyZWF0ZQBtZWFzdXJlAHNldFBvc2l0aW9uVHlwZQBnZXRQb3NpdGlvblR5cGUAaXNSZWZlcmVuY2VCYXNlbGluZQBzZXRJc1JlZmVyZW5jZUJhc2VsaW5lAGNvcHlTdHlsZQBkb3VibGUATm9kZQBleHRlbmQAaW5zZXJ0Q2hpbGQAZ2V0Q2hpbGQAcmVtb3ZlQ2hpbGQAdm9pZABhdmFpbGFibGVIZWlnaHQgaXMgaW5kZWZpbml0ZSBzbyBoZWlnaHRNZWFzdXJlTW9kZSBtdXN0IGJlIFlHTWVhc3VyZU1vZGVVbmRlZmluZWQAYXZhaWxhYmxlV2lkdGggaXMgaW5kZWZpbml0ZSBzbyB3aWR0aE1lYXN1cmVNb2RlIG11c3QgYmUgWUdNZWFzdXJlTW9kZVVuZGVmaW5lZABzZXRFeHBlcmltZW50YWxGZWF0dXJlRW5hYmxlZABpc0V4cGVyaW1lbnRhbEZlYXR1cmVFbmFibGVkAGRpcnRpZWQAQ2Fubm90IHJlc2V0IGEgbm9kZSB3aGljaCBzdGlsbCBoYXMgY2hpbGRyZW4gYXR0YWNoZWQAdW5zZXRNZWFzdXJlRnVuYwB1bnNldERpcnRpZWRGdW5jAHNldEVycmF0YQBnZXRFcnJhdGEARXhwZWN0IGN1c3RvbSBiYXNlbGluZSBmdW5jdGlvbiB0byBub3QgcmV0dXJuIE5hTgBOQU4ASU5GAGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHNob3J0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBzaG9ydD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBpbnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGZsb2F0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQ4X3Q+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8Y2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgY2hhcj4Ac3RkOjpiYXNpY19zdHJpbmc8dW5zaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8c2lnbmVkIGNoYXI+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGRvdWJsZT4AQ2hpbGQgYWxyZWFkeSBoYXMgYSBvd25lciwgaXQgbXVzdCBiZSByZW1vdmVkIGZpcnN0LgBDYW5ub3Qgc2V0IG1lYXN1cmUgZnVuY3Rpb246IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAENhbm5vdCBhZGQgY2hpbGQ6IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAChudWxsKQAlcwoAAQAAAAMAAAAAAAAAAgAAAAMAAAABAAAAAgAAAAAAAAABAAAAAQ=="),ht(V,4338,"wH8DAAAAAADAfwAAAABpaQB2AHZp"),ht(V,4368,"exsAAHkbAAC5GwAAsxsAALkbAACzGwAAaWlpZmlmaQCsGwAAfBsAAHZpaQB9GwAAwBsAAGlpaQ=="),ht(V,4432,"xwAAAMgAAADJ"),ht(V,4452,"xwAAAMoAAADLAAAArBs="),ht(V,4480,"exsAALkbAACzGwAAuRsAALMbAADAGwAAuxsAAMAbAABpaWlpAAAAAKwbAACRGwAArBsAAJMbAACUGwAAwBs="),ht(V,4552,"zAAAAM0AAADO"),ht(V,4572,"zAAAAM8AAADLAAAAlxsAAKwbAACXGw=="),ht(V,4608,"rBsAAJcbAACzGwAArRsAAHZpaWlpAAAArBsAAJcbAAC5GwAAdmlpZgAAAACsGwAAlxsAAK0bAAB2aWlpAAAAAKwbAACXGwAAsxsAAK0bAACYGwAAsxsAAK0bAACYGwAAsxsAAJgbAABpAGRpaQB2aWlkAACcGwAAnBsAAJcbAACsGwAAnBsAAKwbAACcGwAAmxsAAKwbAACcGwAAsxsAAKwbAACcGwAAsxsAALobAAB2aWlpZAAAAKwbAACcGwAAuhsAALMbAACdGwAAmhsAAJ0bAACzGwAAmhsAAJ0bAAC6GwAAnRsAALobAACdGwAAsxsAAGRpaWkAAAAAuRsAAJwbAACzGwAAZmlpaQAAAACsGwAAnBsAAJwbAAC0GwAArBsAAJwbAACcGwAAtBsAAJ0bAACcGwAAnBsAAJwbAACcGwAAtBsAAK0bAACcGwAArBsAAJwbAACtGwAArBsAAJwbAAB5GwAArBsAAJwbAACRGwAArRsAAJ0bAAAAAAAArBsAAJwbAAC6GwAAuhsAALMbAAB2aWlkZGkAAJkbAACdGw=="),ht(V,5040,"GQAKABkZGQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAAZABEKGRkZAwoHAAEACQsYAAAJBgsAAAsABhkAAAAZGRk="),ht(V,5121,"DgAAAAAAAAAAGQAKDRkZGQANAAACAAkOAAAACQAOAAAO"),ht(V,5179,"DA=="),ht(V,5191,"EwAAAAATAAAAAAkMAAAAAAAMAAAM"),ht(V,5237,"EA=="),ht(V,5249,"DwAAAAQPAAAAAAkQAAAAAAAQAAAQ"),ht(V,5295,"Eg=="),ht(V,5307,"EQAAAAARAAAAAAkSAAAAAAASAAASAAAaAAAAGhoa"),ht(V,5362,"GgAAABoaGgAAAAAAAAk="),ht(V,5411,"FA=="),ht(V,5423,"FwAAAAAXAAAAAAkUAAAAAAAUAAAU"),ht(V,5469,"Fg=="),ht(V,5481,"FQAAAAAVAAAAAAkWAAAAAAAWAAAWAAAwMTIzNDU2Nzg5QUJDREVG"),ht(V,5556,"1Q=="),ht(V,5596,"//////////8="),ht(V,5664,"8B8BAAAAAAAF"),ht(V,5684,"0A=="),ht(V,5708,"0QAAANIAAADUGw=="),ht(V,5732,"Ag=="),ht(V,5748,"//////////8="),ht(V,5816,"BQ=="),ht(V,5828,"0w=="),ht(V,5852,"0QAAANQAAADoGwAAAAQ="),ht(V,5876,"AQ=="),ht(V,5892,"/////wo="),ht(V,5960,"1g==")}var It=new ArrayBuffer(16),Dt=new Int32Array(It),Ft=new Float32Array(It),zt=new Float64Array(It);function te(ai){return Dt[ai]}function xt(ai,ae){Dt[ai]=ae}function Ee(){return zt[0]}function Ei(ai){zt[0]=ai}function ce(){throw new Error("abort")}function Ji(ai){Ft[2]=ai}function Bt(){return Ft[2]}function al(ai){var ae=ai.a,or=ae.a,Bi=or.buffer;or.grow=z3;var gt=new Int8Array(Bi),Hr=new Int16Array(Bi),c=new Int32Array(Bi),Tt=new Uint8Array(Bi),Bn=new Uint16Array(Bi),Ap=new Uint32Array(Bi),I=new Float32Array(Bi),He=new Float64Array(Bi),We=Math.imul,m=Math.fround,Xe=Math.abs,Er=Math.clz32,HE=Math.min,WE=Math.max,Yt=NaN,Ep=1/0,Rt=ae.b,Ii=ae.c,us=ae.d,fs=ae.e,Fs=ae.f,Gn=ae.g,Ba=ae.h,ol=ae.i,Ih=ae.j,Dh=ae.k,xh=ae.l,Tp=ae.m,kp=ae.n,wp=ae.o,Sp=ae.p,Rp=ae.q,jE=ae.r,KE=ae.s,zE=ae.t,YE=ae.u,XE=ae.v,ZE=ae.w,qE=ae.x,QE=ae.y,JE=ae.z,tT=ae.A,eT=ae.B,iT=ae.C,rT=ae.D,kt=73712,Gi=0;function _p(r,a,h,u,y,b,k,S,P,K,et,ft,Q,it){var M=0,W=m(0),Y=0,Z=m(0),ot=0,lt=m(0),vt=0,bt=m(0),Ct=0,Mt=0,$t=m(0),Ht=0,qt=0,se=m(0),ge=m(0),Ie=m(0),Oe=m(0),$e=0,je=m(0),qe=m(0),oi=0,li=0,wi=m(0),$i=0,er=0,Fi=0,Wi=0,ir=m(0),rr=0,Dr=0,xr=0,Yr=0,Xr=m(0),Zr=0,qr=0,ps=0,gs=0,ms=m(0),Gs=0,Vs=0,Hs=0,Ws=m(0),js=0,Ks=m(0),Ha=0,Wa=m(0),ja=m(0),Ka=m(0),za=0,gl=m(0),zh=0,Yh=m(0),Xh=m(0),Zh=m(0),qh=m(0),Qh=0,k2=0,w2=0,S2=0,R2=0,_2=0,L2=0,C2=0,Qe=0,Je=m(0),zn=m(0);M=kt-384|0,kt=M;t:{r:{i:{if(!(y&&a!=a)){if(!(b&&h!=h)){if(Y=(P?0:4)+et|0,c[Y>>2]=c[Y>>2]+1,Y=c[r+24>>2]&3,zh=(u|0)<=1?1:u,Wi=Y||zh,gt[r+300|0]=Tt[r+300|0]&252|Wi&3,Y=r+252|0,u=((Wi|0)!=1)<<3,Gs=(Wi|0)==2?3:2,lt=he(r,Gs,k),I[Y+u>>2]=lt,ot=Y,Y=((Wi|0)==1)<<3,ge=Se(r,Gs,k),I[ot+Y>>2]=ge,bt=he(r,0,k),I[r+256>>2]=bt,Oe=Se(r,0,k),I[r+264>>2]=Oe,ot=r+268|0,Qe=ot+u|0,Je=pe(r,Gs),I[Qe>>2]=Je,Qe=Y+ot|0,Je=Re(r,Gs),I[Qe>>2]=Je,W=pe(r,0),I[r+272>>2]=W,je=Re(r,0),I[r+280>>2]=je,ot=u,u=r+284|0,Qe=ot+u|0,Je=xe(r,Gs,k),I[Qe>>2]=Je,Qe=u+Y|0,Je=Pe(r,Gs,k),I[Qe>>2]=Je,Z=xe(r,0,k),I[r+288>>2]=Z,$t=Pe(r,0,k),I[r+296>>2]=$t,lt=m(lt+ge),ge=m(bt+Oe),u=c[r+8>>2],u){bt=m(m(m(I[r+284>>2]+I[r+292>>2])+I[r+268>>2])+I[r+276>>2]),h=m(b?h-ge:Yt),W=m(m(Z+$t)+W),Z=m(y?a-lt:Yt),a=Z;e:{if(a!=a)break e;if(a=m(Z-bt),a!=a){a=m(0);break e}a=oe(a,m(0))}lt=m(W+je),W=h;e:{if(h!=h)break e;if(W=m(h-lt),W!=W){W=m(0);break e}W=oe(W,m(0))}if(!((y|0)!=1|(b|0)!=1)){a=Ze(r,2,Z,k),u=a!=a,W=m(m(xe(r,2,k)+pe(r,2))+m(Pe(r,2,k)+Re(r,2)));e:{if(!(u|W!=W)){a=oe(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=Ze(r,0,h,S),u=a!=a,h=m(m(xe(r,0,k)+pe(r,0))+m(Pe(r,0,k)+Re(r,0)));e:{if(!(u|h!=h)){a=oe(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(Tt[r+4|0]&16){Pt[u|0](M+24|0,r,a,y,W,b,0);break e}Pt[u|0](M+24|0,r,a,y,W,b)}c[et+20>>2]=c[et+20>>2]+1,u=(it<<2)+et|0,c[u+24>>2]=c[u+24>>2]+1,a=m(bt+I[M+24>>2]),a=Ze(r,2,y?(y|0)==2?a:Z:a,k),u=a!=a,W=m(m(xe(r,2,k)+pe(r,2))+m(Pe(r,2,k)+Re(r,2)));e:{if(!(u|W!=W)){a=oe(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=m(lt+I[M+28>>2]),a=Ze(r,0,b?(b|0)==2?a:h:a,S),u=a!=a,h=m(m(xe(r,0,k)+pe(r,0))+m(Pe(r,0,k)+Re(r,0)));e:{if(!(u|h!=h)){a=oe(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}if(u=c[r+556>>2],it=c[r+560>>2],(u|0)==(it|0)){ge=m(h-ge),a=Ze(r,2,y&-3?m(a-lt):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(xe(r,2,k)+pe(r,2))+m(Pe(r,2,k)+Re(r,2)));e:{if(!(u|h!=h)){a=oe(a,h);break e}a=u?h:a}I[r+516>>2]=a,a=Ze(r,0,b&-3?ge:m(m(m(Z+$t)+W)+je),S),u=a!=a,h=m(m(xe(r,0,k)+pe(r,0))+m(Pe(r,0,k)+Re(r,0)));e:{if(!(u|h!=h)){a=oe(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(P||(W=m(a-lt),Z=m(h-ge),!(!(!(W<=m(0))|(y|0)!=2)&W==W|!(!(Z<=m(0))|(b|0)!=2)&Z==Z)&((y|0)!=1|(b|0)!=1)))break e;a=Ze(r,2,W!=W||(y|0)==2&&W<m(0)?m(0):W,k),u=a!=a,h=m(m(xe(r,2,k)+pe(r,2))+m(Pe(r,2,k)+Re(r,2)));s:{if(!(u|h!=h)){a=oe(a,h);break s}a=u?h:a}I[r+516>>2]=a,a=Ze(r,0,Z!=Z||(b|0)==2&&Z<m(0)?m(0):Z,S),u=a!=a,h=m(m(xe(r,0,k)+pe(r,0))+m(Pe(r,0,k)+Re(r,0)));s:{if(!(u|h!=h)){a=oe(a,h);break s}a=u?h:a}I[r+520>>2]=a;break t}for(oi=it-u|0,Yr=oi>>2;Y=c[u>>2],c[Y+552>>2]!=(r|0)&&(ot=c[r+568>>2],Y=Gp(c[ot>>2],Tt[ot+8|0],Y,r,Ct,0),c[u>>2]=Y,c[Y+552>>2]=r),Ct=Ct+1|0,u=u+4|0,(it|0)!=(u|0););gt[r+300|0]=Tt[r+300|0]&251,Ct=3,$i=c[r+24>>2],u=$i>>>2&3;e:{s:{n:{if((Wi|0)==2){it=0;a:switch(u-2|0){case 0:break e;case 1:break a;default:break n}Ct=2;break e}if(Ct=2,it=0,u>>>0>1)break s}it=Ct}Ct=u}Yh=m(a-lt),Xr=m(m(xe(r,Ct,k)+pe(r,Ct))+m(Pe(r,Ct,k)+Re(r,Ct))),je=m(xe(r,it,k)+pe(r,it)),ir=m(je+m(Pe(r,it,k)+Re(r,it))),rr=Ct>>>0>1,bt=xp(r,0,Yh,rr?Xr:ir,k),Xh=m(h-ge),qe=xp(r,1,Xh,rr?ir:Xr,S),Oe=rr?qe:bt,ge=rr?bt:qe,Zr=c[r+560>>2],Y=c[r+556>>2],er=rr?y:b;e:{if((er|0)!=1)break e;if((Y|0)==(Zr|0))break i;for(u=Y;;){ot=c[u>>2];s:{if(!qp(ot))break s;if(qt=0,vt)break e;n:{a:{if(!c[ot+552>>2]){W=m(0);break a}if(h=I[ot+32>>2],h!=h&&(W=m(0),h=I[ot+28>>2],!(h>m(0))))break a;if(W=h,h!=h)break n}if(m(Xe(W))<m(9999999747378752e-20))break e}if(a=jn(ot),a!=a){vt=ot;break s}if(vt=ot,m(Xe(a))<m(9999999747378752e-20))break e}if(qt=vt,u=u+4|0,(Zr|0)==(u|0))break}}if((Y|0)==(Zr|0))break i;for(Ha=(Wi|0)<=1?1:Wi,Vs=bt!=bt,qr=Vs|(y|0)!=1,ps=qe==qe,Hs=bt==bt,W=m(0);;){Ht=c[Y>>2],Dp(Ht),ot=c[Ht+24>>2];e:{if(ot&4194304){if(Mp(Ht,0),u=Tt[Ht+4|0],ot=u|1,gt[Ht+4|0]=ot,!(u&4))break e;gt[Ht+4|0]=ot&251;break e}if(P&&(u=ot&3,Vp(Ht,u||Ha,ge,Oe,bt),ot=c[Ht+24>>2]),(ot&196608)==131072)break e;s:{if((Ht|0)==(qt|0)){c[qt+308>>2]=0,c[qt+304>>2]=Q,h=m(0);break s}gs=c[r+24>>2],u=gs>>>2&3;n:{a:{if((Wi|0)!=2)break a;vt=3;o:switch(u-2|0){case 0:break n;case 1:break o;default:break a}vt=2;break n}vt=u}Dr=vt>>>0>1,lt=Dr?bt:qe,h=m(0),a=I[Ht+40>>2];n:{a:{Mt=c[Ht+40>>2];o:{if((Mt|0)==2139156720)break o;if((Mt|0)==2140081935)break a;u=4336;l:{if((Mt|0)!=2141891242){if(a==a)break l;u=4344}h=I[u>>2];c:{h:switch(Mt=c[u+4>>2],Mt|0){case 0:case 3:break h;default:break c}if(a=m(Yt),!(I[Ht+28>>2]>m(0)))break n;Mt=gt[c[Ht+568>>2]+8|0]&1,u=Mt?2143289344:0,Mt=Mt?3:1,h=(xt(2,u),Bt())}switch(a=m(Yt),Mt-1|0){case 0:break a;case 1:break o;default:break n}}if(h=(xt(2,(Mt&-1073741825)+536870912|0),Bt()),!(Mt&1073741824))break a}a=m(m(lt*h)*m(.009999999776482582));break n}a=h}h=I[Ht+572>>2],Mt=0;n:{a:switch($e=c[Ht+576>>2],$e|0){case 0:case 3:break n;default:break a}if(Z=I[Ht+572>>2],!(($e|0)!=1|Z!=Z)){if(h<m(0))break n;Mt=1;break n}if(Mt=1,($e|0)!=2|Z!=Z||(Mt=0,h<m(0)))break n;Mt=Hs}Z=I[Ht+580>>2],u=0;n:{a:switch(li=c[Ht+584>>2],li|0){case 0:case 3:break n;default:break a}if($t=I[Ht+580>>2],!((li|0)!=1|$t!=$t)){if(Z<m(0))break n;u=1;break n}if(u=1,(li|0)!=2|$t!=$t||(u=0,Z<m(0)))break n;u=ps}n:{a:{if(!(a!=a|lt!=lt)){if(h=I[Ht+308>>2],(!(gt[c[Ht+568>>2]+12|0]&1)|c[Ht+304>>2]==(Q|0))&h==h)break n;if(h=m(m(xe(Ht,vt,bt)+pe(Ht,vt))+m(Pe(Ht,vt,bt)+Re(Ht,vt))),!(h<=a)&a<h)break a;h=a;break a}if(Mt&Dr){Z=m(m(xe(Ht,2,bt)+pe(Ht,2))+m(Pe(Ht,2,bt)+Re(Ht,2))),a=m(Yt);o:switch($e-1|0){case 1:h=m(m(bt*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(!(Dr|u^1)){a=m(m(xe(Ht,0,bt)+pe(Ht,0))+m(Pe(Ht,0,bt)+Re(Ht,0))),h=m(Yt);o:switch(li-1|0){case 1:Z=m(m(qe*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(c[M+360>>2]=2143289344,c[M+24>>2]=2143289344,Fi=0,c[M+356>>2]=0,c[M+352>>2]=0,$t=m(he(Ht,2,bt)+Se(Ht,2,bt)),se=he(Ht,0,bt),Ie=Se(Ht,0,bt),lt=m(Yt),xr=0,a=m(Yt),Mt){o:{l:switch($e-1|0){case 0:a=h;break o;case 1:break l;default:break o}a=m(m(bt*h)*m(.009999999776482582))}c[M+356>>2]=1,a=m($t+a),I[M+24>>2]=a,xr=1}if(se=m(se+Ie),u){h=m(Yt);o:{l:switch(li-1|0){case 0:h=Z;break o;case 1:break l;default:break o}h=m(m(qe*Z)*m(.009999999776482582))}c[M+352>>2]=1,lt=m(se+h),I[M+360>>2]=lt,Fi=1}$e=(gs&3145728)==2097152,li=vt>>>0<2;o:{l:{c:{if(!($e&li)){if($e|Vs)break l;if(a!=a)break c;break l}if(Vs|a==a)break o}xr=2,c[M+356>>2]=2,I[M+24>>2]=bt,a=bt}l:{if(!$e||li){if($e|qe!=qe)break o;if(lt!=lt)break l;break o}if(lt==lt|qe!=qe)break o}Fi=2,c[M+352>>2]=2,I[M+360>>2]=qe,lt=qe}h=I[Ht+224>>2],$e=h!=h;o:{if($e)break o;l:{if(!(Dr|(xr|0)!=1)){c[M+352>>2]=1,I[M+360>>2]=se+m(m(a-$t)/h);break l}if(li|(Fi|0)!=1)break o;c[M+356>>2]=1,I[M+24>>2]=m(m(lt-se)*h)+$t}Fi=1,xr=1}ot=ot>>>13&7,ot=ot||gs>>>10&7;o:{if((ot|0)==5|(xr|0)==1|(Dr|(Mt|qr))|(ot|0)!=4||(c[M+356>>2]=1,I[M+24>>2]=bt,$e))break o;Fi=1,c[M+352>>2]=1,I[M+360>>2]=m(bt-$t)/h}o:{if(li|(b|0)!=1|qe!=qe|u|(ot|0)!=4|(Fi|0)==1||(c[M+352>>2]=1,I[M+360>>2]=qe,$e))break o;c[M+356>>2]=1,I[M+24>>2]=m(qe-se)*h}if(Vn(Ht,2,bt,bt,M+356|0,M+24|0),Vn(Ht,0,qe,bt,M+352|0,M+360|0),gn(Ht,I[M+24>>2],I[M+360>>2],Wi,c[M+356>>2],c[M+352>>2],bt,qe,0,5,K,et,ft,Q),a=I[(Ht+(c[(vt<<2)+4320>>2]<<2)|0)+516>>2],u=a!=a,h=m(m(xe(Ht,vt,bt)+pe(Ht,vt))+m(Pe(Ht,vt,bt)+Re(Ht,vt))),!(u|h!=h)){h=oe(a,h);break a}h=u?h:a}I[Ht+308>>2]=h}c[Ht+304>>2]=Q}W=m(W+m(h+m(he(Ht,Ct,bt)+Se(Ht,Ct,bt))))}if(Y=Y+4|0,(Zr|0)==(Y|0))break}break r}c[M>>2]=3072,lr(r,M),tr(),ce()}c[M+16>>2]=3154,lr(r,M+16|0),tr(),ce()}W=m(0)}a=m(W+m(0)),Wa=rr?S:k,Ws=rr?k:S,oi>>>0>=5&&(a=m(m(ll(r,Ct,Oe)*m(Yr-1>>>0))+a)),u=a>ge,Zr=$i&786432,ps=(er|0)==2&&Zr&&u?1:er,Ht=rr?b:y,Dr=(Ht|0)==1,k2=Dr&(P^1),rr=Ct>>>0<2,w2=Ht&-3,Vs=r+208|0,b=it<<2,li=b+4288|0,S2=Dr&!Zr,R2=(Ht|0)!=1|P,Y=Ct<<2,xr=Y+4288|0,Hs=Y+4320|0,gs=Oe==Oe,_2=gs<<1,$e=b+4320|0,L2=!er|!u,Ha=M+52|0,Zh=ll(r,it,Oe),ot=0,u=0,Fi=0;r:{for(;;){er=u,Hi(M+24|0,0,44),u=c[r+560>>2],b=c[r+556>>2];i:{if((u|0)==(b|0))break i;if(u=u-b|0,(u|0)<0)break r;if(Y=Va(M+360|0,u>>2,0,Ha),u=c[M+44>>2],b=c[M+48>>2]-u|0,b=Ns(c[M+364>>2]-b|0,u,b),u=c[M+44>>2],c[M+364>>2]=u,c[M+44>>2]=b,vt=c[M+368>>2],Mt=c[M+372>>2],b=c[M+48>>2],c[M+368>>2]=b,qt=c[M+52>>2],c[M+48>>2]=vt,c[M+52>>2]=Mt,c[M+372>>2]=qt,c[Y>>2]=u,(u|0)!=(b|0)&&(c[M+368>>2]=b+((u-b|0)+3&-4)),!u)break i;Ti(u)}qt=c[r+24>>2],u=qt>>>2&3;i:{e:{if(b=qt&3,((b||zh)|0)!=2)break e;vt=3;s:switch(u-2|0){case 0:break i;case 1:break s;default:break e}vt=2;break i}vt=u}W=ll(r,vt,bt),Y=ot,Mt=c[r+560>>2],b=c[r+556>>2];i:{if(Y>>>0>=Mt-b>>2>>>0)break i;for(qt=qt&786432,h=m(0);;){if(Mt-b>>2>>>0<=Y>>>0)break r;if(u=c[(Y<<2)+b>>2],oi=c[u+24>>2],!(oi&4194304|(oi&196608)==131072)){if(c[u+548>>2]=er,a=he(u,vt,bt),Z=Se(u,vt,bt),b=c[M+24>>2],lt=(Y|0)==(ot|0)?m(0):W,a=m(a+Z),Z=I[u+308>>2],$t=Ze(u,vt,Z,Ws),!(!b||!(m(lt+m(a+m(h+$t)))>ge)|!qt))break i;if(c[M+24>>2]=b+1,lt=m(lt+m(a+$t)),I[M+28>>2]=lt+I[M+28>>2],qp(u)){e:{if(!c[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[M+32>>2]=a+I[M+32>>2],Qe=M,Je=m(I[M+36>>2]-m(jn(u)*Z)),I[Qe+36>>2]=Je}b=c[M+48>>2];e:{if((b|0)!=c[M+52>>2]){c[b>>2]=u,c[M+48>>2]=b+4;break e}if(b=b-c[M+44>>2]|0,oi=b>>2,Mt=oi+1|0,Mt>>>0>=1073741824)break r;if($i=b>>1,Mt=Va(M+360|0,b>>>0>=2147483644?1073741823:Mt>>>0<$i>>>0?$i:Mt,oi,Ha),c[c[M+368>>2]>>2]=u,c[M+368>>2]=c[M+368>>2]+4,u=c[M+44>>2],b=c[M+48>>2]-u|0,b=Ns(c[M+364>>2]-b|0,u,b),u=c[M+44>>2],c[M+364>>2]=u,c[M+44>>2]=b,oi=c[M+368>>2],$i=c[M+372>>2],b=c[M+48>>2],c[M+368>>2]=b,qr=c[M+52>>2],c[M+48>>2]=oi,c[M+52>>2]=$i,c[M+372>>2]=qr,c[Mt>>2]=u,(u|0)!=(b|0)&&(c[M+368>>2]=b+((u-b|0)+3&-4)),!u)break e;Ti(u)}b=c[r+556>>2],Mt=c[r+560>>2],h=m(h+lt)}if(Y=Y+1|0,!(Y>>>0<Mt-b>>2>>>0))break}}Ie=I[M+32>>2],!(Ie>m(0))|!(Ie<m(1))||(c[M+32>>2]=1065353216,Ie=m(1)),wi=I[M+36>>2],!(wi>m(0))|!(wi<m(1))||(c[M+36>>2]=1065353216,wi=m(1)),c[M+40>>2]=Y,$t=I[M+28>>2],vt=c[M+24>>2],Fi&&Ti(Fi),Z=I[M+56>>2],oi=c[M+48>>2],Fi=c[M+44>>2];i:{e:{s:{n:{if((ps|0)==1)break n;h=m(0),a=I[Vs>>2];a:{o:{u=c[Vs>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(a==a)break c;b=4344}switch(h=I[b>>2],a=m(Yt),c[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(xt(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=c[r+216>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(W==W)break c;b=4344}switch(h=I[b>>2],W=m(Yt),c[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(xt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}W=m(m(h*k)*m(.009999999776482582));break a}W=h}h=m(0),lt=I[r+212>>2];a:{o:{u=c[r+212>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(lt==lt)break c;b=4344}switch(h=I[b>>2],lt=m(Yt),c[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(xt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}lt=m(m(h*S)*m(.009999999776482582));break a}lt=h}h=m(0),se=I[r+220>>2];a:{o:{u=c[r+220>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(se==se)break c;b=4344}switch(h=I[b>>2],se=m(Yt),c[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(xt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}se=m(m(h*S)*m(.009999999776482582));break a}se=h}if(u=Ct>>>0>1,h=m((u?a:lt)-Xr),h==h&h>$t||(h=m((u?W:se)-Xr),h==h&h<$t))break s;if(gt[c[r+568>>2]+16|0]&1)break n;if(h=$t,!c[r+552>>2]|Ie==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=ge;break e}a=I[r+32>>2]}if(a!=a&&(h=$t,a=I[r+28>>2],!(a>m(0)))||(h=ge,a!=m(0)))break e;h=$t;break e}h=ge}if(h!=h)break e;Z=m(h-$t);break i}if(!($t<m(0)))break i;Z=m(-$t)}if(ge=h,!k2){i:{if((oi|0)==(Fi|0)){lt=m(0);break i}for(se=m(0),b=Fi;;){u=c[b>>2],$t=I[u+308>>2],h=Ze(u,Ct,$t,Ws);e:{if(Z<m(0)){if(a=m(h*m(-jn(u))),!(a>m(0)|a<m(0)))break e;W=m(m(m(Z/wi)*a)+h),a=Ze(u,Ct,W,ge),Mt=a!=a,lt=m(m(xe(u,Ct,bt)+pe(u,Ct))+m(Pe(u,Ct,bt)+Re(u,Ct)));s:{if(!(Mt|lt!=lt)){a=oe(a,lt);break s}a=Mt?lt:a}if(W!=W|a!=a|a==W)break e;se=m(se+m(a-h)),wi=m(m(jn(u)*$t)+wi);break e}if(!(Z>m(0))|!c[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;lt=m(m(m(Z/Ie)*W)+h),a=Ze(u,Ct,lt,ge),Mt=a!=a,$t=m(m(xe(u,Ct,bt)+pe(u,Ct))+m(Pe(u,Ct,bt)+Re(u,Ct)));s:{if(!(Mt|$t!=$t)){a=oe(a,$t);break s}a=Mt?$t:a}if(lt!=lt|a!=a|a==lt)break e;Ie=m(Ie-W),se=m(se+m(a-h))}if(b=b+4|0,(oi|0)==(b|0))break}for(se=m(Z-se),ja=m(se/wi),Ka=m(se/Ie),za=Dr&(L2|!(Tt[r+26|0]&12)),qr=!za,$i=c[$e>>2],lt=m(0),Mt=Fi;;){u=c[Mt>>2],$t=Ze(u,Ct,I[u+308>>2],Ws);e:{s:{if(se<m(0)){if(W=$t,a=m(W*m(-jn(u))),a==m(0))break e;a=wi==m(0)?m($t+a):m(m(ja*a)+$t);break s}if(W=$t,!(se>m(0))|!c[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(Ka*a)+$t)}if(a=Ze(u,Ct,a,ge),b=a!=a,h=m(m(xe(u,Ct,bt)+pe(u,Ct))+m(Pe(u,Ct,bt)+Re(u,Ct))),!(b|h!=h)){W=oe(a,h);break e}W=b?h:a}a=he(u,Ct,bt),h=Se(u,Ct,bt),Ie=he(u,it,bt),gl=Se(u,it,bt),h=m(a+h),qh=m(W+h),I[M+352>>2]=qh,c[M+344>>2]=1,Ie=m(Ie+gl),a=I[u+224>>2];e:{if(a==a){c[M+348>>2]=1,h=m(qh-h),I[M+356>>2]=Ie+m(rr?h*a:h/a);break e}s:{if(js=Oe!=Oe,js)break s;qt=($i<<3)+u|0,a=I[qt+572>>2];n:{a:{o:{l:switch(b=c[qt+576>>2],b|0){case 0:case 3:break o;default:break l}if(h=I[qt+572>>2],(b|0)!=1|h!=h)break a;if(!(qr|!(a<m(0))))break n;break s}if(!za)break s;break n}if(qr|(!(a<m(0))|((b|0)!=2|h!=h)))break s}if(b=c[u+24>>2]>>>13&7,b||(b=c[r+24>>2]>>>10&7),(b|0)!=4||(vn(M+24|0,u,it),c[M+28>>2]==3)||(mn(M+360|0,u,it),c[M+364>>2]==3))break s;c[M+348>>2]=1,I[M+356>>2]=Oe;break e}qt=($i<<3)+u|0,h=I[qt+572>>2];s:{n:{a:{o:{l:switch(b=c[qt+576>>2],b|0){case 0:case 3:break o;default:break l}if(a=I[qt+572>>2],!((b|0)!=1|a!=a)){if(a=h,a<m(0))break o;break s}if((b|0)!=2|a!=a)break a;if(js)break o;if(!(h<m(0)))break n}c[M+348>>2]=_2,I[M+356>>2]=Oe;break e}a=m(Yt);a:switch(b-1|0){case 1:break n;case 0:break a;default:break s}a=h;break s}a=m(m(Oe*h)*m(.009999999776482582))}a=m(Ie+a),I[M+356>>2]=a,c[M+348>>2]=(Dr|(b|0)!=2)&a==a}Vn(u,Ct,ge,bt,M+344|0,M+352|0),Vn(u,it,Oe,bt,M+348|0,M+356|0),qt=($i<<3)+u|0,a=I[qt+572>>2];e:{s:{n:{a:switch(b=c[qt+576>>2],b|0){case 0:case 3:break n;default:break a}if(h=I[qt+572>>2],!((b|0)!=1|h!=h)){if(a<m(0))break n;break s}if((b|0)!=2|h!=h)break s;if(a<m(0))break n;if(qt=0,gs)break e}if(qt=0,b=c[u+24>>2]>>>13&7,b||(b=c[r+24>>2]>>>10&7),(b|0)!=4||(vn(M+24|0,u,it),c[M+28>>2]==3))break e;mn(M+360|0,u,it),qt=c[M+364>>2]!=3;break e}qt=0}a=I[M+352>>2],h=I[M+356>>2],b=Ct>>>0>1,Ie=b?a:h,a=b?h:a,js=c[M+344>>2],Qh=c[M+348>>2],C2=b?js:Qh,js=b?Qh:js,b=(qt^1)&P,gn(u,Ie,a,Tt[r+300|0]&3,C2,js,bt,qe,b,b?4:7,K,et,ft,Q),lt=m(lt+m(W-$t)),b=Tt[r+300|0];e:{s:{if(b&4){qt=b&251;break s}if(qt=b&251,b=0,!(Tt[u+300|0]&4))break e}b=4}if(gt[r+300|0]=b|qt,Mt=Mt+4|0,(oi|0)==(Mt|0))break}}Z=m(Z-lt)}u=Tt[r+300|0],gt[r+300|0]=u&251|(Z<m(0)?4:u&4),se=m(xe(r,Ct,k)+pe(r,Ct)),ja=m(Pe(r,Ct,k)+Re(r,Ct)),$t=ll(r,Ct,k);i:{if(!(!(Z>m(0))|(ps|0)!=2)){lt=m(0),h=m(0);e:{s:{u=Vs+(c[Hs>>2]<<2)|0,a=I[u>>2],u=c[u>>2],b=(u|0)==2139156720;n:{if(!b){if(Mt=(u|0)==2140081935,Mt)break s;if(qt=(u|0)==2141891242,qt|a!=a)break i;if(Mt)break s;if(qt)break i;if(h=(xt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break n}h=m(m(Ws*h)*m(.009999999776482582))}if(h!=h)break i;h=m(0);n:{if(b)break n;if((u|0)==2140081935)break s;b=4336;a:{if((u|0)!=2141891242){if(a==a)break a;b=4344}switch(h=I[b>>2],W=m(Yt),c[b+4>>2]-1|0){case 0:break s;case 1:break n;default:break e}}if(h=(xt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break s}W=m(m(Ws*h)*m(.009999999776482582));break e}W=h}if(a=m(m(m(W-se)-ja)-m(ge-Z)),a!=a)break i;lt=oe(a,m(0));break i}lt=Z}qt=Y>>>0<=ot>>>0;i:{if(!qt){for(oi=c[r+556>>2],u=c[r+560>>2]-oi>>2,$i=u>>>0<ot>>>0?ot:u,Mt=0,u=ot;;){if((u|0)==($i|0))break r;if(b=c[oi+(u<<2)>>2],(c[b+24>>2]&196608)!=131072&&(qr=M+24|0,vn(qr,b,Ct),za=c[M+28>>2],mn(qr,b,Ct),Mt=(((za|0)==3)+Mt|0)+(c[M+28>>2]==3)|0),u=u+1|0,(Y|0)==(u|0))break}if(Ie=m(0),h=$t,Mt)break i}Ie=m(0),Mt=0,h=$t;e:switch((c[r+24>>2]>>>4&7)-1|0){case 0:Ie=m(lt*m(.5));break i;case 1:Ie=lt;break i;case 2:if(vt>>>0<2)break i;h=m($t+m((Je=m(0),zn=oe(lt,m(0)),Qe=lt!=lt,(Qe?Je:zn)/m(vt-1>>>0))));break i;case 4:Ie=m(lt/m(vt+1>>>0)),h=m($t+Ie);break i;case 3:break e;default:break i}Ie=m(m(lt*m(.5))/m(vt>>>0)),h=m(m(Ie+Ie)+$t)}if(a=m(se+Ie),Z=m(0),oi=Wp(r),qt)h=m(0);else{for($i=Y-1|0,Ka=m(lt/m(Mt|0)),se=m(0),W=m(0),u=ot;;){if(b=c[r+556>>2],c[r+560>>2]-b>>2>>>0<=u>>>0)break r;b=c[b+(u<<2)>>2],vt=b+228|0,Vi(M+24|0,vt,320),h=m(h-((u|0)==($i|0)?$t:m(0))),Mt=c[b+24>>2];i:{if(Mt&4194304)break i;e:{if((Mt&196608)==131072){if(!cr(b,Ct))break e;if(!P)break i;lt=Us(b,Ct,ge),wi=pe(r,Ct),gl=he(b,Ct,bt),I[vt+(c[xr>>2]<<2)>>2]=gl+m(lt+wi);break i}if(vn(M+360|0,b,Ct),a=m(a+(c[M+364>>2]==3?Ka:m(-0))),P&&(Mt=vt,vt=c[xr>>2]<<2,I[Mt+vt>>2]=a+I[vt+(M+24|0)>>2]),mn(M+360|0,b,Ct),a=m(a+(c[M+364>>2]==3?Ka:m(-0))),!R2){a=m(a+m(m(h+m(he(b,Ct,bt)+Se(b,Ct,bt)))+I[M+104>>2])),Z=Oe;break i}if(vt=b+516|0,a=m(a+m(h+m(I[vt+(c[Hs>>2]<<2)>>2]+m(he(b,Ct,bt)+Se(b,Ct,bt))))),oi){lt=cl(b),wi=he(b,0,bt),lt=m(lt+wi),wi=m(m(I[b+520>>2]+m(he(b,0,bt)+Se(b,0,bt)))-lt),b=se!=se;s:{if(!(b|lt!=lt)){se=oe(se,lt);break s}se=b?lt:se}if(b=W!=W,!(b|wi!=wi)){W=oe(W,wi);break i}W=b?wi:W;break i}if(lt=m(I[vt+(c[$e>>2]<<2)>>2]+m(he(b,it,bt)+Se(b,it,bt))),b=Z!=Z,!(lt!=lt|b)){Z=oe(Z,lt);break i}Z=b?lt:Z;break i}if(!P)break i;b=c[xr>>2]<<2,lt=I[b+(M+24|0)>>2],Qe=b+vt|0,Je=m(Ie+m(lt+pe(r,Ct))),I[Qe>>2]=Je}if(u=u+1|0,(Y|0)==(u|0))break}h=m(W+se)}if(Z=oi?h:Z,lt=Oe,!w2){h=Ze(r,it,m(ir+Z),Wa),u=h!=h,W=m(m(xe(r,it,k)+pe(r,it))+m(Pe(r,it,k)+Re(r,it)));i:{if(!(u|W!=W)){h=oe(h,W);break i}h=u?W:h}lt=m(h-ir)}h=Ze(r,it,m(ir+(S2?Oe:Z)),Wa),u=h!=h,W=m(m(xe(r,it,k)+pe(r,it))+m(Pe(r,it,k)+Re(r,it)));i:{if(!(u|W!=W)){h=oe(h,W);break i}h=u?W:h}if(W=m(h-ir),!(qt|!P))for(;;){if(u=c[r+556>>2],c[r+560>>2]-u>>2>>>0<=ot>>>0)break r;vt=c[u+(ot<<2)>>2],u=c[vt+24>>2];i:{if(u&4194304)break i;if((u&196608)==131072){e:{if(!cr(vt,it)){b=c[li>>2];break e}if(h=Us(vt,it,Oe),Z=pe(r,it),$t=he(vt,it,bt),b=c[li>>2],h=m($t+m(h+Z)),I[(vt+(b<<2)|0)+228>>2]=h,h==h)break i}Qe=vt+(b<<2)|0,Je=m(pe(r,it)+he(vt,it,bt)),I[Qe+228>>2]=Je;break i}b=u>>>13&7,b||(b=c[r+24>>2]>>>10&7);e:{s:{if((b|0)==5){b=c[r+24>>2]&8?5:1;break s}if((b|0)!=4||(vn(M+24|0,vt,it),b=4,c[M+28>>2]==3)||(mn(M+360|0,vt,it),c[M+364>>2]==3))break s;b=vt+(c[$e>>2]<<3)|0,Z=I[b+572>>2];n:{a:switch(u=c[b+576>>2],u|0){case 0:case 3:break n;default:break a}if($t=I[b+572>>2],!((u|0)!=1|$t!=$t)){if(h=je,Z<m(0))break n;break e}if(h=je,gs&!(Z<m(0))|((u|0)!=2|$t!=$t))break e}Z=I[(vt+(c[Hs>>2]<<2)|0)+516>>2],h=W,$t=I[vt+224>>2],$t==$t&&(h=m(m(he(vt,it,bt)+Se(vt,it,bt))+m(rr?Z*$t:Z/$t))),I[M+360>>2]=h,Qe=M,Je=m(Z+m(he(vt,Ct,bt)+Se(vt,Ct,bt))),I[Qe+24>>2]=Je,c[M+356>>2]=1,c[M+352>>2]=1,Vn(vt,Ct,ge,bt,M+356|0,M+24|0),Vn(vt,it,Oe,bt,M+352|0,M+360|0),Z=I[M+360>>2],$t=I[M+24>>2],u=Ct>>>0>1,h=u?Z:$t,Z=u?$t:Z,u=(Zr|0)!=0&(c[r+24>>2]&896)!=512,gn(vt,Z,h,Wi,!(u&rr|Z!=Z),(!u|rr)&h==h,bt,qe,1,2,K,et,ft,Q),h=je;break e}h=I[(vt+(c[$e>>2]<<2)|0)+516>>2],Z=he(vt,it,bt),$t=Se(vt,it,bt),vn(M+24|0,vt,it),Z=m(lt-m(h+m(Z+$t)));s:{if(c[M+28>>2]!=3||(mn(M+360|0,vt,it),c[M+364>>2]!=3))break s;h=m(Z*m(.5)),h=m(je+(Je=m(0),zn=oe(h,m(0)),Qe=h!=h,Qe?Je:zn));break e}if(mn(M+24|0,vt,it),h=je,c[M+28>>2]==3)break e;if(vn(M+24|0,vt,it),c[M+28>>2]==3){h=m(je+(Je=m(0),zn=oe(Z,m(0)),Qe=Z!=Z,Qe?Je:zn));break e}s:switch(b-1|0){case 1:h=m(je+m(Z*m(.5)));break e;case 0:break e;default:break s}h=m(je+Z)}u=vt+(c[li>>2]<<2)|0,I[u+228>>2]=h+m(ms+I[u+228>>2])}if(ot=ot+1|0,(ot|0)==(Y|0))break}h=m((er?Zh:m(0))+W),u=Ks!=Ks,a=m(ja+a);i:{if(!(u|a!=a)){Ks=oe(Ks,a);break i}Ks=u?a:Ks}if(ms=m(ms+h),u=er+1|0,ot=Y,!(Yr>>>0>Y>>>0))break}i:{if(!P||!Zr&&!Wp(r))break i;se=m(0);e:{s:{if(Oe!=Oe)break s;a=m(Oe-ms);n:switch((c[r+24>>2]>>>7&7)-2|0){case 0:je=m(je+m(a*m(.5)));break s;case 2:if(!(Oe>ms))break s;se=m(a/m(u>>>0));break s;case 5:if(Oe>ms){if(je=m(je+m(a/m(u<<1>>>0))),u>>>0<2)break s;se=m(a/m(u>>>0));break e}je=m(je+m(a*m(.5)));break s;case 4:if(!(Oe>ms)|u>>>0<2)break s;se=m(a/m(er>>>0));break e;case 1:break n;default:break s}je=m(je+a)}if(!u)break i}for(Mt=0,u=0,b=0;;){if(Z=m(0),h=m(0),a=m(0),W=m(0),Y=u,Yr>>>0>u>>>0){e:{for(;;){if(b=c[r+556>>2],c[r+560>>2]-b>>2>>>0<=Y>>>0)break r;ot=c[b+(Y<<2)>>2],vt=c[ot+24>>2];s:{if(vt&4194304|(vt&196608)==131072)break s;if(b=Y,c[ot+548>>2]!=(Mt|0))break e;a=I[(ot+(c[$e>>2]<<2)|0)+516>>2];n:{if(!(a>=m(0)))break n;if(b=h!=h,a=m(a+m(he(ot,it,bt)+Se(ot,it,bt))),!(b|a!=a)){h=oe(h,a);break n}h=b?a:h}if(b=vt>>>13&7,b||(b=c[r+24>>2]>>>10&7),!(Tt[r+24|0]&8)|(b|0)!=5)break s;a=cl(ot),lt=he(ot,0,bt),a=m(a+lt),lt=m(m(I[ot+520>>2]+m(he(ot,0,bt)+Se(ot,0,bt)))-a),b=h!=h,ot=W!=W;n:{if(!(ot|a!=a)){W=oe(W,a);break n}W=ot?a:W}ot=Z!=Z;n:{if(!(ot|lt!=lt)){Z=oe(Z,lt);break n}Z=ot?lt:Z}if(a=m(W+Z),!(b|a!=a)){h=oe(h,a);break s}h=b?a:h}if(Y=Y+1|0,(Yr|0)==(Y|0))break}b=Yr}a=h}if(lt=m(je+(Mt?Zh:m(0))),h=m(se+a),je=m(lt+h),u>>>0<b>>>0)for($t=m(lt+W);;){if(Y=c[r+556>>2],c[r+560>>2]-Y>>2>>>0<=u>>>0)break r;ot=c[Y+(u<<2)>>2],Y=c[ot+24>>2];e:{if(Y&4194304|(Y&196608)==131072)break e;Y=Y>>>13&7,Y||(Y=c[r+24>>2]>>>10&7);s:{n:switch(Y-1|0){case 4:if(Tt[r+24|0]&8)break s;case 0:a=he(ot,it,bt),I[(ot+(c[li>>2]<<2)|0)+228>>2]=lt+a;break e;case 2:a=Se(ot,it,bt),Y=ot+228|0,I[Y+(c[li>>2]<<2)>>2]=m(je-a)-I[(Y+(c[$e>>2]<<2)|0)+288>>2];break e;case 1:Y=ot+228|0,I[Y+(c[li>>2]<<2)>>2]=lt+m(m(h-I[(Y+(c[$e>>2]<<2)|0)+288>>2])*m(.5));break e;case 3:break n;default:break e}a=he(ot,it,bt),I[(ot+(c[li>>2]<<2)|0)+228>>2]=lt+a,vt=ot+(c[$e>>2]<<3)|0,a=I[vt+572>>2];n:{a:switch(Y=c[vt+576>>2],Y|0){case 0:case 3:break n;default:break a}if(W=I[vt+572>>2],!((Y|0)!=1|W!=W)){if(a<m(0))break n;break e}if(gs&!(a<m(0))|((Y|0)!=2|W!=W))break e}n:{if(Ct>>>0>=2){Z=h,a=I[ot+516>>2],W=m(a+m(he(ot,Ct,bt)+Se(ot,Ct,bt)));break n}Z=m(I[ot+520>>2]+m(he(ot,it,bt)+Se(ot,it,bt))),a=I[ot+516>>2],W=h}n:{a:{if(!(W!=W|a!=a)){if(m(Xe(m(W-a)))<m(9999999747378752e-20))break a;break n}if(W==W|a==a)break n}if(a=I[ot+520>>2],Y=a!=a,!(Y|Z!=Z)){if(!(m(Xe(m(Z-a)))<m(9999999747378752e-20)))break n;break e}if(Z==Z)break n;if(Y)break e}gn(ot,W,Z,Wi,1,1,bt,qe,1,3,K,et,ft,Q);break e}Qe=ot,Je=m(m($t-cl(ot))+Us(ot,0,Oe)),I[Qe+232>>2]=Je}if(u=u+1|0,(b|0)==(u|0))break}if(Y=(Mt|0)!=(er|0),Mt=Mt+1|0,u=b,!Y)break}}vt=r+516|0,a=Ze(r,2,Yh,k),u=a!=a,h=m(m(xe(r,2,k)+pe(r,2))+m(Pe(r,2,k)+Re(r,2)));i:{if(!(u|h!=h)){a=oe(a,h);break i}a=u?h:a}I[vt>>2]=a,a=Ze(r,0,Xh,S),u=a!=a,h=m(m(xe(r,0,k)+pe(r,0))+m(Pe(r,0,k)+Re(r,0)));i:{if(!(u|h!=h)){a=oe(a,h);break i}a=u?h:a}I[r+520>>2]=a;i:{e:{s:{if(ps&&(u=c[r+24>>2]>>>20&3,(u|0)==2|(ps|0)!=2))break s;if(a=Ze(r,Ct,Ks,Ws),u=a!=a,h=m(m(xe(r,Ct,k)+pe(r,Ct))+m(Pe(r,Ct,k)+Re(r,Ct))),!(u|h!=h)){a=oe(a,h);break e}a=u?h:a;break e}if((ps|0)!=2|(u|0)!=2)break i;h=m(Xr+ge),u=h!=h,a=Ze(r,Ct,Ks,Ws);s:{if(!(u|a!=a)){a=Gh(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Xr!=Xr)){a=oe(a,Xr);break e}a=u?Xr:a}I[vt+(c[Hs>>2]<<2)>>2]=a}i:{e:{s:{if(Ht&&(b=(Ht|0)!=2,u=c[r+24>>2]>>>20&3,b|(u|0)==2))break s;if(a=Ze(r,it,m(ir+ms),Wa),u=a!=a,h=m(m(xe(r,it,k)+pe(r,it))+m(Pe(r,it,k)+Re(r,it))),!(u|h!=h)){a=oe(a,h);break e}a=u?h:a;break e}if(b|(u|0)!=2)break i;h=m(ir+Oe),u=h!=h,a=Ze(r,it,m(ir+ms),Wa);s:{if(!(u|a!=a)){a=Gh(h,a);break s}a=u?a:h}if(u=a!=a,!(u|ir!=ir)){a=oe(a,ir);break e}a=u?ir:a}I[vt+(c[$e>>2]<<2)>>2]=a}i:{if(!P)break i;if((c[r+24>>2]&786432)==524288)for(b=Yr>>>0<=1?1:Yr,P=c[r+556>>2],ot=c[r+560>>2]-P>>2,u=0;Y=0,Y=u>>>0<ot>>>0?c[P+(u<<2)>>2]:Y,(c[Y+24>>2]&196608)!=131072&&(Y=Y+228|0,Mt=Y+(c[li>>2]<<2)|0,qt=c[$e>>2]<<2,I[Mt>>2]=m(I[qt+vt>>2]-I[Mt>>2])-I[(Y+qt|0)+288>>2]),u=u+1|0,(b|0)!=(u|0););if(b=c[r+556>>2],P=c[r+560>>2],(b|0)!=(P|0))for(Mt=((Ct>>>0>1?ps:y)|0)!=0;;){y=c[b>>2];e:{if((c[y+24>>2]&4390912)!=131072)break e;W=bt,ge=qe,Tt[c[r+568>>2]+12|0]&2&&(ge=I[r+520>>2],W=I[r+516>>2]),u=c[r+24>>2]>>>2&3;s:{n:{if((Wi|0)==2){ot=0,Y=3;a:switch(u-2|0){case 0:break s;case 1:break a;default:break n}Y=2;break s}if(ot=0,u>>>0<=1)break n;Y=u;break s}Y=u,ot=Gs}S=m(he(y,2,W)+Se(y,2,W)),k=he(y,0,W),Z=Se(y,0,W),a=I[y+572>>2];s:{n:{a:switch(u=c[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),!cr(y,2)||!ul(y,2))break s;if(a=Ze(y,2,m(m(I[r+516>>2]-m(pe(r,2)+Re(r,2)))-m(Us(y,2,W)+Ga(y,2,W))),W),u=a!=a,h=m(m(xe(y,2,W)+pe(y,2))+m(Pe(y,2,W)+Re(y,2))),!(u|h!=h)){h=oe(a,h);break s}h=u?h:a}Z=m(k+Z);s:{n:{a:{o:{l:{c:{h:{qt=h!=h,k=I[y+580>>2];f:{d:{p:switch(u=c[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(ge!=ge|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(ge*k)*m(.009999999776482582))}a=m(Z+a);break f}d:{if(cr(y,0)&&ul(y,0))break d;if(a=m(Yt),h==h)break h;break a}if(a=Ze(y,0,m(m(I[r+520>>2]-m(pe(r,0)+Re(r,0)))-m(Us(y,0,ge)+Ga(y,0,ge))),ge),u=a!=a,k=m(m(xe(y,0,W)+pe(y,0))+m(Pe(y,0,W)+Re(y,0))),!(u|k!=k)){a=oe(a,k);break f}a=u?k:a}if((qt|0)==(a!=a|0)||(lt=I[y+224>>2],lt!=lt))break l;if(h!=h){h=m(m(m(a-Z)*lt)+S);break l}if(a==a)break l;break c}if(lt=I[y+224>>2],lt!=lt)break o}a=m(Z+m(m(h-S)/lt))}if(h!=h)break a;if(a==a)break s}u=0;break n}u=1}qt=W>m(0),er=u&Mt&Y>>>0<2,h=er&&qt?W:h,u=u^1,gn(y,h,a,Wi,er&&qt?2:u,a==a,h,a,0,6,K,et,ft,Q),h=m(I[y+516>>2]+f2(y,2,W)),a=m(I[y+520>>2]+f2(y,0,W))}gn(y,h,a,Wi,1,1,h,a,1,1,K,et,ft,Q);s:{n:{a:{if(!ul(y,Y)||cr(y,Y))break a;u=c[(Y<<2)+4320>>2]<<2,a=Y>>>0<2?ge:W,a=m(m(m(m(I[u+vt>>2]-I[(u+y|0)+516>>2])-Re(r,Y))-Se(y,Y,a))-Ga(y,Y,a));break n}if(!(cr(y,Y)|(c[r+24>>2]&112)!=16)){u=c[(Y<<2)+4320>>2]<<2,a=m(m(I[u+vt>>2]-I[(u+y|0)+516>>2])*m(.5));break n}if(!(cr(y,Y)|(c[r+24>>2]&112)!=32)){u=c[(Y<<2)+4320>>2]<<2,a=m(I[u+vt>>2]-I[(u+y|0)+516>>2]);break n}if(!(Tt[c[r+568>>2]+12|0]&2)||!cr(y,Y))break s;a=I[vt+(c[(Y<<2)+4320>>2]<<2)>>2],a=m(m(Us(y,Y,a)+pe(r,Y))+he(y,Y,a))}I[(y+(c[(Y<<2)+4288>>2]<<2)|0)+228>>2]=a}s:{n:{if(!ul(y,ot)||cr(y,ot))break n;u=c[(ot<<2)+4320>>2]<<2,a=Y>>>0<2?W:ge,a=m(m(m(m(I[u+vt>>2]-I[(u+y|0)+516>>2])-Re(r,ot))-Se(y,ot,a))-Ga(y,ot,a));break s}n:{if(cr(y,ot)||(u=c[y+24>>2]>>>13&7,u||(u=c[r+24>>2]>>>10&7),(u|0)!=2))break n;u=c[(ot<<2)+4320>>2]<<2,a=m(m(I[u+vt>>2]-I[(u+y|0)+516>>2])*m(.5));break s}n:{if(cr(y,ot))break n;Y=c[y+24>>2]>>>13&7,u=c[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=c[(ot<<2)+4320>>2]<<2,a=m(I[u+vt>>2]-I[(u+y|0)+516>>2]);break s}if(!(Tt[c[r+568>>2]+12|0]&2)||!cr(y,ot))break e;a=I[vt+(c[(ot<<2)+4320>>2]<<2)>>2],a=m(m(Us(y,ot,a)+pe(r,ot))+he(y,ot,a))}I[(y+(c[(ot<<2)+4288>>2]<<2)|0)+228>>2]=a}if(b=b+4|0,(P|0)==(b|0))break}if(!((it|Ct)&1))break i;for(b=it&1,P=Ct&1,K=Yr>>>0<=1?1:Yr,et=(it<<2)+4304|0,ft=(Ct<<2)+4304|0,Q=c[r+556>>2],it=c[r+560>>2]-Q>>2,r=0;;){if((r|0)==(it|0))break r;u=c[Q+(r<<2)>>2];e:{if(Tt[u+26|0]&64||(P&&(y=u+228|0,Y=c[Hs>>2]<<2,I[y+(c[ft>>2]<<2)>>2]=m(I[Y+vt>>2]-I[(y+Y|0)+288>>2])-I[y+(c[xr>>2]<<2)>>2]),!b))break e;u=u+228|0,y=c[$e>>2]<<2,I[u+(c[et>>2]<<2)>>2]=m(I[y+vt>>2]-I[(u+y|0)+288>>2])-I[u+(c[li>>2]<<2)>>2]}if(r=r+1|0,(K|0)==(r|0))break}}if(!Fi)break t;Ti(Fi);break t}Fs(),ce()}kt=M+384|0}function Lp(){var r=0,a=0;Gn(7032,7033,7034,0,4352,17,4355,0,4355,0,2529,4357,18),r=ut(8),c[r>>2]=8,c[r+4>>2]=1,Rt(7032,2922,6,4368,4392,19,r|0,1),Gn(7036,7037,7038,7032,4352,20,4352,21,4352,22,2001,4357,23),r=ut(4),c[r>>2]=24,Rt(7036,2359,2,4400,4408,25,r|0,0),us(7032,1398,2,4412,4420,26,27),us(7032,3027,3,4500,4512,28,29),Gn(7056,7057,7058,0,4352,30,4355,0,4355,0,2545,4357,31),r=ut(8),c[r>>2]=8,c[r+4>>2]=1,Rt(7056,3293,2,4520,4408,32,r|0,1),Gn(7059,7060,7061,7056,4352,33,4352,34,4352,35,2024,4357,36),r=ut(4),c[r>>2]=37,Rt(7059,2359,2,4528,4408,38,r|0,0),us(7056,1398,2,4536,4420,39,40),us(7056,3027,3,4500,4512,28,41),Gn(7062,7063,7064,0,4352,42,4355,0,4355,0,2861,4357,43),Sp(7062,1,4584,4352,44,45),us(7062,2915,1,4584,4352,44,45),us(7062,1129,2,4588,4408,46,47),r=ut(8),c[r+4>>2]=0,c[r>>2]=48,Rt(7062,3234,4,4608,4624,49,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=50,Rt(7062,1981,3,4632,4644,51,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=52,Rt(7062,1952,3,4652,4664,53,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=54,Rt(7062,3389,3,4672,4664,55,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=56,Rt(7062,1800,3,4652,4664,53,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=57,Rt(7062,3264,3,4684,4512,58,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=59,Rt(7062,1926,2,4696,4420,60,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=61,Rt(7062,3399,2,4704,4420,62,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=63,Rt(7062,1785,2,4696,4420,60,r|0,0),xh(7065,1271,4712,64,4357,65),Kn(1732,0),Kn(1612,8),Kn(2145,16),Kn(2455,24),Kn(2561,32),Kn(1618,40),Dh(7065),xh(7035,2898,4712,66,4357,67),s2(2561,0),s2(1618,8),Dh(7035),xh(7066,2909,4712,68,4357,69),r=ut(4),c[r>>2]=8,a=ut(4),c[a>>2]=8,ol(7066,2903,7098,4714,70,r|0,7098,4718,71,a|0),r=ut(4),c[r>>2]=0,a=ut(4),c[a>>2]=0,ol(7066,1607,7091,4420,72,r|0,7091,4664,73,a|0),Dh(7066),Gn(7067,7068,7069,0,4352,74,4355,0,4355,0,3022,4357,75),Sp(7067,1,4724,4352,76,77),us(7067,1593,1,4724,4352,76,77),us(7067,2851,2,4728,4420,78,79),us(7067,1129,2,4736,4408,80,81),r=ut(8),c[r+4>>2]=0,c[r>>2]=82,Rt(7067,1753,2,4736,4408,83,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=84,Rt(7067,3005,3,4744,4664,85,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=86,Rt(7067,2930,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=88,Rt(7067,2335,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=90,Rt(7067,1485,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=91,Rt(7067,1356,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=92,Rt(7067,1818,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=93,Rt(7067,2872,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=94,Rt(7067,2379,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=95,Rt(7067,2164,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=96,Rt(7067,1320,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=97,Rt(7067,2413,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=98,Rt(7067,1504,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=99,Rt(7067,2236,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=100,Rt(7067,1220,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=101,Rt(7067,1137,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=102,Rt(7067,1159,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=104,Rt(7067,1846,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=105,Rt(7067,1465,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=106,Rt(7067,2219,2,4736,4408,83,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=107,Rt(7067,1196,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=108,Rt(7067,2501,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=109,Rt(7067,2591,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=110,Rt(7067,1540,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=111,Rt(7067,2250,2,4736,4408,83,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=112,Rt(7067,1651,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=113,Rt(7067,1428,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=114,Rt(7067,2205,2,4736,4408,83,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=115,Rt(7067,2609,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=116,Rt(7067,1556,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=117,Rt(7067,1671,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=118,Rt(7067,1445,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=119,Rt(7067,2567,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=120,Rt(7067,1521,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=121,Rt(7067,1625,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=122,Rt(7067,1408,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=123,Rt(7067,2305,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=124,Rt(7067,2093,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=125,Rt(7067,2719,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=126,Rt(7067,1575,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=127,Rt(7067,2188,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=128,Rt(7067,2946,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=130,Rt(7067,2347,3,4812,4512,131,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=132,Rt(7067,1372,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=133,Rt(7067,1832,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=134,Rt(7067,2885,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=135,Rt(7067,2396,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=136,Rt(7067,2176,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=137,Rt(7067,1338,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=138,Rt(7067,2423,3,4812,4512,131,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=139,Rt(7067,1859,2,4824,4420,140,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=141,Rt(7067,1208,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=143,Rt(7067,2515,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=144,Rt(7067,2600,2,4824,4420,140,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=145,Rt(7067,1661,2,4824,4420,140,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=146,Rt(7067,2621,2,4824,4420,140,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=147,Rt(7067,1684,2,4824,4420,140,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=148,Rt(7067,2579,2,4824,4420,140,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=149,Rt(7067,1638,2,4824,4420,140,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=150,Rt(7067,2320,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=151,Rt(7067,2103,3,4840,4852,152,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=153,Rt(7067,1232,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=154,Rt(7067,1148,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=155,Rt(7067,2730,3,4812,4512,131,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=156,Rt(7067,2195,3,4860,4872,157,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=158,Rt(7067,3034,4,4880,4624,159,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=160,Rt(7067,3055,3,4896,4664,161,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=162,Rt(7067,1293,2,4908,4420,163,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=164,Rt(7067,1388,2,4916,4420,165,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=166,Rt(7067,3046,3,4924,4512,167,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=168,Rt(7067,2962,2,4936,4420,169,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=170,Rt(7067,2982,3,4944,4664,171,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=172,Rt(7067,3357,3,4956,4664,173,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=174,Rt(7067,3355,2,4736,4408,83,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=175,Rt(7067,3374,3,4968,4664,176,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=177,Rt(7067,3372,2,4736,4408,83,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=178,Rt(7067,1119,2,4736,4408,83,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=179,Rt(7067,1111,2,4980,4420,180,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=181,Rt(7067,1244,5,4992,5012,182,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=183,Rt(7067,1737,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=184,Rt(7067,1715,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=185,Rt(7067,2149,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=186,Rt(7067,2462,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=187,Rt(7067,2633,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=188,Rt(7067,1697,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=189,Rt(7067,1260,2,5020,4420,190,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=191,Rt(7067,2433,3,4840,4852,152,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=192,Rt(7067,2113,3,4840,4852,152,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=193,Rt(7067,2741,3,4840,4852,152,r|0,0)}function sT(r,a,h,u,y,b){r=r|0,a=+a,h=h|0,u=u|0,y=y|0,b=b|0;var k=0,S=0,P=0,K=0,et=0,ft=0,Q=0,it=0,M=0,W=0,Y=0,Z=0,ot=0,lt=0,vt=0,bt=0,Ct=0,Mt=0,$t=0;Q=kt-560|0,kt=Q,c[Q+44>>2]=0,Ei(+a),k=te(1)|0,te(0)|0;t:{if((k|0)<0){ot=1,Mt=1177,a=-a,Ei(+a),k=te(1)|0,te(0)|0;break t}if(y&2048){ot=1,Mt=1180;break t}ot=y&1,Mt=ot?1183:1178,$t=!ot}t:{if((k&2146435072)==2146435072){k=ot+3|0,ki(r,32,h,k,y&-65537),gi(r,Mt,ot),u=b&32,gi(r,a!=a?u?2451:3459:u?2868:3463,3),ki(r,32,h,k,y^8192),it=(h|0)<(k|0)?k:h;break t}vt=Q+16|0;r:{i:{e:{if(a=zp(a,Q+44|0),a=a+a,a!=0){if(k=c[Q+44>>2],c[Q+44>>2]=k-1,bt=b|32,(bt|0)!=97)break e;break r}if(bt=b|32,(bt|0)==97)break r;et=c[Q+44>>2],ft=(u|0)<0?6:u;break i}et=k-29|0,c[Q+44>>2]=et,a=a*268435456,ft=(u|0)<0?6:u}for(Y=(Q+48|0)+((et|0)>=0?288:0)|0,S=Y;a<4294967296&a>=0?u=~~a>>>0:u=0,c[S>>2]=u,S=S+4|0,a=(a-+(u>>>0))*1e9,a!=0;);i:{if((et|0)<=0){u=et,k=S,P=Y;break i}for(P=Y,u=et;;){M=(u|0)>=29?29:u,k=S-4|0;e:{if(P>>>0>k>>>0)break e;for(u=0;K=c[k>>2],Ct=u,u=M&31,(M&63)>>>0>=32?(it=K<<u,u=0):(it=(1<<u)-1&K>>>32-u,u=K<<u),Ct=Ct+u|0,K=it+W|0,u=Op(Ct,u>>>0>Ct>>>0?K+1|0:K,1e9),K=Bh(u,Gi,-1e9,0)+Ct|0,c[k>>2]=K,k=k-4|0,P>>>0<=k>>>0;);if(!u)break e;P=P-4|0,c[P>>2]=u}for(;k=S,P>>>0<k>>>0&&(S=k-4|0,!c[S>>2]););if(u=c[Q+44>>2]-M|0,c[Q+44>>2]=u,S=k,!((u|0)>0))break}}if((u|0)<0)for(lt=((ft+25>>>0)/9|0)+1|0,W=(bt|0)==102;;){u=0-u|0,it=(u|0)>=9?9:u;i:{if(k>>>0<=P>>>0){S=c[P>>2];break i}for(M=1e9>>>it|0,K=-1<<it^-1,u=0,S=P;Ct=u,u=c[S>>2],c[S>>2]=Ct+(u>>>it|0),u=We(M,u&K),S=S+4|0,S>>>0<k>>>0;);if(S=c[P>>2],!u)break i;c[k>>2]=u,k=k+4|0}if(u=it+c[Q+44>>2]|0,c[Q+44>>2]=u,P=(!S<<2)+P|0,S=W?Y:P,k=k-S>>2>(lt|0)?S+(lt<<2)|0:k,!((u|0)<0))break}u=0;i:{if(k>>>0<=P>>>0||(u=We(Y-P>>2,9),S=10,K=c[P>>2],K>>>0<10))break i;for(;u=u+1|0,S=We(S,10),K>>>0>=S>>>0;);}if(S=(ft-((bt|0)!=102?u:0)|0)-((bt|0)==103&(ft|0)!=0)|0,(S|0)<(We(k-Y>>2,9)-9|0)){if(M=S+9216|0,K=(M|0)/9|0,et=((((et|0)<0?4:292)+Q|0)+(K<<2)|0)-4048|0,S=10,it=M+We(K,-9)|0,(it|0)<=7)for(;S=We(S,10),it=it+1|0,(it|0)!=8;);M=c[et>>2],lt=(M>>>0)/(S>>>0)|0,W=We(lt,S),K=et+4|0;i:{if((M|0)==(W|0)&(K|0)==(k|0))break i;M=M-W|0;e:{if(!(lt&1)&&(a=9007199254740992,!(gt[et-4|0]&1)|((S|0)!=1e9|P>>>0>=et>>>0)))break e;a=9007199254740994}if(Z=(k|0)==(K|0)?1:1.5,K=S>>>1|0,Z=K>>>0>M>>>0?.5:(K|0)==(M|0)?Z:1.5,Tt[Mt|0]!=45|$t||(Z=-Z,a=-a),c[et>>2]=W,a+Z==a)break i;if(u=S+W|0,c[et>>2]=u,u>>>0>=1e9)for(;c[et>>2]=0,et=et-4|0,et>>>0<P>>>0&&(P=P-4|0,c[P>>2]=0),u=c[et>>2]+1|0,c[et>>2]=u,u>>>0>999999999;);if(u=We(Y-P>>2,9),S=10,K=c[P>>2],K>>>0<10)break i;for(;u=u+1|0,S=We(S,10),K>>>0>=S>>>0;);}S=et+4|0,k=k>>>0>S>>>0?S:k}for(;K=k,M=k>>>0<=P>>>0,!M&&(k=K-4|0,!c[k>>2]););i:{if((bt|0)!=103){et=y&8;break i}if(S=ft||1,k=(S|0)>(u|0)&(u|0)>-5,ft=(k?u^-1:-1)+S|0,b=(k?-1:-2)+b|0,et=y&8,et)break i;k=-9;e:{if(M||(et=c[K-4>>2],!et)||(it=10,k=0,(et>>>0)%10|0))break e;for(;S=k,k=k+1|0,it=We(it,10),!((et>>>0)%(it>>>0)|0););k=S^-1}if(S=We(K-Y>>2,9),(b&-33)==70){et=0,k=(k+S|0)-9|0,k=(k|0)>0?k:0,ft=(k|0)>(ft|0)?ft:k;break i}et=0,k=((u+S|0)+k|0)-9|0,k=(k|0)>0?k:0,ft=(k|0)>(ft|0)?ft:k}if(it=-1,M=et|ft,((M?2147483645:2147483646)|0)<(ft|0))break t;W=(((M|0)!=0)+ft|0)+1|0,S=b&-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=Hn((k^u)-k|0,0,vt),(vt-k|0)<=1)for(;k=k-1|0,gt[k|0]=48,(vt-k|0)<2;);if(lt=k-2|0,gt[lt|0]=b,gt[k-1|0]=(u|0)<0?45:43,k=vt-lt|0,(k|0)>(W^2147483647))break t}if(u=k+W|0,(u|0)>(ot^2147483647))break t;W=u+ot|0,ki(r,32,h,W,y),gi(r,Mt,ot),ki(r,48,h,W,y^65536);i:{e:{s:{if((S|0)==70){for(b=Q+16|0,u=b|8,et=b|9,S=P>>>0>Y>>>0?Y:P,P=S;;){k=Hn(c[P>>2],0,et);n:{if((S|0)!=(P|0)){if(Q+16>>>0>=k>>>0)break n;for(;k=k-1|0,gt[k|0]=48,Q+16>>>0<k>>>0;);break n}if((k|0)!=(et|0))break n;gt[Q+24|0]=48,k=u}if(gi(r,k,et-k|0),P=P+4|0,!(Y>>>0>=P>>>0))break}if(M&&gi(r,4275,1),(ft|0)<=0|P>>>0>=K>>>0)break s;for(;;){if(k=Hn(c[P>>2],0,et),k>>>0>Q+16>>>0)for(;k=k-1|0,gt[k|0]=48,Q+16>>>0<k>>>0;);if(gi(r,k,(ft|0)>=9?9:ft),k=ft-9|0,P=P+4|0,K>>>0<=P>>>0)break e;if(u=(ft|0)>9,ft=k,!u)break}break e}n:{if((ft|0)<0)break n;for(Y=P>>>0<K>>>0?K:P+4|0,b=Q+16|0,u=b|8,K=b|9,S=P;;){k=Hn(c[S>>2],0,K),(K|0)==(k|0)&&(gt[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,gt[k|0]=48,Q+16>>>0<k>>>0;);break a}if(gi(r,k,1),k=k+1|0,!(et|ft))break a;gi(r,4275,1)}if(b=K-k|0,gi(r,k,(b|0)>(ft|0)?ft:b),ft=ft-b|0,S=S+4|0,Y>>>0<=S>>>0)break n;if(!((ft|0)>=0))break}}ki(r,48,ft+18|0,18,0),gi(r,lt,vt-lt|0);break i}k=ft}ki(r,48,k+9|0,9,0)}ki(r,32,h,W,y^8192),it=(h|0)<(W|0)?W:h;break t}et=(b<<26>>31&9)+Mt|0;r:{if(u>>>0>11)break r;for(k=12-u|0,Z=16;Z=Z*16,k=k-1|0,!!k;);if(Tt[et|0]==45){a=-(Z+(-a-Z));break r}a=a+Z-Z}for(Y=ot|2,P=b&32,S=c[Q+44>>2],k=S>>31,k=Hn((k^S)-k|0,0,vt),(vt|0)==(k|0)&&(gt[Q+15|0]=48,k=Q+15|0),ft=k-2|0,gt[ft|0]=b+15,gt[k-1|0]=(S|0)<0?45:43,k=y&8,S=Q+16|0;b=S,Xe(a)<2147483648?K=~~a:K=-2147483648,gt[S|0]=P|Tt[K+5504|0],a=(a-+(K|0))*16,S=b+1|0,!(k|(u|0)>0)&a==0|(S-(Q+16|0)|0)!=1||(gt[b+1|0]=46,S=b+2|0),a!=0;);if(it=-1,k=vt-ft|0,b=k+Y|0,(2147483645-b|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}b=u+b|0,ki(r,32,h,b,y),gi(r,et,Y),ki(r,48,h,b,y^65536),gi(r,Q+16|0,P),ki(r,48,u-P|0,0,0),gi(r,ft,k),ki(r,32,h,b,y^8192),it=(h|0)<(b|0)?b:h}return kt=Q+560|0,it|0}function Cp(r,a,h,u,y,b,k){var S=0,P=0,K=0,et=0,ft=0,Q=0,it=0,M=0,W=0,Y=0,Z=0,ot=0,lt=0,vt=0,bt=0,Ct=0,Mt=0,$t=0,Ht=0,qt=0;K=kt-80|0,kt=K,c[K+76>>2]=a,$t=K+55|0,lt=K+56|0;t:{r:{i:{e:{s:for(;;){if(et=a,(W^2147483647)<(S|0))break e;W=S+W|0;n:{a:{o:{if(S=et,P=Tt[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(Tt[P+1|0]!=37){a=P;break c}if(S=S+1|0,ft=Tt[P+2|0],a=P+2|0,P=a,(ft|0)!=37)break}}if(S=S-et|0,Mt=W^2147483647,(S|0)>(Mt|0))break e;if(r&&gi(r,et,S),S)continue s;c[K+76>>2]=a,S=a+1|0,Z=-1,P=gt[a+1|0],!pl(P)|Tt[a+2|0]!=36||(Z=P-48|0,vt=1,S=a+3|0),c[K+76>>2]=S,M=0,P=gt[S|0],a=P-32|0;c:{if(a>>>0>31){ft=S;break c}if(ft=S,a=1<<a,!(a&75913))break c;for(;;){if(ft=S+1|0,c[K+76>>2]=ft,M=a|M,P=gt[S+1|0],a=P-32|0,a>>>0>=32)break c;if(S=ft,a=1<<a,!(a&75913))break}}c:{if((P|0)==42){a=gt[ft+1|0];h:{if(!(!pl(a)|Tt[ft+2|0]!=36)){c[((a<<2)+y|0)-192>>2]=10,P=ft+3|0,vt=1,Y=c[((gt[ft+1|0]<<3)+u|0)-384>>2];break h}if(vt)break o;if(P=ft+1|0,!r){c[K+76>>2]=P,vt=0,Y=0;break c}a=c[h>>2],c[h>>2]=a+4,vt=0,Y=c[a>>2]}if(c[K+76>>2]=P,(Y|0)>=0)break c;Y=0-Y|0,M=M|8192;break c}if(Y=Qp(K+76|0),(Y|0)<0)break e;P=c[K+76>>2]}S=0,it=-1;c:{if(Tt[P|0]!=46){a=P,ot=0;break c}if(Tt[P+1|0]==42){a=gt[P+2|0];h:{if(!(!pl(a)|Tt[P+3|0]!=36)){c[((a<<2)+y|0)-192>>2]=10,a=P+4|0,it=c[((gt[P+2|0]<<3)+u|0)-384>>2];break h}if(vt)break o;if(a=P+2|0,it=0,!r)break h;P=c[h>>2],c[h>>2]=P+4,it=c[P>>2]}c[K+76>>2]=a,ot=(it^-1)>>>31|0;break c}c[K+76>>2]=P+1,it=Qp(K+76|0),a=c[K+76>>2],ot=1}for(;;){if(Q=S,ft=28,bt=a,S=gt[a|0],S-123>>>0<4294967238)break i;if(a=bt+1|0,S=Tt[(S+We(Q,58)|0)+4975|0],!(S-1>>>0<8))break}c[K+76>>2]=a;c:{h:{if((S|0)!=27){if(!S)break i;if((Z|0)>=0){c[(Z<<2)+y>>2]=S,S=(Z<<3)+u|0,P=c[S+4>>2],c[K+64>>2]=c[S>>2],c[K+68>>2]=P;break h}if(!r)break n;Np(K- -64|0,S,h,k);break c}if((Z|0)>=0)break i}if(S=0,!r)continue s}P=M&-65537,M=M&8192?P:M,Z=0,Ct=1167,ft=lt;c:{h:{f:{d:{p:{v:{y:{u:{g:{b:{m:{T:{k:{A:{w:{E:switch(S=gt[bt|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=c[K+64>>2],Q=c[K+68>>2],S=1167;break g}S=0;A:switch(Q&255){case 0:c[c[K+64>>2]>>2]=W;continue s;case 1:c[c[K+64>>2]>>2]=W;continue s;case 2:et=c[K+64>>2],c[et>>2]=W,c[et+4>>2]=W>>31;continue s;case 3:Hr[c[K+64>>2]>>1]=W;continue s;case 4:gt[c[K+64>>2]]=W;continue s;case 6:c[c[K+64>>2]>>2]=W;continue s;case 7:break A;default:continue s}et=c[K+64>>2],c[et>>2]=W,c[et+4>>2]=W>>31;continue s}it=it>>>0<=8?8:it,M=M|8,S=120}if(et=lt,P=c[K+64>>2],Q=c[K+68>>2],P|Q)for(Ht=S&32;et=et-1|0,gt[et|0]=Ht|Tt[(P&15)+5504|0],qt=!Q&P>>>0>15|(Q|0)!=0,bt=Q,Q=Q>>>4|0,P=(bt&15)<<28|P>>>4,!!qt;);if(!(M&8)|!(c[K+64>>2]|c[K+68>>2]))break u;Ct=(S>>>4|0)+1167|0,Z=2;break u}if(S=lt,et=c[K+68>>2],Q=et,P=c[K+64>>2],et|P)for(;S=S-1|0,gt[S|0]=P&7|48,bt=!Q&P>>>0>7|(Q|0)!=0,et=Q,Q=et>>>3|0,P=(et&7)<<29|P>>>3,!!bt;);if(et=S,!(M&8))break u;S=lt-et|0,it=(S|0)<(it|0)?it:S+1|0;break u}if(P=c[K+64>>2],S=c[K+68>>2],Q=S,(S|0)<0){et=0-(Q+((P|0)!=0)|0)|0,Q=et,P=0-P|0,c[K+64>>2]=P,c[K+68>>2]=et,Z=1,S=1167;break g}if(M&2048){Z=1,S=1168;break g}Z=M&1,S=Z?1169:1167}Ct=S,et=Hn(P,Q,lt)}if((it|0)<0&&ot)break e;if(M=ot?M&-65537:M,S=c[K+64>>2],P=c[K+68>>2],!((S|P)!=0|it)){et=lt,it=0;break a}S=!(S|P)+(lt-et|0)|0,it=(S|0)<(it|0)?it:S;break a}M=0,ot=it>>>0>=2147483647?2147483647:it,Q=ot,ft=(Q|0)!=0;y:{u:{S=c[K+64>>2],et=S||4277,S=et;g:{b:{m:{if(!(S&3)|!Q)break m;for(;;){if(M=Tt[S|0],!M)break b;if(Q=Q-1|0,ft=(Q|0)!=0,S=S+1|0,!(S&3))break m;if(!Q)break}}if(!ft)break u;m:{if(!(!Tt[S|0]|Q>>>0<4))for(;;){if(ft=c[S>>2],(ft^-1)&ft-16843009&-2139062144)break m;if(S=S+4|0,Q=Q-4|0,!(Q>>>0>3))break}if(!Q)break u}ft=0;break g}ft=1}for(;;){if(!ft){M=Tt[S|0],ft=1;continue}if(!M)break y;if(S=S+1|0,Q=Q-1|0,!Q)break u;ft=0}}S=0}if(S=S?S-et|0:ot,ft=S+et|0,(it|0)>=0){M=P,it=S;break a}if(M=P,it=S,Tt[ft|0])break e;break a}if(it){P=c[K+64>>2];break d}S=0,ki(r,32,Y,0,M);break f}c[K+12>>2]=0,c[K+8>>2]=c[K+64>>2],P=K+8|0,c[K+64>>2]=P,it=-1}S=0;d:{for(;;){if(et=c[P>>2],!et)break d;if(et=r2(K+4|0,et),ft=(et|0)<0,!(ft|et>>>0>it-S>>>0)){if(P=P+4|0,S=S+et|0,it>>>0>S>>>0)continue;break d}break}if(ft)break r}if(ft=61,(S|0)<0)break i;if(ki(r,32,Y,S,M),!S){S=0;break f}for(ft=0,P=c[K+64>>2];;){if(et=c[P>>2],!et||(et=r2(K+4|0,et),ft=et+ft|0,ft>>>0>S>>>0))break f;if(gi(r,K+4|0,et),P=P+4|0,!(S>>>0>ft>>>0))break}}ki(r,32,Y,S,M^8192),S=(S|0)<(Y|0)?Y:S;continue s}if((it|0)<0&&ot)break e;if(ft=61,S=Pt[b|0](r,He[K+64>>3],Y,it,M,S)|0,(S|0)>=0)continue s;break i}gt[K+55|0]=c[K+64>>2],it=1,et=$t,M=P;break a}P=Tt[S+1|0],S=S+1|0}if(r)break t;if(!vt)break n;for(S=1;;){if(r=c[(S<<2)+y>>2],r){if(Np((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(c[(S<<2)+y>>2])break o;if(S=S+1|0,(S|0)==10)break}break t}ft=28;break i}if(Q=ft-et|0,it=(it|0)>(Q|0)?it:Q,(it|0)>(Z^2147483647))break e;if(ft=61,P=it+Z|0,S=(P|0)<(Y|0)?Y:P,(Mt|0)<(S|0))break i;ki(r,32,S,P,M),gi(r,Ct,Z),ki(r,48,S,P,M^65536),ki(r,48,it,Q,0),gi(r,et,Q),ki(r,32,S,P,M^8192);continue}break}W=0;break t}ft=61}c[1781]=ft}W=-1}return kt=K+80|0,W}function nT(r,a,h,u){r=r|0,a=+a,h=+h,u=u|0;var y=m(0),b=m(0),k=0,S=m(0),P=0,K=m(0),et=0,ft=m(0),Q=0;Q=kt+-64|0,kt=Q,k=c[r>>2],Hi(Q+8|0,0,56),c[1755]=c[1755]+1,Dp(k),S=m(a),b=I[k+572>>2];t:{r:{i:switch(r=c[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=b,!(y<m(0)))break i;break r}e:{if(!((r|0)!=2|y!=y)){if(S!=S|b<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=b;break i}y=m(m(b*S)*m(.009999999776482582))}ft=m(y+m(he(k,2,S)+Se(k,2,S))),et=1;break t}y=m(0),b=I[k+216>>2];r:{i:{r=c[k+216>>2];e:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;et=4336;n:{if((r|0)!=2141891242){if(b==b)break n;et=4344}switch(y=I[et>>2],c[et+4>>2]-1|0){case 0:break e;case 1:break s;default:break i}}if(y=(xt(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(b==b)break s;P=4344}switch(y=I[P>>2],ft=m(Yt),et=2,c[P+4>>2]-1|0){case 1:break e;case 0:break r;default:break t}}if(y=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break r}ft=m(m(y*S)*m(.009999999776482582)),et=2;break t}et=S==S,ft=S;break t}et=2,ft=y}K=m(h),b=I[k+580>>2];t:{r:{i:switch(r=c[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=b,!(y<m(0)))break i;break r}e:{if(!((r|0)!=2|y!=y)){if(K!=K|b<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=b;break i}y=m(m(b*K)*m(.009999999776482582))}b=m(y+m(he(k,0,S)+Se(k,0,S))),r=1;break t}y=m(0),b=I[k+220>>2];r:{i:{r=c[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(b==b)break n;P=4344}switch(y=I[P>>2],c[P+4>>2]-1|0){case 0:break e;case 1:break s;default:break i}}if(y=(xt(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(b==b)break s;P=4344}switch(y=I[P>>2],b=m(Yt),r=2,c[P+4>>2]-1|0){case 0:break r;case 1:break e;default:break t}}if(y=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break r}b=m(m(y*K)*m(.009999999776482582)),r=2;break t}r=K==K,b=K;break t}r=2,b=y}gn(k,ft,b,u,et,r,S,K,1,0,c[k+568>>2],Q+8|0,0,c[1755])&&(Vp(k,Tt[k+300|0]&3,S,K,S),Up(k,+I[c[k+568>>2]+20>>2],0,0)),kt=Q- -64|0}function aT(r,a){r=r|0,a=a|0;var h=0,u=m(0),y=0,b=0,k=m(0),S=0,P=0,K=0,et=m(0);t:{P=c[a>>2],a=c[r>>2];r:{if((c[P+24>>2]^c[a+24>>2])&8388607)break r;et=I[P+40>>2],y=c[P+40>>2],u=I[a+40>>2];i:{e:{if(h=c[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=(xt(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,et!=et)break i;u=(xt(2,(y&-1073741825)+536870912|0),Bt()),h=y&1073741824?2:1}if((h|0)!=(r|0)|!(!r|k!=k&u!=u|m(Xe(m(k-u)))<m(9999999747378752e-20))||(h=a+44|0,b=P+44|0,c[h>>2]!=c[b>>2]))break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break r}if(h=a+80|0,b=P+80|0,c[h>>2]!=c[b>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break r}if(h=a+116|0,b=P+116|0,c[h>>2]!=c[b>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break r}if(h=a+152|0,b=P+152|0,c[h>>2]!=c[b>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break r}if(h=a+188|0,b=P+188|0,c[h>>2]!=c[b>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==3)break i;if(S=r<<2,c[S+h>>2]!=c[b+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=c[r+S>>2],b=c[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|0))break r;for(S=P+208|0,K=a+208|0,r=0,y=1;;){i:{if(r=r<<2,h=c[r+S>>2],b=c[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|0))break r;for(S=P+216|0,K=a+216|0,r=0,y=1;;){i:{if(r=r<<2,h=c[r+S>>2],b=c[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|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(Vi(a+24|0,P+24|0,204);;){if(r=Tt[a+4|0],r&4)break t;if(gt[a+4|0]=r|4,r=c[a+20>>2],r&&Pt[r|0](a),c[a+308>>2]=2143289344,a=c[a+552>>2],!a)break}}}function oT(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,b=0,k=0,S=0,P=0,K=0,et=0,ft=0,Q=0,it=0,M=0,W=0,Y=0,Z=0;h=a,a=c[a>>2]+7&-8,c[h>>2]=a+16,M=r,P=c[a>>2],u=c[a+4>>2],r=c[a+12>>2],Q=r,k=kt-32|0,kt=k,r=r&2147483647,S=r,y=r-1006698496|0,r=r-1140785152|0,h=c[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,it=S>>>16|0,it>>>0<15249))break t;a=P,r=u,y=Q&65535|65536,S=y,ft=h,b=h,K=it-15233|0;r:{if(K&64){h=a,y=K+-64|0,a=y&31,(y&63)>>>0>=32?(r=h<<a,b=0):(r=(1<<a)-1&h>>>32-a|r<<a,b=h<<a),y=r,a=0,r=0;break r}if(!K)break r;et=b,b=K&31,(K&63)>>>0>=32?(h=et<<b,b=0):(h=(1<<b)-1&et>>>32-b|y<<b,b=et<<b),y=h,W=b,et=a,h=64-K|0,b=h&31,(h&63)>>>0>=32?(h=0,a=r>>>b|0):(h=r>>>b|0,a=((1<<b)-1&r)<<32-b|et>>>b),b=W|a,y=h|y,a=K&31,(K&63)>>>0>=32?(h=et<<a,a=0):(h=(1<<a)-1&et>>>32-a|r<<a,a=et<<a),r=h}c[k+16>>2]=a,c[k+20>>2]=r,c[k+24>>2]=b,c[k+28>>2]=y,a=15361-it|0;r:{if(a&64){u=ft,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,ft=0,S=0;break r}if(!a)break r;y=ft,r=64-a|0,h=r&31,(r&63)>>>0>=32?(r=y<<h,b=0):(r=(1<<h)-1&y>>>32-h|S<<h,b=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=b|y,u=r|h,y=ft,h=a&31,(a&63)>>>0>=32?(r=0,ft=S>>>h|0):(r=S>>>h|0,ft=((1<<h)-1&S)<<32-h|y>>>h),S=r}if(c[k>>2]=P,c[k+4>>2]=u,c[k+8>>2]=ft,c[k+12>>2]=S,a=c[k+8>>2],r=c[k+12>>2]<<4|a>>>28,a=a<<4,h=c[k>>2],S=c[k+4>>2],a=S>>>28|a,u=S&268435455,h=h|(c[k+16>>2]|c[k+24>>2]|(c[k+20>>2]|c[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}kt=k+32|0,xt(0,a|0),xt(1,Q&-2147483648|r),Y=M,Z=+Ee(),He[Y>>3]=Z}function gn(r,a,h,u,y,b,k,S,P,K,et,ft,Q,it){var M=m(0),W=0,Y=0,Z=0,ot=0,lt=m(0),vt=0,bt=0,Ct=m(0);t:{if(!(c[r+312>>2]!=(it|0)&&Tt[r+4|0]&4)&&(ot=0,c[r+316>>2]==(u|0)))break t;c[r+540>>2]=-1082130432,c[r+544>>2]=-1082130432,c[r+532>>2]=0,c[r+536>>2]=0,c[r+524>>2]=-1082130432,c[r+528>>2]=-1082130432,c[r+320>>2]=0,ot=1}vt=Q+1|0;t:{r:{i:{e:{if(c[r+8>>2]){if(lt=he(r,2,k),Ct=Se(r,2,k),M=m(he(r,0,k)+Se(r,0,k)),Q=r+524|0,lt=m(lt+Ct),Pp(y,a,b,h,c[r+532>>2],I[Q>>2],c[r+536>>2],I[r+528>>2],I[r+540>>2],I[r+544>>2],lt,M,et))break i;if(Y=c[r+320>>2],!Y)break e;for(W=r+324|0;;){if(Q=W+We(Z,24)|0,Pp(y,a,b,h,c[Q+8>>2],I[Q>>2],c[Q+12>>2],I[Q+4>>2],I[Q+16>>2],I[Q+20>>2],lt,M,et))break i;if(Z=Z+1|0,(Y|0)==(Z|0))break}break e}if(!P){if(bt=c[r+320>>2],!bt)break e;for(Y=r+324|0;;){W=We(Z,24),Q=W+Y|0,M=I[Q>>2];s:{n:{if(!(M!=M|a!=a)){if(m(Xe(m(M-a)))<m(9999999747378752e-20))break n;break s}if(M==M|a==a)break s}W=Y+W|0,M=I[W+4>>2];n:{if(!(M!=M|h!=h)){if(m(Xe(m(M-h)))<m(9999999747378752e-20))break n;break s}if(M==M|h==h)break s}if(c[W+8>>2]!=(y|0))break s;if(c[W+12>>2]==(b|0))break i}if(Z=Z+1|0,(bt|0)==(Z|0))break}break e}Q=r+524|0,M=I[Q>>2];s:{if(!(M!=M|a!=a)){if(m(Xe(m(M-a)))<m(9999999747378752e-20))break s;break e}if(M==M|a==a)break e}W=c[r+532>>2]==(y|0)&&c[r+536>>2]==(b|0)?Q:0,M=I[r+528>>2],Q=M!=M,Y=h!=h;s:{if(Q|Y){Q=Q&Y;break s}Q=m(Xe(m(M-h)))<m(9999999747378752e-20)}Q=Q?W:0;break i}_p(r,a,h,u,y,b,k,S,P,et,ft,vt,it,K),c[r+316>>2]=u;break r}if(!(!Q|ot)){I[r+516>>2]=I[Q+16>>2],I[r+520>>2]=I[Q+20>>2],u=(P?12:16)+ft|0,c[u>>2]=c[u>>2]+1;break t}if(_p(r,a,h,u,y,b,k,S,P,et,ft,vt,it,K),c[r+316>>2]=u,Q)break t}Q=c[r+320>>2],u=Q+1|0,u>>>0>Ap[ft+8>>2]&&(c[ft+8>>2]=u),(Q|0)==8&&(c[r+320>>2]=0,Q=0),P?u=r+524|0:(c[r+320>>2]=Q+1,u=(We(Q,24)+r|0)+324|0),c[u+12>>2]=b,c[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=c[r+520>>2],c[r+244>>2]=c[r+516>>2],c[r+248>>2]=u,u=Tt[r+4|0],y=u|1,gt[r+4|0]=y,!(u&4)))break t;gt[r+4|0]=y&251}return c[r+312>>2]=it,!Q|ot}function Ph(r){r=r|0;var a=0,h=0,u=0,y=0,b=0,k=0,S=0,P=0,K=0,et=0,ft=0;S=8;t:{if(r>>>0>4294967239)break t;r:{for(;;){S=S>>>0<=8?8:S,a=c[1751],b=a,y=c[1750],r=r>>>0<=8?8:r+3&-4;i:{if(r>>>0<=127){k=(r>>>3|0)-1|0;break i}if(u=Er(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,b=h,h=a-1|0,b=(h|0)!=-1?P:b,u=Er(u^b),u=(u|0)==32?Er(a^h)+32|0:u,h=63-u|0,Gi=0-(u>>>0>63)|0;break i}Gi=0,h=64}b=h,h=b&31,(b&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=b+k|0,h=k<<4,a=c[h+5976>>2],b=h+5968|0;i:{if((a|0)!=(b|0)){if(y=$h(a,S,r),y)break t;y=c[a+4>>2],c[y+8>>2]=c[a+8>>2],c[c[a+8>>2]+4>>2]=y,c[a+8>>2]=b,y=h+5972|0,c[a+4>>2]=c[y>>2],c[y>>2]=a,c[c[a+4>>2]+8>>2]=a,k=k+1|0,a=(u&1)<<31|P>>>1,u=u>>>1|0;break i}K=c[1751],b=k&63,a=b,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=b&31,b>>>0>=32?(a=h<<y,h=0):(a=(1<<y)-1&h>>>32-y|a<<y,h=h<<y),et=h,y=a,b=0-k&63,h=b,a=h&31,h>>>0>=32?(a=-1<<a,h=0):(h=-1<<a,a=h|(1<<a)-1&-1>>>32-a),ft=h&-2,h=b&31,b>>>0>=32?(b=0,a=a>>>h|0):(b=a>>>h|0,a=((1<<h)-1&a)<<32-h|ft>>>h),a=a|et,Gi=y|b,c[1750]=c[1750]&a,c[1751]=Gi&K,a=P^1}if(!(a|u))break}b=c[1751],y=c[1750]}i:{if(y|b){u=Er(b),h=63-((u|0)==32?Er(y)+32|0:u)|0,a=h<<4,u=c[a+5976>>2];e:{if(!b&y>>>0<1073741824||(k=99,a=a+5968|0,(a|0)==(u|0)))break e;for(;;){if(!k)break e;if(y=$h(u,S,r),y)break t;if(k=k-1|0,u=c[u+8>>2],(a|0)==(u|0))break}u=a}if(Mh(r+48|0))break i;if(!u||(a=(h<<4)+5968|0,(a|0)==(u|0)))break r;for(;;){if(y=$h(u,S,r),y)break t;if(u=c[u+8>>2],(a|0)==(u|0))break}break r}if(!Mh(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 lT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0,P=0,K=0,et=0,ft=0,Q=0;S=kt-80|0,kt=S,r=c[r>>2];t:{r:{if(P=c[a>>2],!c[P+552>>2]){if(c[r+8>>2])break r;a=c[r+556>>2],k=a+(h<<2)|0,u=c[r+560>>2],y=r+564|0,b=c[y>>2];i:{if(u>>>0<b>>>0){if((u|0)==(k|0)){c[k>>2]=P,c[r+560>>2]=k+4;break i}if(h=u,a=u-4|0,u>>>0>a>>>0)for(;c[h>>2]=c[a>>2],h=h+4|0,a=a+4|0,u>>>0>a>>>0;);c[r+560>>2]=h,a=k+4|0,(a|0)!=(u|0)&&(a=u-a|0,Ns(u-(a&-4)|0,k,a)),c[k>>2]=P;break i}if(u=(u-a>>2)+1|0,u>>>0>=1073741824)break t;a=b-a|0,b=a>>1,y=Va(S+32|0,a>>>0>=2147483644?1073741823:u>>>0<b>>>0?b:u,h,y),h=c[y+8>>2];e:{if((h|0)!=c[y+12>>2])break e;if(a=c[y+4>>2],u=c[y>>2],a>>>0>u>>>0){u=((a-u>>2)+1|0)/-2<<2,K=u+a|0,b=a,a=h-a|0,h=Ns(K,b,a)+a|0,c[y+8>>2]=h,c[y+4>>2]=u+c[y+4>>2];break e}a=(h|0)==(u|0)?1:h-u>>1,b=Va(S+56|0,a,a>>>2|0,c[y+16>>2]),u=c[b+8>>2],a=c[y+4>>2],h=c[y+8>>2];s:{if((a|0)==(h|0)){h=u,u=a;break s}for(h=(h-a|0)+u|0;c[u>>2]=c[a>>2],a=a+4|0,u=u+4|0,(u|0)!=(h|0););a=c[y+8>>2],u=c[y+4>>2]}if(K=c[y>>2],c[y>>2]=c[b>>2],c[b>>2]=K,c[y+4>>2]=c[b+4>>2],c[b+4>>2]=u,c[y+8>>2]=h,c[b+8>>2]=a,et=c[y+12>>2],c[y+12>>2]=c[b+12>>2],c[b+12>>2]=et,(a|0)!=(u|0)&&(c[b+8>>2]=((u-a|0)+3&-4)+a),!K)break e;Ti(K),h=c[y+8>>2]}if(c[h>>2]=P,c[y+8>>2]=c[y+8>>2]+4,a=c[r+556>>2],h=k-a|0,ft=y,Q=Ns(c[y+4>>2]-h|0,a,h),c[ft+4>>2]=Q,u=c[r+560>>2]-k|0,k=Ns(c[y+8>>2],k,u),a=c[r+556>>2],c[r+556>>2]=c[y+4>>2],c[y+4>>2]=a,h=c[r+560>>2],c[r+560>>2]=u+k,c[y+8>>2]=h,u=c[r+564>>2],c[r+564>>2]=c[y+12>>2],c[y>>2]=a,c[y+12>>2]=u,(a|0)!=(h|0)&&(c[y+8>>2]=h+((a-h|0)+3&-4)),!a)break i;Ti(a)}for(c[P+552>>2]=r;a=Tt[r+4|0],!!(!(a&4)&&(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],r)););kt=S+80|0;return}c[S+16>>2]=4075,lr(r,S+16|0),tr(),ce()}c[S>>2]=4208,lr(r,S),tr(),ce()}Fs(),ce()}function Ip(r,a){var h=0,u=0;for(c[r>>2]=0,c[r+8>>2]=0,c[r+12>>2]=0,c[r+16>>2]=0,c[r+20>>2]=0,c[r+24>>2]=0,c[r+36>>2]=2143289344,c[r+40>>2]=2141891242,c[r+28>>2]=2143289344,c[r+32>>2]=2143289344,gt[r+4|0]=Tt[r+4|0]&128,u=Hi(r+44|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Hi(r+80|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Hi(r+116|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Hi(r+152|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,c[r+196>>2]=0,u=r+188|0,c[u>>2]=0,c[u+4>>2]=0;c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=3;);for(c[r+24>>2]=4224,c[r+224>>2]=2143289344,c[r+216>>2]=2143289344,c[r+220>>2]=2143289344,c[r+208>>2]=2143289344,c[r+212>>2]=2143289344,c[r+200>>2]=2141891242,c[r+204>>2]=2141891242,Hi(r+228|0,0,288),c[r+244>>2]=2143289344,c[r+248>>2]=2143289344,Hi(r+252|0,0,49),c[r+308>>2]=2143289344,u=r+516|0,h=r+324|0;c[h+16>>2]=-1082130432,c[h+20>>2]=-1082130432,c[h+8>>2]=0,c[h+12>>2]=0,c[h>>2]=-1082130432,c[h+4>>2]=-1082130432,h=h+24|0,(u|0)!=(h|0););return c[r+548>>2]=0,c[r+552>>2]=0,c[r+516>>2]=2143289344,c[r+520>>2]=2143289344,c[r+572>>2]=2143289344,c[r+576>>2]=0,c[r+568>>2]=a,c[r+540>>2]=-1082130432,c[r+544>>2]=-1082130432,c[r+532>>2]=0,c[r+536>>2]=0,c[r+524>>2]=-1082130432,c[r+528>>2]=-1082130432,c[r+556>>2]=0,c[r+560>>2]=0,c[r+564>>2]=0,c[r+580>>2]=2143289344,c[r+584>>2]=0,c2((a|0)!=0,2760),gt[r+4|0]=Tt[r+4|0]|1,gt[a+8|0]&1&&(c[r+24>>2]=c[r+24>>2]&-909|520),r}function Ze(r,a,h,u){var y=m(0),b=m(0),k=0,S=m(0);t:{r:{i:{e:{s:{n:{if(a>>>0<=1){b=I[r+212>>2],a=c[r+212>>2];a:{if((a|0)==2139156720)break a;if((a|0)==2140081935)break n;k=4336;o:{if((a|0)!=2141891242){if(b==b)break o;k=4344}switch(y=I[k>>2],b=m(Yt),c[k+4>>2]-1|0){case 0:break n;case 1:break a;default:break s}}if(y=(xt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break n}b=m(m(y*u)*m(.009999999776482582));break s}b=I[r+208>>2];a:{o:{a=c[r+208>>2];l:{if((a|0)==2139156720)break l;if((a|0)==2140081935)break o;k=4336;c:{if((a|0)!=2141891242){if(b==b)break c;k=4344}switch(y=I[k>>2],b=m(Yt),c[k+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(y=(xt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break o}b=m(m(y*u)*m(.009999999776482582));break a}b=y}y=m(0),S=I[r+216>>2],r=c[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],c[a+4>>2]-1|0){case 1:break a;case 0:break e;default:break r}}if(y=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*u)*m(.009999999776482582));break e}b=y}y=m(0),S=I[r+220>>2],r=c[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],c[a+4>>2]-1|0){case 1:break s;case 0:break e;default:break r}}if(y=(xt(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(!(b>=m(0)))return h;y=h<b?b:h}return y}function Dp(r){var a=0,h=0,u=m(0),y=m(0),b=m(0),k=0,S=0,P=0,K=0,et=0,ft=0,Q=0,it=0,M=0;for(k=kt-16|0,c[k+8>>2]=0,c[k+12>>2]=1,et=r+200|0,ft=r+572|0,Q=r+208|0,it=r+216|0,r=0;;){M=r,K=c[(k+8|0)+(r<<2)>>2],S=K<<2,r=it+S|0,u=I[r>>2];t:{r:{i:{e:{s:{n:{if(a=c[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=c[r>>2];a:{o:{if((h|0)!=2139156720){if(b=m(Yt),r=3,(h|0)==2141891242)break a;if((h|0)!=2140081935)break o;b=m(0),r=1;break a}b=m(0),r=2;break a}if(r=0,y!=y)break a;b=(xt(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=(xt(2,(a&-1073741825)+536870912|0),Bt()),r=a&1073741824?2:1}if((h|0)!=(r|0)|!(!r|y!=y&b!=b|m(Xe(m(y-b)))<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+et|0,u=I[a>>2],a=c[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)+ft|0,c[h+4>>2]=a,c[h>>2]=r,r=1,!!(M&1))break}}function Vi(r,a,h){var u=0,y=0,b=0;if(h>>>0>=512)return QE(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(gt[h|0]=Tt[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||(b=u+-64|0,b>>>0<h>>>0))break r;for(;c[h>>2]=c[a>>2],c[h+4>>2]=c[a+4>>2],c[h+8>>2]=c[a+8>>2],c[h+12>>2]=c[a+12>>2],c[h+16>>2]=c[a+16>>2],c[h+20>>2]=c[a+20>>2],c[h+24>>2]=c[a+24>>2],c[h+28>>2]=c[a+28>>2],c[h+32>>2]=c[a+32>>2],c[h+36>>2]=c[a+36>>2],c[h+40>>2]=c[a+40>>2],c[h+44>>2]=c[a+44>>2],c[h+48>>2]=c[a+48>>2],c[h+52>>2]=c[a+52>>2],c[h+56>>2]=c[a+56>>2],c[h+60>>2]=c[a+60>>2],a=a- -64|0,h=h- -64|0,b>>>0>=h>>>0;);}if(h>>>0>=u>>>0)break t;for(;c[h>>2]=c[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;gt[h|0]=Tt[a|0],gt[h+1|0]=Tt[a+1|0],gt[h+2|0]=Tt[a+2|0],gt[h+3|0]=Tt[a+3|0],a=a+4|0,h=h+4|0,u>>>0>=h>>>0;);}if(h>>>0<y>>>0)for(;gt[h|0]=Tt[a|0],a=a+1|0,h=h+1|0,(y|0)!=(h|0););return r}function xp(r,a,h,u,y){var b=m(0),k=0,S=m(0),P=m(0),K=0,et=0,ft=m(0),Q=m(0),it=0;if(S=m(h-u),et=S!=S,!et){h=m(0),k=(a<<2)+r|0,b=I[k+208>>2];t:{r:{k=c[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(b==b)break s;K=4344}switch(h=I[K>>2],c[K+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(h=(xt(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,b=I[r+216>>2];t:{r:{a=c[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(b==b)break s;r=4344}switch(h=I[r>>2],b=m(34028234663852886e22),c[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(h=(xt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break i}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break r;b=m(34028234663852886e22);break t}b=m(h-u)}if(h=(ft=S,Q=Gh(S,b),it=b!=b|et,it?ft:Q),r=h!=h,!(r|P!=P))return oe(h,P);S=r?P:h}return S}function Pp(r,a,h,u,y,b,k,S,P,K,et,ft,Q){var it=m(0),M=m(0),W=0,Y=0,Z=m(0),ot=m(0),lt=m(0),vt=0,bt=0;if(P<m(0)|K<m(0))r=0;else{Z=b,ot=a,lt=u,M=S;t:{if(!Q||(it=I[Q+20>>2],M=S,it==m(0)))break t;vt=+it,ot=Kr(+a,vt,0,0),lt=Kr(+u,vt,0,0),Z=Kr(+b,vt,0,0),M=Kr(+S,vt,0,0)}it=M,Q=0;t:{if((r|0)!=(y|0))break t;if(bt=Z!=Z,Q=ot!=ot,bt|Q){Q=Q&bt;break t}Q=m(Xe(m(Z-ot)))<m(9999999747378752e-20)}bt=Q;t:{if((h|0)!=(k|0))break t;if(W=it!=it,Q=lt!=lt,W|Q){W=Q&W;break t}W=m(Xe(m(it-lt)))<m(9999999747378752e-20)}Y=1,Q=1;t:{if(bt)break t;a=m(a-et);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<b)|(r|(y|0)!=2|(a!=a|b!=b|P!=P))||(Q=1,a>=P))break t}if(y=a!=a,r=P!=P,y|r){Q=r&y;break t}Q=m(Xe(m(a-P)))<m(9999999747378752e-20)}t:{if(W)break t;a=m(u-ft);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(Xe(m(a-K)))<m(9999999747378752e-20)}r=Q&Y}return r}function Oh(r){var a=0,h=0,u=0,y=0,b=0,k=0,S=0,P=0;if(Ei(+r),b=te(1)|0,u=te(0)|0,y=b>>>20&2047,(y|0)==2047)return r=r*1,r/r;if(a=u<<1,k=b<<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=b<<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|b<<h,u=u<<h);break t}a=b&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=b&-2147483648,k=a+-1048576|y<<20,S=h,b=a,S=h,u=1-y|0,h=u&31,(u&63)>>>0>=32?(a=0,u=b>>>h|0):(a=b>>>h|0,u=((1<<h)-1&b)<<32-h|S>>>h),h=(y|0)>0,xt(0,(h?S:u)|0),xt(1,(h?k:a)|P),+Ee()}function Mh(r){var a=0,h=0,u=0,y=0,b=0;u=c[1416],a=r+7&-8,h=u+a|0;t:{r:{if(h>>>0<=u>>>0&&a||h>>>0>T2()<<16>>>0&&!(qE(h|0)|0))break r;c[1416]=h;break t}c[1781]=48,u=-1}if((u|0)!=-1){a=r+u|0,h=a-16|0,c[h+12>>2]=16,c[h>>2]=16,r=c[1748],r?b=c[r+8>>2]:b=0;t:{r:{if((b|0)==(u|0)){if(y=u-(c[u-4>>2]&-2)|0,b=c[y-4>>2],c[r+8>>2]=a,r=y-(b&-2)|0,a=-16,!(gt[(r+c[r>>2]|0)-4|0]&1))break r;a=c[r+4>>2],c[a+8>>2]=c[r+8>>2],c[c[r+8>>2]+4>>2]=a,h=h-r|0,c[r>>2]=h;break t}c[u+12>>2]=16,c[u>>2]=16,c[u+8>>2]=a,c[u+4>>2]=r,c[1748]=u,a=16}r=a+u|0,h=h-r|0,c[r>>2]=h}c[((h&-4)+r|0)-4>>2]=h|1,a=c[r>>2]-8|0;t:{if(a>>>0<=127){h=(a>>>3|0)-1|0;break t}if(y=Er(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,c[r+4>>2]=a+5968,a=a+5976|0,c[r+8>>2]=c[a>>2],c[a>>2]=r,c[c[r+8>>2]+4>>2]=r,a=c[1750],y=c[1751],r=h&31,(h&63)>>>0>=32?(h=1<<r,b=0):(b=1<<r,h=b-1&1>>>32-r),c[1750]=b|a,c[1751]=h|y}return(u|0)!=-1}function Op(r,a,h){var u=0,y=0,b=0,k=0,S=0,P=0,K=0,et=0,ft=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,Gi=0;break t}if(!r)break o;break a}if(!(h-1&h))break n;b=(Er(h)+33|0)-Er(a)|0,k=0-b|0;break e}r=(a>>>0)/0|0,Gi=0;break t}if(u=32-Er(a)|0,u>>>0<31)break s;break i}if((h|0)==1)break r;b=h?31-Er(h-1^h)|0:32,h=b&31,(b&63)>>>0>=32?r=a>>>h|0:(u=a>>>h|0,r=((1<<h)-1&a)<<32-h|r>>>h),Gi=u;break t}b=u+1|0,k=63-u|0}if(u=b&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),b)for(k=h-1|0,ft=(k|0)==-1?-1:0;P=u<<1|S>>>31,u=S<<1|a>>>31,y=ft-(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=et|r<<1,et=y&1,b=b-1|0,!!b;);Gi=a<<1|r>>>31,r=et|r<<1;break t}r=0,a=0}Gi=a}return r}function ll(r,a,h){var u=m(0),y=m(0);t:{r:{i:{if((a&-2)==2){if(a=c[r+188>>2],u=I[r+188>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=c[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=c[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=c[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=(xt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(Yt),c[r+4>>2]-1|0){case 0:break t;case 1:break e;default:break i}}if(u=(xt(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 Mp(r,a){var h=0,u=0,y=0,b=0,k=0,S=0;for(h=kt-320|0,kt=h,u=Hi(h,0,288),h=u,c[h+16>>2]=2143289344,c[h+20>>2]=2143289344,Hi(h+24|0,0,49),c[h+80>>2]=2143289344,b=h+288|0,y=h+96|0;h=y,c[h+16>>2]=-1082130432,c[h+20>>2]=-1082130432,c[h+8>>2]=0,c[h+12>>2]=0,c[h>>2]=-1082130432,c[h+4>>2]=-1082130432,y=h+24|0,(b|0)!=(y|0););if(c[u+312>>2]=-1082130432,c[u+316>>2]=-1082130432,c[u+304>>2]=0,c[u+308>>2]=0,c[u+296>>2]=-1082130432,c[u+300>>2]=-1082130432,c[u+288>>2]=2143289344,c[u+292>>2]=2143289344,Vi(r+228|0,u,320),c[r+244>>2]=0,c[r+248>>2]=0,gt[r+4|0]=Tt[r+4|0]|1,y=c[r+556>>2],k=c[r+560>>2],(y|0)!=(k|0))for(;h=c[y>>2],c[h+552>>2]!=(r|0)&&(b=c[r+568>>2],h=Gp(c[b>>2],Tt[b+8|0],h,r,S,a),c[y>>2]=h,c[h+552>>2]=r,h=c[y>>2]),Mp(h,a),S=S+1|0,y=y+4|0,(k|0)!=(y|0););kt=u+320|0}function $h(r,a,h){var u=0,y=0,b=0,k=0;if(u=r+4|0,y=(u+a|0)-1&0-a,a=c[r>>2],y+h>>>0<=(a+r|0)-4>>>0){b=c[r+4>>2],c[b+8>>2]=c[r+8>>2],c[c[r+8>>2]+4>>2]=b,(u|0)!=(y|0)&&(y=y-u|0,b=r-(c[r-4>>2]&-2)|0,u=y+c[b>>2]|0,c[b>>2]=u,c[(b+(u&-4)|0)-4>>2]=u,r=r+y|0,a=a-y|0,c[r>>2]=a);t:{if(h+24>>>0<=a>>>0){u=(r+h|0)+8|0,a=(a-h|0)-8|0,c[u>>2]=a,c[(u+(a&-4)|0)-4>>2]=a|1,y=c[u>>2]-8|0;r:{if(y>>>0<=127){a=(y>>>3|0)-1|0;break r}if(b=Er(y),a=((y>>>29-b^4)-(b<<2)|0)+110|0,y>>>0<=4095)break r;a=((y>>>30-b^2)-(b<<1)|0)+71|0,a=a>>>0>=63?63:a}y=a<<4,c[u+4>>2]=y+5968,y=y+5976|0,c[u+8>>2]=c[y>>2],c[y>>2]=u,c[c[u+8>>2]+4>>2]=u,y=c[1750],b=c[1751],u=a&31,(a&63)>>>0>=32?(a=1<<u,u=0):(k=1<<u,a=k-1&1>>>32-u,u=k),c[1750]=u|y,c[1751]=a|b,a=h+8|0,c[r>>2]=a,c[((a&-4)+r|0)-4>>2]=a;break t}c[(r+a|0)-4>>2]=a}r=r+4|0}else r=0;return r}function cT(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,b=0;y=kt-320|0,kt=y,r=c[r>>2];t:{if(c[r+560>>2]==c[r+556>>2]||(u=c[a>>2],a=c[u+552>>2],!Kp(r,u)))break t;if((r|0)==(a|0)){for(h=Hi(y,0,288),a=h,c[a+16>>2]=2143289344,c[a+20>>2]=2143289344,Hi(a+24|0,0,49),c[a+80>>2]=2143289344,b=a+288|0,a=a+96|0;c[a+16>>2]=-1082130432,c[a+20>>2]=-1082130432,c[a+8>>2]=0,c[a+12>>2]=0,c[a>>2]=-1082130432,c[a+4>>2]=-1082130432,a=a+24|0,(b|0)!=(a|0););c[h+312>>2]=-1082130432,c[h+316>>2]=-1082130432,c[h+304>>2]=0,c[h+308>>2]=0,c[h+296>>2]=-1082130432,c[h+300>>2]=-1082130432,c[h+288>>2]=2143289344,c[h+292>>2]=2143289344,Vi(u+228|0,h,320),c[u+552>>2]=0}for(;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}kt=y+320|0}function $p(r){r=r|0;var a=0,h=0,u=0,y=0,b=0,k=0,S=0;if(r){if(k=kt-32|0,kt=k,a=c[r>>2],u=c[a+552>>2],u&&(Kp(u,a),c[a+552>>2]=0),u=c[a+556>>2],h=c[a+560>>2],(u|0)!=(h|0))for(h=h-u>>2,y=h>>>0<=1?1:h,h=0;c[c[(h<<2)+u>>2]+552>>2]=0,h=h+1|0,(y|0)!=(h|0););c[a+560>>2]=u,h=a+564|0;t:{if(c[h>>2]==(u|0)||(h=Va(k+8|0,0,0,h),y=c[a+556>>2],b=c[a+560>>2]-y|0,u=c[h+4>>2]-b|0,b=Ns(u,y,b),y=c[a+556>>2],c[a+556>>2]=b,c[h+4>>2]=y,b=c[a+560>>2],c[a+560>>2]=c[h+8>>2],c[h+8>>2]=b,S=c[a+564>>2],c[a+564>>2]=c[h+12>>2],c[h>>2]=y,c[h+12>>2]=S,(y|0)!=(b|0)&&(c[h+8>>2]=b+((y-b|0)+3&-4)),!y))break t;Ti(y),u=c[a+556>>2]}u&&(c[a+560>>2]=u,Ti(u)),Ti(a),a=c[r+8>>2],c[r+8>>2]=0,a&&Pt[c[c[a>>2]+4>>2]](a),a=c[r+4>>2],c[r+4>>2]=0,a&&Pt[c[c[a>>2]+4>>2]](a),kt=k+32|0,Ti(r)}}function hT(r){r=r|0;var a=0,h=0,u=0;u=kt-624|0,kt=u,a=c[r+4>>2],c[r+4>>2]=0,a&&Pt[c[c[a>>2]+4>>2]](a),a=c[r+8>>2],c[r+8>>2]=0,a&&Pt[c[c[a>>2]+4>>2]](a);t:{if(r=c[r>>2],c[r+560>>2]==c[r+556>>2]){if(c[r+552>>2])break t;a=Ip(u+32|0,c[r+568>>2]),h=c[a+4>>2],c[r>>2]=c[a>>2],c[r+4>>2]=h,h=c[a+20>>2],c[r+16>>2]=c[a+16>>2],c[r+20>>2]=h,h=c[a+12>>2],c[r+8>>2]=c[a+8>>2],c[r+12>>2]=h,Vi(r+24|0,a+24|0,204),Vi(r+228|0,a+228|0,328),h=c[r+556>>2],h&&(c[r+560>>2]=h,Ti(h)),c[r+556>>2]=c[a+556>>2],c[r+560>>2]=c[a+560>>2],c[r+564>>2]=c[a+564>>2],c[r+584>>2]=c[a+584>>2],h=c[a+580>>2],c[r+576>>2]=c[a+576>>2],c[r+580>>2]=h,h=c[a+572>>2],c[r+568>>2]=c[a+568>>2],c[r+572>>2]=h,kt=u+624|0;return}c[u+16>>2]=3301,lr(r,u+16|0),tr(),ce()}c[u>>2]=2047,lr(r,u),tr(),ce()}function Fp(){rT(7084,3067),iT(7085,2480,1,1,0),fs(7086,2140,1,-128,127),fs(7087,2133,1,-128,127),fs(7088,2131,1,0,255),fs(7089,1287,2,-32768,32767),fs(7090,1278,2,0,65535),fs(7091,1316,4,-2147483648,2147483647),fs(7092,1307,4,0,-1),fs(7093,2659,4,-2147483648,2147483647),fs(7094,2650,4,0,-1),p2(7095,1777,-2147483648,2147483647),p2(7096,1776,0,-1),kp(7097,1770,4),kp(7098,3015,8),wp(7099,2677),wp(7100,3904),Ih(7101,4,2664),Ih(7102,2,2689),Ih(7103,4,2704),eT(7104,2485),Ii(7105,0,3835),Ii(7106,0,3937),Ii(7107,1,3865),Ii(7108,2,3467),Ii(7109,3,3498),Ii(7110,4,3538),Ii(7111,5,3567),Ii(7112,4,3974),Ii(7113,5,4004),Ii(7106,0,3669),Ii(7107,1,3636),Ii(7108,2,3735),Ii(7109,3,3701),Ii(7110,4,3802),Ii(7111,5,3768),Ii(7114,6,3605),Ii(7115,7,4043)}function Ns(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 Vi(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(gt[u|0]=Tt[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,gt[u|0]=Tt[a+h|0],!(u&3))break}if(h>>>0<=3)break e;for(;h=h-4|0,c[h+r>>2]=c[a+h>>2],h>>>0>3;);}if(!h)break t;for(;h=h-1|0,gt[h+r|0]=Tt[a+h|0],!!h;);break t}if(h>>>0<=3)break r;for(;c[u>>2]=c[a>>2],a=a+4|0,u=u+4|0,h=h-4|0,h>>>0>3;);}if(!h)break t;for(;gt[u|0]=Tt[a|0],u=u+1|0,a=a+1|0,h=h-1|0,!!h;);}return r}function Np(r,a,h,u){t:switch(a-9|0){case 0:a=c[h>>2],c[h>>2]=a+4,c[r>>2]=c[a>>2];return;case 6:a=c[h>>2],c[h>>2]=a+4,a=Hr[a>>1],c[r>>2]=a,c[r+4>>2]=a>>31;return;case 7:a=c[h>>2],c[h>>2]=a+4,c[r>>2]=Bn[a>>1],c[r+4>>2]=0;return;case 8:a=c[h>>2],c[h>>2]=a+4,a=gt[a|0],c[r>>2]=a,c[r+4>>2]=a>>31;return;case 9:a=c[h>>2],c[h>>2]=a+4,c[r>>2]=Tt[a|0],c[r+4>>2]=0;return;case 16:a=c[h>>2]+7&-8,c[h>>2]=a+8,He[r>>3]=He[a>>3];return;case 17:Pt[u|0](r,h);default:return;case 1:case 4:case 14:a=c[h>>2],c[h>>2]=a+4,a=c[a>>2],c[r>>2]=a,c[r+4>>2]=a>>31;return;case 2:case 5:case 11:case 15:a=c[h>>2],c[h>>2]=a+4,c[r>>2]=c[a>>2],c[r+4>>2]=0;return;case 3:case 10:case 12:case 13:break t}a=c[h>>2]+7&-8,c[h>>2]=a+8,h=c[a+4>>2],c[r>>2]=c[a>>2],c[r+4>>2]=h}function Up(r,a,h,u){var y=0,b=0,k=0,S=0,P=0,K=0,et=0,ft=0,Q=0,it=m(0),M=m(0),W=m(0),Y=0,Z=m(0);t:{if(a==0||(it=I[r+248>>2],M=I[r+244>>2],W=I[r+232>>2],P=+I[r+228>>2],y=Tt[r+4|0]&8,b=y>>>3|0,Y=r,Z=Kr(P,a,0,b),I[Y+228>>2]=Z,K=+W,Y=r,Z=Kr(K,a,0,b),I[Y+232>>2]=Z,et=+M,k=Oh(et*a),b=k==k&Xe(k)<1e-4,S=!(b|k!=k?b:Xe(k+-1)<1e-4),ft=+it,k=Oh(ft*a),b=k==k&Xe(k)<1e-4,Q=!(b|k!=k?b:Xe(k+-1)<1e-4),b=0,h=P+h,y=(y|0)!=0,Y=r,Z=m(Kr(h+et,a,y&S,y&!S)-Kr(h,a,0,y)),I[Y+244>>2]=Z,u=K+u,Y=r,Z=m(Kr(u+ft,a,y&Q,y&!Q)-Kr(u,a,0,y)),I[Y+248>>2]=Z,y=c[r+560>>2],S=c[r+556>>2],(y|0)==(S|0)))break t;for(y=y-S>>2,S=y>>>0<=1?1:y;y=c[r+556>>2],c[r+560>>2]-y>>2>>>0>b>>>0?y=c[y+(b<<2)>>2]:y=0,Up(y,a,h,u),b=b+1|0,(S|0)!=(b|0););}}function Hi(r,a,h){var u=0,y=0,b=0,k=0;t:{if(!h||(gt[r|0]=a,u=r+h|0,gt[u-1|0]=a,h>>>0<3)||(gt[r+2|0]=a,gt[r+1|0]=a,gt[u-3|0]=a,gt[u-2|0]=a,h>>>0<7)||(gt[r+3|0]=a,gt[u-4|0]=a,h>>>0<9)||(u=0-r&3,y=u+r|0,a=We(a&255,16843009),c[y>>2]=a,u=h-u&-4,h=u+y|0,c[h-4>>2]=a,u>>>0<9)||(c[y+8>>2]=a,c[y+4>>2]=a,c[h-8>>2]=a,c[h-12>>2]=a,u>>>0<25)||(c[y+24>>2]=a,c[y+20>>2]=a,c[y+16>>2]=a,c[y+12>>2]=a,c[h-16>>2]=a,c[h-20>>2]=a,c[h-24>>2]=a,c[h-28>>2]=a,k=y&4|24,h=u-k|0,h>>>0<32))break t;for(u=Bh(a,0,1,1),b=Gi,a=y+k|0;c[a+24>>2]=u,c[a+28>>2]=b,c[a+16>>2]=u,c[a+20>>2]=b,c[a+8>>2]=u,c[a+12>>2]=b,c[a>>2]=u,c[a+4>>2]=b,a=a+32|0,h=h-32|0,h>>>0>31;);}return r}function Ti(r){r=r|0;var a=0,h=0,u=0,y=0,b=0;if(r){a=r-4|0,y=c[a>>2],h=y,u=a,b=c[r-8>>2],r=b&-2,(r|0)!=(b|0)&&(u=a-r|0,h=c[u+4>>2],c[h+8>>2]=c[u+8>>2],c[c[u+8>>2]+4>>2]=h,h=r+y|0),r=a+y|0,a=c[r>>2],(a|0)!=c[(r+a|0)-4>>2]&&(y=c[r+4>>2],c[y+8>>2]=c[r+8>>2],c[c[r+8>>2]+4>>2]=y,h=a+h|0),c[u>>2]=h,c[((h&-4)+u|0)-4>>2]=h|1,a=c[u>>2]-8|0;t:{if(a>>>0<=127){r=(a>>>3|0)-1|0;break t}if(h=Er(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,c[u+4>>2]=a+5968,a=a+5976|0,c[u+8>>2]=c[a>>2],c[a>>2]=u,c[c[u+8>>2]+4>>2]=u,a=c[1750],h=c[1751],u=r&31,(r&63)>>>0>=32?(r=1<<u,y=0):(y=1<<u,r=y-1&1>>>32-u),c[1750]=y|a,c[1751]=r|h}}function dT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0,P=0,K=0;u=kt-32|0,kt=u,y=c[r+28>>2],c[u+16>>2]=y,b=c[r+20>>2],c[u+28>>2]=h,c[u+24>>2]=a,a=b-y|0,c[u+20>>2]=a,b=a+h|0,P=2,a=u+16|0;t:{for(;;){r:{i:{e:{if(!u2(JE(c[r+60>>2],a|0,P|0,u+12|0)|0)){if(k=c[u+12>>2],(k|0)==(b|0))break e;if((k|0)>=0)break i;break r}if((b|0)!=-1)break r}a=c[r+44>>2],c[r+28>>2]=a,c[r+20>>2]=a,c[r+16>>2]=a+c[r+48>>2],r=h;break t}S=c[a+4>>2],K=S>>>0<k>>>0,y=(K<<3)+a|0,S=k-(K?S:0)|0,c[y>>2]=S+c[y>>2],a=(K?12:4)+a|0,c[a>>2]=c[a>>2]-S,b=b-k|0,P=P-K|0,a=y;continue}break}if(c[r+28>>2]=0,c[r+16>>2]=0,c[r+20>>2]=0,c[r>>2]=c[r>>2]|32,r=0,(P|0)==2)break t;r=h-c[a+4>>2]|0}return kt=u+32|0,r|0}function uT(r){r=r|0;var a=0,h=0,u=0,y=0,b=0;h=kt-96|0,kt=h,c[h>>2]=r,u=kt-16|0,kt=u,c[u+12>>2]=h,r=kt-144|0,kt=r,r=Vi(r,5520,144),b=h+16|0,a=b,c[r+44>>2]=a,c[r+20>>2]=a,y=-2-a|0,y=y>>>0>=2147483647?2147483647:y,c[r+48>>2]=y,a=a+y|0,c[r+28>>2]=a,c[r+16>>2]=a,Bp(r,2202,h,0,0),y&&(a=c[r+20>>2],gt[a-((a|0)==c[r+16>>2])|0]=0),kt=r+144|0,kt=u+16|0,r=b;t:{if(r&3)for(;;){if(!Tt[r|0])break t;if(r=r+1|0,!(r&3))break}for(;a=r,r=r+4|0,u=c[a>>2],!((u^-1)&u-16843009&-2139062144););for(;r=a,a=r+1|0,!!Tt[r|0];);}return r=(r-b|0)+1|0,a=Ph(r),a?r=Vi(a,b,r):r=0,kt=h+96|0,r|0}function Bp(r,a,h,u,y){var b=0,k=0,S=0,P=0;b=kt-208|0,kt=b,c[b+204>>2]=h,h=b+160|0,Hi(h,0,40),c[b+200>>2]=c[b+204>>2];t:{if((Cp(0,a,b+200|0,b+80|0,h,u,y)|0)<0){y=-1;break t}P=c[r+76>>2]>=0,k=c[r>>2],c[r+72>>2]<=0&&(c[r>>2]=k&-33);r:{i:{e:{if(!c[r+48>>2]){c[r+48>>2]=80,c[r+28>>2]=0,c[r+16>>2]=0,c[r+20>>2]=0,S=c[r+44>>2],c[r+44>>2]=b;break e}if(c[r+16>>2])break i}if(h=-1,Jp(r))break r}h=Cp(r,a,b+200|0,b+80|0,b+160|0,u,y)}if(S&&(Pt[c[r+36>>2]](r,0,0)|0,c[r+48>>2]=0,c[r+44>>2]=S,c[r+28>>2]=0,a=c[r+20>>2],c[r+16>>2]=0,c[r+20>>2]=0,h=a?h:-1),a=r,r=c[r>>2],c[a>>2]=r|k&32,y=r&32?-1:h,!P)break t}return kt=b+208|0,y}function cl(r){var a=0,h=m(0),u=0,y=0,b=0,k=0,S=0,P=m(0),K=0;b=kt-16|0,kt=b,a=c[r+12>>2];t:{if(a){P=I[r+520>>2],h=I[r+516>>2];r:{if(Tt[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;c[b>>2]=3409,lr(r,b),tr(),ce()}r:{i:{if(k=c[r+556>>2],a=c[r+560>>2],(k|0)!=(a|0)){for(a=a-k>>2,K=a>>>0<=1?1:a;;){if(y=c[(S<<2)+k>>2],!c[y+548>>2]){if(a=c[y+24>>2],(a&196608)!=131072){if(a=a>>>13&7,a||(a=c[r+24>>2]>>>10&7),Tt[y+4|0]&2|(Tt[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(cl(u)+I[u+232>>2])}return kt=b+16|0,h}function Vn(r,a,h,u,y,b){var k=0,S=m(0),P=0,K=m(0);k=(c[(a<<2)+4320>>2]<<2)+r|0,S=I[k+216>>2];t:{r:{k=c[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),c[P+4>>2]-1|0){case 0:break r;case 1:break i;default:break t}}if(K=(xt(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(he(r,a,u)+Se(r,a,u)));t:{r:{i:switch(c[y>>2]){case 1:case 2:h=I[b>>2],u=u!=u||h<u?h:u;break r;case 0:break i;default:break t}if(u!=u)break t;c[y>>2]=2}I[b>>2]=u}}function xe(r,a,h){var u=m(0),y=m(0),b=0,k=m(0);r=r+116|0,b=c[(a<<2)+4288>>2];t:{if((a&-2)==2){a=Wr(r,4,b,2140081935);break t}a=jr(r,b,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=(xt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(Yt),c[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break r}}if(u=(xt(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 Pe(r,a,h){var u=m(0),y=m(0),b=0,k=m(0);r=r+116|0,b=c[(a<<2)+4304>>2];t:{if((a&-2)==2){a=Wr(r,5,b,2140081935);break t}a=jr(r,b,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=(xt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(Yt),c[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break r}}if(u=(xt(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 Gp(r,a,h,u,y,b){var k=0;t:{r:{if(r){i:{if(a&4){b=Pt[r|0](h,u,y,b)|0;break i}b=Pt[r|0](h,u,y)|0}if(b)break r}if(b=ut(588),a=Vi(b,h,552),c[a+564>>2]=0,c[a+556>>2]=0,c[a+560>>2]=0,y=c[h+556>>2],u=c[h+560>>2],(y|0)!=(u|0)){if(k=u-y|0,(k|0)<0)break t;for(r=ut(k),c[a+556>>2]=r,c[a+564>>2]=r+k;c[r>>2]=c[y>>2],r=r+4|0,y=y+4|0,(u|0)!=(y|0););c[a+560>>2]=r}r=c[h+572>>2],c[a+568>>2]=c[h+568>>2],c[a+572>>2]=r,c[a+584>>2]=c[h+584>>2],r=c[h+580>>2],c[a+576>>2]=c[h+576>>2],c[a+580>>2]=r,c[a+552>>2]=0}return b}Fs(),ce()}function lr(r,a){var h=0,u=0,y=0;y=kt-16|0,kt=y,c[y+12>>2]=a;t:{r:{if(!r){a=c[y+12>>2];break r}if(a=c[y+12>>2],h=c[r+568>>2],!h)break r;if(u=c[h+4>>2],Tt[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(!Tt[7016]){h=ut(28),c[h+20>>2]=1065353216,c[h+24>>2]=0,c[h+12>>2]=0,c[h+16>>2]=0,c[h>>2]=0,gt[h+8|0]=0,u=1,c[h+4>>2]=1,c[1753]=h,gt[7016]=1,c[1752]=c[1752]+1;break r}if(h=c[1753],u=c[h+4>>2],!(Tt[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}kt=y+16|0}function Ga(r,a,h){var u=m(0),y=0,b=m(0);r=r+80|0,y=c[(a<<2)+4304>>2];t:{r:{if((a&-2)==2){a=Wr(r,5,y,2140081935);break r}a=jr(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=(xt(2,a),Bt()),u==u)break e;r=4344}switch(u=I[r>>2],b=m(Yt),c[r+4>>2]-1|0){case 0:break t;case 1:break i;default:break r}}if(u=(xt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break t}b=m(m(u*h)*m(.009999999776482582))}return b}return u}function Us(r,a,h){var u=m(0),y=0,b=m(0);r=r+80|0,y=c[(a<<2)+4288>>2];t:{r:{if((a&-2)==2){a=Wr(r,4,y,2140081935);break r}a=jr(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=(xt(2,a),Bt()),u==u)break e;r=4344}switch(u=I[r>>2],b=m(Yt),c[r+4>>2]-1|0){case 0:break t;case 1:break i;default:break r}}if(u=(xt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break t}b=m(m(u*h)*m(.009999999776482582))}return b}return u}function Wr(r,a,h,u){var y=m(0);a=(a<<2)+r|0,y=I[a>>2],a=c[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=c[a>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(a=c[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=c[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(a=u,y!=y)))break t;a=r}return a}function fT(r,a){r=r|0,a=m(a);var h=0,u=0,y=0;if(h=kt-16|0,kt=h,r=c[r>>2],!(a>=m(0))){c[h>>2]=2263,u=kt-16|0,kt=u,c[u+12>>2]=h;t:{if(r)break t;if(Tt[7016]){r=c[1753];break t}r=ut(28),c[r+20>>2]=1065353216,c[r+24>>2]=0,c[r+12>>2]=0,c[r+16>>2]=0,c[r>>2]=0,gt[r+8|0]=0,c[r+4>>2]=1,c[1753]=r,gt[7016]=1,c[1752]=c[1752]+1}y=c[r+4>>2];t:{if(Tt[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}kt=u+16|0,tr(),ce()}I[r+20>>2]=a==m(0)?m(0):a,kt=h+16|0}function Vp(r,a,h,u,y){var b=0,k=0,S=m(0),P=0;b=2,k=c[r+24>>2]>>>2&3;t:{r:{i:{if(!(!c[r+552>>2]|(a|0)!=2)){a=0,b=3;e:switch(k-2|0){case 0:break t;case 1:break e;default:break i}b=2;break t}if(a=0,k>>>0>1)break r}a=b}b=k}h=l2(r,b,h),u=l2(r,a,u),S=he(r,b,y),k=r+228|0,P=b<<2,I[k+(c[P+4288>>2]<<2)>>2]=h+S,S=Se(r,b,y),I[k+(c[P+4304>>2]<<2)>>2]=h+S,h=he(r,a,y),b=a<<2,I[k+(c[b+4288>>2]<<2)>>2]=u+h,h=Se(r,a,y),I[k+(c[b+4304>>2]<<2)>>2]=u+h}function pT(r,a,h,u,y,b){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0,S=0,P=0;k=kt-48|0,kt=k,P=c[a+8>>2];t:{if(gt[7052]&1){a=c[1762];break t}a=Tp(5,4480)|0,gt[7052]=1,c[1762]=a}c[k+40>>2]=b,I[k+32>>2]=y,c[k+24>>2]=u,I[k+16>>2]=h,S=+zE(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=c[k+12>>2],b=c[a+4>>2],c[r>>2]=c[a>>2],c[r+4>>2]=b,b=c[a+12>>2],c[r+8>>2]=c[a+8>>2],c[r+12>>2]=b,KE(u|0),kt=k+48|0}function gT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0;if(u=kt-32|0,kt=u,y=c[a>>2],y>>>0<2147483632){t:{r:{if(y>>>0>=11){b=(y|15)+1|0,k=ut(b),c[u+16>>2]=b|-2147483648,c[u+8>>2]=k,c[u+12>>2]=y,b=y+k|0;break r}if(gt[u+19|0]=y,k=u+8|0,b=k+y|0,!y)break t}Vi(k,a+4|0,y)}return gt[b|0]=0,c[u>>2]=h,Pt[r|0](u+24|0,u+8|0,u),jE(c[u+24>>2]),r=c[u+24>>2],Ba(r|0),Ba(c[u>>2]),gt[u+19|0]<0&&Ti(c[u+8>>2]),kt=u+32|0,r|0}Fs(),ce()}function gi(r,a,h){var u=0,y=0,b=0;if(!(Tt[r|0]&32))t:{u=a,a=r,r=c[a+16>>2];r:{if(!r){if(Jp(a))break r;r=c[a+16>>2]}if(b=c[a+20>>2],r-b>>>0<h>>>0){Pt[c[a+36>>2]](a,u,h)|0;break t}i:{if(c[a+80>>2]<0)break i;for(r=h;;){if(y=r,!r)break i;if(r=y-1|0,Tt[u+r|0]==10)break}if(Pt[c[a+36>>2]](a,u,y)>>>0<y>>>0)break r;u=u+y|0,h=h-y|0,b=c[a+20>>2]}Vi(b,u,h),c[a+20>>2]=c[a+20>>2]+h}}}function Fh(r,a,h){var u=0,y=0,b=0;u=kt-16|0,kt=u,y=r+24|0,Pt[a|0](u+8|0,y),b=c[u+12>>2];t:{if((c[c[u+8>>2]>>2]&7<<b)>>b==(h|0))break t;for(Pt[a|0](u+8|0,y),a=c[u+8>>2],y=a,b=c[a>>2],a=c[u+12>>2],c[y>>2]=b&(7<<a^-1)|(h&7)<<a;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}kt=u+16|0}function jr(r,a,h){var u=m(0);a=(a<<2)+r|0,u=I[a>>2],a=c[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=c[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=c[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(a=h,u!=u)))break t;a=r}return a}function Se(r,a,h){var u=m(0),y=0;r=r+44|0,y=c[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Wr(r,5,y,2140081935);break t}r=jr(r,y,2140081935)}t:{if((r|0)!=2139156720){if((r|0)==2140081935|(r|0)==2141891242)break t;if(u=(xt(2,r),Bt()),u!=u)return m(Yt);if(u=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function he(r,a,h){var u=m(0),y=0;r=r+44|0,y=c[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Wr(r,4,y,2140081935);break t}r=jr(r,y,2140081935)}t:{if((r|0)!=2139156720){if((r|0)==2140081935|(r|0)==2141891242)break t;if(u=(xt(2,r),Bt()),u!=u)return m(Yt);if(u=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function mT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0;return y=c[r+84>>2],b=c[y>>2],u=c[y+4>>2],S=c[r+28>>2],k=c[r+20>>2]-S|0,k=u>>>0<k>>>0?u:k,k&&(Vi(b,S,k),b=k+c[y>>2]|0,c[y>>2]=b,u=c[y+4>>2]-k|0,c[y+4>>2]=u),u=h>>>0>u>>>0?u:h,u&&(Vi(b,a,u),b=u+c[y>>2]|0,c[y>>2]=b,c[y+4>>2]=c[y+4>>2]-u),gt[b|0]=0,a=c[r+44>>2],c[r+28>>2]=a,c[r+20>>2]=a,h|0}function Re(r,a){var h=m(0),u=0;r=r+152|0,u=c[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Wr(r,5,u,2140081935);break t}r=jr(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=(xt(2,r),Bt()),h!=h))break r;h=(xt(2,(r&-1073741825)+536870912|0),Bt());break t}h=m(Yt)}return oe(h,m(0))}function pe(r,a){var h=m(0),u=0;r=r+152|0,u=c[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Wr(r,4,u,2140081935);break t}r=jr(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=(xt(2,r),Bt()),h!=h))break r;h=(xt(2,(r&-1073741825)+536870912|0),Bt());break t}h=m(Yt)}return oe(h,m(0))}function vT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=c[a>>2]+(h<<2)|0,b=I[a+116>>2];t:{r:{if(a=c[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(b!=b){u=0;break t}u=a&1073741824?2:1,y=(xt(2,(a&-1073741825)+536870912|0),+Bt())}He[r+8>>3]=y,c[r>>2]=u}function yT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=c[a>>2]+(h<<2)|0,b=I[a+80>>2];t:{r:{if(a=c[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(b!=b){u=0;break t}u=a&1073741824?2:1,y=(xt(2,(a&-1073741825)+536870912|0),+Bt())}He[r+8>>3]=y,c[r>>2]=u}function bT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=c[a>>2]+(h<<2)|0,b=I[a+44>>2];t:{r:{if(a=c[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(b!=b){u=0;break t}u=a&1073741824?2:1,y=(xt(2,(a&-1073741825)+536870912|0),+Bt())}He[r+8>>3]=y,c[r>>2]=u}function Kr(r,a,h,u){var y=0,b=0,k=0;r=r*a,y=Oh(r),y=y<0?y+1:y,k=y!=y;t:{if(!(k|!(Xe(y)<1e-4))){r=r-y;break t}r:{if(y!=y){r=r-y;break r}if(r=r-y,!(Xe(y+-1)<1e-4))break r;r=r+1;break t}if(h){r=r+1;break t}if(u)break t;b=0;r:{if(k||(b=1,y>.5))break r;b=Xe(y+-.5)<1e-4?1:0}r=r+b}return r!=r|a!=a?m(Yt):m(r/a)}function Hp(r,a){var h=m(0);t:{if((a|0)!=2139156720){if((a|0)!=2140081935){if((a|0)!=2141891242)break t;c[r>>2]=2143289344,c[r+4>>2]=3;return}c[r>>2]=0,c[r+4>>2]=1;return}c[r>>2]=0,c[r+4>>2]=2;return}if(h=(xt(2,a),Bt()),h!=h){c[r>>2]=2143289344,c[r+4>>2]=0;return}c[r+4>>2]=a&1073741824?2:1,c[r>>2]=(a&-1073741825)+536870912}function Wp(r){var a=0,h=0,u=0;h=c[r+24>>2];t:{if(!(h&8)||(a=1,(h&7168)==5120)||(a=0,u=c[r+560>>2],h=c[r+556>>2],(u|0)==(h|0)))break t;for(r=u-h>>2,u=r>>>0<=1?1:r,r=0;;){if(a=c[c[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 AT(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+220>>2];t:{r:{if(a=c[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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,He[r+8>>3]=u,c[r>>2]=a}function ET(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+200>>2];t:{r:{if(a=c[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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,He[r+8>>3]=u,c[r>>2]=a}function TT(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+204>>2];t:{r:{if(a=c[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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,He[r+8>>3]=u,c[r>>2]=a}function kT(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+208>>2];t:{r:{if(a=c[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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,He[r+8>>3]=u,c[r>>2]=a}function wT(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+212>>2];t:{r:{if(a=c[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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,He[r+8>>3]=u,c[r>>2]=a}function ST(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+216>>2];t:{r:{if(a=c[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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,He[r+8>>3]=u,c[r>>2]=a}function RT(r,a){r=r|0,a=a|0;var h=0;if(h=kt-16|0,kt=h,r=c[r>>2],(a|0)<6){kt=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+260|0,(Tt[r+300|0]&3)==2)break t;a=r+252|0;break t;case 1:if(a=r+252|0,(Tt[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]}c[h>>2]=1872,lr(r,h),tr(),ce()}function _T(r,a){r=r|0,a=a|0;var h=0;if(h=kt-16|0,kt=h,r=c[r>>2],(a|0)<6){kt=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+276|0,(Tt[r+300|0]&3)==2)break t;a=r+268|0;break t;case 1:if(a=r+268|0,(Tt[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]}c[h>>2]=1872,lr(r,h),tr(),ce()}function LT(r,a){r=r|0,a=a|0;var h=0;if(h=kt-16|0,kt=h,r=c[r>>2],(a|0)<6){kt=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+292|0,(Tt[r+300|0]&3)==2)break t;a=r+284|0;break t;case 1:if(a=r+284|0,(Tt[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]}c[h>>2]=1872,lr(r,h),tr(),ce()}function CT(r,a){r=r|0,a=a|0;var h=0,u=m(0),y=m(0);u=m(Yt),a=c[a>>2],y=I[a+40>>2],a=c[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=(xt(2,(a&-1073741825)+536870912|0),Bt()),h=a&1073741824?2:1}c[r>>2]=h,He[r+8>>3]=u}function zr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Xe(r))==m(Ep)|r!=r||(a=2139156720,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(xt(2,(Ji(r),te(2)&-2147483648|1602224127)),Bt()),a=(Ji(r>m(0xffffff0000000000)||r<m(-0xffffff0000000000)?h:r),te(2)-536870912|1073741824)}return a}function Tr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Xe(r))==m(Ep)|r!=r||(a=2140081935,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(xt(2,(Ji(r),te(2)&-2147483648|1610612735)),Bt()),a=(Ji(r>m(36893485948395848e3)||r<m(-36893485948395848e3)?h:r),te(2)-536870912|0)}return a}function IT(r,a){r=r|0,a=a|0;var h=m(0),u=m(0);r=c[r>>2]+(a<<2)|0,u=I[r+188>>2];t:{r:{if(r=c[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((xt(2,(r&-1073741825)+536870912|0),Bt()))}h=m(0)}return m(h)}function DT(r,a,h,u,y,b){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0,S=0;return k=kt-16|0,kt=k,S=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(S=c[S+c[a>>2]>>2]),Pt[S|0](k,a,h,u,y,b),r=ut(16),a=c[k+12>>2],c[r+8>>2]=c[k+8>>2],c[r+12>>2]=a,a=c[k+4>>2],c[r>>2]=c[k>>2],c[r+4>>2]=a,kt=k+16|0,r|0}function jp(r,a){t:{if(a){a=d2(c[a>>2]);break t}r:{if(Tt[7016]){a=c[1753];break r}a=ut(28),c[a+20>>2]=1065353216,c[a+24>>2]=0,c[a+12>>2]=0,c[a+16>>2]=0,c[a>>2]=0,gt[a+8|0]=0,c[a+4>>2]=1,c[1753]=a,gt[7016]=1,c[1752]=c[1752]+1}a=d2(a)}return c[r+4>>2]=0,c[r+8>>2]=0,c[r>>2]=a,c[a>>2]=r,r}function xT(r,a,h){r=r|0,a=a|0,h=+h;var u=0,y=0;t:{if(r=c[r>>2],a=r+(a<<2)|0,y=c[a+152>>2],u=Tr(m(h)),(y|0)==(u|0))break t;for(c[a+152>>2]=u;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function PT(r,a,h){r=r|0,a=a|0,h=+h;var u=0,y=0;t:{if(r=c[r>>2],a=r+(a<<2)|0,y=c[a+188>>2],u=Tr(m(h)),(y|0)==(u|0))break t;for(c[a+188>>2]=u;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function OT(r,a){r=r|0,a=a|0;var h=0,u=m(0);r=c[r>>2]+(a<<2)|0,u=I[r+152>>2];t:{r:{if(r=c[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 xt(2,(r&-1073741825)+536870912|0),+Bt()}h=0}return+h}function MT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=c[r>>2],h=c[r+24>>2],(h>>>20&3)==(a|0))break t;for(c[r+24>>2]=h&-3145729|a<<20&3145728;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Hn(r,a,h){var u=0,y=0,b=0;t:{if(!a){u=r;break t}for(;u=Op(r,a,10),y=Gi,r=Bh(u,y,246,0)+r|0,h=h-1|0,gt[h|0]=r|48,b=a>>>0>9,r=u,a=y,!!b;);}if(u)for(;h=h-1|0,r=(u>>>0)/10|0,gt[h|0]=We(r,246)+u|48,a=u>>>0>9,u=r,!!a;);return h}function $T(r,a){r=r|0,a=a|0;var h=0;t:{if(r=c[r>>2],h=c[r+24>>2],(h>>>22&1)==(a|0))break t;for(c[r+24>>2]=h&-4194305|a<<22&4194304;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function FT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=c[r>>2],h=c[r+24>>2],(h>>>18&3)==(a|0))break t;for(c[r+24>>2]=h&-786433|a<<18&786432;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function NT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=c[r>>2],h=c[r+24>>2],(h>>>16&3)==(a|0))break t;for(c[r+24>>2]=h&-196609|a<<16&196608;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[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=c[r>>2],y=I[r+224>>2],u==y|u!=u&y!=y)break t;for(I[r+224>>2]=u;;){if(h=Tt[r+4|0],h&4)break t;if(gt[r+4|0]=h|4,h=c[r+20>>2],h&&Pt[h|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function BT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=c[r>>2],y=I[r+28>>2],u==y|u!=u&y!=y)break t;for(I[r+28>>2]=u;;){if(h=Tt[r+4|0],h&4)break t;if(gt[r+4|0]=h|4,h=c[r+20>>2],h&&Pt[h|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function GT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=c[r>>2],y=I[r+32>>2],u==y|u!=u&y!=y)break t;for(I[r+32>>2]=u;;){if(h=Tt[r+4|0],h&4)break t;if(gt[r+4|0]=h|4,h=c[r+20>>2],h&&Pt[h|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function VT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=c[r>>2],y=I[r+36>>2],u==y|u!=u&y!=y)break t;for(I[r+36>>2]=u;;){if(h=Tt[r+4|0],h&4)break t;if(gt[r+4|0]=h|4,h=c[r+20>>2],h&&Pt[h|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function HT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=c[r>>2],h=c[r+24>>2],(h>>>4&7)==(a|0))break t;for(c[r+24>>2]=h&-113|a<<4&112;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function WT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=c[r>>2],h=c[r+24>>2],(h>>>2&3)==(a|0))break t;for(c[r+24>>2]=h&-13|a<<2&12;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function jT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=c[r>>2],h=Tt[r+4|0],((h&2)>>>1|0)==(a|0))break t;for(gt[r+4|0]=h&253|(a?2:0);;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function KT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;return u=kt-16|0,kt=u,y=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(y=c[y+c[a>>2]>>2]),Pt[y|0](u,a,h),r=ut(16),a=c[u+12>>2],c[r+8>>2]=c[u+8>>2],c[r+12>>2]=a,a=c[u+4>>2],c[r>>2]=c[u>>2],c[r+4>>2]=a,kt=u+16|0,r|0}function Kp(r,a){var h=0,u=0;t:{r:{if(h=c[r+556>>2],u=c[r+560>>2],(h|0)==(u|0))break r;for(;;){if(c[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,Ns(h,a,u-a|0),c[r+560>>2]=u-4,1}return 0}function zT(r){r=r|0;var a=0,h=0;if(h=kt-16|0,kt=h,r=c[r>>2],c[r+8>>2]){for(;a=Tt[r+4|0],!!(!(a&4)&&(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],r)););kt=h+16|0;return}c[h>>2]=1024,lr(r,h),tr(),ce()}function zp(r,a){var h=0,u=0,y=0;if(Ei(+r),u=te(1)|0,y=te(0)|0,h=u>>>20&2047,(h|0)!=2047){if(!h)return r==0?h=0:(r=zp(r*18446744073709552e3,a),h=c[a>>2]+-64|0),c[a>>2]=h,r;c[a>>2]=h-1022,xt(0,y|0),xt(1,u&-2146435073|1071644672),r=+Ee()}return r}function YT(r,a){r=r|0,a=a|0;var h=0,u=0;return h=kt-16|0,kt=h,u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),Pt[u|0](h,a),r=ut(16),a=c[h+12>>2],c[r+8>>2]=c[h+8>>2],c[r+12>>2]=a,a=c[h+4>>2],c[r>>2]=c[h>>2],c[r+4>>2]=a,kt=h+16|0,r|0}function hl(r,a,h){var u=0;t:{if(u=r+24|0,c[(u+(a<<2)|0)+184>>2]==(h|0))break t;for(c[((a<<2)+u|0)+184>>2]=h;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function dl(r,a,h){var u=0;t:{if(u=r+24|0,c[(u+(a<<2)|0)+192>>2]==(h|0))break t;for(c[((a<<2)+u|0)+192>>2]=h;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Wn(r,a,h){var u=0;t:{if(u=r+24|0,c[(u+(a<<2)|0)+176>>2]==(h|0))break t;for(c[((a<<2)+u|0)+176>>2]=h;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Nh(r,a){var h=0,u=0,y=0;t:{if(h=r+24|0,c[h+16>>2]==(a|0))break t;for(u=Pt[9](h)|0,y=a,c[u+16>>2]=y;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Yp(r,a,h){var u=0;t:{if(u=r+24|0,c[(u+(a<<2)|0)+92>>2]==(h|0))break t;for(c[((a<<2)+u|0)+92>>2]=h;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Uh(r,a,h){var u=0;t:{if(u=r+24|0,c[(u+(a<<2)|0)+20>>2]==(h|0))break t;for(c[((a<<2)+u|0)+20>>2]=h;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Xp(r,a,h){var u=0;t:{if(u=r+24|0,c[(u+(a<<2)|0)+56>>2]==(h|0))break t;for(c[((a<<2)+u|0)+56>>2]=h;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function XT(){for(var r=0,a=0,h=0;a=r<<4,h=a+5968|0,c[a+5972>>2]=h,c[a+5976>>2]=h,r=r+1|0,(r|0)!=64;);Mh(48),c[1756]=16,c[1757]=0,Lp(),c[1757]=c[1768],c[1768]=7024,c[1769]=198,c[1770]=0,Fp(),c[1770]=c[1768],c[1768]=7076}function cr(r,a){var h=0,u=m(0);r=r+80|0,h=c[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Wr(r,4,h,2143289344);break t}r=jr(r,h,2143289344)}return(r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242?r=1:(u=(xt(2,r),Bt()),r=u==u),r}function ul(r,a){var h=0,u=m(0);r=r+80|0,h=c[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Wr(r,5,h,2143289344);break t}r=jr(r,h,2143289344)}return(r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242?r=1:(u=(xt(2,r),Bt()),r=u==u),r}function Bh(r,a,h,u){var y=0,b=0,k=0,S=0,P=0,K=0;return y=h>>>16|0,b=r>>>16|0,K=We(y,b),k=h&65535,S=r&65535,P=We(k,S),b=(P>>>16|0)+We(b,k)|0,y=(b&65535)+We(y,S)|0,Gi=(We(a,h)+K|0)+We(r,u)+(b>>>16)+(y>>>16)|0,P&65535|y<<16}function Zp(r,a){var h=0,u=0,y=0;u=kt-16|0,kt=u,h=Tt[r+4|0],y=h&-17,gt[r+4|0]=y;t:{if(a){if(c[r+560>>2]!=c[r+556>>2])break t;h=y|8}else h=h&231;c[r+8>>2]=a,gt[r+4|0]=h,kt=u+16|0;return}c[u>>2]=4128,lr(r,u),tr(),ce()}function qp(r){var a=0,h=m(0);a=0;t:{if((c[r+24>>2]&196608)==131072)break t;r:{if(!c[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=jn(r)!=m(0)}return a}function ki(r,a,h,u,y){var b=0;if(b=kt-256|0,kt=b,!(y&73728|(h|0)<=(u|0))){if(u=h-u|0,h=u>>>0<256,Hi(b,a&255,h?u:256),!h)for(;gi(r,b,256),u=u-256|0,u>>>0>255;);gi(r,b,u)}kt=b+256|0}function mn(r,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=a- -64|0,y=I[u>>2],u=c[u>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=c[((c[(h<<2)+4304>>2]<<2)+a|0)+44>>2]}Hp(r,u)}function vn(r,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=c[a+60>>2],y=I[a+60>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=c[((c[(h<<2)+4288>>2]<<2)+a|0)+44>>2]}Hp(r,u)}function jn(r){var a=m(0),h=m(0);if(!c[r+552>>2])return m(0);a=I[r+36>>2];t:{if(a==a||(a=m(1),gt[c[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 Qp(r){var a=0,h=0,u=0;for(u=c[r>>2];;){if(h=gt[u|0],pl(h)){u=u+1|0,c[r>>2]=u,a>>>0<=214748364?(h=h-48|0,a=We(a,10),a=(h|0)>(a^2147483647)?-1:h+a|0):a=-1;continue}break}return a}function Va(r,a,h,u){var y=0;c[r+12>>2]=0,c[r+16>>2]=u;t:{if(a){if(a>>>0>=1073741824)break t;y=ut(a<<2)}return c[r>>2]=y,h=(h<<2)+y|0,c[r+8>>2]=h,c[r+12>>2]=(a<<2)+y,c[r+4>>2]=h,r}Kh(),ce()}function Jp(r){var a=0;return a=c[r+72>>2],c[r+72>>2]=a-1|a,a=c[r>>2],a&8?(c[r>>2]=a|32,-1):(c[r+4>>2]=0,c[r+8>>2]=0,a=c[r+44>>2],c[r+28>>2]=a,c[r+20>>2]=a,c[r+16>>2]=a+c[r+48>>2],0)}function ZT(r,a,h,u,y,b){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0;k=kt-16|0,kt=k,a=c[c[a>>2]+4>>2],Pt[c[c[a>>2]+8>>2]](k,a,h,u,y,b),I[r>>2]=He[k>>3],I[r+4>>2]=He[k+8>>3],kt=k+16|0}function qT(){var r=0,a=0;return a=ut(4),r=ut(28),c[r+20>>2]=1065353216,c[r+24>>2]=0,c[r+12>>2]=0,c[r+16>>2]=0,c[r>>2]=0,gt[r+8|0]=0,c[r+4>>2]=1,c[1752]=c[1752]+1,c[a>>2]=r,a|0}function QT(r,a){r=r|0,a=a|0,a=c[a>>2],He[r>>3]=I[a+228>>2],He[r+8>>3]=I[a+236>>2],He[r+16>>3]=I[a+232>>2],He[r+24>>3]=I[a+240>>2],He[r+32>>3]=I[a+244>>2],He[r+40>>3]=I[a+248>>2]}function JT(r,a){r=r|0,a=a|0;var h=0,u=0;return h=kt-48|0,kt=h,u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),Pt[u|0](h,a),r=Vi(ut(48),h,48),kt=h+48|0,r|0}function tk(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;return y=kt-16|0,kt=y,r=u2(XE(c[r+60>>2],a|0,h|0,u&255,y+8|0)|0),kt=y+16|0,Gi=r?-1:c[y+12>>2],(r?-1:c[y+8>>2])|0}function ek(r,a){r=r|0,a=a|0;var h=0,u=0;h=c[r>>2],r=c[h+556>>2];t:{if(c[h+560>>2]-r>>2>>>0<=a>>>0||(r=c[r+(a<<2)>>2],!r))break t;u=c[r>>2]}return u|0}function ik(r,a,h){if(r=r|0,a=a|0,h=h|0,a>>>0<3){a=1<<a,r=c[r>>2],h?a=a|c[r+12>>2]:a=c[r+12>>2]&(a^-1),c[r+12>>2]=a;return}Fs(),ce()}function rk(r,a,h,u,y){r=r|0,a=a|0,h=+h,u=+u,y=y|0;var b=0;b=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(b=c[b+c[a>>2]>>2]),Pt[b|0](a,h,u,y)}function sk(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),m(m(Pt[u|0](a,h)))}function t2(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;y=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(y=c[y+c[a>>2]>>2]),Pt[y|0](a,h,u)}function e2(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),Pt[u|0](a,h)|0}function nk(r,a,h,u){r=r|0,a=a|0,h=h|0,u=+u;var y=0;y=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(y=c[y+c[a>>2]>>2]),Pt[y|0](a,h,u)}function ak(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),+Pt[u|0](a,h)}function ut(r){var a=0;r=r||1;t:{for(;;){if(a=Ph(r),a)break t;if(a=c[2042],a){Pt[a|0]();continue}break}Fs(),ce()}return a}function ok(r,a,h){r=r|0,a=a|0,h=m(h);var u=0;u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),Pt[u|0](a,h)}function Bs(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),Pt[u|0](a,h)}function yn(r,a){r=r|0,a=a|0;var h=0;return h=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(h=c[h+c[a>>2]>>2]),Pt[h|0](a)|0}function Gh(r,a){return Ji(r),(te(2)&2147483647)>>>0<=2139095040?(Ji(a),(te(2)&2147483647)>>>0>2139095040?r:m(HE(r,a))):a}function oe(r,a){return Ji(r),(te(2)&2147483647)>>>0<=2139095040?(Ji(a),(te(2)&2147483647)>>>0>2139095040?r:m(WE(r,a))):a}function i2(r,a){r=r|0,a=a|0;var h=0;return h=kt-16|0,kt=h,c[h+8>>2]=a,r=Pt[r|0](h+8|0)|0,Ba(c[h+8>>2]),kt=h+16|0,r|0}function lk(r,a,h){r=r|0,a=a|0,h=+h;var u=0;u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),Pt[u|0](a,h)}function ck(r,a,h,u,y){return h=h|0,u=u|0,y=y|0,h&&(h|0)!=5?m2(5816,u,y)|0:m2(5672,u,y)|0}function r2(r,a){if(!r)return 0;t:{if(!((a&-128)==57216|a>>>0<=127)){c[1781]=25,r=-1;break t}gt[r|0]=a,r=1}return r}function hk(r,a){r=r|0,a=a|0;var h=0;return h=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(h=c[h+c[a>>2]>>2]),+Pt[h|0](a)}function s2(r,a){var h=0,u=0;h=ut(4),c[h>>2]=a,u=ut(4),c[u>>2]=a,ol(7035,r|0,7098,4714,196,h|0,7098,4718,197,u|0)}function Kn(r,a){var h=0,u=0;h=ut(4),c[h>>2]=a,u=ut(4),c[u>>2]=a,ol(7065,r|0,7098,4714,194,h|0,7098,4718,195,u|0)}function Vh(r,a){var h=0;t:{if(gt[7044]&1){h=c[1760];break t}h=Tp(1,4464)|0,gt[7044]=1,c[1760]=h}YE(h|0,r|0,a|0,0)}function dk(r,a){r=r|0,a=a|0;var h=0;h=c[r+8>>2],c[r+8>>2]=a,h&&Pt[c[c[h>>2]+4>>2]](h),c[c[r>>2]+20>>2]=15}function uk(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=Rp((gt[a+11|0]<0?c[a>>2]:a)|0,7036,c[h>>2])|0,c[u>>2]=y}function fk(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=Rp((gt[a+11|0]<0?c[a>>2]:a)|0,7059,c[h>>2])|0,c[u>>2]=y}function n2(r,a){r=r|0,a=a|0;var h=0;h=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(h=c[h+c[a>>2]>>2]),Pt[h|0](a)}function pk(r){r=r|0;var a=m(0);return r=c[r>>2],a=I[r+36>>2],a!=a&&(a=gt[c[r+568>>2]+8|0]&1?m(1):m(0)),+a}function gk(r,a){r=r|0,a=a|0;var h=0;h=c[r+4>>2],c[r+4>>2]=a,h&&Pt[c[c[h>>2]+4>>2]](h),Zp(c[r>>2],14)}function mk(r){r=r|0;var a=0;a=c[r+8>>2],c[r+8>>2]=0,a&&Pt[c[c[a>>2]+4>>2]](a),c[c[r>>2]+20>>2]=0}function vk(r){r=r|0;var a=0;return a=ut(12),gt[a+4|0]=0,c[a+8>>2]=c[r>>2],c[r>>2]=0,c[a>>2]=4432,a|0}function yk(r){r=r|0;var a=0;return a=ut(12),gt[a+4|0]=0,c[a+8>>2]=c[r>>2],c[r>>2]=0,c[a>>2]=4552,a|0}function bk(){var r=0;if(r=c[1768],r)for(;Pt[c[r>>2]](),r=c[r+4>>2],!!r;);}function Ak(r){r=r|0;var a=0;a=c[r+4>>2],c[r+4>>2]=0,a&&Pt[c[c[a>>2]+4>>2]](a),Zp(c[r>>2],0)}function a2(r){return r=r|0,c[r>>2]=4572,Tt[r+4|0]&&Vh(c[r+8>>2],1759),Ba(c[r+8>>2]),r|0}function o2(r){return r=r|0,c[r>>2]=4452,Tt[r+4|0]&&Vh(c[r+8>>2],1759),Ba(c[r+8>>2]),r|0}function Ek(){var r=0;return r=ut(16),c[r>>2]=0,c[r+4>>2]=0,c[r+8>>2]=0,c[r+12>>2]=0,r|0}function l2(r,a,h){return cr(r,a)?Us(r,a,h):(h=Ga(r,a,h),h==h&&(h=m(-h)),h)}function c2(r,a){var h=0;h=kt-16|0,kt=h,r||(c[h>>2]=a,lr(0,h),tr(),ce()),kt=h+16|0}function h2(r){r=r|0;var a=0;r&&(a=c[r>>2],a&&Ti(a),c[1752]=c[1752]-1,Ti(r))}function Tk(r,a){return r=r|0,a=a|0,a>>>0>=3&&(Fs(),ce()),c[c[r>>2]+12>>2]>>>a&1}function kk(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 wk(){var r=0;return r=ut(16),c[r+8>>2]=0,c[r+12>>2]=0,c[r>>2]=0,r|0}function Sk(r){r=r|0;var a=m(0);return a=I[c[r>>2]+224>>2],+(a!=a?m(Yt):a)}function Rk(r){return r=r|0,r=c[c[r>>2]+552>>2],r?c[r>>2]:0}function _k(r){r=r|0;var a=m(0);return a=I[c[r>>2]+32>>2],+(a==a?a:m(0))}function d2(r){var a=0;return a=Ip(ut(588),r),c2((r|0)!=0,2808),a}function Lk(r,a){r=r|0,a=a|0,r=c[r>>2],c[r+16>>2]=c[r+16>>2]&-2|a}function Ck(r){return r=r|0,r=c[r>>2],c[r+560>>2]-c[r+556>>2]>>2}function Ik(r,a){r=r|0,a=a|0,r=c[r>>2],gt[r+8|0]=Tt[r+8|0]&254|a}function Dk(r){r=r|0,r=c[c[r>>2]+8>>2],Pt[c[c[r>>2]+8>>2]](r)}function xk(r,a,h){r=r|0,a=a|0,h=+h,Uh(c[r>>2],a,Tr(m(h)))}function Pk(r,a,h){r=r|0,a=a|0,h=+h,Uh(c[r>>2],a,zr(m(h)))}function Ok(r,a,h,u){return Gi=0,0}function Mk(r,a,h){r=r|0,a=a|0,h=+h,Yp(c[r>>2],a,Tr(m(h)))}function $k(r,a,h){r=r|0,a=a|0,h=+h,Yp(c[r>>2],a,zr(m(h)))}function Fk(r,a,h){r=r|0,a=a|0,h=+h,Xp(c[r>>2],a,Tr(m(h)))}function Nk(r,a,h){r=r|0,a=a|0,h=+h,Xp(c[r>>2],a,zr(m(h)))}function Uk(r,a,h){r=r|0,a=a|0,h=h|0,c[c[r>>2]+a>>2]=h}function Bk(r,a){r=r|0,a=a|0,Uh(c[r>>2],a,2141891242)}function Hh(r,a,h){r=r|0,a=a|0,h=+h,He[c[r>>2]+a>>3]=h}function Gk(r){return r=r|0,(Tt[c[r>>2]+4|0]&2)>>>1|0}function Vk(r){return r=r|0,(Tt[c[r>>2]+4|0]&4)>>>2|0}function Hk(r,a){r=r|0,a=a|0,c[r+4>>2]=10,c[r>>2]=a}function Wk(r,a){r=r|0,a=a|0,c[r+4>>2]=13,c[r>>2]=a}function jk(r){return r=r|0,c[c[r>>2]+24>>2]>>>10&7}function Kk(r){return r=r|0,c[c[r>>2]+24>>2]>>>13&7}function Wh(r,a){return r=r|0,a=a|0,+He[c[r>>2]+a>>3]}function zk(r){return r=r|0,c[c[r>>2]+24>>2]>>>18&3}function Yk(r){return r=r|0,c[c[r>>2]+24>>2]>>>20&3}function Xk(r){return r=r|0,c[c[r>>2]+24>>2]>>>22&1}function Zk(r,a){return r=r|0,a=a|0,c[c[r>>2]+a>>2]}function qk(r,a){r=r|0,a=+a,Wn(c[r>>2],0,Tr(m(a)))}function Qk(r,a){r=r|0,a=+a,Wn(c[r>>2],0,zr(m(a)))}function Jk(r,a){r=r|0,a=+a,Wn(c[r>>2],1,Tr(m(a)))}function t3(r,a){r=r|0,a=+a,Wn(c[r>>2],1,zr(m(a)))}function e3(r,a){r=r|0,a=a|0,c[r+4>>2]=7,c[r>>2]=a}function i3(r,a){r=r|0,a=+a,hl(c[r>>2],0,Tr(m(a)))}function r3(r,a){r=r|0,a=+a,hl(c[r>>2],0,zr(m(a)))}function s3(r,a){r=r|0,a=+a,hl(c[r>>2],1,Tr(m(a)))}function n3(r,a){r=r|0,a=+a,hl(c[r>>2],1,zr(m(a)))}function a3(r,a){r=r|0,a=+a,dl(c[r>>2],0,Tr(m(a)))}function o3(r,a){r=r|0,a=+a,dl(c[r>>2],1,Tr(m(a)))}function l3(r,a){r=r|0,a=+a,dl(c[r>>2],1,zr(m(a)))}function c3(r){return r=r|0,c[c[r>>2]+24>>2]>>>7&7}function h3(r){return r=r|0,c[c[r>>2]+24>>2]>>>2&3}function d3(r){return r=r|0,c[c[r>>2]+24>>2]>>>4&7}function fl(r){r=r|0,r&&Pt[c[c[r>>2]+4>>2]](r)}function u3(r,a){r=r|0,a=+a,dl(c[r>>2],0,zr(m(a)))}function u2(r){return r?(c[1781]=r,-1):0}function f3(r,a){r=r|0,a=+a,Nh(c[r>>2],Tr(m(a)))}function p3(r,a){r=r|0,a=+a,Nh(c[r>>2],zr(m(a)))}function f2(r,a,h){return m(he(r,a,h)+Se(r,a,h))}function g3(r,a){return r=r|0,a=a|0,Pt[r|0](a)|0}function p2(r,a,h,u){ZE(r|0,a|0,8,0,h|0,-1,u|0)}function m3(r,a){r=r|0,a=a|0,c[c[r>>2]+16>>2]=a}function v3(r){return r=r|0,c[c[r>>2]+16>>2]&1}function y3(r){return r=r|0,Bn[c[r>>2]+26>>1]&3}function b3(r){r=r|0,Wn(c[r>>2],0,2141891242)}function A3(r){r=r|0,Wn(c[r>>2],1,2141891242)}function E3(r){return r=r|0,+I[c[r>>2]+228>>2]}function T3(r){return r=r|0,+I[c[r>>2]+236>>2]}function k3(r){return r=r|0,+I[c[r>>2]+232>>2]}function w3(r){return r=r|0,+I[c[r>>2]+240>>2]}function S3(r){return r=r|0,+I[c[r>>2]+244>>2]}function R3(r){return r=r|0,+I[c[r>>2]+248>>2]}function _3(r){return r=r|0,tT(c[r+60>>2])|0}function L3(r){return r=r|0,c[c[r>>2]+16>>2]}function C3(r){return r=r|0,gt[c[r>>2]+8|0]&1}function I3(r,a){r=r|0,a=a|0,Fh(c[r>>2],5,a)}function D3(r,a){r=r|0,a=a|0,Fh(c[r>>2],6,a)}function x3(r,a){r=r|0,a=a|0,Fh(c[r>>2],7,a)}function P3(r){r=r|0,Nh(c[r>>2],2141891242)}function g2(r,a){r=r|0,a=a|0,Pt[c[r>>2]](a)}function O3(r){return r=r|0,jp(ut(12),r)|0}function M3(r){r=r|0,Vh(c[r+8>>2],3293)}function m2(r,a,h){return Bp(r,a,h,2,3)}function v2(r){return r=r|0,Pt[r|0]()|0}function y2(r,a){r=r|0,a=a|0,Pt[r|0](a)}function $3(){return Hi(ut(48),0,48)|0}function tr(){Pt[c[1490]](),Kh(),ce()}function F3(){return jp(ut(12),0)|0}function jh(r){r=r|0,r&&Ti(r)}function pl(r){return r-48>>>0<10}function N3(r){return 7032}function U3(r){return 7036}function B3(r){return 7056}function G3(r){return 7059}function V3(r){return 7062}function H3(r){return 7067}function Ir(r){return r=r|0,r|0}function b2(r){r=r|0,gt[r+4|0]=1}function W3(r){r=r|0,Ti(a2(r))}function j3(r){r=r|0,Ti(o2(r))}function K3(r){return 0}function A2(r){ce()}function E2(){Kh(),ce()}function Kh(){Fs(),ce()}V=Tt,_t();var Pt=B([null,ck,sT,oT,Ir,e3,Hk,Wk,Ir,Ir,Ir,Ir,Ir,Ir,ZT,Dk,Lp,N3,fl,DT,U3,Ir,Ir,fl,b2,g2,i2,vk,gT,uk,B3,fl,n2,G3,Ir,Ir,fl,b2,g2,i2,yk,fk,V3,h2,v2,qT,y2,h2,ik,t2,fT,ok,Lk,Bs,m3,Bs,Ik,Tk,e2,v3,yn,L3,yn,C3,$3,jh,Ek,jh,wk,jh,Wh,Hh,Zk,Uk,H3,$p,v2,F3,g3,O3,y2,$p,hT,n2,aT,Bs,NT,Bs,Fk,nk,Nk,I3,D3,x3,WT,FT,HT,xk,Pk,Bk,MT,$T,BT,lk,f3,p3,P3,GT,VT,qk,Qk,b3,Jk,t3,A3,i3,r3,s3,n3,a3,u3,o3,l3,UT,xT,Mk,$k,PT,y3,yn,yT,KT,c3,jk,Kk,h3,zk,d3,bT,CT,YT,_k,hk,pk,ET,TT,kT,wT,ST,AT,Sk,OT,ak,Yk,Xk,vT,IT,sk,lT,t2,cT,Bs,Ck,yn,Rk,yn,ek,e2,Gk,yn,jT,Bs,gk,Bs,Ak,dk,Bs,mk,zT,Vk,yn,nT,rk,E3,T3,k3,w3,S3,R3,QT,JT,RT,_T,LT,Wh,Hh,Wh,Hh,Fp,o2,j3,pT,A2,E2,a2,W3,M3,A2,_3,dT,tk,K3,Ok,mT,E2]);function T2(){return Bi.byteLength/65536|0}function z3(r){r=r|0;var a=T2()|0,h=a+r|0;if(a<h&&h<65536){var u=new ArrayBuffer(We(h,65536)),y=new Int8Array(u);y.set(gt),gt=new Int8Array(u),Hr=new Int16Array(u),c=new Int32Array(u),Tt=new Uint8Array(u),Bn=new Uint16Array(u),Ap=new Uint32Array(u),I=new Float32Array(u),He=new Float64Array(u),Bi=u,or.buffer=Bi,V=Tt}return a}return{E:XT,F:uT,G:bk,H:Ph,I:Pt,J:Ti,K:kk}}return al(L)}(_)}var C=Error,x={};A=[],typeof x!="object"&&Lt("no native wasm support detected");var O,U=!1;function D(_,L,B){B=L+B;for(var V="";!(L>=B);){var rt=_[L++];if(!rt)break;if(rt&128){var yt=_[L++]&63;if((rt&224)==192)V+=String.fromCharCode((rt&31)<<6|yt);else{var ht=_[L++]&63;rt=(rt&240)==224?(rt&15)<<12|yt<<6|ht:(rt&7)<<18|yt<<12|ht<<6|_[L++]&63,65536>rt?V+=String.fromCharCode(rt):(rt-=65536,V+=String.fromCharCode(55296|rt>>10,56320|rt&1023))}}else V+=String.fromCharCode(rt)}return V}var H,$,z,tt,at,J,St,mt,Ot;function Vt(_){H=_,o.HEAP8=$=new Int8Array(_),o.HEAP16=tt=new Int16Array(_),o.HEAP32=J=new Int32Array(_),o.HEAPU8=z=new Uint8Array(_),o.HEAPU16=at=new Uint16Array(_),o.HEAPU32=St=new Uint32Array(_),o.HEAPF32=mt=new Float32Array(_),o.HEAPF64=Ot=new Float64Array(_)}var G=o.INITIAL_MEMORY||16777216;o.wasmMemory?O=o.wasmMemory:O=new E,O&&(H=O.buffer),G=H.byteLength,Vt(H);var q,At=[],N=[],F=[];function j(){var _=o.preRun.shift();At.unshift(_)}var nt=0,ct=null;function Lt(_){throw o.onAbort&&o.onAbort(_),_="Aborted("+_+")",v(_),U=!0,_=new C(_+". Build with -sASSERTIONS for more info."),d(_),_}function Nt(_){return _.startsWith("data:application/octet-stream;base64,")}var jt;if(jt="<<< WASM_BINARY_FILE >>>",!Nt(jt)){var fe=jt;jt=o.locateFile?o.locateFile(fe,p):p+fe}function ve(_){var L=jt;try{try{if(L==jt&&A)new Uint8Array(A);else{if(Nt(L)){try{var B=BE(L.slice(37)),V=new Uint8Array(B.length);for(L=0;L<B.length;++L)V[L]=B.charCodeAt(L);var rt=V}catch{throw Error("Converting base64 string to bytes failed.")}var yt=rt}else yt=void 0;if(!yt)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(It){Lt(It)}var ht=new T,_t=new w(_)}catch(It){throw _=It.toString(),v("failed to compile wasm module: "+_),(_.includes("imported Memory")||_.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)."),It}return[_t,ht]}function me(_){for(;0<_.length;)_.shift()(o)}function Ke(_){if(_===void 0)return"_unknown";_=_.replace(/[^a-zA-Z0-9_]/g,"$");var L=_.charCodeAt(0);return 48<=L&&57>=L?"_"+_:_}function _e(_,L){return _=Ke(_),function(){return L.apply(this,arguments)}}var Kt=[{},{value:void 0},{value:null},{value:!0},{value:!1}],Ae=[];function de(_){var L=Error,B=_e(_,function(V){this.name=_,this.message=V,V=Error(V).stack,V!==void 0&&(this.stack=this.toString()+`
90
- `+V.replace(/^Error(:[^\n]*)?\n/,""))});return B.prototype=Object.create(L.prototype),B.prototype.constructor=B,B.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},B}var Me=void 0;function Ut(_){throw new Me(_)}var ze=_=>(_||Ut("Cannot use deleted val. handle = "+_),Kt[_].value),Fe=_=>{switch(_){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var L=Ae.length?Ae.pop():Kt.length;return Kt[L]={fa:1,value:_},L}},Ve=void 0,we=void 0;function ue(_){for(var L="";z[_];)L+=we[z[_++]];return L}var Ye=[];function le(){for(;Ye.length;){var _=Ye.pop();_.L.Z=!1,_.delete()}}var Ne=void 0,Ue={};function pi(_,L){for(L===void 0&&Ut("ptr should not be undefined");_.P;)L=_.aa(L),_=_.P;return L}var Ce={};function Ai(_){_=VE(_);var L=ue(_);return $s(_),L}function _r(_,L){var B=Ce[_];return B===void 0&&Ut(L+" has unknown type "+Ai(_)),B}function ni(){}var Lr=!1;function xs(_){--_.count.value,_.count.value===0&&(_.S?_.T.V(_.S):_.O.M.V(_.N))}function Ps(_,L,B){return L===B?_:B.P===void 0?null:(_=Ps(_,L,B.P),_===null?null:B.ma(_))}var ar={};function dt(_,L){return L=pi(_,L),Ue[L]}var Gt=void 0;function Zt(_){throw new Gt(_)}function ye(_,L){return L.O&&L.N||Zt("makeClassHandle requires ptr and ptrType"),!!L.T!=!!L.S&&Zt("Both smartPtrType and smartPtr must be specified"),L.count={value:1},ne(Object.create(_,{L:{value:L}}))}function ne(_){return typeof FinalizationRegistry>"u"?(ne=L=>L,_):(Lr=new FinalizationRegistry(L=>{xs(L.L)}),ne=L=>{var B=L.L;return B.S&&Lr.register(L,{L:B},L),L},ni=L=>{Lr.unregister(L)},ne(_))}var ci={};function Oi(_){for(;_.length;){var L=_.pop();_.pop()(L)}}function vr(_){return this.fromWireType(J[_>>2])}var hs={},yr={};function br(_,L,B){function V(_t){_t=B(_t),_t.length!==_.length&&Zt("Mismatched type converter count");for(var It=0;It<_.length;++It)Mi(_[It],_t[It])}_.forEach(function(_t){yr[_t]=L});var rt=Array(L.length),yt=[],ht=0;L.forEach((_t,It)=>{Ce.hasOwnProperty(_t)?rt[It]=Ce[_t]:(yt.push(_t),hs.hasOwnProperty(_t)||(hs[_t]=[]),hs[_t].push(()=>{rt[It]=Ce[_t],++ht,ht===yt.length&&V(rt)}))}),yt.length===0&&V(rt)}function Os(_){switch(_){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+_)}}function Mi(_,L,B={}){if(!("argPackAdvance"in L))throw new TypeError("registerType registeredInstance requires argPackAdvance");var V=L.name;if(_||Ut('type "'+V+'" must have a positive integer typeid pointer'),Ce.hasOwnProperty(_)){if(B.ta)return;Ut("Cannot register type '"+V+"' twice")}Ce[_]=L,delete yr[_],hs.hasOwnProperty(_)&&(L=hs[_],delete hs[_],L.forEach(rt=>rt()))}function Ua(_){Ut(_.L.O.M.name+" instance already deleted")}function Ar(){}function Ms(_,L,B){if(_[L].R===void 0){var V=_[L];_[L]=function(){return _[L].R.hasOwnProperty(arguments.length)||Ut("Function '"+B+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+_[L].R+")!"),_[L].R[arguments.length].apply(this,arguments)},_[L].R=[],_[L].R[V.Y]=V}}function EE(_,L){o.hasOwnProperty(_)?(Ut("Cannot register public name '"+_+"' twice"),Ms(o,_,_),o.hasOwnProperty(void 0)&&Ut("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),o[_].R[void 0]=L):o[_]=L}function TE(_,L,B,V,rt,yt,ht,_t){this.name=_,this.constructor=L,this.W=B,this.V=V,this.P=rt,this.oa=yt,this.aa=ht,this.ma=_t,this.ia=[]}function Sh(_,L,B){for(;L!==B;)L.aa||Ut("Expected null or instance of "+B.name+", got an instance of "+L.name),_=L.aa(_),L=L.P;return _}function kE(_,L){return L===null?(this.da&&Ut("null is not a valid "+this.name),0):(L.L||Ut('Cannot pass "'+Ch(L)+'" as a '+this.name),L.L.N||Ut("Cannot pass deleted object as a pointer of type "+this.name),Sh(L.L.N,L.L.O.M,this.M))}function wE(_,L){if(L===null){if(this.da&&Ut("null is not a valid "+this.name),this.ca){var B=this.ea();return _!==null&&_.push(this.V,B),B}return 0}if(L.L||Ut('Cannot pass "'+Ch(L)+'" as a '+this.name),L.L.N||Ut("Cannot pass deleted object as a pointer of type "+this.name),!this.ba&&L.L.O.ba&&Ut("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name),B=Sh(L.L.N,L.L.O.M,this.M),this.ca)switch(L.L.S===void 0&&Ut("Passing raw pointer to smart pointer is illegal"),this.Aa){case 0:L.L.T===this?B=L.L.S:Ut("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name);break;case 1:B=L.L.S;break;case 2:if(L.L.T===this)B=L.L.S;else{var V=L.clone();B=this.wa(B,Fe(function(){V.delete()})),_!==null&&_.push(this.V,B)}break;default:Ut("Unsupporting sharing policy")}return B}function SE(_,L){return L===null?(this.da&&Ut("null is not a valid "+this.name),0):(L.L||Ut('Cannot pass "'+Ch(L)+'" as a '+this.name),L.L.N||Ut("Cannot pass deleted object as a pointer of type "+this.name),L.L.O.ba&&Ut("Cannot convert argument of type "+L.L.O.name+" to parameter type "+this.name),Sh(L.L.N,L.L.O.M,this.M))}function ds(_,L,B,V){this.name=_,this.M=L,this.da=B,this.ba=V,this.ca=!1,this.V=this.wa=this.ea=this.ja=this.Aa=this.va=void 0,L.P!==void 0?this.toWireType=wE:(this.toWireType=V?kE:SE,this.U=null)}function RE(_,L){o.hasOwnProperty(_)||Zt("Replacing nonexistant public symbol"),o[_]=L,o[_].Y=void 0}function _E(_,L){var B=[];return function(){if(B.length=0,Object.assign(B,arguments),_.includes("j")){var V=o["dynCall_"+_];V=B&&B.length?V.apply(null,[L].concat(B)):V.call(null,L)}else V=q.get(L).apply(null,B);return V}}function Cr(_,L){_=ue(_);var B=_.includes("j")?_E(_,L):q.get(L);return typeof B!="function"&&Ut("unknown function pointer with signature "+_+": "+L),B}var pp=void 0;function il(_,L){function B(yt){rt[yt]||Ce[yt]||(yr[yt]?yr[yt].forEach(B):(V.push(yt),rt[yt]=!0))}var V=[],rt={};throw L.forEach(B),new pp(_+": "+V.map(Ai).join([", "]))}function Rh(_,L,B,V,rt){var yt=L.length;2>yt&&Ut("argTypes array size mismatch! Must at least get return value and 'this' types!");var ht=L[1]!==null&&B!==null,_t=!1;for(B=1;B<L.length;++B)if(L[B]!==null&&L[B].U===void 0){_t=!0;break}var It=L[0].name!=="void",Dt=yt-2,Ft=Array(Dt),zt=[],te=[];return function(){if(arguments.length!==Dt&&Ut("function "+_+" called with "+arguments.length+" arguments, expected "+Dt+" args!"),te.length=0,zt.length=ht?2:1,zt[0]=rt,ht){var xt=L[1].toWireType(te,this);zt[1]=xt}for(var Ee=0;Ee<Dt;++Ee)Ft[Ee]=L[Ee+2].toWireType(te,arguments[Ee]),zt.push(Ft[Ee]);if(Ee=V.apply(null,zt),_t)Oi(te);else for(var Ei=ht?1:2;Ei<L.length;Ei++){var ce=Ei===1?xt:Ft[Ei-2];L[Ei].U!==null&&L[Ei].U(ce)}return xt=It?L[0].fromWireType(Ee):void 0,xt}}function _h(_,L){for(var B=[],V=0;V<_;V++)B.push(St[L+4*V>>2]);return B}function Lh(_){4<_&&--Kt[_].fa===0&&(Kt[_]=void 0,Ae.push(_))}function Ch(_){if(_===null)return"null";var L=typeof _;return L==="object"||L==="array"||L==="function"?_.toString():""+_}function LE(_,L){switch(L){case 2:return function(B){return this.fromWireType(mt[B>>2])};case 3:return function(B){return this.fromWireType(Ot[B>>3])};default:throw new TypeError("Unknown float type: "+_)}}function CE(_,L,B){switch(L){case 0:return B?function(V){return $[V]}:function(V){return z[V]};case 1:return B?function(V){return tt[V>>1]}:function(V){return at[V>>1]};case 2:return B?function(V){return J[V>>2]}:function(V){return St[V>>2]};default:throw new TypeError("Unknown integer type: "+_)}}function IE(_,L){for(var B="",V=0;!(V>=L/2);++V){var rt=tt[_+2*V>>1];if(rt==0)break;B+=String.fromCharCode(rt)}return B}function DE(_,L,B){if(B===void 0&&(B=2147483647),2>B)return 0;B-=2;var V=L;B=B<2*_.length?B/2:_.length;for(var rt=0;rt<B;++rt)tt[L>>1]=_.charCodeAt(rt),L+=2;return tt[L>>1]=0,L-V}function xE(_){return 2*_.length}function PE(_,L){for(var B=0,V="";!(B>=L/4);){var rt=J[_+4*B>>2];if(rt==0)break;++B,65536<=rt?(rt-=65536,V+=String.fromCharCode(55296|rt>>10,56320|rt&1023)):V+=String.fromCharCode(rt)}return V}function OE(_,L,B){if(B===void 0&&(B=2147483647),4>B)return 0;var V=L;B=V+B-4;for(var rt=0;rt<_.length;++rt){var yt=_.charCodeAt(rt);if(55296<=yt&&57343>=yt){var ht=_.charCodeAt(++rt);yt=65536+((yt&1023)<<10)|ht&1023}if(J[L>>2]=yt,L+=4,L+4>B)break}return J[L>>2]=0,L-V}function ME(_){for(var L=0,B=0;B<_.length;++B){var V=_.charCodeAt(B);55296<=V&&57343>=V&&++B,L+=4}return L}var $E={};function gp(_){var L=$E[_];return L===void 0?ue(_):L}var rl=[];function FE(_){var L=rl.length;return rl.push(_),L}function NE(_,L){for(var B=Array(_),V=0;V<_;++V)B[V]=_r(St[L+4*V>>2],"parameter "+V);return B}var mp=[],UE=[null,[],[]];Me=o.BindingError=de("BindingError"),o.count_emval_handles=function(){for(var _=0,L=5;L<Kt.length;++L)Kt[L]!==void 0&&++_;return _},o.get_first_emval=function(){for(var _=5;_<Kt.length;++_)if(Kt[_]!==void 0)return Kt[_];return null},Ve=o.PureVirtualError=de("PureVirtualError");for(var vp=Array(256),sl=0;256>sl;++sl)vp[sl]=String.fromCharCode(sl);we=vp,o.getInheritedInstanceCount=function(){return Object.keys(Ue).length},o.getLiveInheritedInstances=function(){var _=[],L;for(L in Ue)Ue.hasOwnProperty(L)&&_.push(Ue[L]);return _},o.flushPendingDeletes=le,o.setDelayFunction=function(_){Ne=_,Ye.length&&Ne&&Ne(le)},Gt=o.InternalError=de("InternalError"),Ar.prototype.isAliasOf=function(_){if(!(this instanceof Ar&&_ instanceof Ar))return!1;var L=this.L.O.M,B=this.L.N,V=_.L.O.M;for(_=_.L.N;L.P;)B=L.aa(B),L=L.P;for(;V.P;)_=V.aa(_),V=V.P;return L===V&&B===_},Ar.prototype.clone=function(){if(this.L.N||Ua(this),this.L.$)return this.L.count.value+=1,this;var _=ne,L=Object,B=L.create,V=Object.getPrototypeOf(this),rt=this.L;return _=_(B.call(L,V,{L:{value:{count:rt.count,Z:rt.Z,$:rt.$,N:rt.N,O:rt.O,S:rt.S,T:rt.T}}})),_.L.count.value+=1,_.L.Z=!1,_},Ar.prototype.delete=function(){this.L.N||Ua(this),this.L.Z&&!this.L.$&&Ut("Object already scheduled for deletion"),ni(this),xs(this.L),this.L.$||(this.L.S=void 0,this.L.N=void 0)},Ar.prototype.isDeleted=function(){return!this.L.N},Ar.prototype.deleteLater=function(){return this.L.N||Ua(this),this.L.Z&&!this.L.$&&Ut("Object already scheduled for deletion"),Ye.push(this),Ye.length===1&&Ne&&Ne(le),this.L.Z=!0,this},ds.prototype.pa=function(_){return this.ja&&(_=this.ja(_)),_},ds.prototype.ga=function(_){this.V&&this.V(_)},ds.prototype.argPackAdvance=8,ds.prototype.readValueFromPointer=vr,ds.prototype.deleteObject=function(_){_!==null&&_.delete()},ds.prototype.fromWireType=function(_){function L(){return this.ca?ye(this.M.W,{O:this.va,N:B,T:this,S:_}):ye(this.M.W,{O:this,N:_})}var B=this.pa(_);if(!B)return this.ga(_),null;var V=dt(this.M,B);if(V!==void 0)return V.L.count.value===0?(V.L.N=B,V.L.S=_,V.clone()):(V=V.clone(),this.ga(_),V);if(V=this.M.oa(B),V=ar[V],!V)return L.call(this);V=this.ba?V.ka:V.pointerType;var rt=Ps(B,this.M,V.M);return rt===null?L.call(this):this.ca?ye(V.M.W,{O:V,N:rt,T:this,S:_}):ye(V.M.W,{O:V,N:rt})},pp=o.UnboundTypeError=de("UnboundTypeError");var BE=typeof atob=="function"?atob:function(_){var L="",B=0;_=_.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var V="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++)),rt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++)),yt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++)),ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++));V=V<<2|rt>>4,rt=(rt&15)<<4|yt>>2;var _t=(yt&3)<<6|ht;L+=String.fromCharCode(V),yt!==64&&(L+=String.fromCharCode(rt)),ht!==64&&(L+=String.fromCharCode(_t))}while(B<_.length);return L},GE={q:function(_,L,B){_=ue(_),L=_r(L,"wrapper"),B=ze(B);var V=[].slice,rt=L.M,yt=rt.W,ht=rt.P.W,_t=rt.P.constructor;_=_e(_,function(){rt.P.ia.forEach((function(Dt){if(this[Dt]===ht[Dt])throw new Ve("Pure virtual function "+Dt+" must be implemented in JavaScript")}).bind(this)),Object.defineProperty(this,"__parent",{value:yt}),this.__construct.apply(this,V.call(arguments))}),yt.__construct=function(){this===yt&&Ut("Pass correct 'this' to __construct");var Dt=_t.implement.apply(void 0,[this].concat(V.call(arguments)));ni(Dt);var Ft=Dt.L;Dt.notifyOnDestruction(),Ft.$=!0,Object.defineProperties(this,{L:{value:Ft}}),ne(this),Dt=Ft.N,Dt=pi(rt,Dt),Ue.hasOwnProperty(Dt)?Ut("Tried to register registered instance: "+Dt):Ue[Dt]=this},yt.__destruct=function(){this===yt&&Ut("Pass correct 'this' to __destruct"),ni(this);var Dt=this.L.N;Dt=pi(rt,Dt),Ue.hasOwnProperty(Dt)?delete Ue[Dt]:Ut("Tried to unregister unregistered instance: "+Dt)},_.prototype=Object.create(yt);for(var It in B)_.prototype[It]=B[It];return Fe(_)},k:function(_){var L=ci[_];delete ci[_];var B=L.ea,V=L.V,rt=L.ha,yt=rt.map(ht=>ht.sa).concat(rt.map(ht=>ht.ya));br([_],yt,ht=>{var _t={};return rt.forEach((It,Dt)=>{var Ft=ht[Dt],zt=It.qa,te=It.ra,xt=ht[Dt+rt.length],Ee=It.xa,Ei=It.za;_t[It.na]={read:ce=>Ft.fromWireType(zt(te,ce)),write:(ce,Ji)=>{var Bt=[];Ee(Ei,ce,xt.toWireType(Bt,Ji)),Oi(Bt)}}}),[{name:L.name,fromWireType:function(It){var Dt={},Ft;for(Ft in _t)Dt[Ft]=_t[Ft].read(It);return V(It),Dt},toWireType:function(It,Dt){for(var Ft in _t)if(!(Ft in Dt))throw new TypeError('Missing field: "'+Ft+'"');var zt=B();for(Ft in _t)_t[Ft].write(zt,Dt[Ft]);return It!==null&&It.push(V,zt),zt},argPackAdvance:8,readValueFromPointer:vr,U:V}]})},w:function(){},C:function(_,L,B,V,rt){var yt=Os(B);L=ue(L),Mi(_,{name:L,fromWireType:function(ht){return!!ht},toWireType:function(ht,_t){return _t?V:rt},argPackAdvance:8,readValueFromPointer:function(ht){if(B===1)var _t=$;else if(B===2)_t=tt;else if(B===4)_t=J;else throw new TypeError("Unknown boolean type size: "+L);return this.fromWireType(_t[ht>>yt])},U:null})},g:function(_,L,B,V,rt,yt,ht,_t,It,Dt,Ft,zt,te){Ft=ue(Ft),yt=Cr(rt,yt),_t&&(_t=Cr(ht,_t)),Dt&&(Dt=Cr(It,Dt)),te=Cr(zt,te);var xt=Ke(Ft);EE(xt,function(){il("Cannot construct "+Ft+" due to unbound types",[V])}),br([_,L,B],V?[V]:[],function(Ee){if(Ee=Ee[0],V)var Ei=Ee.M,ce=Ei.W;else ce=Ar.prototype;Ee=_e(xt,function(){if(Object.getPrototypeOf(this)!==Ji)throw new Me("Use 'new' to construct "+Ft);if(Bt.X===void 0)throw new Me(Ft+" has no accessible constructor");var ai=Bt.X[arguments.length];if(ai===void 0)throw new Me("Tried to invoke ctor of "+Ft+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(Bt.X).toString()+") parameters instead!");return ai.apply(this,arguments)});var Ji=Object.create(ce,{constructor:{value:Ee}});Ee.prototype=Ji;var Bt=new TE(Ft,Ee,Ji,te,Ei,yt,_t,Dt);Ei=new ds(Ft,Bt,!0,!1),ce=new ds(Ft+"*",Bt,!1,!1);var al=new ds(Ft+" const*",Bt,!1,!0);return ar[_]={pointerType:ce,ka:al},RE(xt,Ee),[Ei,ce,al]})},d:function(_,L,B,V,rt,yt,ht){var _t=_h(B,V);L=ue(L),yt=Cr(rt,yt),br([],[_],function(It){function Dt(){il("Cannot call "+Ft+" due to unbound types",_t)}It=It[0];var Ft=It.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]);var zt=It.M.constructor;return zt[L]===void 0?(Dt.Y=B-1,zt[L]=Dt):(Ms(zt,L,Ft),zt[L].R[B-1]=Dt),br([],_t,function(te){return te=Rh(Ft,[te[0],null].concat(te.slice(1)),null,yt,ht),zt[L].R===void 0?(te.Y=B-1,zt[L]=te):zt[L].R[B-1]=te,[]}),[]})},p:function(_,L,B,V,rt,yt){0<L||Lt();var ht=_h(L,B);rt=Cr(V,rt),br([],[_],function(_t){_t=_t[0];var It="constructor "+_t.name;if(_t.M.X===void 0&&(_t.M.X=[]),_t.M.X[L-1]!==void 0)throw new Me("Cannot register multiple constructors with identical number of parameters ("+(L-1)+") for class '"+_t.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return _t.M.X[L-1]=()=>{il("Cannot construct "+_t.name+" due to unbound types",ht)},br([],ht,function(Dt){return Dt.splice(1,0,null),_t.M.X[L-1]=Rh(It,Dt,null,rt,yt),[]}),[]})},b:function(_,L,B,V,rt,yt,ht,_t){var It=_h(B,V);L=ue(L),yt=Cr(rt,yt),br([],[_],function(Dt){function Ft(){il("Cannot call "+zt+" due to unbound types",It)}Dt=Dt[0];var zt=Dt.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]),_t&&Dt.M.ia.push(L);var te=Dt.M.W,xt=te[L];return xt===void 0||xt.R===void 0&&xt.className!==Dt.name&&xt.Y===B-2?(Ft.Y=B-2,Ft.className=Dt.name,te[L]=Ft):(Ms(te,L,zt),te[L].R[B-2]=Ft),br([],It,function(Ee){return Ee=Rh(zt,Ee,Dt,yt,ht),te[L].R===void 0?(Ee.Y=B-2,te[L]=Ee):te[L].R[B-2]=Ee,[]}),[]})},B:function(_,L){L=ue(L),Mi(_,{name:L,fromWireType:function(B){var V=ze(B);return Lh(B),V},toWireType:function(B,V){return Fe(V)},argPackAdvance:8,readValueFromPointer:vr,U:null})},n:function(_,L,B){B=Os(B),L=ue(L),Mi(_,{name:L,fromWireType:function(V){return V},toWireType:function(V,rt){return rt},argPackAdvance:8,readValueFromPointer:LE(L,B),U:null})},e:function(_,L,B,V,rt){L=ue(L),rt===-1&&(rt=4294967295),rt=Os(B);var yt=_t=>_t;if(V===0){var ht=32-8*B;yt=_t=>_t<<ht>>>ht}B=L.includes("unsigned")?function(_t,It){return It>>>0}:function(_t,It){return It},Mi(_,{name:L,fromWireType:yt,toWireType:B,argPackAdvance:8,readValueFromPointer:CE(L,rt,V!==0),U:null})},c:function(_,L,B){function V(yt){yt>>=2;var ht=St;return new rt(H,ht[yt+1],ht[yt])}var rt=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][L];B=ue(B),Mi(_,{name:B,fromWireType:V,argPackAdvance:8,readValueFromPointer:V},{ta:!0})},o:function(_,L){L=ue(L);var B=L==="std::string";Mi(_,{name:L,fromWireType:function(V){var rt=St[V>>2],yt=V+4;if(B)for(var ht=yt,_t=0;_t<=rt;++_t){var It=yt+_t;if(_t==rt||z[It]==0){if(ht=ht?D(z,ht,It-ht):"",Dt===void 0)var Dt=ht;else Dt+=String.fromCharCode(0),Dt+=ht;ht=It+1}}else{for(Dt=Array(rt),_t=0;_t<rt;++_t)Dt[_t]=String.fromCharCode(z[yt+_t]);Dt=Dt.join("")}return $s(V),Dt},toWireType:function(V,rt){rt instanceof ArrayBuffer&&(rt=new Uint8Array(rt));var yt,ht=typeof rt=="string";if(ht||rt instanceof Uint8Array||rt instanceof Uint8ClampedArray||rt instanceof Int8Array||Ut("Cannot pass non-string to std::string"),B&&ht){var _t=0;for(yt=0;yt<rt.length;++yt){var It=rt.charCodeAt(yt);127>=It?_t++:2047>=It?_t+=2:55296<=It&&57343>=It?(_t+=4,++yt):_t+=3}yt=_t}else yt=rt.length;if(_t=yp(4+yt+1),It=_t+4,St[_t>>2]=yt,B&&ht){if(ht=It,It=yt+1,yt=z,0<It){It=ht+It-1;for(var Dt=0;Dt<rt.length;++Dt){var Ft=rt.charCodeAt(Dt);if(55296<=Ft&&57343>=Ft){var zt=rt.charCodeAt(++Dt);Ft=65536+((Ft&1023)<<10)|zt&1023}if(127>=Ft){if(ht>=It)break;yt[ht++]=Ft}else{if(2047>=Ft){if(ht+1>=It)break;yt[ht++]=192|Ft>>6}else{if(65535>=Ft){if(ht+2>=It)break;yt[ht++]=224|Ft>>12}else{if(ht+3>=It)break;yt[ht++]=240|Ft>>18,yt[ht++]=128|Ft>>12&63}yt[ht++]=128|Ft>>6&63}yt[ht++]=128|Ft&63}}yt[ht]=0}}else if(ht)for(ht=0;ht<yt;++ht)Dt=rt.charCodeAt(ht),255<Dt&&($s(It),Ut("String has UTF-16 code units that do not fit in 8 bits")),z[It+ht]=Dt;else for(ht=0;ht<yt;++ht)z[It+ht]=rt[ht];return V!==null&&V.push($s,_t),_t},argPackAdvance:8,readValueFromPointer:vr,U:function(V){$s(V)}})},j:function(_,L,B){if(B=ue(B),L===2)var V=IE,rt=DE,yt=xE,ht=()=>at,_t=1;else L===4&&(V=PE,rt=OE,yt=ME,ht=()=>St,_t=2);Mi(_,{name:B,fromWireType:function(It){for(var Dt=St[It>>2],Ft=ht(),zt,te=It+4,xt=0;xt<=Dt;++xt){var Ee=It+4+xt*L;(xt==Dt||Ft[Ee>>_t]==0)&&(te=V(te,Ee-te),zt===void 0?zt=te:(zt+=String.fromCharCode(0),zt+=te),te=Ee+L)}return $s(It),zt},toWireType:function(It,Dt){typeof Dt!="string"&&Ut("Cannot pass non-string to C++ string type "+B);var Ft=yt(Dt),zt=yp(4+Ft+L);return St[zt>>2]=Ft>>_t,rt(Dt,zt+4,Ft+L),It!==null&&It.push($s,zt),zt},argPackAdvance:8,readValueFromPointer:vr,U:function(It){$s(It)}})},l:function(_,L,B,V,rt,yt){ci[_]={name:ue(L),ea:Cr(B,V),V:Cr(rt,yt),ha:[]}},i:function(_,L,B,V,rt,yt,ht,_t,It,Dt){ci[_].ha.push({na:ue(L),sa:B,qa:Cr(V,rt),ra:yt,ya:ht,xa:Cr(_t,It),za:Dt})},D:function(_,L){L=ue(L),Mi(_,{ua:!0,name:L,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},t:function(_,L,B,V,rt){_=rl[_],L=ze(L),B=gp(B);var yt=[];return St[V>>2]=Fe(yt),_(L,B,yt,rt)},u:function(_,L,B,V){_=rl[_],L=ze(L),B=gp(B),_(L,B,null,V)},h:Lh,m:function(_,L){var B=NE(_,L),V=B[0];L=V.name+"_$"+B.slice(1).map(function(ht){return ht.name}).join("_")+"$";var rt=mp[L];if(rt!==void 0)return rt;var yt=Array(_-1);return rt=FE((ht,_t,It,Dt)=>{for(var Ft=0,zt=0;zt<_-1;++zt)yt[zt]=B[zt+1].readValueFromPointer(Dt+Ft),Ft+=B[zt+1].argPackAdvance;for(ht=ht[_t].apply(ht,yt),zt=0;zt<_-1;++zt)B[zt+1].la&&B[zt+1].la(yt[zt]);if(!V.ua)return V.toWireType(It,ht)}),mp[L]=rt},r:function(_){4<_&&(Kt[_].fa+=1)},s:function(_){var L=ze(_);Oi(L),Lh(_)},f:function(){Lt("")},y:function(_,L,B){z.copyWithin(_,L,L+B)},x:function(_){var L=z.length;if(_>>>=0,2147483648<_)return!1;for(var B=1;4>=B;B*=2){var V=L*(1+.2/B);V=Math.min(V,_+100663296);var rt=Math;V=Math.max(_,V),rt=rt.min.call(rt,2147483648,V+(65536-V%65536)%65536);t:{try{O.grow(rt-H.byteLength+65535>>>16),Vt(O.buffer);var yt=1;break t}catch{}yt=void 0}if(yt)return!0}return!1},A:function(){return 52},v:function(){return 70},z:function(_,L,B,V){for(var rt=0,yt=0;yt<B;yt++){var ht=St[L>>2],_t=St[L+4>>2];L+=8;for(var It=0;It<_t;It++){var Dt=z[ht+It],Ft=UE[_];Dt===0||Dt===10?((_===1?g:v)(D(Ft,0)),Ft.length=0):Ft.push(Dt)}rt+=_t}return St[V>>2]=rt,0},a:O},Un=function(){function _(B){o.asm=B.exports,q=o.asm.I,N.unshift(o.asm.E),nt--,o.monitorRunDependencies&&o.monitorRunDependencies(nt),nt==0&&ct&&(B=ct,ct=null,B())}var L={a:GE};if(nt++,o.monitorRunDependencies&&o.monitorRunDependencies(nt),o.instantiateWasm)try{return o.instantiateWasm(L,_)}catch(B){v("Module.instantiateWasm callback failed with error: "+B),d(B)}return L=ve(L),_(L[0]),o.asm}();o.___wasm_call_ctors=Un.E;var VE=o.___getTypeName=Un.F;o.__embind_initialize_bindings=Un.G;var yp=o._malloc=Un.H,$s=o._free=Un.J;o.dynCall_jiji=Un.K;var nl;ct=function _(){nl||bp(),nl||(ct=_)};function bp(){function _(){if(!nl&&(nl=!0,o.calledRun=!0,!U)){if(me(N),l(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;){var L=o.postRun.shift();F.unshift(L)}me(F)}}if(!(0<nt)){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)j();me(At),0<nt||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),_()},1)):_())}}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);0<o.preInit.length;)o.preInit.pop()();return bp(),n}})();s.exports=e})(tu);var Am=tu.exports;(function(s){Object.defineProperty(s,"__esModule",{value:!0});var t={};s.default=void 0;var e=n(Wl),i=re;Object.keys(i).forEach(function(d){d==="default"||d==="__esModule"||Object.prototype.hasOwnProperty.call(t,d)||d in s&&s[d]===i[d]||Object.defineProperty(s,d,{enumerable:!0,get:function(){return i[d]}})});function n(d){return d&&d.__esModule?d:{default:d}}const o=Am;var l=(0,e.default)(o());s.default=l})(Te);const eu=mm(Te),is=1.8;function Em(s,t){return typeof s=="number"?{top:s*t,right:s*t,bottom:s*t,left:s*t}:{top:typeof s.top=="number"?s.top*t:s.top,right:typeof s.right=="number"?s.right*t:s.right,bottom:typeof s.bottom=="number"?s.bottom*t:s.bottom,left:typeof s.left=="number"?s.left*t:s.left}}function iu(s,t){return typeof s=="number"?{top:s*t,right:s*t,bottom:s*t,left:s*t}:{top:(typeof s.top=="number"?s.top*t:s.top)??0,right:(typeof s.right=="number"?s.right*t:s.right)??0,bottom:(typeof s.bottom=="number"?s.bottom*t:s.bottom)??0,left:(typeof s.left=="number"?s.left*t:s.left)??0}}function Tm(s,t=1){return typeof s=="number"?{topLeft:s*t,topRight:s*t,bottomRight:s*t,bottomLeft:s*t}:{topLeft:((s==null?void 0:s.topLeft)??0)*t,topRight:((s==null?void 0:s.topRight)??0)*t,bottomRight:((s==null?void 0:s.bottomRight)??0)*t,bottomLeft:((s==null?void 0:s.bottomLeft)??0)*t}}function ru(s,{layout:t,scale:e=1}){const{position:i="static",inset:n,width:o,height:l,minWidth:d,minHeight:f,maxWidth:p,maxHeight:g,flex:v,gap:A,margin:E,padding:T,direction:w="column",align:C="start",alignSelf:x,justify:O="start"}=t,U={static:Te.PositionType.Static,relative:Te.PositionType.Relative,absolute:Te.PositionType.Absolute};if(s.setPositionType(U[i]),n){const{top:z,right:tt,bottom:at,left:J}=Em(n,e);z&&s.setPosition(Te.Edge.Top,z),tt&&s.setPosition(Te.Edge.Right,tt),at&&s.setPosition(Te.Edge.Bottom,at),J&&s.setPosition(Te.Edge.Left,J)}const D={row:Te.FlexDirection.Row,column:Te.FlexDirection.Column,"row-reverse":Te.FlexDirection.RowReverse,"column-reverse":Te.FlexDirection.ColumnReverse};s.setFlexDirection(D[w]);const H={start:Te.Align.FlexStart,end:Te.Align.FlexEnd,center:Te.Align.Center,stretch:Te.Align.Stretch};s.setAlignItems(H[C]),x&&s.setAlignSelf(H[x]);const $={start:Te.Justify.FlexStart,end:Te.Justify.FlexEnd,center:Te.Justify.Center,"space-between":Te.Justify.SpaceBetween,"space-around":Te.Justify.SpaceAround,"space-evenly":Te.Justify.SpaceEvenly};if(s.setJustifyContent($[O]),E){const{top:z,right:tt,bottom:at,left:J}=iu(E,e);s.setMargin(Te.Edge.Top,z),s.setMargin(Te.Edge.Right,tt),s.setMargin(Te.Edge.Bottom,at),s.setMargin(Te.Edge.Left,J)}if(T){const{top:z,right:tt,bottom:at,left:J}=iu(T,e);s.setPadding(Te.Edge.Top,z),s.setPadding(Te.Edge.Right,tt),s.setPadding(Te.Edge.Bottom,at),s.setPadding(Te.Edge.Left,J)}v&&s.setFlex(v),s.setGap(Te.Gutter.All,(A??0)*e),o&&s.setWidth(typeof o=="number"?o*e:o),l&&(typeof l=="function"?s.setHeight("100%"):s.setHeight(typeof l=="number"?l*e:l)),d&&s.setMinWidth(typeof d=="number"?d*e:d),f&&s.setMinHeight(typeof f=="number"?f*e:f),p&&s.setMaxWidth(typeof p=="number"?p*e:p),g&&s.setMaxHeight(typeof g=="number"?g*e:g)}function su({canvas:s,debug:t=!1,scale:e=1,position:i=[]}){i.forEach(({x:n,y:o,width:l,height:d,childNodes:f,element:p})=>{const g=s.getContext("2d",{alpha:!1});if(g){const{radius:v,draw:A}=p;if(A){if(g.save(),v){const{topLeft:E,topRight:T,bottomRight:w,bottomLeft:C}=Tm(v,e);g.beginPath(),g.moveTo(n+Math.min(d/is,E),o),g.lineTo(n+l-Math.min(d/is,T),o),g.quadraticCurveTo(n+l,o,n+l,o+Math.min(d/is,T)),g.lineTo(n+l,o+d-Math.min(d/is,w)),g.quadraticCurveTo(n+l,o+d,n+l-Math.min(d/is,w),o+d),g.lineTo(n+Math.min(d/is,C),o+d),g.quadraticCurveTo(n,o+d,n,o+d-Math.min(d/is,C)),g.lineTo(n,o+Math.min(d/is,E)),g.quadraticCurveTo(n,o,n+Math.min(d/is,E),o),g.closePath(),t&&(g.strokeStyle="blue",g.stroke()),g.clip()}A({scale:e,dx:n,dy:o,dw:l,dh:d}),t&&(g.strokeStyle="red",g.strokeRect(n,o,l,d)),g.restore()}}su({canvas:s,debug:t,scale:e,position:f})})}function nu(s,t,e){const i=t.map((n,o)=>{const l=eu.Node.create(),{radius:d,elements:f=[],draw:p,...g}=n;return ru(l,{layout:g,scale:e}),s.insertChild(l,o),{node:l,element:n,childNodes:nu(l,f,e)}});return s.calculateLayout(),i}function au(s,t,e=0,i=0){const{top:n,left:o}=s.getComputedLayout();return t.map(({node:l,element:d,childNodes:f})=>{const{top:p,left:g,width:v,height:A}=l.getComputedLayout(),E=e+g,T=i+p;return{x:o+E,y:n+T,width:v,height:A,element:d,childNodes:au(s,f,E,T)}})}function ou(s,t){s.forEach(({node:e,element:i,childNodes:n})=>{const{height:o}=i;if(o&&typeof o=="function"){const l=e.getComputedWidth(),d=e.getComputedHeight(),f=o({width:l,maxHeight:d,scale:t});e.setHeight(f)}ou(n,t)})}function km({canvas:s,origin:t,elements:e,...i}){const n={inset:{top:0,left:0},width:s.width,height:s.height,...t},o=eu.Node.create();ru(o,{layout:n}),o.calculateLayout();const{width:l,height:d}=o.getComputedLayout(),f=Math.min(l,d)/1080,p=nu(o,e,f);ou(p,f),o.calculateLayout();const g=au(o,p);return su({...i,scale:f,canvas:s,position:g})}const lu=[{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 vo({text:s,font:t}){let e=t;return lu.forEach(({family:i,regex:n})=>{n.exec(s)&&(e+=`, ${i}`)}),e}const yo=/(?<value>\d+\.?\d*)(?=px)/;function cu(s){const{visible:t=!0,node:e}=s,i=[...(e==null?void 0:e.elements)??[],...(s==null?void 0:s.elements)??[]];return t?e&&e.type!=="box"&&e.type!=="gradient"?!!e.value:i==null?void 0:i.some(n=>cu(n)):!1}function hu({debug:s=!1,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:o=[],currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,parentAlpha:A}){return o.map(E=>{var T,w,C,x,O,U,D,H;const{node:$,transient:z=[{from:0,duration:1/0}]}=E,tt=t.getContext("2d"),at={total:l,content:d,scene:f},J={total:p,content:g,scene:v},St=z.reduce((mt,{type:Ot="scene",from:Vt,duration:G,animation:q})=>{const At=Vt<0?J[Ot]+Vt:Vt;return at[Ot]>=At&&at[Ot]<=At+G&&(mt={type:Ot,animation:q,duration:G,from:At}),mt},null);if(tt&&St&&cu(E)){let mt=E.width,Ot=E.height,Vt=A??1;const{type:G="scene",from:q,duration:At,animation:N={type:"fade",duration:.3333333333333333}}=St;if(N){const{type:F,duration:j}=N;F==="fade"&&(q>0&&at[G]<=q+j&&(Vt=Math.max(0,Math.min(1,(at[G]-q)/j))),q+At<J[G]&&q+At-j<=at[G]&&(Vt=Math.max(0,Math.min(1,(q+At-at[G])/j))))}if(($==null?void 0:$.type)==="text"&&$.value){const F=vo({text:$.value,font:$.font});tt.save(),$.wrap?Ot=({width:j,maxHeight:nt,scale:ct})=>{var Lt,Nt;const jt=Qd({font:F,scale:ct,context:tt,maxW:j,maxH:nt,text:$.value??"",minSize:(Lt=$.fill)==null?void 0:Lt.minSize,maxSize:(Nt=$.fill)==null?void 0:Nt.maxSize});return bo({context:tt,font:F,fontSize:jt,text:$.value??"",maxW:j}).length*jt}:(tt.font=F,mt=tt.measureText($.value).width,Ot=parseFloat(((w=(T=F.match(yo))==null?void 0:T.groups)==null?void 0:w.value)??"0")),tt.restore()}if(($==null?void 0:$.type)==="image"&&$.image&&$.size){const F=((C=$.image)==null?void 0:C.naturalWidth)??((x=$.image)==null?void 0:x.width),j=((O=$.image)==null?void 0:O.naturalHeight)??((U=$.image)==null?void 0:U.height),nt=F/j,ct=(D=$.size)==null?void 0:D.width,Lt=(H=$.size)==null?void 0:H.height;mt=ct??(nt>=1?(Lt??0)*nt:(Lt??0)/nt),Ot=Lt??(nt<1?(ct??0)*nt:(ct??0)/nt)}return{...E,width:mt,height:Ot,elements:hu({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:E.elements,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,parentAlpha:Vt}),draw:({dx:F,dy:j,dw:nt,dh:ct,scale:Lt})=>{var Nt,jt,fe,ve,me,Ke,_e,Kt,Ae,de,Me,Ut,ze;if(tt.globalAlpha=Vt,$){const{type:Fe}=$;if(Fe==="box"&&(tt.fillStyle=$.background,tt.fillRect(F,j,nt,ct)),Fe==="text"&&$.value){const Ve=vo({text:$.value,font:$.font}),we=Qd({font:Ve,scale:Lt,context:tt,maxW:nt,maxH:ct,text:$.value??"",minSize:(Nt=$.fill)==null?void 0:Nt.minSize,maxSize:(jt=$.fill)==null?void 0:jt.maxSize});tt.font=Ve.replace(yo,we.toString()),tt.textBaseline="top",tt.fillStyle=$.color,$.wrap?bo({context:tt,font:Ve,fontSize:we,text:$.value,maxW:nt}).forEach((ue,Ye)=>{tt.fillText(ue.text,F,j+we*Ye)}):tt.fillText($.value,F,j)}if(Fe==="image"&&$.image&&tt.drawImage($.image,F,j,nt,ct),Fe==="video"&&((fe=$.video)!=null&&fe.node||(ve=$.video)!=null&&ve.getSource)){const Ve=$.format??"letterbox",we=((Ke=(me=$.video)==null?void 0:me.getSource)==null?void 0:Ke.call(me,f))??$.video.node,ue=(we==null?void 0:we.videoWidth)??(we==null?void 0:we.naturalWidth)??(we==null?void 0:we.width),Ye=(we==null?void 0:we.videoHeight)??(we==null?void 0:we.naturalHeight)??(we==null?void 0:we.height);if(ue&&Ye){const{dx:Ne,dy:Ue,dw:pi,dh:Ce}=Yd({context:tt,cropCanvas:e,letterboxCanvas:n,source:we,format:Ve,crop:(_e=$==null?void 0:$.value)==null?void 0:_e.crop,sourceWidth:ue,sourceHeight:Ye,posX:F,posY:j,drawAreaWidth:nt,drawAreaHeight:ct});$.elements&&Yl({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:$.elements,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,origin:{inset:{top:Math.max(j,j+Ue),left:Math.max(F,F+Ne)},width:Math.min(nt,pi),height:Math.min(ct,Ce)}})}const le=1/3;if($.poster&&l>=0&&l<=le){tt.save(),tt.globalAlpha=1-l/le;const Ne=((Kt=$.poster)==null?void 0:Kt.naturalWidth)??((Ae=$.poster)==null?void 0:Ae.width),Ue=((de=$.poster)==null?void 0:de.naturalHeight)??((Me=$.poster)==null?void 0:Me.height);i.width=i.height=0,i.width=nt,i.height=ct;const pi=i.getContext("2d");if(pi&&Ne&&Ue){const{dx:Ce,dy:Ai,dw:_r,dh:ni}=Yd({context:pi,cropCanvas:e,letterboxCanvas:n,source:$.poster,format:Ve,crop:(Ut=$==null?void 0:$.value)==null?void 0:Ut.crop,sourceWidth:Ne,sourceHeight:Ue,posX:0,posY:0,drawAreaWidth:nt,drawAreaHeight:ct});$.elements&&Yl({debug:s,canvas:i,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:$.elements,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,origin:{inset:{top:Math.max(0,Ai),left:Math.max(0,Ce)},width:Math.min(nt,_r),height:Math.min(ct,ni)}}),tt.drawImage(i,F,j,nt,ct),tt.restore()}}}if(Fe==="gradient"&&$.value){const Ve=tt.createLinearGradient(F+nt,j,F+nt,j+ct);(ze=$.value)==null||ze.forEach(we=>{Ve.addColorStop(we.percent,we.color)}),tt.fillStyle=Ve,tt.fillRect(F,j,nt,ct)}}}}}}).filter(Boolean)}function Yl({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:o,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,...A}){return km({...A,debug:s,canvas:t,elements:hu({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:o,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v})})}const bo=Zd(({context:s,font:t,fontSize:e,text:i,maxW:n=1/0})=>{try{return s.save(),s.font=t.replace(yo,e.toString()),i.split(`
77
+ */const Pg=Symbol();class so{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 n=typeof e=="object"?e:{task:e,args:i};this._=n.task,this.v=n.args,this.j=n.argsEqual??Og,this.m=n.onComplete,this.g=n.onError,this.autoRun=n.autoRun??!0,"initialValue"in n&&(this.l=n.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 l,d,f,p,g;let e,i;t??(t=this.A()),this.k=t,this.status===1?(l=this.T)==null||l.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 n=++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===n){if(e===Pg)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,n,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(n=t.complete)==null?void 0:n.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 Og=(s,t)=>s===t||s.length===t.length&&s.every((e,i)=>!Ul(e,t[i]));let no;const Mg=new Uint8Array(16);function $g(){if(!no&&(no=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!no))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return no(Mg)}const Li=[];for(let s=0;s<256;++s)Li.push((s+256).toString(16).slice(1));function Fg(s,t=0){return Li[s[t+0]]+Li[s[t+1]]+Li[s[t+2]]+Li[s[t+3]]+"-"+Li[s[t+4]]+Li[s[t+5]]+"-"+Li[s[t+6]]+Li[s[t+7]]+"-"+Li[s[t+8]]+Li[s[t+9]]+"-"+Li[s[t+10]]+Li[s[t+11]]+Li[s[t+12]]+Li[s[t+13]]+Li[s[t+14]]+Li[s[t+15]]}const jd={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function en(s,t,e){if(jd.randomUUID&&!t&&!s)return jd.randomUUID();s=s||{};const i=s.random||(s.rng||$g)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let n=0;n<16;++n)t[e+n]=i[n];return t}return Fg(i)}const Kd="https://d2rxhdlm2q91uk.cloudfront.net",Ng="https://d1ix11aj5kfygl.cloudfront.net",Ug="https://d157jlwnudd93d.cloudfront.net",Yd="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",Bg="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",Gg="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",Vg="http://localhost:6060/v2",Hg="https://embed-dev.vouchfor.com/v2",Wg="https://embed-staging.vouchfor.com/v2",jg="https://embed.vouchfor.com/v2";function ao(s){if(!["local","dev","staging","prod"].includes(s))throw new Error(`Unknown environment: ${s}`);if(s==="local")return{videoUrl:Kd,publicApiUrl:Yd,embedApiUrl:Vg};if(s==="dev")return{videoUrl:Kd,publicApiUrl:Yd,embedApiUrl:Hg};if(s==="staging")return{videoUrl:Ng,publicApiUrl:Bg,embedApiUrl:Wg};if(s==="prod")return{videoUrl:Ug,publicApiUrl:Gg,embedApiUrl:jg}}class Kg{constructor(t){this._fetching=!1,this.getVouch=async(e,i,n)=>{var g;const{embedApiUrl:o}=ao(e),l=en(),d=await fetch(`${o}/vouches/${n}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",l]]}),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"))!==l&&fetch(`${o}/vouches/${n}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.getTemplate=async(e,i,n)=>{var g;const{embedApiUrl:o}=ao(e),l=en(),d=await fetch(`${o}/templates/${n}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",l]]}),f=await d.json();return((g=d==null?void 0:d.headers)==null?void 0:g.get("X-Cache-Check"))!==l&&fetch(`${o}/templates/${n}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.host=t,new so(this.host,async([e,i,n,o,l])=>{var d,f,p,g;try{if(t.vouch=void 0,t.template=void 0,n){let v;l&&(this.fetching=!0,v=await this.getTemplate(e,i,l)),this._vouch=n,t.template=v??((f=(d=n==null?void 0:n.settings)==null?void 0:d.template)==null?void 0:f.instance)}else if(o){this.fetching=!0;const[v,A]=await Promise.all([this.getVouch(e,i,o),l?this.getTemplate(e,i,l):null]);this._vouch=v,t.template=A??((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]),new so(this.host,([e,i])=>{t.vouch=e?{...e,questions:{items:e==null?void 0:e.questions.items.filter((n,o)=>!(i!=null&&i.length)||(i==null?void 0:i.includes(o+1)))}}:void 0},()=>[this._vouch,t.questions])}set fetching(t){this._fetching!==t&&(this._fetching=t,this.host.requestUpdate())}get fetching(){return this._fetching}}const Yg=(s,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const n=Object.getOwnPropertyDescriptor(s,e),o=Object.getOwnPropertyDescriptor(t,e);!zg(n,o)&&i||Object.defineProperty(s,e,o)},zg=function(s,t){return s===void 0||s.configurable||s.writable===t.writable&&s.enumerable===t.enumerable&&s.configurable===t.configurable&&(s.writable||s.value===t.value)},Xg=(s,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(s)&&Object.setPrototypeOf(s,e)},Zg=(s,t)=>`/* Wrapped ${s}*/
78
+ ${t}`,qg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Qg=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Jg=(s,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,n=Zg.bind(null,i,t.toString());Object.defineProperty(n,"name",Qg),Object.defineProperty(s,"toString",{...qg,value:n})};function tm(s,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=s;for(const n of Reflect.ownKeys(t))Yg(s,t,n,e);return Xg(s,t),Jg(s,t,i),s}const em=new WeakMap;function ks(s,{cacheKey:t=([i])=>i,cache:e=new Map}={}){const i=new Map,n=function(...o){const l=t(o);if(i.has(l))return i.get(l);const d=(async()=>{try{if(e&&await e.has(l))return await e.get(l);const p=await s.apply(this,o);try{return p}finally{e&&await e.set(l,p)}}finally{i.delete(l)}})();return i.set(l,d),d};return tm(n,s,{ignoreNonConfigurable:!0}),em.set(n,e),n}var oo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Bl(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Gl={exports:{}};(function(s,t){(function(e,i){i(t)})(oo,function(e){function i(N){var F,j,at=new Error(N);return F=at,j=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(F,j):F.__proto__=j,at}function n(N,F,j){var at=F.slice(0,j).split(/\n/),ht=at.length,_t=at[ht-1].length+1;throw i(N+=" at line "+ht+" col "+_t+`:
79
+
80
+ `+F.split(/\n/)[ht-1]+`
81
+ `+Array(_t).join(" ")+"^")}i.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var o=new Function("return this")().Promise,l=!1;try{l=new Function("return (async function(){}).constructor")()}catch(N){if(!(N instanceof SyntaxError))throw N}function d(N,F){return Object.prototype.hasOwnProperty.call(N,F)}function f(N,F,j){for(var at in F)d(F,at)&&(F[at]==null||typeof F[at]!="object"||at!=="storage"&&at!=="prefixes"||j?N[at]=F[at]:N[at]=f({},F[at]));return N}var p=/^async +/,g=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,v=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,A=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,E=/[.*+\-?^${}()|[\]\\]/g;function T(N){return E.test(N)?N.replace(E,"\\$&"):N}function w(N,F){F.rmWhitespace&&(N=N.replace(/[\r\n]+/g,`
82
+ `).replace(/^\s+|\s+$/gm,"")),g.lastIndex=0,v.lastIndex=0,A.lastIndex=0;var j=F.prefixes,at=[j.h,j.b,j.i,j.r,j.c,j.e].reduce(function(Le,Kt){return Le&&Kt?Le+"|"+T(Kt):Kt?T(Kt):Le},""),ht=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+T(F.tags[1])+")","g"),_t=new RegExp("([^]*?)"+T(F.tags[0])+"(-|_)?\\s*("+at+")?\\s*","g"),$t=0,jt=!1;function fe(Le,Kt){var Ae,de={f:[]},Me=0,Ut="c";function Ye(Ue){var pi=N.slice($t,Ue),Ce=pi.trim();if(Ut==="f")Ce==="safe"?de.raw=!0:F.async&&p.test(Ce)?(Ce=Ce.replace(p,""),de.f.push([Ce,"",!0])):de.f.push([Ce,""]);else if(Ut==="fp")de.f[de.f.length-1][1]+=Ce;else if(Ut==="err"){if(Ce){var Ai=pi.search(/\S/);n("invalid syntax",N,$t+Ai)}}else de[Ut]=Ce;$t=Ue+1}for(Kt==="h"||Kt==="b"||Kt==="c"?Ut="n":Kt==="r"&&(de.raw=!0,Kt="i"),ht.lastIndex=$t;(Ae=ht.exec(N))!==null;){var Fe=Ae[1],Ve=Ae[2],we=Ae[3],ue=Ae[4],ze=Ae[5],le=Ae.index;if(Fe)Fe==="("?(Me===0&&(Ut==="n"?(Ye(le),Ut="p"):Ut==="f"&&(Ye(le),Ut="fp")),Me++):Fe===")"?--Me===0&&Ut!=="c"&&(Ye(le),Ut="err"):Me===0&&Fe==="|"?(Ye(le),Ut="f"):Fe==="=>"&&(Ye(le),$t+=1,Ut="res");else if(Ve)if(Ve==="/*"){var Ne=N.indexOf("*/",ht.lastIndex);Ne===-1&&n("unclosed comment",N,Ae.index),ht.lastIndex=Ne+2}else Ve==="'"?(v.lastIndex=Ae.index,v.exec(N)?ht.lastIndex=v.lastIndex:n("unclosed string",N,Ae.index)):Ve==='"'?(A.lastIndex=Ae.index,A.exec(N)?ht.lastIndex=A.lastIndex:n("unclosed string",N,Ae.index)):Ve==="`"&&(g.lastIndex=Ae.index,g.exec(N)?ht.lastIndex=g.lastIndex:n("unclosed string",N,Ae.index));else if(we)return Ye(le),$t=le+Ae[0].length,_t.lastIndex=$t,jt=ze,ue&&Kt==="h"&&(Kt="s"),de.t=Kt,de}return n("unclosed tag",N,Le),de}var ve=function Le(Kt,Ae){Kt.b=[],Kt.d=[];var de,Me=!1,Ut=[];function Ye(Ai,Lr){Ai&&(Ai=function(ni,_r,Ds,Ps){var ar,dt;return typeof _r.autoTrim=="string"?ar=dt=_r.autoTrim:Array.isArray(_r.autoTrim)&&(ar=_r.autoTrim[1],dt=_r.autoTrim[0]),(Ds||Ds===!1)&&(ar=Ds),(Ps||Ps===!1)&&(dt=Ps),ar==="slurp"&&dt==="slurp"?ni.trim():(ar==="_"||ar==="slurp"?ni=String.prototype.trimLeft?ni.trimLeft():ni.replace(/^[\s\uFEFF\xA0]+/,""):ar!=="-"&&ar!=="nl"||(ni=ni.replace(/^(?:\n|\r|\r\n)/,"")),dt==="_"||dt==="slurp"?ni=String.prototype.trimRight?ni.trimRight():ni.replace(/[\s\uFEFF\xA0]+$/,""):dt!=="-"&&dt!=="nl"||(ni=ni.replace(/(?:\n|\r|\r\n)$/,"")),ni)}(Ai,F,jt,Lr))&&(Ai=Ai.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),Ut.push(Ai))}for(;(de=_t.exec(N))!==null;){var Fe,Ve=de[1],we=de[2],ue=de[3]||"";for(var ze in j)if(j[ze]===ue){Fe=ze;break}Ye(Ve,we),$t=de.index+de[0].length,Fe||n("unrecognized tag type: "+ue,N,$t);var le=fe(de.index,Fe),Ne=le.t;if(Ne==="h"){var Ue=le.n||"";F.async&&p.test(Ue)&&(le.a=!0,le.n=Ue.replace(p,"")),le=Le(le),Ut.push(le)}else if(Ne==="c"){if(Kt.n===le.n)return Me?(Me.d=Ut,Kt.b.push(Me)):Kt.d=Ut,Kt;n("Helper start and end don't match",N,de.index+de[0].length)}else if(Ne==="b"){Me?(Me.d=Ut,Kt.b.push(Me)):Kt.d=Ut;var pi=le.n||"";F.async&&p.test(pi)&&(le.a=!0,le.n=pi.replace(p,"")),Me=le,Ut=[]}else if(Ne==="s"){var Ce=le.n||"";F.async&&p.test(Ce)&&(le.a=!0,le.n=Ce.replace(p,"")),Ut.push(le)}else Ut.push(le)}if(!Ae)throw i('unclosed helper "'+Kt.n+'"');return Ye(N.slice($t,N.length),!1),Kt.d=Ut,Kt}({f:[]},!0);if(F.plugins)for(var me=0;me<F.plugins.length;me++){var Ke=F.plugins[me];Ke.processAST&&(ve.d=Ke.processAST(ve.d,F))}return ve.d}function C(N,F){var j=w(N,F),at="var tR='';"+(F.useWith?"with("+F.varName+"||{}){":"")+G(j,F)+"if(cb){cb(null,tR)} return tR"+(F.useWith?"}":"");if(F.plugins)for(var ht=0;ht<F.plugins.length;ht++){var _t=F.plugins[ht];_t.processFnString&&(at=_t.processFnString(at,F))}return at}function D(N,F){for(var j=0;j<F.length;j++){var at=F[j][0],ht=F[j][1];N=(F[j][2]?"await ":"")+"c.l('F','"+at+"')("+N,ht&&(N+=","+ht),N+=")"}return N}function M(N,F,j,at,ht,_t){var $t="{exec:"+(ht?"async ":"")+x(j,F,N)+",params:["+at+"]";return _t&&($t+=",name:'"+_t+"'"),ht&&($t+=",async:true"),$t+="}"}function U(N,F){for(var j="[",at=0;at<N.length;at++){var ht=N[at];j+=M(F,ht.res||"",ht.d,ht.p||"",ht.a,ht.n),at<N.length&&(j+=",")}return j+="]"}function x(N,F,j){return"function("+F+"){var tR='';"+G(N,j)+"return tR}"}function G(N,F){for(var j=0,at=N.length,ht="";j<at;j++){var _t=N[j];if(typeof _t=="string")ht+="tR+='"+_t+"';";else{var $t=_t.t,jt=_t.c||"",fe=_t.f,ve=_t.n||"",me=_t.p||"",Ke=_t.res||"",Le=_t.b,Kt=!!_t.a;if($t==="i"){F.defaultFilter&&(jt="c.l('F','"+F.defaultFilter+"')("+jt+")");var Ae=D(jt,fe);!_t.raw&&F.autoEscape&&(Ae="c.l('F','e')("+Ae+")"),ht+="tR+="+Ae+";"}else if($t==="h")if(F.storage.nativeHelpers.get(ve))ht+=F.storage.nativeHelpers.get(ve)(_t,F);else{var de=(Kt?"await ":"")+"c.l('H','"+ve+"')("+M(F,Ke,_t.d,me,Kt);de+=Le?","+U(Le,F):",[]",ht+="tR+="+D(de+=",c)",fe)+";"}else $t==="s"?ht+="tR+="+D((Kt?"await ":"")+"c.l('H','"+ve+"')({params:["+me+"]},[],c)",fe)+";":$t==="e"&&(ht+=jt+`
83
+ `)}}return ht}var $=function(){function N(F){this.cache=F}return N.prototype.define=function(F,j){this.cache[F]=j},N.prototype.get=function(F){return this.cache[F]},N.prototype.remove=function(F){delete this.cache[F]},N.prototype.reset=function(){this.cache={}},N.prototype.load=function(F){f(this.cache,F,!0)},N}();function Y(N,F,j,at){if(F&&F.length>0)throw i((at?"Native":"")+"Helper '"+N+"' doesn't accept blocks");if(j&&j.length>0)throw i((at?"Native":"")+"Helper '"+N+"' doesn't accept filters")}var tt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function nt(N){return tt[N]}var J=new $({}),St=new $({each:function(N,F){var j="",at=N.params[0];if(Y("each",F,!1),N.async)return new Promise(function(_t){(function $t(jt,fe,ve,me,Ke){ve(jt[fe],fe).then(function(Le){me+=Le,fe===jt.length-1?Ke(me):$t(jt,fe+1,ve,me,Ke)})})(at,0,N.exec,j,_t)});for(var ht=0;ht<at.length;ht++)j+=N.exec(at[ht],ht);return j},foreach:function(N,F){var j=N.params[0];if(Y("foreach",F,!1),N.async)return new Promise(function(_t){(function $t(jt,fe,ve,me,Ke,Le){me(fe[ve],jt[fe[ve]]).then(function(Kt){Ke+=Kt,ve===fe.length-1?Le(Ke):$t(jt,fe,ve+1,me,Ke,Le)})})(j,Object.keys(j),0,N.exec,"",_t)});var at="";for(var ht in j)d(j,ht)&&(at+=N.exec(ht,j[ht]));return at},include:function(N,F,j){Y("include",F,!1);var at=j.storage.templates.get(N.params[0]);if(!at)throw i('Could not fetch template "'+N.params[0]+'"');return at(N.params[1],j)},extends:function(N,F,j){var at=N.params[1]||{};at.content=N.exec();for(var ht=0;ht<F.length;ht++){var _t=F[ht];at[_t.name]=_t.exec()}var $t=j.storage.templates.get(N.params[0]);if(!$t)throw i('Could not fetch template "'+N.params[0]+'"');return $t(at,j)},useScope:function(N,F){return Y("useScope",F,!1),N.exec(N.params[0])}}),mt=new $({if:function(N,F){Y("if",!1,N.f,!0);var j="if("+N.p+"){"+G(N.d,F)+"}";if(N.b)for(var at=0;at<N.b.length;at++){var ht=N.b[at];ht.n==="else"?j+="else{"+G(ht.d,F)+"}":ht.n==="elif"&&(j+="else if("+ht.p+"){"+G(ht.d,F)+"}")}return j},try:function(N,F){if(Y("try",!1,N.f,!0),!N.b||N.b.length!==1||N.b[0].n!=="catch")throw i("native helper 'try' only accepts 1 block, 'catch'");var j="try{"+G(N.d,F)+"}",at=N.b[0];return j+="catch"+(at.res?"("+at.res+")":"")+"{"+G(at.d,F)+"}"},block:function(N,F){return Y("block",N.b,N.f,!0),"if(!"+F.varName+"["+N.p+"]){tR+=("+x(N.d,"",F)+")()}else{tR+="+F.varName+"["+N.p+"]}"}}),Ot=new $({e:function(N){var F=String(N);return/[&<>"']/.test(F)?F.replace(/[&<>"']/g,nt):F}}),Vt={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(N,F){if(N==="H"){var j=this.storage.helpers.get(F);if(j)return j;throw i("Can't find helper '"+F+"'")}if(N==="F"){var at=this.storage.filters.get(F);if(at)return at;throw i("Can't find filter '"+F+"'")}},async:!1,storage:{helpers:St,nativeHelpers:mt,filters:Ot,templates:J},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function V(N,F){var j={};return f(j,Vt),F&&f(j,F),N&&f(j,N),j.l.bind(j),j}function q(N,F){var j=V(F||{}),at=Function;if(j.async){if(!l)throw i("This environment doesn't support async/await");at=l}try{return new at(j.varName,"c","cb",C(N,j))}catch(ht){throw ht instanceof SyntaxError?i(`Bad template syntax
84
+
85
+ `+ht.message+`
86
+ `+Array(ht.message.length+1).join("=")+`
87
+ `+C(N,j)):ht}}function At(N,F){var j;return F.cache&&F.name&&F.storage.templates.get(F.name)?F.storage.templates.get(F.name):(j=typeof N=="function"?N:q(N,F),F.cache&&F.name&&F.storage.templates.define(F.name,j),j)}Vt.l.bind(Vt),e.compile=q,e.compileScope=G,e.compileScopeIntoFunction=x,e.compileToString=C,e.defaultConfig=Vt,e.filters=Ot,e.getConfig=V,e.helpers=St,e.nativeHelpers=mt,e.parse=w,e.render=function(N,F,j,at){var ht=V(j||{});if(!ht.async)return At(N,ht)(F,ht);if(!at){if(typeof o=="function")return new o(function(_t,$t){try{_t(At(N,ht)(F,ht))}catch(jt){$t(jt)}});throw i("Please provide a callback function, this env doesn't support Promises")}try{At(N,ht)(F,ht,at)}catch(_t){return at(_t)}},e.templates=J,Object.defineProperty(e,"__esModule",{value:!0})})})(Gl,Gl.exports);var lo=Gl.exports,Vl={exports:{}};(function(s,t){var e=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof oo<"u"&&oo,i=function(){function o(){this.fetch=!1,this.DOMException=e.DOMException}return o.prototype=e,new o}();(function(o){(function(l){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(V){return V&&DataView.prototype.isPrototypeOf(V)}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(V){return V&&g.indexOf(Object.prototype.toString.call(V))>-1};function A(V){if(typeof V!="string"&&(V=String(V)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(V)||V==="")throw new TypeError('Invalid character in header field name: "'+V+'"');return V.toLowerCase()}function E(V){return typeof V!="string"&&(V=String(V)),V}function T(V){var q={next:function(){var At=V.shift();return{done:At===void 0,value:At}}};return f.iterable&&(q[Symbol.iterator]=function(){return q}),q}function w(V){this.map={},V instanceof w?V.forEach(function(q,At){this.append(At,q)},this):Array.isArray(V)?V.forEach(function(q){this.append(q[0],q[1])},this):V&&Object.getOwnPropertyNames(V).forEach(function(q){this.append(q,V[q])},this)}w.prototype.append=function(V,q){V=A(V),q=E(q);var At=this.map[V];this.map[V]=At?At+", "+q:q},w.prototype.delete=function(V){delete this.map[A(V)]},w.prototype.get=function(V){return V=A(V),this.has(V)?this.map[V]:null},w.prototype.has=function(V){return this.map.hasOwnProperty(A(V))},w.prototype.set=function(V,q){this.map[A(V)]=E(q)},w.prototype.forEach=function(V,q){for(var At in this.map)this.map.hasOwnProperty(At)&&V.call(q,this.map[At],At,this)},w.prototype.keys=function(){var V=[];return this.forEach(function(q,At){V.push(At)}),T(V)},w.prototype.values=function(){var V=[];return this.forEach(function(q){V.push(q)}),T(V)},w.prototype.entries=function(){var V=[];return this.forEach(function(q,At){V.push([At,q])}),T(V)},f.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function C(V){if(V.bodyUsed)return Promise.reject(new TypeError("Already read"));V.bodyUsed=!0}function D(V){return new Promise(function(q,At){V.onload=function(){q(V.result)},V.onerror=function(){At(V.error)}})}function M(V){var q=new FileReader,At=D(q);return q.readAsArrayBuffer(V),At}function U(V){var q=new FileReader,At=D(q);return q.readAsText(V),At}function x(V){for(var q=new Uint8Array(V),At=new Array(q.length),N=0;N<q.length;N++)At[N]=String.fromCharCode(q[N]);return At.join("")}function G(V){if(V.slice)return V.slice(0);var q=new Uint8Array(V.byteLength);return q.set(new Uint8Array(V)),q.buffer}function $(){return this.bodyUsed=!1,this._initBody=function(V){this.bodyUsed=this.bodyUsed,this._bodyInit=V,V?typeof V=="string"?this._bodyText=V:f.blob&&Blob.prototype.isPrototypeOf(V)?this._bodyBlob=V:f.formData&&FormData.prototype.isPrototypeOf(V)?this._bodyFormData=V:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(V)?this._bodyText=V.toString():f.arrayBuffer&&f.blob&&p(V)?(this._bodyArrayBuffer=G(V.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(V)||v(V))?this._bodyArrayBuffer=G(V):this._bodyText=V=Object.prototype.toString.call(V):this._bodyText="",this.headers.get("content-type")||(typeof V=="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(V)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var V=C(this);if(V)return V;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 V=C(this);return V||(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 V=C(this);if(V)return V;if(this._bodyBlob)return U(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(J)}),this.json=function(){return this.text().then(JSON.parse)},this}var Y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function tt(V){var q=V.toUpperCase();return Y.indexOf(q)>-1?q:V}function nt(V,q){if(!(this instanceof nt))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');q=q||{};var At=q.body;if(V instanceof nt){if(V.bodyUsed)throw new TypeError("Already read");this.url=V.url,this.credentials=V.credentials,q.headers||(this.headers=new w(V.headers)),this.method=V.method,this.mode=V.mode,this.signal=V.signal,!At&&V._bodyInit!=null&&(At=V._bodyInit,V.bodyUsed=!0)}else this.url=String(V);if(this.credentials=q.credentials||this.credentials||"same-origin",(q.headers||!this.headers)&&(this.headers=new w(q.headers)),this.method=tt(q.method||this.method||"GET"),this.mode=q.mode||this.mode||null,this.signal=q.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&At)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(At),(this.method==="GET"||this.method==="HEAD")&&(q.cache==="no-store"||q.cache==="no-cache")){var N=/([?&])_=[^&]*/;if(N.test(this.url))this.url=this.url.replace(N,"$1_="+new Date().getTime());else{var F=/\?/;this.url+=(F.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}nt.prototype.clone=function(){return new nt(this,{body:this._bodyInit})};function J(V){var q=new FormData;return V.trim().split("&").forEach(function(At){if(At){var N=At.split("="),F=N.shift().replace(/\+/g," "),j=N.join("=").replace(/\+/g," ");q.append(decodeURIComponent(F),decodeURIComponent(j))}}),q}function St(V){var q=new w,At=V.replace(/\r?\n[\t ]+/g," ");return At.split("\r").map(function(N){return N.indexOf(`
88
+ `)===0?N.substr(1,N.length):N}).forEach(function(N){var F=N.split(":"),j=F.shift().trim();if(j){var at=F.join(":").trim();q.append(j,at)}}),q}$.call(nt.prototype);function mt(V,q){if(!(this instanceof mt))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');q||(q={}),this.type="default",this.status=q.status===void 0?200:q.status,this.ok=this.status>=200&&this.status<300,this.statusText=q.statusText===void 0?"":""+q.statusText,this.headers=new w(q.headers),this.url=q.url||"",this._initBody(V)}$.call(mt.prototype),mt.prototype.clone=function(){return new mt(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new w(this.headers),url:this.url})},mt.error=function(){var V=new mt(null,{status:0,statusText:""});return V.type="error",V};var Ot=[301,302,303,307,308];mt.redirect=function(V,q){if(Ot.indexOf(q)===-1)throw new RangeError("Invalid status code");return new mt(null,{status:q,headers:{location:V}})},l.DOMException=d.DOMException;try{new l.DOMException}catch{l.DOMException=function(q,At){this.message=q,this.name=At;var N=Error(q);this.stack=N.stack},l.DOMException.prototype=Object.create(Error.prototype),l.DOMException.prototype.constructor=l.DOMException}function Vt(V,q){return new Promise(function(At,N){var F=new nt(V,q);if(F.signal&&F.signal.aborted)return N(new l.DOMException("Aborted","AbortError"));var j=new XMLHttpRequest;function at(){j.abort()}j.onload=function(){var _t={status:j.status,statusText:j.statusText,headers:St(j.getAllResponseHeaders()||"")};_t.url="responseURL"in j?j.responseURL:_t.headers.get("X-Request-URL");var $t="response"in j?j.response:j.responseText;setTimeout(function(){At(new mt($t,_t))},0)},j.onerror=function(){setTimeout(function(){N(new TypeError("Network request failed"))},0)},j.ontimeout=function(){setTimeout(function(){N(new TypeError("Network request failed"))},0)},j.onabort=function(){setTimeout(function(){N(new l.DOMException("Aborted","AbortError"))},0)};function ht(_t){try{return _t===""&&d.location.href?d.location.href:_t}catch{return _t}}j.open(F.method,ht(F.url),!0),F.credentials==="include"?j.withCredentials=!0:F.credentials==="omit"&&(j.withCredentials=!1),"responseType"in j&&(f.blob?j.responseType="blob":f.arrayBuffer&&F.headers.get("Content-Type")&&F.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(j.responseType="arraybuffer")),q&&typeof q.headers=="object"&&!(q.headers instanceof w)?Object.getOwnPropertyNames(q.headers).forEach(function(_t){j.setRequestHeader(_t,E(q.headers[_t]))}):F.headers.forEach(function(_t,$t){j.setRequestHeader($t,_t)}),F.signal&&(F.signal.addEventListener("abort",at),j.onreadystatechange=function(){j.readyState===4&&F.signal.removeEventListener("abort",at)}),j.send(typeof F._bodyInit>"u"?null:F._bodyInit)})}return Vt.polyfill=!0,d.fetch||(d.fetch=Vt,d.Headers=w,d.Request=nt,d.Response=mt),l.Headers=w,l.Request=nt,l.Response=mt,l.fetch=Vt,l})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var n=e.fetch?e:i;t=n.fetch,t.default=n.fetch,t.fetch=n.fetch,t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response,s.exports=t})(Vl,Vl.exports);var im=Vl.exports;const rm=Bl(im);function Hl({canvas:s,scenes:t,currentTime:e}){if(t&&s){const i=t.scenes.filter(({start:o,duration:l})=>e>=o&&e<=o+l);if(i.length<=0)return;const n=s.getContext("2d");if(n){const o=t.transitionDuration,l=Math.max(...t.scenes.map(({start:d,duration:f})=>d+f));n.globalCompositeOperation="lighter",n.clearRect(0,0,s.width,s.height),i.forEach(({start:d,duration:f,draw:p,transitionCanvas:g})=>{if(n.globalAlpha=1,g.width=g.height=0,g.width=s.width,g.height=s.height,g.getContext("2d")){const v=d+f,A=d===0,E=v===l;p({currentTime:e,canvas:g}),!A&&e>=d&&e<=d+o?n.globalAlpha=Math.max(0,Math.min(1,(e-d)/o)):!E&&e>=v-o&&e<=v&&(n.globalAlpha=Math.max(0,Math.min(1,(v-e)/o))),n.drawImage(g,0,0,s.width,s.height)}})}}}function sm(s){if(typeof s=="string"){const[t,e]=s.split(":");return Math.min(parseFloat(t),parseFloat(e))}return s}function nm(s){if(typeof s=="string"){const[t,e]=s.split(":"),i=parseFloat(t),n=parseFloat(e);return i/n}return s}function Wl({resolution:s,aspectRatio:t}){const e=sm(s),i=nm(t),n=i>=1,o=Math.min(n?e*i:e/i,e),l=Math.max(n?e*i:e/i,e);return{resolution:e,aspectRatio:i,height:n?o:l,width:n?l:o}}function am({format:s,resolution:t,aspectRatio:e,sourceWidth:i,sourceHeight:n}){const{width:o,height:l}=Wl({resolution:t,aspectRatio:e}),d=i/n,f=e>d;let p=1;if(s==="letterbox"||s==="letterbox-video")p=f?l/n:o/i;else if(s==="squarebox"){const T=Math.min(l,o);p=i>=n?T/n:T/i}else s==="crop"&&(p=f?o/i:l/n);const g=o/p,v=l/p,A=(i-g)/2,E=(n-v)/2;return{sx:A,sy:E,sWidth:g,sHeight:v,scale:p}}function ua({source:s,sx:t,sy:e,sw:i,sh:n,dx:o,dy:l,dw:d,dh:f}){const p=(s==null?void 0:s.naturalWidth)??(s==null?void 0:s.videoWidth)??(s==null?void 0:s.width),g=(s==null?void 0:s.naturalHeight)??(s==null?void 0:s.videoHeight)??(s==null?void 0:s.height);t=t??0,e=e??0,i=i??p,n=n??g,i<0&&(t+=i,i=Math.abs(i)),n<0&&(e+=n,n=Math.abs(n)),d<0&&(o+=d,d=Math.abs(d)),f<0&&(l+=f,f=Math.abs(f));const v=Math.max(t,0),A=Math.min(t+i,p),E=Math.max(e,0),T=Math.min(e+n,g),w=d/i,C=f/n;return[s,v,E,A-v,T-E,t<0?o-t*w:o,e<0?l-e*C:l,(A-v)*w,(T-E)*C]}function zd({context:s,source:t,crop:e,format:i="letterbox",posX:n,posY:o,drawAreaWidth:l,drawAreaHeight:d,sourceWidth:f,sourceHeight:p,cropCanvas:g,letterboxCanvas:v}){const{x:A,y:E,width:T,height:w}=e??{},C=f*(A??0),D=p*(E??0),M=f*Math.min(1-(A??0),T??1),U=p*Math.min(1-(E??0),w??1),x=g.getContext("2d");if(x){g.width=M,g.height=U;const q=ua({source:t,sx:C,sy:D,sw:M,sh:U,dx:0,dy:0,dw:M,dh:U});x.drawImage(...q)}const G=M/U,{sx:$,sy:Y,sWidth:tt,sHeight:nt,scale:J}=am({resolution:Math.min(l,d),aspectRatio:l/d,format:i,sourceWidth:M,sourceHeight:U}),St=g&&typeof s.filter<"u";if(i==="letterbox"||i==="squarebox"||i==="letterbox-video"&&!St){if($<0){const q=Math.abs($)*J;s.fillStyle="black",s.beginPath(),s.rect(n,o,q,d),s.rect(n+l-q,o,q,d),s.fill(),s.closePath()}if(Y<0){const q=Math.abs(Y)*J;s.fillStyle="black",s.beginPath(),s.rect(n,o,l,q),s.rect(n,o+d-q,l,q),s.fill(),s.closePath()}}if(i==="letterbox-video"&&St){const q=v.getContext("2d");if(q){v.width=M,v.height=U,s.save(),s.globalCompositeOperation="destination-out",s.fillRect(n,o,l,d);const At=ua({source:g,sx:$,sy:Y,sw:tt,sh:nt,dx:n,dy:o,dw:l,dh:d});s.globalCompositeOperation="source-over",s.drawImage(...At),q.save();const N=1.2,F=-(M*N-M)/2,j=-(U*N-U)/2,at=Math.min(M/20,U/20);if(q.filter=`blur(${at}px) brightness(20%)`,q.translate(F,j),q.scale(N,N),q.drawImage(g,0,0,M,U),q.restore(),s.globalCompositeOperation="destination-over",$<0){const ht=l/G,_t=d/ht,$t=ua({source:v,sy:(1-_t)*U/2,sh:_t*U,dx:n,dy:o,dw:l,dh:d});s.drawImage(...$t)}if(Y<0){const ht=d*G,_t=l/ht,$t=ua({source:v,sx:(1-_t)*M/2,sw:_t*M,dx:n,dy:o,dw:l,dh:d});s.drawImage(...$t)}s.restore()}}else{const q=ua({source:g,sx:$,sy:Y,sw:tt,sh:nt,dx:n,dy:o,dw:l,dh:d});s.drawImage(...q)}const mt=$*-1*J,Ot=Y*-1*J,Vt=l-mt*2,V=d-Ot*2;return{dx:mt,dy:Ot,dw:Vt,dh:V}}const om=(s,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const n=Object.getOwnPropertyDescriptor(s,e),o=Object.getOwnPropertyDescriptor(t,e);!lm(n,o)&&i||Object.defineProperty(s,e,o)},lm=function(s,t){return s===void 0||s.configurable||s.writable===t.writable&&s.enumerable===t.enumerable&&s.configurable===t.configurable&&(s.writable||s.value===t.value)},cm=(s,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(s)&&Object.setPrototypeOf(s,e)},hm=(s,t)=>`/* Wrapped ${s}*/
89
+ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),fm=(s,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,n=hm.bind(null,i,t.toString());Object.defineProperty(n,"name",um),Object.defineProperty(s,"toString",{...dm,value:n})};function pm(s,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=s;for(const n of Reflect.ownKeys(t))om(s,t,n,e);return cm(s,t),fm(s,t,i),s}const gm=new WeakMap,Xd=new WeakMap;function Zd(s,{cacheKey:t,cache:e=new Map,maxAge:i}={}){if(i===0)return s;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 n=function(...o){var l;const d=t?t(o):o[0],f=e.get(d);if(f)return f.data;const p=s.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);(l=g.unref)==null||l.call(g);const v=Xd.get(s)??new Set;v.add(g),Xd.set(s,v)}return p};return pm(n,s,{ignoreNonConfigurable:!0}),gm.set(n,e),n}function qd({context:s,word:t,maxW:e=1/0}){const i=[],n=s.measureText(t);if(n.width<e)return[{text:t,metrics:n}];for(let o=0;o<t.length;o++){const l=i[i.length-1],d=((l==null?void 0:l.text)??"")+t[o],f=s.measureText(d);f.width<e?i[l?i.length-1:0]={text:d,metrics:f}:i.push({text:t[o],metrics:s.measureText(t[o])})}return i}const Qd=Zd(({font:s,scale:t,context:e,maxW:i,maxH:n,text:o,minSize:l,maxSize:d})=>{var f,p;let g=0;if(d){g=(l??0)*t;let v=0;for(;d*t>g+1;){g+=1;const A=Ao({context:e,font:s,fontSize:g,text:o,maxW:i});if(v=A.reduce((E,T)=>(T.metrics.width>E&&(E=T.metrics.width),E),0),v>i||A.length*g>n){g-=1;break}}}else g=parseFloat(((p=(f=s.match(bo))==null?void 0:f.groups)==null?void 0:p.value)??"0")*t;return g},{cacheKey:([{font:s,text:t,minSize:e,maxSize:i,scale:n,maxW:o,maxH:l}])=>`${s}_${t}_${e}_${i}_${n}_${o}_${l}`});function mm(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Te={},jl={},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 is=function(s){return s[s.Auto=0]="Auto",s[s.FlexStart=1]="FlexStart",s[s.Center=2]="Center",s[s.FlexEnd=3]="FlexEnd",s[s.Stretch=4]="Stretch",s[s.Baseline=5]="Baseline",s[s.SpaceBetween=6]="SpaceBetween",s[s.SpaceAround=7]="SpaceAround",s}({});re.Align=is;let Kl=function(s){return s[s.Width=0]="Width",s[s.Height=1]="Height",s}({});re.Dimension=Kl;let co=function(s){return s[s.Inherit=0]="Inherit",s[s.LTR=1]="LTR",s[s.RTL=2]="RTL",s}({});re.Direction=co;let Yl=function(s){return s[s.Flex=0]="Flex",s[s.None=1]="None",s}({});re.Display=Yl;let Or=function(s){return s[s.Left=0]="Left",s[s.Top=1]="Top",s[s.Right=2]="Right",s[s.Bottom=3]="Bottom",s[s.Start=4]="Start",s[s.End=5]="End",s[s.Horizontal=6]="Horizontal",s[s.Vertical=7]="Vertical",s[s.All=8]="All",s}({});re.Edge=Or;let fa=function(s){return s[s.None=0]="None",s[s.StretchFlexBasis=1]="StretchFlexBasis",s[s.All=2147483647]="All",s[s.Classic=2147483646]="Classic",s}({});re.Errata=fa;let ho=function(s){return s[s.WebFlexBasis=0]="WebFlexBasis",s[s.AbsolutePercentageAgainstPaddingEdge=1]="AbsolutePercentageAgainstPaddingEdge",s[s.FixJNILocalRefOverflows=2]="FixJNILocalRefOverflows",s}({});re.ExperimentalFeature=ho;let pa=function(s){return s[s.Column=0]="Column",s[s.ColumnReverse=1]="ColumnReverse",s[s.Row=2]="Row",s[s.RowReverse=3]="RowReverse",s}({});re.FlexDirection=pa;let uo=function(s){return s[s.Column=0]="Column",s[s.Row=1]="Row",s[s.All=2]="All",s}({});re.Gutter=uo;let rn=function(s){return s[s.FlexStart=0]="FlexStart",s[s.Center=1]="Center",s[s.FlexEnd=2]="FlexEnd",s[s.SpaceBetween=3]="SpaceBetween",s[s.SpaceAround=4]="SpaceAround",s[s.SpaceEvenly=5]="SpaceEvenly",s}({});re.Justify=rn;let sn=function(s){return s[s.Error=0]="Error",s[s.Warn=1]="Warn",s[s.Info=2]="Info",s[s.Debug=3]="Debug",s[s.Verbose=4]="Verbose",s[s.Fatal=5]="Fatal",s}({});re.LogLevel=sn;let fo=function(s){return s[s.Undefined=0]="Undefined",s[s.Exactly=1]="Exactly",s[s.AtMost=2]="AtMost",s}({});re.MeasureMode=fo;let zl=function(s){return s[s.Default=0]="Default",s[s.Text=1]="Text",s}({});re.NodeType=zl;let po=function(s){return s[s.Visible=0]="Visible",s[s.Hidden=1]="Hidden",s[s.Scroll=2]="Scroll",s}({});re.Overflow=po;let go=function(s){return s[s.Static=0]="Static",s[s.Relative=1]="Relative",s[s.Absolute=2]="Absolute",s}({});re.PositionType=go;let mo=function(s){return s[s.Layout=1]="Layout",s[s.Style=2]="Style",s[s.Children=4]="Children",s}({});re.PrintOptions=mo;let ga=function(s){return s[s.Undefined=0]="Undefined",s[s.Point=1]="Point",s[s.Percent=2]="Percent",s[s.Auto=3]="Auto",s}({});re.Unit=ga;let vo=function(s){return s[s.NoWrap=0]="NoWrap",s[s.Wrap=1]="Wrap",s[s.WrapReverse=2]="WrapReverse",s}({});re.Wrap=vo;var vm={ALIGN_AUTO:is.Auto,ALIGN_FLEX_START:is.FlexStart,ALIGN_CENTER:is.Center,ALIGN_FLEX_END:is.FlexEnd,ALIGN_STRETCH:is.Stretch,ALIGN_BASELINE:is.Baseline,ALIGN_SPACE_BETWEEN:is.SpaceBetween,ALIGN_SPACE_AROUND:is.SpaceAround,DIMENSION_WIDTH:Kl.Width,DIMENSION_HEIGHT:Kl.Height,DIRECTION_INHERIT:co.Inherit,DIRECTION_LTR:co.LTR,DIRECTION_RTL:co.RTL,DISPLAY_FLEX:Yl.Flex,DISPLAY_NONE:Yl.None,EDGE_LEFT:Or.Left,EDGE_TOP:Or.Top,EDGE_RIGHT:Or.Right,EDGE_BOTTOM:Or.Bottom,EDGE_START:Or.Start,EDGE_END:Or.End,EDGE_HORIZONTAL:Or.Horizontal,EDGE_VERTICAL:Or.Vertical,EDGE_ALL:Or.All,ERRATA_NONE:fa.None,ERRATA_STRETCH_FLEX_BASIS:fa.StretchFlexBasis,ERRATA_ALL:fa.All,ERRATA_CLASSIC:fa.Classic,EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS:ho.WebFlexBasis,EXPERIMENTAL_FEATURE_ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE:ho.AbsolutePercentageAgainstPaddingEdge,EXPERIMENTAL_FEATURE_FIX_JNILOCAL_REF_OVERFLOWS:ho.FixJNILocalRefOverflows,FLEX_DIRECTION_COLUMN:pa.Column,FLEX_DIRECTION_COLUMN_REVERSE:pa.ColumnReverse,FLEX_DIRECTION_ROW:pa.Row,FLEX_DIRECTION_ROW_REVERSE:pa.RowReverse,GUTTER_COLUMN:uo.Column,GUTTER_ROW:uo.Row,GUTTER_ALL:uo.All,JUSTIFY_FLEX_START:rn.FlexStart,JUSTIFY_CENTER:rn.Center,JUSTIFY_FLEX_END:rn.FlexEnd,JUSTIFY_SPACE_BETWEEN:rn.SpaceBetween,JUSTIFY_SPACE_AROUND:rn.SpaceAround,JUSTIFY_SPACE_EVENLY:rn.SpaceEvenly,LOG_LEVEL_ERROR:sn.Error,LOG_LEVEL_WARN:sn.Warn,LOG_LEVEL_INFO:sn.Info,LOG_LEVEL_DEBUG:sn.Debug,LOG_LEVEL_VERBOSE:sn.Verbose,LOG_LEVEL_FATAL:sn.Fatal,MEASURE_MODE_UNDEFINED:fo.Undefined,MEASURE_MODE_EXACTLY:fo.Exactly,MEASURE_MODE_AT_MOST:fo.AtMost,NODE_TYPE_DEFAULT:zl.Default,NODE_TYPE_TEXT:zl.Text,OVERFLOW_VISIBLE:po.Visible,OVERFLOW_HIDDEN:po.Hidden,OVERFLOW_SCROLL:po.Scroll,POSITION_TYPE_STATIC:go.Static,POSITION_TYPE_RELATIVE:go.Relative,POSITION_TYPE_ABSOLUTE:go.Absolute,PRINT_OPTIONS_LAYOUT:mo.Layout,PRINT_OPTIONS_STYLE:mo.Style,PRINT_OPTIONS_CHILDREN:mo.Children,UNIT_UNDEFINED:ga.Undefined,UNIT_POINT:ga.Point,UNIT_PERCENT:ga.Percent,UNIT_AUTO:ga.Auto,WRAP_NO_WRAP:vo.NoWrap,WRAP_WRAP:vo.Wrap,WRAP_WRAP_REVERSE:vo.WrapReverse};re.default=vm,Object.defineProperty(jl,"__esModule",{value:!0}),jl.default=bm;var ws=ym(re);function Jd(s){if(typeof WeakMap!="function")return null;var t=new WeakMap,e=new WeakMap;return(Jd=function(i){return i?e:t})(s)}function ym(s,t){if(!t&&s&&s.__esModule)return s;if(s===null||typeof s!="object"&&typeof s!="function")return{default:s};var e=Jd(t);if(e&&e.has(s))return e.get(s);var i={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in s)if(o!=="default"&&Object.prototype.hasOwnProperty.call(s,o)){var l=n?Object.getOwnPropertyDescriptor(s,o):null;l&&(l.get||l.set)?Object.defineProperty(i,o,l):i[o]=s[o]}return i.default=s,e&&e.set(s,i),i}function bm(s){function t(n,o,l){const d=n[o];n[o]=function(){for(var f=arguments.length,p=new Array(f),g=0;g<f;g++)p[g]=arguments[g];return l.call(this,d,...p)}}for(const n of["setPosition","setMargin","setFlexBasis","setWidth","setHeight","setMinWidth","setMinHeight","setMaxWidth","setMaxHeight","setPadding"]){const o={[ws.Unit.Point]:s.Node.prototype[n],[ws.Unit.Percent]:s.Node.prototype[`${n}Percent`],[ws.Unit.Auto]:s.Node.prototype[`${n}Auto`]};t(s.Node.prototype,n,function(l){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,A;if(g==="auto")v=ws.Unit.Auto,A=void 0;else if(typeof g=="object")v=g.unit,A=g.valueOf();else if(v=typeof g=="string"&&g.endsWith("%")?ws.Unit.Percent:ws.Unit.Point,A=parseFloat(g),!Number.isNaN(g)&&Number.isNaN(A))throw new Error(`Invalid value ${g} for ${n}`);if(!o[v])throw new Error(`Failed to execute "${n}": Unsupported unit '${g}'`);return A!==void 0?o[v].call(this,...f,A):o[v].call(this,...f)})}function e(n){return s.MeasureCallback.implement({measure:function(){const{width:o,height:l}=n(...arguments);return{width:o??NaN,height:l??NaN}}})}t(s.Node.prototype,"setMeasureFunc",function(n,o){return o?n.call(this,e(o)):this.unsetMeasureFunc()});function i(n){return s.DirtiedCallback.implement({dirtied:n})}return t(s.Node.prototype,"setDirtiedFunc",function(n,o){n.call(this,i(o))}),t(s.Config.prototype,"free",function(){s.Config.destroy(this)}),t(s.Node,"create",(n,o)=>o?s.Node.createWithConfig(o):s.Node.createDefault()),t(s.Node.prototype,"free",function(){s.Node.destroy(this)}),t(s.Node.prototype,"freeRecursive",function(){for(let n=0,o=this.getChildCount();n<o;++n)this.getChild(0).freeRecursive();this.free()}),t(s.Node.prototype,"calculateLayout",function(n){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:NaN,l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:NaN,d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:ws.Direction.LTR;return n.call(this,o,l,d)}),{Config:s.Config,Node:s.Node,...ws.default}}var tu={exports:{}};(function(s,t){var e=(()=>{var i=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(n){n=n||{};var o;o||(o=typeof n<"u"?n:{});var l,d;o.ready=new Promise(function(L,_){l=L,d=_});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 A;o.wasmBinary&&(A=o.wasmBinary),o.noExitRuntime;function E(){this.buffer=new ArrayBuffer(V/65536*65536)}function T(){}function w(L){this.exports=function(_){function B(ai){return ai.set=function(ae,or){this[ae]=or},ai.get=function(ae){return this[ae]},ai}for(var H,rt=new Uint8Array(123),yt=25;yt>=0;--yt)rt[48+yt]=52+yt,rt[65+yt]=yt,rt[97+yt]=26+yt;rt[43]=62,rt[47]=63;function ct(ai,ae,or){for(var Bi,gt,Wr=0,c=ae,Tt=or.length,Bn=ae+(Tt*3>>2)-(or[Tt-2]=="=")-(or[Tt-1]=="=");Wr<Tt;Wr+=4)Bi=rt[or.charCodeAt(Wr+1)],gt=rt[or.charCodeAt(Wr+2)],ai[c++]=rt[or.charCodeAt(Wr)]<<2|Bi>>4,c<Bn&&(ai[c++]=Bi<<4|gt>>2),c<Bn&&(ai[c++]=gt<<6|rt[or.charCodeAt(Wr+3)])}function Lt(ai){ct(H,1024,"T25seSBsZWFmIG5vZGVzIHdpdGggY3VzdG9tIG1lYXN1cmUgZnVuY3Rpb25zIHNob3VsZCBtYW51YWxseSBtYXJrIHRoZW1zZWx2ZXMgYXMgZGlydHkAaXNEaXJ0eQBtYXJrRGlydHkAZGVzdHJveQBzZXREaXNwbGF5AGdldERpc3BsYXkAc2V0RmxleAAtKyAgIDBYMHgALTBYKzBYIDBYLTB4KzB4IDB4AHNldEZsZXhHcm93AGdldEZsZXhHcm93AHNldE92ZXJmbG93AGdldE92ZXJmbG93AGNhbGN1bGF0ZUxheW91dABnZXRDb21wdXRlZExheW91dAB1bnNpZ25lZCBzaG9ydABnZXRDaGlsZENvdW50AHVuc2lnbmVkIGludABzZXRKdXN0aWZ5Q29udGVudABnZXRKdXN0aWZ5Q29udGVudABzZXRBbGlnbkNvbnRlbnQAZ2V0QWxpZ25Db250ZW50AGdldFBhcmVudABpbXBsZW1lbnQAc2V0TWF4SGVpZ2h0UGVyY2VudABzZXRIZWlnaHRQZXJjZW50AHNldE1pbkhlaWdodFBlcmNlbnQAc2V0RmxleEJhc2lzUGVyY2VudABzZXRQb3NpdGlvblBlcmNlbnQAc2V0TWFyZ2luUGVyY2VudABzZXRNYXhXaWR0aFBlcmNlbnQAc2V0V2lkdGhQZXJjZW50AHNldE1pbldpZHRoUGVyY2VudABzZXRQYWRkaW5nUGVyY2VudABjcmVhdGVEZWZhdWx0AHVuaXQAcmlnaHQAaGVpZ2h0AHNldE1heEhlaWdodABnZXRNYXhIZWlnaHQAc2V0SGVpZ2h0AGdldEhlaWdodABzZXRNaW5IZWlnaHQAZ2V0TWluSGVpZ2h0AGdldENvbXB1dGVkSGVpZ2h0AGdldENvbXB1dGVkUmlnaHQAbGVmdABnZXRDb21wdXRlZExlZnQAcmVzZXQAX19kZXN0cnVjdABmbG9hdAB1aW50NjRfdAB1c2VXZWJEZWZhdWx0cwBzZXRVc2VXZWJEZWZhdWx0cwBzZXRBbGlnbkl0ZW1zAGdldEFsaWduSXRlbXMAc2V0RmxleEJhc2lzAGdldEZsZXhCYXNpcwBDYW5ub3QgZ2V0IGxheW91dCBwcm9wZXJ0aWVzIG9mIG11bHRpLWVkZ2Ugc2hvcnRoYW5kcwB1c2VMZWdhY3lTdHJldGNoQmVoYXZpb3VyAHNldFVzZUxlZ2FjeVN0cmV0Y2hCZWhhdmlvdXIAc2V0UG9pbnRTY2FsZUZhY3RvcgBNZWFzdXJlQ2FsbGJhY2tXcmFwcGVyAERpcnRpZWRDYWxsYmFja1dyYXBwZXIAQ2Fubm90IHJlc2V0IGEgbm9kZSBzdGlsbCBhdHRhY2hlZCB0byBhIG93bmVyAHNldEJvcmRlcgBnZXRCb3JkZXIAZ2V0Q29tcHV0ZWRCb3JkZXIAdW5zaWduZWQgY2hhcgB0b3AAZ2V0Q29tcHV0ZWRUb3AAc2V0RmxleFdyYXAAZ2V0RmxleFdyYXAAc2V0R2FwAGdldEdhcAAlcABzZXRIZWlnaHRBdXRvAHNldEZsZXhCYXNpc0F1dG8Ac2V0TWFyZ2luQXV0bwBzZXRXaWR0aEF1dG8AU2NhbGUgZmFjdG9yIHNob3VsZCBub3QgYmUgbGVzcyB0aGFuIHplcm8Ac2V0QXNwZWN0UmF0aW8AZ2V0QXNwZWN0UmF0aW8Ac2V0UG9zaXRpb24AZ2V0UG9zaXRpb24Abm90aWZ5T25EZXN0cnVjdGlvbgBzZXRGbGV4RGlyZWN0aW9uAGdldEZsZXhEaXJlY3Rpb24Ac2V0TWFyZ2luAGdldE1hcmdpbgBnZXRDb21wdXRlZE1hcmdpbgBuYW4AYm90dG9tAGdldENvbXB1dGVkQm90dG9tAGJvb2wAZW1zY3JpcHRlbjo6dmFsAHNldEZsZXhTaHJpbmsAZ2V0RmxleFNocmluawBNZWFzdXJlQ2FsbGJhY2sARGlydGllZENhbGxiYWNrAHdpZHRoAHNldE1heFdpZHRoAGdldE1heFdpZHRoAHNldFdpZHRoAGdldFdpZHRoAHNldE1pbldpZHRoAGdldE1pbldpZHRoAGdldENvbXB1dGVkV2lkdGgAdW5zaWduZWQgbG9uZwBzdGQ6OndzdHJpbmcAc3RkOjpzdHJpbmcAc3RkOjp1MTZzdHJpbmcAc3RkOjp1MzJzdHJpbmcAc2V0UGFkZGluZwBnZXRQYWRkaW5nAGdldENvbXB1dGVkUGFkZGluZwBBdHRlbXB0aW5nIHRvIGNvbnN0cnVjdCBZR05vZGUgd2l0aCBudWxsIGNvbmZpZwBUcmllZCB0byBjb25zdHJ1Y3QgWUdOb2RlIHdpdGggbnVsbCBjb25maWcAY3JlYXRlV2l0aENvbmZpZwBpbmYAc2V0QWxpZ25TZWxmAGdldEFsaWduU2VsZgBTaXplAHZhbHVlAFZhbHVlAGNyZWF0ZQBtZWFzdXJlAHNldFBvc2l0aW9uVHlwZQBnZXRQb3NpdGlvblR5cGUAaXNSZWZlcmVuY2VCYXNlbGluZQBzZXRJc1JlZmVyZW5jZUJhc2VsaW5lAGNvcHlTdHlsZQBkb3VibGUATm9kZQBleHRlbmQAaW5zZXJ0Q2hpbGQAZ2V0Q2hpbGQAcmVtb3ZlQ2hpbGQAdm9pZABhdmFpbGFibGVIZWlnaHQgaXMgaW5kZWZpbml0ZSBzbyBoZWlnaHRNZWFzdXJlTW9kZSBtdXN0IGJlIFlHTWVhc3VyZU1vZGVVbmRlZmluZWQAYXZhaWxhYmxlV2lkdGggaXMgaW5kZWZpbml0ZSBzbyB3aWR0aE1lYXN1cmVNb2RlIG11c3QgYmUgWUdNZWFzdXJlTW9kZVVuZGVmaW5lZABzZXRFeHBlcmltZW50YWxGZWF0dXJlRW5hYmxlZABpc0V4cGVyaW1lbnRhbEZlYXR1cmVFbmFibGVkAGRpcnRpZWQAQ2Fubm90IHJlc2V0IGEgbm9kZSB3aGljaCBzdGlsbCBoYXMgY2hpbGRyZW4gYXR0YWNoZWQAdW5zZXRNZWFzdXJlRnVuYwB1bnNldERpcnRpZWRGdW5jAHNldEVycmF0YQBnZXRFcnJhdGEARXhwZWN0IGN1c3RvbSBiYXNlbGluZSBmdW5jdGlvbiB0byBub3QgcmV0dXJuIE5hTgBOQU4ASU5GAGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHNob3J0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBzaG9ydD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBpbnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGZsb2F0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQ4X3Q+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8Y2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgY2hhcj4Ac3RkOjpiYXNpY19zdHJpbmc8dW5zaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8c2lnbmVkIGNoYXI+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGRvdWJsZT4AQ2hpbGQgYWxyZWFkeSBoYXMgYSBvd25lciwgaXQgbXVzdCBiZSByZW1vdmVkIGZpcnN0LgBDYW5ub3Qgc2V0IG1lYXN1cmUgZnVuY3Rpb246IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAENhbm5vdCBhZGQgY2hpbGQ6IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAChudWxsKQAlcwoAAQAAAAMAAAAAAAAAAgAAAAMAAAABAAAAAgAAAAAAAAABAAAAAQ=="),ct(H,4338,"wH8DAAAAAADAfwAAAABpaQB2AHZp"),ct(H,4368,"exsAAHkbAAC5GwAAsxsAALkbAACzGwAAaWlpZmlmaQCsGwAAfBsAAHZpaQB9GwAAwBsAAGlpaQ=="),ct(H,4432,"xwAAAMgAAADJ"),ct(H,4452,"xwAAAMoAAADLAAAArBs="),ct(H,4480,"exsAALkbAACzGwAAuRsAALMbAADAGwAAuxsAAMAbAABpaWlpAAAAAKwbAACRGwAArBsAAJMbAACUGwAAwBs="),ct(H,4552,"zAAAAM0AAADO"),ct(H,4572,"zAAAAM8AAADLAAAAlxsAAKwbAACXGw=="),ct(H,4608,"rBsAAJcbAACzGwAArRsAAHZpaWlpAAAArBsAAJcbAAC5GwAAdmlpZgAAAACsGwAAlxsAAK0bAAB2aWlpAAAAAKwbAACXGwAAsxsAAK0bAACYGwAAsxsAAK0bAACYGwAAsxsAAJgbAABpAGRpaQB2aWlkAACcGwAAnBsAAJcbAACsGwAAnBsAAKwbAACcGwAAmxsAAKwbAACcGwAAsxsAAKwbAACcGwAAsxsAALobAAB2aWlpZAAAAKwbAACcGwAAuhsAALMbAACdGwAAmhsAAJ0bAACzGwAAmhsAAJ0bAAC6GwAAnRsAALobAACdGwAAsxsAAGRpaWkAAAAAuRsAAJwbAACzGwAAZmlpaQAAAACsGwAAnBsAAJwbAAC0GwAArBsAAJwbAACcGwAAtBsAAJ0bAACcGwAAnBsAAJwbAACcGwAAtBsAAK0bAACcGwAArBsAAJwbAACtGwAArBsAAJwbAAB5GwAArBsAAJwbAACRGwAArRsAAJ0bAAAAAAAArBsAAJwbAAC6GwAAuhsAALMbAAB2aWlkZGkAAJkbAACdGw=="),ct(H,5040,"GQAKABkZGQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAAZABEKGRkZAwoHAAEACQsYAAAJBgsAAAsABhkAAAAZGRk="),ct(H,5121,"DgAAAAAAAAAAGQAKDRkZGQANAAACAAkOAAAACQAOAAAO"),ct(H,5179,"DA=="),ct(H,5191,"EwAAAAATAAAAAAkMAAAAAAAMAAAM"),ct(H,5237,"EA=="),ct(H,5249,"DwAAAAQPAAAAAAkQAAAAAAAQAAAQ"),ct(H,5295,"Eg=="),ct(H,5307,"EQAAAAARAAAAAAkSAAAAAAASAAASAAAaAAAAGhoa"),ct(H,5362,"GgAAABoaGgAAAAAAAAk="),ct(H,5411,"FA=="),ct(H,5423,"FwAAAAAXAAAAAAkUAAAAAAAUAAAU"),ct(H,5469,"Fg=="),ct(H,5481,"FQAAAAAVAAAAAAkWAAAAAAAWAAAWAAAwMTIzNDU2Nzg5QUJDREVG"),ct(H,5556,"1Q=="),ct(H,5596,"//////////8="),ct(H,5664,"8B8BAAAAAAAF"),ct(H,5684,"0A=="),ct(H,5708,"0QAAANIAAADUGw=="),ct(H,5732,"Ag=="),ct(H,5748,"//////////8="),ct(H,5816,"BQ=="),ct(H,5828,"0w=="),ct(H,5852,"0QAAANQAAADoGwAAAAQ="),ct(H,5876,"AQ=="),ct(H,5892,"/////wo="),ct(H,5960,"1g==")}var It=new ArrayBuffer(16),xt=new Int32Array(It),Nt=new Float32Array(It),Yt=new Float64Array(It);function te(ai){return xt[ai]}function Dt(ai,ae){xt[ai]=ae}function Ee(){return Yt[0]}function Ei(ai){Yt[0]=ai}function ce(){throw new Error("abort")}function Ji(ai){Nt[2]=ai}function Bt(){return Nt[2]}function ol(ai){var ae=ai.a,or=ae.a,Bi=or.buffer;or.grow=X3;var gt=new Int8Array(Bi),Wr=new Int16Array(Bi),c=new Int32Array(Bi),Tt=new Uint8Array(Bi),Bn=new Uint16Array(Bi),Ap=new Uint32Array(Bi),I=new Float32Array(Bi),He=new Float64Array(Bi),We=Math.imul,m=Math.fround,Xe=Math.abs,Er=Math.clz32,jE=Math.min,KE=Math.max,zt=NaN,Ep=1/0,Rt=ae.b,Ii=ae.c,us=ae.d,fs=ae.e,Fs=ae.f,Gn=ae.g,Ga=ae.h,ll=ae.i,Ih=ae.j,xh=ae.k,Dh=ae.l,Tp=ae.m,kp=ae.n,wp=ae.o,Sp=ae.p,Rp=ae.q,YE=ae.r,zE=ae.s,XE=ae.t,ZE=ae.u,qE=ae.v,QE=ae.w,JE=ae.x,tT=ae.y,eT=ae.z,iT=ae.A,rT=ae.B,sT=ae.C,nT=ae.D,kt=73712,Gi=0;function Lp(r,a,h,u,y,b,k,S,P,K,et,ft,Q,it){var O=0,W=m(0),z=0,Z=m(0),ot=0,lt=m(0),vt=0,bt=m(0),Ct=0,Mt=0,Ft=m(0),Ht=0,qt=0,se=m(0),ge=m(0),Ie=m(0),Oe=m(0),$e=0,je=m(0),qe=m(0),oi=0,li=0,wi=m(0),$i=0,er=0,Fi=0,Wi=0,ir=m(0),rr=0,xr=0,Dr=0,Xr=0,Zr=m(0),qr=0,Qr=0,ps=0,gs=0,ms=m(0),Gs=0,Vs=0,Hs=0,Ws=m(0),js=0,Ks=m(0),Wa=0,ja=m(0),Ka=m(0),Ya=m(0),za=0,ml=m(0),Yh=0,zh=m(0),Xh=m(0),Zh=m(0),qh=m(0),Qh=0,k2=0,w2=0,S2=0,R2=0,L2=0,_2=0,C2=0,Qe=0,Je=m(0),Yn=m(0);O=kt-384|0,kt=O;t:{r:{i:{if(!(y&&a!=a)){if(!(b&&h!=h)){if(z=(P?0:4)+et|0,c[z>>2]=c[z>>2]+1,z=c[r+24>>2]&3,Yh=(u|0)<=1?1:u,Wi=z||Yh,gt[r+300|0]=Tt[r+300|0]&252|Wi&3,z=r+252|0,u=((Wi|0)!=1)<<3,Gs=(Wi|0)==2?3:2,lt=he(r,Gs,k),I[z+u>>2]=lt,ot=z,z=((Wi|0)==1)<<3,ge=Se(r,Gs,k),I[ot+z>>2]=ge,bt=he(r,0,k),I[r+256>>2]=bt,Oe=Se(r,0,k),I[r+264>>2]=Oe,ot=r+268|0,Qe=ot+u|0,Je=pe(r,Gs),I[Qe>>2]=Je,Qe=z+ot|0,Je=Re(r,Gs),I[Qe>>2]=Je,W=pe(r,0),I[r+272>>2]=W,je=Re(r,0),I[r+280>>2]=je,ot=u,u=r+284|0,Qe=ot+u|0,Je=De(r,Gs,k),I[Qe>>2]=Je,Qe=u+z|0,Je=Pe(r,Gs,k),I[Qe>>2]=Je,Z=De(r,0,k),I[r+288>>2]=Z,Ft=Pe(r,0,k),I[r+296>>2]=Ft,lt=m(lt+ge),ge=m(bt+Oe),u=c[r+8>>2],u){bt=m(m(m(I[r+284>>2]+I[r+292>>2])+I[r+268>>2])+I[r+276>>2]),h=m(b?h-ge:zt),W=m(m(Z+Ft)+W),Z=m(y?a-lt:zt),a=Z;e:{if(a!=a)break e;if(a=m(Z-bt),a!=a){a=m(0);break e}a=oe(a,m(0))}lt=m(W+je),W=h;e:{if(h!=h)break e;if(W=m(h-lt),W!=W){W=m(0);break e}W=oe(W,m(0))}if(!((y|0)!=1|(b|0)!=1)){a=Ze(r,2,Z,k),u=a!=a,W=m(m(De(r,2,k)+pe(r,2))+m(Pe(r,2,k)+Re(r,2)));e:{if(!(u|W!=W)){a=oe(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=Ze(r,0,h,S),u=a!=a,h=m(m(De(r,0,k)+pe(r,0))+m(Pe(r,0,k)+Re(r,0)));e:{if(!(u|h!=h)){a=oe(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(Tt[r+4|0]&16){Pt[u|0](O+24|0,r,a,y,W,b,0);break e}Pt[u|0](O+24|0,r,a,y,W,b)}c[et+20>>2]=c[et+20>>2]+1,u=(it<<2)+et|0,c[u+24>>2]=c[u+24>>2]+1,a=m(bt+I[O+24>>2]),a=Ze(r,2,y?(y|0)==2?a:Z:a,k),u=a!=a,W=m(m(De(r,2,k)+pe(r,2))+m(Pe(r,2,k)+Re(r,2)));e:{if(!(u|W!=W)){a=oe(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=m(lt+I[O+28>>2]),a=Ze(r,0,b?(b|0)==2?a:h:a,S),u=a!=a,h=m(m(De(r,0,k)+pe(r,0))+m(Pe(r,0,k)+Re(r,0)));e:{if(!(u|h!=h)){a=oe(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}if(u=c[r+556>>2],it=c[r+560>>2],(u|0)==(it|0)){ge=m(h-ge),a=Ze(r,2,y&-3?m(a-lt):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(De(r,2,k)+pe(r,2))+m(Pe(r,2,k)+Re(r,2)));e:{if(!(u|h!=h)){a=oe(a,h);break e}a=u?h:a}I[r+516>>2]=a,a=Ze(r,0,b&-3?ge:m(m(m(Z+Ft)+W)+je),S),u=a!=a,h=m(m(De(r,0,k)+pe(r,0))+m(Pe(r,0,k)+Re(r,0)));e:{if(!(u|h!=h)){a=oe(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(P||(W=m(a-lt),Z=m(h-ge),!(!(!(W<=m(0))|(y|0)!=2)&W==W|!(!(Z<=m(0))|(b|0)!=2)&Z==Z)&((y|0)!=1|(b|0)!=1)))break e;a=Ze(r,2,W!=W||(y|0)==2&&W<m(0)?m(0):W,k),u=a!=a,h=m(m(De(r,2,k)+pe(r,2))+m(Pe(r,2,k)+Re(r,2)));s:{if(!(u|h!=h)){a=oe(a,h);break s}a=u?h:a}I[r+516>>2]=a,a=Ze(r,0,Z!=Z||(b|0)==2&&Z<m(0)?m(0):Z,S),u=a!=a,h=m(m(De(r,0,k)+pe(r,0))+m(Pe(r,0,k)+Re(r,0)));s:{if(!(u|h!=h)){a=oe(a,h);break s}a=u?h:a}I[r+520>>2]=a;break t}for(oi=it-u|0,Xr=oi>>2;z=c[u>>2],c[z+552>>2]!=(r|0)&&(ot=c[r+568>>2],z=Gp(c[ot>>2],Tt[ot+8|0],z,r,Ct,0),c[u>>2]=z,c[z+552>>2]=r),Ct=Ct+1|0,u=u+4|0,(it|0)!=(u|0););gt[r+300|0]=Tt[r+300|0]&251,Ct=3,$i=c[r+24>>2],u=$i>>>2&3;e:{s:{n:{if((Wi|0)==2){it=0;a:switch(u-2|0){case 0:break e;case 1:break a;default:break n}Ct=2;break e}if(Ct=2,it=0,u>>>0>1)break s}it=Ct}Ct=u}zh=m(a-lt),Zr=m(m(De(r,Ct,k)+pe(r,Ct))+m(Pe(r,Ct,k)+Re(r,Ct))),je=m(De(r,it,k)+pe(r,it)),ir=m(je+m(Pe(r,it,k)+Re(r,it))),rr=Ct>>>0>1,bt=Dp(r,0,zh,rr?Zr:ir,k),Xh=m(h-ge),qe=Dp(r,1,Xh,rr?ir:Zr,S),Oe=rr?qe:bt,ge=rr?bt:qe,qr=c[r+560>>2],z=c[r+556>>2],er=rr?y:b;e:{if((er|0)!=1)break e;if((z|0)==(qr|0))break i;for(u=z;;){ot=c[u>>2];s:{if(!qp(ot))break s;if(qt=0,vt)break e;n:{a:{if(!c[ot+552>>2]){W=m(0);break a}if(h=I[ot+32>>2],h!=h&&(W=m(0),h=I[ot+28>>2],!(h>m(0))))break a;if(W=h,h!=h)break n}if(m(Xe(W))<m(9999999747378752e-20))break e}if(a=jn(ot),a!=a){vt=ot;break s}if(vt=ot,m(Xe(a))<m(9999999747378752e-20))break e}if(qt=vt,u=u+4|0,(qr|0)==(u|0))break}}if((z|0)==(qr|0))break i;for(Wa=(Wi|0)<=1?1:Wi,Vs=bt!=bt,Qr=Vs|(y|0)!=1,ps=qe==qe,Hs=bt==bt,W=m(0);;){Ht=c[z>>2],xp(Ht),ot=c[Ht+24>>2];e:{if(ot&4194304){if(Mp(Ht,0),u=Tt[Ht+4|0],ot=u|1,gt[Ht+4|0]=ot,!(u&4))break e;gt[Ht+4|0]=ot&251;break e}if(P&&(u=ot&3,Vp(Ht,u||Wa,ge,Oe,bt),ot=c[Ht+24>>2]),(ot&196608)==131072)break e;s:{if((Ht|0)==(qt|0)){c[qt+308>>2]=0,c[qt+304>>2]=Q,h=m(0);break s}gs=c[r+24>>2],u=gs>>>2&3;n:{a:{if((Wi|0)!=2)break a;vt=3;o:switch(u-2|0){case 0:break n;case 1:break o;default:break a}vt=2;break n}vt=u}xr=vt>>>0>1,lt=xr?bt:qe,h=m(0),a=I[Ht+40>>2];n:{a:{Mt=c[Ht+40>>2];o:{if((Mt|0)==2139156720)break o;if((Mt|0)==2140081935)break a;u=4336;l:{if((Mt|0)!=2141891242){if(a==a)break l;u=4344}h=I[u>>2];c:{h:switch(Mt=c[u+4>>2],Mt|0){case 0:case 3:break h;default:break c}if(a=m(zt),!(I[Ht+28>>2]>m(0)))break n;Mt=gt[c[Ht+568>>2]+8|0]&1,u=Mt?2143289344:0,Mt=Mt?3:1,h=(Dt(2,u),Bt())}switch(a=m(zt),Mt-1|0){case 0:break a;case 1:break o;default:break n}}if(h=(Dt(2,(Mt&-1073741825)+536870912|0),Bt()),!(Mt&1073741824))break a}a=m(m(lt*h)*m(.009999999776482582));break n}a=h}h=I[Ht+572>>2],Mt=0;n:{a:switch($e=c[Ht+576>>2],$e|0){case 0:case 3:break n;default:break a}if(Z=I[Ht+572>>2],!(($e|0)!=1|Z!=Z)){if(h<m(0))break n;Mt=1;break n}if(Mt=1,($e|0)!=2|Z!=Z||(Mt=0,h<m(0)))break n;Mt=Hs}Z=I[Ht+580>>2],u=0;n:{a:switch(li=c[Ht+584>>2],li|0){case 0:case 3:break n;default:break a}if(Ft=I[Ht+580>>2],!((li|0)!=1|Ft!=Ft)){if(Z<m(0))break n;u=1;break n}if(u=1,(li|0)!=2|Ft!=Ft||(u=0,Z<m(0)))break n;u=ps}n:{a:{if(!(a!=a|lt!=lt)){if(h=I[Ht+308>>2],(!(gt[c[Ht+568>>2]+12|0]&1)|c[Ht+304>>2]==(Q|0))&h==h)break n;if(h=m(m(De(Ht,vt,bt)+pe(Ht,vt))+m(Pe(Ht,vt,bt)+Re(Ht,vt))),!(h<=a)&a<h)break a;h=a;break a}if(Mt&xr){Z=m(m(De(Ht,2,bt)+pe(Ht,2))+m(Pe(Ht,2,bt)+Re(Ht,2))),a=m(zt);o:switch($e-1|0){case 1:h=m(m(bt*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(!(xr|u^1)){a=m(m(De(Ht,0,bt)+pe(Ht,0))+m(Pe(Ht,0,bt)+Re(Ht,0))),h=m(zt);o:switch(li-1|0){case 1:Z=m(m(qe*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(c[O+360>>2]=2143289344,c[O+24>>2]=2143289344,Fi=0,c[O+356>>2]=0,c[O+352>>2]=0,Ft=m(he(Ht,2,bt)+Se(Ht,2,bt)),se=he(Ht,0,bt),Ie=Se(Ht,0,bt),lt=m(zt),Dr=0,a=m(zt),Mt){o:{l:switch($e-1|0){case 0:a=h;break o;case 1:break l;default:break o}a=m(m(bt*h)*m(.009999999776482582))}c[O+356>>2]=1,a=m(Ft+a),I[O+24>>2]=a,Dr=1}if(se=m(se+Ie),u){h=m(zt);o:{l:switch(li-1|0){case 0:h=Z;break o;case 1:break l;default:break o}h=m(m(qe*Z)*m(.009999999776482582))}c[O+352>>2]=1,lt=m(se+h),I[O+360>>2]=lt,Fi=1}$e=(gs&3145728)==2097152,li=vt>>>0<2;o:{l:{c:{if(!($e&li)){if($e|Vs)break l;if(a!=a)break c;break l}if(Vs|a==a)break o}Dr=2,c[O+356>>2]=2,I[O+24>>2]=bt,a=bt}l:{if(!$e||li){if($e|qe!=qe)break o;if(lt!=lt)break l;break o}if(lt==lt|qe!=qe)break o}Fi=2,c[O+352>>2]=2,I[O+360>>2]=qe,lt=qe}h=I[Ht+224>>2],$e=h!=h;o:{if($e)break o;l:{if(!(xr|(Dr|0)!=1)){c[O+352>>2]=1,I[O+360>>2]=se+m(m(a-Ft)/h);break l}if(li|(Fi|0)!=1)break o;c[O+356>>2]=1,I[O+24>>2]=m(m(lt-se)*h)+Ft}Fi=1,Dr=1}ot=ot>>>13&7,ot=ot||gs>>>10&7;o:{if((ot|0)==5|(Dr|0)==1|(xr|(Mt|Qr))|(ot|0)!=4||(c[O+356>>2]=1,I[O+24>>2]=bt,$e))break o;Fi=1,c[O+352>>2]=1,I[O+360>>2]=m(bt-Ft)/h}o:{if(li|(b|0)!=1|qe!=qe|u|(ot|0)!=4|(Fi|0)==1||(c[O+352>>2]=1,I[O+360>>2]=qe,$e))break o;c[O+356>>2]=1,I[O+24>>2]=m(qe-se)*h}if(Vn(Ht,2,bt,bt,O+356|0,O+24|0),Vn(Ht,0,qe,bt,O+352|0,O+360|0),gn(Ht,I[O+24>>2],I[O+360>>2],Wi,c[O+356>>2],c[O+352>>2],bt,qe,0,5,K,et,ft,Q),a=I[(Ht+(c[(vt<<2)+4320>>2]<<2)|0)+516>>2],u=a!=a,h=m(m(De(Ht,vt,bt)+pe(Ht,vt))+m(Pe(Ht,vt,bt)+Re(Ht,vt))),!(u|h!=h)){h=oe(a,h);break a}h=u?h:a}I[Ht+308>>2]=h}c[Ht+304>>2]=Q}W=m(W+m(h+m(he(Ht,Ct,bt)+Se(Ht,Ct,bt))))}if(z=z+4|0,(qr|0)==(z|0))break}break r}c[O>>2]=3072,lr(r,O),tr(),ce()}c[O+16>>2]=3154,lr(r,O+16|0),tr(),ce()}W=m(0)}a=m(W+m(0)),ja=rr?S:k,Ws=rr?k:S,oi>>>0>=5&&(a=m(m(cl(r,Ct,Oe)*m(Xr-1>>>0))+a)),u=a>ge,qr=$i&786432,ps=(er|0)==2&&qr&&u?1:er,Ht=rr?b:y,xr=(Ht|0)==1,k2=xr&(P^1),rr=Ct>>>0<2,w2=Ht&-3,Vs=r+208|0,b=it<<2,li=b+4288|0,S2=xr&!qr,R2=(Ht|0)!=1|P,z=Ct<<2,Dr=z+4288|0,Hs=z+4320|0,gs=Oe==Oe,L2=gs<<1,$e=b+4320|0,_2=!er|!u,Wa=O+52|0,Zh=cl(r,it,Oe),ot=0,u=0,Fi=0;r:{for(;;){er=u,Hi(O+24|0,0,44),u=c[r+560>>2],b=c[r+556>>2];i:{if((u|0)==(b|0))break i;if(u=u-b|0,(u|0)<0)break r;if(z=Ha(O+360|0,u>>2,0,Wa),u=c[O+44>>2],b=c[O+48>>2]-u|0,b=Ns(c[O+364>>2]-b|0,u,b),u=c[O+44>>2],c[O+364>>2]=u,c[O+44>>2]=b,vt=c[O+368>>2],Mt=c[O+372>>2],b=c[O+48>>2],c[O+368>>2]=b,qt=c[O+52>>2],c[O+48>>2]=vt,c[O+52>>2]=Mt,c[O+372>>2]=qt,c[z>>2]=u,(u|0)!=(b|0)&&(c[O+368>>2]=b+((u-b|0)+3&-4)),!u)break i;Ti(u)}qt=c[r+24>>2],u=qt>>>2&3;i:{e:{if(b=qt&3,((b||Yh)|0)!=2)break e;vt=3;s:switch(u-2|0){case 0:break i;case 1:break s;default:break e}vt=2;break i}vt=u}W=cl(r,vt,bt),z=ot,Mt=c[r+560>>2],b=c[r+556>>2];i:{if(z>>>0>=Mt-b>>2>>>0)break i;for(qt=qt&786432,h=m(0);;){if(Mt-b>>2>>>0<=z>>>0)break r;if(u=c[(z<<2)+b>>2],oi=c[u+24>>2],!(oi&4194304|(oi&196608)==131072)){if(c[u+548>>2]=er,a=he(u,vt,bt),Z=Se(u,vt,bt),b=c[O+24>>2],lt=(z|0)==(ot|0)?m(0):W,a=m(a+Z),Z=I[u+308>>2],Ft=Ze(u,vt,Z,Ws),!(!b||!(m(lt+m(a+m(h+Ft)))>ge)|!qt))break i;if(c[O+24>>2]=b+1,lt=m(lt+m(a+Ft)),I[O+28>>2]=lt+I[O+28>>2],qp(u)){e:{if(!c[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],Qe=O,Je=m(I[O+36>>2]-m(jn(u)*Z)),I[Qe+36>>2]=Je}b=c[O+48>>2];e:{if((b|0)!=c[O+52>>2]){c[b>>2]=u,c[O+48>>2]=b+4;break e}if(b=b-c[O+44>>2]|0,oi=b>>2,Mt=oi+1|0,Mt>>>0>=1073741824)break r;if($i=b>>1,Mt=Ha(O+360|0,b>>>0>=2147483644?1073741823:Mt>>>0<$i>>>0?$i:Mt,oi,Wa),c[c[O+368>>2]>>2]=u,c[O+368>>2]=c[O+368>>2]+4,u=c[O+44>>2],b=c[O+48>>2]-u|0,b=Ns(c[O+364>>2]-b|0,u,b),u=c[O+44>>2],c[O+364>>2]=u,c[O+44>>2]=b,oi=c[O+368>>2],$i=c[O+372>>2],b=c[O+48>>2],c[O+368>>2]=b,Qr=c[O+52>>2],c[O+48>>2]=oi,c[O+52>>2]=$i,c[O+372>>2]=Qr,c[Mt>>2]=u,(u|0)!=(b|0)&&(c[O+368>>2]=b+((u-b|0)+3&-4)),!u)break e;Ti(u)}b=c[r+556>>2],Mt=c[r+560>>2],h=m(h+lt)}if(z=z+1|0,!(z>>>0<Mt-b>>2>>>0))break}}Ie=I[O+32>>2],!(Ie>m(0))|!(Ie<m(1))||(c[O+32>>2]=1065353216,Ie=m(1)),wi=I[O+36>>2],!(wi>m(0))|!(wi<m(1))||(c[O+36>>2]=1065353216,wi=m(1)),c[O+40>>2]=z,Ft=I[O+28>>2],vt=c[O+24>>2],Fi&&Ti(Fi),Z=I[O+56>>2],oi=c[O+48>>2],Fi=c[O+44>>2];i:{e:{s:{n:{if((ps|0)==1)break n;h=m(0),a=I[Vs>>2];a:{o:{u=c[Vs>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(a==a)break c;b=4344}switch(h=I[b>>2],a=m(zt),c[b+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=c[r+216>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(W==W)break c;b=4344}switch(h=I[b>>2],W=m(zt),c[b+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),lt=I[r+212>>2];a:{o:{u=c[r+212>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(lt==lt)break c;b=4344}switch(h=I[b>>2],lt=m(zt),c[b+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}lt=m(m(h*S)*m(.009999999776482582));break a}lt=h}h=m(0),se=I[r+220>>2];a:{o:{u=c[r+220>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(se==se)break c;b=4344}switch(h=I[b>>2],se=m(zt),c[b+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}se=m(m(h*S)*m(.009999999776482582));break a}se=h}if(u=Ct>>>0>1,h=m((u?a:lt)-Zr),h==h&h>Ft||(h=m((u?W:se)-Zr),h==h&h<Ft))break s;if(gt[c[r+568>>2]+16|0]&1)break n;if(h=Ft,!c[r+552>>2]|Ie==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=ge;break e}a=I[r+32>>2]}if(a!=a&&(h=Ft,a=I[r+28>>2],!(a>m(0)))||(h=ge,a!=m(0)))break e;h=Ft;break e}h=ge}if(h!=h)break e;Z=m(h-Ft);break i}if(!(Ft<m(0)))break i;Z=m(-Ft)}if(ge=h,!k2){i:{if((oi|0)==(Fi|0)){lt=m(0);break i}for(se=m(0),b=Fi;;){u=c[b>>2],Ft=I[u+308>>2],h=Ze(u,Ct,Ft,Ws);e:{if(Z<m(0)){if(a=m(h*m(-jn(u))),!(a>m(0)|a<m(0)))break e;W=m(m(m(Z/wi)*a)+h),a=Ze(u,Ct,W,ge),Mt=a!=a,lt=m(m(De(u,Ct,bt)+pe(u,Ct))+m(Pe(u,Ct,bt)+Re(u,Ct)));s:{if(!(Mt|lt!=lt)){a=oe(a,lt);break s}a=Mt?lt:a}if(W!=W|a!=a|a==W)break e;se=m(se+m(a-h)),wi=m(m(jn(u)*Ft)+wi);break e}if(!(Z>m(0))|!c[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;lt=m(m(m(Z/Ie)*W)+h),a=Ze(u,Ct,lt,ge),Mt=a!=a,Ft=m(m(De(u,Ct,bt)+pe(u,Ct))+m(Pe(u,Ct,bt)+Re(u,Ct)));s:{if(!(Mt|Ft!=Ft)){a=oe(a,Ft);break s}a=Mt?Ft:a}if(lt!=lt|a!=a|a==lt)break e;Ie=m(Ie-W),se=m(se+m(a-h))}if(b=b+4|0,(oi|0)==(b|0))break}for(se=m(Z-se),Ka=m(se/wi),Ya=m(se/Ie),za=xr&(_2|!(Tt[r+26|0]&12)),Qr=!za,$i=c[$e>>2],lt=m(0),Mt=Fi;;){u=c[Mt>>2],Ft=Ze(u,Ct,I[u+308>>2],Ws);e:{s:{if(se<m(0)){if(W=Ft,a=m(W*m(-jn(u))),a==m(0))break e;a=wi==m(0)?m(Ft+a):m(m(Ka*a)+Ft);break s}if(W=Ft,!(se>m(0))|!c[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(Ya*a)+Ft)}if(a=Ze(u,Ct,a,ge),b=a!=a,h=m(m(De(u,Ct,bt)+pe(u,Ct))+m(Pe(u,Ct,bt)+Re(u,Ct))),!(b|h!=h)){W=oe(a,h);break e}W=b?h:a}a=he(u,Ct,bt),h=Se(u,Ct,bt),Ie=he(u,it,bt),ml=Se(u,it,bt),h=m(a+h),qh=m(W+h),I[O+352>>2]=qh,c[O+344>>2]=1,Ie=m(Ie+ml),a=I[u+224>>2];e:{if(a==a){c[O+348>>2]=1,h=m(qh-h),I[O+356>>2]=Ie+m(rr?h*a:h/a);break e}s:{if(js=Oe!=Oe,js)break s;qt=($i<<3)+u|0,a=I[qt+572>>2];n:{a:{o:{l:switch(b=c[qt+576>>2],b|0){case 0:case 3:break o;default:break l}if(h=I[qt+572>>2],(b|0)!=1|h!=h)break a;if(!(Qr|!(a<m(0))))break n;break s}if(!za)break s;break n}if(Qr|(!(a<m(0))|((b|0)!=2|h!=h)))break s}if(b=c[u+24>>2]>>>13&7,b||(b=c[r+24>>2]>>>10&7),(b|0)!=4||(vn(O+24|0,u,it),c[O+28>>2]==3)||(mn(O+360|0,u,it),c[O+364>>2]==3))break s;c[O+348>>2]=1,I[O+356>>2]=Oe;break e}qt=($i<<3)+u|0,h=I[qt+572>>2];s:{n:{a:{o:{l:switch(b=c[qt+576>>2],b|0){case 0:case 3:break o;default:break l}if(a=I[qt+572>>2],!((b|0)!=1|a!=a)){if(a=h,a<m(0))break o;break s}if((b|0)!=2|a!=a)break a;if(js)break o;if(!(h<m(0)))break n}c[O+348>>2]=L2,I[O+356>>2]=Oe;break e}a=m(zt);a:switch(b-1|0){case 1:break n;case 0:break a;default:break s}a=h;break s}a=m(m(Oe*h)*m(.009999999776482582))}a=m(Ie+a),I[O+356>>2]=a,c[O+348>>2]=(xr|(b|0)!=2)&a==a}Vn(u,Ct,ge,bt,O+344|0,O+352|0),Vn(u,it,Oe,bt,O+348|0,O+356|0),qt=($i<<3)+u|0,a=I[qt+572>>2];e:{s:{n:{a:switch(b=c[qt+576>>2],b|0){case 0:case 3:break n;default:break a}if(h=I[qt+572>>2],!((b|0)!=1|h!=h)){if(a<m(0))break n;break s}if((b|0)!=2|h!=h)break s;if(a<m(0))break n;if(qt=0,gs)break e}if(qt=0,b=c[u+24>>2]>>>13&7,b||(b=c[r+24>>2]>>>10&7),(b|0)!=4||(vn(O+24|0,u,it),c[O+28>>2]==3))break e;mn(O+360|0,u,it),qt=c[O+364>>2]!=3;break e}qt=0}a=I[O+352>>2],h=I[O+356>>2],b=Ct>>>0>1,Ie=b?a:h,a=b?h:a,js=c[O+344>>2],Qh=c[O+348>>2],C2=b?js:Qh,js=b?Qh:js,b=(qt^1)&P,gn(u,Ie,a,Tt[r+300|0]&3,C2,js,bt,qe,b,b?4:7,K,et,ft,Q),lt=m(lt+m(W-Ft)),b=Tt[r+300|0];e:{s:{if(b&4){qt=b&251;break s}if(qt=b&251,b=0,!(Tt[u+300|0]&4))break e}b=4}if(gt[r+300|0]=b|qt,Mt=Mt+4|0,(oi|0)==(Mt|0))break}}Z=m(Z-lt)}u=Tt[r+300|0],gt[r+300|0]=u&251|(Z<m(0)?4:u&4),se=m(De(r,Ct,k)+pe(r,Ct)),Ka=m(Pe(r,Ct,k)+Re(r,Ct)),Ft=cl(r,Ct,k);i:{if(!(!(Z>m(0))|(ps|0)!=2)){lt=m(0),h=m(0);e:{s:{u=Vs+(c[Hs>>2]<<2)|0,a=I[u>>2],u=c[u>>2],b=(u|0)==2139156720;n:{if(!b){if(Mt=(u|0)==2140081935,Mt)break s;if(qt=(u|0)==2141891242,qt|a!=a)break i;if(Mt)break s;if(qt)break i;if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break n}h=m(m(Ws*h)*m(.009999999776482582))}if(h!=h)break i;h=m(0);n:{if(b)break n;if((u|0)==2140081935)break s;b=4336;a:{if((u|0)!=2141891242){if(a==a)break a;b=4344}switch(h=I[b>>2],W=m(zt),c[b+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(Ws*h)*m(.009999999776482582));break e}W=h}if(a=m(m(m(W-se)-Ka)-m(ge-Z)),a!=a)break i;lt=oe(a,m(0));break i}lt=Z}qt=z>>>0<=ot>>>0;i:{if(!qt){for(oi=c[r+556>>2],u=c[r+560>>2]-oi>>2,$i=u>>>0<ot>>>0?ot:u,Mt=0,u=ot;;){if((u|0)==($i|0))break r;if(b=c[oi+(u<<2)>>2],(c[b+24>>2]&196608)!=131072&&(Qr=O+24|0,vn(Qr,b,Ct),za=c[O+28>>2],mn(Qr,b,Ct),Mt=(((za|0)==3)+Mt|0)+(c[O+28>>2]==3)|0),u=u+1|0,(z|0)==(u|0))break}if(Ie=m(0),h=Ft,Mt)break i}Ie=m(0),Mt=0,h=Ft;e:switch((c[r+24>>2]>>>4&7)-1|0){case 0:Ie=m(lt*m(.5));break i;case 1:Ie=lt;break i;case 2:if(vt>>>0<2)break i;h=m(Ft+m((Je=m(0),Yn=oe(lt,m(0)),Qe=lt!=lt,(Qe?Je:Yn)/m(vt-1>>>0))));break i;case 4:Ie=m(lt/m(vt+1>>>0)),h=m(Ft+Ie);break i;case 3:break e;default:break i}Ie=m(m(lt*m(.5))/m(vt>>>0)),h=m(m(Ie+Ie)+Ft)}if(a=m(se+Ie),Z=m(0),oi=Wp(r),qt)h=m(0);else{for($i=z-1|0,Ya=m(lt/m(Mt|0)),se=m(0),W=m(0),u=ot;;){if(b=c[r+556>>2],c[r+560>>2]-b>>2>>>0<=u>>>0)break r;b=c[b+(u<<2)>>2],vt=b+228|0,Vi(O+24|0,vt,320),h=m(h-((u|0)==($i|0)?Ft:m(0))),Mt=c[b+24>>2];i:{if(Mt&4194304)break i;e:{if((Mt&196608)==131072){if(!cr(b,Ct))break e;if(!P)break i;lt=Us(b,Ct,ge),wi=pe(r,Ct),ml=he(b,Ct,bt),I[vt+(c[Dr>>2]<<2)>>2]=ml+m(lt+wi);break i}if(vn(O+360|0,b,Ct),a=m(a+(c[O+364>>2]==3?Ya:m(-0))),P&&(Mt=vt,vt=c[Dr>>2]<<2,I[Mt+vt>>2]=a+I[vt+(O+24|0)>>2]),mn(O+360|0,b,Ct),a=m(a+(c[O+364>>2]==3?Ya:m(-0))),!R2){a=m(a+m(m(h+m(he(b,Ct,bt)+Se(b,Ct,bt)))+I[O+104>>2])),Z=Oe;break i}if(vt=b+516|0,a=m(a+m(h+m(I[vt+(c[Hs>>2]<<2)>>2]+m(he(b,Ct,bt)+Se(b,Ct,bt))))),oi){lt=hl(b),wi=he(b,0,bt),lt=m(lt+wi),wi=m(m(I[b+520>>2]+m(he(b,0,bt)+Se(b,0,bt)))-lt),b=se!=se;s:{if(!(b|lt!=lt)){se=oe(se,lt);break s}se=b?lt:se}if(b=W!=W,!(b|wi!=wi)){W=oe(W,wi);break i}W=b?wi:W;break i}if(lt=m(I[vt+(c[$e>>2]<<2)>>2]+m(he(b,it,bt)+Se(b,it,bt))),b=Z!=Z,!(lt!=lt|b)){Z=oe(Z,lt);break i}Z=b?lt:Z;break i}if(!P)break i;b=c[Dr>>2]<<2,lt=I[b+(O+24|0)>>2],Qe=b+vt|0,Je=m(Ie+m(lt+pe(r,Ct))),I[Qe>>2]=Je}if(u=u+1|0,(z|0)==(u|0))break}h=m(W+se)}if(Z=oi?h:Z,lt=Oe,!w2){h=Ze(r,it,m(ir+Z),ja),u=h!=h,W=m(m(De(r,it,k)+pe(r,it))+m(Pe(r,it,k)+Re(r,it)));i:{if(!(u|W!=W)){h=oe(h,W);break i}h=u?W:h}lt=m(h-ir)}h=Ze(r,it,m(ir+(S2?Oe:Z)),ja),u=h!=h,W=m(m(De(r,it,k)+pe(r,it))+m(Pe(r,it,k)+Re(r,it)));i:{if(!(u|W!=W)){h=oe(h,W);break i}h=u?W:h}if(W=m(h-ir),!(qt|!P))for(;;){if(u=c[r+556>>2],c[r+560>>2]-u>>2>>>0<=ot>>>0)break r;vt=c[u+(ot<<2)>>2],u=c[vt+24>>2];i:{if(u&4194304)break i;if((u&196608)==131072){e:{if(!cr(vt,it)){b=c[li>>2];break e}if(h=Us(vt,it,Oe),Z=pe(r,it),Ft=he(vt,it,bt),b=c[li>>2],h=m(Ft+m(h+Z)),I[(vt+(b<<2)|0)+228>>2]=h,h==h)break i}Qe=vt+(b<<2)|0,Je=m(pe(r,it)+he(vt,it,bt)),I[Qe+228>>2]=Je;break i}b=u>>>13&7,b||(b=c[r+24>>2]>>>10&7);e:{s:{if((b|0)==5){b=c[r+24>>2]&8?5:1;break s}if((b|0)!=4||(vn(O+24|0,vt,it),b=4,c[O+28>>2]==3)||(mn(O+360|0,vt,it),c[O+364>>2]==3))break s;b=vt+(c[$e>>2]<<3)|0,Z=I[b+572>>2];n:{a:switch(u=c[b+576>>2],u|0){case 0:case 3:break n;default:break a}if(Ft=I[b+572>>2],!((u|0)!=1|Ft!=Ft)){if(h=je,Z<m(0))break n;break e}if(h=je,gs&!(Z<m(0))|((u|0)!=2|Ft!=Ft))break e}Z=I[(vt+(c[Hs>>2]<<2)|0)+516>>2],h=W,Ft=I[vt+224>>2],Ft==Ft&&(h=m(m(he(vt,it,bt)+Se(vt,it,bt))+m(rr?Z*Ft:Z/Ft))),I[O+360>>2]=h,Qe=O,Je=m(Z+m(he(vt,Ct,bt)+Se(vt,Ct,bt))),I[Qe+24>>2]=Je,c[O+356>>2]=1,c[O+352>>2]=1,Vn(vt,Ct,ge,bt,O+356|0,O+24|0),Vn(vt,it,Oe,bt,O+352|0,O+360|0),Z=I[O+360>>2],Ft=I[O+24>>2],u=Ct>>>0>1,h=u?Z:Ft,Z=u?Ft:Z,u=(qr|0)!=0&(c[r+24>>2]&896)!=512,gn(vt,Z,h,Wi,!(u&rr|Z!=Z),(!u|rr)&h==h,bt,qe,1,2,K,et,ft,Q),h=je;break e}h=I[(vt+(c[$e>>2]<<2)|0)+516>>2],Z=he(vt,it,bt),Ft=Se(vt,it,bt),vn(O+24|0,vt,it),Z=m(lt-m(h+m(Z+Ft)));s:{if(c[O+28>>2]!=3||(mn(O+360|0,vt,it),c[O+364>>2]!=3))break s;h=m(Z*m(.5)),h=m(je+(Je=m(0),Yn=oe(h,m(0)),Qe=h!=h,Qe?Je:Yn));break e}if(mn(O+24|0,vt,it),h=je,c[O+28>>2]==3)break e;if(vn(O+24|0,vt,it),c[O+28>>2]==3){h=m(je+(Je=m(0),Yn=oe(Z,m(0)),Qe=Z!=Z,Qe?Je:Yn));break e}s:switch(b-1|0){case 1:h=m(je+m(Z*m(.5)));break e;case 0:break e;default:break s}h=m(je+Z)}u=vt+(c[li>>2]<<2)|0,I[u+228>>2]=h+m(ms+I[u+228>>2])}if(ot=ot+1|0,(ot|0)==(z|0))break}h=m((er?Zh:m(0))+W),u=Ks!=Ks,a=m(Ka+a);i:{if(!(u|a!=a)){Ks=oe(Ks,a);break i}Ks=u?a:Ks}if(ms=m(ms+h),u=er+1|0,ot=z,!(Xr>>>0>z>>>0))break}i:{if(!P||!qr&&!Wp(r))break i;se=m(0);e:{s:{if(Oe!=Oe)break s;a=m(Oe-ms);n:switch((c[r+24>>2]>>>7&7)-2|0){case 0:je=m(je+m(a*m(.5)));break s;case 2:if(!(Oe>ms))break s;se=m(a/m(u>>>0));break s;case 5:if(Oe>ms){if(je=m(je+m(a/m(u<<1>>>0))),u>>>0<2)break s;se=m(a/m(u>>>0));break e}je=m(je+m(a*m(.5)));break s;case 4:if(!(Oe>ms)|u>>>0<2)break s;se=m(a/m(er>>>0));break e;case 1:break n;default:break s}je=m(je+a)}if(!u)break i}for(Mt=0,u=0,b=0;;){if(Z=m(0),h=m(0),a=m(0),W=m(0),z=u,Xr>>>0>u>>>0){e:{for(;;){if(b=c[r+556>>2],c[r+560>>2]-b>>2>>>0<=z>>>0)break r;ot=c[b+(z<<2)>>2],vt=c[ot+24>>2];s:{if(vt&4194304|(vt&196608)==131072)break s;if(b=z,c[ot+548>>2]!=(Mt|0))break e;a=I[(ot+(c[$e>>2]<<2)|0)+516>>2];n:{if(!(a>=m(0)))break n;if(b=h!=h,a=m(a+m(he(ot,it,bt)+Se(ot,it,bt))),!(b|a!=a)){h=oe(h,a);break n}h=b?a:h}if(b=vt>>>13&7,b||(b=c[r+24>>2]>>>10&7),!(Tt[r+24|0]&8)|(b|0)!=5)break s;a=hl(ot),lt=he(ot,0,bt),a=m(a+lt),lt=m(m(I[ot+520>>2]+m(he(ot,0,bt)+Se(ot,0,bt)))-a),b=h!=h,ot=W!=W;n:{if(!(ot|a!=a)){W=oe(W,a);break n}W=ot?a:W}ot=Z!=Z;n:{if(!(ot|lt!=lt)){Z=oe(Z,lt);break n}Z=ot?lt:Z}if(a=m(W+Z),!(b|a!=a)){h=oe(h,a);break s}h=b?a:h}if(z=z+1|0,(Xr|0)==(z|0))break}b=Xr}a=h}if(lt=m(je+(Mt?Zh:m(0))),h=m(se+a),je=m(lt+h),u>>>0<b>>>0)for(Ft=m(lt+W);;){if(z=c[r+556>>2],c[r+560>>2]-z>>2>>>0<=u>>>0)break r;ot=c[z+(u<<2)>>2],z=c[ot+24>>2];e:{if(z&4194304|(z&196608)==131072)break e;z=z>>>13&7,z||(z=c[r+24>>2]>>>10&7);s:{n:switch(z-1|0){case 4:if(Tt[r+24|0]&8)break s;case 0:a=he(ot,it,bt),I[(ot+(c[li>>2]<<2)|0)+228>>2]=lt+a;break e;case 2:a=Se(ot,it,bt),z=ot+228|0,I[z+(c[li>>2]<<2)>>2]=m(je-a)-I[(z+(c[$e>>2]<<2)|0)+288>>2];break e;case 1:z=ot+228|0,I[z+(c[li>>2]<<2)>>2]=lt+m(m(h-I[(z+(c[$e>>2]<<2)|0)+288>>2])*m(.5));break e;case 3:break n;default:break e}a=he(ot,it,bt),I[(ot+(c[li>>2]<<2)|0)+228>>2]=lt+a,vt=ot+(c[$e>>2]<<3)|0,a=I[vt+572>>2];n:{a:switch(z=c[vt+576>>2],z|0){case 0:case 3:break n;default:break a}if(W=I[vt+572>>2],!((z|0)!=1|W!=W)){if(a<m(0))break n;break e}if(gs&!(a<m(0))|((z|0)!=2|W!=W))break e}n:{if(Ct>>>0>=2){Z=h,a=I[ot+516>>2],W=m(a+m(he(ot,Ct,bt)+Se(ot,Ct,bt)));break n}Z=m(I[ot+520>>2]+m(he(ot,it,bt)+Se(ot,it,bt))),a=I[ot+516>>2],W=h}n:{a:{if(!(W!=W|a!=a)){if(m(Xe(m(W-a)))<m(9999999747378752e-20))break a;break n}if(W==W|a==a)break n}if(a=I[ot+520>>2],z=a!=a,!(z|Z!=Z)){if(!(m(Xe(m(Z-a)))<m(9999999747378752e-20)))break n;break e}if(Z==Z)break n;if(z)break e}gn(ot,W,Z,Wi,1,1,bt,qe,1,3,K,et,ft,Q);break e}Qe=ot,Je=m(m(Ft-hl(ot))+Us(ot,0,Oe)),I[Qe+232>>2]=Je}if(u=u+1|0,(b|0)==(u|0))break}if(z=(Mt|0)!=(er|0),Mt=Mt+1|0,u=b,!z)break}}vt=r+516|0,a=Ze(r,2,zh,k),u=a!=a,h=m(m(De(r,2,k)+pe(r,2))+m(Pe(r,2,k)+Re(r,2)));i:{if(!(u|h!=h)){a=oe(a,h);break i}a=u?h:a}I[vt>>2]=a,a=Ze(r,0,Xh,S),u=a!=a,h=m(m(De(r,0,k)+pe(r,0))+m(Pe(r,0,k)+Re(r,0)));i:{if(!(u|h!=h)){a=oe(a,h);break i}a=u?h:a}I[r+520>>2]=a;i:{e:{s:{if(ps&&(u=c[r+24>>2]>>>20&3,(u|0)==2|(ps|0)!=2))break s;if(a=Ze(r,Ct,Ks,Ws),u=a!=a,h=m(m(De(r,Ct,k)+pe(r,Ct))+m(Pe(r,Ct,k)+Re(r,Ct))),!(u|h!=h)){a=oe(a,h);break e}a=u?h:a;break e}if((ps|0)!=2|(u|0)!=2)break i;h=m(Zr+ge),u=h!=h,a=Ze(r,Ct,Ks,Ws);s:{if(!(u|a!=a)){a=Gh(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Zr!=Zr)){a=oe(a,Zr);break e}a=u?Zr:a}I[vt+(c[Hs>>2]<<2)>>2]=a}i:{e:{s:{if(Ht&&(b=(Ht|0)!=2,u=c[r+24>>2]>>>20&3,b|(u|0)==2))break s;if(a=Ze(r,it,m(ir+ms),ja),u=a!=a,h=m(m(De(r,it,k)+pe(r,it))+m(Pe(r,it,k)+Re(r,it))),!(u|h!=h)){a=oe(a,h);break e}a=u?h:a;break e}if(b|(u|0)!=2)break i;h=m(ir+Oe),u=h!=h,a=Ze(r,it,m(ir+ms),ja);s:{if(!(u|a!=a)){a=Gh(h,a);break s}a=u?a:h}if(u=a!=a,!(u|ir!=ir)){a=oe(a,ir);break e}a=u?ir:a}I[vt+(c[$e>>2]<<2)>>2]=a}i:{if(!P)break i;if((c[r+24>>2]&786432)==524288)for(b=Xr>>>0<=1?1:Xr,P=c[r+556>>2],ot=c[r+560>>2]-P>>2,u=0;z=0,z=u>>>0<ot>>>0?c[P+(u<<2)>>2]:z,(c[z+24>>2]&196608)!=131072&&(z=z+228|0,Mt=z+(c[li>>2]<<2)|0,qt=c[$e>>2]<<2,I[Mt>>2]=m(I[qt+vt>>2]-I[Mt>>2])-I[(z+qt|0)+288>>2]),u=u+1|0,(b|0)!=(u|0););if(b=c[r+556>>2],P=c[r+560>>2],(b|0)!=(P|0))for(Mt=((Ct>>>0>1?ps:y)|0)!=0;;){y=c[b>>2];e:{if((c[y+24>>2]&4390912)!=131072)break e;W=bt,ge=qe,Tt[c[r+568>>2]+12|0]&2&&(ge=I[r+520>>2],W=I[r+516>>2]),u=c[r+24>>2]>>>2&3;s:{n:{if((Wi|0)==2){ot=0,z=3;a:switch(u-2|0){case 0:break s;case 1:break a;default:break n}z=2;break s}if(ot=0,u>>>0<=1)break n;z=u;break s}z=u,ot=Gs}S=m(he(y,2,W)+Se(y,2,W)),k=he(y,0,W),Z=Se(y,0,W),a=I[y+572>>2];s:{n:{a:switch(u=c[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(zt);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(zt),!cr(y,2)||!fl(y,2))break s;if(a=Ze(y,2,m(m(I[r+516>>2]-m(pe(r,2)+Re(r,2)))-m(Us(y,2,W)+Va(y,2,W))),W),u=a!=a,h=m(m(De(y,2,W)+pe(y,2))+m(Pe(y,2,W)+Re(y,2))),!(u|h!=h)){h=oe(a,h);break s}h=u?h:a}Z=m(k+Z);s:{n:{a:{o:{l:{c:{h:{qt=h!=h,k=I[y+580>>2];f:{d:{p:switch(u=c[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(ge!=ge|k<m(0))break d;break v}a=m(zt);y:switch(u-1|0){case 1:break v;case 0:break y;default:break p}a=k;break p}a=m(m(ge*k)*m(.009999999776482582))}a=m(Z+a);break f}d:{if(cr(y,0)&&fl(y,0))break d;if(a=m(zt),h==h)break h;break a}if(a=Ze(y,0,m(m(I[r+520>>2]-m(pe(r,0)+Re(r,0)))-m(Us(y,0,ge)+Va(y,0,ge))),ge),u=a!=a,k=m(m(De(y,0,W)+pe(y,0))+m(Pe(y,0,W)+Re(y,0))),!(u|k!=k)){a=oe(a,k);break f}a=u?k:a}if((qt|0)==(a!=a|0)||(lt=I[y+224>>2],lt!=lt))break l;if(h!=h){h=m(m(m(a-Z)*lt)+S);break l}if(a==a)break l;break c}if(lt=I[y+224>>2],lt!=lt)break o}a=m(Z+m(m(h-S)/lt))}if(h!=h)break a;if(a==a)break s}u=0;break n}u=1}qt=W>m(0),er=u&Mt&z>>>0<2,h=er&&qt?W:h,u=u^1,gn(y,h,a,Wi,er&&qt?2:u,a==a,h,a,0,6,K,et,ft,Q),h=m(I[y+516>>2]+f2(y,2,W)),a=m(I[y+520>>2]+f2(y,0,W))}gn(y,h,a,Wi,1,1,h,a,1,1,K,et,ft,Q);s:{n:{a:{if(!fl(y,z)||cr(y,z))break a;u=c[(z<<2)+4320>>2]<<2,a=z>>>0<2?ge:W,a=m(m(m(m(I[u+vt>>2]-I[(u+y|0)+516>>2])-Re(r,z))-Se(y,z,a))-Va(y,z,a));break n}if(!(cr(y,z)|(c[r+24>>2]&112)!=16)){u=c[(z<<2)+4320>>2]<<2,a=m(m(I[u+vt>>2]-I[(u+y|0)+516>>2])*m(.5));break n}if(!(cr(y,z)|(c[r+24>>2]&112)!=32)){u=c[(z<<2)+4320>>2]<<2,a=m(I[u+vt>>2]-I[(u+y|0)+516>>2]);break n}if(!(Tt[c[r+568>>2]+12|0]&2)||!cr(y,z))break s;a=I[vt+(c[(z<<2)+4320>>2]<<2)>>2],a=m(m(Us(y,z,a)+pe(r,z))+he(y,z,a))}I[(y+(c[(z<<2)+4288>>2]<<2)|0)+228>>2]=a}s:{n:{if(!fl(y,ot)||cr(y,ot))break n;u=c[(ot<<2)+4320>>2]<<2,a=z>>>0<2?W:ge,a=m(m(m(m(I[u+vt>>2]-I[(u+y|0)+516>>2])-Re(r,ot))-Se(y,ot,a))-Va(y,ot,a));break s}n:{if(cr(y,ot)||(u=c[y+24>>2]>>>13&7,u||(u=c[r+24>>2]>>>10&7),(u|0)!=2))break n;u=c[(ot<<2)+4320>>2]<<2,a=m(m(I[u+vt>>2]-I[(u+y|0)+516>>2])*m(.5));break s}n:{if(cr(y,ot))break n;z=c[y+24>>2]>>>13&7,u=c[r+24>>2],z=z||u>>>10&7;a:{if((z|0)==5){if((u&786432)==524288)break a;break n}if(((z|0)==3|0)==((u&786432)==524288|0))break n}u=c[(ot<<2)+4320>>2]<<2,a=m(I[u+vt>>2]-I[(u+y|0)+516>>2]);break s}if(!(Tt[c[r+568>>2]+12|0]&2)||!cr(y,ot))break e;a=I[vt+(c[(ot<<2)+4320>>2]<<2)>>2],a=m(m(Us(y,ot,a)+pe(r,ot))+he(y,ot,a))}I[(y+(c[(ot<<2)+4288>>2]<<2)|0)+228>>2]=a}if(b=b+4|0,(P|0)==(b|0))break}if(!((it|Ct)&1))break i;for(b=it&1,P=Ct&1,K=Xr>>>0<=1?1:Xr,et=(it<<2)+4304|0,ft=(Ct<<2)+4304|0,Q=c[r+556>>2],it=c[r+560>>2]-Q>>2,r=0;;){if((r|0)==(it|0))break r;u=c[Q+(r<<2)>>2];e:{if(Tt[u+26|0]&64||(P&&(y=u+228|0,z=c[Hs>>2]<<2,I[y+(c[ft>>2]<<2)>>2]=m(I[z+vt>>2]-I[(y+z|0)+288>>2])-I[y+(c[Dr>>2]<<2)>>2]),!b))break e;u=u+228|0,y=c[$e>>2]<<2,I[u+(c[et>>2]<<2)>>2]=m(I[y+vt>>2]-I[(u+y|0)+288>>2])-I[u+(c[li>>2]<<2)>>2]}if(r=r+1|0,(K|0)==(r|0))break}}if(!Fi)break t;Ti(Fi);break t}Fs(),ce()}kt=O+384|0}function _p(){var r=0,a=0;Gn(7032,7033,7034,0,4352,17,4355,0,4355,0,2529,4357,18),r=ut(8),c[r>>2]=8,c[r+4>>2]=1,Rt(7032,2922,6,4368,4392,19,r|0,1),Gn(7036,7037,7038,7032,4352,20,4352,21,4352,22,2001,4357,23),r=ut(4),c[r>>2]=24,Rt(7036,2359,2,4400,4408,25,r|0,0),us(7032,1398,2,4412,4420,26,27),us(7032,3027,3,4500,4512,28,29),Gn(7056,7057,7058,0,4352,30,4355,0,4355,0,2545,4357,31),r=ut(8),c[r>>2]=8,c[r+4>>2]=1,Rt(7056,3293,2,4520,4408,32,r|0,1),Gn(7059,7060,7061,7056,4352,33,4352,34,4352,35,2024,4357,36),r=ut(4),c[r>>2]=37,Rt(7059,2359,2,4528,4408,38,r|0,0),us(7056,1398,2,4536,4420,39,40),us(7056,3027,3,4500,4512,28,41),Gn(7062,7063,7064,0,4352,42,4355,0,4355,0,2861,4357,43),Sp(7062,1,4584,4352,44,45),us(7062,2915,1,4584,4352,44,45),us(7062,1129,2,4588,4408,46,47),r=ut(8),c[r+4>>2]=0,c[r>>2]=48,Rt(7062,3234,4,4608,4624,49,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=50,Rt(7062,1981,3,4632,4644,51,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=52,Rt(7062,1952,3,4652,4664,53,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=54,Rt(7062,3389,3,4672,4664,55,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=56,Rt(7062,1800,3,4652,4664,53,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=57,Rt(7062,3264,3,4684,4512,58,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=59,Rt(7062,1926,2,4696,4420,60,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=61,Rt(7062,3399,2,4704,4420,62,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=63,Rt(7062,1785,2,4696,4420,60,r|0,0),Dh(7065,1271,4712,64,4357,65),Kn(1732,0),Kn(1612,8),Kn(2145,16),Kn(2455,24),Kn(2561,32),Kn(1618,40),xh(7065),Dh(7035,2898,4712,66,4357,67),s2(2561,0),s2(1618,8),xh(7035),Dh(7066,2909,4712,68,4357,69),r=ut(4),c[r>>2]=8,a=ut(4),c[a>>2]=8,ll(7066,2903,7098,4714,70,r|0,7098,4718,71,a|0),r=ut(4),c[r>>2]=0,a=ut(4),c[a>>2]=0,ll(7066,1607,7091,4420,72,r|0,7091,4664,73,a|0),xh(7066),Gn(7067,7068,7069,0,4352,74,4355,0,4355,0,3022,4357,75),Sp(7067,1,4724,4352,76,77),us(7067,1593,1,4724,4352,76,77),us(7067,2851,2,4728,4420,78,79),us(7067,1129,2,4736,4408,80,81),r=ut(8),c[r+4>>2]=0,c[r>>2]=82,Rt(7067,1753,2,4736,4408,83,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=84,Rt(7067,3005,3,4744,4664,85,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=86,Rt(7067,2930,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=88,Rt(7067,2335,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=90,Rt(7067,1485,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=91,Rt(7067,1356,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=92,Rt(7067,1818,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=93,Rt(7067,2872,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=94,Rt(7067,2379,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=95,Rt(7067,2164,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=96,Rt(7067,1320,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=97,Rt(7067,2413,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=98,Rt(7067,1504,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=99,Rt(7067,2236,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=100,Rt(7067,1220,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=101,Rt(7067,1137,3,4756,4664,87,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=102,Rt(7067,1159,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=104,Rt(7067,1846,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=105,Rt(7067,1465,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=106,Rt(7067,2219,2,4736,4408,83,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=107,Rt(7067,1196,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=108,Rt(7067,2501,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=109,Rt(7067,2591,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=110,Rt(7067,1540,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=111,Rt(7067,2250,2,4736,4408,83,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=112,Rt(7067,1651,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=113,Rt(7067,1428,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=114,Rt(7067,2205,2,4736,4408,83,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=115,Rt(7067,2609,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=116,Rt(7067,1556,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=117,Rt(7067,1671,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=118,Rt(7067,1445,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=119,Rt(7067,2567,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=120,Rt(7067,1521,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=121,Rt(7067,1625,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=122,Rt(7067,1408,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=123,Rt(7067,2305,3,4792,4718,103,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=124,Rt(7067,2093,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=125,Rt(7067,2719,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=126,Rt(7067,1575,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=127,Rt(7067,2188,4,4768,4784,89,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=128,Rt(7067,2946,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=130,Rt(7067,2347,3,4812,4512,131,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=132,Rt(7067,1372,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=133,Rt(7067,1832,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=134,Rt(7067,2885,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=135,Rt(7067,2396,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=136,Rt(7067,2176,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=137,Rt(7067,1338,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=138,Rt(7067,2423,3,4812,4512,131,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=139,Rt(7067,1859,2,4824,4420,140,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=141,Rt(7067,1208,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=143,Rt(7067,2515,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=144,Rt(7067,2600,2,4824,4420,140,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=145,Rt(7067,1661,2,4824,4420,140,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=146,Rt(7067,2621,2,4824,4420,140,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=147,Rt(7067,1684,2,4824,4420,140,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=148,Rt(7067,2579,2,4824,4420,140,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=149,Rt(7067,1638,2,4824,4420,140,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=150,Rt(7067,2320,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=151,Rt(7067,2103,3,4840,4852,152,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=153,Rt(7067,1232,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=154,Rt(7067,1148,2,4804,4420,129,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=155,Rt(7067,2730,3,4812,4512,131,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=156,Rt(7067,2195,3,4860,4872,157,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=158,Rt(7067,3034,4,4880,4624,159,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=160,Rt(7067,3055,3,4896,4664,161,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=162,Rt(7067,1293,2,4908,4420,163,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=164,Rt(7067,1388,2,4916,4420,165,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=166,Rt(7067,3046,3,4924,4512,167,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=168,Rt(7067,2962,2,4936,4420,169,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=170,Rt(7067,2982,3,4944,4664,171,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=172,Rt(7067,3357,3,4956,4664,173,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=174,Rt(7067,3355,2,4736,4408,83,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=175,Rt(7067,3374,3,4968,4664,176,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=177,Rt(7067,3372,2,4736,4408,83,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=178,Rt(7067,1119,2,4736,4408,83,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=179,Rt(7067,1111,2,4980,4420,180,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=181,Rt(7067,1244,5,4992,5012,182,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=183,Rt(7067,1737,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=184,Rt(7067,1715,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=185,Rt(7067,2149,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=186,Rt(7067,2462,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=187,Rt(7067,2633,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=188,Rt(7067,1697,2,4832,4714,142,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=189,Rt(7067,1260,2,5020,4420,190,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=191,Rt(7067,2433,3,4840,4852,152,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=192,Rt(7067,2113,3,4840,4852,152,r|0,0),r=ut(8),c[r+4>>2]=0,c[r>>2]=193,Rt(7067,2741,3,4840,4852,152,r|0,0)}function aT(r,a,h,u,y,b){r=r|0,a=+a,h=h|0,u=u|0,y=y|0,b=b|0;var k=0,S=0,P=0,K=0,et=0,ft=0,Q=0,it=0,O=0,W=0,z=0,Z=0,ot=0,lt=0,vt=0,bt=0,Ct=0,Mt=0,Ft=0;Q=kt-560|0,kt=Q,c[Q+44>>2]=0,Ei(+a),k=te(1)|0,te(0)|0;t:{if((k|0)<0){ot=1,Mt=1177,a=-a,Ei(+a),k=te(1)|0,te(0)|0;break t}if(y&2048){ot=1,Mt=1180;break t}ot=y&1,Mt=ot?1183:1178,Ft=!ot}t:{if((k&2146435072)==2146435072){k=ot+3|0,ki(r,32,h,k,y&-65537),gi(r,Mt,ot),u=b&32,gi(r,a!=a?u?2451:3459:u?2868:3463,3),ki(r,32,h,k,y^8192),it=(h|0)<(k|0)?k:h;break t}vt=Q+16|0;r:{i:{e:{if(a=Yp(a,Q+44|0),a=a+a,a!=0){if(k=c[Q+44>>2],c[Q+44>>2]=k-1,bt=b|32,(bt|0)!=97)break e;break r}if(bt=b|32,(bt|0)==97)break r;et=c[Q+44>>2],ft=(u|0)<0?6:u;break i}et=k-29|0,c[Q+44>>2]=et,a=a*268435456,ft=(u|0)<0?6:u}for(z=(Q+48|0)+((et|0)>=0?288:0)|0,S=z;a<4294967296&a>=0?u=~~a>>>0:u=0,c[S>>2]=u,S=S+4|0,a=(a-+(u>>>0))*1e9,a!=0;);i:{if((et|0)<=0){u=et,k=S,P=z;break i}for(P=z,u=et;;){O=(u|0)>=29?29:u,k=S-4|0;e:{if(P>>>0>k>>>0)break e;for(u=0;K=c[k>>2],Ct=u,u=O&31,(O&63)>>>0>=32?(it=K<<u,u=0):(it=(1<<u)-1&K>>>32-u,u=K<<u),Ct=Ct+u|0,K=it+W|0,u=Op(Ct,u>>>0>Ct>>>0?K+1|0:K,1e9),K=Bh(u,Gi,-1e9,0)+Ct|0,c[k>>2]=K,k=k-4|0,P>>>0<=k>>>0;);if(!u)break e;P=P-4|0,c[P>>2]=u}for(;k=S,P>>>0<k>>>0&&(S=k-4|0,!c[S>>2]););if(u=c[Q+44>>2]-O|0,c[Q+44>>2]=u,S=k,!((u|0)>0))break}}if((u|0)<0)for(lt=((ft+25>>>0)/9|0)+1|0,W=(bt|0)==102;;){u=0-u|0,it=(u|0)>=9?9:u;i:{if(k>>>0<=P>>>0){S=c[P>>2];break i}for(O=1e9>>>it|0,K=-1<<it^-1,u=0,S=P;Ct=u,u=c[S>>2],c[S>>2]=Ct+(u>>>it|0),u=We(O,u&K),S=S+4|0,S>>>0<k>>>0;);if(S=c[P>>2],!u)break i;c[k>>2]=u,k=k+4|0}if(u=it+c[Q+44>>2]|0,c[Q+44>>2]=u,P=(!S<<2)+P|0,S=W?z:P,k=k-S>>2>(lt|0)?S+(lt<<2)|0:k,!((u|0)<0))break}u=0;i:{if(k>>>0<=P>>>0||(u=We(z-P>>2,9),S=10,K=c[P>>2],K>>>0<10))break i;for(;u=u+1|0,S=We(S,10),K>>>0>=S>>>0;);}if(S=(ft-((bt|0)!=102?u:0)|0)-((bt|0)==103&(ft|0)!=0)|0,(S|0)<(We(k-z>>2,9)-9|0)){if(O=S+9216|0,K=(O|0)/9|0,et=((((et|0)<0?4:292)+Q|0)+(K<<2)|0)-4048|0,S=10,it=O+We(K,-9)|0,(it|0)<=7)for(;S=We(S,10),it=it+1|0,(it|0)!=8;);O=c[et>>2],lt=(O>>>0)/(S>>>0)|0,W=We(lt,S),K=et+4|0;i:{if((O|0)==(W|0)&(K|0)==(k|0))break i;O=O-W|0;e:{if(!(lt&1)&&(a=9007199254740992,!(gt[et-4|0]&1)|((S|0)!=1e9|P>>>0>=et>>>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,Tt[Mt|0]!=45|Ft||(Z=-Z,a=-a),c[et>>2]=W,a+Z==a)break i;if(u=S+W|0,c[et>>2]=u,u>>>0>=1e9)for(;c[et>>2]=0,et=et-4|0,et>>>0<P>>>0&&(P=P-4|0,c[P>>2]=0),u=c[et>>2]+1|0,c[et>>2]=u,u>>>0>999999999;);if(u=We(z-P>>2,9),S=10,K=c[P>>2],K>>>0<10)break i;for(;u=u+1|0,S=We(S,10),K>>>0>=S>>>0;);}S=et+4|0,k=k>>>0>S>>>0?S:k}for(;K=k,O=k>>>0<=P>>>0,!O&&(k=K-4|0,!c[k>>2]););i:{if((bt|0)!=103){et=y&8;break i}if(S=ft||1,k=(S|0)>(u|0)&(u|0)>-5,ft=(k?u^-1:-1)+S|0,b=(k?-1:-2)+b|0,et=y&8,et)break i;k=-9;e:{if(O||(et=c[K-4>>2],!et)||(it=10,k=0,(et>>>0)%10|0))break e;for(;S=k,k=k+1|0,it=We(it,10),!((et>>>0)%(it>>>0)|0););k=S^-1}if(S=We(K-z>>2,9),(b&-33)==70){et=0,k=(k+S|0)-9|0,k=(k|0)>0?k:0,ft=(k|0)>(ft|0)?ft:k;break i}et=0,k=((u+S|0)+k|0)-9|0,k=(k|0)>0?k:0,ft=(k|0)>(ft|0)?ft:k}if(it=-1,O=et|ft,((O?2147483645:2147483646)|0)<(ft|0))break t;W=(((O|0)!=0)+ft|0)+1|0,S=b&-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=Hn((k^u)-k|0,0,vt),(vt-k|0)<=1)for(;k=k-1|0,gt[k|0]=48,(vt-k|0)<2;);if(lt=k-2|0,gt[lt|0]=b,gt[k-1|0]=(u|0)<0?45:43,k=vt-lt|0,(k|0)>(W^2147483647))break t}if(u=k+W|0,(u|0)>(ot^2147483647))break t;W=u+ot|0,ki(r,32,h,W,y),gi(r,Mt,ot),ki(r,48,h,W,y^65536);i:{e:{s:{if((S|0)==70){for(b=Q+16|0,u=b|8,et=b|9,S=P>>>0>z>>>0?z:P,P=S;;){k=Hn(c[P>>2],0,et);n:{if((S|0)!=(P|0)){if(Q+16>>>0>=k>>>0)break n;for(;k=k-1|0,gt[k|0]=48,Q+16>>>0<k>>>0;);break n}if((k|0)!=(et|0))break n;gt[Q+24|0]=48,k=u}if(gi(r,k,et-k|0),P=P+4|0,!(z>>>0>=P>>>0))break}if(O&&gi(r,4275,1),(ft|0)<=0|P>>>0>=K>>>0)break s;for(;;){if(k=Hn(c[P>>2],0,et),k>>>0>Q+16>>>0)for(;k=k-1|0,gt[k|0]=48,Q+16>>>0<k>>>0;);if(gi(r,k,(ft|0)>=9?9:ft),k=ft-9|0,P=P+4|0,K>>>0<=P>>>0)break e;if(u=(ft|0)>9,ft=k,!u)break}break e}n:{if((ft|0)<0)break n;for(z=P>>>0<K>>>0?K:P+4|0,b=Q+16|0,u=b|8,K=b|9,S=P;;){k=Hn(c[S>>2],0,K),(K|0)==(k|0)&&(gt[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,gt[k|0]=48,Q+16>>>0<k>>>0;);break a}if(gi(r,k,1),k=k+1|0,!(et|ft))break a;gi(r,4275,1)}if(b=K-k|0,gi(r,k,(b|0)>(ft|0)?ft:b),ft=ft-b|0,S=S+4|0,z>>>0<=S>>>0)break n;if(!((ft|0)>=0))break}}ki(r,48,ft+18|0,18,0),gi(r,lt,vt-lt|0);break i}k=ft}ki(r,48,k+9|0,9,0)}ki(r,32,h,W,y^8192),it=(h|0)<(W|0)?W:h;break t}et=(b<<26>>31&9)+Mt|0;r:{if(u>>>0>11)break r;for(k=12-u|0,Z=16;Z=Z*16,k=k-1|0,!!k;);if(Tt[et|0]==45){a=-(Z+(-a-Z));break r}a=a+Z-Z}for(z=ot|2,P=b&32,S=c[Q+44>>2],k=S>>31,k=Hn((k^S)-k|0,0,vt),(vt|0)==(k|0)&&(gt[Q+15|0]=48,k=Q+15|0),ft=k-2|0,gt[ft|0]=b+15,gt[k-1|0]=(S|0)<0?45:43,k=y&8,S=Q+16|0;b=S,Xe(a)<2147483648?K=~~a:K=-2147483648,gt[S|0]=P|Tt[K+5504|0],a=(a-+(K|0))*16,S=b+1|0,!(k|(u|0)>0)&a==0|(S-(Q+16|0)|0)!=1||(gt[b+1|0]=46,S=b+2|0),a!=0;);if(it=-1,k=vt-ft|0,b=k+z|0,(2147483645-b|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}b=u+b|0,ki(r,32,h,b,y),gi(r,et,z),ki(r,48,h,b,y^65536),gi(r,Q+16|0,P),ki(r,48,u-P|0,0,0),gi(r,ft,k),ki(r,32,h,b,y^8192),it=(h|0)<(b|0)?b:h}return kt=Q+560|0,it|0}function Cp(r,a,h,u,y,b,k){var S=0,P=0,K=0,et=0,ft=0,Q=0,it=0,O=0,W=0,z=0,Z=0,ot=0,lt=0,vt=0,bt=0,Ct=0,Mt=0,Ft=0,Ht=0,qt=0;K=kt-80|0,kt=K,c[K+76>>2]=a,Ft=K+55|0,lt=K+56|0;t:{r:{i:{e:{s:for(;;){if(et=a,(W^2147483647)<(S|0))break e;W=S+W|0;n:{a:{o:{if(S=et,P=Tt[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(Tt[P+1|0]!=37){a=P;break c}if(S=S+1|0,ft=Tt[P+2|0],a=P+2|0,P=a,(ft|0)!=37)break}}if(S=S-et|0,Mt=W^2147483647,(S|0)>(Mt|0))break e;if(r&&gi(r,et,S),S)continue s;c[K+76>>2]=a,S=a+1|0,Z=-1,P=gt[a+1|0],!gl(P)|Tt[a+2|0]!=36||(Z=P-48|0,vt=1,S=a+3|0),c[K+76>>2]=S,O=0,P=gt[S|0],a=P-32|0;c:{if(a>>>0>31){ft=S;break c}if(ft=S,a=1<<a,!(a&75913))break c;for(;;){if(ft=S+1|0,c[K+76>>2]=ft,O=a|O,P=gt[S+1|0],a=P-32|0,a>>>0>=32)break c;if(S=ft,a=1<<a,!(a&75913))break}}c:{if((P|0)==42){a=gt[ft+1|0];h:{if(!(!gl(a)|Tt[ft+2|0]!=36)){c[((a<<2)+y|0)-192>>2]=10,P=ft+3|0,vt=1,z=c[((gt[ft+1|0]<<3)+u|0)-384>>2];break h}if(vt)break o;if(P=ft+1|0,!r){c[K+76>>2]=P,vt=0,z=0;break c}a=c[h>>2],c[h>>2]=a+4,vt=0,z=c[a>>2]}if(c[K+76>>2]=P,(z|0)>=0)break c;z=0-z|0,O=O|8192;break c}if(z=Qp(K+76|0),(z|0)<0)break e;P=c[K+76>>2]}S=0,it=-1;c:{if(Tt[P|0]!=46){a=P,ot=0;break c}if(Tt[P+1|0]==42){a=gt[P+2|0];h:{if(!(!gl(a)|Tt[P+3|0]!=36)){c[((a<<2)+y|0)-192>>2]=10,a=P+4|0,it=c[((gt[P+2|0]<<3)+u|0)-384>>2];break h}if(vt)break o;if(a=P+2|0,it=0,!r)break h;P=c[h>>2],c[h>>2]=P+4,it=c[P>>2]}c[K+76>>2]=a,ot=(it^-1)>>>31|0;break c}c[K+76>>2]=P+1,it=Qp(K+76|0),a=c[K+76>>2],ot=1}for(;;){if(Q=S,ft=28,bt=a,S=gt[a|0],S-123>>>0<4294967238)break i;if(a=bt+1|0,S=Tt[(S+We(Q,58)|0)+4975|0],!(S-1>>>0<8))break}c[K+76>>2]=a;c:{h:{if((S|0)!=27){if(!S)break i;if((Z|0)>=0){c[(Z<<2)+y>>2]=S,S=(Z<<3)+u|0,P=c[S+4>>2],c[K+64>>2]=c[S>>2],c[K+68>>2]=P;break h}if(!r)break n;Np(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,Ct=1167,ft=lt;c:{h:{f:{d:{p:{v:{y:{u:{g:{b:{m:{T:{k:{A:{w:{E:switch(S=gt[bt|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=c[K+64>>2],Q=c[K+68>>2],S=1167;break g}S=0;A:switch(Q&255){case 0:c[c[K+64>>2]>>2]=W;continue s;case 1:c[c[K+64>>2]>>2]=W;continue s;case 2:et=c[K+64>>2],c[et>>2]=W,c[et+4>>2]=W>>31;continue s;case 3:Wr[c[K+64>>2]>>1]=W;continue s;case 4:gt[c[K+64>>2]]=W;continue s;case 6:c[c[K+64>>2]>>2]=W;continue s;case 7:break A;default:continue s}et=c[K+64>>2],c[et>>2]=W,c[et+4>>2]=W>>31;continue s}it=it>>>0<=8?8:it,O=O|8,S=120}if(et=lt,P=c[K+64>>2],Q=c[K+68>>2],P|Q)for(Ht=S&32;et=et-1|0,gt[et|0]=Ht|Tt[(P&15)+5504|0],qt=!Q&P>>>0>15|(Q|0)!=0,bt=Q,Q=Q>>>4|0,P=(bt&15)<<28|P>>>4,!!qt;);if(!(O&8)|!(c[K+64>>2]|c[K+68>>2]))break u;Ct=(S>>>4|0)+1167|0,Z=2;break u}if(S=lt,et=c[K+68>>2],Q=et,P=c[K+64>>2],et|P)for(;S=S-1|0,gt[S|0]=P&7|48,bt=!Q&P>>>0>7|(Q|0)!=0,et=Q,Q=et>>>3|0,P=(et&7)<<29|P>>>3,!!bt;);if(et=S,!(O&8))break u;S=lt-et|0,it=(S|0)<(it|0)?it:S+1|0;break u}if(P=c[K+64>>2],S=c[K+68>>2],Q=S,(S|0)<0){et=0-(Q+((P|0)!=0)|0)|0,Q=et,P=0-P|0,c[K+64>>2]=P,c[K+68>>2]=et,Z=1,S=1167;break g}if(O&2048){Z=1,S=1168;break g}Z=O&1,S=Z?1169:1167}Ct=S,et=Hn(P,Q,lt)}if((it|0)<0&&ot)break e;if(O=ot?O&-65537:O,S=c[K+64>>2],P=c[K+68>>2],!((S|P)!=0|it)){et=lt,it=0;break a}S=!(S|P)+(lt-et|0)|0,it=(S|0)<(it|0)?it:S;break a}O=0,ot=it>>>0>=2147483647?2147483647:it,Q=ot,ft=(Q|0)!=0;y:{u:{S=c[K+64>>2],et=S||4277,S=et;g:{b:{m:{if(!(S&3)|!Q)break m;for(;;){if(O=Tt[S|0],!O)break b;if(Q=Q-1|0,ft=(Q|0)!=0,S=S+1|0,!(S&3))break m;if(!Q)break}}if(!ft)break u;m:{if(!(!Tt[S|0]|Q>>>0<4))for(;;){if(ft=c[S>>2],(ft^-1)&ft-16843009&-2139062144)break m;if(S=S+4|0,Q=Q-4|0,!(Q>>>0>3))break}if(!Q)break u}ft=0;break g}ft=1}for(;;){if(!ft){O=Tt[S|0],ft=1;continue}if(!O)break y;if(S=S+1|0,Q=Q-1|0,!Q)break u;ft=0}}S=0}if(S=S?S-et|0:ot,ft=S+et|0,(it|0)>=0){O=P,it=S;break a}if(O=P,it=S,Tt[ft|0])break e;break a}if(it){P=c[K+64>>2];break d}S=0,ki(r,32,z,0,O);break f}c[K+12>>2]=0,c[K+8>>2]=c[K+64>>2],P=K+8|0,c[K+64>>2]=P,it=-1}S=0;d:{for(;;){if(et=c[P>>2],!et)break d;if(et=r2(K+4|0,et),ft=(et|0)<0,!(ft|et>>>0>it-S>>>0)){if(P=P+4|0,S=S+et|0,it>>>0>S>>>0)continue;break d}break}if(ft)break r}if(ft=61,(S|0)<0)break i;if(ki(r,32,z,S,O),!S){S=0;break f}for(ft=0,P=c[K+64>>2];;){if(et=c[P>>2],!et||(et=r2(K+4|0,et),ft=et+ft|0,ft>>>0>S>>>0))break f;if(gi(r,K+4|0,et),P=P+4|0,!(S>>>0>ft>>>0))break}}ki(r,32,z,S,O^8192),S=(S|0)<(z|0)?z:S;continue s}if((it|0)<0&&ot)break e;if(ft=61,S=Pt[b|0](r,He[K+64>>3],z,it,O,S)|0,(S|0)>=0)continue s;break i}gt[K+55|0]=c[K+64>>2],it=1,et=Ft,O=P;break a}P=Tt[S+1|0],S=S+1|0}if(r)break t;if(!vt)break n;for(S=1;;){if(r=c[(S<<2)+y>>2],r){if(Np((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(c[(S<<2)+y>>2])break o;if(S=S+1|0,(S|0)==10)break}break t}ft=28;break i}if(Q=ft-et|0,it=(it|0)>(Q|0)?it:Q,(it|0)>(Z^2147483647))break e;if(ft=61,P=it+Z|0,S=(P|0)<(z|0)?z:P,(Mt|0)<(S|0))break i;ki(r,32,S,P,O),gi(r,Ct,Z),ki(r,48,S,P,O^65536),ki(r,48,it,Q,0),gi(r,et,Q),ki(r,32,S,P,O^8192);continue}break}W=0;break t}ft=61}c[1781]=ft}W=-1}return kt=K+80|0,W}function oT(r,a,h,u){r=r|0,a=+a,h=+h,u=u|0;var y=m(0),b=m(0),k=0,S=m(0),P=0,K=m(0),et=0,ft=m(0),Q=0;Q=kt+-64|0,kt=Q,k=c[r>>2],Hi(Q+8|0,0,56),c[1755]=c[1755]+1,xp(k),S=m(a),b=I[k+572>>2];t:{r:{i:switch(r=c[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=b,!(y<m(0)))break i;break r}e:{if(!((r|0)!=2|y!=y)){if(S!=S|b<m(0))break r;break e}y=m(zt);s:switch(r-1|0){case 1:break e;case 0:break s;default:break i}y=b;break i}y=m(m(b*S)*m(.009999999776482582))}ft=m(y+m(he(k,2,S)+Se(k,2,S))),et=1;break t}y=m(0),b=I[k+216>>2];r:{i:{r=c[k+216>>2];e:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;et=4336;n:{if((r|0)!=2141891242){if(b==b)break n;et=4344}switch(y=I[et>>2],c[et+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(b==b)break s;P=4344}switch(y=I[P>>2],ft=m(zt),et=2,c[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}ft=m(m(y*S)*m(.009999999776482582)),et=2;break t}et=S==S,ft=S;break t}et=2,ft=y}K=m(h),b=I[k+580>>2];t:{r:{i:switch(r=c[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=b,!(y<m(0)))break i;break r}e:{if(!((r|0)!=2|y!=y)){if(K!=K|b<m(0))break r;break e}y=m(zt);s:switch(r-1|0){case 1:break e;case 0:break s;default:break i}y=b;break i}y=m(m(b*K)*m(.009999999776482582))}b=m(y+m(he(k,0,S)+Se(k,0,S))),r=1;break t}y=m(0),b=I[k+220>>2];r:{i:{r=c[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(b==b)break n;P=4344}switch(y=I[P>>2],c[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(b==b)break s;P=4344}switch(y=I[P>>2],b=m(zt),r=2,c[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}b=m(m(y*K)*m(.009999999776482582)),r=2;break t}r=K==K,b=K;break t}r=2,b=y}gn(k,ft,b,u,et,r,S,K,1,0,c[k+568>>2],Q+8|0,0,c[1755])&&(Vp(k,Tt[k+300|0]&3,S,K,S),Up(k,+I[c[k+568>>2]+20>>2],0,0)),kt=Q- -64|0}function lT(r,a){r=r|0,a=a|0;var h=0,u=m(0),y=0,b=0,k=m(0),S=0,P=0,K=0,et=m(0);t:{P=c[a>>2],a=c[r>>2];r:{if((c[P+24>>2]^c[a+24>>2])&8388607)break r;et=I[P+40>>2],y=c[P+40>>2],u=I[a+40>>2];i:{e:{if(h=c[a+40>>2],(h|0)!=2139156720){if(k=m(zt),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(zt),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,et!=et)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(Xe(m(k-u)))<m(9999999747378752e-20))||(h=a+44|0,b=P+44|0,c[h>>2]!=c[b>>2]))break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break r}if(h=a+80|0,b=P+80|0,c[h>>2]!=c[b>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break r}if(h=a+116|0,b=P+116|0,c[h>>2]!=c[b>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break r}if(h=a+152|0,b=P+152|0,c[h>>2]!=c[b>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break r}if(h=a+188|0,b=P+188|0,c[h>>2]!=c[b>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==3)break i;if(S=r<<2,c[S+h>>2]!=c[b+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=c[r+S>>2],b=c[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|0))break r;for(S=P+208|0,K=a+208|0,r=0,y=1;;){i:{if(r=r<<2,h=c[r+S>>2],b=c[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|0))break r;for(S=P+216|0,K=a+216|0,r=0,y=1;;){i:{if(r=r<<2,h=c[r+S>>2],b=c[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|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(Vi(a+24|0,P+24|0,204);;){if(r=Tt[a+4|0],r&4)break t;if(gt[a+4|0]=r|4,r=c[a+20>>2],r&&Pt[r|0](a),c[a+308>>2]=2143289344,a=c[a+552>>2],!a)break}}}function cT(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,b=0,k=0,S=0,P=0,K=0,et=0,ft=0,Q=0,it=0,O=0,W=0,z=0,Z=0;h=a,a=c[a>>2]+7&-8,c[h>>2]=a+16,O=r,P=c[a>>2],u=c[a+4>>2],r=c[a+12>>2],Q=r,k=kt-32|0,kt=k,r=r&2147483647,S=r,y=r-1006698496|0,r=r-1140785152|0,h=c[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,it=S>>>16|0,it>>>0<15249))break t;a=P,r=u,y=Q&65535|65536,S=y,ft=h,b=h,K=it-15233|0;r:{if(K&64){h=a,y=K+-64|0,a=y&31,(y&63)>>>0>=32?(r=h<<a,b=0):(r=(1<<a)-1&h>>>32-a|r<<a,b=h<<a),y=r,a=0,r=0;break r}if(!K)break r;et=b,b=K&31,(K&63)>>>0>=32?(h=et<<b,b=0):(h=(1<<b)-1&et>>>32-b|y<<b,b=et<<b),y=h,W=b,et=a,h=64-K|0,b=h&31,(h&63)>>>0>=32?(h=0,a=r>>>b|0):(h=r>>>b|0,a=((1<<b)-1&r)<<32-b|et>>>b),b=W|a,y=h|y,a=K&31,(K&63)>>>0>=32?(h=et<<a,a=0):(h=(1<<a)-1&et>>>32-a|r<<a,a=et<<a),r=h}c[k+16>>2]=a,c[k+20>>2]=r,c[k+24>>2]=b,c[k+28>>2]=y,a=15361-it|0;r:{if(a&64){u=ft,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,ft=0,S=0;break r}if(!a)break r;y=ft,r=64-a|0,h=r&31,(r&63)>>>0>=32?(r=y<<h,b=0):(r=(1<<h)-1&y>>>32-h|S<<h,b=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=b|y,u=r|h,y=ft,h=a&31,(a&63)>>>0>=32?(r=0,ft=S>>>h|0):(r=S>>>h|0,ft=((1<<h)-1&S)<<32-h|y>>>h),S=r}if(c[k>>2]=P,c[k+4>>2]=u,c[k+8>>2]=ft,c[k+12>>2]=S,a=c[k+8>>2],r=c[k+12>>2]<<4|a>>>28,a=a<<4,h=c[k>>2],S=c[k+4>>2],a=S>>>28|a,u=S&268435455,h=h|(c[k+16>>2]|c[k+24>>2]|(c[k+20>>2]|c[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}kt=k+32|0,Dt(0,a|0),Dt(1,Q&-2147483648|r),z=O,Z=+Ee(),He[z>>3]=Z}function gn(r,a,h,u,y,b,k,S,P,K,et,ft,Q,it){var O=m(0),W=0,z=0,Z=0,ot=0,lt=m(0),vt=0,bt=0,Ct=m(0);t:{if(!(c[r+312>>2]!=(it|0)&&Tt[r+4|0]&4)&&(ot=0,c[r+316>>2]==(u|0)))break t;c[r+540>>2]=-1082130432,c[r+544>>2]=-1082130432,c[r+532>>2]=0,c[r+536>>2]=0,c[r+524>>2]=-1082130432,c[r+528>>2]=-1082130432,c[r+320>>2]=0,ot=1}vt=Q+1|0;t:{r:{i:{e:{if(c[r+8>>2]){if(lt=he(r,2,k),Ct=Se(r,2,k),O=m(he(r,0,k)+Se(r,0,k)),Q=r+524|0,lt=m(lt+Ct),Pp(y,a,b,h,c[r+532>>2],I[Q>>2],c[r+536>>2],I[r+528>>2],I[r+540>>2],I[r+544>>2],lt,O,et))break i;if(z=c[r+320>>2],!z)break e;for(W=r+324|0;;){if(Q=W+We(Z,24)|0,Pp(y,a,b,h,c[Q+8>>2],I[Q>>2],c[Q+12>>2],I[Q+4>>2],I[Q+16>>2],I[Q+20>>2],lt,O,et))break i;if(Z=Z+1|0,(z|0)==(Z|0))break}break e}if(!P){if(bt=c[r+320>>2],!bt)break e;for(z=r+324|0;;){W=We(Z,24),Q=W+z|0,O=I[Q>>2];s:{n:{if(!(O!=O|a!=a)){if(m(Xe(m(O-a)))<m(9999999747378752e-20))break n;break s}if(O==O|a==a)break s}W=z+W|0,O=I[W+4>>2];n:{if(!(O!=O|h!=h)){if(m(Xe(m(O-h)))<m(9999999747378752e-20))break n;break s}if(O==O|h==h)break s}if(c[W+8>>2]!=(y|0))break s;if(c[W+12>>2]==(b|0))break i}if(Z=Z+1|0,(bt|0)==(Z|0))break}break e}Q=r+524|0,O=I[Q>>2];s:{if(!(O!=O|a!=a)){if(m(Xe(m(O-a)))<m(9999999747378752e-20))break s;break e}if(O==O|a==a)break e}W=c[r+532>>2]==(y|0)&&c[r+536>>2]==(b|0)?Q:0,O=I[r+528>>2],Q=O!=O,z=h!=h;s:{if(Q|z){Q=Q&z;break s}Q=m(Xe(m(O-h)))<m(9999999747378752e-20)}Q=Q?W:0;break i}Lp(r,a,h,u,y,b,k,S,P,et,ft,vt,it,K),c[r+316>>2]=u;break r}if(!(!Q|ot)){I[r+516>>2]=I[Q+16>>2],I[r+520>>2]=I[Q+20>>2],u=(P?12:16)+ft|0,c[u>>2]=c[u>>2]+1;break t}if(Lp(r,a,h,u,y,b,k,S,P,et,ft,vt,it,K),c[r+316>>2]=u,Q)break t}Q=c[r+320>>2],u=Q+1|0,u>>>0>Ap[ft+8>>2]&&(c[ft+8>>2]=u),(Q|0)==8&&(c[r+320>>2]=0,Q=0),P?u=r+524|0:(c[r+320>>2]=Q+1,u=(We(Q,24)+r|0)+324|0),c[u+12>>2]=b,c[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=c[r+520>>2],c[r+244>>2]=c[r+516>>2],c[r+248>>2]=u,u=Tt[r+4|0],y=u|1,gt[r+4|0]=y,!(u&4)))break t;gt[r+4|0]=y&251}return c[r+312>>2]=it,!Q|ot}function Ph(r){r=r|0;var a=0,h=0,u=0,y=0,b=0,k=0,S=0,P=0,K=0,et=0,ft=0;S=8;t:{if(r>>>0>4294967239)break t;r:{for(;;){S=S>>>0<=8?8:S,a=c[1751],b=a,y=c[1750],r=r>>>0<=8?8:r+3&-4;i:{if(r>>>0<=127){k=(r>>>3|0)-1|0;break i}if(u=Er(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,b=h,h=a-1|0,b=(h|0)!=-1?P:b,u=Er(u^b),u=(u|0)==32?Er(a^h)+32|0:u,h=63-u|0,Gi=0-(u>>>0>63)|0;break i}Gi=0,h=64}b=h,h=b&31,(b&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=b+k|0,h=k<<4,a=c[h+5976>>2],b=h+5968|0;i:{if((a|0)!=(b|0)){if(y=$h(a,S,r),y)break t;y=c[a+4>>2],c[y+8>>2]=c[a+8>>2],c[c[a+8>>2]+4>>2]=y,c[a+8>>2]=b,y=h+5972|0,c[a+4>>2]=c[y>>2],c[y>>2]=a,c[c[a+4>>2]+8>>2]=a,k=k+1|0,a=(u&1)<<31|P>>>1,u=u>>>1|0;break i}K=c[1751],b=k&63,a=b,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=b&31,b>>>0>=32?(a=h<<y,h=0):(a=(1<<y)-1&h>>>32-y|a<<y,h=h<<y),et=h,y=a,b=0-k&63,h=b,a=h&31,h>>>0>=32?(a=-1<<a,h=0):(h=-1<<a,a=h|(1<<a)-1&-1>>>32-a),ft=h&-2,h=b&31,b>>>0>=32?(b=0,a=a>>>h|0):(b=a>>>h|0,a=((1<<h)-1&a)<<32-h|ft>>>h),a=a|et,Gi=y|b,c[1750]=c[1750]&a,c[1751]=Gi&K,a=P^1}if(!(a|u))break}b=c[1751],y=c[1750]}i:{if(y|b){u=Er(b),h=63-((u|0)==32?Er(y)+32|0:u)|0,a=h<<4,u=c[a+5976>>2];e:{if(!b&y>>>0<1073741824||(k=99,a=a+5968|0,(a|0)==(u|0)))break e;for(;;){if(!k)break e;if(y=$h(u,S,r),y)break t;if(k=k-1|0,u=c[u+8>>2],(a|0)==(u|0))break}u=a}if(Mh(r+48|0))break i;if(!u||(a=(h<<4)+5968|0,(a|0)==(u|0)))break r;for(;;){if(y=$h(u,S,r),y)break t;if(u=c[u+8>>2],(a|0)==(u|0))break}break r}if(!Mh(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 hT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0,P=0,K=0,et=0,ft=0,Q=0;S=kt-80|0,kt=S,r=c[r>>2];t:{r:{if(P=c[a>>2],!c[P+552>>2]){if(c[r+8>>2])break r;a=c[r+556>>2],k=a+(h<<2)|0,u=c[r+560>>2],y=r+564|0,b=c[y>>2];i:{if(u>>>0<b>>>0){if((u|0)==(k|0)){c[k>>2]=P,c[r+560>>2]=k+4;break i}if(h=u,a=u-4|0,u>>>0>a>>>0)for(;c[h>>2]=c[a>>2],h=h+4|0,a=a+4|0,u>>>0>a>>>0;);c[r+560>>2]=h,a=k+4|0,(a|0)!=(u|0)&&(a=u-a|0,Ns(u-(a&-4)|0,k,a)),c[k>>2]=P;break i}if(u=(u-a>>2)+1|0,u>>>0>=1073741824)break t;a=b-a|0,b=a>>1,y=Ha(S+32|0,a>>>0>=2147483644?1073741823:u>>>0<b>>>0?b:u,h,y),h=c[y+8>>2];e:{if((h|0)!=c[y+12>>2])break e;if(a=c[y+4>>2],u=c[y>>2],a>>>0>u>>>0){u=((a-u>>2)+1|0)/-2<<2,K=u+a|0,b=a,a=h-a|0,h=Ns(K,b,a)+a|0,c[y+8>>2]=h,c[y+4>>2]=u+c[y+4>>2];break e}a=(h|0)==(u|0)?1:h-u>>1,b=Ha(S+56|0,a,a>>>2|0,c[y+16>>2]),u=c[b+8>>2],a=c[y+4>>2],h=c[y+8>>2];s:{if((a|0)==(h|0)){h=u,u=a;break s}for(h=(h-a|0)+u|0;c[u>>2]=c[a>>2],a=a+4|0,u=u+4|0,(u|0)!=(h|0););a=c[y+8>>2],u=c[y+4>>2]}if(K=c[y>>2],c[y>>2]=c[b>>2],c[b>>2]=K,c[y+4>>2]=c[b+4>>2],c[b+4>>2]=u,c[y+8>>2]=h,c[b+8>>2]=a,et=c[y+12>>2],c[y+12>>2]=c[b+12>>2],c[b+12>>2]=et,(a|0)!=(u|0)&&(c[b+8>>2]=((u-a|0)+3&-4)+a),!K)break e;Ti(K),h=c[y+8>>2]}if(c[h>>2]=P,c[y+8>>2]=c[y+8>>2]+4,a=c[r+556>>2],h=k-a|0,ft=y,Q=Ns(c[y+4>>2]-h|0,a,h),c[ft+4>>2]=Q,u=c[r+560>>2]-k|0,k=Ns(c[y+8>>2],k,u),a=c[r+556>>2],c[r+556>>2]=c[y+4>>2],c[y+4>>2]=a,h=c[r+560>>2],c[r+560>>2]=u+k,c[y+8>>2]=h,u=c[r+564>>2],c[r+564>>2]=c[y+12>>2],c[y>>2]=a,c[y+12>>2]=u,(a|0)!=(h|0)&&(c[y+8>>2]=h+((a-h|0)+3&-4)),!a)break i;Ti(a)}for(c[P+552>>2]=r;a=Tt[r+4|0],!!(!(a&4)&&(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],r)););kt=S+80|0;return}c[S+16>>2]=4075,lr(r,S+16|0),tr(),ce()}c[S>>2]=4208,lr(r,S),tr(),ce()}Fs(),ce()}function Ip(r,a){var h=0,u=0;for(c[r>>2]=0,c[r+8>>2]=0,c[r+12>>2]=0,c[r+16>>2]=0,c[r+20>>2]=0,c[r+24>>2]=0,c[r+36>>2]=2143289344,c[r+40>>2]=2141891242,c[r+28>>2]=2143289344,c[r+32>>2]=2143289344,gt[r+4|0]=Tt[r+4|0]&128,u=Hi(r+44|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Hi(r+80|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Hi(r+116|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Hi(r+152|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,c[r+196>>2]=0,u=r+188|0,c[u>>2]=0,c[u+4>>2]=0;c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=3;);for(c[r+24>>2]=4224,c[r+224>>2]=2143289344,c[r+216>>2]=2143289344,c[r+220>>2]=2143289344,c[r+208>>2]=2143289344,c[r+212>>2]=2143289344,c[r+200>>2]=2141891242,c[r+204>>2]=2141891242,Hi(r+228|0,0,288),c[r+244>>2]=2143289344,c[r+248>>2]=2143289344,Hi(r+252|0,0,49),c[r+308>>2]=2143289344,u=r+516|0,h=r+324|0;c[h+16>>2]=-1082130432,c[h+20>>2]=-1082130432,c[h+8>>2]=0,c[h+12>>2]=0,c[h>>2]=-1082130432,c[h+4>>2]=-1082130432,h=h+24|0,(u|0)!=(h|0););return c[r+548>>2]=0,c[r+552>>2]=0,c[r+516>>2]=2143289344,c[r+520>>2]=2143289344,c[r+572>>2]=2143289344,c[r+576>>2]=0,c[r+568>>2]=a,c[r+540>>2]=-1082130432,c[r+544>>2]=-1082130432,c[r+532>>2]=0,c[r+536>>2]=0,c[r+524>>2]=-1082130432,c[r+528>>2]=-1082130432,c[r+556>>2]=0,c[r+560>>2]=0,c[r+564>>2]=0,c[r+580>>2]=2143289344,c[r+584>>2]=0,c2((a|0)!=0,2760),gt[r+4|0]=Tt[r+4|0]|1,gt[a+8|0]&1&&(c[r+24>>2]=c[r+24>>2]&-909|520),r}function Ze(r,a,h,u){var y=m(0),b=m(0),k=0,S=m(0);t:{r:{i:{e:{s:{n:{if(a>>>0<=1){b=I[r+212>>2],a=c[r+212>>2];a:{if((a|0)==2139156720)break a;if((a|0)==2140081935)break n;k=4336;o:{if((a|0)!=2141891242){if(b==b)break o;k=4344}switch(y=I[k>>2],b=m(zt),c[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}b=m(m(y*u)*m(.009999999776482582));break s}b=I[r+208>>2];a:{o:{a=c[r+208>>2];l:{if((a|0)==2139156720)break l;if((a|0)==2140081935)break o;k=4336;c:{if((a|0)!=2141891242){if(b==b)break c;k=4344}switch(y=I[k>>2],b=m(zt),c[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}b=m(m(y*u)*m(.009999999776482582));break a}b=y}y=m(0),S=I[r+216>>2],r=c[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],c[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}b=y}y=m(0),S=I[r+220>>2],r=c[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],c[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(!(b>=m(0)))return h;y=h<b?b:h}return y}function xp(r){var a=0,h=0,u=m(0),y=m(0),b=m(0),k=0,S=0,P=0,K=0,et=0,ft=0,Q=0,it=0,O=0;for(k=kt-16|0,c[k+8>>2]=0,c[k+12>>2]=1,et=r+200|0,ft=r+572|0,Q=r+208|0,it=r+216|0,r=0;;){O=r,K=c[(k+8|0)+(r<<2)>>2],S=K<<2,r=it+S|0,u=I[r>>2];t:{r:{i:{e:{s:{n:{if(a=c[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=c[r>>2];a:{o:{if((h|0)!=2139156720){if(b=m(zt),r=3,(h|0)==2141891242)break a;if((h|0)!=2140081935)break o;b=m(0),r=1;break a}b=m(0),r=2;break a}if(r=0,y!=y)break a;b=(Dt(2,(h&-1073741825)+536870912|0),Bt()),r=h&1073741824?2:1}h=r;a:{o:{if(!P){if(y=m(zt),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&b!=b|m(Xe(m(y-b)))<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+et|0,u=I[a>>2],a=c[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)+ft|0,c[h+4>>2]=a,c[h>>2]=r,r=1,!!(O&1))break}}function Vi(r,a,h){var u=0,y=0,b=0;if(h>>>0>=512)return tT(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(gt[h|0]=Tt[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||(b=u+-64|0,b>>>0<h>>>0))break r;for(;c[h>>2]=c[a>>2],c[h+4>>2]=c[a+4>>2],c[h+8>>2]=c[a+8>>2],c[h+12>>2]=c[a+12>>2],c[h+16>>2]=c[a+16>>2],c[h+20>>2]=c[a+20>>2],c[h+24>>2]=c[a+24>>2],c[h+28>>2]=c[a+28>>2],c[h+32>>2]=c[a+32>>2],c[h+36>>2]=c[a+36>>2],c[h+40>>2]=c[a+40>>2],c[h+44>>2]=c[a+44>>2],c[h+48>>2]=c[a+48>>2],c[h+52>>2]=c[a+52>>2],c[h+56>>2]=c[a+56>>2],c[h+60>>2]=c[a+60>>2],a=a- -64|0,h=h- -64|0,b>>>0>=h>>>0;);}if(h>>>0>=u>>>0)break t;for(;c[h>>2]=c[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;gt[h|0]=Tt[a|0],gt[h+1|0]=Tt[a+1|0],gt[h+2|0]=Tt[a+2|0],gt[h+3|0]=Tt[a+3|0],a=a+4|0,h=h+4|0,u>>>0>=h>>>0;);}if(h>>>0<y>>>0)for(;gt[h|0]=Tt[a|0],a=a+1|0,h=h+1|0,(y|0)!=(h|0););return r}function Dp(r,a,h,u,y){var b=m(0),k=0,S=m(0),P=m(0),K=0,et=0,ft=m(0),Q=m(0),it=0;if(S=m(h-u),et=S!=S,!et){h=m(0),k=(a<<2)+r|0,b=I[k+208>>2];t:{r:{k=c[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(b==b)break s;K=4344}switch(h=I[K>>2],c[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,b=I[r+216>>2];t:{r:{a=c[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(b==b)break s;r=4344}switch(h=I[r>>2],b=m(34028234663852886e22),c[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;b=m(34028234663852886e22);break t}b=m(h-u)}if(h=(ft=S,Q=Gh(S,b),it=b!=b|et,it?ft:Q),r=h!=h,!(r|P!=P))return oe(h,P);S=r?P:h}return S}function Pp(r,a,h,u,y,b,k,S,P,K,et,ft,Q){var it=m(0),O=m(0),W=0,z=0,Z=m(0),ot=m(0),lt=m(0),vt=0,bt=0;if(P<m(0)|K<m(0))r=0;else{Z=b,ot=a,lt=u,O=S;t:{if(!Q||(it=I[Q+20>>2],O=S,it==m(0)))break t;vt=+it,ot=Yr(+a,vt,0,0),lt=Yr(+u,vt,0,0),Z=Yr(+b,vt,0,0),O=Yr(+S,vt,0,0)}it=O,Q=0;t:{if((r|0)!=(y|0))break t;if(bt=Z!=Z,Q=ot!=ot,bt|Q){Q=Q&bt;break t}Q=m(Xe(m(Z-ot)))<m(9999999747378752e-20)}bt=Q;t:{if((h|0)!=(k|0))break t;if(W=it!=it,Q=lt!=lt,W|Q){W=Q&W;break t}W=m(Xe(m(it-lt)))<m(9999999747378752e-20)}z=1,Q=1;t:{if(bt)break t;a=m(a-et);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<b)|(r|(y|0)!=2|(a!=a|b!=b|P!=P))||(Q=1,a>=P))break t}if(y=a!=a,r=P!=P,y|r){Q=r&y;break t}Q=m(Xe(m(a-P)))<m(9999999747378752e-20)}t:{if(W)break t;a=m(u-ft);r:{if((h|0)==1)break r;if(r=(h|0)!=2,!(r|k)){if(!(a>=K))break r;break t}if(z=0,!(a<S)|(r|(k|0)!=2|(a!=a|S!=S|K!=K))||(z=1,a>=K))break t}if(h=a!=a,r=K!=K,h|r){z=r&h;break t}z=m(Xe(m(a-K)))<m(9999999747378752e-20)}r=Q&z}return r}function Oh(r){var a=0,h=0,u=0,y=0,b=0,k=0,S=0,P=0;if(Ei(+r),b=te(1)|0,u=te(0)|0,y=b>>>20&2047,(y|0)==2047)return r=r*1,r/r;if(a=u<<1,k=b<<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=b<<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|b<<h,u=u<<h);break t}a=b&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=b&-2147483648,k=a+-1048576|y<<20,S=h,b=a,S=h,u=1-y|0,h=u&31,(u&63)>>>0>=32?(a=0,u=b>>>h|0):(a=b>>>h|0,u=((1<<h)-1&b)<<32-h|S>>>h),h=(y|0)>0,Dt(0,(h?S:u)|0),Dt(1,(h?k:a)|P),+Ee()}function Mh(r){var a=0,h=0,u=0,y=0,b=0;u=c[1416],a=r+7&-8,h=u+a|0;t:{r:{if(h>>>0<=u>>>0&&a||h>>>0>T2()<<16>>>0&&!(JE(h|0)|0))break r;c[1416]=h;break t}c[1781]=48,u=-1}if((u|0)!=-1){a=r+u|0,h=a-16|0,c[h+12>>2]=16,c[h>>2]=16,r=c[1748],r?b=c[r+8>>2]:b=0;t:{r:{if((b|0)==(u|0)){if(y=u-(c[u-4>>2]&-2)|0,b=c[y-4>>2],c[r+8>>2]=a,r=y-(b&-2)|0,a=-16,!(gt[(r+c[r>>2]|0)-4|0]&1))break r;a=c[r+4>>2],c[a+8>>2]=c[r+8>>2],c[c[r+8>>2]+4>>2]=a,h=h-r|0,c[r>>2]=h;break t}c[u+12>>2]=16,c[u>>2]=16,c[u+8>>2]=a,c[u+4>>2]=r,c[1748]=u,a=16}r=a+u|0,h=h-r|0,c[r>>2]=h}c[((h&-4)+r|0)-4>>2]=h|1,a=c[r>>2]-8|0;t:{if(a>>>0<=127){h=(a>>>3|0)-1|0;break t}if(y=Er(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,c[r+4>>2]=a+5968,a=a+5976|0,c[r+8>>2]=c[a>>2],c[a>>2]=r,c[c[r+8>>2]+4>>2]=r,a=c[1750],y=c[1751],r=h&31,(h&63)>>>0>=32?(h=1<<r,b=0):(b=1<<r,h=b-1&1>>>32-r),c[1750]=b|a,c[1751]=h|y}return(u|0)!=-1}function Op(r,a,h){var u=0,y=0,b=0,k=0,S=0,P=0,K=0,et=0,ft=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,Gi=0;break t}if(!r)break o;break a}if(!(h-1&h))break n;b=(Er(h)+33|0)-Er(a)|0,k=0-b|0;break e}r=(a>>>0)/0|0,Gi=0;break t}if(u=32-Er(a)|0,u>>>0<31)break s;break i}if((h|0)==1)break r;b=h?31-Er(h-1^h)|0:32,h=b&31,(b&63)>>>0>=32?r=a>>>h|0:(u=a>>>h|0,r=((1<<h)-1&a)<<32-h|r>>>h),Gi=u;break t}b=u+1|0,k=63-u|0}if(u=b&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),b)for(k=h-1|0,ft=(k|0)==-1?-1:0;P=u<<1|S>>>31,u=S<<1|a>>>31,y=ft-(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=et|r<<1,et=y&1,b=b-1|0,!!b;);Gi=a<<1|r>>>31,r=et|r<<1;break t}r=0,a=0}Gi=a}return r}function cl(r,a,h){var u=m(0),y=m(0);t:{r:{i:{if((a&-2)==2){if(a=c[r+188>>2],u=I[r+188>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=c[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=c[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=c[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(zt),c[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 Mp(r,a){var h=0,u=0,y=0,b=0,k=0,S=0;for(h=kt-320|0,kt=h,u=Hi(h,0,288),h=u,c[h+16>>2]=2143289344,c[h+20>>2]=2143289344,Hi(h+24|0,0,49),c[h+80>>2]=2143289344,b=h+288|0,y=h+96|0;h=y,c[h+16>>2]=-1082130432,c[h+20>>2]=-1082130432,c[h+8>>2]=0,c[h+12>>2]=0,c[h>>2]=-1082130432,c[h+4>>2]=-1082130432,y=h+24|0,(b|0)!=(y|0););if(c[u+312>>2]=-1082130432,c[u+316>>2]=-1082130432,c[u+304>>2]=0,c[u+308>>2]=0,c[u+296>>2]=-1082130432,c[u+300>>2]=-1082130432,c[u+288>>2]=2143289344,c[u+292>>2]=2143289344,Vi(r+228|0,u,320),c[r+244>>2]=0,c[r+248>>2]=0,gt[r+4|0]=Tt[r+4|0]|1,y=c[r+556>>2],k=c[r+560>>2],(y|0)!=(k|0))for(;h=c[y>>2],c[h+552>>2]!=(r|0)&&(b=c[r+568>>2],h=Gp(c[b>>2],Tt[b+8|0],h,r,S,a),c[y>>2]=h,c[h+552>>2]=r,h=c[y>>2]),Mp(h,a),S=S+1|0,y=y+4|0,(k|0)!=(y|0););kt=u+320|0}function $h(r,a,h){var u=0,y=0,b=0,k=0;if(u=r+4|0,y=(u+a|0)-1&0-a,a=c[r>>2],y+h>>>0<=(a+r|0)-4>>>0){b=c[r+4>>2],c[b+8>>2]=c[r+8>>2],c[c[r+8>>2]+4>>2]=b,(u|0)!=(y|0)&&(y=y-u|0,b=r-(c[r-4>>2]&-2)|0,u=y+c[b>>2]|0,c[b>>2]=u,c[(b+(u&-4)|0)-4>>2]=u,r=r+y|0,a=a-y|0,c[r>>2]=a);t:{if(h+24>>>0<=a>>>0){u=(r+h|0)+8|0,a=(a-h|0)-8|0,c[u>>2]=a,c[(u+(a&-4)|0)-4>>2]=a|1,y=c[u>>2]-8|0;r:{if(y>>>0<=127){a=(y>>>3|0)-1|0;break r}if(b=Er(y),a=((y>>>29-b^4)-(b<<2)|0)+110|0,y>>>0<=4095)break r;a=((y>>>30-b^2)-(b<<1)|0)+71|0,a=a>>>0>=63?63:a}y=a<<4,c[u+4>>2]=y+5968,y=y+5976|0,c[u+8>>2]=c[y>>2],c[y>>2]=u,c[c[u+8>>2]+4>>2]=u,y=c[1750],b=c[1751],u=a&31,(a&63)>>>0>=32?(a=1<<u,u=0):(k=1<<u,a=k-1&1>>>32-u,u=k),c[1750]=u|y,c[1751]=a|b,a=h+8|0,c[r>>2]=a,c[((a&-4)+r|0)-4>>2]=a;break t}c[(r+a|0)-4>>2]=a}r=r+4|0}else r=0;return r}function dT(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,b=0;y=kt-320|0,kt=y,r=c[r>>2];t:{if(c[r+560>>2]==c[r+556>>2]||(u=c[a>>2],a=c[u+552>>2],!Kp(r,u)))break t;if((r|0)==(a|0)){for(h=Hi(y,0,288),a=h,c[a+16>>2]=2143289344,c[a+20>>2]=2143289344,Hi(a+24|0,0,49),c[a+80>>2]=2143289344,b=a+288|0,a=a+96|0;c[a+16>>2]=-1082130432,c[a+20>>2]=-1082130432,c[a+8>>2]=0,c[a+12>>2]=0,c[a>>2]=-1082130432,c[a+4>>2]=-1082130432,a=a+24|0,(b|0)!=(a|0););c[h+312>>2]=-1082130432,c[h+316>>2]=-1082130432,c[h+304>>2]=0,c[h+308>>2]=0,c[h+296>>2]=-1082130432,c[h+300>>2]=-1082130432,c[h+288>>2]=2143289344,c[h+292>>2]=2143289344,Vi(u+228|0,h,320),c[u+552>>2]=0}for(;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}kt=y+320|0}function $p(r){r=r|0;var a=0,h=0,u=0,y=0,b=0,k=0,S=0;if(r){if(k=kt-32|0,kt=k,a=c[r>>2],u=c[a+552>>2],u&&(Kp(u,a),c[a+552>>2]=0),u=c[a+556>>2],h=c[a+560>>2],(u|0)!=(h|0))for(h=h-u>>2,y=h>>>0<=1?1:h,h=0;c[c[(h<<2)+u>>2]+552>>2]=0,h=h+1|0,(y|0)!=(h|0););c[a+560>>2]=u,h=a+564|0;t:{if(c[h>>2]==(u|0)||(h=Ha(k+8|0,0,0,h),y=c[a+556>>2],b=c[a+560>>2]-y|0,u=c[h+4>>2]-b|0,b=Ns(u,y,b),y=c[a+556>>2],c[a+556>>2]=b,c[h+4>>2]=y,b=c[a+560>>2],c[a+560>>2]=c[h+8>>2],c[h+8>>2]=b,S=c[a+564>>2],c[a+564>>2]=c[h+12>>2],c[h>>2]=y,c[h+12>>2]=S,(y|0)!=(b|0)&&(c[h+8>>2]=b+((y-b|0)+3&-4)),!y))break t;Ti(y),u=c[a+556>>2]}u&&(c[a+560>>2]=u,Ti(u)),Ti(a),a=c[r+8>>2],c[r+8>>2]=0,a&&Pt[c[c[a>>2]+4>>2]](a),a=c[r+4>>2],c[r+4>>2]=0,a&&Pt[c[c[a>>2]+4>>2]](a),kt=k+32|0,Ti(r)}}function uT(r){r=r|0;var a=0,h=0,u=0;u=kt-624|0,kt=u,a=c[r+4>>2],c[r+4>>2]=0,a&&Pt[c[c[a>>2]+4>>2]](a),a=c[r+8>>2],c[r+8>>2]=0,a&&Pt[c[c[a>>2]+4>>2]](a);t:{if(r=c[r>>2],c[r+560>>2]==c[r+556>>2]){if(c[r+552>>2])break t;a=Ip(u+32|0,c[r+568>>2]),h=c[a+4>>2],c[r>>2]=c[a>>2],c[r+4>>2]=h,h=c[a+20>>2],c[r+16>>2]=c[a+16>>2],c[r+20>>2]=h,h=c[a+12>>2],c[r+8>>2]=c[a+8>>2],c[r+12>>2]=h,Vi(r+24|0,a+24|0,204),Vi(r+228|0,a+228|0,328),h=c[r+556>>2],h&&(c[r+560>>2]=h,Ti(h)),c[r+556>>2]=c[a+556>>2],c[r+560>>2]=c[a+560>>2],c[r+564>>2]=c[a+564>>2],c[r+584>>2]=c[a+584>>2],h=c[a+580>>2],c[r+576>>2]=c[a+576>>2],c[r+580>>2]=h,h=c[a+572>>2],c[r+568>>2]=c[a+568>>2],c[r+572>>2]=h,kt=u+624|0;return}c[u+16>>2]=3301,lr(r,u+16|0),tr(),ce()}c[u>>2]=2047,lr(r,u),tr(),ce()}function Fp(){nT(7084,3067),sT(7085,2480,1,1,0),fs(7086,2140,1,-128,127),fs(7087,2133,1,-128,127),fs(7088,2131,1,0,255),fs(7089,1287,2,-32768,32767),fs(7090,1278,2,0,65535),fs(7091,1316,4,-2147483648,2147483647),fs(7092,1307,4,0,-1),fs(7093,2659,4,-2147483648,2147483647),fs(7094,2650,4,0,-1),p2(7095,1777,-2147483648,2147483647),p2(7096,1776,0,-1),kp(7097,1770,4),kp(7098,3015,8),wp(7099,2677),wp(7100,3904),Ih(7101,4,2664),Ih(7102,2,2689),Ih(7103,4,2704),rT(7104,2485),Ii(7105,0,3835),Ii(7106,0,3937),Ii(7107,1,3865),Ii(7108,2,3467),Ii(7109,3,3498),Ii(7110,4,3538),Ii(7111,5,3567),Ii(7112,4,3974),Ii(7113,5,4004),Ii(7106,0,3669),Ii(7107,1,3636),Ii(7108,2,3735),Ii(7109,3,3701),Ii(7110,4,3802),Ii(7111,5,3768),Ii(7114,6,3605),Ii(7115,7,4043)}function Ns(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 Vi(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(gt[u|0]=Tt[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,gt[u|0]=Tt[a+h|0],!(u&3))break}if(h>>>0<=3)break e;for(;h=h-4|0,c[h+r>>2]=c[a+h>>2],h>>>0>3;);}if(!h)break t;for(;h=h-1|0,gt[h+r|0]=Tt[a+h|0],!!h;);break t}if(h>>>0<=3)break r;for(;c[u>>2]=c[a>>2],a=a+4|0,u=u+4|0,h=h-4|0,h>>>0>3;);}if(!h)break t;for(;gt[u|0]=Tt[a|0],u=u+1|0,a=a+1|0,h=h-1|0,!!h;);}return r}function Np(r,a,h,u){t:switch(a-9|0){case 0:a=c[h>>2],c[h>>2]=a+4,c[r>>2]=c[a>>2];return;case 6:a=c[h>>2],c[h>>2]=a+4,a=Wr[a>>1],c[r>>2]=a,c[r+4>>2]=a>>31;return;case 7:a=c[h>>2],c[h>>2]=a+4,c[r>>2]=Bn[a>>1],c[r+4>>2]=0;return;case 8:a=c[h>>2],c[h>>2]=a+4,a=gt[a|0],c[r>>2]=a,c[r+4>>2]=a>>31;return;case 9:a=c[h>>2],c[h>>2]=a+4,c[r>>2]=Tt[a|0],c[r+4>>2]=0;return;case 16:a=c[h>>2]+7&-8,c[h>>2]=a+8,He[r>>3]=He[a>>3];return;case 17:Pt[u|0](r,h);default:return;case 1:case 4:case 14:a=c[h>>2],c[h>>2]=a+4,a=c[a>>2],c[r>>2]=a,c[r+4>>2]=a>>31;return;case 2:case 5:case 11:case 15:a=c[h>>2],c[h>>2]=a+4,c[r>>2]=c[a>>2],c[r+4>>2]=0;return;case 3:case 10:case 12:case 13:break t}a=c[h>>2]+7&-8,c[h>>2]=a+8,h=c[a+4>>2],c[r>>2]=c[a>>2],c[r+4>>2]=h}function Up(r,a,h,u){var y=0,b=0,k=0,S=0,P=0,K=0,et=0,ft=0,Q=0,it=m(0),O=m(0),W=m(0),z=0,Z=m(0);t:{if(a==0||(it=I[r+248>>2],O=I[r+244>>2],W=I[r+232>>2],P=+I[r+228>>2],y=Tt[r+4|0]&8,b=y>>>3|0,z=r,Z=Yr(P,a,0,b),I[z+228>>2]=Z,K=+W,z=r,Z=Yr(K,a,0,b),I[z+232>>2]=Z,et=+O,k=Oh(et*a),b=k==k&Xe(k)<1e-4,S=!(b|k!=k?b:Xe(k+-1)<1e-4),ft=+it,k=Oh(ft*a),b=k==k&Xe(k)<1e-4,Q=!(b|k!=k?b:Xe(k+-1)<1e-4),b=0,h=P+h,y=(y|0)!=0,z=r,Z=m(Yr(h+et,a,y&S,y&!S)-Yr(h,a,0,y)),I[z+244>>2]=Z,u=K+u,z=r,Z=m(Yr(u+ft,a,y&Q,y&!Q)-Yr(u,a,0,y)),I[z+248>>2]=Z,y=c[r+560>>2],S=c[r+556>>2],(y|0)==(S|0)))break t;for(y=y-S>>2,S=y>>>0<=1?1:y;y=c[r+556>>2],c[r+560>>2]-y>>2>>>0>b>>>0?y=c[y+(b<<2)>>2]:y=0,Up(y,a,h,u),b=b+1|0,(S|0)!=(b|0););}}function Hi(r,a,h){var u=0,y=0,b=0,k=0;t:{if(!h||(gt[r|0]=a,u=r+h|0,gt[u-1|0]=a,h>>>0<3)||(gt[r+2|0]=a,gt[r+1|0]=a,gt[u-3|0]=a,gt[u-2|0]=a,h>>>0<7)||(gt[r+3|0]=a,gt[u-4|0]=a,h>>>0<9)||(u=0-r&3,y=u+r|0,a=We(a&255,16843009),c[y>>2]=a,u=h-u&-4,h=u+y|0,c[h-4>>2]=a,u>>>0<9)||(c[y+8>>2]=a,c[y+4>>2]=a,c[h-8>>2]=a,c[h-12>>2]=a,u>>>0<25)||(c[y+24>>2]=a,c[y+20>>2]=a,c[y+16>>2]=a,c[y+12>>2]=a,c[h-16>>2]=a,c[h-20>>2]=a,c[h-24>>2]=a,c[h-28>>2]=a,k=y&4|24,h=u-k|0,h>>>0<32))break t;for(u=Bh(a,0,1,1),b=Gi,a=y+k|0;c[a+24>>2]=u,c[a+28>>2]=b,c[a+16>>2]=u,c[a+20>>2]=b,c[a+8>>2]=u,c[a+12>>2]=b,c[a>>2]=u,c[a+4>>2]=b,a=a+32|0,h=h-32|0,h>>>0>31;);}return r}function Ti(r){r=r|0;var a=0,h=0,u=0,y=0,b=0;if(r){a=r-4|0,y=c[a>>2],h=y,u=a,b=c[r-8>>2],r=b&-2,(r|0)!=(b|0)&&(u=a-r|0,h=c[u+4>>2],c[h+8>>2]=c[u+8>>2],c[c[u+8>>2]+4>>2]=h,h=r+y|0),r=a+y|0,a=c[r>>2],(a|0)!=c[(r+a|0)-4>>2]&&(y=c[r+4>>2],c[y+8>>2]=c[r+8>>2],c[c[r+8>>2]+4>>2]=y,h=a+h|0),c[u>>2]=h,c[((h&-4)+u|0)-4>>2]=h|1,a=c[u>>2]-8|0;t:{if(a>>>0<=127){r=(a>>>3|0)-1|0;break t}if(h=Er(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,c[u+4>>2]=a+5968,a=a+5976|0,c[u+8>>2]=c[a>>2],c[a>>2]=u,c[c[u+8>>2]+4>>2]=u,a=c[1750],h=c[1751],u=r&31,(r&63)>>>0>=32?(r=1<<u,y=0):(y=1<<u,r=y-1&1>>>32-u),c[1750]=y|a,c[1751]=r|h}}function fT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0,P=0,K=0;u=kt-32|0,kt=u,y=c[r+28>>2],c[u+16>>2]=y,b=c[r+20>>2],c[u+28>>2]=h,c[u+24>>2]=a,a=b-y|0,c[u+20>>2]=a,b=a+h|0,P=2,a=u+16|0;t:{for(;;){r:{i:{e:{if(!u2(eT(c[r+60>>2],a|0,P|0,u+12|0)|0)){if(k=c[u+12>>2],(k|0)==(b|0))break e;if((k|0)>=0)break i;break r}if((b|0)!=-1)break r}a=c[r+44>>2],c[r+28>>2]=a,c[r+20>>2]=a,c[r+16>>2]=a+c[r+48>>2],r=h;break t}S=c[a+4>>2],K=S>>>0<k>>>0,y=(K<<3)+a|0,S=k-(K?S:0)|0,c[y>>2]=S+c[y>>2],a=(K?12:4)+a|0,c[a>>2]=c[a>>2]-S,b=b-k|0,P=P-K|0,a=y;continue}break}if(c[r+28>>2]=0,c[r+16>>2]=0,c[r+20>>2]=0,c[r>>2]=c[r>>2]|32,r=0,(P|0)==2)break t;r=h-c[a+4>>2]|0}return kt=u+32|0,r|0}function pT(r){r=r|0;var a=0,h=0,u=0,y=0,b=0;h=kt-96|0,kt=h,c[h>>2]=r,u=kt-16|0,kt=u,c[u+12>>2]=h,r=kt-144|0,kt=r,r=Vi(r,5520,144),b=h+16|0,a=b,c[r+44>>2]=a,c[r+20>>2]=a,y=-2-a|0,y=y>>>0>=2147483647?2147483647:y,c[r+48>>2]=y,a=a+y|0,c[r+28>>2]=a,c[r+16>>2]=a,Bp(r,2202,h,0,0),y&&(a=c[r+20>>2],gt[a-((a|0)==c[r+16>>2])|0]=0),kt=r+144|0,kt=u+16|0,r=b;t:{if(r&3)for(;;){if(!Tt[r|0])break t;if(r=r+1|0,!(r&3))break}for(;a=r,r=r+4|0,u=c[a>>2],!((u^-1)&u-16843009&-2139062144););for(;r=a,a=r+1|0,!!Tt[r|0];);}return r=(r-b|0)+1|0,a=Ph(r),a?r=Vi(a,b,r):r=0,kt=h+96|0,r|0}function Bp(r,a,h,u,y){var b=0,k=0,S=0,P=0;b=kt-208|0,kt=b,c[b+204>>2]=h,h=b+160|0,Hi(h,0,40),c[b+200>>2]=c[b+204>>2];t:{if((Cp(0,a,b+200|0,b+80|0,h,u,y)|0)<0){y=-1;break t}P=c[r+76>>2]>=0,k=c[r>>2],c[r+72>>2]<=0&&(c[r>>2]=k&-33);r:{i:{e:{if(!c[r+48>>2]){c[r+48>>2]=80,c[r+28>>2]=0,c[r+16>>2]=0,c[r+20>>2]=0,S=c[r+44>>2],c[r+44>>2]=b;break e}if(c[r+16>>2])break i}if(h=-1,Jp(r))break r}h=Cp(r,a,b+200|0,b+80|0,b+160|0,u,y)}if(S&&(Pt[c[r+36>>2]](r,0,0)|0,c[r+48>>2]=0,c[r+44>>2]=S,c[r+28>>2]=0,a=c[r+20>>2],c[r+16>>2]=0,c[r+20>>2]=0,h=a?h:-1),a=r,r=c[r>>2],c[a>>2]=r|k&32,y=r&32?-1:h,!P)break t}return kt=b+208|0,y}function hl(r){var a=0,h=m(0),u=0,y=0,b=0,k=0,S=0,P=m(0),K=0;b=kt-16|0,kt=b,a=c[r+12>>2];t:{if(a){P=I[r+520>>2],h=I[r+516>>2];r:{if(Tt[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;c[b>>2]=3409,lr(r,b),tr(),ce()}r:{i:{if(k=c[r+556>>2],a=c[r+560>>2],(k|0)!=(a|0)){for(a=a-k>>2,K=a>>>0<=1?1:a;;){if(y=c[(S<<2)+k>>2],!c[y+548>>2]){if(a=c[y+24>>2],(a&196608)!=131072){if(a=a>>>13&7,a||(a=c[r+24>>2]>>>10&7),Tt[y+4|0]&2|(Tt[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(hl(u)+I[u+232>>2])}return kt=b+16|0,h}function Vn(r,a,h,u,y,b){var k=0,S=m(0),P=0,K=m(0);k=(c[(a<<2)+4320>>2]<<2)+r|0,S=I[k+216>>2];t:{r:{k=c[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(zt),c[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(he(r,a,u)+Se(r,a,u)));t:{r:{i:switch(c[y>>2]){case 1:case 2:h=I[b>>2],u=u!=u||h<u?h:u;break r;case 0:break i;default:break t}if(u!=u)break t;c[y>>2]=2}I[b>>2]=u}}function De(r,a,h){var u=m(0),y=m(0),b=0,k=m(0);r=r+116|0,b=c[(a<<2)+4288>>2];t:{if((a&-2)==2){a=jr(r,4,b,2140081935);break t}a=Kr(r,b,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(zt),c[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 Pe(r,a,h){var u=m(0),y=m(0),b=0,k=m(0);r=r+116|0,b=c[(a<<2)+4304>>2];t:{if((a&-2)==2){a=jr(r,5,b,2140081935);break t}a=Kr(r,b,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(zt),c[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 Gp(r,a,h,u,y,b){var k=0;t:{r:{if(r){i:{if(a&4){b=Pt[r|0](h,u,y,b)|0;break i}b=Pt[r|0](h,u,y)|0}if(b)break r}if(b=ut(588),a=Vi(b,h,552),c[a+564>>2]=0,c[a+556>>2]=0,c[a+560>>2]=0,y=c[h+556>>2],u=c[h+560>>2],(y|0)!=(u|0)){if(k=u-y|0,(k|0)<0)break t;for(r=ut(k),c[a+556>>2]=r,c[a+564>>2]=r+k;c[r>>2]=c[y>>2],r=r+4|0,y=y+4|0,(u|0)!=(y|0););c[a+560>>2]=r}r=c[h+572>>2],c[a+568>>2]=c[h+568>>2],c[a+572>>2]=r,c[a+584>>2]=c[h+584>>2],r=c[h+580>>2],c[a+576>>2]=c[h+576>>2],c[a+580>>2]=r,c[a+552>>2]=0}return b}Fs(),ce()}function lr(r,a){var h=0,u=0,y=0;y=kt-16|0,kt=y,c[y+12>>2]=a;t:{r:{if(!r){a=c[y+12>>2];break r}if(a=c[y+12>>2],h=c[r+568>>2],!h)break r;if(u=c[h+4>>2],Tt[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(!Tt[7016]){h=ut(28),c[h+20>>2]=1065353216,c[h+24>>2]=0,c[h+12>>2]=0,c[h+16>>2]=0,c[h>>2]=0,gt[h+8|0]=0,u=1,c[h+4>>2]=1,c[1753]=h,gt[7016]=1,c[1752]=c[1752]+1;break r}if(h=c[1753],u=c[h+4>>2],!(Tt[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}kt=y+16|0}function Va(r,a,h){var u=m(0),y=0,b=m(0);r=r+80|0,y=c[(a<<2)+4304>>2];t:{r:{if((a&-2)==2){a=jr(r,5,y,2140081935);break r}a=Kr(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],b=m(zt),c[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}b=m(m(u*h)*m(.009999999776482582))}return b}return u}function Us(r,a,h){var u=m(0),y=0,b=m(0);r=r+80|0,y=c[(a<<2)+4288>>2];t:{r:{if((a&-2)==2){a=jr(r,4,y,2140081935);break r}a=Kr(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],b=m(zt),c[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}b=m(m(u*h)*m(.009999999776482582))}return b}return u}function jr(r,a,h,u){var y=m(0);a=(a<<2)+r|0,y=I[a>>2],a=c[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=c[a>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(a=c[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=c[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(a=u,y!=y)))break t;a=r}return a}function gT(r,a){r=r|0,a=m(a);var h=0,u=0,y=0;if(h=kt-16|0,kt=h,r=c[r>>2],!(a>=m(0))){c[h>>2]=2263,u=kt-16|0,kt=u,c[u+12>>2]=h;t:{if(r)break t;if(Tt[7016]){r=c[1753];break t}r=ut(28),c[r+20>>2]=1065353216,c[r+24>>2]=0,c[r+12>>2]=0,c[r+16>>2]=0,c[r>>2]=0,gt[r+8|0]=0,c[r+4>>2]=1,c[1753]=r,gt[7016]=1,c[1752]=c[1752]+1}y=c[r+4>>2];t:{if(Tt[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}kt=u+16|0,tr(),ce()}I[r+20>>2]=a==m(0)?m(0):a,kt=h+16|0}function Vp(r,a,h,u,y){var b=0,k=0,S=m(0),P=0;b=2,k=c[r+24>>2]>>>2&3;t:{r:{i:{if(!(!c[r+552>>2]|(a|0)!=2)){a=0,b=3;e:switch(k-2|0){case 0:break t;case 1:break e;default:break i}b=2;break t}if(a=0,k>>>0>1)break r}a=b}b=k}h=l2(r,b,h),u=l2(r,a,u),S=he(r,b,y),k=r+228|0,P=b<<2,I[k+(c[P+4288>>2]<<2)>>2]=h+S,S=Se(r,b,y),I[k+(c[P+4304>>2]<<2)>>2]=h+S,h=he(r,a,y),b=a<<2,I[k+(c[b+4288>>2]<<2)>>2]=u+h,h=Se(r,a,y),I[k+(c[b+4304>>2]<<2)>>2]=u+h}function mT(r,a,h,u,y,b){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0,S=0,P=0;k=kt-48|0,kt=k,P=c[a+8>>2];t:{if(gt[7052]&1){a=c[1762];break t}a=Tp(5,4480)|0,gt[7052]=1,c[1762]=a}c[k+40>>2]=b,I[k+32>>2]=y,c[k+24>>2]=u,I[k+16>>2]=h,S=+XE(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=c[k+12>>2],b=c[a+4>>2],c[r>>2]=c[a>>2],c[r+4>>2]=b,b=c[a+12>>2],c[r+8>>2]=c[a+8>>2],c[r+12>>2]=b,zE(u|0),kt=k+48|0}function vT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0;if(u=kt-32|0,kt=u,y=c[a>>2],y>>>0<2147483632){t:{r:{if(y>>>0>=11){b=(y|15)+1|0,k=ut(b),c[u+16>>2]=b|-2147483648,c[u+8>>2]=k,c[u+12>>2]=y,b=y+k|0;break r}if(gt[u+19|0]=y,k=u+8|0,b=k+y|0,!y)break t}Vi(k,a+4|0,y)}return gt[b|0]=0,c[u>>2]=h,Pt[r|0](u+24|0,u+8|0,u),YE(c[u+24>>2]),r=c[u+24>>2],Ga(r|0),Ga(c[u>>2]),gt[u+19|0]<0&&Ti(c[u+8>>2]),kt=u+32|0,r|0}Fs(),ce()}function gi(r,a,h){var u=0,y=0,b=0;if(!(Tt[r|0]&32))t:{u=a,a=r,r=c[a+16>>2];r:{if(!r){if(Jp(a))break r;r=c[a+16>>2]}if(b=c[a+20>>2],r-b>>>0<h>>>0){Pt[c[a+36>>2]](a,u,h)|0;break t}i:{if(c[a+80>>2]<0)break i;for(r=h;;){if(y=r,!r)break i;if(r=y-1|0,Tt[u+r|0]==10)break}if(Pt[c[a+36>>2]](a,u,y)>>>0<y>>>0)break r;u=u+y|0,h=h-y|0,b=c[a+20>>2]}Vi(b,u,h),c[a+20>>2]=c[a+20>>2]+h}}}function Fh(r,a,h){var u=0,y=0,b=0;u=kt-16|0,kt=u,y=r+24|0,Pt[a|0](u+8|0,y),b=c[u+12>>2];t:{if((c[c[u+8>>2]>>2]&7<<b)>>b==(h|0))break t;for(Pt[a|0](u+8|0,y),a=c[u+8>>2],y=a,b=c[a>>2],a=c[u+12>>2],c[y>>2]=b&(7<<a^-1)|(h&7)<<a;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}kt=u+16|0}function Kr(r,a,h){var u=m(0);a=(a<<2)+r|0,u=I[a>>2],a=c[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=c[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=c[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(a=h,u!=u)))break t;a=r}return a}function Se(r,a,h){var u=m(0),y=0;r=r+44|0,y=c[(a<<2)+4304>>2];t:{if((a&-2)==2){r=jr(r,5,y,2140081935);break t}r=Kr(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(zt);if(u=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function he(r,a,h){var u=m(0),y=0;r=r+44|0,y=c[(a<<2)+4288>>2];t:{if((a&-2)==2){r=jr(r,4,y,2140081935);break t}r=Kr(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(zt);if(u=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function yT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0;return y=c[r+84>>2],b=c[y>>2],u=c[y+4>>2],S=c[r+28>>2],k=c[r+20>>2]-S|0,k=u>>>0<k>>>0?u:k,k&&(Vi(b,S,k),b=k+c[y>>2]|0,c[y>>2]=b,u=c[y+4>>2]-k|0,c[y+4>>2]=u),u=h>>>0>u>>>0?u:h,u&&(Vi(b,a,u),b=u+c[y>>2]|0,c[y>>2]=b,c[y+4>>2]=c[y+4>>2]-u),gt[b|0]=0,a=c[r+44>>2],c[r+28>>2]=a,c[r+20>>2]=a,h|0}function Re(r,a){var h=m(0),u=0;r=r+152|0,u=c[(a<<2)+4304>>2];t:{if((a&-2)==2){r=jr(r,5,u,2140081935);break t}r=Kr(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(zt)}return oe(h,m(0))}function pe(r,a){var h=m(0),u=0;r=r+152|0,u=c[(a<<2)+4288>>2];t:{if((a&-2)==2){r=jr(r,4,u,2140081935);break t}r=Kr(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(zt)}return oe(h,m(0))}function bT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=c[a>>2]+(h<<2)|0,b=I[a+116>>2];t:{r:{if(a=c[a+116>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(b!=b){u=0;break t}u=a&1073741824?2:1,y=(Dt(2,(a&-1073741825)+536870912|0),+Bt())}He[r+8>>3]=y,c[r>>2]=u}function AT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=c[a>>2]+(h<<2)|0,b=I[a+80>>2];t:{r:{if(a=c[a+80>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(b!=b){u=0;break t}u=a&1073741824?2:1,y=(Dt(2,(a&-1073741825)+536870912|0),+Bt())}He[r+8>>3]=y,c[r>>2]=u}function ET(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=c[a>>2]+(h<<2)|0,b=I[a+44>>2];t:{r:{if(a=c[a+44>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(b!=b){u=0;break t}u=a&1073741824?2:1,y=(Dt(2,(a&-1073741825)+536870912|0),+Bt())}He[r+8>>3]=y,c[r>>2]=u}function Yr(r,a,h,u){var y=0,b=0,k=0;r=r*a,y=Oh(r),y=y<0?y+1:y,k=y!=y;t:{if(!(k|!(Xe(y)<1e-4))){r=r-y;break t}r:{if(y!=y){r=r-y;break r}if(r=r-y,!(Xe(y+-1)<1e-4))break r;r=r+1;break t}if(h){r=r+1;break t}if(u)break t;b=0;r:{if(k||(b=1,y>.5))break r;b=Xe(y+-.5)<1e-4?1:0}r=r+b}return r!=r|a!=a?m(zt):m(r/a)}function Hp(r,a){var h=m(0);t:{if((a|0)!=2139156720){if((a|0)!=2140081935){if((a|0)!=2141891242)break t;c[r>>2]=2143289344,c[r+4>>2]=3;return}c[r>>2]=0,c[r+4>>2]=1;return}c[r>>2]=0,c[r+4>>2]=2;return}if(h=(Dt(2,a),Bt()),h!=h){c[r>>2]=2143289344,c[r+4>>2]=0;return}c[r+4>>2]=a&1073741824?2:1,c[r>>2]=(a&-1073741825)+536870912}function Wp(r){var a=0,h=0,u=0;h=c[r+24>>2];t:{if(!(h&8)||(a=1,(h&7168)==5120)||(a=0,u=c[r+560>>2],h=c[r+556>>2],(u|0)==(h|0)))break t;for(r=u-h>>2,u=r>>>0<=1?1:r,r=0;;){if(a=c[c[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 TT(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+220>>2];t:{r:{if(a=c[a+220>>2],(a|0)!=2139156720){if(u=zt,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,He[r+8>>3]=u,c[r>>2]=a}function kT(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+200>>2];t:{r:{if(a=c[a+200>>2],(a|0)!=2139156720){if(u=zt,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,He[r+8>>3]=u,c[r>>2]=a}function wT(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+204>>2];t:{r:{if(a=c[a+204>>2],(a|0)!=2139156720){if(u=zt,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,He[r+8>>3]=u,c[r>>2]=a}function ST(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+208>>2];t:{r:{if(a=c[a+208>>2],(a|0)!=2139156720){if(u=zt,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,He[r+8>>3]=u,c[r>>2]=a}function RT(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+212>>2];t:{r:{if(a=c[a+212>>2],(a|0)!=2139156720){if(u=zt,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,He[r+8>>3]=u,c[r>>2]=a}function LT(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+216>>2];t:{r:{if(a=c[a+216>>2],(a|0)!=2139156720){if(u=zt,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,He[r+8>>3]=u,c[r>>2]=a}function _T(r,a){r=r|0,a=a|0;var h=0;if(h=kt-16|0,kt=h,r=c[r>>2],(a|0)<6){kt=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+260|0,(Tt[r+300|0]&3)==2)break t;a=r+252|0;break t;case 1:if(a=r+252|0,(Tt[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]}c[h>>2]=1872,lr(r,h),tr(),ce()}function CT(r,a){r=r|0,a=a|0;var h=0;if(h=kt-16|0,kt=h,r=c[r>>2],(a|0)<6){kt=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+276|0,(Tt[r+300|0]&3)==2)break t;a=r+268|0;break t;case 1:if(a=r+268|0,(Tt[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]}c[h>>2]=1872,lr(r,h),tr(),ce()}function IT(r,a){r=r|0,a=a|0;var h=0;if(h=kt-16|0,kt=h,r=c[r>>2],(a|0)<6){kt=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+292|0,(Tt[r+300|0]&3)==2)break t;a=r+284|0;break t;case 1:if(a=r+284|0,(Tt[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]}c[h>>2]=1872,lr(r,h),tr(),ce()}function xT(r,a){r=r|0,a=a|0;var h=0,u=m(0),y=m(0);u=m(zt),a=c[a>>2],y=I[a+40>>2],a=c[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}c[r>>2]=h,He[r+8>>3]=u}function zr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Xe(r))==m(Ep)|r!=r||(a=2139156720,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(Dt(2,(Ji(r),te(2)&-2147483648|1602224127)),Bt()),a=(Ji(r>m(0xffffff0000000000)||r<m(-0xffffff0000000000)?h:r),te(2)-536870912|1073741824)}return a}function Tr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Xe(r))==m(Ep)|r!=r||(a=2140081935,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(Dt(2,(Ji(r),te(2)&-2147483648|1610612735)),Bt()),a=(Ji(r>m(36893485948395848e3)||r<m(-36893485948395848e3)?h:r),te(2)-536870912|0)}return a}function DT(r,a){r=r|0,a=a|0;var h=m(0),u=m(0);r=c[r>>2]+(a<<2)|0,u=I[r+188>>2];t:{r:{if(r=c[r+188>>2],(r|0)==2139156720|(r|0)==2140081935)break r;if(h=m(zt),(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 PT(r,a,h,u,y,b){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0,S=0;return k=kt-16|0,kt=k,S=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(S=c[S+c[a>>2]>>2]),Pt[S|0](k,a,h,u,y,b),r=ut(16),a=c[k+12>>2],c[r+8>>2]=c[k+8>>2],c[r+12>>2]=a,a=c[k+4>>2],c[r>>2]=c[k>>2],c[r+4>>2]=a,kt=k+16|0,r|0}function jp(r,a){t:{if(a){a=d2(c[a>>2]);break t}r:{if(Tt[7016]){a=c[1753];break r}a=ut(28),c[a+20>>2]=1065353216,c[a+24>>2]=0,c[a+12>>2]=0,c[a+16>>2]=0,c[a>>2]=0,gt[a+8|0]=0,c[a+4>>2]=1,c[1753]=a,gt[7016]=1,c[1752]=c[1752]+1}a=d2(a)}return c[r+4>>2]=0,c[r+8>>2]=0,c[r>>2]=a,c[a>>2]=r,r}function OT(r,a,h){r=r|0,a=a|0,h=+h;var u=0,y=0;t:{if(r=c[r>>2],a=r+(a<<2)|0,y=c[a+152>>2],u=Tr(m(h)),(y|0)==(u|0))break t;for(c[a+152>>2]=u;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function MT(r,a,h){r=r|0,a=a|0,h=+h;var u=0,y=0;t:{if(r=c[r>>2],a=r+(a<<2)|0,y=c[a+188>>2],u=Tr(m(h)),(y|0)==(u|0))break t;for(c[a+188>>2]=u;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function $T(r,a){r=r|0,a=a|0;var h=0,u=m(0);r=c[r>>2]+(a<<2)|0,u=I[r+152>>2];t:{r:{if(r=c[r+152>>2],(r|0)==2139156720|(r|0)==2140081935)break r;if(h=zt,(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 FT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=c[r>>2],h=c[r+24>>2],(h>>>20&3)==(a|0))break t;for(c[r+24>>2]=h&-3145729|a<<20&3145728;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Hn(r,a,h){var u=0,y=0,b=0;t:{if(!a){u=r;break t}for(;u=Op(r,a,10),y=Gi,r=Bh(u,y,246,0)+r|0,h=h-1|0,gt[h|0]=r|48,b=a>>>0>9,r=u,a=y,!!b;);}if(u)for(;h=h-1|0,r=(u>>>0)/10|0,gt[h|0]=We(r,246)+u|48,a=u>>>0>9,u=r,!!a;);return h}function NT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=c[r>>2],h=c[r+24>>2],(h>>>22&1)==(a|0))break t;for(c[r+24>>2]=h&-4194305|a<<22&4194304;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function UT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=c[r>>2],h=c[r+24>>2],(h>>>18&3)==(a|0))break t;for(c[r+24>>2]=h&-786433|a<<18&786432;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function BT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=c[r>>2],h=c[r+24>>2],(h>>>16&3)==(a|0))break t;for(c[r+24>>2]=h&-196609|a<<16&196608;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function GT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=c[r>>2],y=I[r+224>>2],u==y|u!=u&y!=y)break t;for(I[r+224>>2]=u;;){if(h=Tt[r+4|0],h&4)break t;if(gt[r+4|0]=h|4,h=c[r+20>>2],h&&Pt[h|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function VT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=c[r>>2],y=I[r+28>>2],u==y|u!=u&y!=y)break t;for(I[r+28>>2]=u;;){if(h=Tt[r+4|0],h&4)break t;if(gt[r+4|0]=h|4,h=c[r+20>>2],h&&Pt[h|0](r),c[r+308>>2]=2143289344,r=c[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=c[r>>2],y=I[r+32>>2],u==y|u!=u&y!=y)break t;for(I[r+32>>2]=u;;){if(h=Tt[r+4|0],h&4)break t;if(gt[r+4|0]=h|4,h=c[r+20>>2],h&&Pt[h|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function WT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=c[r>>2],y=I[r+36>>2],u==y|u!=u&y!=y)break t;for(I[r+36>>2]=u;;){if(h=Tt[r+4|0],h&4)break t;if(gt[r+4|0]=h|4,h=c[r+20>>2],h&&Pt[h|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function jT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=c[r>>2],h=c[r+24>>2],(h>>>4&7)==(a|0))break t;for(c[r+24>>2]=h&-113|a<<4&112;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function KT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=c[r>>2],h=c[r+24>>2],(h>>>2&3)==(a|0))break t;for(c[r+24>>2]=h&-13|a<<2&12;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function YT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=c[r>>2],h=Tt[r+4|0],((h&2)>>>1|0)==(a|0))break t;for(gt[r+4|0]=h&253|(a?2:0);;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function zT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;return u=kt-16|0,kt=u,y=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(y=c[y+c[a>>2]>>2]),Pt[y|0](u,a,h),r=ut(16),a=c[u+12>>2],c[r+8>>2]=c[u+8>>2],c[r+12>>2]=a,a=c[u+4>>2],c[r>>2]=c[u>>2],c[r+4>>2]=a,kt=u+16|0,r|0}function Kp(r,a){var h=0,u=0;t:{r:{if(h=c[r+556>>2],u=c[r+560>>2],(h|0)==(u|0))break r;for(;;){if(c[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,Ns(h,a,u-a|0),c[r+560>>2]=u-4,1}return 0}function XT(r){r=r|0;var a=0,h=0;if(h=kt-16|0,kt=h,r=c[r>>2],c[r+8>>2]){for(;a=Tt[r+4|0],!!(!(a&4)&&(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],r)););kt=h+16|0;return}c[h>>2]=1024,lr(r,h),tr(),ce()}function Yp(r,a){var h=0,u=0,y=0;if(Ei(+r),u=te(1)|0,y=te(0)|0,h=u>>>20&2047,(h|0)!=2047){if(!h)return r==0?h=0:(r=Yp(r*18446744073709552e3,a),h=c[a>>2]+-64|0),c[a>>2]=h,r;c[a>>2]=h-1022,Dt(0,y|0),Dt(1,u&-2146435073|1071644672),r=+Ee()}return r}function ZT(r,a){r=r|0,a=a|0;var h=0,u=0;return h=kt-16|0,kt=h,u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),Pt[u|0](h,a),r=ut(16),a=c[h+12>>2],c[r+8>>2]=c[h+8>>2],c[r+12>>2]=a,a=c[h+4>>2],c[r>>2]=c[h>>2],c[r+4>>2]=a,kt=h+16|0,r|0}function dl(r,a,h){var u=0;t:{if(u=r+24|0,c[(u+(a<<2)|0)+184>>2]==(h|0))break t;for(c[((a<<2)+u|0)+184>>2]=h;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function ul(r,a,h){var u=0;t:{if(u=r+24|0,c[(u+(a<<2)|0)+192>>2]==(h|0))break t;for(c[((a<<2)+u|0)+192>>2]=h;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Wn(r,a,h){var u=0;t:{if(u=r+24|0,c[(u+(a<<2)|0)+176>>2]==(h|0))break t;for(c[((a<<2)+u|0)+176>>2]=h;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Nh(r,a){var h=0,u=0,y=0;t:{if(h=r+24|0,c[h+16>>2]==(a|0))break t;for(u=Pt[9](h)|0,y=a,c[u+16>>2]=y;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function zp(r,a,h){var u=0;t:{if(u=r+24|0,c[(u+(a<<2)|0)+92>>2]==(h|0))break t;for(c[((a<<2)+u|0)+92>>2]=h;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Uh(r,a,h){var u=0;t:{if(u=r+24|0,c[(u+(a<<2)|0)+20>>2]==(h|0))break t;for(c[((a<<2)+u|0)+20>>2]=h;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Xp(r,a,h){var u=0;t:{if(u=r+24|0,c[(u+(a<<2)|0)+56>>2]==(h|0))break t;for(c[((a<<2)+u|0)+56>>2]=h;;){if(a=Tt[r+4|0],a&4)break t;if(gt[r+4|0]=a|4,a=c[r+20>>2],a&&Pt[a|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function qT(){for(var r=0,a=0,h=0;a=r<<4,h=a+5968|0,c[a+5972>>2]=h,c[a+5976>>2]=h,r=r+1|0,(r|0)!=64;);Mh(48),c[1756]=16,c[1757]=0,_p(),c[1757]=c[1768],c[1768]=7024,c[1769]=198,c[1770]=0,Fp(),c[1770]=c[1768],c[1768]=7076}function cr(r,a){var h=0,u=m(0);r=r+80|0,h=c[(a<<2)+4288>>2];t:{if((a&-2)==2){r=jr(r,4,h,2143289344);break t}r=Kr(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 fl(r,a){var h=0,u=m(0);r=r+80|0,h=c[(a<<2)+4304>>2];t:{if((a&-2)==2){r=jr(r,5,h,2143289344);break t}r=Kr(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 Bh(r,a,h,u){var y=0,b=0,k=0,S=0,P=0,K=0;return y=h>>>16|0,b=r>>>16|0,K=We(y,b),k=h&65535,S=r&65535,P=We(k,S),b=(P>>>16|0)+We(b,k)|0,y=(b&65535)+We(y,S)|0,Gi=(We(a,h)+K|0)+We(r,u)+(b>>>16)+(y>>>16)|0,P&65535|y<<16}function Zp(r,a){var h=0,u=0,y=0;u=kt-16|0,kt=u,h=Tt[r+4|0],y=h&-17,gt[r+4|0]=y;t:{if(a){if(c[r+560>>2]!=c[r+556>>2])break t;h=y|8}else h=h&231;c[r+8>>2]=a,gt[r+4|0]=h,kt=u+16|0;return}c[u>>2]=4128,lr(r,u),tr(),ce()}function qp(r){var a=0,h=m(0);a=0;t:{if((c[r+24>>2]&196608)==131072)break t;r:{if(!c[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=jn(r)!=m(0)}return a}function ki(r,a,h,u,y){var b=0;if(b=kt-256|0,kt=b,!(y&73728|(h|0)<=(u|0))){if(u=h-u|0,h=u>>>0<256,Hi(b,a&255,h?u:256),!h)for(;gi(r,b,256),u=u-256|0,u>>>0>255;);gi(r,b,u)}kt=b+256|0}function mn(r,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=a- -64|0,y=I[u>>2],u=c[u>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=c[((c[(h<<2)+4304>>2]<<2)+a|0)+44>>2]}Hp(r,u)}function vn(r,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=c[a+60>>2],y=I[a+60>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=c[((c[(h<<2)+4288>>2]<<2)+a|0)+44>>2]}Hp(r,u)}function jn(r){var a=m(0),h=m(0);if(!c[r+552>>2])return m(0);a=I[r+36>>2];t:{if(a==a||(a=m(1),gt[c[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 Qp(r){var a=0,h=0,u=0;for(u=c[r>>2];;){if(h=gt[u|0],gl(h)){u=u+1|0,c[r>>2]=u,a>>>0<=214748364?(h=h-48|0,a=We(a,10),a=(h|0)>(a^2147483647)?-1:h+a|0):a=-1;continue}break}return a}function Ha(r,a,h,u){var y=0;c[r+12>>2]=0,c[r+16>>2]=u;t:{if(a){if(a>>>0>=1073741824)break t;y=ut(a<<2)}return c[r>>2]=y,h=(h<<2)+y|0,c[r+8>>2]=h,c[r+12>>2]=(a<<2)+y,c[r+4>>2]=h,r}Kh(),ce()}function Jp(r){var a=0;return a=c[r+72>>2],c[r+72>>2]=a-1|a,a=c[r>>2],a&8?(c[r>>2]=a|32,-1):(c[r+4>>2]=0,c[r+8>>2]=0,a=c[r+44>>2],c[r+28>>2]=a,c[r+20>>2]=a,c[r+16>>2]=a+c[r+48>>2],0)}function QT(r,a,h,u,y,b){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0;k=kt-16|0,kt=k,a=c[c[a>>2]+4>>2],Pt[c[c[a>>2]+8>>2]](k,a,h,u,y,b),I[r>>2]=He[k>>3],I[r+4>>2]=He[k+8>>3],kt=k+16|0}function JT(){var r=0,a=0;return a=ut(4),r=ut(28),c[r+20>>2]=1065353216,c[r+24>>2]=0,c[r+12>>2]=0,c[r+16>>2]=0,c[r>>2]=0,gt[r+8|0]=0,c[r+4>>2]=1,c[1752]=c[1752]+1,c[a>>2]=r,a|0}function tk(r,a){r=r|0,a=a|0,a=c[a>>2],He[r>>3]=I[a+228>>2],He[r+8>>3]=I[a+236>>2],He[r+16>>3]=I[a+232>>2],He[r+24>>3]=I[a+240>>2],He[r+32>>3]=I[a+244>>2],He[r+40>>3]=I[a+248>>2]}function ek(r,a){r=r|0,a=a|0;var h=0,u=0;return h=kt-48|0,kt=h,u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),Pt[u|0](h,a),r=Vi(ut(48),h,48),kt=h+48|0,r|0}function ik(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;return y=kt-16|0,kt=y,r=u2(qE(c[r+60>>2],a|0,h|0,u&255,y+8|0)|0),kt=y+16|0,Gi=r?-1:c[y+12>>2],(r?-1:c[y+8>>2])|0}function rk(r,a){r=r|0,a=a|0;var h=0,u=0;h=c[r>>2],r=c[h+556>>2];t:{if(c[h+560>>2]-r>>2>>>0<=a>>>0||(r=c[r+(a<<2)>>2],!r))break t;u=c[r>>2]}return u|0}function sk(r,a,h){if(r=r|0,a=a|0,h=h|0,a>>>0<3){a=1<<a,r=c[r>>2],h?a=a|c[r+12>>2]:a=c[r+12>>2]&(a^-1),c[r+12>>2]=a;return}Fs(),ce()}function nk(r,a,h,u,y){r=r|0,a=a|0,h=+h,u=+u,y=y|0;var b=0;b=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(b=c[b+c[a>>2]>>2]),Pt[b|0](a,h,u,y)}function ak(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),m(m(Pt[u|0](a,h)))}function t2(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;y=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(y=c[y+c[a>>2]>>2]),Pt[y|0](a,h,u)}function e2(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),Pt[u|0](a,h)|0}function ok(r,a,h,u){r=r|0,a=a|0,h=h|0,u=+u;var y=0;y=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(y=c[y+c[a>>2]>>2]),Pt[y|0](a,h,u)}function lk(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),+Pt[u|0](a,h)}function ut(r){var a=0;r=r||1;t:{for(;;){if(a=Ph(r),a)break t;if(a=c[2042],a){Pt[a|0]();continue}break}Fs(),ce()}return a}function ck(r,a,h){r=r|0,a=a|0,h=m(h);var u=0;u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),Pt[u|0](a,h)}function Bs(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),Pt[u|0](a,h)}function yn(r,a){r=r|0,a=a|0;var h=0;return h=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(h=c[h+c[a>>2]>>2]),Pt[h|0](a)|0}function Gh(r,a){return Ji(r),(te(2)&2147483647)>>>0<=2139095040?(Ji(a),(te(2)&2147483647)>>>0>2139095040?r:m(jE(r,a))):a}function oe(r,a){return Ji(r),(te(2)&2147483647)>>>0<=2139095040?(Ji(a),(te(2)&2147483647)>>>0>2139095040?r:m(KE(r,a))):a}function i2(r,a){r=r|0,a=a|0;var h=0;return h=kt-16|0,kt=h,c[h+8>>2]=a,r=Pt[r|0](h+8|0)|0,Ga(c[h+8>>2]),kt=h+16|0,r|0}function hk(r,a,h){r=r|0,a=a|0,h=+h;var u=0;u=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(u=c[u+c[a>>2]>>2]),Pt[u|0](a,h)}function dk(r,a,h,u,y){return h=h|0,u=u|0,y=y|0,h&&(h|0)!=5?m2(5816,u,y)|0:m2(5672,u,y)|0}function r2(r,a){if(!r)return 0;t:{if(!((a&-128)==57216|a>>>0<=127)){c[1781]=25,r=-1;break t}gt[r|0]=a,r=1}return r}function uk(r,a){r=r|0,a=a|0;var h=0;return h=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(h=c[h+c[a>>2]>>2]),+Pt[h|0](a)}function s2(r,a){var h=0,u=0;h=ut(4),c[h>>2]=a,u=ut(4),c[u>>2]=a,ll(7035,r|0,7098,4714,196,h|0,7098,4718,197,u|0)}function Kn(r,a){var h=0,u=0;h=ut(4),c[h>>2]=a,u=ut(4),c[u>>2]=a,ll(7065,r|0,7098,4714,194,h|0,7098,4718,195,u|0)}function Vh(r,a){var h=0;t:{if(gt[7044]&1){h=c[1760];break t}h=Tp(1,4464)|0,gt[7044]=1,c[1760]=h}ZE(h|0,r|0,a|0,0)}function fk(r,a){r=r|0,a=a|0;var h=0;h=c[r+8>>2],c[r+8>>2]=a,h&&Pt[c[c[h>>2]+4>>2]](h),c[c[r>>2]+20>>2]=15}function pk(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=Rp((gt[a+11|0]<0?c[a>>2]:a)|0,7036,c[h>>2])|0,c[u>>2]=y}function gk(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=Rp((gt[a+11|0]<0?c[a>>2]:a)|0,7059,c[h>>2])|0,c[u>>2]=y}function n2(r,a){r=r|0,a=a|0;var h=0;h=c[r>>2],r=c[r+4>>2],a=(r>>1)+a|0,r&1&&(h=c[h+c[a>>2]>>2]),Pt[h|0](a)}function mk(r){r=r|0;var a=m(0);return r=c[r>>2],a=I[r+36>>2],a!=a&&(a=gt[c[r+568>>2]+8|0]&1?m(1):m(0)),+a}function vk(r,a){r=r|0,a=a|0;var h=0;h=c[r+4>>2],c[r+4>>2]=a,h&&Pt[c[c[h>>2]+4>>2]](h),Zp(c[r>>2],14)}function yk(r){r=r|0;var a=0;a=c[r+8>>2],c[r+8>>2]=0,a&&Pt[c[c[a>>2]+4>>2]](a),c[c[r>>2]+20>>2]=0}function bk(r){r=r|0;var a=0;return a=ut(12),gt[a+4|0]=0,c[a+8>>2]=c[r>>2],c[r>>2]=0,c[a>>2]=4432,a|0}function Ak(r){r=r|0;var a=0;return a=ut(12),gt[a+4|0]=0,c[a+8>>2]=c[r>>2],c[r>>2]=0,c[a>>2]=4552,a|0}function Ek(){var r=0;if(r=c[1768],r)for(;Pt[c[r>>2]](),r=c[r+4>>2],!!r;);}function Tk(r){r=r|0;var a=0;a=c[r+4>>2],c[r+4>>2]=0,a&&Pt[c[c[a>>2]+4>>2]](a),Zp(c[r>>2],0)}function a2(r){return r=r|0,c[r>>2]=4572,Tt[r+4|0]&&Vh(c[r+8>>2],1759),Ga(c[r+8>>2]),r|0}function o2(r){return r=r|0,c[r>>2]=4452,Tt[r+4|0]&&Vh(c[r+8>>2],1759),Ga(c[r+8>>2]),r|0}function kk(){var r=0;return r=ut(16),c[r>>2]=0,c[r+4>>2]=0,c[r+8>>2]=0,c[r+12>>2]=0,r|0}function l2(r,a,h){return cr(r,a)?Us(r,a,h):(h=Va(r,a,h),h==h&&(h=m(-h)),h)}function c2(r,a){var h=0;h=kt-16|0,kt=h,r||(c[h>>2]=a,lr(0,h),tr(),ce()),kt=h+16|0}function h2(r){r=r|0;var a=0;r&&(a=c[r>>2],a&&Ti(a),c[1752]=c[1752]-1,Ti(r))}function wk(r,a){return r=r|0,a=a|0,a>>>0>=3&&(Fs(),ce()),c[c[r>>2]+12>>2]>>>a&1}function Sk(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 Rk(){var r=0;return r=ut(16),c[r+8>>2]=0,c[r+12>>2]=0,c[r>>2]=0,r|0}function Lk(r){r=r|0;var a=m(0);return a=I[c[r>>2]+224>>2],+(a!=a?m(zt):a)}function _k(r){return r=r|0,r=c[c[r>>2]+552>>2],r?c[r>>2]:0}function Ck(r){r=r|0;var a=m(0);return a=I[c[r>>2]+32>>2],+(a==a?a:m(0))}function d2(r){var a=0;return a=Ip(ut(588),r),c2((r|0)!=0,2808),a}function Ik(r,a){r=r|0,a=a|0,r=c[r>>2],c[r+16>>2]=c[r+16>>2]&-2|a}function xk(r){return r=r|0,r=c[r>>2],c[r+560>>2]-c[r+556>>2]>>2}function Dk(r,a){r=r|0,a=a|0,r=c[r>>2],gt[r+8|0]=Tt[r+8|0]&254|a}function Pk(r){r=r|0,r=c[c[r>>2]+8>>2],Pt[c[c[r>>2]+8>>2]](r)}function Ok(r,a,h){r=r|0,a=a|0,h=+h,Uh(c[r>>2],a,Tr(m(h)))}function Mk(r,a,h){r=r|0,a=a|0,h=+h,Uh(c[r>>2],a,zr(m(h)))}function $k(r,a,h,u){return Gi=0,0}function Fk(r,a,h){r=r|0,a=a|0,h=+h,zp(c[r>>2],a,Tr(m(h)))}function Nk(r,a,h){r=r|0,a=a|0,h=+h,zp(c[r>>2],a,zr(m(h)))}function Uk(r,a,h){r=r|0,a=a|0,h=+h,Xp(c[r>>2],a,Tr(m(h)))}function Bk(r,a,h){r=r|0,a=a|0,h=+h,Xp(c[r>>2],a,zr(m(h)))}function Gk(r,a,h){r=r|0,a=a|0,h=h|0,c[c[r>>2]+a>>2]=h}function Vk(r,a){r=r|0,a=a|0,Uh(c[r>>2],a,2141891242)}function Hh(r,a,h){r=r|0,a=a|0,h=+h,He[c[r>>2]+a>>3]=h}function Hk(r){return r=r|0,(Tt[c[r>>2]+4|0]&2)>>>1|0}function Wk(r){return r=r|0,(Tt[c[r>>2]+4|0]&4)>>>2|0}function jk(r,a){r=r|0,a=a|0,c[r+4>>2]=10,c[r>>2]=a}function Kk(r,a){r=r|0,a=a|0,c[r+4>>2]=13,c[r>>2]=a}function Yk(r){return r=r|0,c[c[r>>2]+24>>2]>>>10&7}function zk(r){return r=r|0,c[c[r>>2]+24>>2]>>>13&7}function Wh(r,a){return r=r|0,a=a|0,+He[c[r>>2]+a>>3]}function Xk(r){return r=r|0,c[c[r>>2]+24>>2]>>>18&3}function Zk(r){return r=r|0,c[c[r>>2]+24>>2]>>>20&3}function qk(r){return r=r|0,c[c[r>>2]+24>>2]>>>22&1}function Qk(r,a){return r=r|0,a=a|0,c[c[r>>2]+a>>2]}function Jk(r,a){r=r|0,a=+a,Wn(c[r>>2],0,Tr(m(a)))}function t3(r,a){r=r|0,a=+a,Wn(c[r>>2],0,zr(m(a)))}function e3(r,a){r=r|0,a=+a,Wn(c[r>>2],1,Tr(m(a)))}function i3(r,a){r=r|0,a=+a,Wn(c[r>>2],1,zr(m(a)))}function r3(r,a){r=r|0,a=a|0,c[r+4>>2]=7,c[r>>2]=a}function s3(r,a){r=r|0,a=+a,dl(c[r>>2],0,Tr(m(a)))}function n3(r,a){r=r|0,a=+a,dl(c[r>>2],0,zr(m(a)))}function a3(r,a){r=r|0,a=+a,dl(c[r>>2],1,Tr(m(a)))}function o3(r,a){r=r|0,a=+a,dl(c[r>>2],1,zr(m(a)))}function l3(r,a){r=r|0,a=+a,ul(c[r>>2],0,Tr(m(a)))}function c3(r,a){r=r|0,a=+a,ul(c[r>>2],1,Tr(m(a)))}function h3(r,a){r=r|0,a=+a,ul(c[r>>2],1,zr(m(a)))}function d3(r){return r=r|0,c[c[r>>2]+24>>2]>>>7&7}function u3(r){return r=r|0,c[c[r>>2]+24>>2]>>>2&3}function f3(r){return r=r|0,c[c[r>>2]+24>>2]>>>4&7}function pl(r){r=r|0,r&&Pt[c[c[r>>2]+4>>2]](r)}function p3(r,a){r=r|0,a=+a,ul(c[r>>2],0,zr(m(a)))}function u2(r){return r?(c[1781]=r,-1):0}function g3(r,a){r=r|0,a=+a,Nh(c[r>>2],Tr(m(a)))}function m3(r,a){r=r|0,a=+a,Nh(c[r>>2],zr(m(a)))}function f2(r,a,h){return m(he(r,a,h)+Se(r,a,h))}function v3(r,a){return r=r|0,a=a|0,Pt[r|0](a)|0}function p2(r,a,h,u){QE(r|0,a|0,8,0,h|0,-1,u|0)}function y3(r,a){r=r|0,a=a|0,c[c[r>>2]+16>>2]=a}function b3(r){return r=r|0,c[c[r>>2]+16>>2]&1}function A3(r){return r=r|0,Bn[c[r>>2]+26>>1]&3}function E3(r){r=r|0,Wn(c[r>>2],0,2141891242)}function T3(r){r=r|0,Wn(c[r>>2],1,2141891242)}function k3(r){return r=r|0,+I[c[r>>2]+228>>2]}function w3(r){return r=r|0,+I[c[r>>2]+236>>2]}function S3(r){return r=r|0,+I[c[r>>2]+232>>2]}function R3(r){return r=r|0,+I[c[r>>2]+240>>2]}function L3(r){return r=r|0,+I[c[r>>2]+244>>2]}function _3(r){return r=r|0,+I[c[r>>2]+248>>2]}function C3(r){return r=r|0,iT(c[r+60>>2])|0}function I3(r){return r=r|0,c[c[r>>2]+16>>2]}function x3(r){return r=r|0,gt[c[r>>2]+8|0]&1}function D3(r,a){r=r|0,a=a|0,Fh(c[r>>2],5,a)}function P3(r,a){r=r|0,a=a|0,Fh(c[r>>2],6,a)}function O3(r,a){r=r|0,a=a|0,Fh(c[r>>2],7,a)}function M3(r){r=r|0,Nh(c[r>>2],2141891242)}function g2(r,a){r=r|0,a=a|0,Pt[c[r>>2]](a)}function $3(r){return r=r|0,jp(ut(12),r)|0}function F3(r){r=r|0,Vh(c[r+8>>2],3293)}function m2(r,a,h){return Bp(r,a,h,2,3)}function v2(r){return r=r|0,Pt[r|0]()|0}function y2(r,a){r=r|0,a=a|0,Pt[r|0](a)}function N3(){return Hi(ut(48),0,48)|0}function tr(){Pt[c[1490]](),Kh(),ce()}function U3(){return jp(ut(12),0)|0}function jh(r){r=r|0,r&&Ti(r)}function gl(r){return r-48>>>0<10}function B3(r){return 7032}function G3(r){return 7036}function V3(r){return 7056}function H3(r){return 7059}function W3(r){return 7062}function j3(r){return 7067}function Ir(r){return r=r|0,r|0}function b2(r){r=r|0,gt[r+4|0]=1}function K3(r){r=r|0,Ti(a2(r))}function Y3(r){r=r|0,Ti(o2(r))}function z3(r){return 0}function A2(r){ce()}function E2(){Kh(),ce()}function Kh(){Fs(),ce()}H=Tt,Lt();var Pt=B([null,dk,aT,cT,Ir,r3,jk,Kk,Ir,Ir,Ir,Ir,Ir,Ir,QT,Pk,_p,B3,pl,PT,G3,Ir,Ir,pl,b2,g2,i2,bk,vT,pk,V3,pl,n2,H3,Ir,Ir,pl,b2,g2,i2,Ak,gk,W3,h2,v2,JT,y2,h2,sk,t2,gT,ck,Ik,Bs,y3,Bs,Dk,wk,e2,b3,yn,I3,yn,x3,N3,jh,kk,jh,Rk,jh,Wh,Hh,Qk,Gk,j3,$p,v2,U3,v3,$3,y2,$p,uT,n2,lT,Bs,BT,Bs,Uk,ok,Bk,D3,P3,O3,KT,UT,jT,Ok,Mk,Vk,FT,NT,VT,hk,g3,m3,M3,HT,WT,Jk,t3,E3,e3,i3,T3,s3,n3,a3,o3,l3,p3,c3,h3,GT,OT,Fk,Nk,MT,A3,yn,AT,zT,d3,Yk,zk,u3,Xk,f3,ET,xT,ZT,Ck,uk,mk,kT,wT,ST,RT,LT,TT,Lk,$T,lk,Zk,qk,bT,DT,ak,hT,t2,dT,Bs,xk,yn,_k,yn,rk,e2,Hk,yn,YT,Bs,vk,Bs,Tk,fk,Bs,yk,XT,Wk,yn,oT,nk,k3,w3,S3,R3,L3,_3,tk,ek,_T,CT,IT,Wh,Hh,Wh,Hh,Fp,o2,Y3,mT,A2,E2,a2,K3,F3,A2,C3,fT,ik,z3,$k,yT,E2]);function T2(){return Bi.byteLength/65536|0}function X3(r){r=r|0;var a=T2()|0,h=a+r|0;if(a<h&&h<65536){var u=new ArrayBuffer(We(h,65536)),y=new Int8Array(u);y.set(gt),gt=new Int8Array(u),Wr=new Int16Array(u),c=new Int32Array(u),Tt=new Uint8Array(u),Bn=new Uint16Array(u),Ap=new Uint32Array(u),I=new Float32Array(u),He=new Float64Array(u),Bi=u,or.buffer=Bi,H=Tt}return a}return{E:qT,F:pT,G:Ek,H:Ph,I:Pt,J:Ti,K:Sk}}return ol(_)}(L)}var C=Error,D={};A=[],typeof D!="object"&&_t("no native wasm support detected");var M,U=!1;function x(L,_,B){B=_+B;for(var H="";!(_>=B);){var rt=L[_++];if(!rt)break;if(rt&128){var yt=L[_++]&63;if((rt&224)==192)H+=String.fromCharCode((rt&31)<<6|yt);else{var ct=L[_++]&63;rt=(rt&240)==224?(rt&15)<<12|yt<<6|ct:(rt&7)<<18|yt<<12|ct<<6|L[_++]&63,65536>rt?H+=String.fromCharCode(rt):(rt-=65536,H+=String.fromCharCode(55296|rt>>10,56320|rt&1023))}}else H+=String.fromCharCode(rt)}return H}var G,$,Y,tt,nt,J,St,mt,Ot;function Vt(L){G=L,o.HEAP8=$=new Int8Array(L),o.HEAP16=tt=new Int16Array(L),o.HEAP32=J=new Int32Array(L),o.HEAPU8=Y=new Uint8Array(L),o.HEAPU16=nt=new Uint16Array(L),o.HEAPU32=St=new Uint32Array(L),o.HEAPF32=mt=new Float32Array(L),o.HEAPF64=Ot=new Float64Array(L)}var V=o.INITIAL_MEMORY||16777216;o.wasmMemory?M=o.wasmMemory:M=new E,M&&(G=M.buffer),V=G.byteLength,Vt(G);var q,At=[],N=[],F=[];function j(){var L=o.preRun.shift();At.unshift(L)}var at=0,ht=null;function _t(L){throw o.onAbort&&o.onAbort(L),L="Aborted("+L+")",v(L),U=!0,L=new C(L+". Build with -sASSERTIONS for more info."),d(L),L}function $t(L){return L.startsWith("data:application/octet-stream;base64,")}var jt;if(jt="<<< WASM_BINARY_FILE >>>",!$t(jt)){var fe=jt;jt=o.locateFile?o.locateFile(fe,p):p+fe}function ve(L){var _=jt;try{try{if(_==jt&&A)new Uint8Array(A);else{if($t(_)){try{var B=VE(_.slice(37)),H=new Uint8Array(B.length);for(_=0;_<B.length;++_)H[_]=B.charCodeAt(_);var rt=H}catch{throw Error("Converting base64 string to bytes failed.")}var yt=rt}else yt=void 0;if(!yt)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(It){_t(It)}var ct=new T,Lt=new w(L)}catch(It){throw L=It.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)."),It}return[Lt,ct]}function me(L){for(;0<L.length;)L.shift()(o)}function Ke(L){if(L===void 0)return"_unknown";L=L.replace(/[^a-zA-Z0-9_]/g,"$");var _=L.charCodeAt(0);return 48<=_&&57>=_?"_"+L:L}function Le(L,_){return L=Ke(L),function(){return _.apply(this,arguments)}}var Kt=[{},{value:void 0},{value:null},{value:!0},{value:!1}],Ae=[];function de(L){var _=Error,B=Le(L,function(H){this.name=L,this.message=H,H=Error(H).stack,H!==void 0&&(this.stack=this.toString()+`
90
+ `+H.replace(/^Error(:[^\n]*)?\n/,""))});return B.prototype=Object.create(_.prototype),B.prototype.constructor=B,B.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},B}var Me=void 0;function Ut(L){throw new Me(L)}var Ye=L=>(L||Ut("Cannot use deleted val. handle = "+L),Kt[L].value),Fe=L=>{switch(L){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var _=Ae.length?Ae.pop():Kt.length;return Kt[_]={fa:1,value:L},_}},Ve=void 0,we=void 0;function ue(L){for(var _="";Y[L];)_+=we[Y[L++]];return _}var ze=[];function le(){for(;ze.length;){var L=ze.pop();L.L.Z=!1,L.delete()}}var Ne=void 0,Ue={};function pi(L,_){for(_===void 0&&Ut("ptr should not be undefined");L.P;)_=L.aa(_),L=L.P;return _}var Ce={};function Ai(L){L=WE(L);var _=ue(L);return $s(L),_}function Lr(L,_){var B=Ce[L];return B===void 0&&Ut(_+" has unknown type "+Ai(L)),B}function ni(){}var _r=!1;function Ds(L){--L.count.value,L.count.value===0&&(L.S?L.T.V(L.S):L.O.M.V(L.N))}function Ps(L,_,B){return _===B?L:B.P===void 0?null:(L=Ps(L,_,B.P),L===null?null:B.ma(L))}var ar={};function dt(L,_){return _=pi(L,_),Ue[_]}var Gt=void 0;function Zt(L){throw new Gt(L)}function ye(L,_){return _.O&&_.N||Zt("makeClassHandle requires ptr and ptrType"),!!_.T!=!!_.S&&Zt("Both smartPtrType and smartPtr must be specified"),_.count={value:1},ne(Object.create(L,{L:{value:_}}))}function ne(L){return typeof FinalizationRegistry>"u"?(ne=_=>_,L):(_r=new FinalizationRegistry(_=>{Ds(_.L)}),ne=_=>{var B=_.L;return B.S&&_r.register(_,{L:B},_),_},ni=_=>{_r.unregister(_)},ne(L))}var ci={};function Oi(L){for(;L.length;){var _=L.pop();L.pop()(_)}}function vr(L){return this.fromWireType(J[L>>2])}var hs={},yr={};function br(L,_,B){function H(Lt){Lt=B(Lt),Lt.length!==L.length&&Zt("Mismatched type converter count");for(var It=0;It<L.length;++It)Mi(L[It],Lt[It])}L.forEach(function(Lt){yr[Lt]=_});var rt=Array(_.length),yt=[],ct=0;_.forEach((Lt,It)=>{Ce.hasOwnProperty(Lt)?rt[It]=Ce[Lt]:(yt.push(Lt),hs.hasOwnProperty(Lt)||(hs[Lt]=[]),hs[Lt].push(()=>{rt[It]=Ce[Lt],++ct,ct===yt.length&&H(rt)}))}),yt.length===0&&H(rt)}function Os(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 Mi(L,_,B={}){if(!("argPackAdvance"in _))throw new TypeError("registerType registeredInstance requires argPackAdvance");var H=_.name;if(L||Ut('type "'+H+'" must have a positive integer typeid pointer'),Ce.hasOwnProperty(L)){if(B.ta)return;Ut("Cannot register type '"+H+"' twice")}Ce[L]=_,delete yr[L],hs.hasOwnProperty(L)&&(_=hs[L],delete hs[L],_.forEach(rt=>rt()))}function Ba(L){Ut(L.L.O.M.name+" instance already deleted")}function Ar(){}function Ms(L,_,B){if(L[_].R===void 0){var H=L[_];L[_]=function(){return L[_].R.hasOwnProperty(arguments.length)||Ut("Function '"+B+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+L[_].R+")!"),L[_].R[arguments.length].apply(this,arguments)},L[_].R=[],L[_].R[H.Y]=H}}function kE(L,_){o.hasOwnProperty(L)?(Ut("Cannot register public name '"+L+"' twice"),Ms(o,L,L),o.hasOwnProperty(void 0)&&Ut("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),o[L].R[void 0]=_):o[L]=_}function wE(L,_,B,H,rt,yt,ct,Lt){this.name=L,this.constructor=_,this.W=B,this.V=H,this.P=rt,this.oa=yt,this.aa=ct,this.ma=Lt,this.ia=[]}function Sh(L,_,B){for(;_!==B;)_.aa||Ut("Expected null or instance of "+B.name+", got an instance of "+_.name),L=_.aa(L),_=_.P;return L}function SE(L,_){return _===null?(this.da&&Ut("null is not a valid "+this.name),0):(_.L||Ut('Cannot pass "'+Ch(_)+'" as a '+this.name),_.L.N||Ut("Cannot pass deleted object as a pointer of type "+this.name),Sh(_.L.N,_.L.O.M,this.M))}function RE(L,_){if(_===null){if(this.da&&Ut("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(_.L||Ut('Cannot pass "'+Ch(_)+'" as a '+this.name),_.L.N||Ut("Cannot pass deleted object as a pointer of type "+this.name),!this.ba&&_.L.O.ba&&Ut("Cannot convert argument of type "+(_.L.T?_.L.T.name:_.L.O.name)+" to parameter type "+this.name),B=Sh(_.L.N,_.L.O.M,this.M),this.ca)switch(_.L.S===void 0&&Ut("Passing raw pointer to smart pointer is illegal"),this.Aa){case 0:_.L.T===this?B=_.L.S:Ut("Cannot convert argument of type "+(_.L.T?_.L.T.name:_.L.O.name)+" to parameter type "+this.name);break;case 1:B=_.L.S;break;case 2:if(_.L.T===this)B=_.L.S;else{var H=_.clone();B=this.wa(B,Fe(function(){H.delete()})),L!==null&&L.push(this.V,B)}break;default:Ut("Unsupporting sharing policy")}return B}function LE(L,_){return _===null?(this.da&&Ut("null is not a valid "+this.name),0):(_.L||Ut('Cannot pass "'+Ch(_)+'" as a '+this.name),_.L.N||Ut("Cannot pass deleted object as a pointer of type "+this.name),_.L.O.ba&&Ut("Cannot convert argument of type "+_.L.O.name+" to parameter type "+this.name),Sh(_.L.N,_.L.O.M,this.M))}function ds(L,_,B,H){this.name=L,this.M=_,this.da=B,this.ba=H,this.ca=!1,this.V=this.wa=this.ea=this.ja=this.Aa=this.va=void 0,_.P!==void 0?this.toWireType=RE:(this.toWireType=H?SE:LE,this.U=null)}function _E(L,_){o.hasOwnProperty(L)||Zt("Replacing nonexistant public symbol"),o[L]=_,o[L].Y=void 0}function CE(L,_){var B=[];return function(){if(B.length=0,Object.assign(B,arguments),L.includes("j")){var H=o["dynCall_"+L];H=B&&B.length?H.apply(null,[_].concat(B)):H.call(null,_)}else H=q.get(_).apply(null,B);return H}}function Cr(L,_){L=ue(L);var B=L.includes("j")?CE(L,_):q.get(_);return typeof B!="function"&&Ut("unknown function pointer with signature "+L+": "+_),B}var pp=void 0;function rl(L,_){function B(yt){rt[yt]||Ce[yt]||(yr[yt]?yr[yt].forEach(B):(H.push(yt),rt[yt]=!0))}var H=[],rt={};throw _.forEach(B),new pp(L+": "+H.map(Ai).join([", "]))}function Rh(L,_,B,H,rt){var yt=_.length;2>yt&&Ut("argTypes array size mismatch! Must at least get return value and 'this' types!");var ct=_[1]!==null&&B!==null,Lt=!1;for(B=1;B<_.length;++B)if(_[B]!==null&&_[B].U===void 0){Lt=!0;break}var It=_[0].name!=="void",xt=yt-2,Nt=Array(xt),Yt=[],te=[];return function(){if(arguments.length!==xt&&Ut("function "+L+" called with "+arguments.length+" arguments, expected "+xt+" args!"),te.length=0,Yt.length=ct?2:1,Yt[0]=rt,ct){var Dt=_[1].toWireType(te,this);Yt[1]=Dt}for(var Ee=0;Ee<xt;++Ee)Nt[Ee]=_[Ee+2].toWireType(te,arguments[Ee]),Yt.push(Nt[Ee]);if(Ee=H.apply(null,Yt),Lt)Oi(te);else for(var Ei=ct?1:2;Ei<_.length;Ei++){var ce=Ei===1?Dt:Nt[Ei-2];_[Ei].U!==null&&_[Ei].U(ce)}return Dt=It?_[0].fromWireType(Ee):void 0,Dt}}function Lh(L,_){for(var B=[],H=0;H<L;H++)B.push(St[_+4*H>>2]);return B}function _h(L){4<L&&--Kt[L].fa===0&&(Kt[L]=void 0,Ae.push(L))}function Ch(L){if(L===null)return"null";var _=typeof L;return _==="object"||_==="array"||_==="function"?L.toString():""+L}function IE(L,_){switch(_){case 2:return function(B){return this.fromWireType(mt[B>>2])};case 3:return function(B){return this.fromWireType(Ot[B>>3])};default:throw new TypeError("Unknown float type: "+L)}}function xE(L,_,B){switch(_){case 0:return B?function(H){return $[H]}:function(H){return Y[H]};case 1:return B?function(H){return tt[H>>1]}:function(H){return nt[H>>1]};case 2:return B?function(H){return J[H>>2]}:function(H){return St[H>>2]};default:throw new TypeError("Unknown integer type: "+L)}}function DE(L,_){for(var B="",H=0;!(H>=_/2);++H){var rt=tt[L+2*H>>1];if(rt==0)break;B+=String.fromCharCode(rt)}return B}function PE(L,_,B){if(B===void 0&&(B=2147483647),2>B)return 0;B-=2;var H=_;B=B<2*L.length?B/2:L.length;for(var rt=0;rt<B;++rt)tt[_>>1]=L.charCodeAt(rt),_+=2;return tt[_>>1]=0,_-H}function OE(L){return 2*L.length}function ME(L,_){for(var B=0,H="";!(B>=_/4);){var rt=J[L+4*B>>2];if(rt==0)break;++B,65536<=rt?(rt-=65536,H+=String.fromCharCode(55296|rt>>10,56320|rt&1023)):H+=String.fromCharCode(rt)}return H}function $E(L,_,B){if(B===void 0&&(B=2147483647),4>B)return 0;var H=_;B=H+B-4;for(var rt=0;rt<L.length;++rt){var yt=L.charCodeAt(rt);if(55296<=yt&&57343>=yt){var ct=L.charCodeAt(++rt);yt=65536+((yt&1023)<<10)|ct&1023}if(J[_>>2]=yt,_+=4,_+4>B)break}return J[_>>2]=0,_-H}function FE(L){for(var _=0,B=0;B<L.length;++B){var H=L.charCodeAt(B);55296<=H&&57343>=H&&++B,_+=4}return _}var NE={};function gp(L){var _=NE[L];return _===void 0?ue(L):_}var sl=[];function UE(L){var _=sl.length;return sl.push(L),_}function BE(L,_){for(var B=Array(L),H=0;H<L;++H)B[H]=Lr(St[_+4*H>>2],"parameter "+H);return B}var mp=[],GE=[null,[],[]];Me=o.BindingError=de("BindingError"),o.count_emval_handles=function(){for(var L=0,_=5;_<Kt.length;++_)Kt[_]!==void 0&&++L;return L},o.get_first_emval=function(){for(var L=5;L<Kt.length;++L)if(Kt[L]!==void 0)return Kt[L];return null},Ve=o.PureVirtualError=de("PureVirtualError");for(var vp=Array(256),nl=0;256>nl;++nl)vp[nl]=String.fromCharCode(nl);we=vp,o.getInheritedInstanceCount=function(){return Object.keys(Ue).length},o.getLiveInheritedInstances=function(){var L=[],_;for(_ in Ue)Ue.hasOwnProperty(_)&&L.push(Ue[_]);return L},o.flushPendingDeletes=le,o.setDelayFunction=function(L){Ne=L,ze.length&&Ne&&Ne(le)},Gt=o.InternalError=de("InternalError"),Ar.prototype.isAliasOf=function(L){if(!(this instanceof Ar&&L instanceof Ar))return!1;var _=this.L.O.M,B=this.L.N,H=L.L.O.M;for(L=L.L.N;_.P;)B=_.aa(B),_=_.P;for(;H.P;)L=H.aa(L),H=H.P;return _===H&&B===L},Ar.prototype.clone=function(){if(this.L.N||Ba(this),this.L.$)return this.L.count.value+=1,this;var L=ne,_=Object,B=_.create,H=Object.getPrototypeOf(this),rt=this.L;return L=L(B.call(_,H,{L:{value:{count:rt.count,Z:rt.Z,$:rt.$,N:rt.N,O:rt.O,S:rt.S,T:rt.T}}})),L.L.count.value+=1,L.L.Z=!1,L},Ar.prototype.delete=function(){this.L.N||Ba(this),this.L.Z&&!this.L.$&&Ut("Object already scheduled for deletion"),ni(this),Ds(this.L),this.L.$||(this.L.S=void 0,this.L.N=void 0)},Ar.prototype.isDeleted=function(){return!this.L.N},Ar.prototype.deleteLater=function(){return this.L.N||Ba(this),this.L.Z&&!this.L.$&&Ut("Object already scheduled for deletion"),ze.push(this),ze.length===1&&Ne&&Ne(le),this.L.Z=!0,this},ds.prototype.pa=function(L){return this.ja&&(L=this.ja(L)),L},ds.prototype.ga=function(L){this.V&&this.V(L)},ds.prototype.argPackAdvance=8,ds.prototype.readValueFromPointer=vr,ds.prototype.deleteObject=function(L){L!==null&&L.delete()},ds.prototype.fromWireType=function(L){function _(){return this.ca?ye(this.M.W,{O:this.va,N:B,T:this,S:L}):ye(this.M.W,{O:this,N:L})}var B=this.pa(L);if(!B)return this.ga(L),null;var H=dt(this.M,B);if(H!==void 0)return H.L.count.value===0?(H.L.N=B,H.L.S=L,H.clone()):(H=H.clone(),this.ga(L),H);if(H=this.M.oa(B),H=ar[H],!H)return _.call(this);H=this.ba?H.ka:H.pointerType;var rt=Ps(B,this.M,H.M);return rt===null?_.call(this):this.ca?ye(H.M.W,{O:H,N:rt,T:this,S:L}):ye(H.M.W,{O:H,N:rt})},pp=o.UnboundTypeError=de("UnboundTypeError");var VE=typeof atob=="function"?atob:function(L){var _="",B=0;L=L.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var H="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(L.charAt(B++)),rt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(L.charAt(B++)),yt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(L.charAt(B++)),ct="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(L.charAt(B++));H=H<<2|rt>>4,rt=(rt&15)<<4|yt>>2;var Lt=(yt&3)<<6|ct;_+=String.fromCharCode(H),yt!==64&&(_+=String.fromCharCode(rt)),ct!==64&&(_+=String.fromCharCode(Lt))}while(B<L.length);return _},HE={q:function(L,_,B){L=ue(L),_=Lr(_,"wrapper"),B=Ye(B);var H=[].slice,rt=_.M,yt=rt.W,ct=rt.P.W,Lt=rt.P.constructor;L=Le(L,function(){rt.P.ia.forEach((function(xt){if(this[xt]===ct[xt])throw new Ve("Pure virtual function "+xt+" must be implemented in JavaScript")}).bind(this)),Object.defineProperty(this,"__parent",{value:yt}),this.__construct.apply(this,H.call(arguments))}),yt.__construct=function(){this===yt&&Ut("Pass correct 'this' to __construct");var xt=Lt.implement.apply(void 0,[this].concat(H.call(arguments)));ni(xt);var Nt=xt.L;xt.notifyOnDestruction(),Nt.$=!0,Object.defineProperties(this,{L:{value:Nt}}),ne(this),xt=Nt.N,xt=pi(rt,xt),Ue.hasOwnProperty(xt)?Ut("Tried to register registered instance: "+xt):Ue[xt]=this},yt.__destruct=function(){this===yt&&Ut("Pass correct 'this' to __destruct"),ni(this);var xt=this.L.N;xt=pi(rt,xt),Ue.hasOwnProperty(xt)?delete Ue[xt]:Ut("Tried to unregister unregistered instance: "+xt)},L.prototype=Object.create(yt);for(var It in B)L.prototype[It]=B[It];return Fe(L)},k:function(L){var _=ci[L];delete ci[L];var B=_.ea,H=_.V,rt=_.ha,yt=rt.map(ct=>ct.sa).concat(rt.map(ct=>ct.ya));br([L],yt,ct=>{var Lt={};return rt.forEach((It,xt)=>{var Nt=ct[xt],Yt=It.qa,te=It.ra,Dt=ct[xt+rt.length],Ee=It.xa,Ei=It.za;Lt[It.na]={read:ce=>Nt.fromWireType(Yt(te,ce)),write:(ce,Ji)=>{var Bt=[];Ee(Ei,ce,Dt.toWireType(Bt,Ji)),Oi(Bt)}}}),[{name:_.name,fromWireType:function(It){var xt={},Nt;for(Nt in Lt)xt[Nt]=Lt[Nt].read(It);return H(It),xt},toWireType:function(It,xt){for(var Nt in Lt)if(!(Nt in xt))throw new TypeError('Missing field: "'+Nt+'"');var Yt=B();for(Nt in Lt)Lt[Nt].write(Yt,xt[Nt]);return It!==null&&It.push(H,Yt),Yt},argPackAdvance:8,readValueFromPointer:vr,U:H}]})},w:function(){},C:function(L,_,B,H,rt){var yt=Os(B);_=ue(_),Mi(L,{name:_,fromWireType:function(ct){return!!ct},toWireType:function(ct,Lt){return Lt?H:rt},argPackAdvance:8,readValueFromPointer:function(ct){if(B===1)var Lt=$;else if(B===2)Lt=tt;else if(B===4)Lt=J;else throw new TypeError("Unknown boolean type size: "+_);return this.fromWireType(Lt[ct>>yt])},U:null})},g:function(L,_,B,H,rt,yt,ct,Lt,It,xt,Nt,Yt,te){Nt=ue(Nt),yt=Cr(rt,yt),Lt&&(Lt=Cr(ct,Lt)),xt&&(xt=Cr(It,xt)),te=Cr(Yt,te);var Dt=Ke(Nt);kE(Dt,function(){rl("Cannot construct "+Nt+" due to unbound types",[H])}),br([L,_,B],H?[H]:[],function(Ee){if(Ee=Ee[0],H)var Ei=Ee.M,ce=Ei.W;else ce=Ar.prototype;Ee=Le(Dt,function(){if(Object.getPrototypeOf(this)!==Ji)throw new Me("Use 'new' to construct "+Nt);if(Bt.X===void 0)throw new Me(Nt+" has no accessible constructor");var ai=Bt.X[arguments.length];if(ai===void 0)throw new Me("Tried to invoke ctor of "+Nt+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(Bt.X).toString()+") parameters instead!");return ai.apply(this,arguments)});var Ji=Object.create(ce,{constructor:{value:Ee}});Ee.prototype=Ji;var Bt=new wE(Nt,Ee,Ji,te,Ei,yt,Lt,xt);Ei=new ds(Nt,Bt,!0,!1),ce=new ds(Nt+"*",Bt,!1,!1);var ol=new ds(Nt+" const*",Bt,!1,!0);return ar[L]={pointerType:ce,ka:ol},_E(Dt,Ee),[Ei,ce,ol]})},d:function(L,_,B,H,rt,yt,ct){var Lt=Lh(B,H);_=ue(_),yt=Cr(rt,yt),br([],[L],function(It){function xt(){rl("Cannot call "+Nt+" due to unbound types",Lt)}It=It[0];var Nt=It.name+"."+_;_.startsWith("@@")&&(_=Symbol[_.substring(2)]);var Yt=It.M.constructor;return Yt[_]===void 0?(xt.Y=B-1,Yt[_]=xt):(Ms(Yt,_,Nt),Yt[_].R[B-1]=xt),br([],Lt,function(te){return te=Rh(Nt,[te[0],null].concat(te.slice(1)),null,yt,ct),Yt[_].R===void 0?(te.Y=B-1,Yt[_]=te):Yt[_].R[B-1]=te,[]}),[]})},p:function(L,_,B,H,rt,yt){0<_||_t();var ct=Lh(_,B);rt=Cr(H,rt),br([],[L],function(Lt){Lt=Lt[0];var It="constructor "+Lt.name;if(Lt.M.X===void 0&&(Lt.M.X=[]),Lt.M.X[_-1]!==void 0)throw new Me("Cannot register multiple constructors with identical number of parameters ("+(_-1)+") for class '"+Lt.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return Lt.M.X[_-1]=()=>{rl("Cannot construct "+Lt.name+" due to unbound types",ct)},br([],ct,function(xt){return xt.splice(1,0,null),Lt.M.X[_-1]=Rh(It,xt,null,rt,yt),[]}),[]})},b:function(L,_,B,H,rt,yt,ct,Lt){var It=Lh(B,H);_=ue(_),yt=Cr(rt,yt),br([],[L],function(xt){function Nt(){rl("Cannot call "+Yt+" due to unbound types",It)}xt=xt[0];var Yt=xt.name+"."+_;_.startsWith("@@")&&(_=Symbol[_.substring(2)]),Lt&&xt.M.ia.push(_);var te=xt.M.W,Dt=te[_];return Dt===void 0||Dt.R===void 0&&Dt.className!==xt.name&&Dt.Y===B-2?(Nt.Y=B-2,Nt.className=xt.name,te[_]=Nt):(Ms(te,_,Yt),te[_].R[B-2]=Nt),br([],It,function(Ee){return Ee=Rh(Yt,Ee,xt,yt,ct),te[_].R===void 0?(Ee.Y=B-2,te[_]=Ee):te[_].R[B-2]=Ee,[]}),[]})},B:function(L,_){_=ue(_),Mi(L,{name:_,fromWireType:function(B){var H=Ye(B);return _h(B),H},toWireType:function(B,H){return Fe(H)},argPackAdvance:8,readValueFromPointer:vr,U:null})},n:function(L,_,B){B=Os(B),_=ue(_),Mi(L,{name:_,fromWireType:function(H){return H},toWireType:function(H,rt){return rt},argPackAdvance:8,readValueFromPointer:IE(_,B),U:null})},e:function(L,_,B,H,rt){_=ue(_),rt===-1&&(rt=4294967295),rt=Os(B);var yt=Lt=>Lt;if(H===0){var ct=32-8*B;yt=Lt=>Lt<<ct>>>ct}B=_.includes("unsigned")?function(Lt,It){return It>>>0}:function(Lt,It){return It},Mi(L,{name:_,fromWireType:yt,toWireType:B,argPackAdvance:8,readValueFromPointer:xE(_,rt,H!==0),U:null})},c:function(L,_,B){function H(yt){yt>>=2;var ct=St;return new rt(G,ct[yt+1],ct[yt])}var rt=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][_];B=ue(B),Mi(L,{name:B,fromWireType:H,argPackAdvance:8,readValueFromPointer:H},{ta:!0})},o:function(L,_){_=ue(_);var B=_==="std::string";Mi(L,{name:_,fromWireType:function(H){var rt=St[H>>2],yt=H+4;if(B)for(var ct=yt,Lt=0;Lt<=rt;++Lt){var It=yt+Lt;if(Lt==rt||Y[It]==0){if(ct=ct?x(Y,ct,It-ct):"",xt===void 0)var xt=ct;else xt+=String.fromCharCode(0),xt+=ct;ct=It+1}}else{for(xt=Array(rt),Lt=0;Lt<rt;++Lt)xt[Lt]=String.fromCharCode(Y[yt+Lt]);xt=xt.join("")}return $s(H),xt},toWireType:function(H,rt){rt instanceof ArrayBuffer&&(rt=new Uint8Array(rt));var yt,ct=typeof rt=="string";if(ct||rt instanceof Uint8Array||rt instanceof Uint8ClampedArray||rt instanceof Int8Array||Ut("Cannot pass non-string to std::string"),B&&ct){var Lt=0;for(yt=0;yt<rt.length;++yt){var It=rt.charCodeAt(yt);127>=It?Lt++:2047>=It?Lt+=2:55296<=It&&57343>=It?(Lt+=4,++yt):Lt+=3}yt=Lt}else yt=rt.length;if(Lt=yp(4+yt+1),It=Lt+4,St[Lt>>2]=yt,B&&ct){if(ct=It,It=yt+1,yt=Y,0<It){It=ct+It-1;for(var xt=0;xt<rt.length;++xt){var Nt=rt.charCodeAt(xt);if(55296<=Nt&&57343>=Nt){var Yt=rt.charCodeAt(++xt);Nt=65536+((Nt&1023)<<10)|Yt&1023}if(127>=Nt){if(ct>=It)break;yt[ct++]=Nt}else{if(2047>=Nt){if(ct+1>=It)break;yt[ct++]=192|Nt>>6}else{if(65535>=Nt){if(ct+2>=It)break;yt[ct++]=224|Nt>>12}else{if(ct+3>=It)break;yt[ct++]=240|Nt>>18,yt[ct++]=128|Nt>>12&63}yt[ct++]=128|Nt>>6&63}yt[ct++]=128|Nt&63}}yt[ct]=0}}else if(ct)for(ct=0;ct<yt;++ct)xt=rt.charCodeAt(ct),255<xt&&($s(It),Ut("String has UTF-16 code units that do not fit in 8 bits")),Y[It+ct]=xt;else for(ct=0;ct<yt;++ct)Y[It+ct]=rt[ct];return H!==null&&H.push($s,Lt),Lt},argPackAdvance:8,readValueFromPointer:vr,U:function(H){$s(H)}})},j:function(L,_,B){if(B=ue(B),_===2)var H=DE,rt=PE,yt=OE,ct=()=>nt,Lt=1;else _===4&&(H=ME,rt=$E,yt=FE,ct=()=>St,Lt=2);Mi(L,{name:B,fromWireType:function(It){for(var xt=St[It>>2],Nt=ct(),Yt,te=It+4,Dt=0;Dt<=xt;++Dt){var Ee=It+4+Dt*_;(Dt==xt||Nt[Ee>>Lt]==0)&&(te=H(te,Ee-te),Yt===void 0?Yt=te:(Yt+=String.fromCharCode(0),Yt+=te),te=Ee+_)}return $s(It),Yt},toWireType:function(It,xt){typeof xt!="string"&&Ut("Cannot pass non-string to C++ string type "+B);var Nt=yt(xt),Yt=yp(4+Nt+_);return St[Yt>>2]=Nt>>Lt,rt(xt,Yt+4,Nt+_),It!==null&&It.push($s,Yt),Yt},argPackAdvance:8,readValueFromPointer:vr,U:function(It){$s(It)}})},l:function(L,_,B,H,rt,yt){ci[L]={name:ue(_),ea:Cr(B,H),V:Cr(rt,yt),ha:[]}},i:function(L,_,B,H,rt,yt,ct,Lt,It,xt){ci[L].ha.push({na:ue(_),sa:B,qa:Cr(H,rt),ra:yt,ya:ct,xa:Cr(Lt,It),za:xt})},D:function(L,_){_=ue(_),Mi(L,{ua:!0,name:_,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},t:function(L,_,B,H,rt){L=sl[L],_=Ye(_),B=gp(B);var yt=[];return St[H>>2]=Fe(yt),L(_,B,yt,rt)},u:function(L,_,B,H){L=sl[L],_=Ye(_),B=gp(B),L(_,B,null,H)},h:_h,m:function(L,_){var B=BE(L,_),H=B[0];_=H.name+"_$"+B.slice(1).map(function(ct){return ct.name}).join("_")+"$";var rt=mp[_];if(rt!==void 0)return rt;var yt=Array(L-1);return rt=UE((ct,Lt,It,xt)=>{for(var Nt=0,Yt=0;Yt<L-1;++Yt)yt[Yt]=B[Yt+1].readValueFromPointer(xt+Nt),Nt+=B[Yt+1].argPackAdvance;for(ct=ct[Lt].apply(ct,yt),Yt=0;Yt<L-1;++Yt)B[Yt+1].la&&B[Yt+1].la(yt[Yt]);if(!H.ua)return H.toWireType(It,ct)}),mp[_]=rt},r:function(L){4<L&&(Kt[L].fa+=1)},s:function(L){var _=Ye(L);Oi(_),_h(L)},f:function(){_t("")},y:function(L,_,B){Y.copyWithin(L,_,_+B)},x:function(L){var _=Y.length;if(L>>>=0,2147483648<L)return!1;for(var B=1;4>=B;B*=2){var H=_*(1+.2/B);H=Math.min(H,L+100663296);var rt=Math;H=Math.max(L,H),rt=rt.min.call(rt,2147483648,H+(65536-H%65536)%65536);t:{try{M.grow(rt-G.byteLength+65535>>>16),Vt(M.buffer);var yt=1;break t}catch{}yt=void 0}if(yt)return!0}return!1},A:function(){return 52},v:function(){return 70},z:function(L,_,B,H){for(var rt=0,yt=0;yt<B;yt++){var ct=St[_>>2],Lt=St[_+4>>2];_+=8;for(var It=0;It<Lt;It++){var xt=Y[ct+It],Nt=GE[L];xt===0||xt===10?((L===1?g:v)(x(Nt,0)),Nt.length=0):Nt.push(xt)}rt+=Lt}return St[H>>2]=rt,0},a:M},Un=function(){function L(B){o.asm=B.exports,q=o.asm.I,N.unshift(o.asm.E),at--,o.monitorRunDependencies&&o.monitorRunDependencies(at),at==0&&ht&&(B=ht,ht=null,B())}var _={a:HE};if(at++,o.monitorRunDependencies&&o.monitorRunDependencies(at),o.instantiateWasm)try{return o.instantiateWasm(_,L)}catch(B){v("Module.instantiateWasm callback failed with error: "+B),d(B)}return _=ve(_),L(_[0]),o.asm}();o.___wasm_call_ctors=Un.E;var WE=o.___getTypeName=Un.F;o.__embind_initialize_bindings=Un.G;var yp=o._malloc=Un.H,$s=o._free=Un.J;o.dynCall_jiji=Un.K;var al;ht=function L(){al||bp(),al||(ht=L)};function bp(){function L(){if(!al&&(al=!0,o.calledRun=!0,!U)){if(me(N),l(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;){var _=o.postRun.shift();F.unshift(_)}me(F)}}if(!(0<at)){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)j();me(At),0<at||(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 bp(),n}})();s.exports=e})(tu);var Am=tu.exports;(function(s){Object.defineProperty(s,"__esModule",{value:!0});var t={};s.default=void 0;var e=n(jl),i=re;Object.keys(i).forEach(function(d){d==="default"||d==="__esModule"||Object.prototype.hasOwnProperty.call(t,d)||d in s&&s[d]===i[d]||Object.defineProperty(s,d,{enumerable:!0,get:function(){return i[d]}})});function n(d){return d&&d.__esModule?d:{default:d}}const o=Am;var l=(0,e.default)(o());s.default=l})(Te);const eu=mm(Te),rs=1.8;function Em(s,t){return typeof s=="number"?{top:s*t,right:s*t,bottom:s*t,left:s*t}:{top:typeof s.top=="number"?s.top*t:s.top,right:typeof s.right=="number"?s.right*t:s.right,bottom:typeof s.bottom=="number"?s.bottom*t:s.bottom,left:typeof s.left=="number"?s.left*t:s.left}}function iu(s,t){return typeof s=="number"?{top:s*t,right:s*t,bottom:s*t,left:s*t}:{top:(typeof s.top=="number"?s.top*t:s.top)??0,right:(typeof s.right=="number"?s.right*t:s.right)??0,bottom:(typeof s.bottom=="number"?s.bottom*t:s.bottom)??0,left:(typeof s.left=="number"?s.left*t:s.left)??0}}function Tm(s,t=1){return typeof s=="number"?{topLeft:s*t,topRight:s*t,bottomRight:s*t,bottomLeft:s*t}:{topLeft:((s==null?void 0:s.topLeft)??0)*t,topRight:((s==null?void 0:s.topRight)??0)*t,bottomRight:((s==null?void 0:s.bottomRight)??0)*t,bottomLeft:((s==null?void 0:s.bottomLeft)??0)*t}}function ru(s,{layout:t,scale:e=1}){const{position:i="static",inset:n,width:o,height:l,minWidth:d,minHeight:f,maxWidth:p,maxHeight:g,flex:v,gap:A,margin:E,padding:T,direction:w="column",align:C="start",alignSelf:D,justify:M="start"}=t,U={static:Te.PositionType.Static,relative:Te.PositionType.Relative,absolute:Te.PositionType.Absolute};if(s.setPositionType(U[i]),n){const{top:Y,right:tt,bottom:nt,left:J}=Em(n,e);Y&&s.setPosition(Te.Edge.Top,Y),tt&&s.setPosition(Te.Edge.Right,tt),nt&&s.setPosition(Te.Edge.Bottom,nt),J&&s.setPosition(Te.Edge.Left,J)}const x={row:Te.FlexDirection.Row,column:Te.FlexDirection.Column,"row-reverse":Te.FlexDirection.RowReverse,"column-reverse":Te.FlexDirection.ColumnReverse};s.setFlexDirection(x[w]);const G={start:Te.Align.FlexStart,end:Te.Align.FlexEnd,center:Te.Align.Center,stretch:Te.Align.Stretch};s.setAlignItems(G[C]),D&&s.setAlignSelf(G[D]);const $={start:Te.Justify.FlexStart,end:Te.Justify.FlexEnd,center:Te.Justify.Center,"space-between":Te.Justify.SpaceBetween,"space-around":Te.Justify.SpaceAround,"space-evenly":Te.Justify.SpaceEvenly};if(s.setJustifyContent($[M]),E){const{top:Y,right:tt,bottom:nt,left:J}=iu(E,e);s.setMargin(Te.Edge.Top,Y),s.setMargin(Te.Edge.Right,tt),s.setMargin(Te.Edge.Bottom,nt),s.setMargin(Te.Edge.Left,J)}if(T){const{top:Y,right:tt,bottom:nt,left:J}=iu(T,e);s.setPadding(Te.Edge.Top,Y),s.setPadding(Te.Edge.Right,tt),s.setPadding(Te.Edge.Bottom,nt),s.setPadding(Te.Edge.Left,J)}v&&s.setFlex(v),s.setGap(Te.Gutter.All,(A??0)*e),o&&s.setWidth(typeof o=="number"?o*e:o),l&&(typeof l=="function"?s.setHeight("100%"):s.setHeight(typeof l=="number"?l*e:l)),d&&s.setMinWidth(typeof d=="number"?d*e:d),f&&s.setMinHeight(typeof f=="number"?f*e:f),p&&s.setMaxWidth(typeof p=="number"?p*e:p),g&&s.setMaxHeight(typeof g=="number"?g*e:g)}function su({canvas:s,debug:t=!1,scale:e=1,position:i=[]}){i.forEach(({x:n,y:o,width:l,height:d,childNodes:f,element:p})=>{const g=s.getContext("2d",{alpha:!1});if(g){const{radius:v,draw:A}=p;if(A){if(g.save(),v){const{topLeft:E,topRight:T,bottomRight:w,bottomLeft:C}=Tm(v,e);g.beginPath(),g.moveTo(n+Math.min(d/rs,E),o),g.lineTo(n+l-Math.min(d/rs,T),o),g.quadraticCurveTo(n+l,o,n+l,o+Math.min(d/rs,T)),g.lineTo(n+l,o+d-Math.min(d/rs,w)),g.quadraticCurveTo(n+l,o+d,n+l-Math.min(d/rs,w),o+d),g.lineTo(n+Math.min(d/rs,C),o+d),g.quadraticCurveTo(n,o+d,n,o+d-Math.min(d/rs,C)),g.lineTo(n,o+Math.min(d/rs,E)),g.quadraticCurveTo(n,o,n+Math.min(d/rs,E),o),g.closePath(),t&&(g.strokeStyle="blue",g.stroke()),g.clip()}A({scale:e,dx:n,dy:o,dw:l,dh:d}),t&&(g.strokeStyle="red",g.strokeRect(n,o,l,d)),g.restore()}}su({canvas:s,debug:t,scale:e,position:f})})}function nu(s,t,e){const i=t.map((n,o)=>{const l=eu.Node.create(),{radius:d,elements:f=[],draw:p,...g}=n;return ru(l,{layout:g,scale:e}),s.insertChild(l,o),{node:l,element:n,childNodes:nu(l,f,e)}});return s.calculateLayout(),i}function au(s,t,e=0,i=0){const{top:n,left:o}=s.getComputedLayout();return t.map(({node:l,element:d,childNodes:f})=>{const{top:p,left:g,width:v,height:A}=l.getComputedLayout(),E=e+g,T=i+p;return{x:o+E,y:n+T,width:v,height:A,element:d,childNodes:au(s,f,E,T)}})}function ou(s,t){s.forEach(({node:e,element:i,childNodes:n})=>{const{height:o}=i;if(o&&typeof o=="function"){const l=e.getComputedWidth(),d=e.getComputedHeight(),f=o({width:l,maxHeight:d,scale:t});e.setHeight(f)}ou(n,t)})}function km({canvas:s,origin:t,elements:e,...i}){const n={inset:{top:0,left:0},width:s.width,height:s.height,...t},o=eu.Node.create();ru(o,{layout:n}),o.calculateLayout();const{width:l,height:d}=o.getComputedLayout(),f=Math.min(l,d)/1080,p=nu(o,e,f);ou(p,f),o.calculateLayout();const g=au(o,p);return su({...i,scale:f,canvas:s,position:g})}const lu=[{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 yo({text:s,font:t}){let e=t;return lu.forEach(({family:i,regex:n})=>{n.exec(s)&&(e+=`, ${i}`)}),e}const bo=/(?<value>\d+\.?\d*)(?=px)/;function cu(s){const{visible:t=!0,node:e}=s,i=[...(e==null?void 0:e.elements)??[],...(s==null?void 0:s.elements)??[]];return t?e&&e.type!=="box"&&e.type!=="gradient"?!!e.value:i==null?void 0:i.some(n=>cu(n)):!1}function hu({debug:s=!1,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:o=[],currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,parentAlpha:A}){return o.map(E=>{var T,w,C,D,M,U,x,G;const{node:$,transient:Y=[{from:0,duration:1/0}]}=E,tt=t.getContext("2d"),nt={total:l,content:d,scene:f},J={total:p,content:g,scene:v},St=Y.reduce((mt,{type:Ot="scene",from:Vt,duration:V,animation:q})=>{const At=Vt<0?J[Ot]+Vt:Vt;return nt[Ot]>=At&&nt[Ot]<=At+V&&(mt={type:Ot,animation:q,duration:V,from:At}),mt},null);if(tt&&St&&cu(E)){let mt=E.width,Ot=E.height,Vt=A??1;const{type:V="scene",from:q,duration:At,animation:N={type:"fade",duration:.3333333333333333}}=St;if(N){const{type:F,duration:j}=N;F==="fade"&&(q>0&&nt[V]<=q+j&&(Vt=Math.max(0,Math.min(1,(nt[V]-q)/j))),q+At<J[V]&&q+At-j<=nt[V]&&(Vt=Math.max(0,Math.min(1,(q+At-nt[V])/j))))}if(($==null?void 0:$.type)==="text"&&$.value){const F=yo({text:$.value,font:$.font});tt.save(),$.wrap?Ot=({width:j,maxHeight:at,scale:ht})=>{var _t,$t;const jt=Qd({font:F,scale:ht,context:tt,maxW:j,maxH:at,text:$.value??"",minSize:(_t=$.fill)==null?void 0:_t.minSize,maxSize:($t=$.fill)==null?void 0:$t.maxSize});return Ao({context:tt,font:F,fontSize:jt,text:$.value??"",maxW:j}).length*jt}:(tt.font=F,mt=tt.measureText($.value).width,Ot=parseFloat(((w=(T=F.match(bo))==null?void 0:T.groups)==null?void 0:w.value)??"0")),tt.restore()}if(($==null?void 0:$.type)==="image"&&$.image&&$.size){const F=((C=$.image)==null?void 0:C.naturalWidth)??((D=$.image)==null?void 0:D.width),j=((M=$.image)==null?void 0:M.naturalHeight)??((U=$.image)==null?void 0:U.height),at=F/j,ht=(x=$.size)==null?void 0:x.width,_t=(G=$.size)==null?void 0:G.height;mt=ht??(at>=1?(_t??0)*at:(_t??0)/at),Ot=_t??(at<1?(ht??0)*at:(ht??0)/at)}return{...E,width:mt,height:Ot,elements:hu({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:E.elements,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,parentAlpha:Vt}),draw:({dx:F,dy:j,dw:at,dh:ht,scale:_t})=>{var $t,jt,fe,ve,me,Ke,Le,Kt,Ae,de,Me,Ut,Ye;if(tt.globalAlpha=Vt,$){const{type:Fe}=$;if(Fe==="box"&&(tt.fillStyle=$.background,tt.fillRect(F,j,at,ht)),Fe==="text"&&$.value){const Ve=yo({text:$.value,font:$.font}),we=Qd({font:Ve,scale:_t,context:tt,maxW:at,maxH:ht,text:$.value??"",minSize:($t=$.fill)==null?void 0:$t.minSize,maxSize:(jt=$.fill)==null?void 0:jt.maxSize});tt.font=Ve.replace(bo,we.toString()),tt.textBaseline="top",tt.fillStyle=$.color,$.wrap?Ao({context:tt,font:Ve,fontSize:we,text:$.value,maxW:at}).forEach((ue,ze)=>{tt.fillText(ue.text,F,j+we*ze)}):tt.fillText($.value,F,j)}if(Fe==="image"&&$.image&&tt.drawImage($.image,F,j,at,ht),Fe==="video"&&((fe=$.video)!=null&&fe.node||(ve=$.video)!=null&&ve.getSource)){const Ve=$.format??"letterbox",we=((Ke=(me=$.video)==null?void 0:me.getSource)==null?void 0:Ke.call(me,f))??$.video.node,ue=(we==null?void 0:we.videoWidth)??(we==null?void 0:we.naturalWidth)??(we==null?void 0:we.width),ze=(we==null?void 0:we.videoHeight)??(we==null?void 0:we.naturalHeight)??(we==null?void 0:we.height);if(ue&&ze){const{dx:Ne,dy:Ue,dw:pi,dh:Ce}=zd({context:tt,cropCanvas:e,letterboxCanvas:n,source:we,format:Ve,crop:(Le=$==null?void 0:$.value)==null?void 0:Le.crop,sourceWidth:ue,sourceHeight:ze,posX:F,posY:j,drawAreaWidth:at,drawAreaHeight:ht});$.elements&&Xl({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:$.elements,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,origin:{inset:{top:Math.max(j,j+Ue),left:Math.max(F,F+Ne)},width:Math.min(at,pi),height:Math.min(ht,Ce)}})}const le=1/3;if($.poster&&l>=0&&l<=le){tt.save(),tt.globalAlpha=1-l/le;const Ne=((Kt=$.poster)==null?void 0:Kt.naturalWidth)??((Ae=$.poster)==null?void 0:Ae.width),Ue=((de=$.poster)==null?void 0:de.naturalHeight)??((Me=$.poster)==null?void 0:Me.height);i.width=i.height=0,i.width=at,i.height=ht;const pi=i.getContext("2d");if(pi&&Ne&&Ue){const{dx:Ce,dy:Ai,dw:Lr,dh:ni}=zd({context:pi,cropCanvas:e,letterboxCanvas:n,source:$.poster,format:Ve,crop:(Ut=$==null?void 0:$.value)==null?void 0:Ut.crop,sourceWidth:Ne,sourceHeight:Ue,posX:0,posY:0,drawAreaWidth:at,drawAreaHeight:ht});$.elements&&Xl({debug:s,canvas:i,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:$.elements,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,origin:{inset:{top:Math.max(0,Ai),left:Math.max(0,Ce)},width:Math.min(at,Lr),height:Math.min(ht,ni)}}),tt.drawImage(i,F,j,at,ht),tt.restore()}}}if(Fe==="gradient"&&$.value){const Ve=tt.createLinearGradient(F+at,j,F+at,j+ht);(Ye=$.value)==null||Ye.forEach(we=>{Ve.addColorStop(we.percent,we.color)}),tt.fillStyle=Ve,tt.fillRect(F,j,at,ht)}}}}}}).filter(Boolean)}function Xl({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:o,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,...A}){return km({...A,debug:s,canvas:t,elements:hu({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:o,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v})})}const Ao=Zd(({context:s,font:t,fontSize:e,text:i,maxW:n=1/0})=>{try{return s.save(),s.font=t.replace(bo,e.toString()),i.split(`
91
91
  `).flatMap(o=>{const l=o.split(" ").filter(Boolean);return l.length?l.slice(1).reduce((d,f)=>{const p=`${d[d.length-1].text} ${f}`.trim(),g=s.measureText(p);return g.width>n?d=[...d,...qd({context:s,word:f,maxW:n})]:d[d.length-1]={text:p,metrics:g},d},qd({context:s,word:l[0],maxW:n})):{text:"",metrics:s.measureText("")}})}finally{s.restore()}},{cacheKey:([{font:s,fontSize:t,text:e,maxW:i}])=>`${s}_${t}_${e}_${i}`}),wm=/\d{0,2}:?\d{2}:\d{2}\.\d{3}\s-->\s\d{0,2}:?\d{2}:\d{2}\.\d{3}\s{1,2}.*/g,Sm=/\d{0,2}:?\d{2}:\d{2}\.\d{3}/g;function du(s){if(!s)return[];const t=s.match(wm);return t?t==null?void 0:t.map(e=>{const[i,n]=e.replace(`\r
92
92
  `,`
93
93
  `).split(`
94
- `),[o,l]=i.match(Sm)||[];return{start:o,end:l,text:n}}):[]}function Ao(s){const[t,e,i]=s.split(":");return i?parseInt(t)*60*60+parseInt(e)*60+parseFloat(i):parseInt(t)*60+parseInt(e)}function Rm({canvas:s,dx:t,dy:e,dw:i,dh:n,sceneTime:o,vttCaptions:l}){if(l){const d=du(l).find(({start:f,end:p})=>f&&p&&o>=Ao(f)&&o<Ao(p));if(d){const f=s.getContext("2d");if(f){const p=Math.min(i,n),g=p*.04,v=vo({text:l,font:`400 ${g}px Roobert Captions`});f.font=v,f.textBaseline="middle";const A=i*.9,E=bo({context:f,font:v,fontSize:g,text:d.text,maxW:A});E.forEach(({text:T,metrics:w},C)=>{const x=t+(i-w.width)/2,O=e+(n*.85-(g+p*.03)*(E.length-1-C)),U=g*.8,D=g/1.5,H=t+(i-w.width-D)/2,$=O-U,z=w.width+D,tt=U*2,at=f.globalAlpha;f.save(),f.globalAlpha=.8*at,f.fillStyle="#000000",f.beginPath(),f.roundRect(H,$,z,tt,p*.01),f.fill(),f.closePath(),f.globalAlpha=at,f.fillStyle="#FFFFFF",f.fillText(T,x,O),f.restore()})}}}}const _m={id:"046f363c-960a-449c-ae5e-984ac6ab58c2",version:"2",name:"None",entityId:"none",templateId:"a95e537e-fb4d-4d2f-9c72-86c0925c7176",layouts:[{name:"none",tree:`[
94
+ `),[o,l]=i.match(Sm)||[];return{start:o,end:l,text:n}}):[]}function Eo(s){const[t,e,i]=s.split(":");return i?parseInt(t)*60*60+parseInt(e)*60+parseFloat(i):parseInt(t)*60+parseInt(e)}function Rm({canvas:s,dx:t,dy:e,dw:i,dh:n,sceneTime:o,vttCaptions:l}){if(l){const d=du(l).find(({start:f,end:p})=>f&&p&&o>=Eo(f)&&o<Eo(p));if(d){const f=s.getContext("2d");if(f){const p=Math.min(i,n),g=p*.04,v=yo({text:l,font:`400 ${g}px Roobert Captions`});f.font=v,f.textBaseline="middle";const A=i*.9,E=Ao({context:f,font:v,fontSize:g,text:d.text,maxW:A});E.forEach(({text:T,metrics:w},C)=>{const D=t+(i-w.width)/2,M=e+(n*.85-(g+p*.03)*(E.length-1-C)),U=g*.8,x=g/1.5,G=t+(i-w.width-x)/2,$=M-U,Y=w.width+x,tt=U*2,nt=f.globalAlpha;f.save(),f.globalAlpha=.8*nt,f.fillStyle="#000000",f.beginPath(),f.roundRect(G,$,Y,tt,p*.01),f.fill(),f.closePath(),f.globalAlpha=nt,f.fillStyle="#FFFFFF",f.fillText(T,D,M),f.restore()})}}}}const Lm={id:"046f363c-960a-449c-ae5e-984ac6ab58c2",version:"2",name:"None",entityId:"none",templateId:"a95e537e-fb4d-4d2f-9c72-86c0925c7176",layouts:[{name:"none",tree:`[
95
95
  {
96
96
  "width": "100%",
97
97
  "height": "100%",
@@ -168,7 +168,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
168
168
  "width": {{ it.root?.answer?.settings?.crop?.width }},
169
169
  "height": {{ it.root?.answer?.settings?.crop?.height }}
170
170
  }
171
- }`}],root:"{{ it.outro?.questions?.items }}"}],system:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},Lm={id:"073977ec-6384-4329-b7c5-8275fb513e74",name:"None",entityId:"none",templateId:"a95e537e-fb4d-4d2f-9c72-86c0925c7176",templates:[_m],meta:{frameRate:30,resolution:720,transitionDuration:1/3},system:!0,default:0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};async function Cm(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>up);return new s.Image}return new Image}const uu=ks(async function(s){return s?new Promise((t,e)=>{Cm().then(i=>{i.onload=()=>{t(i)},i.onerror=n=>{e(n)},i.src=s})}):null});async function Xl({element:s},t,e){var i,n,o;let l={...s};const{node:d}=s;if((d==null?void 0:d.type)==="video"&&((i=d==null?void 0:d.value)!=null&&i.src||(n=d==null?void 0:d.value)!=null&&n.playlist)){const f=await t(d.value);let p;try{p=await uu(d.value.poster)}catch{p=null}l={...l,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 uu(d.value)}catch{f=null}l={...l,node:{...d,image:f}}}return l.node&&(o=s.node)!=null&&o.elements&&(l.node.elements=await Promise.all(s.node.elements.map(f=>Xl({element:f},t,e)))),s.elements&&(l.elements=await Promise.all(s.elements.map(f=>Xl({element:f},t,e)))),l}async function Eo(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>up),t=new s.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function Im(s){var t;try{if((t=await rm(s,{method:"HEAD"}))!=null&&t.ok)return s}catch{return}}async function Dm({sources:s}){let t=null;if(s){const e=s.filter(Boolean).map(i=>Im(i));t=(await Promise.all(e)).find(Boolean)}return t}function Zl(s=[]){var t;for(const e of s){if(((t=e==null?void 0:e.node)==null?void 0:t.type)==="video")return e.node;const i=Zl(e==null?void 0:e.elements);if(i)return i}}function To(s,t,e=!0){return s.reduce((i,{duration:n},o)=>e&&o<=0?i+=n:i+=n-t/2,0)}function xm(s){if(s===null||typeof s!="object")return!1;if(Object.getPrototypeOf(s)===null)return!0;let t=s;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(s)===t}oo.filters.define("parse",s=>{if(typeof s>"u")return null;if(typeof s=="string"){let t=s;return t=t.replace(/\n/g,"\\n"),t=t.replace(/\r/g,"\\r"),t=t.replace(/"/g,'\\"'),`"${t}"`}return xm(s)||Array.isArray(s)?JSON.stringify(s):s}),oo.helpers.define("resolve-source",ks(async s=>{const{sources:t}=s.params[0]??{},e=t==null?void 0:t.filter(Boolean),i=e==null?void 0:e.find(l=>l.includes("blob:")),n=e==null?void 0:e.find(l=>!l.includes("http")),o=i??n??await Dm({sources:t});return o?`"${o}"`:"null"},{cacheKey:([s])=>JSON.stringify(s.params[0]??{})}));const ma=(s,t,e)=>oo.render(s,t,oo.getConfig({autoEscape:!1,defaultFilter:"parse",async:!0,asyncHelpers:["resolve-source"],...e}));async function kn({data:s,template:t,burnCaptions:e=!1,debug:i=!1},n,o){var l,d,f,p;const g=t??Lm;if(!((l=g.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${g.id}`);let v=g.templates.find(({version:O})=>O===ql);if(!v){const O=g.templates.map(({version:U})=>`"${U}"`).join(", ");console.warn(`Template renderer expects template version "${ql}" but got ${O}`),v=g.templates[g.templates.length-1]}const A=(await Promise.all(v.content.map(async({scenes:O,root:U})=>{const D={...g.options,...s,intro:g.intro,outro:g.outro};async function H($,z){return Promise.all(O.map(async({layout:tt,duration:at,data:J,options:St})=>{var mt,Ot,Vt;const G={...D,index:z,root:$},q=J?JSON.parse(await ma(J,G)):{},At=St?JSON.parse(await ma(St,G)):{},N=at?parseFloat(await ma(at,G)):NaN,F=(mt=v.layouts.find(Lt=>Lt.name===tt))==null?void 0:mt.tree;if(!F)throw new Error(`Layout tree "${tt}" not found in template "${v.id}" layouts.`);const j=JSON.parse(await ma(F,{...q,...At})),nt=await Promise.all(j.flatMap(Lt=>Xl({element:Lt},n,o))),ct=Zl(nt);return{duration:(isNaN(N)?null:N)??((Ot=ct==null?void 0:ct.meta)==null?void 0:Ot.duration)??0,captions:(Vt=ct==null?void 0:ct.meta)==null?void 0:Vt.captions,elements:nt}}))}if(U){const $=JSON.parse(await ma(U,D));return Array.isArray($)?(await Promise.all($.map(async(z,tt)=>H(z,tt)))).flatMap(z=>z):H($,null)}return H(s,null)}))).reduce((O,U)=>{const D=U.filter(H=>H.duration>0);return D.length>0&&(O=[...O,D]),O},[]),E=((d=g.meta)==null?void 0:d.frameRate)??30,T=((f=g.meta)==null?void 0:f.resolution)??720,w=((p=g.meta)==null?void 0:p.transitionDuration)??1/3,C=A.flatMap(O=>O),x=To(C,w);return{scenes:(await Promise.all(A.map((O,U)=>{const D=To(O,w),H=A.slice(0,U).flatMap(z=>z),$=To(H,w,!1);return Promise.all(O.map(async({duration:z,captions:tt,elements:at},J)=>{var St,mt;const Ot=await Eo(),Vt=await Eo(),G=await Eo(),q=await Eo(),At=Zl(at),N=[...H,...O.slice(0,J)],F=To(N,w,!1);return{draw:({canvas:j,currentTime:nt})=>{const ct=Math.max(0,nt-$),Lt=Math.max(0,nt-F);Yl({debug:i,canvas:j,cropCanvas:Ot,posterCanvas:q,letterboxCanvas:Vt,elements:at,currentTime:nt,contentTime:ct,sceneTime:Lt,totalDuration:x,contentDuration:D,sceneDuration:z}),tt&&e&&Rm({canvas:j,dx:0,dy:0,dw:j.width,dh:j.height,vttCaptions:tt,sceneTime:Lt+((At==null?void 0:At.meta.start)??0)})},duration:z,transitionCanvas:G,start:F,video:At==null?void 0:At.video,videoMeta:At==null?void 0:At.meta,audio:{duration:z,src:(St=At==null?void 0:At.value)==null?void 0:St.src,start:(mt=At==null?void 0:At.meta)==null?void 0:mt.start}}}))}))).flatMap(O=>O),frameRate:E,resolution:T,transitionDuration:w,fonts:v.fonts??[],duration:x}}const ql="2",Pm={name:"@vouchfor/embeds",version:"1.1.0",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"latest",access:"public"},scripts:{build:"rm -rf dist && tsc && yarn build:self","build:deps":"yarn --cwd ../media-player build","build:self":"vite build --mode iife && vite build --mode es && node scripts/build.cjs","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:"rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner","test:ci":"yarn test --config web-test-runner.ci.config.js"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@a11y/focus-trap":"^1.0.5","@lit/task":"^1.0.0","@vouchfor/media-player":"^2.0.3",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",glob:"^10.3.10","lint-staged":"^14.0.1",lit:"^3.1.0",lodash:"^4.17.21",prettier:"^3.0.3",react:"^18.2.0","react-dom":"^18.2.0","rollup-plugin-internal":"^1.0.4",sinon:"^17.0.1",storybook:"^7.4.5",typescript:"^5.1.3",vite:"^4.4.9","vite-plugin-commonjs":"^0.10.0","vite-plugin-dts":"^3.6.0","web-component-analyzer":"^1.1.7"}};function Om(s){const{publicApiUrl:t}=no(s),e=en();return navigator.sendBeacon(`${t}/api/visitor`,JSON.stringify({visitorId:e})),e}function Mm(s){var o,l,d,f,p,g,v,A,E,T,w,C;if(typeof window>"u")return{client:null,tab:null,request:en()};let t=(l=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:l.call(o,"vouch-uid-visitor"),e=(f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"),i=(g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab");const n=en();return t||(t=Om(s),(A=(v=window.localStorage)==null?void 0:v.setItem)==null||A.call(v,"vouch-uid-visitor",t)),e||(e=en(),(T=(E=window.localStorage)==null?void 0:E.setItem)==null||T.call(E,"vouch-uid-client",e)),i||(i=en(),(C=(w=window.sessionStorage)==null?void 0:w.setItem)==null||C.call(w,"vouch-uid-tab",i)),{client:e,tab:i,request:n,visitor:t}}function $m(s,t){return s&&"vouchId"in s?s.vouchId:(t==null?void 0:t.id)??null}function Fm(s="embedded_player"){var n,o;const[t,e]=((o=(n=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:n.split)==null?void 0:o.call(n,"/"))??[],i={};return[...new URLSearchParams(location.search).entries()].forEach(([l,d])=>{if(/utm/.test(l)){const f=l.toLowerCase().replace(/[-_][a-z0-9]/g,p=>p.slice(-1).toUpperCase());i[f]=d}}),{source:s,time:new Date,region:e,country:t,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:Pm.version,templateVersion:ql,...i}}const fu=1;class Nm{constructor(t){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(e,i)=>{const n=$m(i,this.host.vouch);!n||this.host.disableTracking||this._batchedEvents.push({event:e,payload:{...i,vouchId:n,time:new Date().toISOString()}})},this._sendTrackingEvent=()=>{if(this._batchedEvents.length<=0)return;const{publicApiUrl:e}=no(this.host.env),{client:i,tab:n,request:o,visitor:l}=Mm(this.host.env);navigator.sendBeacon(`${e}/api/batchevents`,JSON.stringify({payload:{events:this._batchedEvents},context:{"x-uid-client":i,"x-uid-tab":n,"x-uid-request":o,"x-uid-visitor":l,"x-reporting-metadata":Fm(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:e,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+fu&&this._createTrackingEvent("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._createTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._createTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:e,key:i}})=>{this._answersViewed[i]||(this._createTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:e}),this._answersViewed[i]=!0)},this._handleVideoTimeUpdate=({detail:{id:e,key:i,node:n}})=>{var o,l;!this.host.paused&&e===((l=(o=this.host.scene)==null?void 0:o.video)==null?void 0:l.id)&&(this._currentlyPlayingVideo={id:e,key:i,node:n},this._streamLatestTime[i]=n.currentTime,this._streamStartTime[i]||(this._streamStartTime[i]=n.currentTime,this._streamLatestTime[i]=n.currentTime))},this._handleVideoPause=({detail:{id:e,key:i}})=>{this._streamLatestTime[i]>this._streamStartTime[i]+fu&&this._createTrackingEvent("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._sendTrackingEvent()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=t,t.addController(this)}hostConnected(){requestAnimationFrame(()=>{var t,e,i,n;"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),(n=this.host.mediaPlayer)==null||n.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,i,n;this._pageUnloading(),"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),(n=this.host.mediaPlayer)==null||n.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}const Um=s=>{class t extends s{constructor(){super(...arguments),this._mediaPlayerRef=Si()}get waiting(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.waiting}get initialised(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.initialised}get seeking(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.seeking}get paused(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.paused}get captions(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.captions}get fullscreen(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.fullscreen}get duration(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.duration}set currentTime(i){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.currentTime=i)}get currentTime(){var i;return((i=this._mediaPlayerRef.value)==null?void 0:i.currentTime)??0}set playbackRate(i){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.playbackRate=i)}get playbackRate(){var i;return((i=this._mediaPlayerRef.value)==null?void 0:i.playbackRate)??1}set volume(i){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.volume=i)}get volume(){var i;return((i=this._mediaPlayerRef.value)==null?void 0:i.volume)??1}set muted(i){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.muted=i)}get muted(){var i;return((i=this._mediaPlayerRef.value)==null?void 0:i.muted)??!1}get scene(){var i;return((i=this._mediaPlayerRef.value)==null?void 0:i.scene)??null}get scenes(){var i;return((i=this._mediaPlayerRef.value)==null?void 0:i.scenes)??[]}get sceneConfig(){var i;return((i=this._mediaPlayerRef.value)==null?void 0:i.sceneConfig)??null}get videoState(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.videoState}get mediaPlayer(){return this._mediaPlayerRef.value}play(){var i;(i=this._mediaPlayerRef.value)==null||i.play()}pause(){var i;(i=this._mediaPlayerRef.value)==null||i.pause()}reset(i=0,n=!1){var o;(o=this._mediaPlayerRef.value)==null||o.reset(i,n)}setScene(i){var n;(n=this._mediaPlayerRef.value)==null||n.setScene(i)}}return t};/**
171
+ }`}],root:"{{ it.outro?.questions?.items }}"}],system:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},_m={id:"073977ec-6384-4329-b7c5-8275fb513e74",name:"None",entityId:"none",templateId:"a95e537e-fb4d-4d2f-9c72-86c0925c7176",templates:[Lm],meta:{frameRate:30,resolution:720,transitionDuration:1/3},system:!0,default:0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};async function Cm(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>up);return new s.Image}return new Image}const uu=ks(async function(s){return s?new Promise((t,e)=>{Cm().then(i=>{i.onload=()=>{t(i)},i.onerror=n=>{e(n)},i.src=s})}):null});async function Zl({element:s,meta:t},e,i){var n,o,l;let d={...s};const{node:f}=s;if((f==null?void 0:f.type)==="video"&&((n=f==null?void 0:f.value)!=null&&n.src||(o=f==null?void 0:f.value)!=null&&o.playlist)){const p=await e(f.value,t);let g;try{g=await uu(f.value.poster)}catch{g=null}d={...d,node:{...f,video:p,poster:g,meta:await i(f.value,p.node,t)}}}if((f==null?void 0:f.type)==="image"&&f.value){let p;try{p=await uu(f.value)}catch{p=null}d={...d,node:{...f,image:p}}}return d.node&&(l=s.node)!=null&&l.elements&&(d.node.elements=await Promise.all(s.node.elements.map(p=>Zl({element:p,meta:t},e,i)))),s.elements&&(d.elements=await Promise.all(s.elements.map(p=>Zl({element:p,meta:t},e,i)))),d}async function To(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>up),t=new s.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function Im(s){var t;try{if((t=await rm(s,{method:"HEAD"}))!=null&&t.ok)return s}catch{return}}async function xm({sources:s}){let t=null;if(s){const e=s.filter(Boolean).map(i=>Im(i));t=(await Promise.all(e)).find(Boolean)}return t}function ma(s=[]){var t;for(const e of s){if(((t=e==null?void 0:e.node)==null?void 0:t.type)==="video")return e.node;const i=ma(e==null?void 0:e.elements);if(i)return i}}function Dm(s,t){return s.reduce((e,i,n)=>[...e,i.map(({duration:o},l)=>n===s.length-1&&l===i.length-1?o:o-t)],[])}function Pm(s){if(s===null||typeof s!="object")return!1;if(Object.getPrototypeOf(s)===null)return!0;let t=s;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(s)===t}function Om(s){return s.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\f/g,"\\f").replace(/"/g,'\\"')}function ko(s){return s.flatMap(t=>t).reduce((t,e)=>t+e,0)}lo.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${Om(s)}"`:Pm(s)||Array.isArray(s)?JSON.stringify(s):s),lo.helpers.define("resolve-source",ks(async s=>{const{sources:t}=s.params[0]??{},e=t==null?void 0:t.filter(Boolean),i=e==null?void 0:e.find(l=>l.includes("blob:")),n=e==null?void 0:e.find(l=>!l.includes("http")),o=i??n??await xm({sources:t});return o?`"${o}"`:"null"},{cacheKey:([s])=>JSON.stringify(s.params[0]??{})}));const va=(s,t,e)=>lo.render(s,t,lo.getConfig({autoEscape:!1,defaultFilter:"parse",async:!0,asyncHelpers:["resolve-source"],...e}));async function kn({data:s,template:t,burnCaptions:e=!1,debug:i=!1},n,o){var l,d,f,p;const g=t??_m;if(!((l=g.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${g.id}`);let v=g.templates.find(({version:U})=>U===ql);if(!v){const U=g.templates.map(({version:x})=>`"${x}"`).join(", ");console.warn(`Template renderer expects template version "${ql}" but got ${U}`),v=g.templates[g.templates.length-1]}const A=await Promise.all(v.content.map(async({scenes:U,root:x})=>{const G={...g.options,...s,intro:g.intro,outro:g.outro};async function $(Y,tt){return Promise.all(U.map(async({layout:nt,duration:J,data:St,options:mt})=>{var Ot,Vt,V;const q={...G,index:tt,root:Y},At=St?JSON.parse(await va(St,q)):{},N=mt?JSON.parse(await va(mt,q)):{},F=J?parseFloat(await va(J,q)):NaN,j=(Ot=v.layouts.find($t=>$t.name===nt))==null?void 0:Ot.tree;if(!j)throw new Error(`Layout tree "${nt}" not found in template "${v.id}" layouts.`);const at=JSON.parse(await va(j,{...At,...N})),ht=await Promise.all(at.flatMap($t=>Zl({element:$t,meta:g.meta},n,o))),_t=ma(ht);return{duration:(isNaN(F)?null:F)??((Vt=_t==null?void 0:_t.meta)==null?void 0:Vt.duration)??0,captions:(V=_t==null?void 0:_t.meta)==null?void 0:V.captions,elements:ht}}))}if(x){const Y=JSON.parse(await va(x,G));return Array.isArray(Y)?(await Promise.all(Y.map(async(tt,nt)=>$(tt,nt)))).flatMap(tt=>tt):$(Y,null)}return $(s,null)}));if(A.every(U=>U.every(x=>{const G=ma(x.elements);return!(G!=null&&G.value.src)&&!(G!=null&&G.value.playlist)}))){const U=A.flatMap(x=>x.map(G=>{const $=ma(G.elements);return!($!=null&&$.value.src)&&!($!=null&&$.value.playlist)&&($==null?void 0:$.value.id)}).filter(Boolean)).join(", ");throw new Error(`Video(s) with ID ${U} failed to load, video can not be processed`)}if(A.every(U=>U.every(x=>x.duration<=0)))throw new Error("No scenes have any duration, video can not be processed");const E=A.reduce((U,x)=>{const G=x.filter($=>$.duration>0);return G.length>0&&(U=[...U,G]),U},[]),T=((d=g.meta)==null?void 0:d.frameRate)??30,w=((f=g.meta)==null?void 0:f.resolution)??720,C=((p=g.meta)==null?void 0:p.transitionDuration)??1/3,D=Dm(E,C),M=ko(D);return{scenes:(await Promise.all(E.map((U,x)=>{const G=ko(D[x]),$=ko(D.slice(0,x));return Promise.all(U.map(async({duration:Y,captions:tt,elements:nt},J)=>{var St,mt;const Ot=await To(),Vt=await To(),V=await To(),q=await To(),At=ma(nt),N=ko([...D.slice(0,x),...D[x].slice(0,J)]);return{draw:({canvas:F,currentTime:j})=>{const at=Math.max(0,j-$),ht=Math.max(0,j-N);Xl({debug:i,canvas:F,cropCanvas:Ot,posterCanvas:q,letterboxCanvas:Vt,elements:nt,currentTime:j,contentTime:at,sceneTime:ht,totalDuration:M,contentDuration:G,sceneDuration:Y}),tt&&e&&Rm({canvas:F,dx:0,dy:0,dw:F.width,dh:F.height,vttCaptions:tt,sceneTime:ht+((At==null?void 0:At.meta.start)??0)})},duration:Y,transitionCanvas:V,start:N,video:At==null?void 0:At.video,videoMeta:At==null?void 0:At.meta,audio:{duration:Y,src:(St=At==null?void 0:At.value)==null?void 0:St.src,start:(mt=At==null?void 0:At.meta)==null?void 0:mt.start}}}))}))).flatMap(U=>U),frameRate:T,resolution:w,transitionDuration:C,fonts:v.fonts??[],duration:M}}const ql="2",Mm={name:"@vouchfor/embeds",version:"1.1.3",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"latest",access:"public"},scripts:{build:"rm -rf dist && tsc && yarn build:self","build:deps":"yarn --cwd ../media-player build","build:self":"vite build --mode iife && vite build --mode es && node scripts/build.cjs","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:"rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner","test:ci":"yarn test --config web-test-runner.ci.config.js"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@a11y/focus-trap":"^1.0.5","@lit/task":"^1.0.0","@vouchfor/media-player":"^2.0.6",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",glob:"^10.3.10","lint-staged":"^14.0.1",lit:"^3.1.0",lodash:"^4.17.21",prettier:"^3.0.3",react:"^18.2.0","react-dom":"^18.2.0","rollup-plugin-internal":"^1.0.4",sinon:"^17.0.1",storybook:"^7.4.5",typescript:"^5.1.3",vite:"^4.4.9","vite-plugin-commonjs":"^0.10.0","vite-plugin-dts":"^3.6.0","web-component-analyzer":"^1.1.7"}};function $m(s){const{publicApiUrl:t}=ao(s),e=en();return navigator.sendBeacon(`${t}/api/visitor`,JSON.stringify({visitorId:e})),e}function Fm(s){var o,l,d,f,p,g,v,A,E,T,w,C;if(typeof window>"u")return{client:null,tab:null,request:en()};let t=(l=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:l.call(o,"vouch-uid-visitor"),e=(f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"),i=(g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab");const n=en();return t||(t=$m(s),(A=(v=window.localStorage)==null?void 0:v.setItem)==null||A.call(v,"vouch-uid-visitor",t)),e||(e=en(),(T=(E=window.localStorage)==null?void 0:E.setItem)==null||T.call(E,"vouch-uid-client",e)),i||(i=en(),(C=(w=window.sessionStorage)==null?void 0:w.setItem)==null||C.call(w,"vouch-uid-tab",i)),{client:e,tab:i,request:n,visitor:t}}function Nm(s,t){return s&&"vouchId"in s?s.vouchId:(t==null?void 0:t.id)??null}function Um(s="embedded_player"){var n,o;const[t,e]=((o=(n=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:n.split)==null?void 0:o.call(n,"/"))??[],i={};return[...new URLSearchParams(location.search).entries()].forEach(([l,d])=>{if(/utm/.test(l)){const f=l.toLowerCase().replace(/[-_][a-z0-9]/g,p=>p.slice(-1).toUpperCase());i[f]=d}}),{source:s,time:new Date,region:e,country:t,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:Mm.version,templateVersion:ql,...i}}const fu=1;class Bm{constructor(t){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(e,i)=>{const n=Nm(i,this.host.vouch);!n||this.host.disableTracking||this._batchedEvents.push({event:e,payload:{...i,vouchId:n,time:new Date().toISOString()}})},this._sendTrackingEvent=()=>{if(this._batchedEvents.length<=0)return;const{publicApiUrl:e}=ao(this.host.env),{client:i,tab:n,request:o,visitor:l}=Fm(this.host.env);navigator.sendBeacon(`${e}/api/batchevents`,JSON.stringify({payload:{events:this._batchedEvents},context:{"x-uid-client":i,"x-uid-tab":n,"x-uid-request":o,"x-uid-visitor":l,"x-reporting-metadata":Um(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:e,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+fu&&this._createTrackingEvent("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._createTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._createTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:e,key:i}})=>{this._answersViewed[i]||(this._createTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:e}),this._answersViewed[i]=!0)},this._handleVideoTimeUpdate=({detail:{id:e,key:i,node:n}})=>{var o,l;!this.host.paused&&e===((l=(o=this.host.scene)==null?void 0:o.video)==null?void 0:l.id)&&(this._currentlyPlayingVideo={id:e,key:i,node:n},this._streamLatestTime[i]=n.currentTime,this._streamStartTime[i]||(this._streamStartTime[i]=n.currentTime,this._streamLatestTime[i]=n.currentTime))},this._handleVideoPause=({detail:{id:e,key:i}})=>{this._streamLatestTime[i]>this._streamStartTime[i]+fu&&this._createTrackingEvent("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._sendTrackingEvent()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=t,t.addController(this)}hostConnected(){requestAnimationFrame(()=>{var t,e,i,n;"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),(n=this.host.mediaPlayer)==null||n.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,i,n;this._pageUnloading(),"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),(n=this.host.mediaPlayer)==null||n.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}const Gm=s=>{class t extends s{constructor(){super(...arguments),this._mediaPlayerRef=Si()}get waiting(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.waiting}get initialised(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.initialised}get seeking(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.seeking}get paused(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.paused}get captions(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.captions}get fullscreen(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.fullscreen}get duration(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.duration}set currentTime(i){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.currentTime=i)}get currentTime(){var i;return((i=this._mediaPlayerRef.value)==null?void 0:i.currentTime)??0}set playbackRate(i){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.playbackRate=i)}get playbackRate(){var i;return((i=this._mediaPlayerRef.value)==null?void 0:i.playbackRate)??1}set volume(i){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.volume=i)}get volume(){var i;return((i=this._mediaPlayerRef.value)==null?void 0:i.volume)??1}set muted(i){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.muted=i)}get muted(){var i;return((i=this._mediaPlayerRef.value)==null?void 0:i.muted)??!1}get scene(){var i;return((i=this._mediaPlayerRef.value)==null?void 0:i.scene)??null}get scenes(){var i;return((i=this._mediaPlayerRef.value)==null?void 0:i.scenes)??[]}get sceneConfig(){var i;return((i=this._mediaPlayerRef.value)==null?void 0:i.sceneConfig)??null}get videoState(){var i;return(i=this._mediaPlayerRef.value)==null?void 0:i.videoState}get mediaPlayer(){return this._mediaPlayerRef.value}play(){var i;(i=this._mediaPlayerRef.value)==null||i.play()}pause(){var i;(i=this._mediaPlayerRef.value)==null||i.pause()}reset(i=0,n=!1){var o;(o=this._mediaPlayerRef.value)==null||o.reset(i,n)}setScene(i){var n;(n=this._mediaPlayerRef.value)==null||n.setScene(i)}}return t};/**
172
172
  * @license
173
173
  * Copyright 2018 Google LLC
174
174
  * SPDX-License-Identifier: BSD-3-Clause
@@ -176,36 +176,36 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
176
176
  * @license
177
177
  * Copyright 2018 Google LLC
178
178
  * SPDX-License-Identifier: BSD-3-Clause
179
- */const pu="important",Bm=" !"+pu,va=Tn(class extends la{constructor(s){var t;if(super(s),s.type!==En.ATTRIBUTE||s.name!=="style"||((t=s.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(s){return Object.keys(s).reduce((t,e)=>{const i=s[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(s,[t]){const{style:e}=s.element;if(this.ut===void 0)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 n=t[i];if(n!=null){this.ut.add(i);const o=typeof n=="string"&&n.endsWith(Bm);i.includes("-")||o?e.setProperty(i,o?n.slice(0,-11):n,o?pu:""):e[i]=n}}return ys}});var Gm=ya;ya.flatten=ya,ya.unflatten=vu;function gu(s){return s&&s.constructor&&typeof s.constructor.isBuffer=="function"&&s.constructor.isBuffer(s)}function mu(s){return s}function ya(s,t){t=t||{};const e=t.delimiter||".",i=t.maxDepth,n=t.transformKey||mu,o={};function l(d,f,p){p=p||1,Object.keys(d).forEach(function(g){const v=d[g],A=t.safe&&Array.isArray(v),E=Object.prototype.toString.call(v),T=gu(v),w=E==="[object Object]"||E==="[object Array]",C=f?f+e+n(g):n(g);if(!A&&!T&&w&&Object.keys(v).length&&(!t.maxDepth||p<i))return l(v,C,p+1);o[C]=v})}return l(s),o}function vu(s,t){t=t||{};const e=t.delimiter||".",i=t.overwrite||!1,n=t.transformKey||mu,o={};if(gu(s)||Object.prototype.toString.call(s)!=="[object Object]")return s;function d(g){const v=Number(g);return isNaN(v)||g.indexOf(".")!==-1||t.object?g:v}function f(g,v,A){return Object.keys(A).reduce(function(E,T){return E[g+e+T]=A[T],E},v)}function p(g){const v=Object.prototype.toString.call(g),A=v==="[object Array]",E=v==="[object Object]";if(g){if(A)return!g.length;if(E)return!Object.keys(g).length}else return!0}return s=Object.keys(s).reduce(function(g,v){const A=Object.prototype.toString.call(s[v]);return!(A==="[object Object]"||A==="[object Array]")||p(s[v])?(g[v]=s[v],g):f(v,g,ya(s[v],t))},{}),Object.keys(s).forEach(function(g){const v=g.split(e).map(n);let A=d(v.shift()),E=d(v[0]),T=o;for(;E!==void 0;){if(A==="__proto__")return;const w=Object.prototype.toString.call(T[A]),C=w==="[object Object]"||w==="[object Array]";if(!i&&!C&&typeof T[A]<"u")return;(i&&!C||!i&&T[A]==null)&&(T[A]=typeof E=="number"&&!t.object?[]:{}),T=T[A],v.length>0&&(A=d(v.shift()),E=d(v[0]))}T[A]=vu(s[g],t)}),o}const Vm=Ul(Gm);/**
179
+ */const pu="important",Vm=" !"+pu,ya=Tn(class extends la{constructor(s){var t;if(super(s),s.type!==En.ATTRIBUTE||s.name!=="style"||((t=s.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(s){return Object.keys(s).reduce((t,e)=>{const i=s[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(s,[t]){const{style:e}=s.element;if(this.ut===void 0)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 n=t[i];if(n!=null){this.ut.add(i);const o=typeof n=="string"&&n.endsWith(Vm);i.includes("-")||o?e.setProperty(i,o?n.slice(0,-11):n,o?pu:""):e[i]=n}}return ys}});var Hm=ba;ba.flatten=ba,ba.unflatten=vu;function gu(s){return s&&s.constructor&&typeof s.constructor.isBuffer=="function"&&s.constructor.isBuffer(s)}function mu(s){return s}function ba(s,t){t=t||{};const e=t.delimiter||".",i=t.maxDepth,n=t.transformKey||mu,o={};function l(d,f,p){p=p||1,Object.keys(d).forEach(function(g){const v=d[g],A=t.safe&&Array.isArray(v),E=Object.prototype.toString.call(v),T=gu(v),w=E==="[object Object]"||E==="[object Array]",C=f?f+e+n(g):n(g);if(!A&&!T&&w&&Object.keys(v).length&&(!t.maxDepth||p<i))return l(v,C,p+1);o[C]=v})}return l(s),o}function vu(s,t){t=t||{};const e=t.delimiter||".",i=t.overwrite||!1,n=t.transformKey||mu,o={};if(gu(s)||Object.prototype.toString.call(s)!=="[object Object]")return s;function d(g){const v=Number(g);return isNaN(v)||g.indexOf(".")!==-1||t.object?g:v}function f(g,v,A){return Object.keys(A).reduce(function(E,T){return E[g+e+T]=A[T],E},v)}function p(g){const v=Object.prototype.toString.call(g),A=v==="[object Array]",E=v==="[object Object]";if(g){if(A)return!g.length;if(E)return!Object.keys(g).length}else return!0}return s=Object.keys(s).reduce(function(g,v){const A=Object.prototype.toString.call(s[v]);return!(A==="[object Object]"||A==="[object Array]")||p(s[v])?(g[v]=s[v],g):f(v,g,ba(s[v],t))},{}),Object.keys(s).forEach(function(g){const v=g.split(e).map(n);let A=d(v.shift()),E=d(v[0]),T=o;for(;E!==void 0;){if(A==="__proto__")return;const w=Object.prototype.toString.call(T[A]),C=w==="[object Object]"||w==="[object Array]";if(!i&&!C&&typeof T[A]<"u")return;(i&&!C||!i&&T[A]==null)&&(T[A]=typeof E=="number"&&!t.object?[]:{}),T=T[A],v.length>0&&(A=d(v.shift()),E=d(v[0]))}T[A]=vu(s[g],t)}),o}const Wm=Bl(Hm);/**
180
180
  * @license
181
181
  * Copyright 2017 Google LLC
182
182
  * SPDX-License-Identifier: BSD-3-Clause
183
- */const yu=(s,t,e)=>{const i=new Map;for(let n=t;n<=e;n++)i.set(s[n],n);return i},bu=Tn(class extends la{constructor(s){if(super(s),s.type!==En.CHILD)throw Error("repeat() can only be used in text expressions")}ht(s,t,e){let i;e===void 0?e=t:t!==void 0&&(i=t);const n=[],o=[];let l=0;for(const d of s)n[l]=i?i(d,l):l,o[l]=e(d,l),l++;return{values:o,keys:n}}render(s,t,e){return this.ht(s,t,e).values}update(s,[t,e,i]){const n=mg(s),{values:o,keys:l}=this.ht(t,e,i);if(!Array.isArray(n))return this.dt=l,o;const d=this.dt??(this.dt=[]),f=[];let p,g,v=0,A=n.length-1,E=0,T=o.length-1;for(;v<=A&&E<=T;)if(n[v]===null)v++;else if(n[A]===null)A--;else if(d[v]===l[E])f[E]=tn(n[v],o[E]),v++,E++;else if(d[A]===l[T])f[T]=tn(n[A],o[T]),A--,T--;else if(d[v]===l[T])f[T]=tn(n[v],o[T]),oa(s,f[T+1],n[v]),v++,T--;else if(d[A]===l[E])f[E]=tn(n[A],o[E]),oa(s,n[v],n[A]),A--,E++;else if(p===void 0&&(p=yu(l,E,T),g=yu(d,v,A)),p.has(d[v]))if(p.has(d[A])){const w=g.get(l[E]),C=w!==void 0?n[w]:null;if(C===null){const x=oa(s,n[v]);tn(x,o[E]),f[E]=x}else f[E]=tn(C,o[E]),oa(s,n[v],C),n[w]=null;E++}else Pl(n[A]),A--;else Pl(n[v]),v++;for(;E<=T;){const w=oa(s,f[T+1]);tn(w,o[E]),f[E++]=w}for(;v<=A;){const w=n[v++];w!==null&&Pl(w)}return this.dt=l,gg(s,f),ys}});var ji="top",hr="bottom",dr="right",Ki="left",Ql="auto",ba=[ji,hr,dr,Ki],wn="start",Aa="end",Hm="clippingParents",Au="viewport",Ea="popper",Wm="reference",Eu=ba.reduce(function(s,t){return s.concat([t+"-"+wn,t+"-"+Aa])},[]),Tu=[].concat(ba,[Ql]).reduce(function(s,t){return s.concat([t,t+"-"+wn,t+"-"+Aa])},[]),jm="beforeRead",Km="read",zm="afterRead",Ym="beforeMain",Xm="main",Zm="afterMain",qm="beforeWrite",Qm="write",Jm="afterWrite",t1=[jm,Km,zm,Ym,Xm,Zm,qm,Qm,Jm];function Mr(s){return s?(s.nodeName||"").toLowerCase():null}function sr(s){if(s==null)return window;if(s.toString()!=="[object Window]"){var t=s.ownerDocument;return t&&t.defaultView||window}return s}function nn(s){var t=sr(s).Element;return s instanceof t||s instanceof Element}function ur(s){var t=sr(s).HTMLElement;return s instanceof t||s instanceof HTMLElement}function Jl(s){if(typeof ShadowRoot>"u")return!1;var t=sr(s).ShadowRoot;return s instanceof t||s instanceof ShadowRoot}function e1(s){var t=s.state;Object.keys(t.elements).forEach(function(e){var i=t.styles[e]||{},n=t.attributes[e]||{},o=t.elements[e];!ur(o)||!Mr(o)||(Object.assign(o.style,i),Object.keys(n).forEach(function(l){var d=n[l];d===!1?o.removeAttribute(l):o.setAttribute(l,d===!0?"":d)}))})}function i1(s){var t=s.state,e={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,e.popper),t.styles=e,t.elements.arrow&&Object.assign(t.elements.arrow.style,e.arrow),function(){Object.keys(t.elements).forEach(function(i){var n=t.elements[i],o=t.attributes[i]||{},l=Object.keys(t.styles.hasOwnProperty(i)?t.styles[i]:e[i]),d=l.reduce(function(f,p){return f[p]="",f},{});!ur(n)||!Mr(n)||(Object.assign(n.style,d),Object.keys(o).forEach(function(f){n.removeAttribute(f)}))})}}const ku={name:"applyStyles",enabled:!0,phase:"write",fn:e1,effect:i1,requires:["computeStyles"]};function $r(s){return s.split("-")[0]}var an=Math.max,ko=Math.min,Sn=Math.round;function tc(){var s=navigator.userAgentData;return s!=null&&s.brands&&Array.isArray(s.brands)?s.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function wu(){return!/^((?!chrome|android).)*safari/i.test(tc())}function Rn(s,t,e){t===void 0&&(t=!1),e===void 0&&(e=!1);var i=s.getBoundingClientRect(),n=1,o=1;t&&ur(s)&&(n=s.offsetWidth>0&&Sn(i.width)/s.offsetWidth||1,o=s.offsetHeight>0&&Sn(i.height)/s.offsetHeight||1);var l=nn(s)?sr(s):window,d=l.visualViewport,f=!wu()&&e,p=(i.left+(f&&d?d.offsetLeft:0))/n,g=(i.top+(f&&d?d.offsetTop:0))/o,v=i.width/n,A=i.height/o;return{width:v,height:A,top:g,right:p+v,bottom:g+A,left:p,x:p,y:g}}function ec(s){var t=Rn(s),e=s.offsetWidth,i=s.offsetHeight;return Math.abs(t.width-e)<=1&&(e=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:s.offsetLeft,y:s.offsetTop,width:e,height:i}}function Su(s,t){var e=t.getRootNode&&t.getRootNode();if(s.contains(t))return!0;if(e&&Jl(e)){var i=t;do{if(i&&s.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function rs(s){return sr(s).getComputedStyle(s)}function r1(s){return["table","td","th"].indexOf(Mr(s))>=0}function Ss(s){return((nn(s)?s.ownerDocument:s.document)||window.document).documentElement}function wo(s){return Mr(s)==="html"?s:s.assignedSlot||s.parentNode||(Jl(s)?s.host:null)||Ss(s)}function Ru(s){return!ur(s)||rs(s).position==="fixed"?null:s.offsetParent}function s1(s){var t=/firefox/i.test(tc()),e=/Trident/i.test(tc());if(e&&ur(s)){var i=rs(s);if(i.position==="fixed")return null}var n=wo(s);for(Jl(n)&&(n=n.host);ur(n)&&["html","body"].indexOf(Mr(n))<0;){var o=rs(n);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 n;n=n.parentNode}return null}function Ta(s){for(var t=sr(s),e=Ru(s);e&&r1(e)&&rs(e).position==="static";)e=Ru(e);return e&&(Mr(e)==="html"||Mr(e)==="body"&&rs(e).position==="static")?t:e||s1(s)||t}function ic(s){return["top","bottom"].indexOf(s)>=0?"x":"y"}function ka(s,t,e){return an(s,ko(t,e))}function n1(s,t,e){var i=ka(s,t,e);return i>e?e:i}function _u(){return{top:0,right:0,bottom:0,left:0}}function Lu(s){return Object.assign({},_u(),s)}function Cu(s,t){return t.reduce(function(e,i){return e[i]=s,e},{})}var a1=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,Lu(typeof t!="number"?t:Cu(t,ba))};function o1(s){var t,e=s.state,i=s.name,n=s.options,o=e.elements.arrow,l=e.modifiersData.popperOffsets,d=$r(e.placement),f=ic(d),p=[Ki,dr].indexOf(d)>=0,g=p?"height":"width";if(!(!o||!l)){var v=a1(n.padding,e),A=ec(o),E=f==="y"?ji:Ki,T=f==="y"?hr:dr,w=e.rects.reference[g]+e.rects.reference[f]-l[f]-e.rects.popper[g],C=l[f]-e.rects.reference[f],x=Ta(o),O=x?f==="y"?x.clientHeight||0:x.clientWidth||0:0,U=w/2-C/2,D=v[E],H=O-A[g]-v[T],$=O/2-A[g]/2+U,z=ka(D,$,H),tt=f;e.modifiersData[i]=(t={},t[tt]=z,t.centerOffset=z-$,t)}}function l1(s){var t=s.state,e=s.options,i=e.element,n=i===void 0?"[data-popper-arrow]":i;n!=null&&(typeof n=="string"&&(n=t.elements.popper.querySelector(n),!n)||Su(t.elements.popper,n)&&(t.elements.arrow=n))}const c1={name:"arrow",enabled:!0,phase:"main",fn:o1,effect:l1,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function _n(s){return s.split("-")[1]}var h1={top:"auto",right:"auto",bottom:"auto",left:"auto"};function d1(s,t){var e=s.x,i=s.y,n=t.devicePixelRatio||1;return{x:Sn(e*n)/n||0,y:Sn(i*n)/n||0}}function Iu(s){var t,e=s.popper,i=s.popperRect,n=s.placement,o=s.variation,l=s.offsets,d=s.position,f=s.gpuAcceleration,p=s.adaptive,g=s.roundOffsets,v=s.isFixed,A=l.x,E=A===void 0?0:A,T=l.y,w=T===void 0?0:T,C=typeof g=="function"?g({x:E,y:w}):{x:E,y:w};E=C.x,w=C.y;var x=l.hasOwnProperty("x"),O=l.hasOwnProperty("y"),U=Ki,D=ji,H=window;if(p){var $=Ta(e),z="clientHeight",tt="clientWidth";if($===sr(e)&&($=Ss(e),rs($).position!=="static"&&d==="absolute"&&(z="scrollHeight",tt="scrollWidth")),$=$,n===ji||(n===Ki||n===dr)&&o===Aa){D=hr;var at=v&&$===H&&H.visualViewport?H.visualViewport.height:$[z];w-=at-i.height,w*=f?1:-1}if(n===Ki||(n===ji||n===hr)&&o===Aa){U=dr;var J=v&&$===H&&H.visualViewport?H.visualViewport.width:$[tt];E-=J-i.width,E*=f?1:-1}}var St=Object.assign({position:d},p&&h1),mt=g===!0?d1({x:E,y:w},sr(e)):{x:E,y:w};if(E=mt.x,w=mt.y,f){var Ot;return Object.assign({},St,(Ot={},Ot[D]=O?"0":"",Ot[U]=x?"0":"",Ot.transform=(H.devicePixelRatio||1)<=1?"translate("+E+"px, "+w+"px)":"translate3d("+E+"px, "+w+"px, 0)",Ot))}return Object.assign({},St,(t={},t[D]=O?w+"px":"",t[U]=x?E+"px":"",t.transform="",t))}function u1(s){var t=s.state,e=s.options,i=e.gpuAcceleration,n=i===void 0?!0:i,o=e.adaptive,l=o===void 0?!0:o,d=e.roundOffsets,f=d===void 0?!0:d,p={placement:$r(t.placement),variation:_n(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:n,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,Iu(Object.assign({},p,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:l,roundOffsets:f})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,Iu(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 f1={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:u1,data:{}};var So={passive:!0};function p1(s){var t=s.state,e=s.instance,i=s.options,n=i.scroll,o=n===void 0?!0:n,l=i.resize,d=l===void 0?!0:l,f=sr(t.elements.popper),p=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&p.forEach(function(g){g.addEventListener("scroll",e.update,So)}),d&&f.addEventListener("resize",e.update,So),function(){o&&p.forEach(function(g){g.removeEventListener("scroll",e.update,So)}),d&&f.removeEventListener("resize",e.update,So)}}const g1={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:p1,data:{}};var m1={left:"right",right:"left",bottom:"top",top:"bottom"};function Ro(s){return s.replace(/left|right|bottom|top/g,function(t){return m1[t]})}var v1={start:"end",end:"start"};function Du(s){return s.replace(/start|end/g,function(t){return v1[t]})}function rc(s){var t=sr(s),e=t.pageXOffset,i=t.pageYOffset;return{scrollLeft:e,scrollTop:i}}function sc(s){return Rn(Ss(s)).left+rc(s).scrollLeft}function y1(s,t){var e=sr(s),i=Ss(s),n=e.visualViewport,o=i.clientWidth,l=i.clientHeight,d=0,f=0;if(n){o=n.width,l=n.height;var p=wu();(p||!p&&t==="fixed")&&(d=n.offsetLeft,f=n.offsetTop)}return{width:o,height:l,x:d+sc(s),y:f}}function b1(s){var t,e=Ss(s),i=rc(s),n=(t=s.ownerDocument)==null?void 0:t.body,o=an(e.scrollWidth,e.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),l=an(e.scrollHeight,e.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),d=-i.scrollLeft+sc(s),f=-i.scrollTop;return rs(n||e).direction==="rtl"&&(d+=an(e.clientWidth,n?n.clientWidth:0)-o),{width:o,height:l,x:d,y:f}}function nc(s){var t=rs(s),e=t.overflow,i=t.overflowX,n=t.overflowY;return/auto|scroll|overlay|hidden/.test(e+n+i)}function xu(s){return["html","body","#document"].indexOf(Mr(s))>=0?s.ownerDocument.body:ur(s)&&nc(s)?s:xu(wo(s))}function wa(s,t){var e;t===void 0&&(t=[]);var i=xu(s),n=i===((e=s.ownerDocument)==null?void 0:e.body),o=sr(i),l=n?[o].concat(o.visualViewport||[],nc(i)?i:[]):i,d=t.concat(l);return n?d:d.concat(wa(wo(l)))}function ac(s){return Object.assign({},s,{left:s.x,top:s.y,right:s.x+s.width,bottom:s.y+s.height})}function A1(s,t){var e=Rn(s,!1,t==="fixed");return e.top=e.top+s.clientTop,e.left=e.left+s.clientLeft,e.bottom=e.top+s.clientHeight,e.right=e.left+s.clientWidth,e.width=s.clientWidth,e.height=s.clientHeight,e.x=e.left,e.y=e.top,e}function Pu(s,t,e){return t===Au?ac(y1(s,e)):nn(t)?A1(t,e):ac(b1(Ss(s)))}function E1(s){var t=wa(wo(s)),e=["absolute","fixed"].indexOf(rs(s).position)>=0,i=e&&ur(s)?Ta(s):s;return nn(i)?t.filter(function(n){return nn(n)&&Su(n,i)&&Mr(n)!=="body"}):[]}function T1(s,t,e,i){var n=t==="clippingParents"?E1(s):[].concat(t),o=[].concat(n,[e]),l=o[0],d=o.reduce(function(f,p){var g=Pu(s,p,i);return f.top=an(g.top,f.top),f.right=ko(g.right,f.right),f.bottom=ko(g.bottom,f.bottom),f.left=an(g.left,f.left),f},Pu(s,l,i));return d.width=d.right-d.left,d.height=d.bottom-d.top,d.x=d.left,d.y=d.top,d}function Ou(s){var t=s.reference,e=s.element,i=s.placement,n=i?$r(i):null,o=i?_n(i):null,l=t.x+t.width/2-e.width/2,d=t.y+t.height/2-e.height/2,f;switch(n){case ji:f={x:l,y:t.y-e.height};break;case hr:f={x:l,y:t.y+t.height};break;case dr:f={x:t.x+t.width,y:d};break;case Ki:f={x:t.x-e.width,y:d};break;default:f={x:t.x,y:t.y}}var p=n?ic(n):null;if(p!=null){var g=p==="y"?"height":"width";switch(o){case wn:f[p]=f[p]-(t[g]/2-e[g]/2);break;case Aa:f[p]=f[p]+(t[g]/2-e[g]/2);break}}return f}function Sa(s,t){t===void 0&&(t={});var e=t,i=e.placement,n=i===void 0?s.placement:i,o=e.strategy,l=o===void 0?s.strategy:o,d=e.boundary,f=d===void 0?Hm:d,p=e.rootBoundary,g=p===void 0?Au:p,v=e.elementContext,A=v===void 0?Ea:v,E=e.altBoundary,T=E===void 0?!1:E,w=e.padding,C=w===void 0?0:w,x=Lu(typeof C!="number"?C:Cu(C,ba)),O=A===Ea?Wm:Ea,U=s.rects.popper,D=s.elements[T?O:A],H=T1(nn(D)?D:D.contextElement||Ss(s.elements.popper),f,g,l),$=Rn(s.elements.reference),z=Ou({reference:$,element:U,strategy:"absolute",placement:n}),tt=ac(Object.assign({},U,z)),at=A===Ea?tt:$,J={top:H.top-at.top+x.top,bottom:at.bottom-H.bottom+x.bottom,left:H.left-at.left+x.left,right:at.right-H.right+x.right},St=s.modifiersData.offset;if(A===Ea&&St){var mt=St[n];Object.keys(J).forEach(function(Ot){var Vt=[dr,hr].indexOf(Ot)>=0?1:-1,G=[ji,hr].indexOf(Ot)>=0?"y":"x";J[Ot]+=mt[G]*Vt})}return J}function k1(s,t){t===void 0&&(t={});var e=t,i=e.placement,n=e.boundary,o=e.rootBoundary,l=e.padding,d=e.flipVariations,f=e.allowedAutoPlacements,p=f===void 0?Tu:f,g=_n(i),v=g?d?Eu:Eu.filter(function(T){return _n(T)===g}):ba,A=v.filter(function(T){return p.indexOf(T)>=0});A.length===0&&(A=v);var E=A.reduce(function(T,w){return T[w]=Sa(s,{placement:w,boundary:n,rootBoundary:o,padding:l})[$r(w)],T},{});return Object.keys(E).sort(function(T,w){return E[T]-E[w]})}function w1(s){if($r(s)===Ql)return[];var t=Ro(s);return[Du(s),t,Du(t)]}function S1(s){var t=s.state,e=s.options,i=s.name;if(!t.modifiersData[i]._skip){for(var n=e.mainAxis,o=n===void 0?!0:n,l=e.altAxis,d=l===void 0?!0:l,f=e.fallbackPlacements,p=e.padding,g=e.boundary,v=e.rootBoundary,A=e.altBoundary,E=e.flipVariations,T=E===void 0?!0:E,w=e.allowedAutoPlacements,C=t.options.placement,x=$r(C),O=x===C,U=f||(O||!T?[Ro(C)]:w1(C)),D=[C].concat(U).reduce(function(Nt,jt){return Nt.concat($r(jt)===Ql?k1(t,{placement:jt,boundary:g,rootBoundary:v,padding:p,flipVariations:T,allowedAutoPlacements:w}):jt)},[]),H=t.rects.reference,$=t.rects.popper,z=new Map,tt=!0,at=D[0],J=0;J<D.length;J++){var St=D[J],mt=$r(St),Ot=_n(St)===wn,Vt=[ji,hr].indexOf(mt)>=0,G=Vt?"width":"height",q=Sa(t,{placement:St,boundary:g,rootBoundary:v,altBoundary:A,padding:p}),At=Vt?Ot?dr:Ki:Ot?hr:ji;H[G]>$[G]&&(At=Ro(At));var N=Ro(At),F=[];if(o&&F.push(q[mt]<=0),d&&F.push(q[At]<=0,q[N]<=0),F.every(function(Nt){return Nt})){at=St,tt=!1;break}z.set(St,F)}if(tt)for(var j=T?3:1,nt=function(jt){var fe=D.find(function(ve){var me=z.get(ve);if(me)return me.slice(0,jt).every(function(Ke){return Ke})});if(fe)return at=fe,"break"},ct=j;ct>0;ct--){var Lt=nt(ct);if(Lt==="break")break}t.placement!==at&&(t.modifiersData[i]._skip=!0,t.placement=at,t.reset=!0)}}const R1={name:"flip",enabled:!0,phase:"main",fn:S1,requiresIfExists:["offset"],data:{_skip:!1}};function Mu(s,t,e){return e===void 0&&(e={x:0,y:0}),{top:s.top-t.height-e.y,right:s.right-t.width+e.x,bottom:s.bottom-t.height+e.y,left:s.left-t.width-e.x}}function $u(s){return[ji,dr,hr,Ki].some(function(t){return s[t]>=0})}function _1(s){var t=s.state,e=s.name,i=t.rects.reference,n=t.rects.popper,o=t.modifiersData.preventOverflow,l=Sa(t,{elementContext:"reference"}),d=Sa(t,{altBoundary:!0}),f=Mu(l,i),p=Mu(d,n,o),g=$u(f),v=$u(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 L1={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:_1};function C1(s,t,e){var i=$r(s),n=[Ki,ji].indexOf(i)>=0?-1:1,o=typeof e=="function"?e(Object.assign({},t,{placement:s})):e,l=o[0],d=o[1];return l=l||0,d=(d||0)*n,[Ki,dr].indexOf(i)>=0?{x:d,y:l}:{x:l,y:d}}function I1(s){var t=s.state,e=s.options,i=s.name,n=e.offset,o=n===void 0?[0,0]:n,l=Tu.reduce(function(g,v){return g[v]=C1(v,t.rects,o),g},{}),d=l[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]=l}const D1={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:I1};function x1(s){var t=s.state,e=s.name;t.modifiersData[e]=Ou({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const P1={name:"popperOffsets",enabled:!0,phase:"read",fn:x1,data:{}};function O1(s){return s==="x"?"y":"x"}function M1(s){var t=s.state,e=s.options,i=s.name,n=e.mainAxis,o=n===void 0?!0:n,l=e.altAxis,d=l===void 0?!1:l,f=e.boundary,p=e.rootBoundary,g=e.altBoundary,v=e.padding,A=e.tether,E=A===void 0?!0:A,T=e.tetherOffset,w=T===void 0?0:T,C=Sa(t,{boundary:f,rootBoundary:p,padding:v,altBoundary:g}),x=$r(t.placement),O=_n(t.placement),U=!O,D=ic(x),H=O1(D),$=t.modifiersData.popperOffsets,z=t.rects.reference,tt=t.rects.popper,at=typeof w=="function"?w(Object.assign({},t.rects,{placement:t.placement})):w,J=typeof at=="number"?{mainAxis:at,altAxis:at}:Object.assign({mainAxis:0,altAxis:0},at),St=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,mt={x:0,y:0};if($){if(o){var Ot,Vt=D==="y"?ji:Ki,G=D==="y"?hr:dr,q=D==="y"?"height":"width",At=$[D],N=At+C[Vt],F=At-C[G],j=E?-tt[q]/2:0,nt=O===wn?z[q]:tt[q],ct=O===wn?-tt[q]:-z[q],Lt=t.elements.arrow,Nt=E&&Lt?ec(Lt):{width:0,height:0},jt=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:_u(),fe=jt[Vt],ve=jt[G],me=ka(0,z[q],Nt[q]),Ke=U?z[q]/2-j-me-fe-J.mainAxis:nt-me-fe-J.mainAxis,_e=U?-z[q]/2+j+me+ve+J.mainAxis:ct+me+ve+J.mainAxis,Kt=t.elements.arrow&&Ta(t.elements.arrow),Ae=Kt?D==="y"?Kt.clientTop||0:Kt.clientLeft||0:0,de=(Ot=St==null?void 0:St[D])!=null?Ot:0,Me=At+Ke-de-Ae,Ut=At+_e-de,ze=ka(E?ko(N,Me):N,At,E?an(F,Ut):F);$[D]=ze,mt[D]=ze-At}if(d){var Fe,Ve=D==="x"?ji:Ki,we=D==="x"?hr:dr,ue=$[H],Ye=H==="y"?"height":"width",le=ue+C[Ve],Ne=ue-C[we],Ue=[ji,Ki].indexOf(x)!==-1,pi=(Fe=St==null?void 0:St[H])!=null?Fe:0,Ce=Ue?le:ue-z[Ye]-tt[Ye]-pi+J.altAxis,Ai=Ue?ue+z[Ye]+tt[Ye]-pi-J.altAxis:Ne,_r=E&&Ue?n1(Ce,ue,Ai):ka(E?Ce:le,ue,E?Ai:Ne);$[H]=_r,mt[H]=_r-ue}t.modifiersData[i]=mt}}const $1={name:"preventOverflow",enabled:!0,phase:"main",fn:M1,requiresIfExists:["offset"]};function F1(s){return{scrollLeft:s.scrollLeft,scrollTop:s.scrollTop}}function N1(s){return s===sr(s)||!ur(s)?rc(s):F1(s)}function U1(s){var t=s.getBoundingClientRect(),e=Sn(t.width)/s.offsetWidth||1,i=Sn(t.height)/s.offsetHeight||1;return e!==1||i!==1}function B1(s,t,e){e===void 0&&(e=!1);var i=ur(t),n=ur(t)&&U1(t),o=Ss(t),l=Rn(s,n,e),d={scrollLeft:0,scrollTop:0},f={x:0,y:0};return(i||!i&&!e)&&((Mr(t)!=="body"||nc(o))&&(d=N1(t)),ur(t)?(f=Rn(t,!0),f.x+=t.clientLeft,f.y+=t.clientTop):o&&(f.x=sc(o))),{x:l.left+d.scrollLeft-f.x,y:l.top+d.scrollTop-f.y,width:l.width,height:l.height}}function G1(s){var t=new Map,e=new Set,i=[];s.forEach(function(o){t.set(o.name,o)});function n(o){e.add(o.name);var l=[].concat(o.requires||[],o.requiresIfExists||[]);l.forEach(function(d){if(!e.has(d)){var f=t.get(d);f&&n(f)}}),i.push(o)}return s.forEach(function(o){e.has(o.name)||n(o)}),i}function V1(s){var t=G1(s);return t1.reduce(function(e,i){return e.concat(t.filter(function(n){return n.phase===i}))},[])}function H1(s){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(s())})})),t}}function W1(s){var t=s.reduce(function(e,i){var n=e[i.name];return e[i.name]=n?Object.assign({},n,i,{options:Object.assign({},n.options,i.options),data:Object.assign({},n.data,i.data)}):i,e},{});return Object.keys(t).map(function(e){return t[e]})}var Fu={placement:"bottom",modifiers:[],strategy:"absolute"};function Nu(){for(var s=arguments.length,t=new Array(s),e=0;e<s;e++)t[e]=arguments[e];return!t.some(function(i){return!(i&&typeof i.getBoundingClientRect=="function")})}function j1(s){s===void 0&&(s={});var t=s,e=t.defaultModifiers,i=e===void 0?[]:e,n=t.defaultOptions,o=n===void 0?Fu:n;return function(d,f,p){p===void 0&&(p=o);var g={placement:"bottom",orderedModifiers:[],options:Object.assign({},Fu,o),modifiersData:{},elements:{reference:d,popper:f},attributes:{},styles:{}},v=[],A=!1,E={state:g,setOptions:function(x){var O=typeof x=="function"?x(g.options):x;w(),g.options=Object.assign({},o,g.options,O),g.scrollParents={reference:nn(d)?wa(d):d.contextElement?wa(d.contextElement):[],popper:wa(f)};var U=V1(W1([].concat(i,g.options.modifiers)));return g.orderedModifiers=U.filter(function(D){return D.enabled}),T(),E.update()},forceUpdate:function(){if(!A){var x=g.elements,O=x.reference,U=x.popper;if(Nu(O,U)){g.rects={reference:B1(O,Ta(U),g.options.strategy==="fixed"),popper:ec(U)},g.reset=!1,g.placement=g.options.placement,g.orderedModifiers.forEach(function(J){return g.modifiersData[J.name]=Object.assign({},J.data)});for(var D=0;D<g.orderedModifiers.length;D++){if(g.reset===!0){g.reset=!1,D=-1;continue}var H=g.orderedModifiers[D],$=H.fn,z=H.options,tt=z===void 0?{}:z,at=H.name;typeof $=="function"&&(g=$({state:g,options:tt,name:at,instance:E})||g)}}}},update:H1(function(){return new Promise(function(C){E.forceUpdate(),C(g)})}),destroy:function(){w(),A=!0}};if(!Nu(d,f))return E;E.setOptions(p).then(function(C){!A&&p.onFirstUpdate&&p.onFirstUpdate(C)});function T(){g.orderedModifiers.forEach(function(C){var x=C.name,O=C.options,U=O===void 0?{}:O,D=C.effect;if(typeof D=="function"){var H=D({state:g,name:x,instance:E,options:U}),$=function(){};v.push(H||$)}})}function w(){v.forEach(function(C){return C()}),v=[]}return E}}var K1=[g1,P1,f1,ku,D1,R1,$1,c1,L1],z1=j1({defaultModifiers:K1}),Y1="tippy-box",Uu="tippy-content",X1="tippy-backdrop",Bu="tippy-arrow",Gu="tippy-svg-arrow",on={passive:!0,capture:!0},Vu=function(){return document.body};function oc(s,t,e){if(Array.isArray(s)){var i=s[t];return i??(Array.isArray(e)?e[t]:e)}return s}function lc(s,t){var e={}.toString.call(s);return e.indexOf("[object")===0&&e.indexOf(t+"]")>-1}function Hu(s,t){return typeof s=="function"?s.apply(void 0,t):s}function Wu(s,t){if(t===0)return s;var e;return function(i){clearTimeout(e),e=setTimeout(function(){s(i)},t)}}function Z1(s){return s.split(/\s+/).filter(Boolean)}function Ln(s){return[].concat(s)}function ju(s,t){s.indexOf(t)===-1&&s.push(t)}function q1(s){return s.filter(function(t,e){return s.indexOf(t)===e})}function Q1(s){return s.split("-")[0]}function _o(s){return[].slice.call(s)}function Ku(s){return Object.keys(s).reduce(function(t,e){return s[e]!==void 0&&(t[e]=s[e]),t},{})}function Ra(){return document.createElement("div")}function Lo(s){return["Element","Fragment"].some(function(t){return lc(s,t)})}function J1(s){return lc(s,"NodeList")}function tv(s){return lc(s,"MouseEvent")}function ev(s){return!!(s&&s._tippy&&s._tippy.reference===s)}function iv(s){return Lo(s)?[s]:J1(s)?_o(s):Array.isArray(s)?s:_o(document.querySelectorAll(s))}function cc(s,t){s.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function zu(s,t){s.forEach(function(e){e&&e.setAttribute("data-state",t)})}function rv(s){var t,e=Ln(s),i=e[0];return i!=null&&(t=i.ownerDocument)!=null&&t.body?i.ownerDocument:document}function sv(s,t){var e=t.clientX,i=t.clientY;return s.every(function(n){var o=n.popperRect,l=n.popperState,d=n.props,f=d.interactiveBorder,p=Q1(l.placement),g=l.modifiersData.offset;if(!g)return!0;var v=p==="bottom"?g.top.y:0,A=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,C=i-o.bottom-A>f,x=o.left-e+E>f,O=e-o.right-T>f;return w||C||x||O})}function hc(s,t,e){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){s[i](n,e)})}function Yu(s,t){for(var e=t;e;){var i;if(s.contains(e))return!0;e=e.getRootNode==null||(i=e.getRootNode())==null?void 0:i.host}return!1}var Fr={isTouch:!1},Xu=0;function nv(){Fr.isTouch||(Fr.isTouch=!0,window.performance&&document.addEventListener("mousemove",Zu))}function Zu(){var s=performance.now();s-Xu<20&&(Fr.isTouch=!1,document.removeEventListener("mousemove",Zu)),Xu=s}function av(){var s=document.activeElement;if(ev(s)){var t=s._tippy;s.blur&&!t.state.isVisible&&s.blur()}}function ov(){document.addEventListener("touchstart",nv,on),window.addEventListener("blur",av)}var lv=typeof window<"u"&&typeof document<"u",cv=lv?!!window.msCrypto:!1,hv={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},dv={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},kr=Object.assign({appendTo:Vu,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},hv,dv),uv=Object.keys(kr),fv=function(t){var e=Object.keys(t);e.forEach(function(i){kr[i]=t[i]})};function qu(s){var t=s.plugins||[],e=t.reduce(function(i,n){var o=n.name,l=n.defaultValue;if(o){var d;i[o]=s[o]!==void 0?s[o]:(d=kr[o])!=null?d:l}return i},{});return Object.assign({},s,e)}function pv(s,t){var e=t?Object.keys(qu(Object.assign({},kr,{plugins:t}))):uv,i=e.reduce(function(n,o){var l=(s.getAttribute("data-tippy-"+o)||"").trim();if(!l)return n;if(o==="content")n[o]=l;else try{n[o]=JSON.parse(l)}catch{n[o]=l}return n},{});return i}function Qu(s,t){var e=Object.assign({},t,{content:Hu(t.content,[s])},t.ignoreAttributes?{}:pv(s,t.plugins));return e.aria=Object.assign({},kr.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 gv=function(){return"innerHTML"};function dc(s,t){s[gv()]=t}function Ju(s){var t=Ra();return s===!0?t.className=Bu:(t.className=Gu,Lo(s)?t.appendChild(s):dc(t,s)),t}function t0(s,t){Lo(t.content)?(dc(s,""),s.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?dc(s,t.content):s.textContent=t.content)}function uc(s){var t=s.firstElementChild,e=_o(t.children);return{box:t,content:e.find(function(i){return i.classList.contains(Uu)}),arrow:e.find(function(i){return i.classList.contains(Bu)||i.classList.contains(Gu)}),backdrop:e.find(function(i){return i.classList.contains(X1)})}}function e0(s){var t=Ra(),e=Ra();e.className=Y1,e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var i=Ra();i.className=Uu,i.setAttribute("data-state","hidden"),t0(i,s.props),t.appendChild(e),e.appendChild(i),n(s.props,s.props);function n(o,l){var d=uc(t),f=d.box,p=d.content,g=d.arrow;l.theme?f.setAttribute("data-theme",l.theme):f.removeAttribute("data-theme"),typeof l.animation=="string"?f.setAttribute("data-animation",l.animation):f.removeAttribute("data-animation"),l.inertia?f.setAttribute("data-inertia",""):f.removeAttribute("data-inertia"),f.style.maxWidth=typeof l.maxWidth=="number"?l.maxWidth+"px":l.maxWidth,l.role?f.setAttribute("role",l.role):f.removeAttribute("role"),(o.content!==l.content||o.allowHTML!==l.allowHTML)&&t0(p,s.props),l.arrow?g?o.arrow!==l.arrow&&(f.removeChild(g),f.appendChild(Ju(l.arrow))):f.appendChild(Ju(l.arrow)):g&&f.removeChild(g)}return{popper:t,onUpdate:n}}e0.$$tippy=!0;var mv=1,Co=[],fc=[];function vv(s,t){var e=Qu(s,Object.assign({},kr,qu(Ku(t)))),i,n,o,l=!1,d=!1,f=!1,p=!1,g,v,A,E=[],T=Wu(Me,e.interactiveDebounce),w,C=mv++,x=null,O=q1(e.plugins),U={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},D={id:C,reference:s,popper:Ra(),popperInstance:x,props:e,state:U,plugins:O,clearDelayTimeouts:Ce,setProps:Ai,setContent:_r,show:ni,hide:Lr,hideWithInteractivity:xs,enable:Ue,disable:pi,unmount:Ps,destroy:ar};if(!e.render)return D;var H=e.render(D),$=H.popper,z=H.onUpdate;$.setAttribute("data-tippy-root",""),$.id="tippy-"+D.id,D.popper=$,s._tippy=D,$._tippy=D;var tt=O.map(function(dt){return dt.fn(D)}),at=s.hasAttribute("aria-expanded");return Kt(),j(),At(),N("onCreate",[D]),e.showOnCreate&&le(),$.addEventListener("mouseenter",function(){D.props.interactive&&D.state.isVisible&&D.clearDelayTimeouts()}),$.addEventListener("mouseleave",function(){D.props.interactive&&D.props.trigger.indexOf("mouseenter")>=0&&Vt().addEventListener("mousemove",T)}),D;function J(){var dt=D.props.touch;return Array.isArray(dt)?dt:[dt,0]}function St(){return J()[0]==="hold"}function mt(){var dt;return!!((dt=D.props.render)!=null&&dt.$$tippy)}function Ot(){return w||s}function Vt(){var dt=Ot().parentNode;return dt?rv(dt):document}function G(){return uc($)}function q(dt){return D.state.isMounted&&!D.state.isVisible||Fr.isTouch||g&&g.type==="focus"?0:oc(D.props.delay,dt?0:1,kr.delay)}function At(dt){dt===void 0&&(dt=!1),$.style.pointerEvents=D.props.interactive&&!dt?"":"none",$.style.zIndex=""+D.props.zIndex}function N(dt,Gt,Zt){if(Zt===void 0&&(Zt=!0),tt.forEach(function(ne){ne[dt]&&ne[dt].apply(ne,Gt)}),Zt){var ye;(ye=D.props)[dt].apply(ye,Gt)}}function F(){var dt=D.props.aria;if(dt.content){var Gt="aria-"+dt.content,Zt=$.id,ye=Ln(D.props.triggerTarget||s);ye.forEach(function(ne){var ci=ne.getAttribute(Gt);if(D.state.isVisible)ne.setAttribute(Gt,ci?ci+" "+Zt:Zt);else{var Oi=ci&&ci.replace(Zt,"").trim();Oi?ne.setAttribute(Gt,Oi):ne.removeAttribute(Gt)}})}}function j(){if(!(at||!D.props.aria.expanded)){var dt=Ln(D.props.triggerTarget||s);dt.forEach(function(Gt){D.props.interactive?Gt.setAttribute("aria-expanded",D.state.isVisible&&Gt===Ot()?"true":"false"):Gt.removeAttribute("aria-expanded")})}}function nt(){Vt().removeEventListener("mousemove",T),Co=Co.filter(function(dt){return dt!==T})}function ct(dt){if(!(Fr.isTouch&&(f||dt.type==="mousedown"))){var Gt=dt.composedPath&&dt.composedPath()[0]||dt.target;if(!(D.props.interactive&&Yu($,Gt))){if(Ln(D.props.triggerTarget||s).some(function(Zt){return Yu(Zt,Gt)})){if(Fr.isTouch||D.state.isVisible&&D.props.trigger.indexOf("click")>=0)return}else N("onClickOutside",[D,dt]);D.props.hideOnClick===!0&&(D.clearDelayTimeouts(),D.hide(),d=!0,setTimeout(function(){d=!1}),D.state.isMounted||fe())}}}function Lt(){f=!0}function Nt(){f=!1}function jt(){var dt=Vt();dt.addEventListener("mousedown",ct,!0),dt.addEventListener("touchend",ct,on),dt.addEventListener("touchstart",Nt,on),dt.addEventListener("touchmove",Lt,on)}function fe(){var dt=Vt();dt.removeEventListener("mousedown",ct,!0),dt.removeEventListener("touchend",ct,on),dt.removeEventListener("touchstart",Nt,on),dt.removeEventListener("touchmove",Lt,on)}function ve(dt,Gt){Ke(dt,function(){!D.state.isVisible&&$.parentNode&&$.parentNode.contains($)&&Gt()})}function me(dt,Gt){Ke(dt,Gt)}function Ke(dt,Gt){var Zt=G().box;function ye(ne){ne.target===Zt&&(hc(Zt,"remove",ye),Gt())}if(dt===0)return Gt();hc(Zt,"remove",v),hc(Zt,"add",ye),v=ye}function _e(dt,Gt,Zt){Zt===void 0&&(Zt=!1);var ye=Ln(D.props.triggerTarget||s);ye.forEach(function(ne){ne.addEventListener(dt,Gt,Zt),E.push({node:ne,eventType:dt,handler:Gt,options:Zt})})}function Kt(){St()&&(_e("touchstart",de,{passive:!0}),_e("touchend",Ut,{passive:!0})),Z1(D.props.trigger).forEach(function(dt){if(dt!=="manual")switch(_e(dt,de),dt){case"mouseenter":_e("mouseleave",Ut);break;case"focus":_e(cv?"focusout":"blur",ze);break;case"focusin":_e("focusout",ze);break}})}function Ae(){E.forEach(function(dt){var Gt=dt.node,Zt=dt.eventType,ye=dt.handler,ne=dt.options;Gt.removeEventListener(Zt,ye,ne)}),E=[]}function de(dt){var Gt,Zt=!1;if(!(!D.state.isEnabled||Fe(dt)||d)){var ye=((Gt=g)==null?void 0:Gt.type)==="focus";g=dt,w=dt.currentTarget,j(),!D.state.isVisible&&tv(dt)&&Co.forEach(function(ne){return ne(dt)}),dt.type==="click"&&(D.props.trigger.indexOf("mouseenter")<0||l)&&D.props.hideOnClick!==!1&&D.state.isVisible?Zt=!0:le(dt),dt.type==="click"&&(l=!Zt),Zt&&!ye&&Ne(dt)}}function Me(dt){var Gt=dt.target,Zt=Ot().contains(Gt)||$.contains(Gt);if(!(dt.type==="mousemove"&&Zt)){var ye=Ye().concat($).map(function(ne){var ci,Oi=ne._tippy,vr=(ci=Oi.popperInstance)==null?void 0:ci.state;return vr?{popperRect:ne.getBoundingClientRect(),popperState:vr,props:e}:null}).filter(Boolean);sv(ye,dt)&&(nt(),Ne(dt))}}function Ut(dt){var Gt=Fe(dt)||D.props.trigger.indexOf("click")>=0&&l;if(!Gt){if(D.props.interactive){D.hideWithInteractivity(dt);return}Ne(dt)}}function ze(dt){D.props.trigger.indexOf("focusin")<0&&dt.target!==Ot()||D.props.interactive&&dt.relatedTarget&&$.contains(dt.relatedTarget)||Ne(dt)}function Fe(dt){return Fr.isTouch?St()!==dt.type.indexOf("touch")>=0:!1}function Ve(){we();var dt=D.props,Gt=dt.popperOptions,Zt=dt.placement,ye=dt.offset,ne=dt.getReferenceClientRect,ci=dt.moveTransition,Oi=mt()?uc($).arrow:null,vr=ne?{getBoundingClientRect:ne,contextElement:ne.contextElement||Ot()}:s,hs={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Os){var Mi=Os.state;if(mt()){var Ua=G(),Ar=Ua.box;["placement","reference-hidden","escaped"].forEach(function(Ms){Ms==="placement"?Ar.setAttribute("data-placement",Mi.placement):Mi.attributes.popper["data-popper-"+Ms]?Ar.setAttribute("data-"+Ms,""):Ar.removeAttribute("data-"+Ms)}),Mi.attributes.popper={}}}},yr=[{name:"offset",options:{offset:ye}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!ci}},hs];mt()&&Oi&&yr.push({name:"arrow",options:{element:Oi,padding:3}}),yr.push.apply(yr,(Gt==null?void 0:Gt.modifiers)||[]),D.popperInstance=z1(vr,$,Object.assign({},Gt,{placement:Zt,onFirstUpdate:A,modifiers:yr}))}function we(){D.popperInstance&&(D.popperInstance.destroy(),D.popperInstance=null)}function ue(){var dt=D.props.appendTo,Gt,Zt=Ot();D.props.interactive&&dt===Vu||dt==="parent"?Gt=Zt.parentNode:Gt=Hu(dt,[Zt]),Gt.contains($)||Gt.appendChild($),D.state.isMounted=!0,Ve()}function Ye(){return _o($.querySelectorAll("[data-tippy-root]"))}function le(dt){D.clearDelayTimeouts(),dt&&N("onTrigger",[D,dt]),jt();var Gt=q(!0),Zt=J(),ye=Zt[0],ne=Zt[1];Fr.isTouch&&ye==="hold"&&ne&&(Gt=ne),Gt?i=setTimeout(function(){D.show()},Gt):D.show()}function Ne(dt){if(D.clearDelayTimeouts(),N("onUntrigger",[D,dt]),!D.state.isVisible){fe();return}if(!(D.props.trigger.indexOf("mouseenter")>=0&&D.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(dt.type)>=0&&l)){var Gt=q(!1);Gt?n=setTimeout(function(){D.state.isVisible&&D.hide()},Gt):o=requestAnimationFrame(function(){D.hide()})}}function Ue(){D.state.isEnabled=!0}function pi(){D.hide(),D.state.isEnabled=!1}function Ce(){clearTimeout(i),clearTimeout(n),cancelAnimationFrame(o)}function Ai(dt){if(!D.state.isDestroyed){N("onBeforeUpdate",[D,dt]),Ae();var Gt=D.props,Zt=Qu(s,Object.assign({},Gt,Ku(dt),{ignoreAttributes:!0}));D.props=Zt,Kt(),Gt.interactiveDebounce!==Zt.interactiveDebounce&&(nt(),T=Wu(Me,Zt.interactiveDebounce)),Gt.triggerTarget&&!Zt.triggerTarget?Ln(Gt.triggerTarget).forEach(function(ye){ye.removeAttribute("aria-expanded")}):Zt.triggerTarget&&s.removeAttribute("aria-expanded"),j(),At(),z&&z(Gt,Zt),D.popperInstance&&(Ve(),Ye().forEach(function(ye){requestAnimationFrame(ye._tippy.popperInstance.forceUpdate)})),N("onAfterUpdate",[D,dt])}}function _r(dt){D.setProps({content:dt})}function ni(){var dt=D.state.isVisible,Gt=D.state.isDestroyed,Zt=!D.state.isEnabled,ye=Fr.isTouch&&!D.props.touch,ne=oc(D.props.duration,0,kr.duration);if(!(dt||Gt||Zt||ye)&&!Ot().hasAttribute("disabled")&&(N("onShow",[D],!1),D.props.onShow(D)!==!1)){if(D.state.isVisible=!0,mt()&&($.style.visibility="visible"),At(),jt(),D.state.isMounted||($.style.transition="none"),mt()){var ci=G(),Oi=ci.box,vr=ci.content;cc([Oi,vr],0)}A=function(){var yr;if(!(!D.state.isVisible||p)){if(p=!0,$.offsetHeight,$.style.transition=D.props.moveTransition,mt()&&D.props.animation){var br=G(),Os=br.box,Mi=br.content;cc([Os,Mi],ne),zu([Os,Mi],"visible")}F(),j(),ju(fc,D),(yr=D.popperInstance)==null||yr.forceUpdate(),N("onMount",[D]),D.props.animation&&mt()&&me(ne,function(){D.state.isShown=!0,N("onShown",[D])})}},ue()}}function Lr(){var dt=!D.state.isVisible,Gt=D.state.isDestroyed,Zt=!D.state.isEnabled,ye=oc(D.props.duration,1,kr.duration);if(!(dt||Gt||Zt)&&(N("onHide",[D],!1),D.props.onHide(D)!==!1)){if(D.state.isVisible=!1,D.state.isShown=!1,p=!1,l=!1,mt()&&($.style.visibility="hidden"),nt(),fe(),At(!0),mt()){var ne=G(),ci=ne.box,Oi=ne.content;D.props.animation&&(cc([ci,Oi],ye),zu([ci,Oi],"hidden"))}F(),j(),D.props.animation?mt()&&ve(ye,D.unmount):D.unmount()}}function xs(dt){Vt().addEventListener("mousemove",T),ju(Co,T),T(dt)}function Ps(){D.state.isVisible&&D.hide(),D.state.isMounted&&(we(),Ye().forEach(function(dt){dt._tippy.unmount()}),$.parentNode&&$.parentNode.removeChild($),fc=fc.filter(function(dt){return dt!==D}),D.state.isMounted=!1,N("onHidden",[D]))}function ar(){D.state.isDestroyed||(D.clearDelayTimeouts(),D.unmount(),Ae(),delete s._tippy,D.state.isDestroyed=!0,N("onDestroy",[D]))}}function ln(s,t){t===void 0&&(t={});var e=kr.plugins.concat(t.plugins||[]);ov();var i=Object.assign({},t,{plugins:e}),n=iv(s),o=n.reduce(function(l,d){var f=d&&vv(d,i);return f&&l.push(f),l},[]);return Lo(s)?o[0]:o}ln.defaultProps=kr,ln.setDefaultProps=fv,ln.currentInput=Fr,Object.assign({},ku,{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)}}),ln.setDefaultProps({render:e0});class ss extends Error{constructor(t,e=!1){super(),this.fatal=!1,this.message=t,this.fatal=e}}const yv=5;class bv{constructor(t){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._canvas=Si(),this._controls=Si(),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,n,o,l;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-yv&&d<g))??[],this.loadScenes(),this.syncVideoState(),(n=this._controls.value)==null||n.setAttribute("currentTime",d.toString());const f=this.activeScenes[0],p=du((o=f==null?void 0:f.videoMeta)==null?void 0:o.captions);this.caption=((l=p.find(({start:g,end:v})=>{var A;const E=d-f.start+(((A=f.videoMeta)==null?void 0:A.start)??0);return g&&v&&E>=Ao(g)&&E<=Ao(v)}))==null?void 0:l.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 Ri(this._canvas)}controls(){return Ri(this._controls)}loadScenes(){[...this.activeScenes,...this._upcomingScenes].forEach(t=>{var e,i,n;const{start:o,duration:l,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:A}=d,{start:E,duration:T}=f,w=this.host.videoState[g];A&&w&&(A.currentTime>=E+T||A.ended||p&&(v?(e=v.startLoadOnce)==null||e.call(v,A.currentTime):w.initialised||(i=A.startLoadOnce)==null||i.call(A)))}else if(p){const g=`${o}-${l}`,v=this.host._sceneController.videoState[g];this.host.duration&&!((n=v==null?void 0:v.buffered)!=null&&n.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+l)/this.host.duration*100,100)}]}})}})}syncVideoState(){var t;(t=this.host.scenes)==null||t.forEach(e=>{if(e.video){const{key:i,node:n}=e.video,o=this.host.videoState[i],l=this.activeScenes.includes(e);if(n&&o)if(l&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(n.paused&&o.initialised)try{return n.play()}catch(d){throw new ss(`Video play error: ${d.message}`,!0)}}else n.paused||n.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 Av(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var i0={exports:{}};(function(s,t){(function(e){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,o=/(?:\/|^)\.(?=\/)/g,l=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/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 A=d.parseURL(p);if(!A)throw new Error("Error trying to parse relative URL.");if(A.scheme)return g.alwaysNormalize?(A.path=d.normalizePath(A.path),d.buildURLFromParts(A)):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=n.exec(E.path);E.netLoc=T[1],E.path=T[2]}E.netLoc&&!E.path&&(E.path="/");var w={scheme:E.scheme,netLoc:A.netLoc,path:null,params:A.params,query:A.query,fragment:A.fragment};if(!A.netLoc&&(w.netLoc=E.netLoc,A.path[0]!=="/"))if(!A.path)w.path=E.path,A.params||(w.params=E.params,A.query||(w.query=E.query));else{var C=E.path,x=C.substring(0,C.lastIndexOf("/")+1)+A.path;w.path=d.normalizePath(x)}return w.path===null&&(w.path=g.alwaysNormalize?d.normalizePath(A.path):A.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(l,"")).length;);return f.split("").reverse().join("")},buildURLFromParts:function(f){return f.scheme+f.netLoc+f.path+f.params+f.query+f.fragment}};s.exports=d})()})(i0);var pc=i0.exports;function r0(s,t){var e=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(s,n).enumerable})),e.push.apply(e,i)}return e}function zi(s){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?r0(Object(e),!0).forEach(function(i){Ev(s,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):r0(Object(e)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(e,i))})}return s}function Ev(s,t,e){return t=kv(t),t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}function ui(){return ui=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(s[i]=e[i])}return s},ui.apply(this,arguments)}function Tv(s,t){if(typeof s!="object"||s===null)return s;var e=s[Symbol.toPrimitive];if(e!==void 0){var i=e.call(s,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(s)}function kv(s){var t=Tv(s,"string");return typeof t=="symbol"?t:String(t)}const Wt=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)};let R=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s}({}),Qt=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),pt=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.UNKNOWN="unknown",s}({});const cn=function(){},gc={trace:cn,debug:cn,log:cn,warn:cn,info:cn,error:cn};let _a=gc;function wv(s){const t=self.console[s];return t?t.bind(self.console,`[${s}] >`):cn}function Sv(s,...t){t.forEach(function(e){_a[e]=s[e]?s[e].bind(s):wv(e)})}function Rv(s,t){if(self.console&&s===!0||typeof s=="object"){Sv(s,"debug","log","info","warn","error");try{_a.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch{_a=gc}}else _a=gc}const X=_a,_v=/^(\d+)x(\d+)$/,s0=/(.+?)=(".*?"|.*?)(?:,|$)/g;class ti{constructor(t){typeof t=="string"&&(t=ti.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 n=0;n<e.length/2;n++)i[n]=parseInt(e.slice(n*2,n*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=_v.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const i={},n='"';for(s0.lastIndex=0;(e=s0.exec(t))!==null;){let o=e[2];o.indexOf(n)===0&&o.lastIndexOf(n)===o.length-1&&(o=o.slice(1,-1));const l=e[1].trim();i[l]=o}return i}}function Lv(s){return s!=="ID"&&s!=="CLASS"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function Cv(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}class n0{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 n in i)if(Object.prototype.hasOwnProperty.call(t,n)&&t[n]!==i[n]){X.warn(`DATERANGE tag attribute: "${n}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=n;break}t=ui(new ti({}),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"]);Wt(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(Wt(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&&Wt(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Io{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 De={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class a0{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[De.AUDIO]:null,[De.VIDEO]:null,[De.AUDIOVIDEO]:null},this.baseurl=t}setByteRange(t,e){const i=t.split("@",2),n=[];i.length===1?n[0]=e?e.byteRangeEndOffset:0:n[0]=parseInt(i[1]),n[1]=parseInt(i[0])+n[0],this._byteRange=n}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=pc.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class mc extends a0{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 Io,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||!Wt(this.programDateTime))return null;const t=Wt(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,n,o,l=!1){const{elementaryStreams:d}=this,f=d[t];if(!f){d[t]={startPTS:e,endPTS:i,startDTS:n,endDTS:o,partial:l};return}f.startPTS=Math.min(f.startPTS,e),f.endPTS=Math.max(f.endPTS,i),f.startDTS=Math.min(f.startDTS,n),f.endDTS=Math.max(f.endDTS,o)}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[De.AUDIO]=null,t[De.VIDEO]=null,t[De.AUDIOVIDEO]=null}}class Iv extends a0{constructor(t,e,i,n,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 Io,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=n;const l=t.enumeratedString("BYTERANGE");l&&this.setByteRange(l,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 Dv=10;class xv{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?Wt(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Dv}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 vc(s){return Uint8Array.from(atob(s),t=>t.charCodeAt(0))}function Pv(s){const t=o0(s).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e}function Ov(s){const t=function(e,i,n){const o=e[i];e[i]=e[n],e[n]=o};t(s,0,3),t(s,1,2),t(s,4,5),t(s,6,7)}function Mv(s){const t=s.split(":");let e=null;if(t[0]==="data"&&t.length===2){const i=t[1].split(";"),n=i[i.length-1].split(",");if(n.length===2){const o=n[0]==="base64",l=n[1];o?(i.splice(-1,1),e=vc(l)):e=Pv(l)}}return e}function o0(s){return Uint8Array.from(unescape(encodeURIComponent(s)),t=>t.charCodeAt(0))}var ei={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Yi={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function l0(s){switch(s){case Yi.FAIRPLAY:return ei.FAIRPLAY;case Yi.PLAYREADY:return ei.PLAYREADY;case Yi.WIDEVINE:return ei.WIDEVINE;case Yi.CLEARKEY:return ei.CLEARKEY}}var c0={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function $v(s){if(s===c0.WIDEVINE)return ei.WIDEVINE}function h0(s){switch(s){case ei.FAIRPLAY:return Yi.FAIRPLAY;case ei.PLAYREADY:return Yi.PLAYREADY;case ei.WIDEVINE:return Yi.WIDEVINE;case ei.CLEARKEY:return Yi.CLEARKEY}}function yc(s){const{drmSystems:t,widevineLicenseUrl:e}=s,i=t?[ei.FAIRPLAY,ei.WIDEVINE,ei.PLAYREADY,ei.CLEARKEY].filter(n=>!!t[n]):[];return!i[ei.WIDEVINE]&&e&&i.push(ei.WIDEVINE),i}const d0=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Fv(s,t,e,i){let n;switch(s){case ei.FAIRPLAY:n=["cenc","sinf"];break;case ei.WIDEVINE:case ei.PLAYREADY:n=["cenc"];break;case ei.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return Nv(n,t,e,i)}function Nv(s,t,e,i){return[{initDataTypes:s,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:e.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function hn(s,t,e){return Uint8Array.prototype.slice?s.slice(t,e):new Uint8Array(Array.prototype.slice.call(s,t,e))}const bc=(s,t)=>t+10<=s.length&&s[t]===73&&s[t+1]===68&&s[t+2]===51&&s[t+3]<255&&s[t+4]<255&&s[t+6]<128&&s[t+7]<128&&s[t+8]<128&&s[t+9]<128,u0=(s,t)=>t+10<=s.length&&s[t]===51&&s[t+1]===68&&s[t+2]===73&&s[t+3]<255&&s[t+4]<255&&s[t+6]<128&&s[t+7]<128&&s[t+8]<128&&s[t+9]<128,Do=(s,t)=>{const e=t;let i=0;for(;bc(s,t);){i+=10;const n=xo(s,t+6);i+=n,u0(s,t+10)&&(i+=10),t+=i}if(i>0)return s.subarray(e,e+i)},xo=(s,t)=>{let e=0;return e=(s[t]&127)<<21,e|=(s[t+1]&127)<<14,e|=(s[t+2]&127)<<7,e|=s[t+3]&127,e},Uv=(s,t)=>bc(s,t)&&xo(s,t+6)+10<=s.length-t,Bv=s=>{const t=p0(s);for(let e=0;e<t.length;e++){const i=t[e];if(f0(i))return Kv(i)}},f0=s=>s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp",Gv=s=>{const t=String.fromCharCode(s[0],s[1],s[2],s[3]),e=xo(s,4),i=10;return{type:t,size:e,data:s.subarray(i,i+e)}},p0=s=>{let t=0;const e=[];for(;bc(s,t);){const i=xo(s,t+6);t+=10;const n=t+i;for(;t+8<n;){const o=Gv(s.subarray(t)),l=Vv(o);l&&e.push(l),t+=o.size+10}u0(s,t)&&(t+=10)}return e},Vv=s=>s.type==="PRIV"?Hv(s):s.type[0]==="W"?jv(s):Wv(s),Hv=s=>{if(s.size<2)return;const t=Nr(s.data,!0),e=new Uint8Array(s.data.subarray(t.length+1));return{key:s.type,info:t,data:e.buffer}},Wv=s=>{if(s.size<2)return;if(s.type==="TXXX"){let e=1;const i=Nr(s.data.subarray(e),!0);e+=i.length+1;const n=Nr(s.data.subarray(e));return{key:s.type,info:i,data:n}}const t=Nr(s.data.subarray(1));return{key:s.type,data:t}},jv=s=>{if(s.type==="WXXX"){if(s.size<2)return;let e=1;const i=Nr(s.data.subarray(e),!0);e+=i.length+1;const n=Nr(s.data.subarray(e));return{key:s.type,info:i,data:n}}const t=Nr(s.data);return{key:s.type,data:t}},Kv=s=>{if(s.data.byteLength===8){const t=new Uint8Array(s.data),e=t[3]&1;let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,e&&(i+=4772185884e-2),Math.round(i)}},Nr=(s,t=!1)=>{const e=zv();if(e){const p=e.decode(s);if(t){const g=p.indexOf("\0");return g!==-1?p.substring(0,g):p}return p.replace(/\0/g,"")}const i=s.length;let n,o,l,d="",f=0;for(;f<i;){if(n=s[f++],n===0&&t)return d;if(!(n===0||n===3))switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(n);break;case 12:case 13:o=s[f++],d+=String.fromCharCode((n&31)<<6|o&63);break;case 14:o=s[f++],l=s[f++],d+=String.fromCharCode((n&15)<<12|(o&63)<<6|(l&63)<<0);break}}return d};let Ac;function zv(){return!Ac&&typeof self.TextDecoder<"u"&&(Ac=new self.TextDecoder("utf-8")),Ac}const Ur={hexDump:function(s){let t="";for(let e=0;e<s.length;e++){let i=s[e].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},Po=Math.pow(2,32)-1,Yv=[].push,g0={video:1,audio:2,id3:3,text:4};function Li(s){return String.fromCharCode.apply(null,s)}function m0(s,t){const e=s[t]<<8|s[t+1];return e<0?65536+e:e}function ee(s,t){const e=v0(s,t);return e<0?4294967296+e:e}function v0(s,t){return s[t]<<24|s[t+1]<<16|s[t+2]<<8|s[t+3]}function Ec(s,t,e){s[t]=e>>24,s[t+1]=e>>16&255,s[t+2]=e>>8&255,s[t+3]=e&255}function be(s,t){const e=[];if(!t.length)return e;const i=s.byteLength;for(let n=0;n<i;){const o=ee(s,n),l=Li(s.subarray(n+4,n+8)),d=o>1?n+o:i;if(l===t[0])if(t.length===1)e.push(s.subarray(n+8,d));else{const f=be(s.subarray(n+8,d),t.slice(1));f.length&&Yv.apply(e,f)}n=d}return e}function Xv(s){const t=[],e=s[0];let i=8;const n=ee(s,i);i+=4;const o=0,l=0;e===0?i+=8:i+=16,i+=2;let d=s.length+l;const f=m0(s,i);i+=2;for(let p=0;p<f;p++){let g=i;const v=ee(s,g);g+=4;const A=v&2147483647;if((v&2147483648)>>>31===1)return X.warn("SIDX has hierarchical references (not supported)"),null;const E=ee(s,g);g+=4,t.push({referenceSize:A,subsegmentDuration:E,info:{duration:E/n,start:d,end:d+A-1}}),d+=A,g+=4,i=g}return{earliestPresentationTime:o,timescale:n,version:e,referencesCount:f,references:t}}function y0(s){const t=[],e=be(s,["moov","trak"]);for(let i=0;i<e.length;i++){const n=e[i],o=be(n,["tkhd"])[0];if(o){let l=o[0],d=l===0?12:20;const f=ee(o,d),p=be(n,["mdia","mdhd"])[0];if(p){l=p[0],d=l===0?12:20;const g=ee(p,d),v=be(n,["mdia","hdlr"])[0];if(v){const A=Li(v.subarray(8,12)),E={soun:De.AUDIO,vide:De.VIDEO}[A];if(E){const T=be(n,["mdia","minf","stbl","stsd"])[0];let w;T&&(w=Li(T.subarray(12,16))),t[f]={timescale:g,type:E},t[E]={timescale:g,id:f,codec:w}}}}}}return be(s,["moov","mvex","trex"]).forEach(i=>{const n=ee(i,4),o=t[n];o&&(o.default={duration:ee(i,12),flags:ee(i,20)})}),t}function Zv(s,t){if(!s||!t)return s;const e=t.keyId;return e&&t.isCommonEncryption&&be(s,["moov","trak"]).forEach(i=>{const n=be(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=be(n,["enca"]);const l=o.length>0;l||(o=be(n,["encv"])),o.forEach(d=>{const f=l?d.subarray(28):d.subarray(78);be(f,["sinf"]).forEach(p=>{const g=b0(p);if(g){const v=g.subarray(8,24);v.some(A=>A!==0)||(X.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Ur.hexDump(v)} -> ${Ur.hexDump(e)}`),g.set(e,8))}})})}),s}function b0(s){const t=be(s,["schm"])[0];if(t){const e=Li(t.subarray(4,8));if(e==="cbcs"||e==="cenc")return be(s,["schi","tenc"])[0]}return X.error("[eme] missing 'schm' box"),null}function qv(s,t){return be(t,["moof","traf"]).reduce((e,i)=>{const n=be(i,["tfdt"])[0],o=n[0],l=be(i,["tfhd"]).reduce((d,f)=>{const p=ee(f,4),g=s[p];if(g){let v=ee(n,4);if(o===1){if(v===Po)return X.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),d;v*=Po+1,v+=ee(n,8)}const A=g.timescale||9e4,E=v/A;if(isFinite(E)&&(d===null||E<d))return E}return d},null);return l!==null&&isFinite(l)&&(e===null||l<e)?l:e},null)}function Qv(s,t){let e=0,i=0,n=0;const o=be(s,["moof","traf"]);for(let l=0;l<o.length;l++){const d=o[l],f=be(d,["tfhd"])[0],p=ee(f,4),g=t[p];if(!g)continue;const v=g.default,A=ee(f,0)|(v==null?void 0:v.flags);let E=v==null?void 0:v.duration;A&8&&(A&2?E=ee(f,12):E=ee(f,8));const T=g.timescale||9e4,w=be(d,["trun"]);for(let C=0;C<w.length;C++){if(e=Jv(w[C]),!e&&E){const x=ee(w[C],4);e=E*x}g.type===De.VIDEO?i+=e/T:g.type===De.AUDIO&&(n+=e/T)}}if(i===0&&n===0){let l=0;const d=be(s,["sidx"]);for(let f=0;f<d.length;f++){const p=Xv(d[f]);p!=null&&p.references&&(l+=p.references.reduce((g,v)=>g+v.info.duration||0,0))}return l}return i||n}function Jv(s){const t=ee(s,0);let e=8;t&1&&(e+=4),t&4&&(e+=4);let i=0;const n=ee(s,4);for(let o=0;o<n;o++){if(t&256){const l=ee(s,e);i+=l,e+=4}t&512&&(e+=4),t&1024&&(e+=4),t&2048&&(e+=4)}return i}function ty(s,t,e){be(t,["moof","traf"]).forEach(i=>{be(i,["tfhd"]).forEach(n=>{const o=ee(n,4),l=s[o];if(!l)return;const d=l.timescale||9e4;be(i,["tfdt"]).forEach(f=>{const p=f[0];let g=ee(f,4);if(p===0)g-=e*d,g=Math.max(g,0),Ec(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/(Po+1)),A=Math.floor(g%(Po+1));Ec(f,4,v),Ec(f,8,A)}})})})}function ey(s){const t={valid:null,remainder:null},e=be(s,["moof"]);if(e){if(e.length<2)return t.remainder=s,t}else return t;const i=e[e.length-1];return t.valid=hn(s,0,i.byteOffset-8),t.remainder=hn(s,i.byteOffset-8),t}function dn(s,t){const e=new Uint8Array(s.length+t.length);return e.set(s),e.set(t,s.length),e}function A0(s,t){const e=[],i=t.samples,n=t.timescale,o=t.id;let l=!1;return be(i,["moof"]).map(d=>{const f=d.byteOffset-8;be(d,["traf"]).map(p=>{const g=be(p,["tfdt"]).map(v=>{const A=v[0];let E=ee(v,4);return A===1&&(E*=Math.pow(2,32),E+=ee(v,8)),E/n})[0];return g!==void 0&&(s=g),be(p,["tfhd"]).map(v=>{const A=ee(v,4),E=ee(v,0)&16777215,T=(E&1)!==0,w=(E&2)!==0,C=(E&8)!==0;let x=0;const O=(E&16)!==0;let U=0;const D=(E&32)!==0;let H=8;A===o&&(T&&(H+=8),w&&(H+=4),C&&(x=ee(v,H),H+=4),O&&(U=ee(v,H),H+=4),D&&(H+=4),t.type==="video"&&(l=iy(t.codec)),be(p,["trun"]).map($=>{const z=$[0],tt=ee($,0)&16777215,at=(tt&1)!==0;let J=0;const St=(tt&4)!==0,mt=(tt&256)!==0;let Ot=0;const Vt=(tt&512)!==0;let G=0;const q=(tt&1024)!==0,At=(tt&2048)!==0;let N=0;const F=ee($,4);let j=8;at&&(J=ee($,j),j+=4),St&&(j+=4);let nt=J+f;for(let ct=0;ct<F;ct++){if(mt?(Ot=ee($,j),j+=4):Ot=x,Vt?(G=ee($,j),j+=4):G=U,q&&(j+=4),At&&(z===0?N=ee($,j):N=v0($,j),j+=4),t.type===De.VIDEO){let Lt=0;for(;Lt<G;){const Nt=ee(i,nt);if(nt+=4,ry(l,i[nt])){const jt=i.subarray(nt,nt+Nt);E0(jt,l?2:1,s+N/n,e)}nt+=Nt,Lt+=Nt+4}}s+=Ot/n}}))})})}),e}function iy(s){if(!s)return!1;const t=s.indexOf("."),e=t<0?s:s.substring(0,t);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function ry(s,t){if(s){const e=t>>1&63;return e===39||e===40}else return(t&31)===6}function E0(s,t,e,i){const n=T0(s);let o=0;o+=t;let l=0,d=0,f=!1,p=0;for(;o<n.length;){l=0;do{if(o>=n.length)break;p=n[o++],l+=p}while(p===255);d=0;do{if(o>=n.length)break;p=n[o++],d+=p}while(p===255);const g=n.length-o;if(!f&&l===4&&o<n.length){if(f=!0,n[o++]===181){const v=m0(n,o);if(o+=2,v===49){const A=ee(n,o);if(o+=4,A===1195456820){const E=n[o++];if(E===3){const T=n[o++],w=31&T,C=64&T,x=C?2+w*3:0,O=new Uint8Array(x);if(C){O[0]=T;for(let U=1;U<x;U++)O[U]=n[o++]}i.push({type:E,payloadType:l,pts:e,bytes:O})}}}}}else if(l===5&&d<g){if(f=!0,d>16){const v=[];for(let T=0;T<16;T++){const w=n[o++].toString(16);v.push(w.length==1?"0"+w:w),(T===3||T===5||T===7||T===9)&&v.push("-")}const A=d-16,E=new Uint8Array(A);for(let T=0;T<A;T++)E[T]=n[o++];i.push({payloadType:l,pts:e,uuid:v.join(""),userData:Nr(E),userDataBytes:E})}}else if(d<g)o+=d;else if(d>g)break}}function T0(s){const t=s.byteLength,e=[];let i=1;for(;i<t-2;)s[i]===0&&s[i+1]===0&&s[i+2]===3?(e.push(i+2),i+=2):i++;if(e.length===0)return s;const n=t-e.length,o=new Uint8Array(n);let l=0;for(i=0;i<n;l++,i++)l===e[0]&&(l++,e.shift()),o[i]=s[l];return o}function sy(s){const t=s[0];let e="",i="",n=0,o=0,l=0,d=0,f=0,p=0;if(t===0){for(;Li(s.subarray(p,p+1))!=="\0";)e+=Li(s.subarray(p,p+1)),p+=1;for(e+=Li(s.subarray(p,p+1)),p+=1;Li(s.subarray(p,p+1))!=="\0";)i+=Li(s.subarray(p,p+1)),p+=1;i+=Li(s.subarray(p,p+1)),p+=1,n=ee(s,12),o=ee(s,16),d=ee(s,20),f=ee(s,24),p=28}else if(t===1){p+=4,n=ee(s,p),p+=4;const v=ee(s,p);p+=4;const A=ee(s,p);for(p+=4,l=4294967296*v+A,Number.isSafeInteger(l)||(l=Number.MAX_SAFE_INTEGER,X.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),d=ee(s,p),p+=4,f=ee(s,p),p+=4;Li(s.subarray(p,p+1))!=="\0";)e+=Li(s.subarray(p,p+1)),p+=1;for(e+=Li(s.subarray(p,p+1)),p+=1;Li(s.subarray(p,p+1))!=="\0";)i+=Li(s.subarray(p,p+1)),p+=1;i+=Li(s.subarray(p,p+1)),p+=1}const g=s.subarray(p,s.byteLength);return{schemeIdUri:e,value:i,timeScale:n,presentationTime:l,presentationTimeDelta:o,eventDuration:d,id:f,payload:g}}function ny(s,...t){const e=t.length;let i=8,n=e;for(;n--;)i+=t[n].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(s,4),n=0,i=8;n<e;n++)o.set(t[n],i),i+=t[n].byteLength;return o}function ay(s,t,e){if(s.byteLength!==16)throw new RangeError("Invalid system id");let i,n;if(t){i=1,n=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");n.set(f,d*16)}}else i=0,n=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 l=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(l.buffer).setUint32(0,e.byteLength,!1),ny([112,115,115,104],new Uint8Array([i,0,0,0]),s,o,n,l,e||new Uint8Array)}function oy(s){if(!(s instanceof ArrayBuffer)||s.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},e=new DataView(s),i=e.getUint32(0);if(s.byteLength!==i&&i>44||e.getUint32(4)!==1886614376||(t.version=e.getUint32(8)>>>24,t.version>1))return null;t.systemId=Ur.hexDump(new Uint8Array(s,12,16));const n=e.getUint32(28);if(t.version===0){if(i-32<n)return null;t.data=new Uint8Array(s,32,n)}else if(t.version===1){t.kids=[];for(let o=0;o<n;o++)t.kids.push(new Uint8Array(s,32+o*16,16))}return t}let Oo={};class La{static clearKeyUriToKeyIdMap(){Oo={}}constructor(t,e,i,n=[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=n,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 Yi.FAIRPLAY:case Yi.WIDEVINE:case Yi.PLAYREADY:case Yi.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&&X.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const i=ly(t);return new La(this.method,this.uri,"identity",this.keyFormatVersions,i)}const e=Mv(this.uri);if(e)switch(this.keyFormat){case Yi.WIDEVINE:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case Yi.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=ay(i,null,e);const n=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),o=String.fromCharCode.apply(null,Array.from(n)),l=o.substring(o.indexOf("<"),o.length),d=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("KID")[0];if(d){const f=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(f){const p=vc(f).subarray(0,16);Ov(p),this.keyId=p}}break}default:{let i=e.subarray(0,16);if(i.length!==16){const n=new Uint8Array(16);n.set(i,16-i.length),i=n}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=Oo[this.uri];if(!i){const n=Object.keys(Oo).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,n),Oo[this.uri]=i}this.keyId=i}return this}}function ly(s){const t=new Uint8Array(16);for(let e=12;e<16;e++)t[e]=s>>8*(15-e)&255;return t}const k0=/\{\$([a-zA-Z0-9-_]+)\}/g;function w0(s){return k0.test(s)}function Xi(s,t,e){if(s.variableList!==null||s.hasVariableRefs)for(let i=e.length;i--;){const n=e[i],o=t[n];o&&(t[n]=Tc(s,o))}}function Tc(s,t){if(s.variableList!==null||s.hasVariableRefs){const e=s.variableList;return t.replace(k0,i=>{const n=i.substring(2,i.length-1),o=e==null?void 0:e[n];return o===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),i):o})}return t}function S0(s,t,e){let i=s.variableList;i||(s.variableList=i={});let n,o;if("QUERYPARAM"in t){n=t.QUERYPARAM;try{const l=new self.URL(e).searchParams;if(l.has(n))o=l.get(n);else throw new Error(`"${n}" does not match any query parameter in URI: "${e}"`)}catch(l){s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${l.message}`))}}else n=t.NAME,o=t.VALUE;n in i?s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):i[n]=o||""}function cy(s,t,e){const i=t.IMPORT;if(e&&i in e){let n=s.variableList;n||(s.variableList=n={}),n[i]=e[i]}else s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function Mo(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const hy={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}},R0=Mo();function dy(s,t){const e=hy[t];return!!e&&e[s.slice(0,4)]===!0}function kc(s,t){var e;return(e=R0==null?void 0:R0.isTypeSupported(`${t||"video"}/mp4;codecs="${s}"`))!=null?e:!1}const _0=/#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,L0=/#EXT-X-MEDIA:(.*)/g,uy=/^#EXT(?:INF|-X-TARGETDURATION):/m,C0=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),fy=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 wr{static findGroup(t,e){for(let i=0;i<t.length;i++){const n=t[i];if(n.id===e)return n}}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 pc.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return uy.test(t)}static parseMasterPlaylist(t,e){const i=w0(t),n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},o=[];_0.lastIndex=0;let l;for(;(l=_0.exec(t))!=null;)if(l[1]){var d;const p=new ti(l[1]);Xi(n,p,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const g=Tc(n,l[2]),v={attrs:p,bitrate:p.decimalInteger("AVERAGE-BANDWIDTH")||p.decimalInteger("BANDWIDTH"),name:p.NAME,url:wr.resolve(g,e)},A=p.decimalResolution("RESOLUTION");A&&(v.width=A.width,v.height=A.height),py((p.CODECS||"").split(/[ ,]+/).filter(E=>E),v),v.videoCodec&&v.videoCodec.indexOf("avc1")!==-1&&(v.videoCodec=wr.convertAVC1ToAVCOTI(v.videoCodec)),(d=v.unknownCodecs)!=null&&d.length||o.push(v),n.levels.push(v)}else if(l[3]){const p=l[3],g=l[4];switch(p){case"SESSION-DATA":{const v=new ti(g);Xi(n,v,["DATA-ID","LANGUAGE","VALUE","URI"]);const A=v["DATA-ID"];A&&(n.sessionData===null&&(n.sessionData={}),n.sessionData[A]=v);break}case"SESSION-KEY":{const v=I0(g,e,n);v.encrypted&&v.isSupported()?(n.sessionKeys===null&&(n.sessionKeys=[]),n.sessionKeys.push(v)):X.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${g}"`);break}case"DEFINE":{{const v=new ti(g);Xi(n,v,["NAME","VALUE","QUERYPARAM"]),S0(n,v,e)}break}case"CONTENT-STEERING":{const v=new ti(g);Xi(n,v,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:wr.resolve(v["SERVER-URI"],e),pathwayId:v["PATHWAY-ID"]||"."};break}case"START":{n.startTimeOffset=D0(g);break}}}const f=o.length>0&&o.length<n.levels.length;return n.levels=f?o:n.levels,n.levels.length===0&&(n.playlistParsingError=new Error("no levels found in manifest")),n}static parseMasterPlaylistMedia(t,e,i){let n;const o={},l=i.levels,d={AUDIO:l.map(p=>({id:p.attrs.AUDIO,audioCodec:p.audioCodec})),SUBTITLES:l.map(p=>({id:p.attrs.SUBTITLES,textCodec:p.textCodec})),"CLOSED-CAPTIONS":[]};let f=0;for(L0.lastIndex=0;(n=L0.exec(t))!==null;){const p=new ti(n[1]),g=p.TYPE;if(g){const v=d[g],A=o[g]||[];o[g]=A,Xi(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?wr.resolve(p.URI,e):""};if(v!=null&&v.length){const T=wr.findGroup(v,E.groupId)||v[0];x0(E,T,"audioCodec"),x0(E,T,"textCodec")}A.push(E)}}return o}static parseLevelPlaylist(t,e,i,n,o,l){const d=new xv(e),f=d.fragments;let p=null,g=0,v=0,A=0,E=0,T=null,w=new mc(n,e),C,x,O,U=-1,D=!1;for(C0.lastIndex=0,d.m3u8=t,d.hasVariableRefs=w0(t);(C=C0.exec(t))!==null;){D&&(D=!1,w=new mc(n,e),w.start=A,w.sn=g,w.cc=E,w.level=i,p&&(w.initSegment=p,w.rawProgramDateTime=p.rawProgramDateTime,p.rawProgramDateTime=null));const tt=C[1];if(tt){w.duration=parseFloat(tt);const at=(" "+C[2]).slice(1);w.title=at||null,w.tagList.push(at?["INF",tt,at]:["INF",tt])}else if(C[3]){if(Wt(w.duration)){w.start=A,O&&M0(w,O,d),w.sn=g,w.level=i,w.cc=E,w.urlId=o,f.push(w);const at=(" "+C[3]).slice(1);w.relurl=Tc(d,at),P0(w,T),T=w,A+=w.duration,g++,v=0,D=!0}}else if(C[4]){const at=(" "+C[4]).slice(1);T?w.setByteRange(at,T):w.setByteRange(at)}else if(C[5])w.rawProgramDateTime=(" "+C[5]).slice(1),w.tagList.push(["PROGRAM-DATE-TIME",w.rawProgramDateTime]),U===-1&&(U=f.length);else{if(C=C[0].match(fy),!C){X.warn("No matches on slow regex match for level playlist!");continue}for(x=1;x<C.length&&!(typeof C[x]<"u");x++);const at=(" "+C[x]).slice(1),J=(" "+C[x+1]).slice(1),St=C[x+2]?(" "+C[x+2]).slice(1):"";switch(at){case"PLAYLIST-TYPE":d.type=J.toUpperCase();break;case"MEDIA-SEQUENCE":g=d.startSN=parseInt(J);break;case"SKIP":{const mt=new ti(J);Xi(d,mt,["RECENTLY-REMOVED-DATERANGES"]);const Ot=mt.decimalInteger("SKIPPED-SEGMENTS");if(Wt(Ot)){d.skippedSegments=Ot;for(let G=Ot;G--;)f.unshift(null);g+=Ot}const Vt=mt.enumeratedString("RECENTLY-REMOVED-DATERANGES");Vt&&(d.recentlyRemovedDateranges=Vt.split(" "));break}case"TARGETDURATION":d.targetduration=Math.max(parseInt(J),1);break;case"VERSION":d.version=parseInt(J);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(J||St)&&w.tagList.push(St?[J,St]:[J]);break;case"DISCONTINUITY":E++,w.tagList.push(["DIS"]);break;case"GAP":w.gap=!0,w.tagList.push([at]);break;case"BITRATE":w.tagList.push([at,J]);break;case"DATERANGE":{const mt=new ti(J);Xi(d,mt,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Xi(d,mt,mt.clientAttrs);const Ot=new n0(mt,d.dateRanges[mt.ID]);Ot.isValid||d.skippedSegments?d.dateRanges[Ot.id]=Ot:X.warn(`Ignoring invalid DATERANGE tag: "${J}"`),w.tagList.push(["EXT-X-DATERANGE",J]);break}case"DEFINE":{{const mt=new ti(J);Xi(d,mt,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in mt?cy(d,mt,l):S0(d,mt,e)}break}case"DISCONTINUITY-SEQUENCE":E=parseInt(J);break;case"KEY":{const mt=I0(J,e,d);if(mt.isSupported()){if(mt.method==="NONE"){O=void 0;break}O||(O={}),O[mt.keyFormat]&&(O=ui({},O)),O[mt.keyFormat]=mt}else X.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${J}"`);break}case"START":d.startTimeOffset=D0(J);break;case"MAP":{const mt=new ti(J);if(Xi(d,mt,["BYTERANGE","URI"]),w.duration){const Ot=new mc(n,e);O0(Ot,mt,i,O),p=Ot,w.initSegment=p,p.rawProgramDateTime&&!w.rawProgramDateTime&&(w.rawProgramDateTime=p.rawProgramDateTime)}else O0(w,mt,i,O),p=w,D=!0;break}case"SERVER-CONTROL":{const mt=new ti(J);d.canBlockReload=mt.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=mt.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&mt.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=mt.optionalFloat("PART-HOLD-BACK",0),d.holdBack=mt.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const mt=new ti(J);d.partTarget=mt.decimalFloatingPoint("PART-TARGET");break}case"PART":{let mt=d.partList;mt||(mt=d.partList=[]);const Ot=v>0?mt[mt.length-1]:void 0,Vt=v++,G=new ti(J);Xi(d,G,["BYTERANGE","URI"]);const q=new Iv(G,w,e,Vt,Ot);mt.push(q),w.duration+=q.duration;break}case"PRELOAD-HINT":{const mt=new ti(J);Xi(d,mt,["URI"]),d.preloadHint=mt;break}case"RENDITION-REPORT":{const mt=new ti(J);Xi(d,mt,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(mt);break}default:X.warn(`line parsed but not handled: ${C}`);break}}}T&&!T.relurl?(f.pop(),A-=T.duration,d.partList&&(d.fragmentHint=T)):d.partList&&(P0(w,T),w.cc=E,d.fragmentHint=w,O&&M0(w,O,d));const H=f.length,$=f[0],z=f[H-1];if(A+=d.skippedSegments*d.targetduration,A>0&&H&&z){d.averagetargetduration=A/H;const tt=z.sn;d.endSN=tt!=="initSegment"?tt:0,d.live||(z.endList=!0),$&&(d.startCC=$.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(A+=d.fragmentHint.duration),d.totalduration=A,d.endCC=E,U>0&&gy(f,U),d}}function I0(s,t,e){var i,n;const o=new ti(s);Xi(e,o,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const l=(i=o.METHOD)!=null?i:"",d=o.URI,f=o.hexadecimalInteger("IV"),p=o.KEYFORMATVERSIONS,g=(n=o.KEYFORMAT)!=null?n:"identity";d&&o.IV&&!f&&X.error(`Invalid IV: ${o.IV}`);const v=d?wr.resolve(d,t):"",A=(p||"1").split("/").map(Number).filter(Number.isFinite);return new La(l,v,g,A,f)}function D0(s){const t=new ti(s).decimalFloatingPoint("TIME-OFFSET");return Wt(t)?t:null}function py(s,t){["video","audio","text"].forEach(e=>{const i=s.filter(n=>dy(n,e));if(i.length){const n=i.filter(o=>o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0);t[`${e}Codec`]=n.length>0?n[0]:i[0],s=s.filter(o=>i.indexOf(o)===-1)}}),t.unknownCodecs=s}function x0(s,t,e){const i=t[e];i&&(s[e]=i)}function gy(s,t){let e=s[t];for(let i=t;i--;){const n=s[i];if(!n)return;n.programDateTime=e.programDateTime-n.duration*1e3,e=n}}function P0(s,t){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):t!=null&&t.programDateTime&&(s.programDateTime=t.endProgramDateTime),Wt(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function O0(s,t,e,i){s.relurl=t.URI,t.BYTERANGE&&s.setByteRange(t.BYTERANGE),s.level=e,s.sn="initSegment",i&&(s.levelkeys=i),s.initSegment=null}function M0(s,t,e){s.levelkeys=t;const{encryptedFragments:i}=e;(!i.length||i[i.length-1].levelkeys!==t)&&Object.keys(t).some(n=>t[n].isCommonEncryption)&&i.push(s)}var ke={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Jt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function $0(s){const{type:t}=s;switch(t){case ke.AUDIO_TRACK:return Jt.AUDIO;case ke.SUBTITLE_TRACK:return Jt.SUBTITLE;default:return Jt.MAIN}}function wc(s,t){let e=s.url;return(e===void 0||e.indexOf("data:")===0)&&(e=t.url),e}class my{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,n=e.loader,o=i||n,l=new o(e);return this.loaders[t.type]=l,l}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:ke.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(t,e){const{id:i,level:n,url:o,deliveryDirectives:l}=e;this.load({id:i,level:n,responseType:"text",type:ke.LEVEL,url:o,deliveryDirectives:l})}onAudioTrackLoading(t,e){const{id:i,groupId:n,url:o,deliveryDirectives:l}=e;this.load({id:i,groupId:n,level:null,responseType:"text",type:ke.AUDIO_TRACK,url:o,deliveryDirectives:l})}onSubtitleTrackLoading(t,e){const{id:i,groupId:n,url:o,deliveryDirectives:l}=e;this.load({id:i,groupId:n,level:null,responseType:"text",type:ke.SUBTITLE_TRACK,url:o,deliveryDirectives:l})}load(t){var e;const i=this.hls.config;let n=this.getInternalLoader(t);if(n){const p=n.context;if(p&&p.url===t.url){X.trace("[playlist-loader]: playlist request ongoing");return}X.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),n.abort()}let o;if(t.type===ke.MANIFEST?o=i.manifestLoadPolicy.default:o=ui({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(t),(e=t.deliveryDirectives)!=null&&e.part){let p;if(t.type===ke.LEVEL&&t.level!==null?p=this.hls.levels[t.level].details:t.type===ke.AUDIO_TRACK&&t.id!==null?p=this.hls.audioTracks[t.id].details:t.type===ke.SUBTITLE_TRACK&&t.id!==null&&(p=this.hls.subtitleTracks[t.id].details),p){const g=p.partTarget,v=p.targetduration;if(g&&v){const A=Math.max(g*3,v*.8)*1e3;o=ui({},o,{maxTimeToFirstByteMs:Math.min(A,o.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(A,o.maxTimeToFirstByteMs)})}}}const l=o.errorRetry||o.timeoutRetry||{},d={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},f={onSuccess:(p,g,v,A)=>{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"),A||null,g);return}g.parsing.start=performance.now(),wr.isMediaPlaylist(T)?this.handleTrackOrLevelPlaylist(p,g,v,A||null,E):this.handleMasterPlaylist(p,g,v,A)},onError:(p,g,v,A)=>{this.handleNetworkError(g,v,!1,p,A)},onTimeout:(p,g,v)=>{this.handleNetworkError(g,v,!0,void 0,p)}};n.load(t,d,f)}handleMasterPlaylist(t,e,i,n){const o=this.hls,l=t.data,d=wc(t,i),f=wr.parseMasterPlaylist(l,d);if(f.playlistParsingError){this.handleManifestParsingError(t,i,f.playlistParsingError,n,e);return}const{contentSteering:p,levels:g,sessionData:v,sessionKeys:A,startTimeOffset:E,variableList:T}=f;this.variableList=T;const{AUDIO:w=[],SUBTITLES:C,"CLOSED-CAPTIONS":x}=wr.parseMasterPlaylistMedia(l,d,f);w.length&&!w.some(O=>!O.url)&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(X.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 ti({}),bitrate:0,url:""})),o.trigger(R.MANIFEST_LOADED,{levels:g,audioTracks:w,subtitles:C,captions:x,contentSteering:p,url:d,stats:e,networkDetails:n,sessionData:v,sessionKeys:A,startTimeOffset:E,variableList:T})}handleTrackOrLevelPlaylist(t,e,i,n,o){const l=this.hls,{id:d,level:f,type:p}=i,g=wc(t,i),v=Wt(d)?d:0,A=Wt(f)?f:v,E=$0(i),T=wr.parseLevelPlaylist(t.data,g,A,E,v,this.variableList);if(p===ke.MANIFEST){const w={attrs:new ti({}),bitrate:0,details:T,name:"",url:g};l.trigger(R.MANIFEST_LOADED,{levels:[w],audioTracks:[],url:g,stats:e,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),i.levelDetails=T,this.handlePlaylistLoaded(T,t,e,i,n,o)}handleManifestParsingError(t,e,i,n,o){this.hls.trigger(R.ERROR,{type:Qt.NETWORK_ERROR,details:pt.MANIFEST_PARSING_ERROR,fatal:e.type===ke.MANIFEST,url:t.url,err:i,error:i,reason:i.message,response:t,context:e,networkDetails:n,stats:o})}handleNetworkError(t,e,i=!1,n,o){let l=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${t.type}`;t.type===ke.LEVEL?l+=`: ${t.level} id: ${t.id}`:(t.type===ke.AUDIO_TRACK||t.type===ke.SUBTITLE_TRACK)&&(l+=` id: ${t.id} group-id: "${t.groupId}"`);const d=new Error(l);X.warn(`[playlist-loader]: ${l}`);let f=pt.UNKNOWN,p=!1;const g=this.getInternalLoader(t);switch(t.type){case ke.MANIFEST:f=i?pt.MANIFEST_LOAD_TIMEOUT:pt.MANIFEST_LOAD_ERROR,p=!0;break;case ke.LEVEL:f=i?pt.LEVEL_LOAD_TIMEOUT:pt.LEVEL_LOAD_ERROR,p=!1;break;case ke.AUDIO_TRACK:f=i?pt.AUDIO_TRACK_LOAD_TIMEOUT:pt.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case ke.SUBTITLE_TRACK:f=i?pt.SUBTITLE_TRACK_LOAD_TIMEOUT:pt.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(n){const A=(e==null?void 0:e.url)||t.url;v.response=zi({url:A,data:void 0},n)}this.hls.trigger(R.ERROR,v)}handlePlaylistLoaded(t,e,i,n,o,l){const d=this.hls,{type:f,level:p,id:g,groupId:v,deliveryDirectives:A}=n,E=wc(e,n),T=$0(n),w=typeof n.level=="number"&&T===Jt.MAIN?p:void 0;if(!t.fragments.length){const x=new Error("No Segments found in Playlist");d.trigger(R.ERROR,{type:Qt.NETWORK_ERROR,details:pt.LEVEL_EMPTY_ERROR,fatal:!1,url:E,error:x,reason:x.message,response:e,context:n,level:w,parent:T,networkDetails:o,stats:i});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const C=t.playlistParsingError;if(C){d.trigger(R.ERROR,{type:Qt.NETWORK_ERROR,details:pt.LEVEL_PARSING_ERROR,fatal:!1,url:E,error:C,reason:C.message,response:e,context:n,level:w,parent:T,networkDetails:o,stats:i});return}switch(t.live&&l&&(l.getCacheAge&&(t.ageHeader=l.getCacheAge()||0),(!l.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),f){case ke.MANIFEST:case ke.LEVEL:d.trigger(R.LEVEL_LOADED,{details:t,level:w||0,id:g||0,stats:i,networkDetails:o,deliveryDirectives:A});break;case ke.AUDIO_TRACK:d.trigger(R.AUDIO_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:A});break;case ke.SUBTITLE_TRACK:d.trigger(R.SUBTITLE_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:A});break}}}function F0(s,t){let e;try{e=new Event("addtrack")}catch{e=document.createEvent("Event"),e.initEvent("addtrack",!1,!1)}e.track=s,t.dispatchEvent(e)}function N0(s,t){const e=s.mode;if(e==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(t.id))try{if(s.addCue(t),!s.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){X.debug(`[texttrack-utils]: ${i}`);try{const n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,s.addCue(n)}catch(n){X.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${n}`)}}e==="disabled"&&(s.mode=e)}function Cn(s){const t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues)for(let e=s.cues.length;e--;)s.removeCue(s.cues[e]);t==="disabled"&&(s.mode=t)}function Sc(s,t,e,i){const n=s.mode;if(n==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){const o=yy(s.cues,t,e);for(let l=0;l<o.length;l++)(!i||i(o[l]))&&s.removeCue(o[l])}n==="disabled"&&(s.mode=n)}function vy(s,t){if(t<s[0].startTime)return 0;const e=s.length-1;if(t>s[e].endTime)return-1;let i=0,n=e;for(;i<=n;){const o=Math.floor((n+i)/2);if(t<s[o].startTime)n=o-1;else if(t>s[o].startTime&&i<e)i=o+1;else return o}return s[i].startTime-t<t-s[n].startTime?i:n}function yy(s,t,e){const i=[],n=vy(s,t);if(n>-1)for(let o=n,l=s.length;o<l;o++){const d=s[o];if(d.startTime>=t&&d.endTime<=e)i.push(d);else if(d.startTime>e)return i}return i}var Sr={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const by=.25;function Rc(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const $o=(()=>{const s=Rc();try{new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function _c(s,t){return s.getTime()/1e3-t}function Ay(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class Ey{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&&(Cn(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 F0(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:n}}}=this;if(!i&&!n)return;const{samples:o}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=Rc();for(let d=0;d<o.length;d++){const f=o[d].type;if(f===Sr.emsg&&!i||!n)continue;const p=p0(o[d].data);if(p){const g=o[d].pts;let v=g+o[d].duration;v>$o&&(v=$o),v-g<=0&&(v=g+by);for(let A=0;A<p.length;A++){const E=p[A];if(!f0(E)){this.updateId3CueEnds(g,f);const T=new l(g,v,"");T.value=E,f&&(T.type=f),this.id3Track.addCue(T)}}}}}updateId3CueEnds(t,e){var i;const n=(i=this.id3Track)==null?void 0:i.cues;if(n)for(let o=n.length;o--;){const l=n[o];l.type===e&&l.startTime<t&&l.endTime===$o&&(l.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:i,type:n}){const{id3Track:o,hls:l}=this;if(!l)return;const{config:{enableEmsgMetadataCues:d,enableID3MetadataCues:f}}=l;if(o&&(d||f)){let p;n==="audio"?p=g=>g.type===Sr.audioId3&&f:n==="video"?p=g=>g.type===Sr.emsg&&d:p=g=>g.type===Sr.audioId3&&f||g.type===Sr.emsg&&d,Sc(o,e,i,p)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:n}=this,{dateRanges:o}=e,l=Object.keys(o);if(n){const g=Object.keys(i).filter(v=>!l.includes(v));for(let v=g.length;v--;){const A=g[v];Object.keys(i[A].cues).forEach(E=>{n.removeCue(i[A].cues[E])}),delete i[A]}}const d=e.fragments[e.fragments.length-1];if(l.length===0||!Wt(d==null?void 0:d.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const f=d.programDateTime/1e3-d.start,p=Rc();for(let g=0;g<l.length;g++){const v=l[g],A=o[v],E=i[v],T=(E==null?void 0:E.cues)||{};let w=(E==null?void 0:E.durationKnown)||!1;const C=_c(A.startDate,f);let x=$o;const O=A.endDate;if(O)x=_c(O,f),w=!0;else if(A.endOnNext&&!w){const D=l.reduce((H,$)=>{const z=o[$];return z.class===A.class&&z.id!==$&&z.startDate>A.startDate&&H.push(z),H},[]).sort((H,$)=>H.startDate.getTime()-$.startDate.getTime())[0];D&&(x=_c(D.startDate,f),w=!0)}const U=Object.keys(A.attr);for(let D=0;D<U.length;D++){const H=U[D];if(!Lv(H))continue;let $=T[H];if($)w&&!E.durationKnown&&($.endTime=x);else{let z=A.attr[H];$=new p(C,x,""),Cv(H)&&(z=Ay(z)),$.value={key:H,data:z},$.type=Sr.dateRange,$.id=v,this.id3Track.addCue($),T[H]=$}}i[v]={cues:T,dateRange:A,durationKnown:w}}}}class Ty{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:n}=t,{liveSyncDuration:o,liveSyncDurationCount:l,lowLatencyMode:d}=this.config,f=this.hls.userConfig;let p=d&&i||e;(f.liveSyncDuration||f.liveSyncDurationCount||p===0)&&(p=o!==void 0?o:l*n);const g=n,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 n=i.edge,o=t-e-this.edgeStalled,l=n-i.totalduration,d=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(l,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===pt.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&X.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:n,maxLiveSyncPlaybackRate:o}=this.config;if(!n||o===1)return;const l=this.targetLatency;if(l===null)return;const d=i-l,f=Math.min(this.maxLatency,l+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 Lc=["NONE","TYPE-0","TYPE-1",null];var Ca={No:"",Yes:"YES",v2:"v2"};function ky(s,t){const{canSkipUntil:e,canSkipDateRanges:i,endSN:n}=s,o=t!==void 0?t-n:0;return e&&o<e?i?Ca.v2:Ca.Yes:Ca.No}class U0{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 Ia{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 Cc(s,t){const e=t.startPTS;if(Wt(e)){let i=0,n;t.sn>s.sn?(i=e-s.start,n=s):(i=s.start-e,n=t),n.duration!==i&&(n.duration=i)}else t.sn>s.sn?s.cc===t.cc&&s.minEndPTS?t.start=s.start+(s.minEndPTS-s.start):t.start=s.start+s.duration:t.start=Math.max(s.start-t.duration,0)}function B0(s,t,e,i,n,o){i-e<=0&&(X.warn("Fragment should have a positive duration",t),i=e+t.duration,o=n+t.duration);let l=e,d=i;const f=t.startPTS,p=t.endPTS;if(Wt(f)){const w=Math.abs(f-e);Wt(t.deltaPTS)?t.deltaPTS=Math.max(w,t.deltaPTS):t.deltaPTS=w,l=Math.max(e,f),e=Math.min(e,f),n=Math.min(n,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=l,t.startDTS=n,t.endPTS=i,t.minEndPTS=d,t.endDTS=o;const v=t.sn;if(!s||v<s.startSN||v>s.endSN)return 0;let A;const E=v-s.startSN,T=s.fragments;for(T[E]=t,A=E;A>0;A--)Cc(T[A],T[A-1]);for(A=E;A<T.length-1;A++)Cc(T[A],T[A+1]);return s.fragmentHint&&Cc(T[T.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,g}function wy(s,t){let e=null;const i=s.fragments;for(let f=i.length-1;f>=0;f--){const p=i[f].initSegment;if(p){e=p;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let n=0,o;if(_y(s,t,(f,p)=>{f.relurl&&(n=f.cc-p.cc),Wt(f.startPTS)&&Wt(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){X.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=Sy(s.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const l=t.fragments;if(n){X.warn("discontinuity sliding from playlist, take drift into account");for(let f=0;f<l.length;f++)l[f].cc+=n}t.skippedSegments&&(t.startCC=t.fragments[0].cc),Ry(s.partList,t.partList,(f,p)=>{p.elementaryStreams=f.elementaryStreams,p.stats=f.stats}),o?B0(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):G0(s,t),l.length&&(t.totalduration=t.edge-l[0].start),t.driftStartTime=s.driftStartTime,t.driftStart=s.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=s.driftEndTime,t.driftEnd=s.driftEnd,t.advancedDateTime=s.advancedDateTime}function Sy(s,t,e){const i=ui({},s);return e&&e.forEach(n=>{delete i[n]}),Object.keys(t).forEach(n=>{const o=new n0(t[n].attr,i[n]);o.isValid?i[n]=o:X.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[n].attr)}"`)}),i}function Ry(s,t,e){if(s&&t){let i=0;for(let n=0,o=s.length;n<=o;n++){const l=s[n],d=t[n+i];l&&d&&l.index===d.index&&l.fragment.sn===d.fragment.sn?e(l,d):i--}}}function _y(s,t,e){const i=t.skippedSegments,n=Math.max(s.startSN,t.startSN)-t.startSN,o=(s.fragmentHint?1:0)+(i?t.endSN:Math.min(s.endSN,t.endSN))-t.startSN,l=t.startSN-s.startSN,d=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,f=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments;for(let p=n;p<=o;p++){const g=f[l+p];let v=d[p];i&&!v&&p<i&&(v=t.fragments[p]=g),g&&v&&e(g,v)}}function G0(s,t){const e=t.startSN+t.skippedSegments-s.startSN,i=s.fragments;e<0||e>=i.length||Ic(t,i[e].start)}function Ic(s,t){if(t){const e=s.fragments;for(let i=s.skippedSegments;i<e.length;i++)e[i].start+=t;s.fragmentHint&&(s.fragmentHint.start+=t)}}function Ly(s,t=1/0){let e=1e3*s.targetduration;if(s.updated){const i=s.fragments,n=4;if(i.length&&e*n>t){const o=i[i.length-1].duration*1e3;o<e&&(e=o)}}else e/=2;return Math.round(e)}function Cy(s,t,e){if(!(s!=null&&s.details))return null;const i=s.details;let n=i.fragments[t-i.startSN];return n||(n=i.fragmentHint,n&&n.sn===t)?n:t<i.startSN&&e&&e.sn===t?e:null}function V0(s,t,e){var i;return s!=null&&s.details?H0((i=s.details)==null?void 0:i.partList,t,e):null}function H0(s,t,e){if(s)for(let i=s.length;i--;){const n=s[i];if(n.index===e&&n.fragment.sn===t)return n}return null}function Fo(s){switch(s.details){case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_TIMEOUT:case pt.LEVEL_LOAD_TIMEOUT:case pt.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function W0(s,t){const e=Fo(t);return s.default[`${e?"timeout":"error"}Retry`]}function Dc(s,t){const e=s.backoff==="linear"?1:Math.pow(2,t);return Math.min(e*s.retryDelayMs,s.maxRetryDelayMs)}function j0(s){return zi(zi({},s),{errorRetry:null,timeoutRetry:null})}function No(s,t,e,i){return!!s&&t<s.maxNumRetry&&(Iy(i)||!!e)}function Iy(s){return s===0&&navigator.onLine===!1||!!s&&(s<400||s>499)}const K0={search:function(s,t){let e=0,i=s.length-1,n=null,o=null;for(;e<=i;){n=(e+i)/2|0,o=s[n];const l=t(o);if(l>0)e=n+1;else if(l<0)i=n-1;else return o}return null}};function Dy(s,t,e){if(t===null||!Array.isArray(s)||!s.length||!Wt(t))return null;const i=s[0].programDateTime;if(t<(i||0))return null;const n=s[s.length-1].endProgramDateTime;if(t>=(n||0))return null;e=e||0;for(let o=0;o<s.length;++o){const l=s[o];if(xy(t,e,l))return l}return null}function Da(s,t,e=0,i=0){let n=null;if(s?n=t[s.sn-t[0].sn+1]||null:e===0&&t[0].start===0&&(n=t[0]),n&&xc(e,i,n)===0)return n;const o=K0.search(t,xc.bind(null,e,i));return o&&(o!==s||!n)?o:n}function xc(s=0,t=0,e){if(e.start<=s&&e.start+e.duration>s)return 0;const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-i<=s?1:e.start-i>s&&e.start?-1:0}function xy(s,t,e){const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0))*1e3;return(e.endProgramDateTime||0)-i>s}function Py(s,t){return K0.search(s,e=>e.cc<t?1:e.cc>t?-1:0)}const Oy=3e5;var Di={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},fr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class My{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=X.log.bind(X,"[info]:"),this.warn=X.warn.bind(X,"[warning]:"),this.error=X.error.bind(X,"[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,n;if(e.fatal)return;const o=this.hls,l=e.context;switch(e.details){case pt.FRAG_LOAD_ERROR:case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_ERROR:case pt.KEY_LOAD_TIMEOUT:e.errorAction=this.getFragRetryOrSwitchAction(e);return;case pt.FRAG_PARSING_ERROR:if((i=e.frag)!=null&&i.gap){e.errorAction={action:Di.DoNothing,flags:fr.None};return}case pt.FRAG_GAP:case pt.FRAG_DECRYPT_ERROR:{e.errorAction=this.getFragRetryOrSwitchAction(e),e.errorAction.action=Di.SendAlternateToPenaltyBox;return}case pt.LEVEL_EMPTY_ERROR:case pt.LEVEL_PARSING_ERROR:{var d,f;const p=e.parent===Jt.MAIN?e.level:o.loadLevel;e.details===pt.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 pt.LEVEL_LOAD_ERROR:case pt.LEVEL_LOAD_TIMEOUT:typeof(l==null?void 0:l.level)=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,l.level));return;case pt.AUDIO_TRACK_LOAD_ERROR:case pt.AUDIO_TRACK_LOAD_TIMEOUT:case pt.SUBTITLE_LOAD_ERROR:case pt.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){const p=o.levels[o.loadLevel];if(p&&(l.type===ke.AUDIO_TRACK&&l.groupId===p.audioGroupId||l.type===ke.SUBTITLE_TRACK&&l.groupId===p.textGroupId)){e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o.loadLevel),e.errorAction.action=Di.SendAlternateToPenaltyBox,e.errorAction.flags=fr.MoveAllAlternatesMatchingHost;return}}return;case pt.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const p=o.levels[o.loadLevel],g=p==null?void 0:p.attrs["HDCP-LEVEL"];g&&(e.errorAction={action:Di.SendAlternateToPenaltyBox,flags:fr.MoveAllAlternatesMatchingHDCP,hdcpLevel:g})}return;case pt.BUFFER_ADD_CODEC_ERROR:case pt.REMUX_ALLOC_ERROR:e.errorAction=this.getLevelSwitchAction(e,(n=e.level)!=null?n:o.loadLevel);return;case pt.INTERNAL_EXCEPTION:case pt.BUFFER_APPENDING_ERROR:case pt.BUFFER_APPEND_ERROR:case pt.BUFFER_FULL_ERROR:case pt.LEVEL_SWITCH_ERROR:case pt.BUFFER_STALLED_ERROR:case pt.BUFFER_SEEK_OVER_HOLE:case pt.BUFFER_NUDGE_ON_STALL:e.errorAction={action:Di.DoNothing,flags:fr.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 n=this.hls,o=W0(n.config.playlistLoadPolicy,t),l=this.playlistError++,d=(i=t.response)==null?void 0:i.code;if(No(o,l,Fo(t),d))return{action:Di.RetryRequest,flags:fr.None,retryConfig:o,retryCount:l};const f=this.getLevelSwitchAction(t,e);return o&&(f.retryConfig=o,f.retryCount=l),f}getFragRetryOrSwitchAction(t){const e=this.hls,i=this.getVariantLevelIndex(t.frag),n=e.levels[i],{fragLoadPolicy:o,keyLoadPolicy:l}=e.config,d=W0(t.details.startsWith("key")?l:o,t),f=e.levels.reduce((v,A)=>v+A.fragmentError,0);if(n){var p;t.details!==pt.FRAG_GAP&&n.fragmentError++;const v=(p=t.response)==null?void 0:p.code;if(No(d,f,Fo(t),v))return{action:Di.RetryRequest,flags:fr.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 n=this.hls.levels[e];if(n&&(n.loadError++,i.autoLevelEnabled)){var o,l;let d=-1;const{levels:f,loadLevel:p,minAutoLevel:g,maxAutoLevel:v}=i,A=(o=t.frag)==null?void 0:o.type,{type:E,groupId:T}=(l=t.context)!=null?l:{};for(let w=f.length;w--;){const C=(w+p)%f.length;if(C!==p&&C>=g&&C<=v&&f[C].loadError===0){const x=f[C];if(t.details===pt.FRAG_GAP&&t.frag){const O=f[C].details;if(O){const U=Da(t.frag,O.fragments,t.frag.start);if(U!=null&&U.gap)continue}}else if(E===ke.AUDIO_TRACK&&T===x.audioGroupId||E===ke.SUBTITLE_TRACK&&T===x.textGroupId||A===Jt.AUDIO&&n.audioGroupId===x.audioGroupId||A===Jt.SUBTITLE&&n.textGroupId===x.textGroupId)continue;d=C;break}}if(d>-1&&i.loadLevel!==d)return t.levelRetry=!0,this.playlistError=0,{action:Di.SendAlternateToPenaltyBox,flags:fr.None,nextAutoLevel:d}}return{action:Di.SendAlternateToPenaltyBox,flags:fr.MoveAllAlternatesMatchingHost}}onErrorOut(t,e){var i;switch((i=e.errorAction)==null?void 0:i.action){case Di.DoNothing:break;case Di.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),!e.errorAction.resolved&&e.details!==pt.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:n,hdcpLevel:o,nextAutoLevel:l}=i;switch(n){case fr.None:this.switchLevel(t,l);break;case fr.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(t));break;case fr.MoveAllAlternatesMatchingHDCP:o&&(e.maxHdcpLevel=Lc[Lc.indexOf(o)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(t,l)}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,n=t.parent===Jt.MAIN?t.level:e.loadLevel,o=e.levels[n],l=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<l;f++){const p=(d+f)%l,g=i[p];if(!g||$y(g,t,i[d]))return this.warn(`Switching to Redundant Stream ${p+1}/${l}: "${o.url[p]}" after ${t.details}`),this.playlistError=0,e.levels.forEach(v=>{v.urlId=p}),e.nextLoadLevel=n,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:i}=this,n=i[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};n.lastErrorPerfMs=performance.now(),n.errors.push(e),n.details=t.details,i[t.urlId]=n}}function $y(s,t,e){if(performance.now()-s.lastErrorPerfMs>Oy)return!0;const i=s.details;if(t.details===pt.FRAG_GAP&&i&&t.frag){const n=t.frag.start,o=Da(null,i.fragments,n);if(o&&!o.gap)return!0}if(e&&s.errors.length<e.errors.length){const n=s.errors[s.errors.length-1];if(i&&n.frag&&t.frag&&Math.abs(n.frag.start-t.frag.start)>i.targetduration*3)return!0}return!1}class Pc{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=X.log.bind(X,`${e}:`),this.warn=X.warn.bind(X,`${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 n=-1;for(let o=0;o<i.length;o++){const l=i[o];let d;try{d=new self.URL(l.URI,e.url).href}catch(f){X.warn(`Could not construct new URL for Rendition Report: ${f}`),d=l.URI||""}if(d===t){n=o;break}else d===t.substring(0,d.length)&&(n=o)}if(n!==-1){const o=i[n],l=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 U0(l,d>=0?d:void 0,Ca.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:n,stats:o}=e,l=self.performance.now(),d=o.loading.first?Math.max(0,l-o.loading.first):0;if(n.advancedDateTime=Date.now()-d,n.live||i!=null&&i.live){if(n.reloaded(i),i&&this.log(`live playlist ${t} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),i&&n.fragments.length>0&&wy(i,n),!this.canLoad||!n.live)return;let f,p,g;if(n.canBlockReload&&n.endSN&&n.advanced){const C=this.hls.config.lowLatencyMode,x=n.lastPartSn,O=n.endSN,U=n.lastPartIndex,D=U!==-1,H=x===O,$=C?0:U;D?(p=H?O+1:x,g=H?$:U+1):p=O+1;const z=n.age,tt=z+n.ageHeader;let at=Math.min(tt-n.partTarget,n.targetduration*1.5);if(at>0){if(i&&at>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${at} with playlist age: ${n.age}`),at=0;else{const J=Math.floor(at/n.targetduration);if(p+=J,g!==void 0){const St=Math.round(at%n.targetduration/n.partTarget);g+=St}this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${z.toFixed(2)}s goal: ${at} skip sn ${J} to part ${g}`)}n.tuneInGoal=at}if(f=this.getDeliveryDirectives(n,e.deliveryDirectives,p,g),C||!H){this.loadPlaylist(f);return}}else(n.canBlockReload||n.canSkipUntil)&&(f=this.getDeliveryDirectives(n,e.deliveryDirectives,p,g));const v=this.hls.mainForwardBufferInfo,A=v?v.end-v.len:0,E=(n.edge-A)*1e3,T=Ly(n,E);n.updated&&l>this.requestScheduled+T&&(this.requestScheduled=o.loading.start),p!==void 0&&n.canBlockReload?this.requestScheduled=o.loading.first+T-(n.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+T<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=T);let w=this.requestScheduled-l;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,n){let o=ky(t,i);return e!=null&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,n=e.part,o=Ca.No),new U0(i,n,o)}checkRetry(t){const e=t.details,i=Fo(t),n=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=n||{},f=!!n&&!!d&&(o===Di.RetryRequest||!n.resolved&&o===Di.SendAlternateToPenaltyBox);if(f){var p;if(this.requestScheduled=-1,l>=d.maxNumRetry)return!1;if(i&&(p=t.context)!=null&&p.deliveryDirectives)this.warn(`Retrying playlist loading ${l+1}/${d.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const g=Dc(d,l);this.timer=self.setTimeout(()=>this.loadPlaylist(),g),this.warn(`Retrying playlist loading ${l+1}/${d.maxNumRetry} after "${e}" in ${g}ms`)}t.levelRetry=!0,n.resolved=!0}return f}}let Oc;class Fy extends Pc{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=[],n={};let o;e.levels.forEach(l=>{var d;const f=l.attrs;((d=l.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(Oc||(Oc=/chrome|firefox/i.test(navigator.userAgent)),Oc&&(l.audioCodec=void 0));const{AUDIO:p,CODECS:g,"FRAME-RATE":v,"PATHWAY-ID":A,RESOLUTION:E,SUBTITLES:T}=f,w=`${`${A||"."}-`}${l.bitrate}-${E}-${v}-${g}`;o=n[w],o?o.addFallback(l):(o=new Ia(l),n[w]=o,i.push(o)),Uo(o,"audio",p),Uo(o,"text",T)}),this.filterAndSortMediaOptions(i,e)}filterAndSortMediaOptions(t,e){let i=[],n=[],o=!1,l=!1,d=!1,f=t.filter(({audioCodec:E,videoCodec:T,width:w,height:C,unknownCodecs:x})=>(o||(o=!!(w&&C)),l||(l=!!T),d||(d=!!E),!(x!=null&&x.length)&&(!E||kc(E,"audio"))&&(!T||kc(T,"video"))));if((o||l)&&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:pt.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:E,reason:E.message})}});return}e.audioTracks&&(i=e.audioTracks.filter(E=>!E.audioCodec||kc(E.audioCodec,"audio")),z0(i)),e.subtitles&&(n=e.subtitles,z0(n));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&&!l,A={levels:f,audioTracks:i,subtitleTracks:n,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:d,video:l,altAudio:!v&&i.some(E=>!!E.url)};this.hls.trigger(R.MANIFEST_PARSED,A),(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:pt.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,n=this.currentLevel,o=n?n.attrs["PATHWAY-ID"]:void 0,l=e[t],d=l.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=l,i===t&&l.details&&n&&o===d)return;this.log(`Switching to level ${t}${d?" with Pathway "+d:""} from level ${i}${o?" with Pathway "+o:""}`);const f=ui({},l,{level:t,maxBitrate:l.maxBitrate,attrs:l.attrs,uri:l.uri,urlId:l.urlId});delete f._attrs,delete f._urlId,this.hls.trigger(R.LEVEL_SWITCHING,f);const p=l.details;if(!p||p.live){const g=this.switchParams(l.uri,n==null?void 0:n.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===ke.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:n,details:o}=e,l=this._levels[n];if(!l){var d;this.warn(`Invalid level index ${n}`),(d=e.deliveryDirectives)!=null&&d.skip&&(o.deltaUpdateFailed=!0);return}n===this.currentLevelIndex?(l.fragmentError===0&&(l.loadError=0),this.playlistLoaded(n,e,l.details)):(i=e.deliveryDirectives)!=null&&i.skip&&(o.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const i=this.currentLevel;if(!i)return;const n=this.hls.audioTracks[e.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==n){let o=-1;for(let l=0;l<i.audioGroupIds.length;l++)if(i.audioGroupIds[l]===n){o=l;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 n=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 l=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${l?" Pathway "+l:""} URI ${n+1}/${i.url.length} ${o}`),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:o,level:e,id:n,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,l)=>l!==e,n=this._levels.filter((o,l)=>l!==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:n})}onLevelsUpdated(t,{levels:e}){e.forEach((i,n)=>{const{details:o}=i;o!=null&&o.fragments&&o.fragments.forEach(l=>{l.level=n})}),this._levels=e}}function Uo(s,t,e){e&&(t==="audio"?(s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds[s.url.length-1]=e):t==="text"&&(s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds[s.url.length-1]=e))}function z0(s){const t={};s.forEach(e=>{const i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}var yi={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Ny{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 n=i.length;n--;){const o=i[n];if(!o)break;const l=o.end;if(o.start<=t&&l!==null&&t<=l)return o}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:i}=this,n=Object.keys(i);for(let o=n.length;o--;){const l=i[n[o]];if((l==null?void 0:l.body.type)===e&&l.buffered){const d=l.body;if(d.start<=t&&t<=d.end)return d}}return null}detectEvictedFragments(t,e,i,n){this.timeRanges&&(this.timeRanges[t]=e);const o=(n==null?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach(l=>{const d=this.fragments[l];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:n}=t;if(!e||i.sn==="initSegment")return;const o=In(i),l=this.fragments[o];if(!l||l.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;l.range[f]=this.getBufferedTimes(i,n,v,g)}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,(l.body.endList=i.endList||l.body.endList)&&(this.endListFragments[l.body.type]=l),Bo(l)||this.removeParts(i.sn-1,i.type)):this.removeFragment(l.body)}removeParts(t,e){const i=this.activePartLists[e];i&&(this.activePartLists[e]=i.filter(n=>n.fragment.sn>=t))}fragBuffered(t,e){const i=In(t);let n=this.fragments[i];!n&&e&&(n=this.fragments[i]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,n.buffered=!0)}getBufferedTimes(t,e,i,n){const o={time:[],partial:i},l=t.start,d=t.end,f=t.minEndPTS||d,p=t.maxStartPTS||l;for(let g=0;g<n.length;g++){const v=n.start(g)-this.bufferPadding,A=n.end(g)+this.bufferPadding;if(p>=v&&f<=A){o.time.push({startPTS:Math.max(l,n.start(g)),endPTS:Math.min(d,n.end(g))});break}else if(l<A&&d>v)o.partial=!0,o.time.push({startPTS:Math.max(l,n.start(g)),endPTS:Math.min(d,n.end(g))});else if(d<=v)break}return o}getPartialFragment(t){let e=null,i,n,o,l=0;const{bufferPadding:d,fragments:f}=this;return Object.keys(f).forEach(p=>{const g=f[p];g&&Bo(g)&&(n=g.body.start-d,o=g.body.end+d,t>=n&&t<=o&&(i=Math.min(t-n,o-t),l<=i&&(e=g.body,l=i)))}),e}isEndListAppended(t){const e=this.endListFragments[t];return e!==void 0&&(e.buffered||Bo(e))}getState(t){const e=In(t),i=this.fragments[e];return i?i.buffered?Bo(i)?yi.PARTIAL:yi.OK:yi.APPENDING:yi.NOT_LOADED}isTimeBuffered(t,e,i){let n,o;for(let l=0;l<i.length;l++){if(n=i.start(l)-this.bufferPadding,o=i.end(l)+this.bufferPadding,t>=n&&e<=o)return!0;if(e<=n)return!1}return!1}onFragLoaded(t,e){const{frag:i,part:n}=e;if(i.sn==="initSegment"||i.bitrateTest)return;const o=n?null:e,l=In(i);this.fragments[l]={body:i,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:i,part:n,timeRanges:o}=e;if(i.sn==="initSegment")return;const l=i.type;if(n){let d=this.activePartLists[l];d||(this.activePartLists[l]=d=[]),d.push(n)}this.timeRanges=o,Object.keys(o).forEach(d=>{const f=o[d];this.detectEvictedFragments(d,f,l,n)})}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=In(t);return!!this.fragments[e]}hasParts(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)}removeFragmentsInRange(t,e,i,n,o){n&&!this.hasGaps||Object.keys(this.fragments).forEach(l=>{const d=this.fragments[l];if(!d)return;const f=d.body;f.type!==i||n&&!f.gap||f.start<e&&f.end>t&&(d.buffered||o)&&this.removeFragment(f)})}removeFragment(t){const e=In(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const i=this.activePartLists[t.type];if(i){const n=t.sn;this.activePartLists[t.type]=i.filter(o=>o.fragment.sn!==n)}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 Bo(s){var t,e,i;return s.buffered&&(s.body.gap||((t=s.range.video)==null?void 0:t.partial)||((e=s.range.audio)==null?void 0:e.partial)||((i=s.range.audiovideo)==null?void 0:i.partial))}function In(s){return`${s.type}_${s.level}_${s.urlId}_${s.sn}`}const Y0=Math.pow(2,17);class Uy{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 ns({type:Qt.NETWORK_ERROR,details:pt.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const n=this.config,o=n.fLoader,l=n.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap)if(t.tagList.some(E=>E[0]==="GAP")){f(Z0(t));return}else t.gap=!1;const p=this.loader=t.loader=o?new o(n):new l(n),g=X0(t),v=j0(n.fragLoadPolicy.default),A={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:Y0};t.stats=p.stats,p.load(g,A,{onSuccess:(E,T,w,C)=>{this.resetLoader(t,p);let x=E.data;w.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(x.slice(0,16)),x=x.slice(16)),d({frag:t,part:null,payload:x,networkDetails:C})},onError:(E,T,w,C)=>{this.resetLoader(t,p),f(new ns({type:Qt.NETWORK_ERROR,details:pt.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:zi({url:i,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:C}))},onAbort:(E,T,w)=>{this.resetLoader(t,p),f(new ns({type:Qt.NETWORK_ERROR,details:pt.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:w,stats:E}))},onTimeout:(E,T,w)=>{this.resetLoader(t,p),f(new ns({type:Qt.NETWORK_ERROR,details:pt.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:w,stats:E}))},onProgress:(E,T,w,C)=>{e&&e({frag:t,part:null,payload:w,networkDetails:C})}})})}loadPart(t,e,i){this.abort();const n=this.config,o=n.fLoader,l=n.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap){f(Z0(t,e));return}const p=this.loader=t.loader=o?new o(n):new l(n),g=X0(t,e),v=j0(n.fragLoadPolicy.default),A={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Y0};e.stats=p.stats,p.load(g,A,{onSuccess:(E,T,w,C)=>{this.resetLoader(t,p),this.updateStatsFromPart(t,e);const x={frag:t,part:e,payload:E.data,networkDetails:C};i(x),d(x)},onError:(E,T,w,C)=>{this.resetLoader(t,p),f(new ns({type:Qt.NETWORK_ERROR,details:pt.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:zi({url:g.url,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:C}))},onAbort:(E,T,w)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,p),f(new ns({type:Qt.NETWORK_ERROR,details:pt.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 ns({type:Qt.NETWORK_ERROR,details:pt.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:w,stats:E}))}})})}updateStatsFromPart(t,e){const i=t.stats,n=e.stats,o=n.total;if(i.loaded+=n.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 l=i.loading,d=n.loading;l.start?l.first+=d.first-d.start:(l.start=d.start,l.first=d.first),l.end=d.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function X0(s,t=null){const e=t||s,i={frag:s,part:t,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},n=e.byteRangeStartOffset,o=e.byteRangeEndOffset;if(Wt(n)&&Wt(o)){var l;let d=n,f=o;if(s.sn==="initSegment"&&((l=s.decryptdata)==null?void 0:l.method)==="AES-128"){const p=o-n;p%16&&(f=o+(16-p%16)),n!==0&&(i.resetIV=!0,d=n-16)}i.rangeStart=d,i.rangeEnd=f}return i}function Z0(s,t){const e=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:Qt.MEDIA_ERROR,details:pt.FRAG_GAP,fatal:!1,frag:s,error:e,networkDetails:null};return t&&(i.part=t),(t||s).stats.aborted=!0,new ns(i)}class ns extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class By{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=pt.KEY_LOAD_ERROR,i,n,o){return new ns({type:Qt.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:o,error:i,networkDetails:n})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:n}=t;for(let o=0;o<e.length;o++){const l=e[o];if(n<=l.cc&&(i==="initSegment"||l.sn==="initSegment"||i<l.sn)){this.emeController.selectKeySystemFormat(l).then(d=>{l.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,n;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,pt.KEY_LOAD_ERROR,p))}const l=o.uri;if(!l)return Promise.reject(this.createKeyLoadError(t,pt.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${l}"`)));let d=this.keyUriToKeyInfo[l];if((i=d)!=null&&i.decryptdata.key)return o.key=d.decryptdata.key,Promise.resolve({frag:t,keyInfo:d});if((n=d)!=null&&n.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[l]={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,pt.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 n=this.emeController.loadKey(i);if(n)return(t.keyLoadPromise=n.then(o=>(t.mediaKeySessionContext=o,i))).catch(o=>{throw t.keyLoadPromise=null,o})}return Promise.resolve(i)}loadKeyHTTP(t,e){const i=this.config,n=i.loader,o=new n(i);return e.keyLoader=t.loader=o,t.keyLoadPromise=new Promise((l,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:(A,E,T,w)=>{const{frag:C,keyInfo:x,url:O}=T;if(!C.decryptdata||x!==this.keyUriToKeyInfo[O])return d(this.createKeyLoadError(C,pt.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));x.decryptdata.key=C.decryptdata.key=new Uint8Array(A.data),C.keyLoader=null,x.loader=null,l({frag:C,keyInfo:x})},onError:(A,E,T,w)=>{this.resetLoader(E),d(this.createKeyLoadError(e,pt.KEY_LOAD_ERROR,new Error(`HTTP Error ${A.code} loading key ${A.text}`),T,zi({url:f.url,data:void 0},A)))},onTimeout:(A,E,T)=>{this.resetLoader(E),d(this.createKeyLoadError(e,pt.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:(A,E,T)=>{this.resetLoader(E),d(this.createKeyLoadError(e,pt.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};o.load(f,g,v)})}resetLoader(t){const{frag:e,keyInfo:i,url:n}=t,o=i.loader;e.keyLoader===o&&(e.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[n],o&&o.destroy()}}class Gy{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 Vy={length:0,start:()=>0,end:()=>0};class Ge{static isBuffered(t,e){try{if(t){const i=Ge.getBuffered(t);for(let n=0;n<i.length;n++)if(e>=i.start(n)&&e<=i.end(n))return!0}}catch{}return!1}static bufferInfo(t,e,i){try{if(t){const n=Ge.getBuffered(t),o=[];let l;for(l=0;l<n.length;l++)o.push({start:n.start(l),end:n.end(l)});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 n=[];if(i)for(let p=0;p<t.length;p++){const g=n.length;if(g){const v=n[g-1].end;t[p].start-v<i?t[p].end>v&&(n[g-1].end=t[p].end):n.push(t[p])}else n.push(t[p])}else n=t;let o=0,l,d=e,f=e;for(let p=0;p<n.length;p++){const g=n[p].start,v=n[p].end;if(e+i>=g&&e<v)d=g,f=v,o=f-e;else if(e+i<g){l=g;break}}return{len:o,start:d||0,end:f||0,nextStart:l}}static getBuffered(t){try{return t.buffered}catch(e){return X.log("failed to get media.buffered",e),Vy}}}class Mc{constructor(t,e,i,n=0,o=-1,l=!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=Go(),this.buffering={audio:Go(),video:Go(),audiovideo:Go()},this.level=t,this.sn=e,this.id=i,this.size=n,this.part=o,this.partial=l}}function Go(){return{start:0,executeStart:0,executeEnd:0,end:0}}function q0(s,t){let e=null;for(let i=0,n=s.length;i<n;i++){const o=s[i];if(o&&o.cc===t){e=o;break}}return e}function Hy(s,t,e){return!!(t.details&&(e.endCC>e.startCC||s&&s.cc<e.startCC))}function Wy(s,t,e=0){const i=s.fragments,n=t.fragments;if(!n.length||!i.length){X.log("No fragments to align");return}const o=q0(i,n[0].cc);if(!o||o&&!o.startPTS){X.log("No frag in previous level to align on");return}return o}function Q0(s,t){if(s){const e=s.start+t;s.start=s.startPTS=e,s.endPTS=e+s.duration}}function $c(s,t){const e=t.fragments;for(let i=0,n=e.length;i<n;i++)Q0(e[i],s);t.fragmentHint&&Q0(t.fragmentHint,s),t.alignedSliding=!0}function jy(s,t,e){t&&(Ky(s,e,t),!e.alignedSliding&&t.details&&zy(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&G0(t.details,e))}function Ky(s,t,e){if(Hy(s,e,t)){const i=Wy(e.details,t);i&&Wt(i.start)&&(X.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),$c(i.start,t))}}function zy(s,t){if(!t.fragments.length||!s.hasProgramDateTime||!t.hasProgramDateTime)return;const e=t.fragments[0].programDateTime,i=s.fragments[0].programDateTime,n=(i-e)/1e3+t.fragments[0].start;n&&Wt(n)&&(X.log(`Adjusting PTS using programDateTime delta ${i-e}ms, sliding:${n.toFixed(3)} ${s.url} `),$c(n,s))}function J0(s,t){if(!s.hasProgramDateTime||!t.hasProgramDateTime)return;const e=s.fragments,i=t.fragments;if(!e.length||!i.length)return;const n=Math.round(i.length/2)-1,o=i[n],l=q0(e,o.cc)||e[Math.round(e.length/2)-1],d=o.programDateTime,f=l.programDateTime;if(d===null||f===null)return;const p=(f-d)/1e3-(l.start-o.start);$c(p,s)}class Yy{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 Zy(s){const t=s.byteLength,e=t&&new DataView(s.buffer).getUint8(t-1);return e?hn(s,0,t-e):s}class qy{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 n=0;n<4;n++)i[n]=e.getUint32(n*4);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,n=i[0],o=i[1],l=i[2],d=i[3],f=this.invSubMix,p=f[0],g=f[1],v=f[2],A=f[3],E=new Uint32Array(256);let T=0,w=0,C=0;for(C=0;C<256;C++)C<128?E[C]=C<<1:E[C]=C<<1^283;for(C=0;C<256;C++){let x=w^w<<1^w<<2^w<<3^w<<4;x=x>>>8^x&255^99,t[T]=x,e[x]=T;const O=E[T],U=E[O],D=E[U];let H=E[x]*257^x*16843008;n[T]=H<<24|H>>>8,o[T]=H<<16|H>>>16,l[T]=H<<8|H>>>24,d[T]=H,H=D*16843009^U*65537^O*257^T*16843008,p[x]=H<<24|H>>>8,g[x]=H<<16|H>>>16,v[x]=H<<8|H>>>24,A[x]=H,T?(T=O^E[E[E[D^O]]],w^=E[E[w]]):T=w=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let i=!0,n=0;for(;n<e.length&&i;)i=e[n]===this.key[n],n++;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 l=this.ksRows=(o+6+1)*4;let d,f;const p=this.keySchedule=new Uint32Array(l),g=this.invKeySchedule=new Uint32Array(l),v=this.sBox,A=this.rcon,E=this.invSubMix,T=E[0],w=E[1],C=E[2],x=E[3];let O,U;for(d=0;d<l;d++){if(d<o){O=p[d]=e[d];continue}U=O,d%o===0?(U=U<<8|U>>>24,U=v[U>>>24]<<24|v[U>>>16&255]<<16|v[U>>>8&255]<<8|v[U&255],U^=A[d/o|0]<<24):o>6&&d%o===4&&(U=v[U>>>24]<<24|v[U>>>16&255]<<16|v[U>>>8&255]<<8|v[U&255]),p[d]=O=(p[d-o]^U)>>>0}for(f=0;f<l;f++)d=l-f,f&3?U=p[d]:U=p[d-4],f<4||d<=4?g[f]=U:g[f]=T[v[U>>>24]]^w[v[U>>>16&255]]^C[v[U>>>8&255]]^x[v[U&255]],g[f]=g[f]>>>0}networkToHostOrderSwap(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24}decrypt(t,e,i){const n=this.keySize+6,o=this.invKeySchedule,l=this.invSBox,d=this.invSubMix,f=d[0],p=d[1],g=d[2],v=d[3],A=this.uint8ArrayToUint32Array_(i);let E=A[0],T=A[1],w=A[2],C=A[3];const x=new Int32Array(t),O=new Int32Array(x.length);let U,D,H,$,z,tt,at,J,St,mt,Ot,Vt,G,q;const At=this.networkToHostOrderSwap;for(;e<x.length;){for(St=At(x[e]),mt=At(x[e+1]),Ot=At(x[e+2]),Vt=At(x[e+3]),z=St^o[0],tt=Vt^o[1],at=Ot^o[2],J=mt^o[3],G=4,q=1;q<n;q++)U=f[z>>>24]^p[tt>>16&255]^g[at>>8&255]^v[J&255]^o[G],D=f[tt>>>24]^p[at>>16&255]^g[J>>8&255]^v[z&255]^o[G+1],H=f[at>>>24]^p[J>>16&255]^g[z>>8&255]^v[tt&255]^o[G+2],$=f[J>>>24]^p[z>>16&255]^g[tt>>8&255]^v[at&255]^o[G+3],z=U,tt=D,at=H,J=$,G=G+4;U=l[z>>>24]<<24^l[tt>>16&255]<<16^l[at>>8&255]<<8^l[J&255]^o[G],D=l[tt>>>24]<<24^l[at>>16&255]<<16^l[J>>8&255]<<8^l[z&255]^o[G+1],H=l[at>>>24]<<24^l[J>>16&255]<<16^l[z>>8&255]<<8^l[tt&255]^o[G+2],$=l[J>>>24]<<24^l[z>>16&255]<<16^l[tt>>8&255]<<8^l[at&255]^o[G+3],O[e]=At(U^E),O[e+1]=At($^T),O[e+2]=At(H^w),O[e+3]=At(D^C),E=St,T=mt,w=Ot,C=Vt,e=e+4}return O.buffer}}const Qy=16;class Fc{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?Zy(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((n,o)=>{this.softwareDecrypt(new Uint8Array(t),e,i);const l=this.flush();l?n(l.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,i)}softwareDecrypt(t,e,i){const{currentIV:n,currentResult:o,remainderData:l}=this;this.logOnce("JS AES decrypt"),l&&(t=dn(l,t),this.remainderData=null);const d=this.getValidChunk(t);if(!d.length)return null;n&&(i=n);let f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new qy),f.expandKey(e);const p=o;return this.currentResult=f.decrypt(d.buffer,0,i),this.currentIV=hn(d,-16).buffer,p||null}webCryptoDecrypt(t,e,i){const n=this.subtle;return(this.key!==e||!this.fastAesKey)&&(this.key=e,this.fastAesKey=new Xy(n,e)),this.fastAesKey.expandKey().then(o=>n?(this.logOnce("WebCrypto AES decrypt"),new Yy(n,new Uint8Array(i)).decrypt(t.buffer,o)):Promise.reject(new Error("web crypto not initialized"))).catch(o=>(X.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 n=this.flush();if(n)return n.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const i=t.length-t.length%Qy;return i!==t.length&&(e=hn(t,0,i),this.remainderData=hn(t,i)),e}logOnce(t){this.logEnabled&&(X.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const Jy={toString:function(s){let t="";const e=s.length;for(let i=0;i<e;i++)t+=`[${s.start(i).toFixed(3)}-${s.end(i).toFixed(3)}]`;return t}},wt={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 Nc extends Gy{constructor(t,e,i,n,o){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=wt.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=n,this.log=X.log.bind(X,`${n}:`),this.warn=X.warn.bind(X,`${n}:`),this.hls=t,this.fragmentLoader=new Uy(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new Fc(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=wt.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 Ge.isBuffered(this.media,o.start+o.duration/2)}const n=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)}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 n=this.config;this.levels&&n.autoStartLoad&&this.state===wt.STOPPED&&this.startLoad(n.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:n,state:o}=this,l=i?i.currentTime:0,d=Ge.bufferInfo(n||i,l,t.maxBufferHole);if(this.log(`media seeking to ${Wt(l)?l.toFixed(3):l}, state: ${o}`),this.state===wt.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=l>g;(l<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(l,1/0,this.playlistType,!0),this.lastCurrentTime=l),!this.loadedmetadata&&!d.len&&(this.nextLoadPosition=this.startPosition=l),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=wt.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 n=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,n).then(o=>{if(!o)return;const l=this.state;if(this.fragContextChanged(t)){(l===wt.FRAG_LOADING||!this.fragCurrent&&l===wt.PARSING)&&(this.fragmentTracker.removeFragment(t),this.state=wt.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===wt.STOPPED||this.state===wt.ERROR||(this.warn(o),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===yi.APPENDING){const n=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,n),l=Math.max(t.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(l)&&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)===yi.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 n={startOffset:t,endOffset:e,type:i};this.hls.trigger(R.BUFFER_FLUSHING,n)}_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:n}=this,{payload:o}=i,l=t.decryptdata;if(o&&o.byteLength>0&&l&&l.key&&l.iv&&l.method==="AES-128"){const d=self.performance.now();return this.decrypter.decrypt(new Uint8Array(o),l.key.buffer,l.iv.buffer).catch(f=>{throw n.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.FRAG_DECRYPT_ERROR,fatal:!1,error:f,reason:f.message,frag:t}),f}).then(f=>{const p=self.performance.now();return n.trigger(R.FRAG_DECRYPTED,{frag:t,payload:f,stats:{tstart:d,tdecrypt:p}}),i.payload=f,i})}return i}).then(i=>{const{fragCurrent:n,hls:o,levels:l}=this;if(!l)throw new Error("init load aborted, missing levels");const d=t.stats;this.state=wt.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===n&&o.trigger(R.FRAG_BUFFERED,{stats:d,frag:n,part:null,id:t.type}),this.tick()}).catch(i=>{this.state===wt.STOPPED||this.state===wt.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,n,o,l;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)}-${((n=t.endPTS)!=null?n:NaN).toFixed(3)}] > buffer:${d?Jy.toString(Ge.getBuffered(d)):"(detached)"})`),this.state=wt.IDLE,d&&(!this.loadedmetadata&&t.type==Jt.MAIN&&d.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:i,part:n,partsLoaded:o}=t,l=!o||o.length===0||o.some(f=>!f),d=new Mc(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!l);e.flush(d)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,i=null,n){var o;const l=e==null?void 0:e.details;if(!this.levels||!l)throw new Error(`frag load aborted, missing level${l?"":" detail"}s`);let d=null;if(t.encrypted&&!((o=t.decryptdata)!=null&&o.key)?(this.log(`Loading key for ${t.sn} of [${l.startSN}-${l.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${t.level}`),this.state=wt.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===wt.KEY_LOADING&&(this.state=wt.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&&l.encryptedFragments.length&&this.keyLoader.loadClear(t,l.encryptedFragments),i=Math.max(t.start,i||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){const g=l.partList;if(g&&n){i>t.end&&l.fragmentHint&&(t=l.fragmentHint);const v=this.getNextPart(g,t,i);if(v>-1){const A=g[v];this.log(`Loading part sn: ${t.sn} p: ${A.index} cc: ${t.cc} of playlist [${l.startSN}-${l.endSN}] parts [0-${v}-${g.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=A.start+A.duration,this.state=wt.FRAG_LOADING;let E;return d?E=d.then(T=>!T||this.fragContextChanged(T.frag)?null:this.doFragPartsLoad(t,A,e,n)).catch(T=>this.handleFragLoadError(T)):E=this.doFragPartsLoad(t,A,e,n).catch(T=>this.handleFragLoadError(T)),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:A,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} ${l?"of ["+l.startSN+"-"+l.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),Wt(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=wt.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,n)).catch(g=>this.handleFragLoadError(g)):p=Promise.all([this.fragmentLoader.load(t,f?n:void 0),d]).then(([g])=>(!f&&g&&n&&n(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,n){return new Promise((o,l)=>{var d;const f=[],p=(d=i.details)==null?void 0:d.partList,g=v=>{this.fragmentLoader.loadPart(t,v,n).then(A=>{f[v.index]=A;const E=A.part;this.hls.trigger(R.FRAG_LOADED,A);const T=V0(i,t.sn,v.index+1)||H0(p,t.sn,v.index+1);if(T)g(T);else return o({frag:t,part:E,partsLoaded:f})}).catch(l)};g(e)})}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===pt.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:pt.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==wt.PARSING){!this.fragCurrent&&this.state!==wt.STOPPED&&this.state!==wt.ERROR&&(this.state=wt.IDLE);return}const{frag:i,part:n,level:o}=e,l=self.performance.now();i.stats.parsing.end=l,n&&(n.stats.parsing.end=l),this.updateLevelTiming(i,n,o,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:i}=this,{level:n,sn:o,part:l}=t;if(!(e!=null&&e[n]))return this.warn(`Levels object was unset while buffering fragment ${o} of level ${n}. The current chunk will not be buffered.`),null;const d=e[n],f=l>-1?V0(d,o,l):null,p=f?f.fragment:Cy(d,o,i);return p?(i&&i!==p&&(p.stats=i.stats),{frag:p,part:f,level:d}):null}bufferFragmentData(t,e,i,n,o){var l;if(!t||this.state!==wt.PARSING)return;const{data1:d,data2:f}=t;let p=d;if(d&&f&&(p=dn(d,f)),!((l=p)!=null&&l.length))return;const g={type:t.type,frag:e,part:i,chunkMeta:n,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(!Ge.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}const i=e.currentTime,n=Ge.bufferInfo(e,i,0),o=t.duration,l=Math.min(this.config.maxFragLookUpTolerance*2,o*.25),d=Math.max(Math.min(t.start-l,n.end-l),i+l);t.start-d>l&&this.flushMainBuffer(d,t.start)}getFwdBufferInfo(t,e){const i=this.getLoadPosition();return Wt(i)?this.getFwdBufferInfoAtPos(t,i,e):null}getFwdBufferInfoAtPos(t,e,i){const{config:{maxBufferHole:n}}=this,o=Ge.bufferInfo(t,e,n);if(o.len===0&&o.nextStart!==void 0){const l=this.fragmentTracker.getBufferedFrag(e,i);if(l&&o.nextStart<l.end)return Ge.bufferInfo(t,e,Math.max(o.nextStart,n))}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,n=i.length;if(!n)return null;const{config:o}=this,l=i[0].start;let d;if(e.live){const f=o.initialLiveManifestSize;if(n<f)return this.warn(`Not enough fragments to start playback (have: ${n}, 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<=l&&(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===yi.OK||i===yi.PARTIAL&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,i,n,o){const l=t.gap,d=this.getNextFragment(this.nextLoadPosition,e);if(d===null)return d;if(t=d,l&&t&&!t.gap&&i.nextStart){const f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n);if(f!==null&&i.len+f.len>=o)return this.log(`buffer full after gaps in "${n}" 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 n=-1,o=!1,l=!0;for(let d=0,f=t.length;d<f;d++){const p=t[d];if(l=l&&!p.independent,n>-1&&i<p.start)break;const g=p.loaded;g?n=-1:(o||p.independent||l)&&p.fragment===e&&(n=d),o=g}return n}loadedEndOfParts(t,e){const i=t[t.length-1];return i&&e>i.start&&i.loaded}getInitialLiveFragment(t,e){const i=this.fragPrevious;let n=null;if(i){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),n=Dy(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){const l=e[o-t.startSN];i.cc===l.cc&&(n=l,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=Py(e,i.cc),n&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`))}}else{const o=this.hls.liveSyncPosition;o!==null&&(n=this.getFragmentAtPosition(o,this.bitrateTest?t.fragmentEnd:t.edge,t))}return n}getFragmentAtPosition(t,e,i){const{config:n}=this;let{fragPrevious:o}=this,{fragments:l,endSN:d}=i;const{fragmentHint:f}=i,p=n.maxFragLookUpTolerance,g=i.partList,v=!!(n.lowLatencyMode&&g!=null&&g.length&&f);v&&f&&!this.bitrateTest&&(l=l.concat(f),d=f.sn);let A;if(t<e){const E=t>e-p?0:p;A=Da(o,l,t,E)}else A=l[l.length-1];if(A){const E=A.sn-i.startSN,T=this.fragmentTracker.getState(A);if((T===yi.OK||T===yi.PARTIAL&&A.gap)&&(o=A),o&&A.sn===o.sn&&(!v||g[0].fragment.sn>A.sn)&&o&&A.level===o.level){const w=l[E+1];A.sn<d&&this.fragmentTracker.getState(w)!==yi.OK?A=w:A=null}}return A}synchronizeToLiveEdge(t){const{config:e,media:i}=this;if(!i)return;const n=this.hls.liveSyncPosition,o=i.currentTime,l=t.fragments[0].start,d=t.edge,f=o>=l-e.maxFragLookUpTolerance&&o<=d;if(n!==null&&i.duration>n&&(o<n||!f)){const p=e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!f&&i.readyState<4||o<d-p)&&(this.loadedmetadata||(this.nextLoadPosition=n),i.readyState&&(this.warn(`Playback: ${o.toFixed(3)} is located too far from the end of live sliding playlist: ${d}, reset currentTime to : ${n.toFixed(3)}`),i.currentTime=n))}}alignPlaylists(t,e){const{levels:i,levelLastLoaded:n,fragPrevious:o}=this,l=n!==null?i[n]: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&&Wt(f);if(p||!g&&!f){jy(o,l,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 n=this.startTimeOffset!==null,o=n?this.startTimeOffset:t.startTimeOffset;o!==null&&Wt(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 ${n?"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!==wt.FRAG_LOADING_WAITING_RETRY)&&(this.state=wt.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 n;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(n=this.fragCurrent)==null?void 0:n.url}`);return}const o=e.details===pt.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(i,!0);const l=e.errorAction,{action:d,retryCount:f=0,retryConfig:p}=l||{};if(l&&d===Di.RetryRequest&&p){var g;this.resetStartWhenNotLoaded((g=this.levelLastLoaded)!=null?g:i.level);const v=Dc(p,f);this.warn(`Fragment ${i.sn} of ${t} ${i.level} errored with ${e.details}, retrying loading ${f+1}/${p.maxNumRetry} in ${v}ms`),l.resolved=!0,this.retryDate=self.performance.now()+v,this.state=wt.FRAG_LOADING_WAITING_RETRY}else p&&l?(this.resetFragmentErrors(t),f<p.maxNumRetry?o||(l.resolved=!0):X.warn(`${e.details} reached or exceeded max retry (${f})`)):(l==null?void 0:l.action)===Di.SendAlternateToPenaltyBox?this.state=wt.WAITING_LEVEL:this.state=wt.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===wt.PARSING||this.state===wt.PARSED){const e=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,e),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len);const o=!n;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!==wt.STOPPED&&(this.state=wt.IDLE)}afterBufferFlushed(t,e,i){if(!t)return;const n=Ge.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,n,i),this.state===wt.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=wt.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,n){var o;const l=i.details;if(!l){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=n?0:B0(l,t,p.startPTS,p.endPTS,p.startDTS,p.endDTS);return this.hls.trigger(R.LEVEL_PTS_UPDATED,{details:l,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:pt.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=wt.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,n;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((e=(i=this.levelLastLoaded)!=null?i:(n=this.fragCurrent)==null?void 0:n.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 tf(){return self.SourceBuffer||self.WebKitSourceBuffer}function tb(){const s=Mo();if(!s)return!1;const t=tf(),e=s&&typeof s.isTypeSupported=="function"&&s.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function";return!!e&&!!i}function eb(){var s;const t=tf();return typeof(t==null||(s=t.prototype)==null?void 0:s.changeType)=="function"}function ib(){return typeof __HLS_WORKER_BUNDLE__=="function"}function rb(){const s=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(s);return{worker:new self.Worker(t),objectURL:t}}function sb(s){const t=new self.URL(s,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}function Br(s="",t=9e4){return{type:s,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class ef{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,n){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=dn(this.cachedData,t),this.cachedData=null);let i=Do(t,0),n=i?i.length:0,o;const l=this._audioTrack,d=this._id3Track,f=i?Bv(i):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&Wt(f))&&(this.basePTS=nb(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:Sr.audioId3,duration:Number.POSITIVE_INFINITY});n<p;){if(this.canParse(t,n)){const g=this.appendFrame(l,t,n);g?(this.frameIndex++,this.lastPTS=g.sample.pts,n+=g.length,o=n):n=p}else Uv(t,n)?(i=Do(t,n),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Sr.audioId3,duration:Number.POSITIVE_INFINITY}),n+=i.length,o=n):n++;if(n===p&&o!==p){const g=hn(t,o);this.cachedData?this.cachedData=dn(this.cachedData,g):this.cachedData=g}}return{audioTrack:l,videoTrack:Br(),id3Track:d,textTrack:Br()}}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:Br(),id3Track:this._id3Track,textTrack:Br()}}destroy(){}}const nb=(s,t,e)=>{if(Wt(s))return s*90;const i=e?e.baseTime*9e4/e.timescale:0;return t*9e4+i};function ab(s,t,e,i){let n,o,l,d;const f=navigator.userAgent.toLowerCase(),p=i,g=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=((t[e+2]&192)>>>6)+1;const v=(t[e+2]&60)>>>2;if(v>g.length-1){s.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${v}`});return}return l=(t[e+2]&1)<<2,l|=(t[e+3]&192)>>>6,X.log(`manifest codec:${i}, ADTS type:${n}, samplingIndex:${v}`),/firefox/i.test(f)?v>=6?(n=5,d=new Array(4),o=v-3):(n=2,d=new Array(2),o=v):f.indexOf("android")!==-1?(n=2,d=new Array(2),o=v):(n=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&&l===1||/vivaldi/i.test(f))||!i&&l===1)&&(n=2,d=new Array(2)),o=v)),d[0]=n<<3,d[0]|=(v&14)>>1,d[1]|=(v&1)<<7,d[1]|=l<<3,n===5&&(d[1]|=(o&14)>>1,d[2]=(o&1)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:g[v],channelCount:l,codec:"mp4a.40."+n,manifestCodec:p}}function rf(s,t){return s[t]===255&&(s[t+1]&246)===240}function sf(s,t){return s[t+1]&1?7:9}function Uc(s,t){return(s[t+3]&3)<<11|s[t+4]<<3|(s[t+5]&224)>>>5}function ob(s,t){return t+5<s.length}function Vo(s,t){return t+1<s.length&&rf(s,t)}function lb(s,t){return ob(s,t)&&rf(s,t)&&Uc(s,t)<=s.length-t}function cb(s,t){if(Vo(s,t)){const e=sf(s,t);if(t+e>=s.length)return!1;const i=Uc(s,t);if(i<=e)return!1;const n=t+i;return n===s.length||Vo(s,n)}return!1}function nf(s,t,e,i,n){if(!s.samplerate){const o=ab(t,e,i,n);if(!o)return;s.config=o.config,s.samplerate=o.samplerate,s.channelCount=o.channelCount,s.codec=o.codec,s.manifestCodec=o.manifestCodec,X.log(`parsed codec:${s.codec}, rate:${o.samplerate}, channels:${o.channelCount}`)}}function af(s){return 9216e4/s}function hb(s,t){const e=sf(s,t);if(t+e<=s.length){const i=Uc(s,t)-e;if(i>0)return{headerLength:e,frameLength:i}}}function of(s,t,e,i,n){const o=af(s.samplerate),l=i+n*o,d=hb(t,e);let f;if(d){const{frameLength:g,headerLength:v}=d,A=v+g,E=Math.max(0,e+A-t.length);E?(f=new Uint8Array(A-v),f.set(t.subarray(e+v,t.length),0)):f=t.subarray(e+v,e+A);const T={unit:f,pts:l};return E||s.samples.push(T),{sample:T,length:A,missing:E}}const p=t.length-e;return f=new Uint8Array(p),f.set(t.subarray(e,t.length),0),{sample:{unit:f,pts:l},length:p,missing:-1}}class db extends ef{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,i,n){super.resetInitSegment(t,e,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(Do(t,0)||[]).length;for(let i=t.length;e<i;e++)if(cb(t,e))return X.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return lb(t,e)}appendFrame(t,e,i){nf(t,this.observer,e,i,t.manifestCodec);const n=of(t,e,i,this.basePTS,this.frameIndex);if(n&&n.missing===0)return n}}const ub=/\/emsg[-/]ID3/i;class fb{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,n){const o=this.videoTrack=Br("video",1),l=this.audioTrack=Br("audio",1),d=this.txtTrack=Br("text",1);if(this.id3Track=Br("id3",1),this.timeOffset=0,!(t!=null&&t.byteLength))return;const f=y0(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;l.id=p,l.timescale=g,l.codec=v}d.id=g0.text,o.sampleDuration=0,o.duration=l.duration=n}resetContiguity(){this.remainderData=null}static probe(t){return t=t.length>16384?t.subarray(0,16384):t,be(t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let i=t;const n=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=dn(this.remainderData,t));const d=ey(i);this.remainderData=d.remainder,n.samples=d.valid||new Uint8Array}else n.samples=i;const l=this.extractID3Track(n,e);return o.samples=A0(e,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:l,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,i=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const n=this.extractID3Track(e,this.timeOffset);return i.samples=A0(t,e),{videoTrack:e,audioTrack:Br(),id3Track:n,textTrack:Br()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const n=be(t.samples,["emsg"]);n&&n.forEach(o=>{const l=sy(o);if(ub.test(l.schemeIdUri)){const d=Wt(l.presentationTime)?l.presentationTime/l.timeScale:e+l.presentationTimeDelta/l.timeScale;let f=l.eventDuration===4294967295?Number.POSITIVE_INFINITY:l.eventDuration/l.timeScale;f<=.001&&(f=Number.POSITIVE_INFINITY);const p=l.payload;i.samples.push({data:p,len:p.byteLength,dts:d,pts:d,type:Sr.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 Ho=null;const pb=[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],gb=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],mb=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],vb=[0,1,1,4];function lf(s,t,e,i,n){if(e+24>t.length)return;const o=cf(t,e);if(o&&e+o.frameLength<=t.length){const l=o.samplesPerFrame*9e4/o.sampleRate,d=i+n*l,f={unit:t.subarray(e,e+o.frameLength),pts:d,dts:d};return s.config=[],s.channelCount=o.channelCount,s.samplerate=o.sampleRate,s.samples.push(f),{sample:f,length:o.frameLength,missing:0}}}function cf(s,t){const e=s[t+1]>>3&3,i=s[t+1]>>1&3,n=s[t+2]>>4&15,o=s[t+2]>>2&3;if(e!==1&&n!==0&&n!==15&&o!==3){const l=s[t+2]>>1&1,d=s[t+3]>>6,f=e===3?3-i:i===3?3:4,p=pb[f*14+n-1]*1e3,g=gb[(e===3?0:e===2?1:2)*3+o],v=d===3?1:2,A=mb[e][i],E=vb[i],T=A*8*E,w=Math.floor(A*p/g+l)*E;if(Ho===null){const C=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ho=C?parseInt(C[1]):0}return Ho&&Ho<=87&&i===2&&p>=224e3&&d===0&&(s[t+3]=s[t+3]|128),{sampleRate:g,channelCount:v,frameLength:w,samplesPerFrame:T}}}function Bc(s,t){return s[t]===255&&(s[t+1]&224)===224&&(s[t+1]&6)!==0}function hf(s,t){return t+1<s.length&&Bc(s,t)}function yb(s,t){return Bc(s,t)&&4<=s.length-t}function bb(s,t){if(t+1<s.length&&Bc(s,t)){const e=cf(s,t);let i=4;e!=null&&e.frameLength&&(i=e.frameLength);const n=t+i;return n===s.length||hf(s,n)}return!1}class df{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,n=new Uint8Array(4),o=Math.min(4,e);if(o===0)throw new Error("no bytes available");n.set(t.subarray(i,i+o)),this.word=new DataView(n.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&&X.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,n;for(let o=0;o<t;o++)i!==0&&(n=this.readEG(),i=(e+n+256)%256),e=i===0?e:i}readSPS(){let t=0,e=0,i=0,n=0,o,l,d;const f=this.readUByte.bind(this),p=this.readBits.bind(this),g=this.readUEG.bind(this),v=this.readBoolean.bind(this),A=this.skipBits.bind(this),E=this.skipEG.bind(this),T=this.skipUEG.bind(this),w=this.skipScalingList.bind(this);f();const C=f();if(p(5),A(3),f(),T(),C===100||C===110||C===122||C===244||C===44||C===83||C===86||C===118||C===128){const $=g();if($===3&&A(1),T(),T(),A(1),v())for(l=$!==3?8:12,d=0;d<l;d++)v()&&(d<6?w(16):w(64))}T();const x=g();if(x===0)g();else if(x===1)for(A(1),E(),E(),o=g(),d=0;d<o;d++)E();T(),A(1);const O=g(),U=g(),D=p(1);D===0&&A(1),A(1),v()&&(t=g(),e=g(),i=g(),n=g());let H=[1,1];if(v()&&v())switch(f()){case 1:H=[1,1];break;case 2:H=[12,11];break;case 3:H=[10,11];break;case 4:H=[16,11];break;case 5:H=[40,33];break;case 6:H=[24,11];break;case 7:H=[20,11];break;case 8:H=[32,11];break;case 9:H=[80,33];break;case 10:H=[18,11];break;case 11:H=[15,11];break;case 12:H=[64,33];break;case 13:H=[160,99];break;case 14:H=[4,3];break;case 15:H=[3,2];break;case 16:H=[2,1];break;case 255:{H=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil((O+1)*16-t*2-e*2),height:(2-D)*(U+1)*16-(D?2:4)*(i+n),pixelRatio:H}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Ab{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Fc(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,i){const n=t[e].unit;if(n.length<=16)return;const o=n.subarray(16,n.length-n.length%16),l=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(l).then(d=>{const f=new Uint8Array(d);n.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 n=0;for(let o=32;o<t.length-16;o+=160,n+=16)i.set(t.subarray(o,o+16),n);return i}getAvcDecryptedUnit(t,e){const i=new Uint8Array(e);let n=0;for(let o=32;o<t.length-16;o+=160,n+=16)t.set(i.subarray(n,n+16),o);return t}decryptAvcSample(t,e,i,n,o){const l=T0(o.data),d=this.getAvcEncryptedData(l);this.decryptBuffer(d.buffer).then(f=>{o.data=this.getAvcDecryptedUnit(l,f),this.decrypter.isSync()||this.decryptAvcSamples(t,e,i+1,n)})}decryptAvcSamples(t,e,i,n){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length){n();return}const o=t[e].units;for(;!(i>=o.length);i++){const l=o[i];if(!(l.data.length<=48||l.type!==1&&l.type!==5)&&(this.decryptAvcSample(t,e,i,n,l),!this.decrypter.isSync()))return}}}}const xi=188;class Rs{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=Rs.syncOffset(t);return e>0&&X.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),e!==-1}static syncOffset(t){const e=t.length;let i=Math.min(xi*5,t.length-xi)+1,n=0;for(;n<i;){let o=!1,l=-1,d=0;for(let f=n;f<e;f+=xi)if(t[f]===71){if(d++,l===-1&&(l=f,l!==0&&(i=Math.min(l+xi*99,t.length-xi)+1)),o||(o=Gc(t,f)===0),o&&d>1&&(l===0&&d>2||f+xi>i))return l}else{if(d)return-1;break}n++}return-1}static createTrack(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:g0[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}}resetInitSegment(t,e,i,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Rs.createTrack("video"),this._audioTrack=Rs.createTrack("audio",n),this._id3Track=Rs.createTrack("id3"),this._txtTrack=Rs.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=i,this._duration=n}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,n=!1){i||(this.sampleAes=null);let o;const l=this._avcTrack,d=this._audioTrack,f=this._id3Track,p=this._txtTrack;let g=l.pid,v=l.pesData,A=d.pid,E=f.pid,T=d.pesData,w=f.pesData,C=null,x=this.pmtParsed,O=this._pmtId,U=t.length;if(this.remainderData&&(t=dn(this.remainderData,t),U=t.length,this.remainderData=null),U<xi&&!n)return this.remainderData=t,{audioTrack:d,videoTrack:l,id3Track:f,textTrack:p};const D=Math.max(0,Rs.syncOffset(t));U-=(U-D)%xi,U<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,U,t.buffer.byteLength-U));let H=0;for(let z=D;z<U;z+=xi)if(t[z]===71){const tt=!!(t[z+1]&64),at=Gc(t,z),J=(t[z+3]&48)>>4;let St;if(J>1){if(St=z+5+t[z+4],St===z+xi)continue}else St=z+4;switch(at){case g:tt&&(v&&(o=Dn(v))&&this.parseAVCPES(l,p,o,!1),v={data:[],size:0}),v&&(v.data.push(t.subarray(St,z+xi)),v.size+=z+xi-St);break;case A:if(tt){if(T&&(o=Dn(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(St,z+xi)),T.size+=z+xi-St);break;case E:tt&&(w&&(o=Dn(w))&&this.parseID3PES(f,o),w={data:[],size:0}),w&&(w.data.push(t.subarray(St,z+xi)),w.size+=z+xi-St);break;case 0:tt&&(St+=t[St]+1),O=this._pmtId=Eb(t,St);break;case O:{tt&&(St+=t[St]+1);const mt=Tb(t,St,this.typeSupported,i);g=mt.avc,g>0&&(l.pid=g),A=mt.audio,A>0&&(d.pid=A,d.segmentCodec=mt.segmentCodec),E=mt.id3,E>0&&(f.pid=E),C!==null&&!x&&(X.warn(`MPEG-TS PMT found at ${z} after unknown PID '${C}'. Backtracking to sync byte @${D} to parse all TS packets.`),C=null,z=D-188),x=this.pmtParsed=!0;break}case 17:case 8191:break;default:C=at;break}}else H++;if(H>0){const z=new Error(`Found ${H} TS packet/s that do not start with 0x47`);this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.FRAG_PARSING_ERROR,fatal:!1,error:z,reason:z.message})}l.pesData=v,d.pesData=T,f.pesData=w;const $={audioTrack:d,videoTrack:l,id3Track:f,textTrack:p};return n&&this.extractRemainingSamples($),$}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:n,textTrack:o}=t,l=i.pesData,d=e.pesData,f=n.pesData;let p;if(l&&(p=Dn(l))?(this.parseAVCPES(i,o,p,!0),i.pesData=null):i.pesData=l,d&&(p=Dn(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&&X.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=d;f&&(p=Dn(f))?(this.parseID3PES(n,p),n.pesData=null):n.pesData=f}demuxSampleAes(t,e,i){const n=this.demux(t,i,!0,!this.config.progressive),o=this.sampleAes=new Ab(this.observer,this.config,e);return this.decrypt(n,o)}decrypt(t,e){return new Promise(i=>{const{audioTrack:n,videoTrack:o}=t;n.samples&&n.segmentCodec==="aac"?e.decryptAacSamples(n.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,n){const o=this.parseAVCNALu(t,i.data);let l=this.avcSample,d,f=!1;i.data=null,l&&o.length&&!t.audFound&&(xa(l,t),l=this.avcSample=Wo(!1,i.pts,i.dts,"")),o.forEach(p=>{var g;switch(p.type){case 1:{let A=!1;d=!0;const E=p.data;if(f&&E.length>4){const T=new df(E).readSliceType();(T===2||T===4||T===7||T===9)&&(A=!0)}if(A){var v;(v=l)!=null&&v.frame&&!l.key&&(xa(l,t),l=this.avcSample=null)}l||(l=this.avcSample=Wo(!0,i.pts,i.dts,"")),l.frame=!0,l.key=A;break}case 5:d=!0,(g=l)!=null&&g.frame&&!l.key&&(xa(l,t),l=this.avcSample=null),l||(l=this.avcSample=Wo(!0,i.pts,i.dts,"")),l.key=!0,l.frame=!0;break;case 6:{d=!0,E0(p.data,1,i.pts,e.samples);break}case 7:if(d=!0,f=!0,!t.sps){const A=p.data,E=new df(A).readSPS();t.width=E.width,t.height=E.height,t.pixelRatio=E.pixelRatio,t.sps=[A],t.duration=this._duration;const T=A.subarray(1,4);let w="avc1.";for(let C=0;C<3;C++){let x=T[C].toString(16);x.length<2&&(x="0"+x),w+=x}t.codec=w}break;case 8:d=!0,t.pps||(t.pps=[p.data]);break;case 9:d=!1,t.audFound=!0,l&&xa(l,t),l=this.avcSample=Wo(!1,i.pts,i.dts,"");break;case 12:d=!0;break;default:d=!1,l&&(l.debug+="unknown NAL "+p.type+" ");break}l&&d&&l.units.push(p)}),n&&l&&(xa(l,t),this.avcSample=null)}getLastNalUnit(t){var e;let i=this.avcSample,n;if((!i||i.units.length===0)&&(i=t[t.length-1]),(e=i)!=null&&e.units){const o=i.units;n=o[o.length-1]}return n}parseAVCNALu(t,e){const i=e.byteLength;let n=t.naluState||0;const o=n,l=[];let d=0,f,p,g,v=-1,A=0;for(n===-1&&(v=0,A=e[0]&31,n=0,d=1);d<i;){if(f=e[d++],!n){n=f?0:1;continue}if(n===1){n=f?0:2;continue}if(!f)n=3;else if(f===1){if(v>=0){const E={data:e.subarray(v,d-n-1),type:A};l.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-n-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,A=g,n=0):n=-1}else n=0}if(v>=0&&n>=0){const E={data:e.subarray(v,i),type:A,state:n};l.push(E)}if(l.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=n,l}parseAACPES(t,e){let i=0;const n=this.aacOverFlow;let o=e.data;if(n){this.aacOverFlow=null;const v=n.missing,A=n.sample.unit.byteLength;if(v===-1){const E=new Uint8Array(A+o.byteLength);E.set(n.sample.unit,0),E.set(o,A),o=E}else{const E=A-v;n.sample.unit.set(o.subarray(0,v),E),t.samples.push(n.sample),i=n.missing}}let l,d;for(l=i,d=o.length;l<d-1&&!Vo(o,l);l++);if(l!==i){let v;const A=l<d-1;A?v=`AAC PES did not start with ADTS header,offset:${l}`:v="No ADTS header found in AAC PES";const E=new Error(v);if(X.warn(`parsing error: ${v}`),this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.FRAG_PARSING_ERROR,fatal:!1,levelRetry:A,error:E,reason:v}),!A)return}nf(t,this.observer,o,l,this.audioCodec);let f;if(e.pts!==void 0)f=e.pts;else if(n){const v=af(t.samplerate);f=n.sample.pts+v}else{X.warn("[tsdemuxer]: AAC PES unknown PTS");return}let p=0,g;for(;l<d;)if(g=of(t,o,l,f,p),l+=g.length,g.missing){this.aacOverFlow=g;break}else for(p++;l<d-1&&!Vo(o,l);l++);}parseMPEGPES(t,e){const i=e.data,n=i.length;let o=0,l=0;const d=e.pts;if(d===void 0){X.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<n;)if(hf(i,l)){const f=lf(t,i,l,d,o);if(f)l+=f.length,o++;else break}else l++}parseID3PES(t,e){if(e.pts===void 0){X.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=ui({},e,{type:this._avcTrack?Sr.emsg:Sr.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function Wo(s,t,e,i){return{key:s,frame:!1,pts:t,dts:e,units:[],debug:i,length:0}}function Gc(s,t){return((s[t+1]&31)<<8)+s[t+2]}function Eb(s,t){return(s[t+10]&31)<<8|s[t+11]}function Tb(s,t,e,i){const n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},o=(s[t+1]&15)<<8|s[t+2],l=t+3+o-4,d=(s[t+10]&15)<<8|s[t+11];for(t+=12+d;t<l;){const f=Gc(s,t);switch(s[t]){case 207:if(!i){X.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:n.audio===-1&&(n.audio=f);break;case 21:n.id3===-1&&(n.id3=f);break;case 219:if(!i){X.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:n.avc===-1&&(n.avc=f);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?X.log("MPEG audio found, not supported in this browser"):n.audio===-1&&(n.audio=f,n.segmentCodec="mp3");break;case 36:X.warn("Unsupported HEVC stream type found");break}t+=((s[t+3]&15)<<8|s[t+4])+5}return n}function Dn(s){let t=0,e,i,n,o,l;const d=s.data;if(!s||s.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>s.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?(l=(e[14]&14)*536870912+(e[15]&255)*4194304+(e[16]&254)*16384+(e[17]&255)*128+(e[18]&254)/2,o-l>54e5&&(X.warn(`${Math.round((o-l)/9e4)}s delta between PTS and DTS, align them`),o=l)):l=o),n=e[8];let p=n+9;if(s.size<=p)return null;s.size-=p;const g=new Uint8Array(s.size);for(let v=0,A=d.length;v<A;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-=n+3),{data:g,pts:o,dts:l,len:i}}return null}function xa(s,t){if(s.units.length&&s.frame){if(s.pts===void 0){const e=t.samples,i=e.length;if(i){const n=e[i-1];s.pts=n.pts,s.dts=n.dts}else{t.dropped++;return}}t.samples.push(s)}s.debug.length&&X.log(s.pts+"/"+s.dts+":"+s.debug)}class kb extends ef{resetInitSegment(t,e,i,n){super.resetInitSegment(t,e,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(Do(t,0)||[]).length;for(let i=t.length;e<i;e++)if(bb(t,e))return X.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return yb(t,e)}appendFrame(t,e,i){if(this.basePTS!==null)return lf(t,e,i,this.basePTS,this.frameIndex)}}class uf{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 _s=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 n=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 l=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,l,f,l,d),st.DINF=st.box(st.types.dinf,st.box(st.types.dref,n))}static box(t,...e){let i=8,n=e.length;const o=n;for(;n--;)i+=e[n].byteLength;const l=new Uint8Array(i);for(l[0]=i>>24&255,l[1]=i>>16&255,l[2]=i>>8&255,l[3]=i&255,l.set(t,4),n=0,i=8;n<o;n++)l.set(e[n],i),i+=e[n].byteLength;return l}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/(_s+1)),n=Math.floor(e%(_s+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,n>>24,n>>16&255,n>>8&255,n&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/(_s+1)),n=Math.floor(e%(_s+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,n>>24,n>>16&255,n>>8&255,n&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 n,o;for(n=0;n<e.length;n++)o=e[n].flags,i[n+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=[],n,o,l;for(n=0;n<t.sps.length;n++)o=t.sps[n],l=o.byteLength,e.push(l>>>8&255),e.push(l&255),e=e.concat(Array.prototype.slice.call(o));for(n=0;n<t.pps.length;n++)o=t.pps[n],l=o.byteLength,i.push(l>>>8&255),i.push(l&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,n=t.width,o=t.height,l=Math.floor(i/(_s+1)),d=Math.floor(i%(_s+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,l>>24,l>>16&255,l>>8&255,l&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,n>>8&255,n&255,0,0,o>>8&255,o&255,0,0]))}static traf(t,e){const i=st.sdtp(t),n=t.id,o=Math.floor(e/(_s+1)),l=Math.floor(e%(_s+1));return st.box(st.types.traf,st.box(st.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255])),st.box(st.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,l>>24,l>>16&255,l>>8&255,l&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||[],n=i.length,o=12+16*n,l=new Uint8Array(o);let d,f,p,g,v,A;for(e+=8+o,l.set([t.type==="video"?1:0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,n&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),d=0;d<n;d++)f=i[d],p=f.duration,g=f.size,v=f.flags,A=f.cts,l.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,A>>>24&255,A>>>16&255,A>>>8&255,A&255],12+16*d);return st.box(st.types.trun,l)}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 ff=9e4;function Vc(s,t,e=1,i=!1){const n=s*t*e;return i?Math.round(n):n}function wb(s,t,e=1,i=!1){return Vc(s,t,1/e,i)}function Pa(s,t=!1){return Vc(s,1e3,1/ff,t)}function Sb(s,t=1){return Vc(s,ff,1/t)}const Rb=10*1e3,pf=1024,_b=1152;let jo=null,Hc=null;class Wc{constructor(t,e,i,n=""){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,jo===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);jo=o?parseInt(o[1]):0}if(Hc===null){const o=navigator.userAgent.match(/Safari\/(\d+)/i);Hc=o?parseInt(o[1]):0}}destroy(){}resetTimeStamp(t){X.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){X.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){X.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const i=t.reduce((n,o)=>{const l=o.pts-n;return l<-4294967296?(e=!0,pr(n,o.pts)):l>0?n:o.pts},t[0].pts);return e&&X.debug("PTS rollover detected"),i}remux(t,e,i,n,o,l,d,f){let p,g,v,A,E,T,w=o,C=o;const x=t.pid>-1,O=e.pid>-1,U=e.samples.length,D=t.samples.length>0,H=d&&U>0||U>1;if((!x||D)&&(!O||H)||this.ISGenerated||d){this.ISGenerated||(v=this.generateIS(t,e,o,l));const $=this.isVideoContiguous;let z=-1,tt;if(H&&(z=Lb(e.samples),!$&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,z>0){X.warn(`[mp4-remuxer]: Dropped ${z} out of ${U} video samples due to a missing keyframe`);const at=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(z),e.dropped+=z,C+=(e.samples[0].pts-at)/e.inputTimeScale,tt=C}else z===-1&&(X.warn(`[mp4-remuxer]: No keyframe found out of ${U} video samples`),T=!1);if(this.ISGenerated){if(D&&H){const at=this.getVideoStartPts(e.samples),J=(pr(t.samples[0].pts,at)-at)/e.inputTimeScale;w+=Math.max(0,J),C+=Math.max(0,-J)}if(D){if(t.samplerate||(X.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),v=this.generateIS(t,e,o,l)),g=this.remuxAudio(t,w,this.isAudioContiguous,l,O||H||f===Jt.AUDIO?C:void 0),H){const at=g?g.endPTS-g.startPTS:0;e.inputTimeScale||(X.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),v=this.generateIS(t,e,o,l)),p=this.remuxVideo(e,C,$,at)}}else H&&(p=this.remuxVideo(e,C,$,0));p&&(p.firstKeyFrame=z,p.independent=z!==-1,p.firstKeyFramePTS=tt)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(E=gf(i,o,this._initPTS,this._initDTS)),n.samples.length&&(A=mf(n,o,this._initPTS))),{audio:g,video:p,initSegment:v,independent:T,text:A,id3:E}}generateIS(t,e,i,n){const o=t.samples,l=e.samples,d=this.typeSupported,f={},p=this._initPTS;let g=!p||n,v="audio/mp4",A,E,T;if(g&&(A=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?A=E=o[0].pts-Math.round(T*i):g=!1)}if(e.sps&&e.pps&&l.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(l),C=Math.round(T*i);E=Math.min(E,pr(l[0].dts,w)-C),A=Math.min(A,w-C)}else g=!1;if(Object.keys(f).length)return this.ISGenerated=!0,g?(this._initPTS={baseTime:A,timescale:T},this._initDTS={baseTime:E,timescale:T}):A=T=void 0,{tracks:f,initPTS:A,timescale:T}}remuxVideo(t,e,i,n){const o=t.inputTimeScale,l=t.samples,d=[],f=l.length,p=this._initPTS;let g=this.nextAvcDts,v=8,A=this.videoSampleDuration,E,T,w=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,x=!1;if(!i||g===null){const N=e*o,F=l[0].pts-pr(l[0].dts,l[0].pts);g=N-F}const O=p.baseTime*o/p.timescale;for(let N=0;N<f;N++){const F=l[N];F.pts=pr(F.pts-O,g),F.dts=pr(F.dts-O,g),F.dts<l[N>0?N-1:N].dts&&(x=!0)}x&&l.sort(function(N,F){const j=N.dts-F.dts,nt=N.pts-F.pts;return j||nt}),E=l[0].dts,T=l[l.length-1].dts;const U=T-E,D=U?Math.round(U/(f-1)):A||t.inputTimeScale/30;if(i){const N=E-g,F=N>D,j=N<-1;if((F||j)&&(F?X.warn(`AVC: ${Pa(N,!0)} ms (${N}dts) hole between fragments detected, filling it`):X.warn(`AVC: ${Pa(-N,!0)} ms (${N}dts) overlapping between fragments detected`),!j||g>=l[0].pts)){E=g;const nt=l[0].pts-N;l[0].dts=E,l[0].pts=nt,X.log(`Video: First PTS/DTS adjusted: ${Pa(nt,!0)}/${Pa(E,!0)}, delta: ${Pa(N,!0)} ms`)}}E=Math.max(0,E);let H=0,$=0;for(let N=0;N<f;N++){const F=l[N],j=F.units,nt=j.length;let ct=0;for(let Lt=0;Lt<nt;Lt++)ct+=j[Lt].data.length;$+=ct,H+=nt,F.length=ct,F.dts=Math.max(F.dts,E),w=Math.min(F.pts,w),C=Math.max(F.pts,C)}T=l[f-1].dts;const z=$+4*H+8;let tt;try{tt=new Uint8Array(z)}catch(N){this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MUX_ERROR,details:pt.REMUX_ALLOC_ERROR,fatal:!1,error:N,bytes:z,reason:`fail allocating video mdat ${z}`});return}const at=new DataView(tt.buffer);at.setUint32(0,z),tt.set(st.types.mdat,4);let J=!1,St=Number.POSITIVE_INFINITY,mt=Number.POSITIVE_INFINITY,Ot=Number.NEGATIVE_INFINITY,Vt=Number.NEGATIVE_INFINITY;for(let N=0;N<f;N++){const F=l[N],j=F.units;let nt=0;for(let Nt=0,jt=j.length;Nt<jt;Nt++){const fe=j[Nt],ve=fe.data,me=fe.data.byteLength;at.setUint32(v,me),v+=4,tt.set(ve,v),v+=me,nt+=4+me}let ct;if(N<f-1)A=l[N+1].dts-F.dts,ct=l[N+1].pts-F.pts;else{const Nt=this.config,jt=N>0?F.dts-l[N-1].dts:D;if(ct=N>0?F.pts-l[N-1].pts:D,Nt.stretchShortVideoTrack&&this.nextAudioPts!==null){const fe=Math.floor(Nt.maxBufferHole*o),ve=(n?w+n*o:this.nextAudioPts)-F.pts;ve>fe?(A=ve-jt,A<0?A=jt:J=!0,X.log(`[mp4-remuxer]: It is approximately ${ve/90} ms to the next segment; using duration ${A/90} ms for the last video frame.`)):A=jt}else A=jt}const Lt=Math.round(F.pts-F.dts);St=Math.min(St,A),Ot=Math.max(Ot,A),mt=Math.min(mt,ct),Vt=Math.max(Vt,ct),d.push(new vf(F.key,A,nt,Lt))}if(d.length){if(jo){if(jo<70){const N=d[0].flags;N.dependsOn=2,N.isNonSync=0}}else if(Hc&&Vt-mt<Ot-St&&D/Ot<.025&&d[0].cts===0){X.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let N=E;for(let F=0,j=d.length;F<j;F++){const nt=N+d[F].duration,ct=N+d[F].cts;if(F<j-1){const Lt=nt+d[F+1].cts;d[F].duration=Lt-ct}else d[F].duration=F?d[F-1].duration:D;d[F].cts=0,N=nt}}}A=J||!A?D:A,this.nextAvcDts=g=T+A,this.videoSampleDuration=A,this.isVideoContiguous=!0;const G=st.moof(t.sequenceNumber++,E,ui({},t,{samples:d})),q="video",At={data1:G,data2:tt,startPTS:w/o,endPTS:(C+A)/o,startDTS:E/o,endDTS:g/o,type:q,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:t.dropped};return t.samples=[],t.dropped=0,At}remuxAudio(t,e,i,n,o){const l=t.inputTimeScale,d=t.samplerate?t.samplerate:l,f=l/d,p=t.segmentCodec==="aac"?pf:_b,g=p*f,v=this._initPTS,A=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,E=[],T=o!==void 0;let w=t.samples,C=A?0:8,x=this.nextAudioPts||-1;const O=e*l,U=v.baseTime*l/v.timescale;if(this.isAudioContiguous=i=i||w.length&&x>0&&(n&&Math.abs(O-x)<9e3||Math.abs(pr(w[0].pts-U,O)-x)<20*g),w.forEach(function(G){G.pts=pr(G.pts-U,O)}),!i||x<0){if(w=w.filter(G=>G.pts>=0),!w.length)return;o===0?x=0:n&&!T?x=Math.max(0,O):x=w[0].pts}if(t.segmentCodec==="aac"){const G=this.config.maxAudioFramesDrift;for(let q=0,At=x;q<w.length;q++){const N=w[q],F=N.pts,j=F-At,nt=Math.abs(1e3*j/l);if(j<=-G*g&&T)q===0&&(X.warn(`Audio frame @ ${(F/l).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*j/l)} ms.`),this.nextAudioPts=x=At=F);else if(j>=G*g&&nt<Rb&&T){let ct=Math.round(j/g);At=F-ct*g,At<0&&(ct--,At+=g),q===0&&(this.nextAudioPts=x=At),X.warn(`[mp4-remuxer]: Injecting ${ct} audio frame @ ${(At/l).toFixed(3)}s due to ${Math.round(1e3*j/l)} ms gap.`);for(let Lt=0;Lt<ct;Lt++){const Nt=Math.max(At,0);let jt=uf.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);jt||(X.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),jt=N.unit.subarray()),w.splice(q,0,{unit:jt,pts:Nt}),At+=g,q++}}N.pts=At,At+=g}}let D=null,H=null,$,z=0,tt=w.length;for(;tt--;)z+=w[tt].unit.byteLength;for(let G=0,q=w.length;G<q;G++){const At=w[G],N=At.unit;let F=At.pts;if(H!==null){const nt=E[G-1];nt.duration=Math.round((F-H)/f)}else if(i&&t.segmentCodec==="aac"&&(F=x),D=F,z>0){z+=C;try{$=new Uint8Array(z)}catch(nt){this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MUX_ERROR,details:pt.REMUX_ALLOC_ERROR,fatal:!1,error:nt,bytes:z,reason:`fail allocating audio mdat ${z}`});return}A||(new DataView($.buffer).setUint32(0,z),$.set(st.types.mdat,4))}else return;$.set(N,C);const j=N.byteLength;C+=j,E.push(new vf(!0,p,j,0)),H=F}const at=E.length;if(!at)return;const J=E[E.length-1];this.nextAudioPts=x=H+f*J.duration;const St=A?new Uint8Array(0):st.moof(t.sequenceNumber++,D/f,ui({},t,{samples:E}));t.samples=[];const mt=D/l,Ot=x/l,Vt={data1:St,data2:$,startPTS:mt,endPTS:Ot,startDTS:mt,endDTS:Ot,type:"audio",hasAudio:!0,hasVideo:!1,nb:at};return this.isAudioContiguous=!0,Vt}remuxEmptyAudio(t,e,i,n){const o=t.inputTimeScale,l=t.samplerate?t.samplerate:o,d=o/l,f=this.nextAudioPts,p=this._initDTS,g=p.baseTime*9e4/p.timescale,v=(f!==null?f:n.startDTS*o)+g,A=n.endDTS*o+g,E=d*pf,T=Math.ceil((A-v)/E),w=uf.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(X.warn("[mp4-remuxer]: remux empty Audio"),!w){X.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const C=[];for(let x=0;x<T;x++){const O=v+x*E;C.push({unit:w,pts:O,dts:O})}return t.samples=C,this.remuxAudio(t,e,i,!1)}}function pr(s,t){let e;if(t===null)return s;for(t<s?e=-8589934592:e=8589934592;Math.abs(s-t)>4294967296;)s+=e;return s}function Lb(s){for(let t=0;t<s.length;t++)if(s[t].key)return t;return-1}function gf(s,t,e,i){const n=s.samples.length;if(!n)return;const o=s.inputTimeScale;for(let d=0;d<n;d++){const f=s.samples[d];f.pts=pr(f.pts-e.baseTime*o/e.timescale,t*o)/o,f.dts=pr(f.dts-i.baseTime*o/i.timescale,t*o)/o}const l=s.samples;return s.samples=[],{samples:l}}function mf(s,t,e){const i=s.samples.length;if(!i)return;const n=s.inputTimeScale;for(let l=0;l<i;l++){const d=s.samples[l];d.pts=pr(d.pts-e.baseTime*n/e.timescale,t*n)/n}s.samples.sort((l,d)=>l.pts-d.pts);const o=s.samples;return s.samples=[],{samples:o}}class vf{constructor(t,e,i,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=i,this.cts=n,this.flags=new Cb(t)}}class Cb{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 Ib{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,n){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(Zv(t,n)),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 n=this.initData=y0(t);e||(e=yf(n.audio,De.AUDIO)),i||(i=yf(n.video,De.VIDEO));const o={};n.audio&&n.video?o.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:n.audio?o.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:n.video?o.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:X.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(t,e,i,n,o,l){var d,f;let{initPTS:p,lastEndTime:g}=this;const v={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};Wt(g)||(g=this.lastEndTime=o||0);const A=e.samples;if(!(A!=null&&A.length))return v;const E={initPTS:void 0,timescale:1};let T=this.initData;if((d=T)!=null&&d.length||(this.generateInitSegment(A),T=this.initData),!((f=T)!=null&&f.length))return X.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),v;this.emitInitSegment&&(E.tracks=this.initTracks,this.emitInitSegment=!1);const w=Qv(A,T),C=qv(T,A),x=C===null?o:C;(Db(p,x,o,w)||E.timescale!==p.timescale&&l)&&(E.initPTS=x-o,p&&p.timescale===1&&X.warn(`Adjusting initPTS by ${E.initPTS-p.baseTime}`),this.initPTS=p={baseTime:E.initPTS,timescale:1});const O=t?x-p.baseTime/p.timescale:g,U=O+w;ty(T,A,p.baseTime/p.timescale),w>0?this.lastEndTime=U:(X.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const D=!!T.audio,H=!!T.video;let $="";D&&($+="audio"),H&&($+="video");const z={data1:A,startPTS:O,startDTS:O,endPTS:U,endDTS:U,type:$,hasAudio:D,hasVideo:H,nb:1,dropped:0};return v.audio=z.type==="audio"?z:void 0,v.video=z.type!=="audio"?z:void 0,v.initSegment=E,v.id3=gf(i,o,p,p),n.samples.length&&(v.text=mf(n,o,p)),v}}function Db(s,t,e,i){if(s===null)return!0;const n=Math.max(i,1),o=t-s.baseTime/s.timescale;return Math.abs(o-e)>n}function yf(s,t){const e=s==null?void 0:s.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||t===De.VIDEO?"avc1.42e01e":"mp4a.40.5"}let as;try{as=self.performance.now.bind(self.performance)}catch{X.debug("Unable to use Performance API on this environment"),as=typeof self<"u"&&self.Date.now}const jc=[{demux:fb,remux:Ib},{demux:Rs,remux:Wc},{demux:db,remux:Wc},{demux:kb,remux:Wc}];class bf{constructor(t,e,i,n,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=n,this.id=o}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,i,n){const o=i.transmuxing;o.executeStart=as();let l=new Uint8Array(t);const{currentTransmuxState:d,transmuxConfig:f}=this;n&&(this.currentTransmuxState=n);const{contiguous:p,discontinuity:g,trackSwitch:v,accurateTimeOffset:A,timeOffset:E,initSegmentChange:T}=n||d,{audioCodec:w,videoCodec:C,defaultInitPts:x,duration:O,initSegmentData:U}=f,D=xb(l,e);if(D&&D.method==="AES-128"){const tt=this.getDecrypter();if(tt.isSync()){let at=tt.softwareDecrypt(l,D.key.buffer,D.iv.buffer);if(i.part>-1&&(at=tt.flush()),!at)return o.executeEnd=as(),Kc(i);l=new Uint8Array(at)}else return this.decryptionPromise=tt.webCryptoDecrypt(l,D.key.buffer,D.iv.buffer).then(at=>{const J=this.push(at,null,i);return this.decryptionPromise=null,J}),this.decryptionPromise}const H=this.needsProbing(g,v);if(H){const tt=this.configureTransmuxer(l);if(tt)return X.warn(`[transmuxer] ${tt.message}`),this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.FRAG_PARSING_ERROR,fatal:!1,error:tt,reason:tt.message}),o.executeEnd=as(),Kc(i)}(g||v||T||H)&&this.resetInitSegment(U,w,C,O,e),(g||T||H)&&this.resetInitialTimestamp(x),p||this.resetContiguity();const $=this.transmux(l,D,E,A,i),z=this.currentTransmuxState;return z.contiguous=!0,z.discontinuity=!1,z.trackSwitch=!1,o.executeEnd=as(),$}flush(t){const e=t.transmuxing;e.executeStart=as();const{decrypter:i,currentTransmuxState:n,decryptionPromise:o}=this;if(o)return o.then(()=>this.flush(t));const l=[],{timeOffset:d}=n;if(i){const v=i.flush();v&&l.push(this.push(v,null,t))}const{demuxer:f,remuxer:p}=this;if(!f||!p)return e.executeEnd=as(),[Kc(t)];const g=f.flush(d);return Ko(g)?g.then(v=>(this.flushRemux(l,v,t),l)):(this.flushRemux(l,g,t),l)}flushRemux(t,e,i){const{audioTrack:n,videoTrack:o,id3Track:l,textTrack:d}=e,{accurateTimeOffset:f,timeOffset:p}=this.currentTransmuxState;X.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const g=this.remuxer.remux(n,o,l,d,p,f,!0,this.id);t.push({remuxResult:g,chunkMeta:i}),i.transmuxing.executeEnd=as()}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,n,o){const{demuxer:l,remuxer:d}=this;!l||!d||(l.resetInitSegment(t,e,i,n),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,n,o){let l;return e&&e.method==="SAMPLE-AES"?l=this.transmuxSampleAes(t,e,i,n,o):l=this.transmuxUnencrypted(t,i,n,o),l}transmuxUnencrypted(t,e,i,n){const{audioTrack:o,videoTrack:l,id3Track:d,textTrack:f}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(o,l,d,f,e,i,!1,this.id),chunkMeta:n}}transmuxSampleAes(t,e,i,n,o){return this.demuxer.demuxSampleAes(t,e,i).then(l=>({remuxResult:this.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,i,n,!1,this.id),chunkMeta:o}))}configureTransmuxer(t){const{config:e,observer:i,typeSupported:n,vendor:o}=this;let l;for(let v=0,A=jc.length;v<A;v++)if(jc[v].demux.probe(t)){l=jc[v];break}if(!l)return new Error("Failed to find demuxer by probing fragment data");const d=this.demuxer,f=this.remuxer,p=l.remux,g=l.demux;(!f||!(f instanceof p))&&(this.remuxer=new p(i,e,n,o)),(!d||!(d instanceof g))&&(this.demuxer=new g(i,e,n),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 Fc(this.config)),t}}function xb(s,t){let e=null;return s.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(e=t),e}const Kc=s=>({remuxResult:{},chunkMeta:s});function Ko(s){return"then"in s&&s.then instanceof Function}class Pb{constructor(t,e,i,n,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=n,this.defaultInitPts=o||null}}class Ob{constructor(t,e,i,n,o,l){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=n,this.timeOffset=o,this.initSegmentChange=l}}var Af={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function n(f,p,g){this.fn=f,this.context=p,this.once=g||!1}function o(f,p,g,v,A){if(typeof g!="function")throw new TypeError("The listener must be a function");var E=new n(g,v||f,A),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 l(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,A=g.length,E=new Array(A);v<A;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,A,E){var T=e?e+f:f;if(!this._events[T])return!1;var w=this._events[T],C=arguments.length,x,O;if(w.fn){switch(w.once&&this.removeListener(f,w.fn,void 0,!0),C){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,A),!0;case 6:return w.fn.call(w.context,p,g,v,A,E),!0}for(O=1,x=new Array(C-1);O<C;O++)x[O-1]=arguments[O];w.fn.apply(w.context,x)}else{var U=w.length,D;for(O=0;O<U;O++)switch(w[O].once&&this.removeListener(f,w[O].fn,void 0,!0),C){case 1:w[O].fn.call(w[O].context);break;case 2:w[O].fn.call(w[O].context,p);break;case 3:w[O].fn.call(w[O].context,p,g);break;case 4:w[O].fn.call(w[O].context,p,g,v);break;default:if(!x)for(D=1,x=new Array(C-1);D<C;D++)x[D-1]=arguments[D];w[O].fn.apply(w[O].context,x)}}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 A=e?e+f:f;if(!this._events[A])return this;if(!p)return l(this,A),this;var E=this._events[A];if(E.fn)E.fn===p&&(!v||E.once)&&(!g||E.context===g)&&l(this,A);else{for(var T=0,w=[],C=E.length;T<C;T++)(E[T].fn!==p||v&&!E[T].once||g&&E[T].context!==g)&&w.push(E[T]);w.length?this._events[A]=w.length===1?w[0]:w:l(this,A)}return this},d.prototype.removeAllListeners=function(f){var p;return f?(p=e?e+f:f,this._events[p]&&l(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,s.exports=d})(Af);var Mb=Af.exports,zc=Av(Mb);const Yc=Mo()||{isTypeSupported:()=>!1};class Ef{constructor(t,e,i,n){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=n;const l=(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 zc,this.observer.on(R.FRAG_DECRYPTED,l),this.observer.on(R.ERROR,l);const d={mp4:Yc.isTypeSupported("video/mp4"),mpeg:Yc.isTypeSupported("audio/mpeg"),mp3:Yc.isTypeSupported('audio/mp4; codecs="mp3"')},f=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(o.workerPath||ib())){try{o.workerPath?(X.log(`loading Web Worker ${o.workerPath} for "${e}"`),this.workerContext=sb(o.workerPath)):(X.log(`injecting Web Worker for "${e}"`),this.workerContext=rb()),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,X.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(R.ERROR,{type:Qt.OTHER_ERROR,details:pt.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:v})},p.postMessage({cmd:"init",typeSupported:d,vendor:f,id:e,config:JSON.stringify(o)})}catch(p){X.warn(`Error setting up "${e}" Web Worker, fallback to inline`,p),this.resetWorker(),this.error=null,this.transmuxer=new bf(this.observer,d,o,f,e)}return}this.transmuxer=new bf(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,n,o,l,d,f,p,g){var v,A;p.transmuxing.start=self.performance.now();const{transmuxer:E}=this,T=l?l.start:o.start,w=o.decryptdata,C=this.frag,x=!(C&&o.cc===C.cc),O=!(C&&p.level===C.level),U=C?p.sn-C.sn:-1,D=this.part?p.part-this.part.index:-1,H=U===0&&p.id>1&&p.id===(C==null?void 0:C.stats.chunkCount),$=!O&&(U===1||U===0&&(D===1||H&&D<=0)),z=self.performance.now();(O||U||o.stats.parsing.start===0)&&(o.stats.parsing.start=z),l&&(D||!$)&&(l.stats.parsing.start=z);const tt=!(C&&((v=o.initSegment)==null?void 0:v.url)===((A=C.initSegment)==null?void 0:A.url)),at=new Ob(x,$,f,O,T,tt);if(!$||x||tt){X.log(`[transmuxer-interface, ${o.type}]: Starting new transmux session for sn: ${p.sn} p: ${p.part} level: ${p.level} id: ${p.id}
184
- discontinuity: ${x}
185
- trackSwitch: ${O}
183
+ */const yu=(s,t,e)=>{const i=new Map;for(let n=t;n<=e;n++)i.set(s[n],n);return i},bu=Tn(class extends la{constructor(s){if(super(s),s.type!==En.CHILD)throw Error("repeat() can only be used in text expressions")}ht(s,t,e){let i;e===void 0?e=t:t!==void 0&&(i=t);const n=[],o=[];let l=0;for(const d of s)n[l]=i?i(d,l):l,o[l]=e(d,l),l++;return{values:o,keys:n}}render(s,t,e){return this.ht(s,t,e).values}update(s,[t,e,i]){const n=mg(s),{values:o,keys:l}=this.ht(t,e,i);if(!Array.isArray(n))return this.dt=l,o;const d=this.dt??(this.dt=[]),f=[];let p,g,v=0,A=n.length-1,E=0,T=o.length-1;for(;v<=A&&E<=T;)if(n[v]===null)v++;else if(n[A]===null)A--;else if(d[v]===l[E])f[E]=tn(n[v],o[E]),v++,E++;else if(d[A]===l[T])f[T]=tn(n[A],o[T]),A--,T--;else if(d[v]===l[T])f[T]=tn(n[v],o[T]),oa(s,f[T+1],n[v]),v++,T--;else if(d[A]===l[E])f[E]=tn(n[A],o[E]),oa(s,n[v],n[A]),A--,E++;else if(p===void 0&&(p=yu(l,E,T),g=yu(d,v,A)),p.has(d[v]))if(p.has(d[A])){const w=g.get(l[E]),C=w!==void 0?n[w]:null;if(C===null){const D=oa(s,n[v]);tn(D,o[E]),f[E]=D}else f[E]=tn(C,o[E]),oa(s,n[v],C),n[w]=null;E++}else Ol(n[A]),A--;else Ol(n[v]),v++;for(;E<=T;){const w=oa(s,f[T+1]);tn(w,o[E]),f[E++]=w}for(;v<=A;){const w=n[v++];w!==null&&Ol(w)}return this.dt=l,gg(s,f),ys}});var ji="top",hr="bottom",dr="right",Ki="left",Ql="auto",Aa=[ji,hr,dr,Ki],wn="start",Ea="end",jm="clippingParents",Au="viewport",Ta="popper",Km="reference",Eu=Aa.reduce(function(s,t){return s.concat([t+"-"+wn,t+"-"+Ea])},[]),Tu=[].concat(Aa,[Ql]).reduce(function(s,t){return s.concat([t,t+"-"+wn,t+"-"+Ea])},[]),Ym="beforeRead",zm="read",Xm="afterRead",Zm="beforeMain",qm="main",Qm="afterMain",Jm="beforeWrite",t1="write",e1="afterWrite",i1=[Ym,zm,Xm,Zm,qm,Qm,Jm,t1,e1];function Mr(s){return s?(s.nodeName||"").toLowerCase():null}function sr(s){if(s==null)return window;if(s.toString()!=="[object Window]"){var t=s.ownerDocument;return t&&t.defaultView||window}return s}function nn(s){var t=sr(s).Element;return s instanceof t||s instanceof Element}function ur(s){var t=sr(s).HTMLElement;return s instanceof t||s instanceof HTMLElement}function Jl(s){if(typeof ShadowRoot>"u")return!1;var t=sr(s).ShadowRoot;return s instanceof t||s instanceof ShadowRoot}function r1(s){var t=s.state;Object.keys(t.elements).forEach(function(e){var i=t.styles[e]||{},n=t.attributes[e]||{},o=t.elements[e];!ur(o)||!Mr(o)||(Object.assign(o.style,i),Object.keys(n).forEach(function(l){var d=n[l];d===!1?o.removeAttribute(l):o.setAttribute(l,d===!0?"":d)}))})}function s1(s){var t=s.state,e={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,e.popper),t.styles=e,t.elements.arrow&&Object.assign(t.elements.arrow.style,e.arrow),function(){Object.keys(t.elements).forEach(function(i){var n=t.elements[i],o=t.attributes[i]||{},l=Object.keys(t.styles.hasOwnProperty(i)?t.styles[i]:e[i]),d=l.reduce(function(f,p){return f[p]="",f},{});!ur(n)||!Mr(n)||(Object.assign(n.style,d),Object.keys(o).forEach(function(f){n.removeAttribute(f)}))})}}const ku={name:"applyStyles",enabled:!0,phase:"write",fn:r1,effect:s1,requires:["computeStyles"]};function $r(s){return s.split("-")[0]}var an=Math.max,wo=Math.min,Sn=Math.round;function tc(){var s=navigator.userAgentData;return s!=null&&s.brands&&Array.isArray(s.brands)?s.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function wu(){return!/^((?!chrome|android).)*safari/i.test(tc())}function Rn(s,t,e){t===void 0&&(t=!1),e===void 0&&(e=!1);var i=s.getBoundingClientRect(),n=1,o=1;t&&ur(s)&&(n=s.offsetWidth>0&&Sn(i.width)/s.offsetWidth||1,o=s.offsetHeight>0&&Sn(i.height)/s.offsetHeight||1);var l=nn(s)?sr(s):window,d=l.visualViewport,f=!wu()&&e,p=(i.left+(f&&d?d.offsetLeft:0))/n,g=(i.top+(f&&d?d.offsetTop:0))/o,v=i.width/n,A=i.height/o;return{width:v,height:A,top:g,right:p+v,bottom:g+A,left:p,x:p,y:g}}function ec(s){var t=Rn(s),e=s.offsetWidth,i=s.offsetHeight;return Math.abs(t.width-e)<=1&&(e=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:s.offsetLeft,y:s.offsetTop,width:e,height:i}}function Su(s,t){var e=t.getRootNode&&t.getRootNode();if(s.contains(t))return!0;if(e&&Jl(e)){var i=t;do{if(i&&s.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function ss(s){return sr(s).getComputedStyle(s)}function n1(s){return["table","td","th"].indexOf(Mr(s))>=0}function Ss(s){return((nn(s)?s.ownerDocument:s.document)||window.document).documentElement}function So(s){return Mr(s)==="html"?s:s.assignedSlot||s.parentNode||(Jl(s)?s.host:null)||Ss(s)}function Ru(s){return!ur(s)||ss(s).position==="fixed"?null:s.offsetParent}function a1(s){var t=/firefox/i.test(tc()),e=/Trident/i.test(tc());if(e&&ur(s)){var i=ss(s);if(i.position==="fixed")return null}var n=So(s);for(Jl(n)&&(n=n.host);ur(n)&&["html","body"].indexOf(Mr(n))<0;){var o=ss(n);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 n;n=n.parentNode}return null}function ka(s){for(var t=sr(s),e=Ru(s);e&&n1(e)&&ss(e).position==="static";)e=Ru(e);return e&&(Mr(e)==="html"||Mr(e)==="body"&&ss(e).position==="static")?t:e||a1(s)||t}function ic(s){return["top","bottom"].indexOf(s)>=0?"x":"y"}function wa(s,t,e){return an(s,wo(t,e))}function o1(s,t,e){var i=wa(s,t,e);return i>e?e:i}function Lu(){return{top:0,right:0,bottom:0,left:0}}function _u(s){return Object.assign({},Lu(),s)}function Cu(s,t){return t.reduce(function(e,i){return e[i]=s,e},{})}var l1=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,_u(typeof t!="number"?t:Cu(t,Aa))};function c1(s){var t,e=s.state,i=s.name,n=s.options,o=e.elements.arrow,l=e.modifiersData.popperOffsets,d=$r(e.placement),f=ic(d),p=[Ki,dr].indexOf(d)>=0,g=p?"height":"width";if(!(!o||!l)){var v=l1(n.padding,e),A=ec(o),E=f==="y"?ji:Ki,T=f==="y"?hr:dr,w=e.rects.reference[g]+e.rects.reference[f]-l[f]-e.rects.popper[g],C=l[f]-e.rects.reference[f],D=ka(o),M=D?f==="y"?D.clientHeight||0:D.clientWidth||0:0,U=w/2-C/2,x=v[E],G=M-A[g]-v[T],$=M/2-A[g]/2+U,Y=wa(x,$,G),tt=f;e.modifiersData[i]=(t={},t[tt]=Y,t.centerOffset=Y-$,t)}}function h1(s){var t=s.state,e=s.options,i=e.element,n=i===void 0?"[data-popper-arrow]":i;n!=null&&(typeof n=="string"&&(n=t.elements.popper.querySelector(n),!n)||Su(t.elements.popper,n)&&(t.elements.arrow=n))}const d1={name:"arrow",enabled:!0,phase:"main",fn:c1,effect:h1,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Ln(s){return s.split("-")[1]}var u1={top:"auto",right:"auto",bottom:"auto",left:"auto"};function f1(s,t){var e=s.x,i=s.y,n=t.devicePixelRatio||1;return{x:Sn(e*n)/n||0,y:Sn(i*n)/n||0}}function Iu(s){var t,e=s.popper,i=s.popperRect,n=s.placement,o=s.variation,l=s.offsets,d=s.position,f=s.gpuAcceleration,p=s.adaptive,g=s.roundOffsets,v=s.isFixed,A=l.x,E=A===void 0?0:A,T=l.y,w=T===void 0?0:T,C=typeof g=="function"?g({x:E,y:w}):{x:E,y:w};E=C.x,w=C.y;var D=l.hasOwnProperty("x"),M=l.hasOwnProperty("y"),U=Ki,x=ji,G=window;if(p){var $=ka(e),Y="clientHeight",tt="clientWidth";if($===sr(e)&&($=Ss(e),ss($).position!=="static"&&d==="absolute"&&(Y="scrollHeight",tt="scrollWidth")),$=$,n===ji||(n===Ki||n===dr)&&o===Ea){x=hr;var nt=v&&$===G&&G.visualViewport?G.visualViewport.height:$[Y];w-=nt-i.height,w*=f?1:-1}if(n===Ki||(n===ji||n===hr)&&o===Ea){U=dr;var J=v&&$===G&&G.visualViewport?G.visualViewport.width:$[tt];E-=J-i.width,E*=f?1:-1}}var St=Object.assign({position:d},p&&u1),mt=g===!0?f1({x:E,y:w},sr(e)):{x:E,y:w};if(E=mt.x,w=mt.y,f){var Ot;return Object.assign({},St,(Ot={},Ot[x]=M?"0":"",Ot[U]=D?"0":"",Ot.transform=(G.devicePixelRatio||1)<=1?"translate("+E+"px, "+w+"px)":"translate3d("+E+"px, "+w+"px, 0)",Ot))}return Object.assign({},St,(t={},t[x]=M?w+"px":"",t[U]=D?E+"px":"",t.transform="",t))}function p1(s){var t=s.state,e=s.options,i=e.gpuAcceleration,n=i===void 0?!0:i,o=e.adaptive,l=o===void 0?!0:o,d=e.roundOffsets,f=d===void 0?!0:d,p={placement:$r(t.placement),variation:Ln(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:n,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,Iu(Object.assign({},p,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:l,roundOffsets:f})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,Iu(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 g1={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:p1,data:{}};var Ro={passive:!0};function m1(s){var t=s.state,e=s.instance,i=s.options,n=i.scroll,o=n===void 0?!0:n,l=i.resize,d=l===void 0?!0:l,f=sr(t.elements.popper),p=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&p.forEach(function(g){g.addEventListener("scroll",e.update,Ro)}),d&&f.addEventListener("resize",e.update,Ro),function(){o&&p.forEach(function(g){g.removeEventListener("scroll",e.update,Ro)}),d&&f.removeEventListener("resize",e.update,Ro)}}const v1={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:m1,data:{}};var y1={left:"right",right:"left",bottom:"top",top:"bottom"};function Lo(s){return s.replace(/left|right|bottom|top/g,function(t){return y1[t]})}var b1={start:"end",end:"start"};function xu(s){return s.replace(/start|end/g,function(t){return b1[t]})}function rc(s){var t=sr(s),e=t.pageXOffset,i=t.pageYOffset;return{scrollLeft:e,scrollTop:i}}function sc(s){return Rn(Ss(s)).left+rc(s).scrollLeft}function A1(s,t){var e=sr(s),i=Ss(s),n=e.visualViewport,o=i.clientWidth,l=i.clientHeight,d=0,f=0;if(n){o=n.width,l=n.height;var p=wu();(p||!p&&t==="fixed")&&(d=n.offsetLeft,f=n.offsetTop)}return{width:o,height:l,x:d+sc(s),y:f}}function E1(s){var t,e=Ss(s),i=rc(s),n=(t=s.ownerDocument)==null?void 0:t.body,o=an(e.scrollWidth,e.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),l=an(e.scrollHeight,e.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),d=-i.scrollLeft+sc(s),f=-i.scrollTop;return ss(n||e).direction==="rtl"&&(d+=an(e.clientWidth,n?n.clientWidth:0)-o),{width:o,height:l,x:d,y:f}}function nc(s){var t=ss(s),e=t.overflow,i=t.overflowX,n=t.overflowY;return/auto|scroll|overlay|hidden/.test(e+n+i)}function Du(s){return["html","body","#document"].indexOf(Mr(s))>=0?s.ownerDocument.body:ur(s)&&nc(s)?s:Du(So(s))}function Sa(s,t){var e;t===void 0&&(t=[]);var i=Du(s),n=i===((e=s.ownerDocument)==null?void 0:e.body),o=sr(i),l=n?[o].concat(o.visualViewport||[],nc(i)?i:[]):i,d=t.concat(l);return n?d:d.concat(Sa(So(l)))}function ac(s){return Object.assign({},s,{left:s.x,top:s.y,right:s.x+s.width,bottom:s.y+s.height})}function T1(s,t){var e=Rn(s,!1,t==="fixed");return e.top=e.top+s.clientTop,e.left=e.left+s.clientLeft,e.bottom=e.top+s.clientHeight,e.right=e.left+s.clientWidth,e.width=s.clientWidth,e.height=s.clientHeight,e.x=e.left,e.y=e.top,e}function Pu(s,t,e){return t===Au?ac(A1(s,e)):nn(t)?T1(t,e):ac(E1(Ss(s)))}function k1(s){var t=Sa(So(s)),e=["absolute","fixed"].indexOf(ss(s).position)>=0,i=e&&ur(s)?ka(s):s;return nn(i)?t.filter(function(n){return nn(n)&&Su(n,i)&&Mr(n)!=="body"}):[]}function w1(s,t,e,i){var n=t==="clippingParents"?k1(s):[].concat(t),o=[].concat(n,[e]),l=o[0],d=o.reduce(function(f,p){var g=Pu(s,p,i);return f.top=an(g.top,f.top),f.right=wo(g.right,f.right),f.bottom=wo(g.bottom,f.bottom),f.left=an(g.left,f.left),f},Pu(s,l,i));return d.width=d.right-d.left,d.height=d.bottom-d.top,d.x=d.left,d.y=d.top,d}function Ou(s){var t=s.reference,e=s.element,i=s.placement,n=i?$r(i):null,o=i?Ln(i):null,l=t.x+t.width/2-e.width/2,d=t.y+t.height/2-e.height/2,f;switch(n){case ji:f={x:l,y:t.y-e.height};break;case hr:f={x:l,y:t.y+t.height};break;case dr:f={x:t.x+t.width,y:d};break;case Ki:f={x:t.x-e.width,y:d};break;default:f={x:t.x,y:t.y}}var p=n?ic(n):null;if(p!=null){var g=p==="y"?"height":"width";switch(o){case wn:f[p]=f[p]-(t[g]/2-e[g]/2);break;case Ea:f[p]=f[p]+(t[g]/2-e[g]/2);break}}return f}function Ra(s,t){t===void 0&&(t={});var e=t,i=e.placement,n=i===void 0?s.placement:i,o=e.strategy,l=o===void 0?s.strategy:o,d=e.boundary,f=d===void 0?jm:d,p=e.rootBoundary,g=p===void 0?Au:p,v=e.elementContext,A=v===void 0?Ta:v,E=e.altBoundary,T=E===void 0?!1:E,w=e.padding,C=w===void 0?0:w,D=_u(typeof C!="number"?C:Cu(C,Aa)),M=A===Ta?Km:Ta,U=s.rects.popper,x=s.elements[T?M:A],G=w1(nn(x)?x:x.contextElement||Ss(s.elements.popper),f,g,l),$=Rn(s.elements.reference),Y=Ou({reference:$,element:U,strategy:"absolute",placement:n}),tt=ac(Object.assign({},U,Y)),nt=A===Ta?tt:$,J={top:G.top-nt.top+D.top,bottom:nt.bottom-G.bottom+D.bottom,left:G.left-nt.left+D.left,right:nt.right-G.right+D.right},St=s.modifiersData.offset;if(A===Ta&&St){var mt=St[n];Object.keys(J).forEach(function(Ot){var Vt=[dr,hr].indexOf(Ot)>=0?1:-1,V=[ji,hr].indexOf(Ot)>=0?"y":"x";J[Ot]+=mt[V]*Vt})}return J}function S1(s,t){t===void 0&&(t={});var e=t,i=e.placement,n=e.boundary,o=e.rootBoundary,l=e.padding,d=e.flipVariations,f=e.allowedAutoPlacements,p=f===void 0?Tu:f,g=Ln(i),v=g?d?Eu:Eu.filter(function(T){return Ln(T)===g}):Aa,A=v.filter(function(T){return p.indexOf(T)>=0});A.length===0&&(A=v);var E=A.reduce(function(T,w){return T[w]=Ra(s,{placement:w,boundary:n,rootBoundary:o,padding:l})[$r(w)],T},{});return Object.keys(E).sort(function(T,w){return E[T]-E[w]})}function R1(s){if($r(s)===Ql)return[];var t=Lo(s);return[xu(s),t,xu(t)]}function L1(s){var t=s.state,e=s.options,i=s.name;if(!t.modifiersData[i]._skip){for(var n=e.mainAxis,o=n===void 0?!0:n,l=e.altAxis,d=l===void 0?!0:l,f=e.fallbackPlacements,p=e.padding,g=e.boundary,v=e.rootBoundary,A=e.altBoundary,E=e.flipVariations,T=E===void 0?!0:E,w=e.allowedAutoPlacements,C=t.options.placement,D=$r(C),M=D===C,U=f||(M||!T?[Lo(C)]:R1(C)),x=[C].concat(U).reduce(function($t,jt){return $t.concat($r(jt)===Ql?S1(t,{placement:jt,boundary:g,rootBoundary:v,padding:p,flipVariations:T,allowedAutoPlacements:w}):jt)},[]),G=t.rects.reference,$=t.rects.popper,Y=new Map,tt=!0,nt=x[0],J=0;J<x.length;J++){var St=x[J],mt=$r(St),Ot=Ln(St)===wn,Vt=[ji,hr].indexOf(mt)>=0,V=Vt?"width":"height",q=Ra(t,{placement:St,boundary:g,rootBoundary:v,altBoundary:A,padding:p}),At=Vt?Ot?dr:Ki:Ot?hr:ji;G[V]>$[V]&&(At=Lo(At));var N=Lo(At),F=[];if(o&&F.push(q[mt]<=0),d&&F.push(q[At]<=0,q[N]<=0),F.every(function($t){return $t})){nt=St,tt=!1;break}Y.set(St,F)}if(tt)for(var j=T?3:1,at=function(jt){var fe=x.find(function(ve){var me=Y.get(ve);if(me)return me.slice(0,jt).every(function(Ke){return Ke})});if(fe)return nt=fe,"break"},ht=j;ht>0;ht--){var _t=at(ht);if(_t==="break")break}t.placement!==nt&&(t.modifiersData[i]._skip=!0,t.placement=nt,t.reset=!0)}}const _1={name:"flip",enabled:!0,phase:"main",fn:L1,requiresIfExists:["offset"],data:{_skip:!1}};function Mu(s,t,e){return e===void 0&&(e={x:0,y:0}),{top:s.top-t.height-e.y,right:s.right-t.width+e.x,bottom:s.bottom-t.height+e.y,left:s.left-t.width-e.x}}function $u(s){return[ji,dr,hr,Ki].some(function(t){return s[t]>=0})}function C1(s){var t=s.state,e=s.name,i=t.rects.reference,n=t.rects.popper,o=t.modifiersData.preventOverflow,l=Ra(t,{elementContext:"reference"}),d=Ra(t,{altBoundary:!0}),f=Mu(l,i),p=Mu(d,n,o),g=$u(f),v=$u(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 I1={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:C1};function x1(s,t,e){var i=$r(s),n=[Ki,ji].indexOf(i)>=0?-1:1,o=typeof e=="function"?e(Object.assign({},t,{placement:s})):e,l=o[0],d=o[1];return l=l||0,d=(d||0)*n,[Ki,dr].indexOf(i)>=0?{x:d,y:l}:{x:l,y:d}}function D1(s){var t=s.state,e=s.options,i=s.name,n=e.offset,o=n===void 0?[0,0]:n,l=Tu.reduce(function(g,v){return g[v]=x1(v,t.rects,o),g},{}),d=l[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]=l}const P1={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:D1};function O1(s){var t=s.state,e=s.name;t.modifiersData[e]=Ou({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const M1={name:"popperOffsets",enabled:!0,phase:"read",fn:O1,data:{}};function $1(s){return s==="x"?"y":"x"}function F1(s){var t=s.state,e=s.options,i=s.name,n=e.mainAxis,o=n===void 0?!0:n,l=e.altAxis,d=l===void 0?!1:l,f=e.boundary,p=e.rootBoundary,g=e.altBoundary,v=e.padding,A=e.tether,E=A===void 0?!0:A,T=e.tetherOffset,w=T===void 0?0:T,C=Ra(t,{boundary:f,rootBoundary:p,padding:v,altBoundary:g}),D=$r(t.placement),M=Ln(t.placement),U=!M,x=ic(D),G=$1(x),$=t.modifiersData.popperOffsets,Y=t.rects.reference,tt=t.rects.popper,nt=typeof w=="function"?w(Object.assign({},t.rects,{placement:t.placement})):w,J=typeof nt=="number"?{mainAxis:nt,altAxis:nt}:Object.assign({mainAxis:0,altAxis:0},nt),St=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,mt={x:0,y:0};if($){if(o){var Ot,Vt=x==="y"?ji:Ki,V=x==="y"?hr:dr,q=x==="y"?"height":"width",At=$[x],N=At+C[Vt],F=At-C[V],j=E?-tt[q]/2:0,at=M===wn?Y[q]:tt[q],ht=M===wn?-tt[q]:-Y[q],_t=t.elements.arrow,$t=E&&_t?ec(_t):{width:0,height:0},jt=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:Lu(),fe=jt[Vt],ve=jt[V],me=wa(0,Y[q],$t[q]),Ke=U?Y[q]/2-j-me-fe-J.mainAxis:at-me-fe-J.mainAxis,Le=U?-Y[q]/2+j+me+ve+J.mainAxis:ht+me+ve+J.mainAxis,Kt=t.elements.arrow&&ka(t.elements.arrow),Ae=Kt?x==="y"?Kt.clientTop||0:Kt.clientLeft||0:0,de=(Ot=St==null?void 0:St[x])!=null?Ot:0,Me=At+Ke-de-Ae,Ut=At+Le-de,Ye=wa(E?wo(N,Me):N,At,E?an(F,Ut):F);$[x]=Ye,mt[x]=Ye-At}if(d){var Fe,Ve=x==="x"?ji:Ki,we=x==="x"?hr:dr,ue=$[G],ze=G==="y"?"height":"width",le=ue+C[Ve],Ne=ue-C[we],Ue=[ji,Ki].indexOf(D)!==-1,pi=(Fe=St==null?void 0:St[G])!=null?Fe:0,Ce=Ue?le:ue-Y[ze]-tt[ze]-pi+J.altAxis,Ai=Ue?ue+Y[ze]+tt[ze]-pi-J.altAxis:Ne,Lr=E&&Ue?o1(Ce,ue,Ai):wa(E?Ce:le,ue,E?Ai:Ne);$[G]=Lr,mt[G]=Lr-ue}t.modifiersData[i]=mt}}const N1={name:"preventOverflow",enabled:!0,phase:"main",fn:F1,requiresIfExists:["offset"]};function U1(s){return{scrollLeft:s.scrollLeft,scrollTop:s.scrollTop}}function B1(s){return s===sr(s)||!ur(s)?rc(s):U1(s)}function G1(s){var t=s.getBoundingClientRect(),e=Sn(t.width)/s.offsetWidth||1,i=Sn(t.height)/s.offsetHeight||1;return e!==1||i!==1}function V1(s,t,e){e===void 0&&(e=!1);var i=ur(t),n=ur(t)&&G1(t),o=Ss(t),l=Rn(s,n,e),d={scrollLeft:0,scrollTop:0},f={x:0,y:0};return(i||!i&&!e)&&((Mr(t)!=="body"||nc(o))&&(d=B1(t)),ur(t)?(f=Rn(t,!0),f.x+=t.clientLeft,f.y+=t.clientTop):o&&(f.x=sc(o))),{x:l.left+d.scrollLeft-f.x,y:l.top+d.scrollTop-f.y,width:l.width,height:l.height}}function H1(s){var t=new Map,e=new Set,i=[];s.forEach(function(o){t.set(o.name,o)});function n(o){e.add(o.name);var l=[].concat(o.requires||[],o.requiresIfExists||[]);l.forEach(function(d){if(!e.has(d)){var f=t.get(d);f&&n(f)}}),i.push(o)}return s.forEach(function(o){e.has(o.name)||n(o)}),i}function W1(s){var t=H1(s);return i1.reduce(function(e,i){return e.concat(t.filter(function(n){return n.phase===i}))},[])}function j1(s){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(s())})})),t}}function K1(s){var t=s.reduce(function(e,i){var n=e[i.name];return e[i.name]=n?Object.assign({},n,i,{options:Object.assign({},n.options,i.options),data:Object.assign({},n.data,i.data)}):i,e},{});return Object.keys(t).map(function(e){return t[e]})}var Fu={placement:"bottom",modifiers:[],strategy:"absolute"};function Nu(){for(var s=arguments.length,t=new Array(s),e=0;e<s;e++)t[e]=arguments[e];return!t.some(function(i){return!(i&&typeof i.getBoundingClientRect=="function")})}function Y1(s){s===void 0&&(s={});var t=s,e=t.defaultModifiers,i=e===void 0?[]:e,n=t.defaultOptions,o=n===void 0?Fu:n;return function(d,f,p){p===void 0&&(p=o);var g={placement:"bottom",orderedModifiers:[],options:Object.assign({},Fu,o),modifiersData:{},elements:{reference:d,popper:f},attributes:{},styles:{}},v=[],A=!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:nn(d)?Sa(d):d.contextElement?Sa(d.contextElement):[],popper:Sa(f)};var U=W1(K1([].concat(i,g.options.modifiers)));return g.orderedModifiers=U.filter(function(x){return x.enabled}),T(),E.update()},forceUpdate:function(){if(!A){var D=g.elements,M=D.reference,U=D.popper;if(Nu(M,U)){g.rects={reference:V1(M,ka(U),g.options.strategy==="fixed"),popper:ec(U)},g.reset=!1,g.placement=g.options.placement,g.orderedModifiers.forEach(function(J){return g.modifiersData[J.name]=Object.assign({},J.data)});for(var x=0;x<g.orderedModifiers.length;x++){if(g.reset===!0){g.reset=!1,x=-1;continue}var G=g.orderedModifiers[x],$=G.fn,Y=G.options,tt=Y===void 0?{}:Y,nt=G.name;typeof $=="function"&&(g=$({state:g,options:tt,name:nt,instance:E})||g)}}}},update:j1(function(){return new Promise(function(C){E.forceUpdate(),C(g)})}),destroy:function(){w(),A=!0}};if(!Nu(d,f))return E;E.setOptions(p).then(function(C){!A&&p.onFirstUpdate&&p.onFirstUpdate(C)});function T(){g.orderedModifiers.forEach(function(C){var D=C.name,M=C.options,U=M===void 0?{}:M,x=C.effect;if(typeof x=="function"){var G=x({state:g,name:D,instance:E,options:U}),$=function(){};v.push(G||$)}})}function w(){v.forEach(function(C){return C()}),v=[]}return E}}var z1=[v1,M1,g1,ku,P1,_1,N1,d1,I1],X1=Y1({defaultModifiers:z1}),Z1="tippy-box",Uu="tippy-content",q1="tippy-backdrop",Bu="tippy-arrow",Gu="tippy-svg-arrow",on={passive:!0,capture:!0},Vu=function(){return document.body};function oc(s,t,e){if(Array.isArray(s)){var i=s[t];return i??(Array.isArray(e)?e[t]:e)}return s}function lc(s,t){var e={}.toString.call(s);return e.indexOf("[object")===0&&e.indexOf(t+"]")>-1}function Hu(s,t){return typeof s=="function"?s.apply(void 0,t):s}function Wu(s,t){if(t===0)return s;var e;return function(i){clearTimeout(e),e=setTimeout(function(){s(i)},t)}}function Q1(s){return s.split(/\s+/).filter(Boolean)}function _n(s){return[].concat(s)}function ju(s,t){s.indexOf(t)===-1&&s.push(t)}function J1(s){return s.filter(function(t,e){return s.indexOf(t)===e})}function tv(s){return s.split("-")[0]}function _o(s){return[].slice.call(s)}function Ku(s){return Object.keys(s).reduce(function(t,e){return s[e]!==void 0&&(t[e]=s[e]),t},{})}function La(){return document.createElement("div")}function Co(s){return["Element","Fragment"].some(function(t){return lc(s,t)})}function ev(s){return lc(s,"NodeList")}function iv(s){return lc(s,"MouseEvent")}function rv(s){return!!(s&&s._tippy&&s._tippy.reference===s)}function sv(s){return Co(s)?[s]:ev(s)?_o(s):Array.isArray(s)?s:_o(document.querySelectorAll(s))}function cc(s,t){s.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function Yu(s,t){s.forEach(function(e){e&&e.setAttribute("data-state",t)})}function nv(s){var t,e=_n(s),i=e[0];return i!=null&&(t=i.ownerDocument)!=null&&t.body?i.ownerDocument:document}function av(s,t){var e=t.clientX,i=t.clientY;return s.every(function(n){var o=n.popperRect,l=n.popperState,d=n.props,f=d.interactiveBorder,p=tv(l.placement),g=l.modifiersData.offset;if(!g)return!0;var v=p==="bottom"?g.top.y:0,A=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,C=i-o.bottom-A>f,D=o.left-e+E>f,M=e-o.right-T>f;return w||C||D||M})}function hc(s,t,e){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){s[i](n,e)})}function zu(s,t){for(var e=t;e;){var i;if(s.contains(e))return!0;e=e.getRootNode==null||(i=e.getRootNode())==null?void 0:i.host}return!1}var Fr={isTouch:!1},Xu=0;function ov(){Fr.isTouch||(Fr.isTouch=!0,window.performance&&document.addEventListener("mousemove",Zu))}function Zu(){var s=performance.now();s-Xu<20&&(Fr.isTouch=!1,document.removeEventListener("mousemove",Zu)),Xu=s}function lv(){var s=document.activeElement;if(rv(s)){var t=s._tippy;s.blur&&!t.state.isVisible&&s.blur()}}function cv(){document.addEventListener("touchstart",ov,on),window.addEventListener("blur",lv)}var hv=typeof window<"u"&&typeof document<"u",dv=hv?!!window.msCrypto:!1,uv={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},fv={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},kr=Object.assign({appendTo:Vu,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},uv,fv),pv=Object.keys(kr),gv=function(t){var e=Object.keys(t);e.forEach(function(i){kr[i]=t[i]})};function qu(s){var t=s.plugins||[],e=t.reduce(function(i,n){var o=n.name,l=n.defaultValue;if(o){var d;i[o]=s[o]!==void 0?s[o]:(d=kr[o])!=null?d:l}return i},{});return Object.assign({},s,e)}function mv(s,t){var e=t?Object.keys(qu(Object.assign({},kr,{plugins:t}))):pv,i=e.reduce(function(n,o){var l=(s.getAttribute("data-tippy-"+o)||"").trim();if(!l)return n;if(o==="content")n[o]=l;else try{n[o]=JSON.parse(l)}catch{n[o]=l}return n},{});return i}function Qu(s,t){var e=Object.assign({},t,{content:Hu(t.content,[s])},t.ignoreAttributes?{}:mv(s,t.plugins));return e.aria=Object.assign({},kr.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 vv=function(){return"innerHTML"};function dc(s,t){s[vv()]=t}function Ju(s){var t=La();return s===!0?t.className=Bu:(t.className=Gu,Co(s)?t.appendChild(s):dc(t,s)),t}function t0(s,t){Co(t.content)?(dc(s,""),s.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?dc(s,t.content):s.textContent=t.content)}function uc(s){var t=s.firstElementChild,e=_o(t.children);return{box:t,content:e.find(function(i){return i.classList.contains(Uu)}),arrow:e.find(function(i){return i.classList.contains(Bu)||i.classList.contains(Gu)}),backdrop:e.find(function(i){return i.classList.contains(q1)})}}function e0(s){var t=La(),e=La();e.className=Z1,e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var i=La();i.className=Uu,i.setAttribute("data-state","hidden"),t0(i,s.props),t.appendChild(e),e.appendChild(i),n(s.props,s.props);function n(o,l){var d=uc(t),f=d.box,p=d.content,g=d.arrow;l.theme?f.setAttribute("data-theme",l.theme):f.removeAttribute("data-theme"),typeof l.animation=="string"?f.setAttribute("data-animation",l.animation):f.removeAttribute("data-animation"),l.inertia?f.setAttribute("data-inertia",""):f.removeAttribute("data-inertia"),f.style.maxWidth=typeof l.maxWidth=="number"?l.maxWidth+"px":l.maxWidth,l.role?f.setAttribute("role",l.role):f.removeAttribute("role"),(o.content!==l.content||o.allowHTML!==l.allowHTML)&&t0(p,s.props),l.arrow?g?o.arrow!==l.arrow&&(f.removeChild(g),f.appendChild(Ju(l.arrow))):f.appendChild(Ju(l.arrow)):g&&f.removeChild(g)}return{popper:t,onUpdate:n}}e0.$$tippy=!0;var yv=1,Io=[],fc=[];function bv(s,t){var e=Qu(s,Object.assign({},kr,qu(Ku(t)))),i,n,o,l=!1,d=!1,f=!1,p=!1,g,v,A,E=[],T=Wu(Me,e.interactiveDebounce),w,C=yv++,D=null,M=J1(e.plugins),U={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},x={id:C,reference:s,popper:La(),popperInstance:D,props:e,state:U,plugins:M,clearDelayTimeouts:Ce,setProps:Ai,setContent:Lr,show:ni,hide:_r,hideWithInteractivity:Ds,enable:Ue,disable:pi,unmount:Ps,destroy:ar};if(!e.render)return x;var G=e.render(x),$=G.popper,Y=G.onUpdate;$.setAttribute("data-tippy-root",""),$.id="tippy-"+x.id,x.popper=$,s._tippy=x,$._tippy=x;var tt=M.map(function(dt){return dt.fn(x)}),nt=s.hasAttribute("aria-expanded");return Kt(),j(),At(),N("onCreate",[x]),e.showOnCreate&&le(),$.addEventListener("mouseenter",function(){x.props.interactive&&x.state.isVisible&&x.clearDelayTimeouts()}),$.addEventListener("mouseleave",function(){x.props.interactive&&x.props.trigger.indexOf("mouseenter")>=0&&Vt().addEventListener("mousemove",T)}),x;function J(){var dt=x.props.touch;return Array.isArray(dt)?dt:[dt,0]}function St(){return J()[0]==="hold"}function mt(){var dt;return!!((dt=x.props.render)!=null&&dt.$$tippy)}function Ot(){return w||s}function Vt(){var dt=Ot().parentNode;return dt?nv(dt):document}function V(){return uc($)}function q(dt){return x.state.isMounted&&!x.state.isVisible||Fr.isTouch||g&&g.type==="focus"?0:oc(x.props.delay,dt?0:1,kr.delay)}function At(dt){dt===void 0&&(dt=!1),$.style.pointerEvents=x.props.interactive&&!dt?"":"none",$.style.zIndex=""+x.props.zIndex}function N(dt,Gt,Zt){if(Zt===void 0&&(Zt=!0),tt.forEach(function(ne){ne[dt]&&ne[dt].apply(ne,Gt)}),Zt){var ye;(ye=x.props)[dt].apply(ye,Gt)}}function F(){var dt=x.props.aria;if(dt.content){var Gt="aria-"+dt.content,Zt=$.id,ye=_n(x.props.triggerTarget||s);ye.forEach(function(ne){var ci=ne.getAttribute(Gt);if(x.state.isVisible)ne.setAttribute(Gt,ci?ci+" "+Zt:Zt);else{var Oi=ci&&ci.replace(Zt,"").trim();Oi?ne.setAttribute(Gt,Oi):ne.removeAttribute(Gt)}})}}function j(){if(!(nt||!x.props.aria.expanded)){var dt=_n(x.props.triggerTarget||s);dt.forEach(function(Gt){x.props.interactive?Gt.setAttribute("aria-expanded",x.state.isVisible&&Gt===Ot()?"true":"false"):Gt.removeAttribute("aria-expanded")})}}function at(){Vt().removeEventListener("mousemove",T),Io=Io.filter(function(dt){return dt!==T})}function ht(dt){if(!(Fr.isTouch&&(f||dt.type==="mousedown"))){var Gt=dt.composedPath&&dt.composedPath()[0]||dt.target;if(!(x.props.interactive&&zu($,Gt))){if(_n(x.props.triggerTarget||s).some(function(Zt){return zu(Zt,Gt)})){if(Fr.isTouch||x.state.isVisible&&x.props.trigger.indexOf("click")>=0)return}else N("onClickOutside",[x,dt]);x.props.hideOnClick===!0&&(x.clearDelayTimeouts(),x.hide(),d=!0,setTimeout(function(){d=!1}),x.state.isMounted||fe())}}}function _t(){f=!0}function $t(){f=!1}function jt(){var dt=Vt();dt.addEventListener("mousedown",ht,!0),dt.addEventListener("touchend",ht,on),dt.addEventListener("touchstart",$t,on),dt.addEventListener("touchmove",_t,on)}function fe(){var dt=Vt();dt.removeEventListener("mousedown",ht,!0),dt.removeEventListener("touchend",ht,on),dt.removeEventListener("touchstart",$t,on),dt.removeEventListener("touchmove",_t,on)}function ve(dt,Gt){Ke(dt,function(){!x.state.isVisible&&$.parentNode&&$.parentNode.contains($)&&Gt()})}function me(dt,Gt){Ke(dt,Gt)}function Ke(dt,Gt){var Zt=V().box;function ye(ne){ne.target===Zt&&(hc(Zt,"remove",ye),Gt())}if(dt===0)return Gt();hc(Zt,"remove",v),hc(Zt,"add",ye),v=ye}function Le(dt,Gt,Zt){Zt===void 0&&(Zt=!1);var ye=_n(x.props.triggerTarget||s);ye.forEach(function(ne){ne.addEventListener(dt,Gt,Zt),E.push({node:ne,eventType:dt,handler:Gt,options:Zt})})}function Kt(){St()&&(Le("touchstart",de,{passive:!0}),Le("touchend",Ut,{passive:!0})),Q1(x.props.trigger).forEach(function(dt){if(dt!=="manual")switch(Le(dt,de),dt){case"mouseenter":Le("mouseleave",Ut);break;case"focus":Le(dv?"focusout":"blur",Ye);break;case"focusin":Le("focusout",Ye);break}})}function Ae(){E.forEach(function(dt){var Gt=dt.node,Zt=dt.eventType,ye=dt.handler,ne=dt.options;Gt.removeEventListener(Zt,ye,ne)}),E=[]}function de(dt){var Gt,Zt=!1;if(!(!x.state.isEnabled||Fe(dt)||d)){var ye=((Gt=g)==null?void 0:Gt.type)==="focus";g=dt,w=dt.currentTarget,j(),!x.state.isVisible&&iv(dt)&&Io.forEach(function(ne){return ne(dt)}),dt.type==="click"&&(x.props.trigger.indexOf("mouseenter")<0||l)&&x.props.hideOnClick!==!1&&x.state.isVisible?Zt=!0:le(dt),dt.type==="click"&&(l=!Zt),Zt&&!ye&&Ne(dt)}}function Me(dt){var Gt=dt.target,Zt=Ot().contains(Gt)||$.contains(Gt);if(!(dt.type==="mousemove"&&Zt)){var ye=ze().concat($).map(function(ne){var ci,Oi=ne._tippy,vr=(ci=Oi.popperInstance)==null?void 0:ci.state;return vr?{popperRect:ne.getBoundingClientRect(),popperState:vr,props:e}:null}).filter(Boolean);av(ye,dt)&&(at(),Ne(dt))}}function Ut(dt){var Gt=Fe(dt)||x.props.trigger.indexOf("click")>=0&&l;if(!Gt){if(x.props.interactive){x.hideWithInteractivity(dt);return}Ne(dt)}}function Ye(dt){x.props.trigger.indexOf("focusin")<0&&dt.target!==Ot()||x.props.interactive&&dt.relatedTarget&&$.contains(dt.relatedTarget)||Ne(dt)}function Fe(dt){return Fr.isTouch?St()!==dt.type.indexOf("touch")>=0:!1}function Ve(){we();var dt=x.props,Gt=dt.popperOptions,Zt=dt.placement,ye=dt.offset,ne=dt.getReferenceClientRect,ci=dt.moveTransition,Oi=mt()?uc($).arrow:null,vr=ne?{getBoundingClientRect:ne,contextElement:ne.contextElement||Ot()}:s,hs={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Os){var Mi=Os.state;if(mt()){var Ba=V(),Ar=Ba.box;["placement","reference-hidden","escaped"].forEach(function(Ms){Ms==="placement"?Ar.setAttribute("data-placement",Mi.placement):Mi.attributes.popper["data-popper-"+Ms]?Ar.setAttribute("data-"+Ms,""):Ar.removeAttribute("data-"+Ms)}),Mi.attributes.popper={}}}},yr=[{name:"offset",options:{offset:ye}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!ci}},hs];mt()&&Oi&&yr.push({name:"arrow",options:{element:Oi,padding:3}}),yr.push.apply(yr,(Gt==null?void 0:Gt.modifiers)||[]),x.popperInstance=X1(vr,$,Object.assign({},Gt,{placement:Zt,onFirstUpdate:A,modifiers:yr}))}function we(){x.popperInstance&&(x.popperInstance.destroy(),x.popperInstance=null)}function ue(){var dt=x.props.appendTo,Gt,Zt=Ot();x.props.interactive&&dt===Vu||dt==="parent"?Gt=Zt.parentNode:Gt=Hu(dt,[Zt]),Gt.contains($)||Gt.appendChild($),x.state.isMounted=!0,Ve()}function ze(){return _o($.querySelectorAll("[data-tippy-root]"))}function le(dt){x.clearDelayTimeouts(),dt&&N("onTrigger",[x,dt]),jt();var Gt=q(!0),Zt=J(),ye=Zt[0],ne=Zt[1];Fr.isTouch&&ye==="hold"&&ne&&(Gt=ne),Gt?i=setTimeout(function(){x.show()},Gt):x.show()}function Ne(dt){if(x.clearDelayTimeouts(),N("onUntrigger",[x,dt]),!x.state.isVisible){fe();return}if(!(x.props.trigger.indexOf("mouseenter")>=0&&x.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(dt.type)>=0&&l)){var Gt=q(!1);Gt?n=setTimeout(function(){x.state.isVisible&&x.hide()},Gt):o=requestAnimationFrame(function(){x.hide()})}}function Ue(){x.state.isEnabled=!0}function pi(){x.hide(),x.state.isEnabled=!1}function Ce(){clearTimeout(i),clearTimeout(n),cancelAnimationFrame(o)}function Ai(dt){if(!x.state.isDestroyed){N("onBeforeUpdate",[x,dt]),Ae();var Gt=x.props,Zt=Qu(s,Object.assign({},Gt,Ku(dt),{ignoreAttributes:!0}));x.props=Zt,Kt(),Gt.interactiveDebounce!==Zt.interactiveDebounce&&(at(),T=Wu(Me,Zt.interactiveDebounce)),Gt.triggerTarget&&!Zt.triggerTarget?_n(Gt.triggerTarget).forEach(function(ye){ye.removeAttribute("aria-expanded")}):Zt.triggerTarget&&s.removeAttribute("aria-expanded"),j(),At(),Y&&Y(Gt,Zt),x.popperInstance&&(Ve(),ze().forEach(function(ye){requestAnimationFrame(ye._tippy.popperInstance.forceUpdate)})),N("onAfterUpdate",[x,dt])}}function Lr(dt){x.setProps({content:dt})}function ni(){var dt=x.state.isVisible,Gt=x.state.isDestroyed,Zt=!x.state.isEnabled,ye=Fr.isTouch&&!x.props.touch,ne=oc(x.props.duration,0,kr.duration);if(!(dt||Gt||Zt||ye)&&!Ot().hasAttribute("disabled")&&(N("onShow",[x],!1),x.props.onShow(x)!==!1)){if(x.state.isVisible=!0,mt()&&($.style.visibility="visible"),At(),jt(),x.state.isMounted||($.style.transition="none"),mt()){var ci=V(),Oi=ci.box,vr=ci.content;cc([Oi,vr],0)}A=function(){var yr;if(!(!x.state.isVisible||p)){if(p=!0,$.offsetHeight,$.style.transition=x.props.moveTransition,mt()&&x.props.animation){var br=V(),Os=br.box,Mi=br.content;cc([Os,Mi],ne),Yu([Os,Mi],"visible")}F(),j(),ju(fc,x),(yr=x.popperInstance)==null||yr.forceUpdate(),N("onMount",[x]),x.props.animation&&mt()&&me(ne,function(){x.state.isShown=!0,N("onShown",[x])})}},ue()}}function _r(){var dt=!x.state.isVisible,Gt=x.state.isDestroyed,Zt=!x.state.isEnabled,ye=oc(x.props.duration,1,kr.duration);if(!(dt||Gt||Zt)&&(N("onHide",[x],!1),x.props.onHide(x)!==!1)){if(x.state.isVisible=!1,x.state.isShown=!1,p=!1,l=!1,mt()&&($.style.visibility="hidden"),at(),fe(),At(!0),mt()){var ne=V(),ci=ne.box,Oi=ne.content;x.props.animation&&(cc([ci,Oi],ye),Yu([ci,Oi],"hidden"))}F(),j(),x.props.animation?mt()&&ve(ye,x.unmount):x.unmount()}}function Ds(dt){Vt().addEventListener("mousemove",T),ju(Io,T),T(dt)}function Ps(){x.state.isVisible&&x.hide(),x.state.isMounted&&(we(),ze().forEach(function(dt){dt._tippy.unmount()}),$.parentNode&&$.parentNode.removeChild($),fc=fc.filter(function(dt){return dt!==x}),x.state.isMounted=!1,N("onHidden",[x]))}function ar(){x.state.isDestroyed||(x.clearDelayTimeouts(),x.unmount(),Ae(),delete s._tippy,x.state.isDestroyed=!0,N("onDestroy",[x]))}}function ln(s,t){t===void 0&&(t={});var e=kr.plugins.concat(t.plugins||[]);cv();var i=Object.assign({},t,{plugins:e}),n=sv(s),o=n.reduce(function(l,d){var f=d&&bv(d,i);return f&&l.push(f),l},[]);return Co(s)?o[0]:o}ln.defaultProps=kr,ln.setDefaultProps=gv,ln.currentInput=Fr,Object.assign({},ku,{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)}}),ln.setDefaultProps({render:e0});class Nr extends Error{constructor(t,e=new Error,i=!1){super(),this.fatal=!1,this.fatal=i,this.stack=e.stack,this.message=[t,e.message].filter(Boolean).join(" - ")}}const Av=5;class Ev{constructor(t){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._canvas=Si(),this._controls=Si(),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,n,o,l;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-Av&&d<g))??[],this.loadScenes(),this.syncVideoState(),(n=this._controls.value)==null||n.setAttribute("currentTime",d.toString());const f=this.activeScenes[0],p=du((o=f==null?void 0:f.videoMeta)==null?void 0:o.captions);this.caption=((l=p.find(({start:g,end:v})=>{var A;const E=d-f.start+(((A=f.videoMeta)==null?void 0:A.start)??0);return g&&v&&E>=Eo(g)&&E<=Eo(v)}))==null?void 0:l.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 Ri(this._canvas)}controls(){return Ri(this._controls)}loadScenes(){[...this.activeScenes,...this._upcomingScenes].forEach(t=>{var e,i,n;const{start:o,duration:l,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:A}=d,{start:E,duration:T}=f,w=this.host.videoState[g];A&&w&&(A.currentTime>=E+T||A.ended||p&&(v?(e=v.startLoadOnce)==null||e.call(v,A.currentTime):w.initialised||(i=A.startLoadOnce)==null||i.call(A)))}else if(p){const g=`${o}-${l}`,v=this.host._sceneController.videoState[g];this.host.duration&&!((n=v==null?void 0:v.buffered)!=null&&n.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+l)/this.host.duration*100,100)}]}})}})}syncVideoState(){var t;(t=this.host.scenes)==null||t.forEach(e=>{if(e.video){const{key:i,node:n}=e.video,o=this.host.videoState[i],l=this.activeScenes.includes(e);if(n&&o)if(l&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(n.paused&&o.initialised)try{return n.play()}catch(d){throw new Nr("Video play error",d,!0)}}else n.paused||n.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 Tv(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var i0={exports:{}};(function(s,t){(function(e){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,o=/(?:\/|^)\.(?=\/)/g,l=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/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 A=d.parseURL(p);if(!A)throw new Error("Error trying to parse relative URL.");if(A.scheme)return g.alwaysNormalize?(A.path=d.normalizePath(A.path),d.buildURLFromParts(A)):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=n.exec(E.path);E.netLoc=T[1],E.path=T[2]}E.netLoc&&!E.path&&(E.path="/");var w={scheme:E.scheme,netLoc:A.netLoc,path:null,params:A.params,query:A.query,fragment:A.fragment};if(!A.netLoc&&(w.netLoc=E.netLoc,A.path[0]!=="/"))if(!A.path)w.path=E.path,A.params||(w.params=E.params,A.query||(w.query=E.query));else{var C=E.path,D=C.substring(0,C.lastIndexOf("/")+1)+A.path;w.path=d.normalizePath(D)}return w.path===null&&(w.path=g.alwaysNormalize?d.normalizePath(A.path):A.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(l,"")).length;);return f.split("").reverse().join("")},buildURLFromParts:function(f){return f.scheme+f.netLoc+f.path+f.params+f.query+f.fragment}};s.exports=d})()})(i0);var pc=i0.exports;function r0(s,t){var e=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(s,n).enumerable})),e.push.apply(e,i)}return e}function Yi(s){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?r0(Object(e),!0).forEach(function(i){kv(s,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):r0(Object(e)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(e,i))})}return s}function kv(s,t,e){return t=Sv(t),t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}function ui(){return ui=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(s[i]=e[i])}return s},ui.apply(this,arguments)}function wv(s,t){if(typeof s!="object"||s===null)return s;var e=s[Symbol.toPrimitive];if(e!==void 0){var i=e.call(s,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(s)}function Sv(s){var t=wv(s,"string");return typeof t=="symbol"?t:String(t)}const Wt=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)};let R=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s}({}),Qt=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),pt=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.UNKNOWN="unknown",s}({});const cn=function(){},gc={trace:cn,debug:cn,log:cn,warn:cn,info:cn,error:cn};let _a=gc;function Rv(s){const t=self.console[s];return t?t.bind(self.console,`[${s}] >`):cn}function Lv(s,...t){t.forEach(function(e){_a[e]=s[e]?s[e].bind(s):Rv(e)})}function _v(s,t){if(self.console&&s===!0||typeof s=="object"){Lv(s,"debug","log","info","warn","error");try{_a.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch{_a=gc}}else _a=gc}const X=_a,Cv=/^(\d+)x(\d+)$/,s0=/(.+?)=(".*?"|.*?)(?:,|$)/g;class ti{constructor(t){typeof t=="string"&&(t=ti.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 n=0;n<e.length/2;n++)i[n]=parseInt(e.slice(n*2,n*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={},n='"';for(s0.lastIndex=0;(e=s0.exec(t))!==null;){let o=e[2];o.indexOf(n)===0&&o.lastIndexOf(n)===o.length-1&&(o=o.slice(1,-1));const l=e[1].trim();i[l]=o}return i}}function Iv(s){return s!=="ID"&&s!=="CLASS"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function xv(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}class n0{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 n in i)if(Object.prototype.hasOwnProperty.call(t,n)&&t[n]!==i[n]){X.warn(`DATERANGE tag attribute: "${n}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=n;break}t=ui(new ti({}),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"]);Wt(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(Wt(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&&Wt(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class xo{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 xe={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class a0{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[xe.AUDIO]:null,[xe.VIDEO]:null,[xe.AUDIOVIDEO]:null},this.baseurl=t}setByteRange(t,e){const i=t.split("@",2),n=[];i.length===1?n[0]=e?e.byteRangeEndOffset:0:n[0]=parseInt(i[1]),n[1]=parseInt(i[0])+n[0],this._byteRange=n}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=pc.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class mc extends a0{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 xo,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||!Wt(this.programDateTime))return null;const t=Wt(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,n,o,l=!1){const{elementaryStreams:d}=this,f=d[t];if(!f){d[t]={startPTS:e,endPTS:i,startDTS:n,endDTS:o,partial:l};return}f.startPTS=Math.min(f.startPTS,e),f.endPTS=Math.max(f.endPTS,i),f.startDTS=Math.min(f.startDTS,n),f.endDTS=Math.max(f.endDTS,o)}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[xe.AUDIO]=null,t[xe.VIDEO]=null,t[xe.AUDIOVIDEO]=null}}class Dv extends a0{constructor(t,e,i,n,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 xo,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=n;const l=t.enumeratedString("BYTERANGE");l&&this.setByteRange(l,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 Pv=10;class Ov{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?Wt(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Pv}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 vc(s){return Uint8Array.from(atob(s),t=>t.charCodeAt(0))}function Mv(s){const t=o0(s).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e}function $v(s){const t=function(e,i,n){const o=e[i];e[i]=e[n],e[n]=o};t(s,0,3),t(s,1,2),t(s,4,5),t(s,6,7)}function Fv(s){const t=s.split(":");let e=null;if(t[0]==="data"&&t.length===2){const i=t[1].split(";"),n=i[i.length-1].split(",");if(n.length===2){const o=n[0]==="base64",l=n[1];o?(i.splice(-1,1),e=vc(l)):e=Mv(l)}}return e}function o0(s){return Uint8Array.from(unescape(encodeURIComponent(s)),t=>t.charCodeAt(0))}var ei={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},zi={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function l0(s){switch(s){case zi.FAIRPLAY:return ei.FAIRPLAY;case zi.PLAYREADY:return ei.PLAYREADY;case zi.WIDEVINE:return ei.WIDEVINE;case zi.CLEARKEY:return ei.CLEARKEY}}var c0={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function Nv(s){if(s===c0.WIDEVINE)return ei.WIDEVINE}function h0(s){switch(s){case ei.FAIRPLAY:return zi.FAIRPLAY;case ei.PLAYREADY:return zi.PLAYREADY;case ei.WIDEVINE:return zi.WIDEVINE;case ei.CLEARKEY:return zi.CLEARKEY}}function yc(s){const{drmSystems:t,widevineLicenseUrl:e}=s,i=t?[ei.FAIRPLAY,ei.WIDEVINE,ei.PLAYREADY,ei.CLEARKEY].filter(n=>!!t[n]):[];return!i[ei.WIDEVINE]&&e&&i.push(ei.WIDEVINE),i}const d0=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Uv(s,t,e,i){let n;switch(s){case ei.FAIRPLAY:n=["cenc","sinf"];break;case ei.WIDEVINE:case ei.PLAYREADY:n=["cenc"];break;case ei.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return Bv(n,t,e,i)}function Bv(s,t,e,i){return[{initDataTypes:s,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:e.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function hn(s,t,e){return Uint8Array.prototype.slice?s.slice(t,e):new Uint8Array(Array.prototype.slice.call(s,t,e))}const bc=(s,t)=>t+10<=s.length&&s[t]===73&&s[t+1]===68&&s[t+2]===51&&s[t+3]<255&&s[t+4]<255&&s[t+6]<128&&s[t+7]<128&&s[t+8]<128&&s[t+9]<128,u0=(s,t)=>t+10<=s.length&&s[t]===51&&s[t+1]===68&&s[t+2]===73&&s[t+3]<255&&s[t+4]<255&&s[t+6]<128&&s[t+7]<128&&s[t+8]<128&&s[t+9]<128,Do=(s,t)=>{const e=t;let i=0;for(;bc(s,t);){i+=10;const n=Po(s,t+6);i+=n,u0(s,t+10)&&(i+=10),t+=i}if(i>0)return s.subarray(e,e+i)},Po=(s,t)=>{let e=0;return e=(s[t]&127)<<21,e|=(s[t+1]&127)<<14,e|=(s[t+2]&127)<<7,e|=s[t+3]&127,e},Gv=(s,t)=>bc(s,t)&&Po(s,t+6)+10<=s.length-t,Vv=s=>{const t=p0(s);for(let e=0;e<t.length;e++){const i=t[e];if(f0(i))return zv(i)}},f0=s=>s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp",Hv=s=>{const t=String.fromCharCode(s[0],s[1],s[2],s[3]),e=Po(s,4),i=10;return{type:t,size:e,data:s.subarray(i,i+e)}},p0=s=>{let t=0;const e=[];for(;bc(s,t);){const i=Po(s,t+6);t+=10;const n=t+i;for(;t+8<n;){const o=Hv(s.subarray(t)),l=Wv(o);l&&e.push(l),t+=o.size+10}u0(s,t)&&(t+=10)}return e},Wv=s=>s.type==="PRIV"?jv(s):s.type[0]==="W"?Yv(s):Kv(s),jv=s=>{if(s.size<2)return;const t=Ur(s.data,!0),e=new Uint8Array(s.data.subarray(t.length+1));return{key:s.type,info:t,data:e.buffer}},Kv=s=>{if(s.size<2)return;if(s.type==="TXXX"){let e=1;const i=Ur(s.data.subarray(e),!0);e+=i.length+1;const n=Ur(s.data.subarray(e));return{key:s.type,info:i,data:n}}const t=Ur(s.data.subarray(1));return{key:s.type,data:t}},Yv=s=>{if(s.type==="WXXX"){if(s.size<2)return;let e=1;const i=Ur(s.data.subarray(e),!0);e+=i.length+1;const n=Ur(s.data.subarray(e));return{key:s.type,info:i,data:n}}const t=Ur(s.data);return{key:s.type,data:t}},zv=s=>{if(s.data.byteLength===8){const t=new Uint8Array(s.data),e=t[3]&1;let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,e&&(i+=4772185884e-2),Math.round(i)}},Ur=(s,t=!1)=>{const e=Xv();if(e){const p=e.decode(s);if(t){const g=p.indexOf("\0");return g!==-1?p.substring(0,g):p}return p.replace(/\0/g,"")}const i=s.length;let n,o,l,d="",f=0;for(;f<i;){if(n=s[f++],n===0&&t)return d;if(!(n===0||n===3))switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(n);break;case 12:case 13:o=s[f++],d+=String.fromCharCode((n&31)<<6|o&63);break;case 14:o=s[f++],l=s[f++],d+=String.fromCharCode((n&15)<<12|(o&63)<<6|(l&63)<<0);break}}return d};let Ac;function Xv(){return!Ac&&typeof self.TextDecoder<"u"&&(Ac=new self.TextDecoder("utf-8")),Ac}const Br={hexDump:function(s){let t="";for(let e=0;e<s.length;e++){let i=s[e].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},Oo=Math.pow(2,32)-1,Zv=[].push,g0={video:1,audio:2,id3:3,text:4};function _i(s){return String.fromCharCode.apply(null,s)}function m0(s,t){const e=s[t]<<8|s[t+1];return e<0?65536+e:e}function ee(s,t){const e=v0(s,t);return e<0?4294967296+e:e}function v0(s,t){return s[t]<<24|s[t+1]<<16|s[t+2]<<8|s[t+3]}function Ec(s,t,e){s[t]=e>>24,s[t+1]=e>>16&255,s[t+2]=e>>8&255,s[t+3]=e&255}function be(s,t){const e=[];if(!t.length)return e;const i=s.byteLength;for(let n=0;n<i;){const o=ee(s,n),l=_i(s.subarray(n+4,n+8)),d=o>1?n+o:i;if(l===t[0])if(t.length===1)e.push(s.subarray(n+8,d));else{const f=be(s.subarray(n+8,d),t.slice(1));f.length&&Zv.apply(e,f)}n=d}return e}function qv(s){const t=[],e=s[0];let i=8;const n=ee(s,i);i+=4;const o=0,l=0;e===0?i+=8:i+=16,i+=2;let d=s.length+l;const f=m0(s,i);i+=2;for(let p=0;p<f;p++){let g=i;const v=ee(s,g);g+=4;const A=v&2147483647;if((v&2147483648)>>>31===1)return X.warn("SIDX has hierarchical references (not supported)"),null;const E=ee(s,g);g+=4,t.push({referenceSize:A,subsegmentDuration:E,info:{duration:E/n,start:d,end:d+A-1}}),d+=A,g+=4,i=g}return{earliestPresentationTime:o,timescale:n,version:e,referencesCount:f,references:t}}function y0(s){const t=[],e=be(s,["moov","trak"]);for(let i=0;i<e.length;i++){const n=e[i],o=be(n,["tkhd"])[0];if(o){let l=o[0],d=l===0?12:20;const f=ee(o,d),p=be(n,["mdia","mdhd"])[0];if(p){l=p[0],d=l===0?12:20;const g=ee(p,d),v=be(n,["mdia","hdlr"])[0];if(v){const A=_i(v.subarray(8,12)),E={soun:xe.AUDIO,vide:xe.VIDEO}[A];if(E){const T=be(n,["mdia","minf","stbl","stsd"])[0];let w;T&&(w=_i(T.subarray(12,16))),t[f]={timescale:g,type:E},t[E]={timescale:g,id:f,codec:w}}}}}}return be(s,["moov","mvex","trex"]).forEach(i=>{const n=ee(i,4),o=t[n];o&&(o.default={duration:ee(i,12),flags:ee(i,20)})}),t}function Qv(s,t){if(!s||!t)return s;const e=t.keyId;return e&&t.isCommonEncryption&&be(s,["moov","trak"]).forEach(i=>{const n=be(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=be(n,["enca"]);const l=o.length>0;l||(o=be(n,["encv"])),o.forEach(d=>{const f=l?d.subarray(28):d.subarray(78);be(f,["sinf"]).forEach(p=>{const g=b0(p);if(g){const v=g.subarray(8,24);v.some(A=>A!==0)||(X.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Br.hexDump(v)} -> ${Br.hexDump(e)}`),g.set(e,8))}})})}),s}function b0(s){const t=be(s,["schm"])[0];if(t){const e=_i(t.subarray(4,8));if(e==="cbcs"||e==="cenc")return be(s,["schi","tenc"])[0]}return X.error("[eme] missing 'schm' box"),null}function Jv(s,t){return be(t,["moof","traf"]).reduce((e,i)=>{const n=be(i,["tfdt"])[0],o=n[0],l=be(i,["tfhd"]).reduce((d,f)=>{const p=ee(f,4),g=s[p];if(g){let v=ee(n,4);if(o===1){if(v===Oo)return X.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),d;v*=Oo+1,v+=ee(n,8)}const A=g.timescale||9e4,E=v/A;if(isFinite(E)&&(d===null||E<d))return E}return d},null);return l!==null&&isFinite(l)&&(e===null||l<e)?l:e},null)}function ty(s,t){let e=0,i=0,n=0;const o=be(s,["moof","traf"]);for(let l=0;l<o.length;l++){const d=o[l],f=be(d,["tfhd"])[0],p=ee(f,4),g=t[p];if(!g)continue;const v=g.default,A=ee(f,0)|(v==null?void 0:v.flags);let E=v==null?void 0:v.duration;A&8&&(A&2?E=ee(f,12):E=ee(f,8));const T=g.timescale||9e4,w=be(d,["trun"]);for(let C=0;C<w.length;C++){if(e=ey(w[C]),!e&&E){const D=ee(w[C],4);e=E*D}g.type===xe.VIDEO?i+=e/T:g.type===xe.AUDIO&&(n+=e/T)}}if(i===0&&n===0){let l=0;const d=be(s,["sidx"]);for(let f=0;f<d.length;f++){const p=qv(d[f]);p!=null&&p.references&&(l+=p.references.reduce((g,v)=>g+v.info.duration||0,0))}return l}return i||n}function ey(s){const t=ee(s,0);let e=8;t&1&&(e+=4),t&4&&(e+=4);let i=0;const n=ee(s,4);for(let o=0;o<n;o++){if(t&256){const l=ee(s,e);i+=l,e+=4}t&512&&(e+=4),t&1024&&(e+=4),t&2048&&(e+=4)}return i}function iy(s,t,e){be(t,["moof","traf"]).forEach(i=>{be(i,["tfhd"]).forEach(n=>{const o=ee(n,4),l=s[o];if(!l)return;const d=l.timescale||9e4;be(i,["tfdt"]).forEach(f=>{const p=f[0];let g=ee(f,4);if(p===0)g-=e*d,g=Math.max(g,0),Ec(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/(Oo+1)),A=Math.floor(g%(Oo+1));Ec(f,4,v),Ec(f,8,A)}})})})}function ry(s){const t={valid:null,remainder:null},e=be(s,["moof"]);if(e){if(e.length<2)return t.remainder=s,t}else return t;const i=e[e.length-1];return t.valid=hn(s,0,i.byteOffset-8),t.remainder=hn(s,i.byteOffset-8),t}function dn(s,t){const e=new Uint8Array(s.length+t.length);return e.set(s),e.set(t,s.length),e}function A0(s,t){const e=[],i=t.samples,n=t.timescale,o=t.id;let l=!1;return be(i,["moof"]).map(d=>{const f=d.byteOffset-8;be(d,["traf"]).map(p=>{const g=be(p,["tfdt"]).map(v=>{const A=v[0];let E=ee(v,4);return A===1&&(E*=Math.pow(2,32),E+=ee(v,8)),E/n})[0];return g!==void 0&&(s=g),be(p,["tfhd"]).map(v=>{const A=ee(v,4),E=ee(v,0)&16777215,T=(E&1)!==0,w=(E&2)!==0,C=(E&8)!==0;let D=0;const M=(E&16)!==0;let U=0;const x=(E&32)!==0;let G=8;A===o&&(T&&(G+=8),w&&(G+=4),C&&(D=ee(v,G),G+=4),M&&(U=ee(v,G),G+=4),x&&(G+=4),t.type==="video"&&(l=sy(t.codec)),be(p,["trun"]).map($=>{const Y=$[0],tt=ee($,0)&16777215,nt=(tt&1)!==0;let J=0;const St=(tt&4)!==0,mt=(tt&256)!==0;let Ot=0;const Vt=(tt&512)!==0;let V=0;const q=(tt&1024)!==0,At=(tt&2048)!==0;let N=0;const F=ee($,4);let j=8;nt&&(J=ee($,j),j+=4),St&&(j+=4);let at=J+f;for(let ht=0;ht<F;ht++){if(mt?(Ot=ee($,j),j+=4):Ot=D,Vt?(V=ee($,j),j+=4):V=U,q&&(j+=4),At&&(Y===0?N=ee($,j):N=v0($,j),j+=4),t.type===xe.VIDEO){let _t=0;for(;_t<V;){const $t=ee(i,at);if(at+=4,ny(l,i[at])){const jt=i.subarray(at,at+$t);E0(jt,l?2:1,s+N/n,e)}at+=$t,_t+=$t+4}}s+=Ot/n}}))})})}),e}function sy(s){if(!s)return!1;const t=s.indexOf("."),e=t<0?s:s.substring(0,t);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function ny(s,t){if(s){const e=t>>1&63;return e===39||e===40}else return(t&31)===6}function E0(s,t,e,i){const n=T0(s);let o=0;o+=t;let l=0,d=0,f=!1,p=0;for(;o<n.length;){l=0;do{if(o>=n.length)break;p=n[o++],l+=p}while(p===255);d=0;do{if(o>=n.length)break;p=n[o++],d+=p}while(p===255);const g=n.length-o;if(!f&&l===4&&o<n.length){if(f=!0,n[o++]===181){const v=m0(n,o);if(o+=2,v===49){const A=ee(n,o);if(o+=4,A===1195456820){const E=n[o++];if(E===3){const T=n[o++],w=31&T,C=64&T,D=C?2+w*3:0,M=new Uint8Array(D);if(C){M[0]=T;for(let U=1;U<D;U++)M[U]=n[o++]}i.push({type:E,payloadType:l,pts:e,bytes:M})}}}}}else if(l===5&&d<g){if(f=!0,d>16){const v=[];for(let T=0;T<16;T++){const w=n[o++].toString(16);v.push(w.length==1?"0"+w:w),(T===3||T===5||T===7||T===9)&&v.push("-")}const A=d-16,E=new Uint8Array(A);for(let T=0;T<A;T++)E[T]=n[o++];i.push({payloadType:l,pts:e,uuid:v.join(""),userData:Ur(E),userDataBytes:E})}}else if(d<g)o+=d;else if(d>g)break}}function T0(s){const t=s.byteLength,e=[];let i=1;for(;i<t-2;)s[i]===0&&s[i+1]===0&&s[i+2]===3?(e.push(i+2),i+=2):i++;if(e.length===0)return s;const n=t-e.length,o=new Uint8Array(n);let l=0;for(i=0;i<n;l++,i++)l===e[0]&&(l++,e.shift()),o[i]=s[l];return o}function ay(s){const t=s[0];let e="",i="",n=0,o=0,l=0,d=0,f=0,p=0;if(t===0){for(;_i(s.subarray(p,p+1))!=="\0";)e+=_i(s.subarray(p,p+1)),p+=1;for(e+=_i(s.subarray(p,p+1)),p+=1;_i(s.subarray(p,p+1))!=="\0";)i+=_i(s.subarray(p,p+1)),p+=1;i+=_i(s.subarray(p,p+1)),p+=1,n=ee(s,12),o=ee(s,16),d=ee(s,20),f=ee(s,24),p=28}else if(t===1){p+=4,n=ee(s,p),p+=4;const v=ee(s,p);p+=4;const A=ee(s,p);for(p+=4,l=4294967296*v+A,Number.isSafeInteger(l)||(l=Number.MAX_SAFE_INTEGER,X.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),d=ee(s,p),p+=4,f=ee(s,p),p+=4;_i(s.subarray(p,p+1))!=="\0";)e+=_i(s.subarray(p,p+1)),p+=1;for(e+=_i(s.subarray(p,p+1)),p+=1;_i(s.subarray(p,p+1))!=="\0";)i+=_i(s.subarray(p,p+1)),p+=1;i+=_i(s.subarray(p,p+1)),p+=1}const g=s.subarray(p,s.byteLength);return{schemeIdUri:e,value:i,timeScale:n,presentationTime:l,presentationTimeDelta:o,eventDuration:d,id:f,payload:g}}function oy(s,...t){const e=t.length;let i=8,n=e;for(;n--;)i+=t[n].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(s,4),n=0,i=8;n<e;n++)o.set(t[n],i),i+=t[n].byteLength;return o}function ly(s,t,e){if(s.byteLength!==16)throw new RangeError("Invalid system id");let i,n;if(t){i=1,n=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");n.set(f,d*16)}}else i=0,n=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 l=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(l.buffer).setUint32(0,e.byteLength,!1),oy([112,115,115,104],new Uint8Array([i,0,0,0]),s,o,n,l,e||new Uint8Array)}function cy(s){if(!(s instanceof ArrayBuffer)||s.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},e=new DataView(s),i=e.getUint32(0);if(s.byteLength!==i&&i>44||e.getUint32(4)!==1886614376||(t.version=e.getUint32(8)>>>24,t.version>1))return null;t.systemId=Br.hexDump(new Uint8Array(s,12,16));const n=e.getUint32(28);if(t.version===0){if(i-32<n)return null;t.data=new Uint8Array(s,32,n)}else if(t.version===1){t.kids=[];for(let o=0;o<n;o++)t.kids.push(new Uint8Array(s,32+o*16,16))}return t}let Mo={};class Ca{static clearKeyUriToKeyIdMap(){Mo={}}constructor(t,e,i,n=[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=n,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 zi.FAIRPLAY:case zi.WIDEVINE:case zi.PLAYREADY:case zi.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&&X.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const i=hy(t);return new Ca(this.method,this.uri,"identity",this.keyFormatVersions,i)}const e=Fv(this.uri);if(e)switch(this.keyFormat){case zi.WIDEVINE:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case zi.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=ly(i,null,e);const n=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),o=String.fromCharCode.apply(null,Array.from(n)),l=o.substring(o.indexOf("<"),o.length),d=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("KID")[0];if(d){const f=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(f){const p=vc(f).subarray(0,16);$v(p),this.keyId=p}}break}default:{let i=e.subarray(0,16);if(i.length!==16){const n=new Uint8Array(16);n.set(i,16-i.length),i=n}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=Mo[this.uri];if(!i){const n=Object.keys(Mo).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,n),Mo[this.uri]=i}this.keyId=i}return this}}function hy(s){const t=new Uint8Array(16);for(let e=12;e<16;e++)t[e]=s>>8*(15-e)&255;return t}const k0=/\{\$([a-zA-Z0-9-_]+)\}/g;function w0(s){return k0.test(s)}function Xi(s,t,e){if(s.variableList!==null||s.hasVariableRefs)for(let i=e.length;i--;){const n=e[i],o=t[n];o&&(t[n]=Tc(s,o))}}function Tc(s,t){if(s.variableList!==null||s.hasVariableRefs){const e=s.variableList;return t.replace(k0,i=>{const n=i.substring(2,i.length-1),o=e==null?void 0:e[n];return o===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),i):o})}return t}function S0(s,t,e){let i=s.variableList;i||(s.variableList=i={});let n,o;if("QUERYPARAM"in t){n=t.QUERYPARAM;try{const l=new self.URL(e).searchParams;if(l.has(n))o=l.get(n);else throw new Error(`"${n}" does not match any query parameter in URI: "${e}"`)}catch(l){s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${l.message}`))}}else n=t.NAME,o=t.VALUE;n in i?s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):i[n]=o||""}function dy(s,t,e){const i=t.IMPORT;if(e&&i in e){let n=s.variableList;n||(s.variableList=n={}),n[i]=e[i]}else s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function $o(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const uy={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}},R0=$o();function fy(s,t){const e=uy[t];return!!e&&e[s.slice(0,4)]===!0}function kc(s,t){var e;return(e=R0==null?void 0:R0.isTypeSupported(`${t||"video"}/mp4;codecs="${s}"`))!=null?e:!1}const L0=/#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,_0=/#EXT-X-MEDIA:(.*)/g,py=/^#EXT(?:INF|-X-TARGETDURATION):/m,C0=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),gy=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 wr{static findGroup(t,e){for(let i=0;i<t.length;i++){const n=t[i];if(n.id===e)return n}}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 pc.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return py.test(t)}static parseMasterPlaylist(t,e){const i=w0(t),n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},o=[];L0.lastIndex=0;let l;for(;(l=L0.exec(t))!=null;)if(l[1]){var d;const p=new ti(l[1]);Xi(n,p,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const g=Tc(n,l[2]),v={attrs:p,bitrate:p.decimalInteger("AVERAGE-BANDWIDTH")||p.decimalInteger("BANDWIDTH"),name:p.NAME,url:wr.resolve(g,e)},A=p.decimalResolution("RESOLUTION");A&&(v.width=A.width,v.height=A.height),my((p.CODECS||"").split(/[ ,]+/).filter(E=>E),v),v.videoCodec&&v.videoCodec.indexOf("avc1")!==-1&&(v.videoCodec=wr.convertAVC1ToAVCOTI(v.videoCodec)),(d=v.unknownCodecs)!=null&&d.length||o.push(v),n.levels.push(v)}else if(l[3]){const p=l[3],g=l[4];switch(p){case"SESSION-DATA":{const v=new ti(g);Xi(n,v,["DATA-ID","LANGUAGE","VALUE","URI"]);const A=v["DATA-ID"];A&&(n.sessionData===null&&(n.sessionData={}),n.sessionData[A]=v);break}case"SESSION-KEY":{const v=I0(g,e,n);v.encrypted&&v.isSupported()?(n.sessionKeys===null&&(n.sessionKeys=[]),n.sessionKeys.push(v)):X.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${g}"`);break}case"DEFINE":{{const v=new ti(g);Xi(n,v,["NAME","VALUE","QUERYPARAM"]),S0(n,v,e)}break}case"CONTENT-STEERING":{const v=new ti(g);Xi(n,v,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:wr.resolve(v["SERVER-URI"],e),pathwayId:v["PATHWAY-ID"]||"."};break}case"START":{n.startTimeOffset=x0(g);break}}}const f=o.length>0&&o.length<n.levels.length;return n.levels=f?o:n.levels,n.levels.length===0&&(n.playlistParsingError=new Error("no levels found in manifest")),n}static parseMasterPlaylistMedia(t,e,i){let n;const o={},l=i.levels,d={AUDIO:l.map(p=>({id:p.attrs.AUDIO,audioCodec:p.audioCodec})),SUBTITLES:l.map(p=>({id:p.attrs.SUBTITLES,textCodec:p.textCodec})),"CLOSED-CAPTIONS":[]};let f=0;for(_0.lastIndex=0;(n=_0.exec(t))!==null;){const p=new ti(n[1]),g=p.TYPE;if(g){const v=d[g],A=o[g]||[];o[g]=A,Xi(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?wr.resolve(p.URI,e):""};if(v!=null&&v.length){const T=wr.findGroup(v,E.groupId)||v[0];D0(E,T,"audioCodec"),D0(E,T,"textCodec")}A.push(E)}}return o}static parseLevelPlaylist(t,e,i,n,o,l){const d=new Ov(e),f=d.fragments;let p=null,g=0,v=0,A=0,E=0,T=null,w=new mc(n,e),C,D,M,U=-1,x=!1;for(C0.lastIndex=0,d.m3u8=t,d.hasVariableRefs=w0(t);(C=C0.exec(t))!==null;){x&&(x=!1,w=new mc(n,e),w.start=A,w.sn=g,w.cc=E,w.level=i,p&&(w.initSegment=p,w.rawProgramDateTime=p.rawProgramDateTime,p.rawProgramDateTime=null));const tt=C[1];if(tt){w.duration=parseFloat(tt);const nt=(" "+C[2]).slice(1);w.title=nt||null,w.tagList.push(nt?["INF",tt,nt]:["INF",tt])}else if(C[3]){if(Wt(w.duration)){w.start=A,M&&M0(w,M,d),w.sn=g,w.level=i,w.cc=E,w.urlId=o,f.push(w);const nt=(" "+C[3]).slice(1);w.relurl=Tc(d,nt),P0(w,T),T=w,A+=w.duration,g++,v=0,x=!0}}else if(C[4]){const nt=(" "+C[4]).slice(1);T?w.setByteRange(nt,T):w.setByteRange(nt)}else if(C[5])w.rawProgramDateTime=(" "+C[5]).slice(1),w.tagList.push(["PROGRAM-DATE-TIME",w.rawProgramDateTime]),U===-1&&(U=f.length);else{if(C=C[0].match(gy),!C){X.warn("No matches on slow regex match for level playlist!");continue}for(D=1;D<C.length&&!(typeof C[D]<"u");D++);const nt=(" "+C[D]).slice(1),J=(" "+C[D+1]).slice(1),St=C[D+2]?(" "+C[D+2]).slice(1):"";switch(nt){case"PLAYLIST-TYPE":d.type=J.toUpperCase();break;case"MEDIA-SEQUENCE":g=d.startSN=parseInt(J);break;case"SKIP":{const mt=new ti(J);Xi(d,mt,["RECENTLY-REMOVED-DATERANGES"]);const Ot=mt.decimalInteger("SKIPPED-SEGMENTS");if(Wt(Ot)){d.skippedSegments=Ot;for(let V=Ot;V--;)f.unshift(null);g+=Ot}const Vt=mt.enumeratedString("RECENTLY-REMOVED-DATERANGES");Vt&&(d.recentlyRemovedDateranges=Vt.split(" "));break}case"TARGETDURATION":d.targetduration=Math.max(parseInt(J),1);break;case"VERSION":d.version=parseInt(J);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(J||St)&&w.tagList.push(St?[J,St]:[J]);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,J]);break;case"DATERANGE":{const mt=new ti(J);Xi(d,mt,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Xi(d,mt,mt.clientAttrs);const Ot=new n0(mt,d.dateRanges[mt.ID]);Ot.isValid||d.skippedSegments?d.dateRanges[Ot.id]=Ot:X.warn(`Ignoring invalid DATERANGE tag: "${J}"`),w.tagList.push(["EXT-X-DATERANGE",J]);break}case"DEFINE":{{const mt=new ti(J);Xi(d,mt,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in mt?dy(d,mt,l):S0(d,mt,e)}break}case"DISCONTINUITY-SEQUENCE":E=parseInt(J);break;case"KEY":{const mt=I0(J,e,d);if(mt.isSupported()){if(mt.method==="NONE"){M=void 0;break}M||(M={}),M[mt.keyFormat]&&(M=ui({},M)),M[mt.keyFormat]=mt}else X.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${J}"`);break}case"START":d.startTimeOffset=x0(J);break;case"MAP":{const mt=new ti(J);if(Xi(d,mt,["BYTERANGE","URI"]),w.duration){const Ot=new mc(n,e);O0(Ot,mt,i,M),p=Ot,w.initSegment=p,p.rawProgramDateTime&&!w.rawProgramDateTime&&(w.rawProgramDateTime=p.rawProgramDateTime)}else O0(w,mt,i,M),p=w,x=!0;break}case"SERVER-CONTROL":{const mt=new ti(J);d.canBlockReload=mt.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=mt.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&mt.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=mt.optionalFloat("PART-HOLD-BACK",0),d.holdBack=mt.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const mt=new ti(J);d.partTarget=mt.decimalFloatingPoint("PART-TARGET");break}case"PART":{let mt=d.partList;mt||(mt=d.partList=[]);const Ot=v>0?mt[mt.length-1]:void 0,Vt=v++,V=new ti(J);Xi(d,V,["BYTERANGE","URI"]);const q=new Dv(V,w,e,Vt,Ot);mt.push(q),w.duration+=q.duration;break}case"PRELOAD-HINT":{const mt=new ti(J);Xi(d,mt,["URI"]),d.preloadHint=mt;break}case"RENDITION-REPORT":{const mt=new ti(J);Xi(d,mt,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(mt);break}default:X.warn(`line parsed but not handled: ${C}`);break}}}T&&!T.relurl?(f.pop(),A-=T.duration,d.partList&&(d.fragmentHint=T)):d.partList&&(P0(w,T),w.cc=E,d.fragmentHint=w,M&&M0(w,M,d));const G=f.length,$=f[0],Y=f[G-1];if(A+=d.skippedSegments*d.targetduration,A>0&&G&&Y){d.averagetargetduration=A/G;const tt=Y.sn;d.endSN=tt!=="initSegment"?tt:0,d.live||(Y.endList=!0),$&&(d.startCC=$.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(A+=d.fragmentHint.duration),d.totalduration=A,d.endCC=E,U>0&&vy(f,U),d}}function I0(s,t,e){var i,n;const o=new ti(s);Xi(e,o,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const l=(i=o.METHOD)!=null?i:"",d=o.URI,f=o.hexadecimalInteger("IV"),p=o.KEYFORMATVERSIONS,g=(n=o.KEYFORMAT)!=null?n:"identity";d&&o.IV&&!f&&X.error(`Invalid IV: ${o.IV}`);const v=d?wr.resolve(d,t):"",A=(p||"1").split("/").map(Number).filter(Number.isFinite);return new Ca(l,v,g,A,f)}function x0(s){const t=new ti(s).decimalFloatingPoint("TIME-OFFSET");return Wt(t)?t:null}function my(s,t){["video","audio","text"].forEach(e=>{const i=s.filter(n=>fy(n,e));if(i.length){const n=i.filter(o=>o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0);t[`${e}Codec`]=n.length>0?n[0]:i[0],s=s.filter(o=>i.indexOf(o)===-1)}}),t.unknownCodecs=s}function D0(s,t,e){const i=t[e];i&&(s[e]=i)}function vy(s,t){let e=s[t];for(let i=t;i--;){const n=s[i];if(!n)return;n.programDateTime=e.programDateTime-n.duration*1e3,e=n}}function P0(s,t){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):t!=null&&t.programDateTime&&(s.programDateTime=t.endProgramDateTime),Wt(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function O0(s,t,e,i){s.relurl=t.URI,t.BYTERANGE&&s.setByteRange(t.BYTERANGE),s.level=e,s.sn="initSegment",i&&(s.levelkeys=i),s.initSegment=null}function M0(s,t,e){s.levelkeys=t;const{encryptedFragments:i}=e;(!i.length||i[i.length-1].levelkeys!==t)&&Object.keys(t).some(n=>t[n].isCommonEncryption)&&i.push(s)}var ke={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Jt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function $0(s){const{type:t}=s;switch(t){case ke.AUDIO_TRACK:return Jt.AUDIO;case ke.SUBTITLE_TRACK:return Jt.SUBTITLE;default:return Jt.MAIN}}function wc(s,t){let e=s.url;return(e===void 0||e.indexOf("data:")===0)&&(e=t.url),e}class yy{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,n=e.loader,o=i||n,l=new o(e);return this.loaders[t.type]=l,l}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:ke.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(t,e){const{id:i,level:n,url:o,deliveryDirectives:l}=e;this.load({id:i,level:n,responseType:"text",type:ke.LEVEL,url:o,deliveryDirectives:l})}onAudioTrackLoading(t,e){const{id:i,groupId:n,url:o,deliveryDirectives:l}=e;this.load({id:i,groupId:n,level:null,responseType:"text",type:ke.AUDIO_TRACK,url:o,deliveryDirectives:l})}onSubtitleTrackLoading(t,e){const{id:i,groupId:n,url:o,deliveryDirectives:l}=e;this.load({id:i,groupId:n,level:null,responseType:"text",type:ke.SUBTITLE_TRACK,url:o,deliveryDirectives:l})}load(t){var e;const i=this.hls.config;let n=this.getInternalLoader(t);if(n){const p=n.context;if(p&&p.url===t.url){X.trace("[playlist-loader]: playlist request ongoing");return}X.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),n.abort()}let o;if(t.type===ke.MANIFEST?o=i.manifestLoadPolicy.default:o=ui({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(t),(e=t.deliveryDirectives)!=null&&e.part){let p;if(t.type===ke.LEVEL&&t.level!==null?p=this.hls.levels[t.level].details:t.type===ke.AUDIO_TRACK&&t.id!==null?p=this.hls.audioTracks[t.id].details:t.type===ke.SUBTITLE_TRACK&&t.id!==null&&(p=this.hls.subtitleTracks[t.id].details),p){const g=p.partTarget,v=p.targetduration;if(g&&v){const A=Math.max(g*3,v*.8)*1e3;o=ui({},o,{maxTimeToFirstByteMs:Math.min(A,o.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(A,o.maxTimeToFirstByteMs)})}}}const l=o.errorRetry||o.timeoutRetry||{},d={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},f={onSuccess:(p,g,v,A)=>{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"),A||null,g);return}g.parsing.start=performance.now(),wr.isMediaPlaylist(T)?this.handleTrackOrLevelPlaylist(p,g,v,A||null,E):this.handleMasterPlaylist(p,g,v,A)},onError:(p,g,v,A)=>{this.handleNetworkError(g,v,!1,p,A)},onTimeout:(p,g,v)=>{this.handleNetworkError(g,v,!0,void 0,p)}};n.load(t,d,f)}handleMasterPlaylist(t,e,i,n){const o=this.hls,l=t.data,d=wc(t,i),f=wr.parseMasterPlaylist(l,d);if(f.playlistParsingError){this.handleManifestParsingError(t,i,f.playlistParsingError,n,e);return}const{contentSteering:p,levels:g,sessionData:v,sessionKeys:A,startTimeOffset:E,variableList:T}=f;this.variableList=T;const{AUDIO:w=[],SUBTITLES:C,"CLOSED-CAPTIONS":D}=wr.parseMasterPlaylistMedia(l,d,f);w.length&&!w.some(M=>!M.url)&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(X.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 ti({}),bitrate:0,url:""})),o.trigger(R.MANIFEST_LOADED,{levels:g,audioTracks:w,subtitles:C,captions:D,contentSteering:p,url:d,stats:e,networkDetails:n,sessionData:v,sessionKeys:A,startTimeOffset:E,variableList:T})}handleTrackOrLevelPlaylist(t,e,i,n,o){const l=this.hls,{id:d,level:f,type:p}=i,g=wc(t,i),v=Wt(d)?d:0,A=Wt(f)?f:v,E=$0(i),T=wr.parseLevelPlaylist(t.data,g,A,E,v,this.variableList);if(p===ke.MANIFEST){const w={attrs:new ti({}),bitrate:0,details:T,name:"",url:g};l.trigger(R.MANIFEST_LOADED,{levels:[w],audioTracks:[],url:g,stats:e,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),i.levelDetails=T,this.handlePlaylistLoaded(T,t,e,i,n,o)}handleManifestParsingError(t,e,i,n,o){this.hls.trigger(R.ERROR,{type:Qt.NETWORK_ERROR,details:pt.MANIFEST_PARSING_ERROR,fatal:e.type===ke.MANIFEST,url:t.url,err:i,error:i,reason:i.message,response:t,context:e,networkDetails:n,stats:o})}handleNetworkError(t,e,i=!1,n,o){let l=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${t.type}`;t.type===ke.LEVEL?l+=`: ${t.level} id: ${t.id}`:(t.type===ke.AUDIO_TRACK||t.type===ke.SUBTITLE_TRACK)&&(l+=` id: ${t.id} group-id: "${t.groupId}"`);const d=new Error(l);X.warn(`[playlist-loader]: ${l}`);let f=pt.UNKNOWN,p=!1;const g=this.getInternalLoader(t);switch(t.type){case ke.MANIFEST:f=i?pt.MANIFEST_LOAD_TIMEOUT:pt.MANIFEST_LOAD_ERROR,p=!0;break;case ke.LEVEL:f=i?pt.LEVEL_LOAD_TIMEOUT:pt.LEVEL_LOAD_ERROR,p=!1;break;case ke.AUDIO_TRACK:f=i?pt.AUDIO_TRACK_LOAD_TIMEOUT:pt.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case ke.SUBTITLE_TRACK:f=i?pt.SUBTITLE_TRACK_LOAD_TIMEOUT:pt.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(n){const A=(e==null?void 0:e.url)||t.url;v.response=Yi({url:A,data:void 0},n)}this.hls.trigger(R.ERROR,v)}handlePlaylistLoaded(t,e,i,n,o,l){const d=this.hls,{type:f,level:p,id:g,groupId:v,deliveryDirectives:A}=n,E=wc(e,n),T=$0(n),w=typeof n.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:pt.LEVEL_EMPTY_ERROR,fatal:!1,url:E,error:D,reason:D.message,response:e,context:n,level:w,parent:T,networkDetails:o,stats:i});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const C=t.playlistParsingError;if(C){d.trigger(R.ERROR,{type:Qt.NETWORK_ERROR,details:pt.LEVEL_PARSING_ERROR,fatal:!1,url:E,error:C,reason:C.message,response:e,context:n,level:w,parent:T,networkDetails:o,stats:i});return}switch(t.live&&l&&(l.getCacheAge&&(t.ageHeader=l.getCacheAge()||0),(!l.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),f){case ke.MANIFEST:case ke.LEVEL:d.trigger(R.LEVEL_LOADED,{details:t,level:w||0,id:g||0,stats:i,networkDetails:o,deliveryDirectives:A});break;case ke.AUDIO_TRACK:d.trigger(R.AUDIO_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:A});break;case ke.SUBTITLE_TRACK:d.trigger(R.SUBTITLE_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:A});break}}}function F0(s,t){let e;try{e=new Event("addtrack")}catch{e=document.createEvent("Event"),e.initEvent("addtrack",!1,!1)}e.track=s,t.dispatchEvent(e)}function N0(s,t){const e=s.mode;if(e==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(t.id))try{if(s.addCue(t),!s.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){X.debug(`[texttrack-utils]: ${i}`);try{const n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,s.addCue(n)}catch(n){X.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${n}`)}}e==="disabled"&&(s.mode=e)}function Cn(s){const t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues)for(let e=s.cues.length;e--;)s.removeCue(s.cues[e]);t==="disabled"&&(s.mode=t)}function Sc(s,t,e,i){const n=s.mode;if(n==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){const o=Ay(s.cues,t,e);for(let l=0;l<o.length;l++)(!i||i(o[l]))&&s.removeCue(o[l])}n==="disabled"&&(s.mode=n)}function by(s,t){if(t<s[0].startTime)return 0;const e=s.length-1;if(t>s[e].endTime)return-1;let i=0,n=e;for(;i<=n;){const o=Math.floor((n+i)/2);if(t<s[o].startTime)n=o-1;else if(t>s[o].startTime&&i<e)i=o+1;else return o}return s[i].startTime-t<t-s[n].startTime?i:n}function Ay(s,t,e){const i=[],n=by(s,t);if(n>-1)for(let o=n,l=s.length;o<l;o++){const d=s[o];if(d.startTime>=t&&d.endTime<=e)i.push(d);else if(d.startTime>e)return i}return i}var Sr={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const Ey=.25;function Rc(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const Fo=(()=>{const s=Rc();try{new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Lc(s,t){return s.getTime()/1e3-t}function Ty(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class ky{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&&(Cn(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 F0(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:n}}}=this;if(!i&&!n)return;const{samples:o}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=Rc();for(let d=0;d<o.length;d++){const f=o[d].type;if(f===Sr.emsg&&!i||!n)continue;const p=p0(o[d].data);if(p){const g=o[d].pts;let v=g+o[d].duration;v>Fo&&(v=Fo),v-g<=0&&(v=g+Ey);for(let A=0;A<p.length;A++){const E=p[A];if(!f0(E)){this.updateId3CueEnds(g,f);const T=new l(g,v,"");T.value=E,f&&(T.type=f),this.id3Track.addCue(T)}}}}}updateId3CueEnds(t,e){var i;const n=(i=this.id3Track)==null?void 0:i.cues;if(n)for(let o=n.length;o--;){const l=n[o];l.type===e&&l.startTime<t&&l.endTime===Fo&&(l.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:i,type:n}){const{id3Track:o,hls:l}=this;if(!l)return;const{config:{enableEmsgMetadataCues:d,enableID3MetadataCues:f}}=l;if(o&&(d||f)){let p;n==="audio"?p=g=>g.type===Sr.audioId3&&f:n==="video"?p=g=>g.type===Sr.emsg&&d:p=g=>g.type===Sr.audioId3&&f||g.type===Sr.emsg&&d,Sc(o,e,i,p)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:n}=this,{dateRanges:o}=e,l=Object.keys(o);if(n){const g=Object.keys(i).filter(v=>!l.includes(v));for(let v=g.length;v--;){const A=g[v];Object.keys(i[A].cues).forEach(E=>{n.removeCue(i[A].cues[E])}),delete i[A]}}const d=e.fragments[e.fragments.length-1];if(l.length===0||!Wt(d==null?void 0:d.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const f=d.programDateTime/1e3-d.start,p=Rc();for(let g=0;g<l.length;g++){const v=l[g],A=o[v],E=i[v],T=(E==null?void 0:E.cues)||{};let w=(E==null?void 0:E.durationKnown)||!1;const C=Lc(A.startDate,f);let D=Fo;const M=A.endDate;if(M)D=Lc(M,f),w=!0;else if(A.endOnNext&&!w){const x=l.reduce((G,$)=>{const Y=o[$];return Y.class===A.class&&Y.id!==$&&Y.startDate>A.startDate&&G.push(Y),G},[]).sort((G,$)=>G.startDate.getTime()-$.startDate.getTime())[0];x&&(D=Lc(x.startDate,f),w=!0)}const U=Object.keys(A.attr);for(let x=0;x<U.length;x++){const G=U[x];if(!Iv(G))continue;let $=T[G];if($)w&&!E.durationKnown&&($.endTime=D);else{let Y=A.attr[G];$=new p(C,D,""),xv(G)&&(Y=Ty(Y)),$.value={key:G,data:Y},$.type=Sr.dateRange,$.id=v,this.id3Track.addCue($),T[G]=$}}i[v]={cues:T,dateRange:A,durationKnown:w}}}}class wy{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:n}=t,{liveSyncDuration:o,liveSyncDurationCount:l,lowLatencyMode:d}=this.config,f=this.hls.userConfig;let p=d&&i||e;(f.liveSyncDuration||f.liveSyncDurationCount||p===0)&&(p=o!==void 0?o:l*n);const g=n,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 n=i.edge,o=t-e-this.edgeStalled,l=n-i.totalduration,d=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(l,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===pt.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&X.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:n,maxLiveSyncPlaybackRate:o}=this.config;if(!n||o===1)return;const l=this.targetLatency;if(l===null)return;const d=i-l,f=Math.min(this.maxLatency,l+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 _c=["NONE","TYPE-0","TYPE-1",null];var Ia={No:"",Yes:"YES",v2:"v2"};function Sy(s,t){const{canSkipUntil:e,canSkipDateRanges:i,endSN:n}=s,o=t!==void 0?t-n:0;return e&&o<e?i?Ia.v2:Ia.Yes:Ia.No}class U0{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 xa{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 Cc(s,t){const e=t.startPTS;if(Wt(e)){let i=0,n;t.sn>s.sn?(i=e-s.start,n=s):(i=s.start-e,n=t),n.duration!==i&&(n.duration=i)}else t.sn>s.sn?s.cc===t.cc&&s.minEndPTS?t.start=s.start+(s.minEndPTS-s.start):t.start=s.start+s.duration:t.start=Math.max(s.start-t.duration,0)}function B0(s,t,e,i,n,o){i-e<=0&&(X.warn("Fragment should have a positive duration",t),i=e+t.duration,o=n+t.duration);let l=e,d=i;const f=t.startPTS,p=t.endPTS;if(Wt(f)){const w=Math.abs(f-e);Wt(t.deltaPTS)?t.deltaPTS=Math.max(w,t.deltaPTS):t.deltaPTS=w,l=Math.max(e,f),e=Math.min(e,f),n=Math.min(n,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=l,t.startDTS=n,t.endPTS=i,t.minEndPTS=d,t.endDTS=o;const v=t.sn;if(!s||v<s.startSN||v>s.endSN)return 0;let A;const E=v-s.startSN,T=s.fragments;for(T[E]=t,A=E;A>0;A--)Cc(T[A],T[A-1]);for(A=E;A<T.length-1;A++)Cc(T[A],T[A+1]);return s.fragmentHint&&Cc(T[T.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,g}function Ry(s,t){let e=null;const i=s.fragments;for(let f=i.length-1;f>=0;f--){const p=i[f].initSegment;if(p){e=p;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let n=0,o;if(Cy(s,t,(f,p)=>{f.relurl&&(n=f.cc-p.cc),Wt(f.startPTS)&&Wt(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){X.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=Ly(s.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const l=t.fragments;if(n){X.warn("discontinuity sliding from playlist, take drift into account");for(let f=0;f<l.length;f++)l[f].cc+=n}t.skippedSegments&&(t.startCC=t.fragments[0].cc),_y(s.partList,t.partList,(f,p)=>{p.elementaryStreams=f.elementaryStreams,p.stats=f.stats}),o?B0(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):G0(s,t),l.length&&(t.totalduration=t.edge-l[0].start),t.driftStartTime=s.driftStartTime,t.driftStart=s.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=s.driftEndTime,t.driftEnd=s.driftEnd,t.advancedDateTime=s.advancedDateTime}function Ly(s,t,e){const i=ui({},s);return e&&e.forEach(n=>{delete i[n]}),Object.keys(t).forEach(n=>{const o=new n0(t[n].attr,i[n]);o.isValid?i[n]=o:X.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[n].attr)}"`)}),i}function _y(s,t,e){if(s&&t){let i=0;for(let n=0,o=s.length;n<=o;n++){const l=s[n],d=t[n+i];l&&d&&l.index===d.index&&l.fragment.sn===d.fragment.sn?e(l,d):i--}}}function Cy(s,t,e){const i=t.skippedSegments,n=Math.max(s.startSN,t.startSN)-t.startSN,o=(s.fragmentHint?1:0)+(i?t.endSN:Math.min(s.endSN,t.endSN))-t.startSN,l=t.startSN-s.startSN,d=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,f=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments;for(let p=n;p<=o;p++){const g=f[l+p];let v=d[p];i&&!v&&p<i&&(v=t.fragments[p]=g),g&&v&&e(g,v)}}function G0(s,t){const e=t.startSN+t.skippedSegments-s.startSN,i=s.fragments;e<0||e>=i.length||Ic(t,i[e].start)}function Ic(s,t){if(t){const e=s.fragments;for(let i=s.skippedSegments;i<e.length;i++)e[i].start+=t;s.fragmentHint&&(s.fragmentHint.start+=t)}}function Iy(s,t=1/0){let e=1e3*s.targetduration;if(s.updated){const i=s.fragments,n=4;if(i.length&&e*n>t){const o=i[i.length-1].duration*1e3;o<e&&(e=o)}}else e/=2;return Math.round(e)}function xy(s,t,e){if(!(s!=null&&s.details))return null;const i=s.details;let n=i.fragments[t-i.startSN];return n||(n=i.fragmentHint,n&&n.sn===t)?n:t<i.startSN&&e&&e.sn===t?e:null}function V0(s,t,e){var i;return s!=null&&s.details?H0((i=s.details)==null?void 0:i.partList,t,e):null}function H0(s,t,e){if(s)for(let i=s.length;i--;){const n=s[i];if(n.index===e&&n.fragment.sn===t)return n}return null}function No(s){switch(s.details){case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_TIMEOUT:case pt.LEVEL_LOAD_TIMEOUT:case pt.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function W0(s,t){const e=No(t);return s.default[`${e?"timeout":"error"}Retry`]}function xc(s,t){const e=s.backoff==="linear"?1:Math.pow(2,t);return Math.min(e*s.retryDelayMs,s.maxRetryDelayMs)}function j0(s){return Yi(Yi({},s),{errorRetry:null,timeoutRetry:null})}function Uo(s,t,e,i){return!!s&&t<s.maxNumRetry&&(Dy(i)||!!e)}function Dy(s){return s===0&&navigator.onLine===!1||!!s&&(s<400||s>499)}const K0={search:function(s,t){let e=0,i=s.length-1,n=null,o=null;for(;e<=i;){n=(e+i)/2|0,o=s[n];const l=t(o);if(l>0)e=n+1;else if(l<0)i=n-1;else return o}return null}};function Py(s,t,e){if(t===null||!Array.isArray(s)||!s.length||!Wt(t))return null;const i=s[0].programDateTime;if(t<(i||0))return null;const n=s[s.length-1].endProgramDateTime;if(t>=(n||0))return null;e=e||0;for(let o=0;o<s.length;++o){const l=s[o];if(Oy(t,e,l))return l}return null}function Da(s,t,e=0,i=0){let n=null;if(s?n=t[s.sn-t[0].sn+1]||null:e===0&&t[0].start===0&&(n=t[0]),n&&Dc(e,i,n)===0)return n;const o=K0.search(t,Dc.bind(null,e,i));return o&&(o!==s||!n)?o:n}function Dc(s=0,t=0,e){if(e.start<=s&&e.start+e.duration>s)return 0;const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-i<=s?1:e.start-i>s&&e.start?-1:0}function Oy(s,t,e){const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0))*1e3;return(e.endProgramDateTime||0)-i>s}function My(s,t){return K0.search(s,e=>e.cc<t?1:e.cc>t?-1:0)}const $y=3e5;var xi={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},fr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class Fy{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=X.log.bind(X,"[info]:"),this.warn=X.warn.bind(X,"[warning]:"),this.error=X.error.bind(X,"[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,n;if(e.fatal)return;const o=this.hls,l=e.context;switch(e.details){case pt.FRAG_LOAD_ERROR:case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_ERROR:case pt.KEY_LOAD_TIMEOUT:e.errorAction=this.getFragRetryOrSwitchAction(e);return;case pt.FRAG_PARSING_ERROR:if((i=e.frag)!=null&&i.gap){e.errorAction={action:xi.DoNothing,flags:fr.None};return}case pt.FRAG_GAP:case pt.FRAG_DECRYPT_ERROR:{e.errorAction=this.getFragRetryOrSwitchAction(e),e.errorAction.action=xi.SendAlternateToPenaltyBox;return}case pt.LEVEL_EMPTY_ERROR:case pt.LEVEL_PARSING_ERROR:{var d,f;const p=e.parent===Jt.MAIN?e.level:o.loadLevel;e.details===pt.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 pt.LEVEL_LOAD_ERROR:case pt.LEVEL_LOAD_TIMEOUT:typeof(l==null?void 0:l.level)=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,l.level));return;case pt.AUDIO_TRACK_LOAD_ERROR:case pt.AUDIO_TRACK_LOAD_TIMEOUT:case pt.SUBTITLE_LOAD_ERROR:case pt.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){const p=o.levels[o.loadLevel];if(p&&(l.type===ke.AUDIO_TRACK&&l.groupId===p.audioGroupId||l.type===ke.SUBTITLE_TRACK&&l.groupId===p.textGroupId)){e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o.loadLevel),e.errorAction.action=xi.SendAlternateToPenaltyBox,e.errorAction.flags=fr.MoveAllAlternatesMatchingHost;return}}return;case pt.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const p=o.levels[o.loadLevel],g=p==null?void 0:p.attrs["HDCP-LEVEL"];g&&(e.errorAction={action:xi.SendAlternateToPenaltyBox,flags:fr.MoveAllAlternatesMatchingHDCP,hdcpLevel:g})}return;case pt.BUFFER_ADD_CODEC_ERROR:case pt.REMUX_ALLOC_ERROR:e.errorAction=this.getLevelSwitchAction(e,(n=e.level)!=null?n:o.loadLevel);return;case pt.INTERNAL_EXCEPTION:case pt.BUFFER_APPENDING_ERROR:case pt.BUFFER_APPEND_ERROR:case pt.BUFFER_FULL_ERROR:case pt.LEVEL_SWITCH_ERROR:case pt.BUFFER_STALLED_ERROR:case pt.BUFFER_SEEK_OVER_HOLE:case pt.BUFFER_NUDGE_ON_STALL:e.errorAction={action:xi.DoNothing,flags:fr.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 n=this.hls,o=W0(n.config.playlistLoadPolicy,t),l=this.playlistError++,d=(i=t.response)==null?void 0:i.code;if(Uo(o,l,No(t),d))return{action:xi.RetryRequest,flags:fr.None,retryConfig:o,retryCount:l};const f=this.getLevelSwitchAction(t,e);return o&&(f.retryConfig=o,f.retryCount=l),f}getFragRetryOrSwitchAction(t){const e=this.hls,i=this.getVariantLevelIndex(t.frag),n=e.levels[i],{fragLoadPolicy:o,keyLoadPolicy:l}=e.config,d=W0(t.details.startsWith("key")?l:o,t),f=e.levels.reduce((v,A)=>v+A.fragmentError,0);if(n){var p;t.details!==pt.FRAG_GAP&&n.fragmentError++;const v=(p=t.response)==null?void 0:p.code;if(Uo(d,f,No(t),v))return{action:xi.RetryRequest,flags:fr.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 n=this.hls.levels[e];if(n&&(n.loadError++,i.autoLevelEnabled)){var o,l;let d=-1;const{levels:f,loadLevel:p,minAutoLevel:g,maxAutoLevel:v}=i,A=(o=t.frag)==null?void 0:o.type,{type:E,groupId:T}=(l=t.context)!=null?l:{};for(let w=f.length;w--;){const C=(w+p)%f.length;if(C!==p&&C>=g&&C<=v&&f[C].loadError===0){const D=f[C];if(t.details===pt.FRAG_GAP&&t.frag){const M=f[C].details;if(M){const U=Da(t.frag,M.fragments,t.frag.start);if(U!=null&&U.gap)continue}}else if(E===ke.AUDIO_TRACK&&T===D.audioGroupId||E===ke.SUBTITLE_TRACK&&T===D.textGroupId||A===Jt.AUDIO&&n.audioGroupId===D.audioGroupId||A===Jt.SUBTITLE&&n.textGroupId===D.textGroupId)continue;d=C;break}}if(d>-1&&i.loadLevel!==d)return t.levelRetry=!0,this.playlistError=0,{action:xi.SendAlternateToPenaltyBox,flags:fr.None,nextAutoLevel:d}}return{action:xi.SendAlternateToPenaltyBox,flags:fr.MoveAllAlternatesMatchingHost}}onErrorOut(t,e){var i;switch((i=e.errorAction)==null?void 0:i.action){case xi.DoNothing:break;case xi.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),!e.errorAction.resolved&&e.details!==pt.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:n,hdcpLevel:o,nextAutoLevel:l}=i;switch(n){case fr.None:this.switchLevel(t,l);break;case fr.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(t));break;case fr.MoveAllAlternatesMatchingHDCP:o&&(e.maxHdcpLevel=_c[_c.indexOf(o)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(t,l)}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,n=t.parent===Jt.MAIN?t.level:e.loadLevel,o=e.levels[n],l=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<l;f++){const p=(d+f)%l,g=i[p];if(!g||Ny(g,t,i[d]))return this.warn(`Switching to Redundant Stream ${p+1}/${l}: "${o.url[p]}" after ${t.details}`),this.playlistError=0,e.levels.forEach(v=>{v.urlId=p}),e.nextLoadLevel=n,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:i}=this,n=i[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};n.lastErrorPerfMs=performance.now(),n.errors.push(e),n.details=t.details,i[t.urlId]=n}}function Ny(s,t,e){if(performance.now()-s.lastErrorPerfMs>$y)return!0;const i=s.details;if(t.details===pt.FRAG_GAP&&i&&t.frag){const n=t.frag.start,o=Da(null,i.fragments,n);if(o&&!o.gap)return!0}if(e&&s.errors.length<e.errors.length){const n=s.errors[s.errors.length-1];if(i&&n.frag&&t.frag&&Math.abs(n.frag.start-t.frag.start)>i.targetduration*3)return!0}return!1}class Pc{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=X.log.bind(X,`${e}:`),this.warn=X.warn.bind(X,`${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 n=-1;for(let o=0;o<i.length;o++){const l=i[o];let d;try{d=new self.URL(l.URI,e.url).href}catch(f){X.warn(`Could not construct new URL for Rendition Report: ${f}`),d=l.URI||""}if(d===t){n=o;break}else d===t.substring(0,d.length)&&(n=o)}if(n!==-1){const o=i[n],l=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 U0(l,d>=0?d:void 0,Ia.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:n,stats:o}=e,l=self.performance.now(),d=o.loading.first?Math.max(0,l-o.loading.first):0;if(n.advancedDateTime=Date.now()-d,n.live||i!=null&&i.live){if(n.reloaded(i),i&&this.log(`live playlist ${t} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),i&&n.fragments.length>0&&Ry(i,n),!this.canLoad||!n.live)return;let f,p,g;if(n.canBlockReload&&n.endSN&&n.advanced){const C=this.hls.config.lowLatencyMode,D=n.lastPartSn,M=n.endSN,U=n.lastPartIndex,x=U!==-1,G=D===M,$=C?0:U;x?(p=G?M+1:D,g=G?$:U+1):p=M+1;const Y=n.age,tt=Y+n.ageHeader;let nt=Math.min(tt-n.partTarget,n.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: ${n.age}`),nt=0;else{const J=Math.floor(nt/n.targetduration);if(p+=J,g!==void 0){const St=Math.round(nt%n.targetduration/n.partTarget);g+=St}this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${Y.toFixed(2)}s goal: ${nt} skip sn ${J} to part ${g}`)}n.tuneInGoal=nt}if(f=this.getDeliveryDirectives(n,e.deliveryDirectives,p,g),C||!G){this.loadPlaylist(f);return}}else(n.canBlockReload||n.canSkipUntil)&&(f=this.getDeliveryDirectives(n,e.deliveryDirectives,p,g));const v=this.hls.mainForwardBufferInfo,A=v?v.end-v.len:0,E=(n.edge-A)*1e3,T=Iy(n,E);n.updated&&l>this.requestScheduled+T&&(this.requestScheduled=o.loading.start),p!==void 0&&n.canBlockReload?this.requestScheduled=o.loading.first+T-(n.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+T<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=T);let w=this.requestScheduled-l;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,n){let o=Sy(t,i);return e!=null&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,n=e.part,o=Ia.No),new U0(i,n,o)}checkRetry(t){const e=t.details,i=No(t),n=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=n||{},f=!!n&&!!d&&(o===xi.RetryRequest||!n.resolved&&o===xi.SendAlternateToPenaltyBox);if(f){var p;if(this.requestScheduled=-1,l>=d.maxNumRetry)return!1;if(i&&(p=t.context)!=null&&p.deliveryDirectives)this.warn(`Retrying playlist loading ${l+1}/${d.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const g=xc(d,l);this.timer=self.setTimeout(()=>this.loadPlaylist(),g),this.warn(`Retrying playlist loading ${l+1}/${d.maxNumRetry} after "${e}" in ${g}ms`)}t.levelRetry=!0,n.resolved=!0}return f}}let Oc;class Uy extends Pc{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=[],n={};let o;e.levels.forEach(l=>{var d;const f=l.attrs;((d=l.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(Oc||(Oc=/chrome|firefox/i.test(navigator.userAgent)),Oc&&(l.audioCodec=void 0));const{AUDIO:p,CODECS:g,"FRAME-RATE":v,"PATHWAY-ID":A,RESOLUTION:E,SUBTITLES:T}=f,w=`${`${A||"."}-`}${l.bitrate}-${E}-${v}-${g}`;o=n[w],o?o.addFallback(l):(o=new xa(l),n[w]=o,i.push(o)),Bo(o,"audio",p),Bo(o,"text",T)}),this.filterAndSortMediaOptions(i,e)}filterAndSortMediaOptions(t,e){let i=[],n=[],o=!1,l=!1,d=!1,f=t.filter(({audioCodec:E,videoCodec:T,width:w,height:C,unknownCodecs:D})=>(o||(o=!!(w&&C)),l||(l=!!T),d||(d=!!E),!(D!=null&&D.length)&&(!E||kc(E,"audio"))&&(!T||kc(T,"video"))));if((o||l)&&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:pt.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:E,reason:E.message})}});return}e.audioTracks&&(i=e.audioTracks.filter(E=>!E.audioCodec||kc(E.audioCodec,"audio")),Y0(i)),e.subtitles&&(n=e.subtitles,Y0(n));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&&!l,A={levels:f,audioTracks:i,subtitleTracks:n,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:d,video:l,altAudio:!v&&i.some(E=>!!E.url)};this.hls.trigger(R.MANIFEST_PARSED,A),(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:pt.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,n=this.currentLevel,o=n?n.attrs["PATHWAY-ID"]:void 0,l=e[t],d=l.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=l,i===t&&l.details&&n&&o===d)return;this.log(`Switching to level ${t}${d?" with Pathway "+d:""} from level ${i}${o?" with Pathway "+o:""}`);const f=ui({},l,{level:t,maxBitrate:l.maxBitrate,attrs:l.attrs,uri:l.uri,urlId:l.urlId});delete f._attrs,delete f._urlId,this.hls.trigger(R.LEVEL_SWITCHING,f);const p=l.details;if(!p||p.live){const g=this.switchParams(l.uri,n==null?void 0:n.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===ke.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:n,details:o}=e,l=this._levels[n];if(!l){var d;this.warn(`Invalid level index ${n}`),(d=e.deliveryDirectives)!=null&&d.skip&&(o.deltaUpdateFailed=!0);return}n===this.currentLevelIndex?(l.fragmentError===0&&(l.loadError=0),this.playlistLoaded(n,e,l.details)):(i=e.deliveryDirectives)!=null&&i.skip&&(o.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const i=this.currentLevel;if(!i)return;const n=this.hls.audioTracks[e.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==n){let o=-1;for(let l=0;l<i.audioGroupIds.length;l++)if(i.audioGroupIds[l]===n){o=l;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 n=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 l=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${l?" Pathway "+l:""} URI ${n+1}/${i.url.length} ${o}`),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:o,level:e,id:n,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,l)=>l!==e,n=this._levels.filter((o,l)=>l!==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:n})}onLevelsUpdated(t,{levels:e}){e.forEach((i,n)=>{const{details:o}=i;o!=null&&o.fragments&&o.fragments.forEach(l=>{l.level=n})}),this._levels=e}}function Bo(s,t,e){e&&(t==="audio"?(s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds[s.url.length-1]=e):t==="text"&&(s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds[s.url.length-1]=e))}function Y0(s){const t={};s.forEach(e=>{const i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}var yi={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class By{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 n=i.length;n--;){const o=i[n];if(!o)break;const l=o.end;if(o.start<=t&&l!==null&&t<=l)return o}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:i}=this,n=Object.keys(i);for(let o=n.length;o--;){const l=i[n[o]];if((l==null?void 0:l.body.type)===e&&l.buffered){const d=l.body;if(d.start<=t&&t<=d.end)return d}}return null}detectEvictedFragments(t,e,i,n){this.timeRanges&&(this.timeRanges[t]=e);const o=(n==null?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach(l=>{const d=this.fragments[l];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:n}=t;if(!e||i.sn==="initSegment")return;const o=In(i),l=this.fragments[o];if(!l||l.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;l.range[f]=this.getBufferedTimes(i,n,v,g)}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,(l.body.endList=i.endList||l.body.endList)&&(this.endListFragments[l.body.type]=l),Go(l)||this.removeParts(i.sn-1,i.type)):this.removeFragment(l.body)}removeParts(t,e){const i=this.activePartLists[e];i&&(this.activePartLists[e]=i.filter(n=>n.fragment.sn>=t))}fragBuffered(t,e){const i=In(t);let n=this.fragments[i];!n&&e&&(n=this.fragments[i]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,n.buffered=!0)}getBufferedTimes(t,e,i,n){const o={time:[],partial:i},l=t.start,d=t.end,f=t.minEndPTS||d,p=t.maxStartPTS||l;for(let g=0;g<n.length;g++){const v=n.start(g)-this.bufferPadding,A=n.end(g)+this.bufferPadding;if(p>=v&&f<=A){o.time.push({startPTS:Math.max(l,n.start(g)),endPTS:Math.min(d,n.end(g))});break}else if(l<A&&d>v)o.partial=!0,o.time.push({startPTS:Math.max(l,n.start(g)),endPTS:Math.min(d,n.end(g))});else if(d<=v)break}return o}getPartialFragment(t){let e=null,i,n,o,l=0;const{bufferPadding:d,fragments:f}=this;return Object.keys(f).forEach(p=>{const g=f[p];g&&Go(g)&&(n=g.body.start-d,o=g.body.end+d,t>=n&&t<=o&&(i=Math.min(t-n,o-t),l<=i&&(e=g.body,l=i)))}),e}isEndListAppended(t){const e=this.endListFragments[t];return e!==void 0&&(e.buffered||Go(e))}getState(t){const e=In(t),i=this.fragments[e];return i?i.buffered?Go(i)?yi.PARTIAL:yi.OK:yi.APPENDING:yi.NOT_LOADED}isTimeBuffered(t,e,i){let n,o;for(let l=0;l<i.length;l++){if(n=i.start(l)-this.bufferPadding,o=i.end(l)+this.bufferPadding,t>=n&&e<=o)return!0;if(e<=n)return!1}return!1}onFragLoaded(t,e){const{frag:i,part:n}=e;if(i.sn==="initSegment"||i.bitrateTest)return;const o=n?null:e,l=In(i);this.fragments[l]={body:i,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:i,part:n,timeRanges:o}=e;if(i.sn==="initSegment")return;const l=i.type;if(n){let d=this.activePartLists[l];d||(this.activePartLists[l]=d=[]),d.push(n)}this.timeRanges=o,Object.keys(o).forEach(d=>{const f=o[d];this.detectEvictedFragments(d,f,l,n)})}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=In(t);return!!this.fragments[e]}hasParts(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)}removeFragmentsInRange(t,e,i,n,o){n&&!this.hasGaps||Object.keys(this.fragments).forEach(l=>{const d=this.fragments[l];if(!d)return;const f=d.body;f.type!==i||n&&!f.gap||f.start<e&&f.end>t&&(d.buffered||o)&&this.removeFragment(f)})}removeFragment(t){const e=In(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const i=this.activePartLists[t.type];if(i){const n=t.sn;this.activePartLists[t.type]=i.filter(o=>o.fragment.sn!==n)}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 Go(s){var t,e,i;return s.buffered&&(s.body.gap||((t=s.range.video)==null?void 0:t.partial)||((e=s.range.audio)==null?void 0:e.partial)||((i=s.range.audiovideo)==null?void 0:i.partial))}function In(s){return`${s.type}_${s.level}_${s.urlId}_${s.sn}`}const z0=Math.pow(2,17);class Gy{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 ns({type:Qt.NETWORK_ERROR,details:pt.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const n=this.config,o=n.fLoader,l=n.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap)if(t.tagList.some(E=>E[0]==="GAP")){f(Z0(t));return}else t.gap=!1;const p=this.loader=t.loader=o?new o(n):new l(n),g=X0(t),v=j0(n.fragLoadPolicy.default),A={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:z0};t.stats=p.stats,p.load(g,A,{onSuccess:(E,T,w,C)=>{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:C})},onError:(E,T,w,C)=>{this.resetLoader(t,p),f(new ns({type:Qt.NETWORK_ERROR,details:pt.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:Yi({url:i,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:C}))},onAbort:(E,T,w)=>{this.resetLoader(t,p),f(new ns({type:Qt.NETWORK_ERROR,details:pt.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:w,stats:E}))},onTimeout:(E,T,w)=>{this.resetLoader(t,p),f(new ns({type:Qt.NETWORK_ERROR,details:pt.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:w,stats:E}))},onProgress:(E,T,w,C)=>{e&&e({frag:t,part:null,payload:w,networkDetails:C})}})})}loadPart(t,e,i){this.abort();const n=this.config,o=n.fLoader,l=n.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap){f(Z0(t,e));return}const p=this.loader=t.loader=o?new o(n):new l(n),g=X0(t,e),v=j0(n.fragLoadPolicy.default),A={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:z0};e.stats=p.stats,p.load(g,A,{onSuccess:(E,T,w,C)=>{this.resetLoader(t,p),this.updateStatsFromPart(t,e);const D={frag:t,part:e,payload:E.data,networkDetails:C};i(D),d(D)},onError:(E,T,w,C)=>{this.resetLoader(t,p),f(new ns({type:Qt.NETWORK_ERROR,details:pt.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:Yi({url:g.url,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:C}))},onAbort:(E,T,w)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,p),f(new ns({type:Qt.NETWORK_ERROR,details:pt.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 ns({type:Qt.NETWORK_ERROR,details:pt.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:w,stats:E}))}})})}updateStatsFromPart(t,e){const i=t.stats,n=e.stats,o=n.total;if(i.loaded+=n.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 l=i.loading,d=n.loading;l.start?l.first+=d.first-d.start:(l.start=d.start,l.first=d.first),l.end=d.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function X0(s,t=null){const e=t||s,i={frag:s,part:t,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},n=e.byteRangeStartOffset,o=e.byteRangeEndOffset;if(Wt(n)&&Wt(o)){var l;let d=n,f=o;if(s.sn==="initSegment"&&((l=s.decryptdata)==null?void 0:l.method)==="AES-128"){const p=o-n;p%16&&(f=o+(16-p%16)),n!==0&&(i.resetIV=!0,d=n-16)}i.rangeStart=d,i.rangeEnd=f}return i}function Z0(s,t){const e=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:Qt.MEDIA_ERROR,details:pt.FRAG_GAP,fatal:!1,frag:s,error:e,networkDetails:null};return t&&(i.part=t),(t||s).stats.aborted=!0,new ns(i)}class ns extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class Vy{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=pt.KEY_LOAD_ERROR,i,n,o){return new ns({type:Qt.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:o,error:i,networkDetails:n})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:n}=t;for(let o=0;o<e.length;o++){const l=e[o];if(n<=l.cc&&(i==="initSegment"||l.sn==="initSegment"||i<l.sn)){this.emeController.selectKeySystemFormat(l).then(d=>{l.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,n;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,pt.KEY_LOAD_ERROR,p))}const l=o.uri;if(!l)return Promise.reject(this.createKeyLoadError(t,pt.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${l}"`)));let d=this.keyUriToKeyInfo[l];if((i=d)!=null&&i.decryptdata.key)return o.key=d.decryptdata.key,Promise.resolve({frag:t,keyInfo:d});if((n=d)!=null&&n.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[l]={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,pt.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 n=this.emeController.loadKey(i);if(n)return(t.keyLoadPromise=n.then(o=>(t.mediaKeySessionContext=o,i))).catch(o=>{throw t.keyLoadPromise=null,o})}return Promise.resolve(i)}loadKeyHTTP(t,e){const i=this.config,n=i.loader,o=new n(i);return e.keyLoader=t.loader=o,t.keyLoadPromise=new Promise((l,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:(A,E,T,w)=>{const{frag:C,keyInfo:D,url:M}=T;if(!C.decryptdata||D!==this.keyUriToKeyInfo[M])return d(this.createKeyLoadError(C,pt.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));D.decryptdata.key=C.decryptdata.key=new Uint8Array(A.data),C.keyLoader=null,D.loader=null,l({frag:C,keyInfo:D})},onError:(A,E,T,w)=>{this.resetLoader(E),d(this.createKeyLoadError(e,pt.KEY_LOAD_ERROR,new Error(`HTTP Error ${A.code} loading key ${A.text}`),T,Yi({url:f.url,data:void 0},A)))},onTimeout:(A,E,T)=>{this.resetLoader(E),d(this.createKeyLoadError(e,pt.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:(A,E,T)=>{this.resetLoader(E),d(this.createKeyLoadError(e,pt.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};o.load(f,g,v)})}resetLoader(t){const{frag:e,keyInfo:i,url:n}=t,o=i.loader;e.keyLoader===o&&(e.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[n],o&&o.destroy()}}class Hy{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 Ge{static isBuffered(t,e){try{if(t){const i=Ge.getBuffered(t);for(let n=0;n<i.length;n++)if(e>=i.start(n)&&e<=i.end(n))return!0}}catch{}return!1}static bufferInfo(t,e,i){try{if(t){const n=Ge.getBuffered(t),o=[];let l;for(l=0;l<n.length;l++)o.push({start:n.start(l),end:n.end(l)});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 n=[];if(i)for(let p=0;p<t.length;p++){const g=n.length;if(g){const v=n[g-1].end;t[p].start-v<i?t[p].end>v&&(n[g-1].end=t[p].end):n.push(t[p])}else n.push(t[p])}else n=t;let o=0,l,d=e,f=e;for(let p=0;p<n.length;p++){const g=n[p].start,v=n[p].end;if(e+i>=g&&e<v)d=g,f=v,o=f-e;else if(e+i<g){l=g;break}}return{len:o,start:d||0,end:f||0,nextStart:l}}static getBuffered(t){try{return t.buffered}catch(e){return X.log("failed to get media.buffered",e),Wy}}}class Mc{constructor(t,e,i,n=0,o=-1,l=!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=Vo(),this.buffering={audio:Vo(),video:Vo(),audiovideo:Vo()},this.level=t,this.sn=e,this.id=i,this.size=n,this.part=o,this.partial=l}}function Vo(){return{start:0,executeStart:0,executeEnd:0,end:0}}function q0(s,t){let e=null;for(let i=0,n=s.length;i<n;i++){const o=s[i];if(o&&o.cc===t){e=o;break}}return e}function jy(s,t,e){return!!(t.details&&(e.endCC>e.startCC||s&&s.cc<e.startCC))}function Ky(s,t,e=0){const i=s.fragments,n=t.fragments;if(!n.length||!i.length){X.log("No fragments to align");return}const o=q0(i,n[0].cc);if(!o||o&&!o.startPTS){X.log("No frag in previous level to align on");return}return o}function Q0(s,t){if(s){const e=s.start+t;s.start=s.startPTS=e,s.endPTS=e+s.duration}}function $c(s,t){const e=t.fragments;for(let i=0,n=e.length;i<n;i++)Q0(e[i],s);t.fragmentHint&&Q0(t.fragmentHint,s),t.alignedSliding=!0}function Yy(s,t,e){t&&(zy(s,e,t),!e.alignedSliding&&t.details&&Xy(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&G0(t.details,e))}function zy(s,t,e){if(jy(s,e,t)){const i=Ky(e.details,t);i&&Wt(i.start)&&(X.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),$c(i.start,t))}}function Xy(s,t){if(!t.fragments.length||!s.hasProgramDateTime||!t.hasProgramDateTime)return;const e=t.fragments[0].programDateTime,i=s.fragments[0].programDateTime,n=(i-e)/1e3+t.fragments[0].start;n&&Wt(n)&&(X.log(`Adjusting PTS using programDateTime delta ${i-e}ms, sliding:${n.toFixed(3)} ${s.url} `),$c(n,s))}function J0(s,t){if(!s.hasProgramDateTime||!t.hasProgramDateTime)return;const e=s.fragments,i=t.fragments;if(!e.length||!i.length)return;const n=Math.round(i.length/2)-1,o=i[n],l=q0(e,o.cc)||e[Math.round(e.length/2)-1],d=o.programDateTime,f=l.programDateTime;if(d===null||f===null)return;const p=(f-d)/1e3-(l.start-o.start);$c(p,s)}class Zy{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 qy{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 Qy(s){const t=s.byteLength,e=t&&new DataView(s.buffer).getUint8(t-1);return e?hn(s,0,t-e):s}class Jy{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 n=0;n<4;n++)i[n]=e.getUint32(n*4);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,n=i[0],o=i[1],l=i[2],d=i[3],f=this.invSubMix,p=f[0],g=f[1],v=f[2],A=f[3],E=new Uint32Array(256);let T=0,w=0,C=0;for(C=0;C<256;C++)C<128?E[C]=C<<1:E[C]=C<<1^283;for(C=0;C<256;C++){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],U=E[M],x=E[U];let G=E[D]*257^D*16843008;n[T]=G<<24|G>>>8,o[T]=G<<16|G>>>16,l[T]=G<<8|G>>>24,d[T]=G,G=x*16843009^U*65537^M*257^T*16843008,p[D]=G<<24|G>>>8,g[D]=G<<16|G>>>16,v[D]=G<<8|G>>>24,A[D]=G,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,n=0;for(;n<e.length&&i;)i=e[n]===this.key[n],n++;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 l=this.ksRows=(o+6+1)*4;let d,f;const p=this.keySchedule=new Uint32Array(l),g=this.invKeySchedule=new Uint32Array(l),v=this.sBox,A=this.rcon,E=this.invSubMix,T=E[0],w=E[1],C=E[2],D=E[3];let M,U;for(d=0;d<l;d++){if(d<o){M=p[d]=e[d];continue}U=M,d%o===0?(U=U<<8|U>>>24,U=v[U>>>24]<<24|v[U>>>16&255]<<16|v[U>>>8&255]<<8|v[U&255],U^=A[d/o|0]<<24):o>6&&d%o===4&&(U=v[U>>>24]<<24|v[U>>>16&255]<<16|v[U>>>8&255]<<8|v[U&255]),p[d]=M=(p[d-o]^U)>>>0}for(f=0;f<l;f++)d=l-f,f&3?U=p[d]:U=p[d-4],f<4||d<=4?g[f]=U:g[f]=T[v[U>>>24]]^w[v[U>>>16&255]]^C[v[U>>>8&255]]^D[v[U&255]],g[f]=g[f]>>>0}networkToHostOrderSwap(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24}decrypt(t,e,i){const n=this.keySize+6,o=this.invKeySchedule,l=this.invSBox,d=this.invSubMix,f=d[0],p=d[1],g=d[2],v=d[3],A=this.uint8ArrayToUint32Array_(i);let E=A[0],T=A[1],w=A[2],C=A[3];const D=new Int32Array(t),M=new Int32Array(D.length);let U,x,G,$,Y,tt,nt,J,St,mt,Ot,Vt,V,q;const At=this.networkToHostOrderSwap;for(;e<D.length;){for(St=At(D[e]),mt=At(D[e+1]),Ot=At(D[e+2]),Vt=At(D[e+3]),Y=St^o[0],tt=Vt^o[1],nt=Ot^o[2],J=mt^o[3],V=4,q=1;q<n;q++)U=f[Y>>>24]^p[tt>>16&255]^g[nt>>8&255]^v[J&255]^o[V],x=f[tt>>>24]^p[nt>>16&255]^g[J>>8&255]^v[Y&255]^o[V+1],G=f[nt>>>24]^p[J>>16&255]^g[Y>>8&255]^v[tt&255]^o[V+2],$=f[J>>>24]^p[Y>>16&255]^g[tt>>8&255]^v[nt&255]^o[V+3],Y=U,tt=x,nt=G,J=$,V=V+4;U=l[Y>>>24]<<24^l[tt>>16&255]<<16^l[nt>>8&255]<<8^l[J&255]^o[V],x=l[tt>>>24]<<24^l[nt>>16&255]<<16^l[J>>8&255]<<8^l[Y&255]^o[V+1],G=l[nt>>>24]<<24^l[J>>16&255]<<16^l[Y>>8&255]<<8^l[tt&255]^o[V+2],$=l[J>>>24]<<24^l[Y>>16&255]<<16^l[tt>>8&255]<<8^l[nt&255]^o[V+3],M[e]=At(U^E),M[e+1]=At($^T),M[e+2]=At(G^w),M[e+3]=At(x^C),E=St,T=mt,w=Ot,C=Vt,e=e+4}return M.buffer}}const tb=16;class Fc{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?Qy(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((n,o)=>{this.softwareDecrypt(new Uint8Array(t),e,i);const l=this.flush();l?n(l.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,i)}softwareDecrypt(t,e,i){const{currentIV:n,currentResult:o,remainderData:l}=this;this.logOnce("JS AES decrypt"),l&&(t=dn(l,t),this.remainderData=null);const d=this.getValidChunk(t);if(!d.length)return null;n&&(i=n);let f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new Jy),f.expandKey(e);const p=o;return this.currentResult=f.decrypt(d.buffer,0,i),this.currentIV=hn(d,-16).buffer,p||null}webCryptoDecrypt(t,e,i){const n=this.subtle;return(this.key!==e||!this.fastAesKey)&&(this.key=e,this.fastAesKey=new qy(n,e)),this.fastAesKey.expandKey().then(o=>n?(this.logOnce("WebCrypto AES decrypt"),new Zy(n,new Uint8Array(i)).decrypt(t.buffer,o)):Promise.reject(new Error("web crypto not initialized"))).catch(o=>(X.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 n=this.flush();if(n)return n.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const i=t.length-t.length%tb;return i!==t.length&&(e=hn(t,0,i),this.remainderData=hn(t,i)),e}logOnce(t){this.logEnabled&&(X.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const eb={toString:function(s){let t="";const e=s.length;for(let i=0;i<e;i++)t+=`[${s.start(i).toFixed(3)}-${s.end(i).toFixed(3)}]`;return t}},wt={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 Nc extends Hy{constructor(t,e,i,n,o){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=wt.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=n,this.log=X.log.bind(X,`${n}:`),this.warn=X.warn.bind(X,`${n}:`),this.hls=t,this.fragmentLoader=new Gy(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new Fc(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=wt.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 Ge.isBuffered(this.media,o.start+o.duration/2)}const n=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)}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 n=this.config;this.levels&&n.autoStartLoad&&this.state===wt.STOPPED&&this.startLoad(n.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:n,state:o}=this,l=i?i.currentTime:0,d=Ge.bufferInfo(n||i,l,t.maxBufferHole);if(this.log(`media seeking to ${Wt(l)?l.toFixed(3):l}, state: ${o}`),this.state===wt.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=l>g;(l<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(l,1/0,this.playlistType,!0),this.lastCurrentTime=l),!this.loadedmetadata&&!d.len&&(this.nextLoadPosition=this.startPosition=l),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=wt.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 n=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,n).then(o=>{if(!o)return;const l=this.state;if(this.fragContextChanged(t)){(l===wt.FRAG_LOADING||!this.fragCurrent&&l===wt.PARSING)&&(this.fragmentTracker.removeFragment(t),this.state=wt.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===wt.STOPPED||this.state===wt.ERROR||(this.warn(o),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===yi.APPENDING){const n=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,n),l=Math.max(t.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(l)&&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)===yi.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 n={startOffset:t,endOffset:e,type:i};this.hls.trigger(R.BUFFER_FLUSHING,n)}_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:n}=this,{payload:o}=i,l=t.decryptdata;if(o&&o.byteLength>0&&l&&l.key&&l.iv&&l.method==="AES-128"){const d=self.performance.now();return this.decrypter.decrypt(new Uint8Array(o),l.key.buffer,l.iv.buffer).catch(f=>{throw n.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.FRAG_DECRYPT_ERROR,fatal:!1,error:f,reason:f.message,frag:t}),f}).then(f=>{const p=self.performance.now();return n.trigger(R.FRAG_DECRYPTED,{frag:t,payload:f,stats:{tstart:d,tdecrypt:p}}),i.payload=f,i})}return i}).then(i=>{const{fragCurrent:n,hls:o,levels:l}=this;if(!l)throw new Error("init load aborted, missing levels");const d=t.stats;this.state=wt.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===n&&o.trigger(R.FRAG_BUFFERED,{stats:d,frag:n,part:null,id:t.type}),this.tick()}).catch(i=>{this.state===wt.STOPPED||this.state===wt.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,n,o,l;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)}-${((n=t.endPTS)!=null?n:NaN).toFixed(3)}] > buffer:${d?eb.toString(Ge.getBuffered(d)):"(detached)"})`),this.state=wt.IDLE,d&&(!this.loadedmetadata&&t.type==Jt.MAIN&&d.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:i,part:n,partsLoaded:o}=t,l=!o||o.length===0||o.some(f=>!f),d=new Mc(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!l);e.flush(d)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,i=null,n){var o;const l=e==null?void 0:e.details;if(!this.levels||!l)throw new Error(`frag load aborted, missing level${l?"":" detail"}s`);let d=null;if(t.encrypted&&!((o=t.decryptdata)!=null&&o.key)?(this.log(`Loading key for ${t.sn} of [${l.startSN}-${l.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${t.level}`),this.state=wt.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===wt.KEY_LOADING&&(this.state=wt.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&&l.encryptedFragments.length&&this.keyLoader.loadClear(t,l.encryptedFragments),i=Math.max(t.start,i||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){const g=l.partList;if(g&&n){i>t.end&&l.fragmentHint&&(t=l.fragmentHint);const v=this.getNextPart(g,t,i);if(v>-1){const A=g[v];this.log(`Loading part sn: ${t.sn} p: ${A.index} cc: ${t.cc} of playlist [${l.startSN}-${l.endSN}] parts [0-${v}-${g.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=A.start+A.duration,this.state=wt.FRAG_LOADING;let E;return d?E=d.then(T=>!T||this.fragContextChanged(T.frag)?null:this.doFragPartsLoad(t,A,e,n)).catch(T=>this.handleFragLoadError(T)):E=this.doFragPartsLoad(t,A,e,n).catch(T=>this.handleFragLoadError(T)),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:A,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} ${l?"of ["+l.startSN+"-"+l.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),Wt(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=wt.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,n)).catch(g=>this.handleFragLoadError(g)):p=Promise.all([this.fragmentLoader.load(t,f?n:void 0),d]).then(([g])=>(!f&&g&&n&&n(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,n){return new Promise((o,l)=>{var d;const f=[],p=(d=i.details)==null?void 0:d.partList,g=v=>{this.fragmentLoader.loadPart(t,v,n).then(A=>{f[v.index]=A;const E=A.part;this.hls.trigger(R.FRAG_LOADED,A);const T=V0(i,t.sn,v.index+1)||H0(p,t.sn,v.index+1);if(T)g(T);else return o({frag:t,part:E,partsLoaded:f})}).catch(l)};g(e)})}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===pt.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:pt.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==wt.PARSING){!this.fragCurrent&&this.state!==wt.STOPPED&&this.state!==wt.ERROR&&(this.state=wt.IDLE);return}const{frag:i,part:n,level:o}=e,l=self.performance.now();i.stats.parsing.end=l,n&&(n.stats.parsing.end=l),this.updateLevelTiming(i,n,o,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:i}=this,{level:n,sn:o,part:l}=t;if(!(e!=null&&e[n]))return this.warn(`Levels object was unset while buffering fragment ${o} of level ${n}. The current chunk will not be buffered.`),null;const d=e[n],f=l>-1?V0(d,o,l):null,p=f?f.fragment:xy(d,o,i);return p?(i&&i!==p&&(p.stats=i.stats),{frag:p,part:f,level:d}):null}bufferFragmentData(t,e,i,n,o){var l;if(!t||this.state!==wt.PARSING)return;const{data1:d,data2:f}=t;let p=d;if(d&&f&&(p=dn(d,f)),!((l=p)!=null&&l.length))return;const g={type:t.type,frag:e,part:i,chunkMeta:n,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(!Ge.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}const i=e.currentTime,n=Ge.bufferInfo(e,i,0),o=t.duration,l=Math.min(this.config.maxFragLookUpTolerance*2,o*.25),d=Math.max(Math.min(t.start-l,n.end-l),i+l);t.start-d>l&&this.flushMainBuffer(d,t.start)}getFwdBufferInfo(t,e){const i=this.getLoadPosition();return Wt(i)?this.getFwdBufferInfoAtPos(t,i,e):null}getFwdBufferInfoAtPos(t,e,i){const{config:{maxBufferHole:n}}=this,o=Ge.bufferInfo(t,e,n);if(o.len===0&&o.nextStart!==void 0){const l=this.fragmentTracker.getBufferedFrag(e,i);if(l&&o.nextStart<l.end)return Ge.bufferInfo(t,e,Math.max(o.nextStart,n))}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,n=i.length;if(!n)return null;const{config:o}=this,l=i[0].start;let d;if(e.live){const f=o.initialLiveManifestSize;if(n<f)return this.warn(`Not enough fragments to start playback (have: ${n}, 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<=l&&(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===yi.OK||i===yi.PARTIAL&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,i,n,o){const l=t.gap,d=this.getNextFragment(this.nextLoadPosition,e);if(d===null)return d;if(t=d,l&&t&&!t.gap&&i.nextStart){const f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n);if(f!==null&&i.len+f.len>=o)return this.log(`buffer full after gaps in "${n}" 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 n=-1,o=!1,l=!0;for(let d=0,f=t.length;d<f;d++){const p=t[d];if(l=l&&!p.independent,n>-1&&i<p.start)break;const g=p.loaded;g?n=-1:(o||p.independent||l)&&p.fragment===e&&(n=d),o=g}return n}loadedEndOfParts(t,e){const i=t[t.length-1];return i&&e>i.start&&i.loaded}getInitialLiveFragment(t,e){const i=this.fragPrevious;let n=null;if(i){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),n=Py(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){const l=e[o-t.startSN];i.cc===l.cc&&(n=l,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=My(e,i.cc),n&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`))}}else{const o=this.hls.liveSyncPosition;o!==null&&(n=this.getFragmentAtPosition(o,this.bitrateTest?t.fragmentEnd:t.edge,t))}return n}getFragmentAtPosition(t,e,i){const{config:n}=this;let{fragPrevious:o}=this,{fragments:l,endSN:d}=i;const{fragmentHint:f}=i,p=n.maxFragLookUpTolerance,g=i.partList,v=!!(n.lowLatencyMode&&g!=null&&g.length&&f);v&&f&&!this.bitrateTest&&(l=l.concat(f),d=f.sn);let A;if(t<e){const E=t>e-p?0:p;A=Da(o,l,t,E)}else A=l[l.length-1];if(A){const E=A.sn-i.startSN,T=this.fragmentTracker.getState(A);if((T===yi.OK||T===yi.PARTIAL&&A.gap)&&(o=A),o&&A.sn===o.sn&&(!v||g[0].fragment.sn>A.sn)&&o&&A.level===o.level){const w=l[E+1];A.sn<d&&this.fragmentTracker.getState(w)!==yi.OK?A=w:A=null}}return A}synchronizeToLiveEdge(t){const{config:e,media:i}=this;if(!i)return;const n=this.hls.liveSyncPosition,o=i.currentTime,l=t.fragments[0].start,d=t.edge,f=o>=l-e.maxFragLookUpTolerance&&o<=d;if(n!==null&&i.duration>n&&(o<n||!f)){const p=e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!f&&i.readyState<4||o<d-p)&&(this.loadedmetadata||(this.nextLoadPosition=n),i.readyState&&(this.warn(`Playback: ${o.toFixed(3)} is located too far from the end of live sliding playlist: ${d}, reset currentTime to : ${n.toFixed(3)}`),i.currentTime=n))}}alignPlaylists(t,e){const{levels:i,levelLastLoaded:n,fragPrevious:o}=this,l=n!==null?i[n]: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&&Wt(f);if(p||!g&&!f){Yy(o,l,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 n=this.startTimeOffset!==null,o=n?this.startTimeOffset:t.startTimeOffset;o!==null&&Wt(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 ${n?"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!==wt.FRAG_LOADING_WAITING_RETRY)&&(this.state=wt.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 n;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(n=this.fragCurrent)==null?void 0:n.url}`);return}const o=e.details===pt.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(i,!0);const l=e.errorAction,{action:d,retryCount:f=0,retryConfig:p}=l||{};if(l&&d===xi.RetryRequest&&p){var g;this.resetStartWhenNotLoaded((g=this.levelLastLoaded)!=null?g:i.level);const v=xc(p,f);this.warn(`Fragment ${i.sn} of ${t} ${i.level} errored with ${e.details}, retrying loading ${f+1}/${p.maxNumRetry} in ${v}ms`),l.resolved=!0,this.retryDate=self.performance.now()+v,this.state=wt.FRAG_LOADING_WAITING_RETRY}else p&&l?(this.resetFragmentErrors(t),f<p.maxNumRetry?o||(l.resolved=!0):X.warn(`${e.details} reached or exceeded max retry (${f})`)):(l==null?void 0:l.action)===xi.SendAlternateToPenaltyBox?this.state=wt.WAITING_LEVEL:this.state=wt.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===wt.PARSING||this.state===wt.PARSED){const e=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,e),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len);const o=!n;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!==wt.STOPPED&&(this.state=wt.IDLE)}afterBufferFlushed(t,e,i){if(!t)return;const n=Ge.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,n,i),this.state===wt.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=wt.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,n){var o;const l=i.details;if(!l){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=n?0:B0(l,t,p.startPTS,p.endPTS,p.startDTS,p.endDTS);return this.hls.trigger(R.LEVEL_PTS_UPDATED,{details:l,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:pt.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=wt.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,n;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((e=(i=this.levelLastLoaded)!=null?i:(n=this.fragCurrent)==null?void 0:n.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 tf(){return self.SourceBuffer||self.WebKitSourceBuffer}function ib(){const s=$o();if(!s)return!1;const t=tf(),e=s&&typeof s.isTypeSupported=="function"&&s.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function";return!!e&&!!i}function rb(){var s;const t=tf();return typeof(t==null||(s=t.prototype)==null?void 0:s.changeType)=="function"}function sb(){return typeof __HLS_WORKER_BUNDLE__=="function"}function nb(){const s=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(s);return{worker:new self.Worker(t),objectURL:t}}function ab(s){const t=new self.URL(s,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}function Gr(s="",t=9e4){return{type:s,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class ef{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,n){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=dn(this.cachedData,t),this.cachedData=null);let i=Do(t,0),n=i?i.length:0,o;const l=this._audioTrack,d=this._id3Track,f=i?Vv(i):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&Wt(f))&&(this.basePTS=ob(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:Sr.audioId3,duration:Number.POSITIVE_INFINITY});n<p;){if(this.canParse(t,n)){const g=this.appendFrame(l,t,n);g?(this.frameIndex++,this.lastPTS=g.sample.pts,n+=g.length,o=n):n=p}else Gv(t,n)?(i=Do(t,n),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Sr.audioId3,duration:Number.POSITIVE_INFINITY}),n+=i.length,o=n):n++;if(n===p&&o!==p){const g=hn(t,o);this.cachedData?this.cachedData=dn(this.cachedData,g):this.cachedData=g}}return{audioTrack:l,videoTrack:Gr(),id3Track:d,textTrack:Gr()}}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:Gr(),id3Track:this._id3Track,textTrack:Gr()}}destroy(){}}const ob=(s,t,e)=>{if(Wt(s))return s*90;const i=e?e.baseTime*9e4/e.timescale:0;return t*9e4+i};function lb(s,t,e,i){let n,o,l,d;const f=navigator.userAgent.toLowerCase(),p=i,g=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=((t[e+2]&192)>>>6)+1;const v=(t[e+2]&60)>>>2;if(v>g.length-1){s.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${v}`});return}return l=(t[e+2]&1)<<2,l|=(t[e+3]&192)>>>6,X.log(`manifest codec:${i}, ADTS type:${n}, samplingIndex:${v}`),/firefox/i.test(f)?v>=6?(n=5,d=new Array(4),o=v-3):(n=2,d=new Array(2),o=v):f.indexOf("android")!==-1?(n=2,d=new Array(2),o=v):(n=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&&l===1||/vivaldi/i.test(f))||!i&&l===1)&&(n=2,d=new Array(2)),o=v)),d[0]=n<<3,d[0]|=(v&14)>>1,d[1]|=(v&1)<<7,d[1]|=l<<3,n===5&&(d[1]|=(o&14)>>1,d[2]=(o&1)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:g[v],channelCount:l,codec:"mp4a.40."+n,manifestCodec:p}}function rf(s,t){return s[t]===255&&(s[t+1]&246)===240}function sf(s,t){return s[t+1]&1?7:9}function Uc(s,t){return(s[t+3]&3)<<11|s[t+4]<<3|(s[t+5]&224)>>>5}function cb(s,t){return t+5<s.length}function Ho(s,t){return t+1<s.length&&rf(s,t)}function hb(s,t){return cb(s,t)&&rf(s,t)&&Uc(s,t)<=s.length-t}function db(s,t){if(Ho(s,t)){const e=sf(s,t);if(t+e>=s.length)return!1;const i=Uc(s,t);if(i<=e)return!1;const n=t+i;return n===s.length||Ho(s,n)}return!1}function nf(s,t,e,i,n){if(!s.samplerate){const o=lb(t,e,i,n);if(!o)return;s.config=o.config,s.samplerate=o.samplerate,s.channelCount=o.channelCount,s.codec=o.codec,s.manifestCodec=o.manifestCodec,X.log(`parsed codec:${s.codec}, rate:${o.samplerate}, channels:${o.channelCount}`)}}function af(s){return 9216e4/s}function ub(s,t){const e=sf(s,t);if(t+e<=s.length){const i=Uc(s,t)-e;if(i>0)return{headerLength:e,frameLength:i}}}function of(s,t,e,i,n){const o=af(s.samplerate),l=i+n*o,d=ub(t,e);let f;if(d){const{frameLength:g,headerLength:v}=d,A=v+g,E=Math.max(0,e+A-t.length);E?(f=new Uint8Array(A-v),f.set(t.subarray(e+v,t.length),0)):f=t.subarray(e+v,e+A);const T={unit:f,pts:l};return E||s.samples.push(T),{sample:T,length:A,missing:E}}const p=t.length-e;return f=new Uint8Array(p),f.set(t.subarray(e,t.length),0),{sample:{unit:f,pts:l},length:p,missing:-1}}class fb extends ef{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,i,n){super.resetInitSegment(t,e,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(Do(t,0)||[]).length;for(let i=t.length;e<i;e++)if(db(t,e))return X.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return hb(t,e)}appendFrame(t,e,i){nf(t,this.observer,e,i,t.manifestCodec);const n=of(t,e,i,this.basePTS,this.frameIndex);if(n&&n.missing===0)return n}}const pb=/\/emsg[-/]ID3/i;class gb{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,n){const o=this.videoTrack=Gr("video",1),l=this.audioTrack=Gr("audio",1),d=this.txtTrack=Gr("text",1);if(this.id3Track=Gr("id3",1),this.timeOffset=0,!(t!=null&&t.byteLength))return;const f=y0(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;l.id=p,l.timescale=g,l.codec=v}d.id=g0.text,o.sampleDuration=0,o.duration=l.duration=n}resetContiguity(){this.remainderData=null}static probe(t){return t=t.length>16384?t.subarray(0,16384):t,be(t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let i=t;const n=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=dn(this.remainderData,t));const d=ry(i);this.remainderData=d.remainder,n.samples=d.valid||new Uint8Array}else n.samples=i;const l=this.extractID3Track(n,e);return o.samples=A0(e,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:l,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,i=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const n=this.extractID3Track(e,this.timeOffset);return i.samples=A0(t,e),{videoTrack:e,audioTrack:Gr(),id3Track:n,textTrack:Gr()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const n=be(t.samples,["emsg"]);n&&n.forEach(o=>{const l=ay(o);if(pb.test(l.schemeIdUri)){const d=Wt(l.presentationTime)?l.presentationTime/l.timeScale:e+l.presentationTimeDelta/l.timeScale;let f=l.eventDuration===4294967295?Number.POSITIVE_INFINITY:l.eventDuration/l.timeScale;f<=.001&&(f=Number.POSITIVE_INFINITY);const p=l.payload;i.samples.push({data:p,len:p.byteLength,dts:d,pts:d,type:Sr.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 Wo=null;const mb=[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],vb=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],yb=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],bb=[0,1,1,4];function lf(s,t,e,i,n){if(e+24>t.length)return;const o=cf(t,e);if(o&&e+o.frameLength<=t.length){const l=o.samplesPerFrame*9e4/o.sampleRate,d=i+n*l,f={unit:t.subarray(e,e+o.frameLength),pts:d,dts:d};return s.config=[],s.channelCount=o.channelCount,s.samplerate=o.sampleRate,s.samples.push(f),{sample:f,length:o.frameLength,missing:0}}}function cf(s,t){const e=s[t+1]>>3&3,i=s[t+1]>>1&3,n=s[t+2]>>4&15,o=s[t+2]>>2&3;if(e!==1&&n!==0&&n!==15&&o!==3){const l=s[t+2]>>1&1,d=s[t+3]>>6,f=e===3?3-i:i===3?3:4,p=mb[f*14+n-1]*1e3,g=vb[(e===3?0:e===2?1:2)*3+o],v=d===3?1:2,A=yb[e][i],E=bb[i],T=A*8*E,w=Math.floor(A*p/g+l)*E;if(Wo===null){const C=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Wo=C?parseInt(C[1]):0}return Wo&&Wo<=87&&i===2&&p>=224e3&&d===0&&(s[t+3]=s[t+3]|128),{sampleRate:g,channelCount:v,frameLength:w,samplesPerFrame:T}}}function Bc(s,t){return s[t]===255&&(s[t+1]&224)===224&&(s[t+1]&6)!==0}function hf(s,t){return t+1<s.length&&Bc(s,t)}function Ab(s,t){return Bc(s,t)&&4<=s.length-t}function Eb(s,t){if(t+1<s.length&&Bc(s,t)){const e=cf(s,t);let i=4;e!=null&&e.frameLength&&(i=e.frameLength);const n=t+i;return n===s.length||hf(s,n)}return!1}class df{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,n=new Uint8Array(4),o=Math.min(4,e);if(o===0)throw new Error("no bytes available");n.set(t.subarray(i,i+o)),this.word=new DataView(n.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&&X.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,n;for(let o=0;o<t;o++)i!==0&&(n=this.readEG(),i=(e+n+256)%256),e=i===0?e:i}readSPS(){let t=0,e=0,i=0,n=0,o,l,d;const f=this.readUByte.bind(this),p=this.readBits.bind(this),g=this.readUEG.bind(this),v=this.readBoolean.bind(this),A=this.skipBits.bind(this),E=this.skipEG.bind(this),T=this.skipUEG.bind(this),w=this.skipScalingList.bind(this);f();const C=f();if(p(5),A(3),f(),T(),C===100||C===110||C===122||C===244||C===44||C===83||C===86||C===118||C===128){const $=g();if($===3&&A(1),T(),T(),A(1),v())for(l=$!==3?8:12,d=0;d<l;d++)v()&&(d<6?w(16):w(64))}T();const D=g();if(D===0)g();else if(D===1)for(A(1),E(),E(),o=g(),d=0;d<o;d++)E();T(),A(1);const M=g(),U=g(),x=p(1);x===0&&A(1),A(1),v()&&(t=g(),e=g(),i=g(),n=g());let G=[1,1];if(v()&&v())switch(f()){case 1:G=[1,1];break;case 2:G=[12,11];break;case 3:G=[10,11];break;case 4:G=[16,11];break;case 5:G=[40,33];break;case 6:G=[24,11];break;case 7:G=[20,11];break;case 8:G=[32,11];break;case 9:G=[80,33];break;case 10:G=[18,11];break;case 11:G=[15,11];break;case 12:G=[64,33];break;case 13:G=[160,99];break;case 14:G=[4,3];break;case 15:G=[3,2];break;case 16:G=[2,1];break;case 255:{G=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil((M+1)*16-t*2-e*2),height:(2-x)*(U+1)*16-(x?2:4)*(i+n),pixelRatio:G}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Tb{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Fc(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,i){const n=t[e].unit;if(n.length<=16)return;const o=n.subarray(16,n.length-n.length%16),l=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(l).then(d=>{const f=new Uint8Array(d);n.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 n=0;for(let o=32;o<t.length-16;o+=160,n+=16)i.set(t.subarray(o,o+16),n);return i}getAvcDecryptedUnit(t,e){const i=new Uint8Array(e);let n=0;for(let o=32;o<t.length-16;o+=160,n+=16)t.set(i.subarray(n,n+16),o);return t}decryptAvcSample(t,e,i,n,o){const l=T0(o.data),d=this.getAvcEncryptedData(l);this.decryptBuffer(d.buffer).then(f=>{o.data=this.getAvcDecryptedUnit(l,f),this.decrypter.isSync()||this.decryptAvcSamples(t,e,i+1,n)})}decryptAvcSamples(t,e,i,n){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length){n();return}const o=t[e].units;for(;!(i>=o.length);i++){const l=o[i];if(!(l.data.length<=48||l.type!==1&&l.type!==5)&&(this.decryptAvcSample(t,e,i,n,l),!this.decrypter.isSync()))return}}}}const Di=188;class Rs{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=Rs.syncOffset(t);return e>0&&X.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),e!==-1}static syncOffset(t){const e=t.length;let i=Math.min(Di*5,t.length-Di)+1,n=0;for(;n<i;){let o=!1,l=-1,d=0;for(let f=n;f<e;f+=Di)if(t[f]===71){if(d++,l===-1&&(l=f,l!==0&&(i=Math.min(l+Di*99,t.length-Di)+1)),o||(o=Gc(t,f)===0),o&&d>1&&(l===0&&d>2||f+Di>i))return l}else{if(d)return-1;break}n++}return-1}static createTrack(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:g0[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}}resetInitSegment(t,e,i,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Rs.createTrack("video"),this._audioTrack=Rs.createTrack("audio",n),this._id3Track=Rs.createTrack("id3"),this._txtTrack=Rs.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=i,this._duration=n}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,n=!1){i||(this.sampleAes=null);let o;const l=this._avcTrack,d=this._audioTrack,f=this._id3Track,p=this._txtTrack;let g=l.pid,v=l.pesData,A=d.pid,E=f.pid,T=d.pesData,w=f.pesData,C=null,D=this.pmtParsed,M=this._pmtId,U=t.length;if(this.remainderData&&(t=dn(this.remainderData,t),U=t.length,this.remainderData=null),U<Di&&!n)return this.remainderData=t,{audioTrack:d,videoTrack:l,id3Track:f,textTrack:p};const x=Math.max(0,Rs.syncOffset(t));U-=(U-x)%Di,U<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,U,t.buffer.byteLength-U));let G=0;for(let Y=x;Y<U;Y+=Di)if(t[Y]===71){const tt=!!(t[Y+1]&64),nt=Gc(t,Y),J=(t[Y+3]&48)>>4;let St;if(J>1){if(St=Y+5+t[Y+4],St===Y+Di)continue}else St=Y+4;switch(nt){case g:tt&&(v&&(o=xn(v))&&this.parseAVCPES(l,p,o,!1),v={data:[],size:0}),v&&(v.data.push(t.subarray(St,Y+Di)),v.size+=Y+Di-St);break;case A:if(tt){if(T&&(o=xn(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(St,Y+Di)),T.size+=Y+Di-St);break;case E:tt&&(w&&(o=xn(w))&&this.parseID3PES(f,o),w={data:[],size:0}),w&&(w.data.push(t.subarray(St,Y+Di)),w.size+=Y+Di-St);break;case 0:tt&&(St+=t[St]+1),M=this._pmtId=kb(t,St);break;case M:{tt&&(St+=t[St]+1);const mt=wb(t,St,this.typeSupported,i);g=mt.avc,g>0&&(l.pid=g),A=mt.audio,A>0&&(d.pid=A,d.segmentCodec=mt.segmentCodec),E=mt.id3,E>0&&(f.pid=E),C!==null&&!D&&(X.warn(`MPEG-TS PMT found at ${Y} after unknown PID '${C}'. Backtracking to sync byte @${x} to parse all TS packets.`),C=null,Y=x-188),D=this.pmtParsed=!0;break}case 17:case 8191:break;default:C=nt;break}}else G++;if(G>0){const Y=new Error(`Found ${G} TS packet/s that do not start with 0x47`);this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.FRAG_PARSING_ERROR,fatal:!1,error:Y,reason:Y.message})}l.pesData=v,d.pesData=T,f.pesData=w;const $={audioTrack:d,videoTrack:l,id3Track:f,textTrack:p};return n&&this.extractRemainingSamples($),$}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:n,textTrack:o}=t,l=i.pesData,d=e.pesData,f=n.pesData;let p;if(l&&(p=xn(l))?(this.parseAVCPES(i,o,p,!0),i.pesData=null):i.pesData=l,d&&(p=xn(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&&X.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=d;f&&(p=xn(f))?(this.parseID3PES(n,p),n.pesData=null):n.pesData=f}demuxSampleAes(t,e,i){const n=this.demux(t,i,!0,!this.config.progressive),o=this.sampleAes=new Tb(this.observer,this.config,e);return this.decrypt(n,o)}decrypt(t,e){return new Promise(i=>{const{audioTrack:n,videoTrack:o}=t;n.samples&&n.segmentCodec==="aac"?e.decryptAacSamples(n.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,n){const o=this.parseAVCNALu(t,i.data);let l=this.avcSample,d,f=!1;i.data=null,l&&o.length&&!t.audFound&&(Pa(l,t),l=this.avcSample=jo(!1,i.pts,i.dts,"")),o.forEach(p=>{var g;switch(p.type){case 1:{let A=!1;d=!0;const E=p.data;if(f&&E.length>4){const T=new df(E).readSliceType();(T===2||T===4||T===7||T===9)&&(A=!0)}if(A){var v;(v=l)!=null&&v.frame&&!l.key&&(Pa(l,t),l=this.avcSample=null)}l||(l=this.avcSample=jo(!0,i.pts,i.dts,"")),l.frame=!0,l.key=A;break}case 5:d=!0,(g=l)!=null&&g.frame&&!l.key&&(Pa(l,t),l=this.avcSample=null),l||(l=this.avcSample=jo(!0,i.pts,i.dts,"")),l.key=!0,l.frame=!0;break;case 6:{d=!0,E0(p.data,1,i.pts,e.samples);break}case 7:if(d=!0,f=!0,!t.sps){const A=p.data,E=new df(A).readSPS();t.width=E.width,t.height=E.height,t.pixelRatio=E.pixelRatio,t.sps=[A],t.duration=this._duration;const T=A.subarray(1,4);let w="avc1.";for(let C=0;C<3;C++){let D=T[C].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,l&&Pa(l,t),l=this.avcSample=jo(!1,i.pts,i.dts,"");break;case 12:d=!0;break;default:d=!1,l&&(l.debug+="unknown NAL "+p.type+" ");break}l&&d&&l.units.push(p)}),n&&l&&(Pa(l,t),this.avcSample=null)}getLastNalUnit(t){var e;let i=this.avcSample,n;if((!i||i.units.length===0)&&(i=t[t.length-1]),(e=i)!=null&&e.units){const o=i.units;n=o[o.length-1]}return n}parseAVCNALu(t,e){const i=e.byteLength;let n=t.naluState||0;const o=n,l=[];let d=0,f,p,g,v=-1,A=0;for(n===-1&&(v=0,A=e[0]&31,n=0,d=1);d<i;){if(f=e[d++],!n){n=f?0:1;continue}if(n===1){n=f?0:2;continue}if(!f)n=3;else if(f===1){if(v>=0){const E={data:e.subarray(v,d-n-1),type:A};l.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-n-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,A=g,n=0):n=-1}else n=0}if(v>=0&&n>=0){const E={data:e.subarray(v,i),type:A,state:n};l.push(E)}if(l.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=n,l}parseAACPES(t,e){let i=0;const n=this.aacOverFlow;let o=e.data;if(n){this.aacOverFlow=null;const v=n.missing,A=n.sample.unit.byteLength;if(v===-1){const E=new Uint8Array(A+o.byteLength);E.set(n.sample.unit,0),E.set(o,A),o=E}else{const E=A-v;n.sample.unit.set(o.subarray(0,v),E),t.samples.push(n.sample),i=n.missing}}let l,d;for(l=i,d=o.length;l<d-1&&!Ho(o,l);l++);if(l!==i){let v;const A=l<d-1;A?v=`AAC PES did not start with ADTS header,offset:${l}`:v="No ADTS header found in AAC PES";const E=new Error(v);if(X.warn(`parsing error: ${v}`),this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.FRAG_PARSING_ERROR,fatal:!1,levelRetry:A,error:E,reason:v}),!A)return}nf(t,this.observer,o,l,this.audioCodec);let f;if(e.pts!==void 0)f=e.pts;else if(n){const v=af(t.samplerate);f=n.sample.pts+v}else{X.warn("[tsdemuxer]: AAC PES unknown PTS");return}let p=0,g;for(;l<d;)if(g=of(t,o,l,f,p),l+=g.length,g.missing){this.aacOverFlow=g;break}else for(p++;l<d-1&&!Ho(o,l);l++);}parseMPEGPES(t,e){const i=e.data,n=i.length;let o=0,l=0;const d=e.pts;if(d===void 0){X.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<n;)if(hf(i,l)){const f=lf(t,i,l,d,o);if(f)l+=f.length,o++;else break}else l++}parseID3PES(t,e){if(e.pts===void 0){X.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=ui({},e,{type:this._avcTrack?Sr.emsg:Sr.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function jo(s,t,e,i){return{key:s,frame:!1,pts:t,dts:e,units:[],debug:i,length:0}}function Gc(s,t){return((s[t+1]&31)<<8)+s[t+2]}function kb(s,t){return(s[t+10]&31)<<8|s[t+11]}function wb(s,t,e,i){const n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},o=(s[t+1]&15)<<8|s[t+2],l=t+3+o-4,d=(s[t+10]&15)<<8|s[t+11];for(t+=12+d;t<l;){const f=Gc(s,t);switch(s[t]){case 207:if(!i){X.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:n.audio===-1&&(n.audio=f);break;case 21:n.id3===-1&&(n.id3=f);break;case 219:if(!i){X.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:n.avc===-1&&(n.avc=f);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?X.log("MPEG audio found, not supported in this browser"):n.audio===-1&&(n.audio=f,n.segmentCodec="mp3");break;case 36:X.warn("Unsupported HEVC stream type found");break}t+=((s[t+3]&15)<<8|s[t+4])+5}return n}function xn(s){let t=0,e,i,n,o,l;const d=s.data;if(!s||s.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>s.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?(l=(e[14]&14)*536870912+(e[15]&255)*4194304+(e[16]&254)*16384+(e[17]&255)*128+(e[18]&254)/2,o-l>54e5&&(X.warn(`${Math.round((o-l)/9e4)}s delta between PTS and DTS, align them`),o=l)):l=o),n=e[8];let p=n+9;if(s.size<=p)return null;s.size-=p;const g=new Uint8Array(s.size);for(let v=0,A=d.length;v<A;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-=n+3),{data:g,pts:o,dts:l,len:i}}return null}function Pa(s,t){if(s.units.length&&s.frame){if(s.pts===void 0){const e=t.samples,i=e.length;if(i){const n=e[i-1];s.pts=n.pts,s.dts=n.dts}else{t.dropped++;return}}t.samples.push(s)}s.debug.length&&X.log(s.pts+"/"+s.dts+":"+s.debug)}class Sb extends ef{resetInitSegment(t,e,i,n){super.resetInitSegment(t,e,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(Do(t,0)||[]).length;for(let i=t.length;e<i;e++)if(Eb(t,e))return X.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return Ab(t,e)}appendFrame(t,e,i){if(this.basePTS!==null)return lf(t,e,i,this.basePTS,this.frameIndex)}}class uf{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 Ls=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 n=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 l=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,l,f,l,d),st.DINF=st.box(st.types.dinf,st.box(st.types.dref,n))}static box(t,...e){let i=8,n=e.length;const o=n;for(;n--;)i+=e[n].byteLength;const l=new Uint8Array(i);for(l[0]=i>>24&255,l[1]=i>>16&255,l[2]=i>>8&255,l[3]=i&255,l.set(t,4),n=0,i=8;n<o;n++)l.set(e[n],i),i+=e[n].byteLength;return l}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/(Ls+1)),n=Math.floor(e%(Ls+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,n>>24,n>>16&255,n>>8&255,n&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/(Ls+1)),n=Math.floor(e%(Ls+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,n>>24,n>>16&255,n>>8&255,n&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 n,o;for(n=0;n<e.length;n++)o=e[n].flags,i[n+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=[],n,o,l;for(n=0;n<t.sps.length;n++)o=t.sps[n],l=o.byteLength,e.push(l>>>8&255),e.push(l&255),e=e.concat(Array.prototype.slice.call(o));for(n=0;n<t.pps.length;n++)o=t.pps[n],l=o.byteLength,i.push(l>>>8&255),i.push(l&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,n=t.width,o=t.height,l=Math.floor(i/(Ls+1)),d=Math.floor(i%(Ls+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,l>>24,l>>16&255,l>>8&255,l&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,n>>8&255,n&255,0,0,o>>8&255,o&255,0,0]))}static traf(t,e){const i=st.sdtp(t),n=t.id,o=Math.floor(e/(Ls+1)),l=Math.floor(e%(Ls+1));return st.box(st.types.traf,st.box(st.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255])),st.box(st.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,l>>24,l>>16&255,l>>8&255,l&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||[],n=i.length,o=12+16*n,l=new Uint8Array(o);let d,f,p,g,v,A;for(e+=8+o,l.set([t.type==="video"?1:0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,n&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),d=0;d<n;d++)f=i[d],p=f.duration,g=f.size,v=f.flags,A=f.cts,l.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,A>>>24&255,A>>>16&255,A>>>8&255,A&255],12+16*d);return st.box(st.types.trun,l)}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 ff=9e4;function Vc(s,t,e=1,i=!1){const n=s*t*e;return i?Math.round(n):n}function Rb(s,t,e=1,i=!1){return Vc(s,t,1/e,i)}function Oa(s,t=!1){return Vc(s,1e3,1/ff,t)}function Lb(s,t=1){return Vc(s,ff,1/t)}const _b=10*1e3,pf=1024,Cb=1152;let Ko=null,Hc=null;class Wc{constructor(t,e,i,n=""){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,Ko===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ko=o?parseInt(o[1]):0}if(Hc===null){const o=navigator.userAgent.match(/Safari\/(\d+)/i);Hc=o?parseInt(o[1]):0}}destroy(){}resetTimeStamp(t){X.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){X.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){X.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const i=t.reduce((n,o)=>{const l=o.pts-n;return l<-4294967296?(e=!0,pr(n,o.pts)):l>0?n:o.pts},t[0].pts);return e&&X.debug("PTS rollover detected"),i}remux(t,e,i,n,o,l,d,f){let p,g,v,A,E,T,w=o,C=o;const D=t.pid>-1,M=e.pid>-1,U=e.samples.length,x=t.samples.length>0,G=d&&U>0||U>1;if((!D||x)&&(!M||G)||this.ISGenerated||d){this.ISGenerated||(v=this.generateIS(t,e,o,l));const $=this.isVideoContiguous;let Y=-1,tt;if(G&&(Y=Ib(e.samples),!$&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,Y>0){X.warn(`[mp4-remuxer]: Dropped ${Y} out of ${U} video samples due to a missing keyframe`);const nt=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(Y),e.dropped+=Y,C+=(e.samples[0].pts-nt)/e.inputTimeScale,tt=C}else Y===-1&&(X.warn(`[mp4-remuxer]: No keyframe found out of ${U} video samples`),T=!1);if(this.ISGenerated){if(x&&G){const nt=this.getVideoStartPts(e.samples),J=(pr(t.samples[0].pts,nt)-nt)/e.inputTimeScale;w+=Math.max(0,J),C+=Math.max(0,-J)}if(x){if(t.samplerate||(X.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),v=this.generateIS(t,e,o,l)),g=this.remuxAudio(t,w,this.isAudioContiguous,l,M||G||f===Jt.AUDIO?C:void 0),G){const nt=g?g.endPTS-g.startPTS:0;e.inputTimeScale||(X.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),v=this.generateIS(t,e,o,l)),p=this.remuxVideo(e,C,$,nt)}}else G&&(p=this.remuxVideo(e,C,$,0));p&&(p.firstKeyFrame=Y,p.independent=Y!==-1,p.firstKeyFramePTS=tt)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(E=gf(i,o,this._initPTS,this._initDTS)),n.samples.length&&(A=mf(n,o,this._initPTS))),{audio:g,video:p,initSegment:v,independent:T,text:A,id3:E}}generateIS(t,e,i,n){const o=t.samples,l=e.samples,d=this.typeSupported,f={},p=this._initPTS;let g=!p||n,v="audio/mp4",A,E,T;if(g&&(A=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?A=E=o[0].pts-Math.round(T*i):g=!1)}if(e.sps&&e.pps&&l.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(l),C=Math.round(T*i);E=Math.min(E,pr(l[0].dts,w)-C),A=Math.min(A,w-C)}else g=!1;if(Object.keys(f).length)return this.ISGenerated=!0,g?(this._initPTS={baseTime:A,timescale:T},this._initDTS={baseTime:E,timescale:T}):A=T=void 0,{tracks:f,initPTS:A,timescale:T}}remuxVideo(t,e,i,n){const o=t.inputTimeScale,l=t.samples,d=[],f=l.length,p=this._initPTS;let g=this.nextAvcDts,v=8,A=this.videoSampleDuration,E,T,w=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,D=!1;if(!i||g===null){const N=e*o,F=l[0].pts-pr(l[0].dts,l[0].pts);g=N-F}const M=p.baseTime*o/p.timescale;for(let N=0;N<f;N++){const F=l[N];F.pts=pr(F.pts-M,g),F.dts=pr(F.dts-M,g),F.dts<l[N>0?N-1:N].dts&&(D=!0)}D&&l.sort(function(N,F){const j=N.dts-F.dts,at=N.pts-F.pts;return j||at}),E=l[0].dts,T=l[l.length-1].dts;const U=T-E,x=U?Math.round(U/(f-1)):A||t.inputTimeScale/30;if(i){const N=E-g,F=N>x,j=N<-1;if((F||j)&&(F?X.warn(`AVC: ${Oa(N,!0)} ms (${N}dts) hole between fragments detected, filling it`):X.warn(`AVC: ${Oa(-N,!0)} ms (${N}dts) overlapping between fragments detected`),!j||g>=l[0].pts)){E=g;const at=l[0].pts-N;l[0].dts=E,l[0].pts=at,X.log(`Video: First PTS/DTS adjusted: ${Oa(at,!0)}/${Oa(E,!0)}, delta: ${Oa(N,!0)} ms`)}}E=Math.max(0,E);let G=0,$=0;for(let N=0;N<f;N++){const F=l[N],j=F.units,at=j.length;let ht=0;for(let _t=0;_t<at;_t++)ht+=j[_t].data.length;$+=ht,G+=at,F.length=ht,F.dts=Math.max(F.dts,E),w=Math.min(F.pts,w),C=Math.max(F.pts,C)}T=l[f-1].dts;const Y=$+4*G+8;let tt;try{tt=new Uint8Array(Y)}catch(N){this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MUX_ERROR,details:pt.REMUX_ALLOC_ERROR,fatal:!1,error:N,bytes:Y,reason:`fail allocating video mdat ${Y}`});return}const nt=new DataView(tt.buffer);nt.setUint32(0,Y),tt.set(st.types.mdat,4);let J=!1,St=Number.POSITIVE_INFINITY,mt=Number.POSITIVE_INFINITY,Ot=Number.NEGATIVE_INFINITY,Vt=Number.NEGATIVE_INFINITY;for(let N=0;N<f;N++){const F=l[N],j=F.units;let at=0;for(let $t=0,jt=j.length;$t<jt;$t++){const fe=j[$t],ve=fe.data,me=fe.data.byteLength;nt.setUint32(v,me),v+=4,tt.set(ve,v),v+=me,at+=4+me}let ht;if(N<f-1)A=l[N+1].dts-F.dts,ht=l[N+1].pts-F.pts;else{const $t=this.config,jt=N>0?F.dts-l[N-1].dts:x;if(ht=N>0?F.pts-l[N-1].pts:x,$t.stretchShortVideoTrack&&this.nextAudioPts!==null){const fe=Math.floor($t.maxBufferHole*o),ve=(n?w+n*o:this.nextAudioPts)-F.pts;ve>fe?(A=ve-jt,A<0?A=jt:J=!0,X.log(`[mp4-remuxer]: It is approximately ${ve/90} ms to the next segment; using duration ${A/90} ms for the last video frame.`)):A=jt}else A=jt}const _t=Math.round(F.pts-F.dts);St=Math.min(St,A),Ot=Math.max(Ot,A),mt=Math.min(mt,ht),Vt=Math.max(Vt,ht),d.push(new vf(F.key,A,at,_t))}if(d.length){if(Ko){if(Ko<70){const N=d[0].flags;N.dependsOn=2,N.isNonSync=0}}else if(Hc&&Vt-mt<Ot-St&&x/Ot<.025&&d[0].cts===0){X.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let N=E;for(let F=0,j=d.length;F<j;F++){const at=N+d[F].duration,ht=N+d[F].cts;if(F<j-1){const _t=at+d[F+1].cts;d[F].duration=_t-ht}else d[F].duration=F?d[F-1].duration:x;d[F].cts=0,N=at}}}A=J||!A?x:A,this.nextAvcDts=g=T+A,this.videoSampleDuration=A,this.isVideoContiguous=!0;const V=st.moof(t.sequenceNumber++,E,ui({},t,{samples:d})),q="video",At={data1:V,data2:tt,startPTS:w/o,endPTS:(C+A)/o,startDTS:E/o,endDTS:g/o,type:q,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:t.dropped};return t.samples=[],t.dropped=0,At}remuxAudio(t,e,i,n,o){const l=t.inputTimeScale,d=t.samplerate?t.samplerate:l,f=l/d,p=t.segmentCodec==="aac"?pf:Cb,g=p*f,v=this._initPTS,A=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,E=[],T=o!==void 0;let w=t.samples,C=A?0:8,D=this.nextAudioPts||-1;const M=e*l,U=v.baseTime*l/v.timescale;if(this.isAudioContiguous=i=i||w.length&&D>0&&(n&&Math.abs(M-D)<9e3||Math.abs(pr(w[0].pts-U,M)-D)<20*g),w.forEach(function(V){V.pts=pr(V.pts-U,M)}),!i||D<0){if(w=w.filter(V=>V.pts>=0),!w.length)return;o===0?D=0:n&&!T?D=Math.max(0,M):D=w[0].pts}if(t.segmentCodec==="aac"){const V=this.config.maxAudioFramesDrift;for(let q=0,At=D;q<w.length;q++){const N=w[q],F=N.pts,j=F-At,at=Math.abs(1e3*j/l);if(j<=-V*g&&T)q===0&&(X.warn(`Audio frame @ ${(F/l).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*j/l)} ms.`),this.nextAudioPts=D=At=F);else if(j>=V*g&&at<_b&&T){let ht=Math.round(j/g);At=F-ht*g,At<0&&(ht--,At+=g),q===0&&(this.nextAudioPts=D=At),X.warn(`[mp4-remuxer]: Injecting ${ht} audio frame @ ${(At/l).toFixed(3)}s due to ${Math.round(1e3*j/l)} ms gap.`);for(let _t=0;_t<ht;_t++){const $t=Math.max(At,0);let jt=uf.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);jt||(X.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),jt=N.unit.subarray()),w.splice(q,0,{unit:jt,pts:$t}),At+=g,q++}}N.pts=At,At+=g}}let x=null,G=null,$,Y=0,tt=w.length;for(;tt--;)Y+=w[tt].unit.byteLength;for(let V=0,q=w.length;V<q;V++){const At=w[V],N=At.unit;let F=At.pts;if(G!==null){const at=E[V-1];at.duration=Math.round((F-G)/f)}else if(i&&t.segmentCodec==="aac"&&(F=D),x=F,Y>0){Y+=C;try{$=new Uint8Array(Y)}catch(at){this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MUX_ERROR,details:pt.REMUX_ALLOC_ERROR,fatal:!1,error:at,bytes:Y,reason:`fail allocating audio mdat ${Y}`});return}A||(new DataView($.buffer).setUint32(0,Y),$.set(st.types.mdat,4))}else return;$.set(N,C);const j=N.byteLength;C+=j,E.push(new vf(!0,p,j,0)),G=F}const nt=E.length;if(!nt)return;const J=E[E.length-1];this.nextAudioPts=D=G+f*J.duration;const St=A?new Uint8Array(0):st.moof(t.sequenceNumber++,x/f,ui({},t,{samples:E}));t.samples=[];const mt=x/l,Ot=D/l,Vt={data1:St,data2:$,startPTS:mt,endPTS:Ot,startDTS:mt,endDTS:Ot,type:"audio",hasAudio:!0,hasVideo:!1,nb:nt};return this.isAudioContiguous=!0,Vt}remuxEmptyAudio(t,e,i,n){const o=t.inputTimeScale,l=t.samplerate?t.samplerate:o,d=o/l,f=this.nextAudioPts,p=this._initDTS,g=p.baseTime*9e4/p.timescale,v=(f!==null?f:n.startDTS*o)+g,A=n.endDTS*o+g,E=d*pf,T=Math.ceil((A-v)/E),w=uf.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(X.warn("[mp4-remuxer]: remux empty Audio"),!w){X.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const C=[];for(let D=0;D<T;D++){const M=v+D*E;C.push({unit:w,pts:M,dts:M})}return t.samples=C,this.remuxAudio(t,e,i,!1)}}function pr(s,t){let e;if(t===null)return s;for(t<s?e=-8589934592:e=8589934592;Math.abs(s-t)>4294967296;)s+=e;return s}function Ib(s){for(let t=0;t<s.length;t++)if(s[t].key)return t;return-1}function gf(s,t,e,i){const n=s.samples.length;if(!n)return;const o=s.inputTimeScale;for(let d=0;d<n;d++){const f=s.samples[d];f.pts=pr(f.pts-e.baseTime*o/e.timescale,t*o)/o,f.dts=pr(f.dts-i.baseTime*o/i.timescale,t*o)/o}const l=s.samples;return s.samples=[],{samples:l}}function mf(s,t,e){const i=s.samples.length;if(!i)return;const n=s.inputTimeScale;for(let l=0;l<i;l++){const d=s.samples[l];d.pts=pr(d.pts-e.baseTime*n/e.timescale,t*n)/n}s.samples.sort((l,d)=>l.pts-d.pts);const o=s.samples;return s.samples=[],{samples:o}}class vf{constructor(t,e,i,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=i,this.cts=n,this.flags=new xb(t)}}class xb{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 Db{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,n){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(Qv(t,n)),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 n=this.initData=y0(t);e||(e=yf(n.audio,xe.AUDIO)),i||(i=yf(n.video,xe.VIDEO));const o={};n.audio&&n.video?o.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:n.audio?o.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:n.video?o.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:X.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(t,e,i,n,o,l){var d,f;let{initPTS:p,lastEndTime:g}=this;const v={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};Wt(g)||(g=this.lastEndTime=o||0);const A=e.samples;if(!(A!=null&&A.length))return v;const E={initPTS:void 0,timescale:1};let T=this.initData;if((d=T)!=null&&d.length||(this.generateInitSegment(A),T=this.initData),!((f=T)!=null&&f.length))return X.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),v;this.emitInitSegment&&(E.tracks=this.initTracks,this.emitInitSegment=!1);const w=ty(A,T),C=Jv(T,A),D=C===null?o:C;(Pb(p,D,o,w)||E.timescale!==p.timescale&&l)&&(E.initPTS=D-o,p&&p.timescale===1&&X.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,U=M+w;iy(T,A,p.baseTime/p.timescale),w>0?this.lastEndTime=U:(X.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const x=!!T.audio,G=!!T.video;let $="";x&&($+="audio"),G&&($+="video");const Y={data1:A,startPTS:M,startDTS:M,endPTS:U,endDTS:U,type:$,hasAudio:x,hasVideo:G,nb:1,dropped:0};return v.audio=Y.type==="audio"?Y:void 0,v.video=Y.type!=="audio"?Y:void 0,v.initSegment=E,v.id3=gf(i,o,p,p),n.samples.length&&(v.text=mf(n,o,p)),v}}function Pb(s,t,e,i){if(s===null)return!0;const n=Math.max(i,1),o=t-s.baseTime/s.timescale;return Math.abs(o-e)>n}function yf(s,t){const e=s==null?void 0:s.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||t===xe.VIDEO?"avc1.42e01e":"mp4a.40.5"}let as;try{as=self.performance.now.bind(self.performance)}catch{X.debug("Unable to use Performance API on this environment"),as=typeof self<"u"&&self.Date.now}const jc=[{demux:gb,remux:Db},{demux:Rs,remux:Wc},{demux:fb,remux:Wc},{demux:Sb,remux:Wc}];class bf{constructor(t,e,i,n,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=n,this.id=o}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,i,n){const o=i.transmuxing;o.executeStart=as();let l=new Uint8Array(t);const{currentTransmuxState:d,transmuxConfig:f}=this;n&&(this.currentTransmuxState=n);const{contiguous:p,discontinuity:g,trackSwitch:v,accurateTimeOffset:A,timeOffset:E,initSegmentChange:T}=n||d,{audioCodec:w,videoCodec:C,defaultInitPts:D,duration:M,initSegmentData:U}=f,x=Ob(l,e);if(x&&x.method==="AES-128"){const tt=this.getDecrypter();if(tt.isSync()){let nt=tt.softwareDecrypt(l,x.key.buffer,x.iv.buffer);if(i.part>-1&&(nt=tt.flush()),!nt)return o.executeEnd=as(),Kc(i);l=new Uint8Array(nt)}else return this.decryptionPromise=tt.webCryptoDecrypt(l,x.key.buffer,x.iv.buffer).then(nt=>{const J=this.push(nt,null,i);return this.decryptionPromise=null,J}),this.decryptionPromise}const G=this.needsProbing(g,v);if(G){const tt=this.configureTransmuxer(l);if(tt)return X.warn(`[transmuxer] ${tt.message}`),this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.FRAG_PARSING_ERROR,fatal:!1,error:tt,reason:tt.message}),o.executeEnd=as(),Kc(i)}(g||v||T||G)&&this.resetInitSegment(U,w,C,M,e),(g||T||G)&&this.resetInitialTimestamp(D),p||this.resetContiguity();const $=this.transmux(l,x,E,A,i),Y=this.currentTransmuxState;return Y.contiguous=!0,Y.discontinuity=!1,Y.trackSwitch=!1,o.executeEnd=as(),$}flush(t){const e=t.transmuxing;e.executeStart=as();const{decrypter:i,currentTransmuxState:n,decryptionPromise:o}=this;if(o)return o.then(()=>this.flush(t));const l=[],{timeOffset:d}=n;if(i){const v=i.flush();v&&l.push(this.push(v,null,t))}const{demuxer:f,remuxer:p}=this;if(!f||!p)return e.executeEnd=as(),[Kc(t)];const g=f.flush(d);return Yo(g)?g.then(v=>(this.flushRemux(l,v,t),l)):(this.flushRemux(l,g,t),l)}flushRemux(t,e,i){const{audioTrack:n,videoTrack:o,id3Track:l,textTrack:d}=e,{accurateTimeOffset:f,timeOffset:p}=this.currentTransmuxState;X.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const g=this.remuxer.remux(n,o,l,d,p,f,!0,this.id);t.push({remuxResult:g,chunkMeta:i}),i.transmuxing.executeEnd=as()}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,n,o){const{demuxer:l,remuxer:d}=this;!l||!d||(l.resetInitSegment(t,e,i,n),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,n,o){let l;return e&&e.method==="SAMPLE-AES"?l=this.transmuxSampleAes(t,e,i,n,o):l=this.transmuxUnencrypted(t,i,n,o),l}transmuxUnencrypted(t,e,i,n){const{audioTrack:o,videoTrack:l,id3Track:d,textTrack:f}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(o,l,d,f,e,i,!1,this.id),chunkMeta:n}}transmuxSampleAes(t,e,i,n,o){return this.demuxer.demuxSampleAes(t,e,i).then(l=>({remuxResult:this.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,i,n,!1,this.id),chunkMeta:o}))}configureTransmuxer(t){const{config:e,observer:i,typeSupported:n,vendor:o}=this;let l;for(let v=0,A=jc.length;v<A;v++)if(jc[v].demux.probe(t)){l=jc[v];break}if(!l)return new Error("Failed to find demuxer by probing fragment data");const d=this.demuxer,f=this.remuxer,p=l.remux,g=l.demux;(!f||!(f instanceof p))&&(this.remuxer=new p(i,e,n,o)),(!d||!(d instanceof g))&&(this.demuxer=new g(i,e,n),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 Fc(this.config)),t}}function Ob(s,t){let e=null;return s.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(e=t),e}const Kc=s=>({remuxResult:{},chunkMeta:s});function Yo(s){return"then"in s&&s.then instanceof Function}class Mb{constructor(t,e,i,n,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=n,this.defaultInitPts=o||null}}class $b{constructor(t,e,i,n,o,l){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=n,this.timeOffset=o,this.initSegmentChange=l}}var Af={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function n(f,p,g){this.fn=f,this.context=p,this.once=g||!1}function o(f,p,g,v,A){if(typeof g!="function")throw new TypeError("The listener must be a function");var E=new n(g,v||f,A),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 l(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,A=g.length,E=new Array(A);v<A;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,A,E){var T=e?e+f:f;if(!this._events[T])return!1;var w=this._events[T],C=arguments.length,D,M;if(w.fn){switch(w.once&&this.removeListener(f,w.fn,void 0,!0),C){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,A),!0;case 6:return w.fn.call(w.context,p,g,v,A,E),!0}for(M=1,D=new Array(C-1);M<C;M++)D[M-1]=arguments[M];w.fn.apply(w.context,D)}else{var U=w.length,x;for(M=0;M<U;M++)switch(w[M].once&&this.removeListener(f,w[M].fn,void 0,!0),C){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(C-1);x<C;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 A=e?e+f:f;if(!this._events[A])return this;if(!p)return l(this,A),this;var E=this._events[A];if(E.fn)E.fn===p&&(!v||E.once)&&(!g||E.context===g)&&l(this,A);else{for(var T=0,w=[],C=E.length;T<C;T++)(E[T].fn!==p||v&&!E[T].once||g&&E[T].context!==g)&&w.push(E[T]);w.length?this._events[A]=w.length===1?w[0]:w:l(this,A)}return this},d.prototype.removeAllListeners=function(f){var p;return f?(p=e?e+f:f,this._events[p]&&l(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,s.exports=d})(Af);var Fb=Af.exports,Yc=Tv(Fb);const zc=$o()||{isTypeSupported:()=>!1};class Ef{constructor(t,e,i,n){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=n;const l=(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 Yc,this.observer.on(R.FRAG_DECRYPTED,l),this.observer.on(R.ERROR,l);const d={mp4:zc.isTypeSupported("video/mp4"),mpeg:zc.isTypeSupported("audio/mpeg"),mp3:zc.isTypeSupported('audio/mp4; codecs="mp3"')},f=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(o.workerPath||sb())){try{o.workerPath?(X.log(`loading Web Worker ${o.workerPath} for "${e}"`),this.workerContext=ab(o.workerPath)):(X.log(`injecting Web Worker for "${e}"`),this.workerContext=nb()),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,X.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(R.ERROR,{type:Qt.OTHER_ERROR,details:pt.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:v})},p.postMessage({cmd:"init",typeSupported:d,vendor:f,id:e,config:JSON.stringify(o)})}catch(p){X.warn(`Error setting up "${e}" Web Worker, fallback to inline`,p),this.resetWorker(),this.error=null,this.transmuxer=new bf(this.observer,d,o,f,e)}return}this.transmuxer=new bf(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,n,o,l,d,f,p,g){var v,A;p.transmuxing.start=self.performance.now();const{transmuxer:E}=this,T=l?l.start:o.start,w=o.decryptdata,C=this.frag,D=!(C&&o.cc===C.cc),M=!(C&&p.level===C.level),U=C?p.sn-C.sn:-1,x=this.part?p.part-this.part.index:-1,G=U===0&&p.id>1&&p.id===(C==null?void 0:C.stats.chunkCount),$=!M&&(U===1||U===0&&(x===1||G&&x<=0)),Y=self.performance.now();(M||U||o.stats.parsing.start===0)&&(o.stats.parsing.start=Y),l&&(x||!$)&&(l.stats.parsing.start=Y);const tt=!(C&&((v=o.initSegment)==null?void 0:v.url)===((A=C.initSegment)==null?void 0:A.url)),nt=new $b(D,$,f,M,T,tt);if(!$||D||tt){X.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
186
  contiguous: ${$}
187
187
  accurateTimeOffset: ${f}
188
188
  timeOffset: ${T}
189
- initSegmentChange: ${tt}`);const J=new Pb(i,n,e,d,g);this.configureTransmuxer(J)}if(this.frag=o,this.part=l,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:w,chunkMeta:p,state:at},t instanceof ArrayBuffer?[t]:[]);else if(E){const J=E.push(t,w,p,at);Ko(J)?(E.async=!0,J.then(St=>{this.handleTransmuxComplete(St)}).catch(St=>{this.transmuxerError(St,p,"transmuxer-interface push error")})):(E.async=!1,this.handleTransmuxComplete(J))}}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);Ko(i)||e.async?(Ko(i)||(i=Promise.resolve(i)),i.then(n=>{this.handleFlushResult(n,t)}).catch(n=>{this.transmuxerError(n,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:pt.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 n;const o=(n=this.workerContext)==null?void 0:n.objectURL;o&&self.URL.revokeObjectURL(o);break}case"transmuxComplete":{this.handleTransmuxComplete(e.data);break}case"flush":{this.onFlush(e.data);break}case"workerLog":X[e.data.logType]&&X[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 $b=250,Xc=2,Fb=.1,Nb=.05;class Ub{constructor(t,e,i,n){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=n}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:i,media:n,stalled:o}=this;if(n===null)return;const{currentTime:l,seeking:d}=n,f=this.seeking&&!d,p=!this.seeking&&d;if(this.seeking=d,l!==t){if(this.moved=!0,o!==null){if(this.stallReported){const x=self.performance.now()-o;X.warn(`playback not stuck anymore @${l}, after ${Math.round(x)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(p||f){this.stalled=null;return}if(n.paused&&!d||n.ended||n.playbackRate===0||!Ge.getBuffered(n).length)return;const g=Ge.bufferInfo(n,l,0),v=g.len>0,A=g.nextStart||0;if(!v&&!A)return;if(d){const x=g.len>Xc,O=!A||e&&e.start<=l||A-l>Xc&&!this.fragmentTracker.getPartialFragment(l);if(x||O)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var E;const x=Math.max(A,g.start||0)-l,O=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,U=!(O==null||(E=O.details)==null)&&E.live?O.details.targetduration*2:Xc,D=this.fragmentTracker.getPartialFragment(l);if(x>0&&(x<=U||D)){this._trySkipBufferHole(D);return}}const T=self.performance.now();if(o===null){this.stalled=T;return}const w=T-o;if(!d&&w>=$b&&(this._reportStall(g),!this.media))return;const C=Ge.bufferInfo(n,l,i.maxBufferHole);this._tryFixBufferStall(C,w)}_tryFixBufferStall(t,e){const{config:i,fragmentTracker:n,media:o}=this;if(o===null)return;const l=o.currentTime,d=n.getPartialFragment(l);d&&(this._trySkipBufferHole(d)||!this.media)||(t.len>i.maxBufferHole||t.nextStart&&t.nextStart-l<i.maxBufferHole)&&e>i.highBufferWatchdogPeriod*1e3&&(X.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:i,stallReported:n}=this;if(!n&&i){this.stallReported=!0;const o=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(t)})`);X.warn(o.message),e.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.BUFFER_STALLED_ERROR,fatal:!1,error:o,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:i,media:n}=this;if(n===null)return 0;const o=n.currentTime,l=Ge.bufferInfo(n,o,0),d=o<l.start?l.start:l.nextStart;if(d){const f=l.len<=e.maxBufferHole,p=l.len>0&&l.len<1&&n.readyState<3,g=d-o;if(g>0&&(f||p)){if(g>e.maxBufferHole){const{fragmentTracker:A}=this;let E=!1;if(o===0){const T=A.getAppendedFrag(0,Jt.MAIN);T&&d<T.end&&(E=!0)}if(!E){const T=t||A.getAppendedFrag(o,Jt.MAIN);if(T){let w=!1,C=T.end;for(;C<d;){const x=A.getPartialFragment(C);if(x)C+=x.duration;else{w=!0;break}}if(w)return 0}}}const v=Math.max(d+Nb,o+Fb);if(X.warn(`skipping hole, adjusting currentTime from ${o} to ${v}`),this.moved=!0,this.stalled=null,n.currentTime=v,t&&!t.gap){const A=new Error(`fragment loaded with buffer holes, seeking from ${o} to ${v}`);i.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:A,reason:A.message,frag:t})}return v}}return 0}_tryNudgeBuffer(){const{config:t,hls:e,media:i,nudgeRetry:n}=this;if(i===null)return;const o=i.currentTime;if(this.nudgeRetry++,n<t.nudgeMaxRetry){const l=o+(n+1)*t.nudgeOffset,d=new Error(`Nudging 'currentTime' from ${o} to ${l}`);X.warn(d.message),i.currentTime=l,e.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1})}else{const l=new Error(`Playhead still not moving while enough data buffered @${o} after ${t.nudgeMaxRetry} nudges`);X.error(l.message),e.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.BUFFER_STALLED_ERROR,error:l,fatal:!0})}}}const Bb=100;class Gb extends Nc{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(Bb),this.level=-1,!this.startFragRequested){let n=i.startLevel;n===-1&&(i.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=i.nextAutoLevel),this.level=i.nextLoadLevel=n,this.loadedmetadata=!1}e>0&&t===-1&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=wt.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=wt.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case wt.WAITING_LEVEL:{var t;const{levels:i,level:n}=this,o=i==null||(t=i[n])==null?void 0:t.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=wt.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=wt.IDLE;break}break}case wt.FRAG_LOADING_WAITING_RETRY:{var e;const i=self.performance.now(),n=this.retryDate;(!n||i>=n||(e=this.media)!=null&&e.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=wt.IDLE)}break}this.state===wt.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:i,media:n}=this,{config:o,nextLoadLevel:l}=t;if(e===null||!n&&(this.startFragRequested||!o.startFragPrefetch)||this.altAudio&&this.audioOnly||!(i!=null&&i[l]))return;const d=i[l],f=this.getMainFwdBufferInfo();if(f===null)return;const p=this.getLevelDetails();if(p&&this._streamEnded(f,p)){const C={};this.altAudio&&(C.type="video"),this.hls.trigger(R.BUFFER_EOS,C),this.state=wt.ENDED;return}t.loadLevel!==l&&t.manualLevel===-1&&this.log(`Adapting to level ${l} from level ${this.level}`),this.level=t.nextLoadLevel=l;const g=d.details;if(!g||this.state===wt.WAITING_LEVEL||g.live&&this.levelLastLoaded!==l){this.level=l,this.state=wt.WAITING_LEVEL;return}const v=f.len,A=this.getMaxBufferLength(d.maxBitrate);if(v>=A)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)!==yi.OK){var w;const C=((w=this.backtrackFragment)!=null?w:T).sn-g.startSN,x=g.fragments[C-1];x&&T.cc===x.cc&&(T=x,this.fragmentTracker.removeFragment(x))}else this.backtrackFragment&&f.len&&(this.backtrackFragment=null);if(T&&this.isLoopLoading(T,E)){if(!T.gap){const C=this.audioOnly&&!this.altAudio?De.AUDIO:De.VIDEO,x=(C===De.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;x&&this.afterBufferFlushed(x,C,Jt.MAIN)}T=this.getNextFragmentLoopLoading(T,g,f,Jt.MAIN,A)}T&&(T.initSegment&&!T.initSegment.data&&!this.bitrateTest&&(T=T.initSegment),this.loadFragment(T,d,E))}loadFragment(t,e,i){const n=this.fragmentTracker.getState(t);this.fragCurrent=t,n===yi.NOT_LOADED||n===yi.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 n=this.getAppendedFrag(e.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.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 l=this.getBufferedFrag(e.currentTime+i);if(l){const d=this.followingBufferedFrag(l);if(d){this.abortCurrentFrag();const f=d.maxStartPTS?d.maxStartPTS:d.start,p=d.duration,g=Math.max(l.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 wt.KEY_LOADING:case wt.FRAG_LOADING:case wt.FRAG_LOADING_WAITING_RETRY:case wt.PARSING:case wt.PARSED:this.state=wt.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 Ub(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;Wt(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,n=!1,o;e.levels.forEach(l=>{o=l.audioCodec,o&&(o.indexOf("mp4a.40.2")!==-1&&(i=!0),o.indexOf("mp4a.40.5")!==-1&&(n=!0))}),this.audioCodecSwitch=i&&n&&!eb(),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!==wt.IDLE)return;const n=i[e.level];(!n.details||n.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(n.details))&&(this.state=wt.WAITING_LEVEL)}onLevelLoaded(t,e){var i;const{levels:n}=this,o=e.level,l=e.details,d=l.totalduration;if(!n){this.warn(`Levels were reset while loading level ${o}`);return}this.log(`Level ${o} loaded [${l.startSN},${l.endSN}]${l.lastPartSn?`[part-${l.lastPartSn}-${l.lastPartIndex}]`:""}, cc [${l.startCC}, ${l.endCC}] duration:${d}`);const f=n[o],p=this.fragCurrent;p&&(this.state===wt.FRAG_LOADING||this.state===wt.FRAG_LOADING_WAITING_RETRY)&&(p.level!==e.level||p.urlId!==f.urlId)&&p.loader&&this.abortCurrentFrag();let g=0;if(l.live||(i=f.details)!=null&&i.live){if(this.checkLiveUpdate(l),l.deltaUpdateFailed)return;g=this.alignPlaylists(l,f.details)}if(f.details=l,this.levelLastLoaded=o,this.hls.trigger(R.LEVEL_UPDATED,{details:l,level:o}),this.state===wt.WAITING_LEVEL){if(this.waitForCdnTuneIn(l))return;this.state=wt.IDLE}this.startFragRequested?l.live&&this.synchronizeToLiveEdge(l):this.setStartPosition(l,g),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:n,payload:o}=t,{levels:l}=this;if(!l){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=l[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,A=this._getAudioCodec(d),E=this.transmuxer=this.transmuxer||new Ef(this.hls,Jt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),T=n?n.index:-1,w=T!==-1,C=new Mc(i.level,i.sn,i.stats.chunkCount,o.byteLength,T,w),x=this.initPTS[i.cc];E.push(o,v,A,p,i,n,f.totalduration,g,C,x)}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 n=this.hls;i&&(n.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(R.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const i=e.id,n=!!this.hls.audioTracks[i].url;if(n){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=n,this.tick()}onBufferCreated(t,e){const i=e.tracks;let n,o,l=!1;for(const d in i){const f=i[d];if(f.id==="main"){if(o=d,n=f,d==="video"){const p=i[d];p&&(this.videoBuffer=p.buffer)}}else l=!0}l&&n?(this.log(`Alternate track found, use ${o}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:i,part:n}=e;if(i&&i.type!==Jt.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===wt.PARSED&&(this.state=wt.IDLE);return}const o=n?n.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,n)}onError(t,e){var i;if(e.fatal){this.state=wt.ERROR;return}switch(e.details){case pt.FRAG_GAP:case pt.FRAG_PARSING_ERROR:case pt.FRAG_DECRYPT_ERROR:case pt.FRAG_LOAD_ERROR:case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_ERROR:case pt.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Jt.MAIN,e);break;case pt.LEVEL_LOAD_ERROR:case pt.LEVEL_LOAD_TIMEOUT:case pt.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===wt.WAITING_LEVEL&&((i=e.context)==null?void 0:i.type)===ke.LEVEL&&(this.state=wt.IDLE);break;case pt.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="main")return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case pt.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}checkBuffer(){const{media:t,gapController:e}=this;if(!(!t||!e||!t.readyState)){if(this.loadedmetadata||!Ge.getBuffered(t).length){const i=this.state!==wt.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=wt.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==De.AUDIO||this.audioOnly&&!this.altAudio){const i=(e===De.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 n=Ge.getBuffered(t),o=(n.length?n.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:n}=this;if(!i||this.fragContextChanged(t))return;e.fragmentError=0,this.state=wt.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(),n.trigger(R.FRAG_LOADED,i),t.bitrateTest=!1})}_handleTransmuxComplete(t){var e;const i="main",{hls:n}=this,{remuxResult:o,chunkMeta:l}=t,d=this.getCurrentContext(l);if(!d){this.resetWhenMissingContext(l);return}const{frag:f,part:p,level:g}=d,{video:v,text:A,id3:E,initSegment:T}=o,{details:w}=g,C=this.altAudio?void 0:o.audio;if(this.fragContextChanged(f)){this.fragmentTracker.removeFragment(f);return}if(this.state=wt.PARSING,T){if(T!=null&&T.tracks){const U=f.initSegment||f;this._bufferInitSegment(g,T.tracks,U,l),n.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:U,id:i,tracks:T.tracks})}const x=T.initPTS,O=T.timescale;Wt(x)&&(this.initPTS[f.cc]={baseTime:x,timescale:O},n.trigger(R.INIT_PTS_FOUND,{frag:f,id:i,initPTS:x,timescale:O}))}if(v&&w&&f.sn!=="initSegment"){const x=w.fragments[f.sn-1-w.startSN],O=f.sn===w.startSN,U=!x||f.cc>x.cc;if(o.independent!==!1){const{startPTS:D,endPTS:H,startDTS:$,endDTS:z}=v;if(p)p.elementaryStreams[v.type]={startPTS:D,endPTS:H,startDTS:$,endDTS:z};else if(v.firstKeyFrame&&v.independent&&l.id===1&&!U&&(this.couldBacktrack=!0),v.dropped&&v.independent){const tt=this.getMainFwdBufferInfo(),at=(tt?tt.end:this.getLoadPosition())+this.config.maxBufferHole,J=v.firstKeyFramePTS?v.firstKeyFramePTS:D;if(!O&&at<J-this.config.maxBufferHole&&!U){this.backtrack(f);return}else U&&(f.gap=!0);f.setElementaryStreamInfo(v.type,f.start,H,f.start,z,!0)}f.setElementaryStreamInfo(v.type,D,H,$,z),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(v,f,p,l,O||U)}else if(O||U)f.gap=!0;else{this.backtrack(f);return}}if(C){const{startPTS:x,endPTS:O,startDTS:U,endDTS:D}=C;p&&(p.elementaryStreams[De.AUDIO]={startPTS:x,endPTS:O,startDTS:U,endDTS:D}),f.setElementaryStreamInfo(De.AUDIO,x,O,U,D),this.bufferFragmentData(C,f,p,l)}if(w&&E!=null&&(e=E.samples)!=null&&e.length){const x={id:i,frag:f,details:w,samples:E.samples};n.trigger(R.FRAG_PARSING_METADATA,x)}if(w&&A){const x={id:i,frag:f,details:w,samples:A.samples};n.trigger(R.FRAG_PARSING_USERDATA,x)}}_bufferInitSegment(t,e,i,n){if(this.state!==wt.PARSING)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;const{audio:o,video:l,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}]`)}l&&(l.levelCodec=t.videoCodec,l.id="main",this.log(`Init video buffer, container:${l.container}, codecs[level/parsed]=[${t.videoCodec||""}/${l.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:n,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=wt.IDLE}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&t.seeking===!1){const i=t.currentTime;if(Ge.isBuffered(t,i)?e=this.getAppendedFrag(i):Ge.isBuffered(t,i+.1)&&(e=this.getAppendedFrag(i+.1)),e){this.backtrackFragment=null;const n=this.fragPlaying,o=e.level;(!n||e.sn!==n.sn||n.level!==o||e.urlId!==n.urlId)&&(this.fragPlaying=e,this.hls.trigger(R.FRAG_CHANGED,{frag:e}),(!n||n.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&&Wt(e)&&Wt(i.programDateTime)){const n=i.programDateTime+(e-i.start)*1e3;return new Date(n)}}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 xn{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 Vb{constructor(t,e,i,n=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 xn(t),this.fast_=new xn(e),this.defaultTTFB_=n,this.ttfb_=new xn(t)}update(t,e){const{slow_:i,fast_:n,ttfb_:o}=this;i.halfLife!==t&&(this.slow_=new xn(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.fast_=new xn(e,n.getEstimate(),n.getTotalWeight())),o.halfLife!==t&&(this.ttfb_=new xn(t,o.getEstimate(),o.getTotalWeight()))}sample(t,e){t=Math.max(t,this.minDelayMs_);const i=8*e,n=t/1e3,o=i/n;this.fast_.sample(n,o),this.slow_.sample(n,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 Hb{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 Vb(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 n=e.frag;this.ignoreFragment(n)||(this.fragCurrent=n,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,n){const o=t+i/e,l=n?this.lastLevelLoadSec:0;return o+l}onLevelLoaded(t,e){const i=this.hls.config,{total:n,bwEstimate:o}=e.stats;Wt(n)&&Wt(o)&&(this.lastLevelLoadSec=8*n/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:n,media:o}=i;if(!t||!o)return;const l=performance.now(),d=e?e.stats:t.stats,f=e?e.duration:t.duration,p=l-d.loading.start;if(d.aborted||d.loaded&&d.loaded===d.total||t.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||o.paused||!o.playbackRate||!o.readyState)return;const g=i.mainForwardBufferInfo;if(g===null)return;const v=this.bwEstimator.getEstimateTTFB(),A=Math.abs(o.playbackRate);if(p<=Math.max(v,1e3*(f/(A*2))))return;const E=g.len/A;if(E>=2*f/A)return;const T=d.loading.first?d.loading.first-d.loading.start:-1,w=d.loaded&&T>-1,C=this.bwEstimator.getEstimate(),{levels:x,minAutoLevel:O}=i,U=x[t.level],D=d.total||Math.max(d.loaded,Math.round(f*U.maxBitrate/8));let H=p-T;H<1&&w&&(H=Math.min(p,d.loaded*8/C));const $=w?d.loaded*1e3/H:0,z=$?(D-d.loaded)/$:D*8/C+v/1e3;if(z<=E)return;const tt=$?$*8:C;let at=Number.POSITIVE_INFINITY,J;for(J=t.level-1;J>O;J--){const St=x[J].maxBitrate;if(at=this.getTimeToLoadFrag(v/1e3,tt,f*St,!x[J].details),at<E)break}at>=z||at>f*10||(i.nextLoadLevel=J,w?this.bwEstimator.sample(p-Math.min(v,T),d.loaded):this.bwEstimator.sampleTTFB(p),this.clearTimer(),X.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;
189
+ initSegmentChange: ${tt}`);const J=new Mb(i,n,e,d,g);this.configureTransmuxer(J)}if(this.frag=o,this.part=l,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:w,chunkMeta:p,state:nt},t instanceof ArrayBuffer?[t]:[]);else if(E){const J=E.push(t,w,p,nt);Yo(J)?(E.async=!0,J.then(St=>{this.handleTransmuxComplete(St)}).catch(St=>{this.transmuxerError(St,p,"transmuxer-interface push error")})):(E.async=!1,this.handleTransmuxComplete(J))}}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);Yo(i)||e.async?(Yo(i)||(i=Promise.resolve(i)),i.then(n=>{this.handleFlushResult(n,t)}).catch(n=>{this.transmuxerError(n,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:pt.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 n;const o=(n=this.workerContext)==null?void 0:n.objectURL;o&&self.URL.revokeObjectURL(o);break}case"transmuxComplete":{this.handleTransmuxComplete(e.data);break}case"flush":{this.onFlush(e.data);break}case"workerLog":X[e.data.logType]&&X[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 Nb=250,Xc=2,Ub=.1,Bb=.05;class Gb{constructor(t,e,i,n){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=n}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:i,media:n,stalled:o}=this;if(n===null)return;const{currentTime:l,seeking:d}=n,f=this.seeking&&!d,p=!this.seeking&&d;if(this.seeking=d,l!==t){if(this.moved=!0,o!==null){if(this.stallReported){const D=self.performance.now()-o;X.warn(`playback not stuck anymore @${l}, after ${Math.round(D)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(p||f){this.stalled=null;return}if(n.paused&&!d||n.ended||n.playbackRate===0||!Ge.getBuffered(n).length)return;const g=Ge.bufferInfo(n,l,0),v=g.len>0,A=g.nextStart||0;if(!v&&!A)return;if(d){const D=g.len>Xc,M=!A||e&&e.start<=l||A-l>Xc&&!this.fragmentTracker.getPartialFragment(l);if(D||M)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var E;const D=Math.max(A,g.start||0)-l,M=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,U=!(M==null||(E=M.details)==null)&&E.live?M.details.targetduration*2:Xc,x=this.fragmentTracker.getPartialFragment(l);if(D>0&&(D<=U||x)){this._trySkipBufferHole(x);return}}const T=self.performance.now();if(o===null){this.stalled=T;return}const w=T-o;if(!d&&w>=Nb&&(this._reportStall(g),!this.media))return;const C=Ge.bufferInfo(n,l,i.maxBufferHole);this._tryFixBufferStall(C,w)}_tryFixBufferStall(t,e){const{config:i,fragmentTracker:n,media:o}=this;if(o===null)return;const l=o.currentTime,d=n.getPartialFragment(l);d&&(this._trySkipBufferHole(d)||!this.media)||(t.len>i.maxBufferHole||t.nextStart&&t.nextStart-l<i.maxBufferHole)&&e>i.highBufferWatchdogPeriod*1e3&&(X.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:i,stallReported:n}=this;if(!n&&i){this.stallReported=!0;const o=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(t)})`);X.warn(o.message),e.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.BUFFER_STALLED_ERROR,fatal:!1,error:o,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:i,media:n}=this;if(n===null)return 0;const o=n.currentTime,l=Ge.bufferInfo(n,o,0),d=o<l.start?l.start:l.nextStart;if(d){const f=l.len<=e.maxBufferHole,p=l.len>0&&l.len<1&&n.readyState<3,g=d-o;if(g>0&&(f||p)){if(g>e.maxBufferHole){const{fragmentTracker:A}=this;let E=!1;if(o===0){const T=A.getAppendedFrag(0,Jt.MAIN);T&&d<T.end&&(E=!0)}if(!E){const T=t||A.getAppendedFrag(o,Jt.MAIN);if(T){let w=!1,C=T.end;for(;C<d;){const D=A.getPartialFragment(C);if(D)C+=D.duration;else{w=!0;break}}if(w)return 0}}}const v=Math.max(d+Bb,o+Ub);if(X.warn(`skipping hole, adjusting currentTime from ${o} to ${v}`),this.moved=!0,this.stalled=null,n.currentTime=v,t&&!t.gap){const A=new Error(`fragment loaded with buffer holes, seeking from ${o} to ${v}`);i.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:A,reason:A.message,frag:t})}return v}}return 0}_tryNudgeBuffer(){const{config:t,hls:e,media:i,nudgeRetry:n}=this;if(i===null)return;const o=i.currentTime;if(this.nudgeRetry++,n<t.nudgeMaxRetry){const l=o+(n+1)*t.nudgeOffset,d=new Error(`Nudging 'currentTime' from ${o} to ${l}`);X.warn(d.message),i.currentTime=l,e.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1})}else{const l=new Error(`Playhead still not moving while enough data buffered @${o} after ${t.nudgeMaxRetry} nudges`);X.error(l.message),e.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.BUFFER_STALLED_ERROR,error:l,fatal:!0})}}}const Vb=100;class Hb extends Nc{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(Vb),this.level=-1,!this.startFragRequested){let n=i.startLevel;n===-1&&(i.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=i.nextAutoLevel),this.level=i.nextLoadLevel=n,this.loadedmetadata=!1}e>0&&t===-1&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=wt.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=wt.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case wt.WAITING_LEVEL:{var t;const{levels:i,level:n}=this,o=i==null||(t=i[n])==null?void 0:t.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=wt.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=wt.IDLE;break}break}case wt.FRAG_LOADING_WAITING_RETRY:{var e;const i=self.performance.now(),n=this.retryDate;(!n||i>=n||(e=this.media)!=null&&e.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=wt.IDLE)}break}this.state===wt.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:i,media:n}=this,{config:o,nextLoadLevel:l}=t;if(e===null||!n&&(this.startFragRequested||!o.startFragPrefetch)||this.altAudio&&this.audioOnly||!(i!=null&&i[l]))return;const d=i[l],f=this.getMainFwdBufferInfo();if(f===null)return;const p=this.getLevelDetails();if(p&&this._streamEnded(f,p)){const C={};this.altAudio&&(C.type="video"),this.hls.trigger(R.BUFFER_EOS,C),this.state=wt.ENDED;return}t.loadLevel!==l&&t.manualLevel===-1&&this.log(`Adapting to level ${l} from level ${this.level}`),this.level=t.nextLoadLevel=l;const g=d.details;if(!g||this.state===wt.WAITING_LEVEL||g.live&&this.levelLastLoaded!==l){this.level=l,this.state=wt.WAITING_LEVEL;return}const v=f.len,A=this.getMaxBufferLength(d.maxBitrate);if(v>=A)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)!==yi.OK){var w;const C=((w=this.backtrackFragment)!=null?w:T).sn-g.startSN,D=g.fragments[C-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 C=this.audioOnly&&!this.altAudio?xe.AUDIO:xe.VIDEO,D=(C===xe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;D&&this.afterBufferFlushed(D,C,Jt.MAIN)}T=this.getNextFragmentLoopLoading(T,g,f,Jt.MAIN,A)}T&&(T.initSegment&&!T.initSegment.data&&!this.bitrateTest&&(T=T.initSegment),this.loadFragment(T,d,E))}loadFragment(t,e,i){const n=this.fragmentTracker.getState(t);this.fragCurrent=t,n===yi.NOT_LOADED||n===yi.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 n=this.getAppendedFrag(e.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.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 l=this.getBufferedFrag(e.currentTime+i);if(l){const d=this.followingBufferedFrag(l);if(d){this.abortCurrentFrag();const f=d.maxStartPTS?d.maxStartPTS:d.start,p=d.duration,g=Math.max(l.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 wt.KEY_LOADING:case wt.FRAG_LOADING:case wt.FRAG_LOADING_WAITING_RETRY:case wt.PARSING:case wt.PARSED:this.state=wt.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 Gb(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;Wt(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,n=!1,o;e.levels.forEach(l=>{o=l.audioCodec,o&&(o.indexOf("mp4a.40.2")!==-1&&(i=!0),o.indexOf("mp4a.40.5")!==-1&&(n=!0))}),this.audioCodecSwitch=i&&n&&!rb(),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!==wt.IDLE)return;const n=i[e.level];(!n.details||n.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(n.details))&&(this.state=wt.WAITING_LEVEL)}onLevelLoaded(t,e){var i;const{levels:n}=this,o=e.level,l=e.details,d=l.totalduration;if(!n){this.warn(`Levels were reset while loading level ${o}`);return}this.log(`Level ${o} loaded [${l.startSN},${l.endSN}]${l.lastPartSn?`[part-${l.lastPartSn}-${l.lastPartIndex}]`:""}, cc [${l.startCC}, ${l.endCC}] duration:${d}`);const f=n[o],p=this.fragCurrent;p&&(this.state===wt.FRAG_LOADING||this.state===wt.FRAG_LOADING_WAITING_RETRY)&&(p.level!==e.level||p.urlId!==f.urlId)&&p.loader&&this.abortCurrentFrag();let g=0;if(l.live||(i=f.details)!=null&&i.live){if(this.checkLiveUpdate(l),l.deltaUpdateFailed)return;g=this.alignPlaylists(l,f.details)}if(f.details=l,this.levelLastLoaded=o,this.hls.trigger(R.LEVEL_UPDATED,{details:l,level:o}),this.state===wt.WAITING_LEVEL){if(this.waitForCdnTuneIn(l))return;this.state=wt.IDLE}this.startFragRequested?l.live&&this.synchronizeToLiveEdge(l):this.setStartPosition(l,g),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:n,payload:o}=t,{levels:l}=this;if(!l){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=l[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,A=this._getAudioCodec(d),E=this.transmuxer=this.transmuxer||new Ef(this.hls,Jt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),T=n?n.index:-1,w=T!==-1,C=new Mc(i.level,i.sn,i.stats.chunkCount,o.byteLength,T,w),D=this.initPTS[i.cc];E.push(o,v,A,p,i,n,f.totalduration,g,C,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 n=this.hls;i&&(n.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(R.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const i=e.id,n=!!this.hls.audioTracks[i].url;if(n){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=n,this.tick()}onBufferCreated(t,e){const i=e.tracks;let n,o,l=!1;for(const d in i){const f=i[d];if(f.id==="main"){if(o=d,n=f,d==="video"){const p=i[d];p&&(this.videoBuffer=p.buffer)}}else l=!0}l&&n?(this.log(`Alternate track found, use ${o}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:i,part:n}=e;if(i&&i.type!==Jt.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===wt.PARSED&&(this.state=wt.IDLE);return}const o=n?n.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,n)}onError(t,e){var i;if(e.fatal){this.state=wt.ERROR;return}switch(e.details){case pt.FRAG_GAP:case pt.FRAG_PARSING_ERROR:case pt.FRAG_DECRYPT_ERROR:case pt.FRAG_LOAD_ERROR:case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_ERROR:case pt.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Jt.MAIN,e);break;case pt.LEVEL_LOAD_ERROR:case pt.LEVEL_LOAD_TIMEOUT:case pt.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===wt.WAITING_LEVEL&&((i=e.context)==null?void 0:i.type)===ke.LEVEL&&(this.state=wt.IDLE);break;case pt.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="main")return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case pt.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}checkBuffer(){const{media:t,gapController:e}=this;if(!(!t||!e||!t.readyState)){if(this.loadedmetadata||!Ge.getBuffered(t).length){const i=this.state!==wt.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=wt.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==xe.AUDIO||this.audioOnly&&!this.altAudio){const i=(e===xe.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 n=Ge.getBuffered(t),o=(n.length?n.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:n}=this;if(!i||this.fragContextChanged(t))return;e.fragmentError=0,this.state=wt.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(),n.trigger(R.FRAG_LOADED,i),t.bitrateTest=!1})}_handleTransmuxComplete(t){var e;const i="main",{hls:n}=this,{remuxResult:o,chunkMeta:l}=t,d=this.getCurrentContext(l);if(!d){this.resetWhenMissingContext(l);return}const{frag:f,part:p,level:g}=d,{video:v,text:A,id3:E,initSegment:T}=o,{details:w}=g,C=this.altAudio?void 0:o.audio;if(this.fragContextChanged(f)){this.fragmentTracker.removeFragment(f);return}if(this.state=wt.PARSING,T){if(T!=null&&T.tracks){const U=f.initSegment||f;this._bufferInitSegment(g,T.tracks,U,l),n.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:U,id:i,tracks:T.tracks})}const D=T.initPTS,M=T.timescale;Wt(D)&&(this.initPTS[f.cc]={baseTime:D,timescale:M},n.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,U=!D||f.cc>D.cc;if(o.independent!==!1){const{startPTS:x,endPTS:G,startDTS:$,endDTS:Y}=v;if(p)p.elementaryStreams[v.type]={startPTS:x,endPTS:G,startDTS:$,endDTS:Y};else if(v.firstKeyFrame&&v.independent&&l.id===1&&!U&&(this.couldBacktrack=!0),v.dropped&&v.independent){const tt=this.getMainFwdBufferInfo(),nt=(tt?tt.end:this.getLoadPosition())+this.config.maxBufferHole,J=v.firstKeyFramePTS?v.firstKeyFramePTS:x;if(!M&&nt<J-this.config.maxBufferHole&&!U){this.backtrack(f);return}else U&&(f.gap=!0);f.setElementaryStreamInfo(v.type,f.start,G,f.start,Y,!0)}f.setElementaryStreamInfo(v.type,x,G,$,Y),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(v,f,p,l,M||U)}else if(M||U)f.gap=!0;else{this.backtrack(f);return}}if(C){const{startPTS:D,endPTS:M,startDTS:U,endDTS:x}=C;p&&(p.elementaryStreams[xe.AUDIO]={startPTS:D,endPTS:M,startDTS:U,endDTS:x}),f.setElementaryStreamInfo(xe.AUDIO,D,M,U,x),this.bufferFragmentData(C,f,p,l)}if(w&&E!=null&&(e=E.samples)!=null&&e.length){const D={id:i,frag:f,details:w,samples:E.samples};n.trigger(R.FRAG_PARSING_METADATA,D)}if(w&&A){const D={id:i,frag:f,details:w,samples:A.samples};n.trigger(R.FRAG_PARSING_USERDATA,D)}}_bufferInitSegment(t,e,i,n){if(this.state!==wt.PARSING)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;const{audio:o,video:l,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}]`)}l&&(l.levelCodec=t.videoCodec,l.id="main",this.log(`Init video buffer, container:${l.container}, codecs[level/parsed]=[${t.videoCodec||""}/${l.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:n,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=wt.IDLE}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&t.seeking===!1){const i=t.currentTime;if(Ge.isBuffered(t,i)?e=this.getAppendedFrag(i):Ge.isBuffered(t,i+.1)&&(e=this.getAppendedFrag(i+.1)),e){this.backtrackFragment=null;const n=this.fragPlaying,o=e.level;(!n||e.sn!==n.sn||n.level!==o||e.urlId!==n.urlId)&&(this.fragPlaying=e,this.hls.trigger(R.FRAG_CHANGED,{frag:e}),(!n||n.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&&Wt(e)&&Wt(i.programDateTime)){const n=i.programDateTime+(e-i.start)*1e3;return new Date(n)}}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 Dn{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,n=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 Dn(t),this.fast_=new Dn(e),this.defaultTTFB_=n,this.ttfb_=new Dn(t)}update(t,e){const{slow_:i,fast_:n,ttfb_:o}=this;i.halfLife!==t&&(this.slow_=new Dn(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.fast_=new Dn(e,n.getEstimate(),n.getTotalWeight())),o.halfLife!==t&&(this.ttfb_=new Dn(t,o.getEstimate(),o.getTotalWeight()))}sample(t,e){t=Math.max(t,this.minDelayMs_);const i=8*e,n=t/1e3,o=i/n;this.fast_.sample(n,o),this.slow_.sample(n,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 jb{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 n=e.frag;this.ignoreFragment(n)||(this.fragCurrent=n,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,n){const o=t+i/e,l=n?this.lastLevelLoadSec:0;return o+l}onLevelLoaded(t,e){const i=this.hls.config,{total:n,bwEstimate:o}=e.stats;Wt(n)&&Wt(o)&&(this.lastLevelLoadSec=8*n/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:n,media:o}=i;if(!t||!o)return;const l=performance.now(),d=e?e.stats:t.stats,f=e?e.duration:t.duration,p=l-d.loading.start;if(d.aborted||d.loaded&&d.loaded===d.total||t.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||o.paused||!o.playbackRate||!o.readyState)return;const g=i.mainForwardBufferInfo;if(g===null)return;const v=this.bwEstimator.getEstimateTTFB(),A=Math.abs(o.playbackRate);if(p<=Math.max(v,1e3*(f/(A*2))))return;const E=g.len/A;if(E>=2*f/A)return;const T=d.loading.first?d.loading.first-d.loading.start:-1,w=d.loaded&&T>-1,C=this.bwEstimator.getEstimate(),{levels:D,minAutoLevel:M}=i,U=D[t.level],x=d.total||Math.max(d.loaded,Math.round(f*U.maxBitrate/8));let G=p-T;G<1&&w&&(G=Math.min(p,d.loaded*8/C));const $=w?d.loaded*1e3/G:0,Y=$?(x-d.loaded)/$:x*8/C+v/1e3;if(Y<=E)return;const tt=$?$*8:C;let nt=Number.POSITIVE_INFINITY,J;for(J=t.level-1;J>M;J--){const St=D[J].maxBitrate;if(nt=this.getTimeToLoadFrag(v/1e3,tt,f*St,!D[J].details),nt<E)break}nt>=Y||nt>f*10||(i.nextLoadLevel=J,w?this.bwEstimator.sample(p-Math.min(v,T),d.loaded):this.bwEstimator.sampleTTFB(p),this.clearTimer(),X.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;
190
190
  Time to underbuffer: ${E.toFixed(3)} s
191
- Estimated load time for current fragment: ${z.toFixed(3)} s
192
- Estimated load time for down switch fragment: ${at.toFixed(3)} s
191
+ Estimated load time for current fragment: ${Y.toFixed(3)} s
192
+ Estimated load time for down switch fragment: ${nt.toFixed(3)} s
193
193
  TTFB estimate: ${T}
194
194
  Current BW estimate: ${Wt(C)?(C/1024).toFixed(3):"Unknown"} Kb/s
195
195
  New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
196
- Aborting and switching to level ${J}`),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 n=i?i.stats:e.stats;if(e.type===Jt.MAIN&&this.bwEstimator.sampleTTFB(n.loading.first-n.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,l=this.hls.levels[e.level],d=(l.loaded?l.loaded.bytes:0)+n.loaded,f=(l.loaded?l.loaded.duration:0)+o;l.loaded={bytes:d,duration:f},l.realBitrate=Math.round(8*d/f)}if(e.bitrateTest){const o={stats:n,frag:e,part:i,id:e.type};this.onFragBuffered(R.FRAG_BUFFERED,o),e.bitrateTest=!1}}}onFragBuffered(t,e){const{frag:i,part:n}=e,o=n!=null&&n.stats.loaded?n.stats:i.stats;if(o.aborted||this.ignoreFragment(i))return;const l=o.parsing.end-o.loading.start-Math.min(o.loading.first-o.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(l,o.loaded),o.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=l/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 n=this.hls.levels;if(n.length>Math.max(t,i)&&n[t].loadError<=n[i].loadError)return t}return t!==-1&&(i=Math.min(t,i)),i}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:i}=this,{maxAutoLevel:n,config:o,minAutoLevel:l,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,A=(v?v.len:0)/p;let E=this.findBestLevel(g,l,n,A,o.abrBandWidthFactor,o.abrBandWidthUpFactor);if(E>=0)return E;X.trace(`[abr] ${A?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let T=f?Math.min(f,o.maxStarvationDelay):o.maxStarvationDelay,w=o.abrBandWidthFactor,C=o.abrBandWidthUpFactor;if(!A){const x=this.bitrateTestDelay;x&&(T=(f?Math.min(f,o.maxLoadingDelay):o.maxLoadingDelay)-x,X.trace(`[abr] bitrate test took ${Math.round(1e3*x)}ms, set first fragment max fetchDuration to ${Math.round(1e3*T)} ms`),w=C=1)}return E=this.findBestLevel(g,l,n,A+T,w,C),Math.max(E,0)}findBestLevel(t,e,i,n,o,l){var d;const{fragCurrent:f,partCurrent:p,lastLoadedFragLevel:g}=this,{levels:v}=this.hls,A=v[g],E=!!(A!=null&&(d=A.details)!=null&&d.live),T=A==null?void 0:A.codecSet,w=p?p.duration:f?f.duration:0,C=this.bwEstimator.getEstimateTTFB()/1e3;let x=e,O=-1;for(let U=i;U>=e;U--){const D=v[U];if(!D||T&&D.codecSet!==T){D&&(x=Math.min(U,x),O=Math.max(U,O));continue}O!==-1&&X.trace(`[abr] Skipped level(s) ${x}-${O} with CODECS:"${v[O].attrs.CODECS}"; not compatible with "${A.attrs.CODECS}"`);const H=D.details,$=(p?H==null?void 0:H.partTarget:H==null?void 0:H.averagetargetduration)||w;let z;U<=g?z=o*t:z=l*t;const tt=v[U].maxBitrate,at=this.getTimeToLoadFrag(C,z,tt*$,H===void 0);if(X.trace(`[abr] level:${U} adjustedbw-bitrate:${Math.round(z-tt)} avgDuration:${$.toFixed(1)} maxFetchDuration:${n.toFixed(1)} fetchDuration:${at.toFixed(1)}`),z>tt&&(at===0||!Wt(at)||E&&!this.bitrateTestDelay||at<n))return U}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}}class Tf{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=Wb(t,e);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function Wb(s,t){const e=new Uint8Array(t);let i=0;for(let n=0;n<s.length;n++){const o=s[n];e.set(o,i),i+=o.length}return e}const kf=100;class jb extends Nc{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:n,timescale:o}){if(i==="main"){const l=e.cc;this.initPTS[e.cc]={baseTime:n,timescale:o},this.log(`InitPTS for cc: ${l} found from main: ${n}`),this.videoTrackCC=l,this.state===wt.WAITING_INIT_PTS&&this.tick()}}startLoad(t){if(!this.levels){this.startPosition=t,this.state=wt.STOPPED;return}const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(kf),e>0&&t===-1?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=wt.IDLE):(this.loadedmetadata=!1,this.state=wt.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case wt.IDLE:this.doTickIdle();break;case wt.WAITING_TRACK:{var t;const{levels:i,trackId:n}=this,o=i==null||(t=i[n])==null?void 0:t.details;if(o){if(this.waitForCdnTuneIn(o))break;this.state=wt.WAITING_INIT_PTS}break}case wt.FRAG_LOADING_WAITING_RETRY:{var e;const i=performance.now(),n=this.retryDate;(!n||i>=n||(e=this.media)!=null&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=wt.IDLE);break}case wt.WAITING_INIT_PTS:{const i=this.waitingData;if(i){const{frag:n,part:o,cache:l,complete:d}=i;if(this.initPTS[n.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=wt.FRAG_LOADING;const f=l.flush(),p={frag:n,part:o,payload:f,networkDetails:null};this._handleFragmentLoadProgress(p),d&&super._handleFragmentLoadComplete(p)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${n.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const f=this.getLoadPosition(),p=Ge.bufferInfo(this.mediaBuffer,f,this.config.maxBufferHole);xc(p.end,this.config.maxFragLookUpTolerance,n)<0&&(this.log(`Waiting fragment cc (${n.cc}) @ ${n.start} cancelled because another fragment at ${p.end} is needed`),this.clearWaitingFragment())}}else this.state=wt.IDLE}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=wt.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:n}=this,o=t.config;if(!(e!=null&&e[n])||!i&&(this.startFragRequested||!o.startFragPrefetch))return;const l=e[n],d=l.details;if(!d||d.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(d)){this.state=wt.WAITING_TRACK;return}const f=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&f&&(this.bufferFlushed=!1,this.afterBufferFlushed(f,De.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=wt.ENDED;return}const A=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Jt.MAIN),E=p.len,T=this.getMaxBufferLength(A==null?void 0:A.len);if(E>=T&&!v)return;const w=d.fragments[0].start;let C=p.end;if(v&&i){const D=this.getLoadPosition();g&&v.attrs!==g.attrs&&(C=D),d.PTSKnown&&D<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 x=this.getNextFragment(C,d),O=!1;if(x&&this.isLoopLoading(x,C)&&(O=!!x.gap,x=this.getNextFragmentLoopLoading(x,d,p,Jt.MAIN,T)),!x){this.bufferFlushed=!0;return}const U=A&&x.start>A.end+d.targetduration;if(U||!(A!=null&&A.len)&&p.len){const D=this.getAppendedFrag(x.start,Jt.MAIN);if(D===null||(O||(O=!!D.gap||!!U&&A.len===0),U&&!O||O&&p.nextStart&&p.nextStart<D.end))return}this.loadFragment(x,l,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 Ia(i))}onAudioTrackSwitching(t,e){const i=!!e.url;this.trackId=e.id;const{fragCurrent:n}=this;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?this.setInterval(kf):this.resetTransmuxer(),i?(this.switchingTrack=e,this.state=wt.IDLE):(this.switchingTrack=null,this.bufferedTrack=e,this.state=wt.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:n}=this,{details:o,id:l}=e;if(!n){this.warn(`Audio tracks were reset while loading level ${l}`);return}this.log(`Track ${l} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""},duration:${o.totalduration}`);const d=n[l];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?(J0(o,p),f=o.fragments[0].start):f=this.alignPlaylists(o,d.details)}d.details=o,this.levelLastLoaded=l,!this.startFragRequested&&(this.mainDetails||!o.live)&&this.setStartPosition(d.details,f),this.state===wt.WAITING_TRACK&&!this.waitForCdnTuneIn(o)&&(this.state=wt.IDLE),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:n,payload:o}=t,{config:l,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=l.defaultAudioCodec||p.audioCodec||"mp4a.40.2";let A=this.transmuxer;A||(A=this.transmuxer=new Ef(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=n?n.index:-1,C=w!==-1,x=new Mc(i.level,i.sn,i.stats.chunkCount,o.byteLength,w,C);A.push(o,T,v,"",i,n,g.totalduration,!1,x,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:n,cache:new Tf,complete:!1};w.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=wt.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:n}=e;if(i.type!==Jt.AUDIO){if(!this.loadedmetadata&&i.type===Jt.MAIN){const o=this.videoBuffer||this.media;o&&Ge.getBuffered(o).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${n?" p: "+n.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,zi({},o)))}this.fragBufferedComplete(i,n)}onError(t,e){var i;if(e.fatal){this.state=wt.ERROR;return}switch(e.details){case pt.FRAG_GAP:case pt.FRAG_PARSING_ERROR:case pt.FRAG_DECRYPT_ERROR:case pt.FRAG_LOAD_ERROR:case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_ERROR:case pt.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Jt.AUDIO,e);break;case pt.AUDIO_TRACK_LOAD_ERROR:case pt.AUDIO_TRACK_LOAD_TIMEOUT:case pt.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===wt.WAITING_TRACK&&((i=e.context)==null?void 0:i.type)===ke.AUDIO_TRACK&&(this.state=wt.IDLE);break;case pt.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 pt.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}onBufferFlushed(t,{type:e}){e===De.AUDIO&&(this.bufferFlushed=!0,this.state===wt.ENDED&&(this.state=wt.IDLE))}_handleTransmuxComplete(t){var e;const i="audio",{hls:n}=this,{remuxResult:o,chunkMeta:l}=t,d=this.getCurrentContext(l);if(!d){this.resetWhenMissingContext(l);return}const{frag:f,part:p,level:g}=d,{details:v}=g,{audio:A,text:E,id3:T,initSegment:w}=o;if(this.fragContextChanged(f)||!v){this.fragmentTracker.removeFragment(f);return}if(this.state=wt.PARSING,this.switchingTrack&&A&&this.completeAudioSwitch(this.switchingTrack),w!=null&&w.tracks){const C=f.initSegment||f;this._bufferInitSegment(w.tracks,C,l),n.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:C,id:i,tracks:w.tracks})}if(A){const{startPTS:C,endPTS:x,startDTS:O,endDTS:U}=A;p&&(p.elementaryStreams[De.AUDIO]={startPTS:C,endPTS:x,startDTS:O,endDTS:U}),f.setElementaryStreamInfo(De.AUDIO,C,x,O,U),this.bufferFragmentData(A,f,p,l)}if(T!=null&&(e=T.samples)!=null&&e.length){const C=ui({id:i,frag:f,details:v},T);n.trigger(R.FRAG_PARSING_METADATA,C)}if(E){const C=ui({id:i,frag:f,details:v},E);n.trigger(R.FRAG_PARSING_USERDATA,C)}}_bufferInitSegment(t,e,i){if(this.state!==wt.PARSING)return;t.video&&delete t.video;const n=t.audio;if(!n)return;n.levelCodec=n.codec,n.id="audio",this.log(`Init audio buffer, container:${n.container}, codecs[parsed]=[${n.codec}]`),this.hls.trigger(R.BUFFER_CODECS,t);const o=n.initSegment;if(o!=null&&o.byteLength){const l={type:"audio",frag:e,part:null,chunkMeta:i,parent:e.type,data:o};this.hls.trigger(R.BUFFER_APPENDING,l)}this.tick()}loadFragment(t,e,i){const n=this.fragmentTracker.getState(t);if(this.fragCurrent=t,this.switchingTrack||n===yi.NOT_LOADED||n===yi.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=wt.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(t,e,i))}else this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){const{hls:e,media:i,bufferedTrack:n}=this,o=n==null?void 0:n.attrs,l=t.attrs;i&&o&&(o.CHANNELS!==l.CHANNELS||o.NAME!==l.NAME||o.LANGUAGE!==l.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,zi({},t))}}class Kb extends Pc{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:n,details:o}=e,l=this.tracksInGroup[i];if(!l||l.groupId!==n){this.warn(`Track with id:${i} and group:${n} not found in active group ${l.groupId}`);return}const d=l.details;l.details=e.details,this.log(`audio-track ${i} "${l.name}" lang:${l.lang} group:${n} 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 n=this.tracks.filter(l=>!i||l.groupId===i);this.selectDefaultTrack&&!n.some(l=>l.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;const o={audioTracks:n};this.log(`Updating audio tracks, ${n.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===ke.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 n=e[t],{groupId:o,name:l}=n;if(this.log(`Switching to audio-track ${t} "${l}" lang:${n.lang} group:${o}`),this.trackId=t,this.currentTrack=n,this.selectDefaultTrack=!1,this.hls.trigger(R.AUDIO_TRACK_SWITCHING,zi({},n)),n.details&&!n.details.live)return;const d=this.switchParams(n.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:pt.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const n=e[i];if((!this.selectDefaultTrack||n.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]!==void 0&&t.attrs["STABLE-RENDITION-ID"]===n.attrs["STABLE-RENDITION-ID"]||t.name===n.name&&t.lang===n.lang))return n.id}return-1}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const i=e.id,n=e.groupId;let o=e.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn(`Could not construct new URL with HLS Delivery Directives: ${l}`)}this.log(`loading audio-track playlist ${i} "${e.name}" lang:${e.lang} group:${n}`),this.clearTimer(),this.hls.trigger(R.AUDIO_TRACK_LOADING,{url:o,id:i,groupId:n,deliveryDirectives:t||null})}}}function wf(s,t){if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(!zb(s[e].attrs,t[e].attrs))return!1;return!0}function zb(s,t){const e=s["STABLE-RENDITION-ID"];return e?e===t["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>s[i]!==t[i])}const Sf=500;class Yb extends Nc{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=wt.IDLE,this.setInterval(Sf),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:n}=e;if(this.fragPrevious=i,this.state=wt.IDLE,!n)return;const o=this.tracksBuffered[this.currentTrackId];if(!o)return;let l;const d=i.start;for(let p=0;p<o.length;p++)if(d>=o[p].start&&d<=o[p].end){l=o[p];break}const f=i.start+i.duration;l?l.end=f:(l={start:d,end:f},o.push(l)),this.fragmentTracker.fragBuffered(i)}onBufferFlushing(t,e){const{startOffset:i,endOffset:n}=e;if(i===0&&n!==Number.POSITIVE_INFINITY){const o=n-1;if(o<=0)return;e.endOffsetSubtitles=Math.max(0,o),this.tracksBuffered.forEach(l=>{for(let d=0;d<l.length;){if(l[d].end<=o){l.shift();continue}else if(l[d].start<o)l[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!==wt.STOPPED&&(this.state=wt.IDLE))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){if(wf(this.levels,e)){this.levels=e.map(i=>new Ia(i));return}this.tracksBuffered=[],this.levels=e.map(i=>{const n=new Ia(i);return this.tracksBuffered[n.id]=[],n}),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(Sf)}onSubtitleTrackLoaded(t,e){var i;const{details:n,id:o}=e,{currentTrackId:l,levels:d}=this;if(!d.length)return;const f=d[l];if(o>=d.length||o!==l||!f)return;this.mediaBuffer=this.mediaBufferTimeRanges;let p=0;if(n.live||(i=f.details)!=null&&i.live){const g=this.mainDetails;if(n.deltaUpdateFailed||!g)return;const v=g.fragments[0];f.details?(p=this.alignPlaylists(n,f.details),p===0&&v&&(p=v.start,Ic(n,p))):n.hasProgramDateTime&&g.hasProgramDateTime?(J0(n,g),p=n.fragments[0].start):v&&(p=v.start,Ic(n,p))}f.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(f.details,p),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===wt.IDLE&&(Da(null,n.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,n=e.decryptdata,o=this.hls;if(!this.fragContextChanged(e)&&i&&i.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){const l=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer).catch(d=>{throw o.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.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:l,tdecrypt:f}})}).catch(d=>{this.warn(`${d.name}: ${d.message}`),this.state=wt.IDLE})}}doTick(){if(!this.media){this.state=wt.IDLE;return}if(this.state===wt.IDLE){const{currentTrackId:t,levels:e}=this,i=e[t];if(!e.length||!i||!i.details)return;const{config:n}=this,o=this.getLoadPosition(),l=Ge.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o,n.maxBufferHole),{end:d,len:f}=l,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 A=g.fragments,E=A.length,T=g.edge;let w=null;const C=this.fragPrevious;if(d<T){const x=n.maxFragLookUpTolerance,O=d>T-x?0:x;w=Da(C,A,Math.max(A[0].start,d),O),!w&&C&&C.start<A[0].start&&(w=A[0])}else w=A[E-1];if(!w)return;if(w=this.mapToInitFragWhenRequired(w),w.sn!=="initSegment"){const x=w.sn-g.startSN,O=A[x-1];O&&O.cc===w.cc&&this.fragmentTracker.getState(O)===yi.NOT_LOADED&&(w=O)}this.fragmentTracker.getState(w)===yi.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,n,o)=>{if(n=n>>>0,n>o-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${o})`);return t[n][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 Zb extends Pc{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),Zc(this.media.textTracks).forEach(t=>{Cn(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:n}=e,{trackId:o}=this,l=this.tracksInGroup[o];if(!l){this.warn(`Invalid subtitle track id ${i}`);return}const d=l.details;l.details=e.details,this.log(`subtitle track ${i} loaded [${n.startSN}-${n.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],n=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 l=this.findTrackId(n==null?void 0:n.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),l!==-1&&this.setSubtitleTrack(l,n)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId,n)}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const n=e[i];if((!this.selectDefaultTrack||n.default)&&(!t||t===n.name))return n.id}return-1}onError(t,e){e.fatal||!e.context||e.context.type===ke.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,n=e.groupId;let o=e.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn(`Could not construct new URL with HLS Delivery Directives: ${l}`)}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(R.SUBTITLE_TRACK_LOADING,{url:o,id:i,groupId:n,deliveryDirectives:t||null})}}toggleTrackModes(t){const{media:e,trackId:i}=this;if(!e)return;const n=Zc(e.textTracks),o=n.filter(d=>d.groupId===this.groupId);if(t===-1)[].slice.call(n).forEach(d=>{d.mode="disabled"});else{const d=o[i];d&&(d.mode="disabled")}const l=o[t];l&&(l.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(t,e){var i;const n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=t;return}if(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(t===-1||(i=n[t])!=null&&i.details)||t<-1||t>=n.length)return;this.clearTimer();const o=n[t];if(this.log(`Switching to subtitle-track ${t}`+(o?` "${o.name}" lang:${o.lang} group:${o.groupId}`:"")),this.trackId=t,o){const{id:l,groupId:d="",name:f,type:p,url:g}=o;this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:l,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=Zc(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 Zc(s){const t=[];for(let e=0;e<s.length;e++){const i=s[e];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&t.push(s[e])}return t}class qb{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}),n={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(n,t),i}executeNext(t){const{buffers:e,queues:i}=this,n=e[t],o=i[t];if(o.length){const l=o[0];try{l.execute()}catch(d){X.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),l.onError(d),n!=null&&n.updating||(o.shift(),this.executeNext(t))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const Rf=Mo(),_f=/([ha]vc.)(?:\.[^.,]+)+/;class Qb{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;X.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=()=>{X.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{X.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:i}=this;e&&e.src!==i&&X.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 qb(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,X.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const i=this.media=e.media;if(i&&Rf){const n=this.mediaSource=new Rf;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(n),this._objectUrl=i.src,i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:i}=this;if(e){if(X.log("[buffer-controller]: media source detaching"),e.readyState==="open")try{e.endOfStream()}catch(n){X.warn(`[buffer-controller]: onMediaDetaching: ${n.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()):X.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){X.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,i)}}),this._initSourceBuffer()}onBufferCodecs(t,e){const i=this.getSourceBufferTypes().length;Object.keys(e).forEach(n=>{if(i){const o=this.tracks[n];if(o&&typeof o.buffer.changeType=="function"){const{id:l,codec:d,levelCodec:f,container:p,metadata:g}=e[n],v=(o.levelCodec||o.codec).replace(_f,"$1"),A=(f||d).replace(_f,"$1");if(v!==A){const E=`${p};codecs=${f||d}`;this.appendChangeType(n,E),X.log(`[buffer-controller]: switching codec ${v} to ${A}`),this.tracks[n]={buffer:o.buffer,codec:d,container:p,levelCodec:f,metadata:g,id:l}}}}else this.pendingTracks[n]=e[n]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(t,e){const{operationQueue:i}=this,n={execute:()=>{const o=this.sourceBuffer[t];o&&(X.log(`[buffer-controller]: changing ${t} sourceBuffer type to ${e}`),o.changeType(e)),i.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:o=>{X.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,o)}};i.append(n,t)}onBufferAppending(t,e){const{hls:i,operationQueue:n,tracks:o}=this,{data:l,type:d,frag:f,part:p,chunkMeta:g}=e,v=g.buffering[d],A=self.performance.now();v.start=A;const E=f.stats.buffering,T=p?p.stats.buffering:null;E.start===0&&(E.start=A),T&&T.start===0&&(T.start=A);const w=o.audio;let C=!1;d==="audio"&&(w==null?void 0:w.container)==="audio/mpeg"&&(C=!this.lastMpegAudioChunk||g.id===1||this.lastMpegAudioChunk.sn!==g.sn,this.lastMpegAudioChunk=g);const x=f.start,O={execute:()=>{if(v.executeStart=self.performance.now(),C){const U=this.sourceBuffer[d];if(U){const D=x-U.timestampOffset;Math.abs(D)>=.1&&(X.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${x} (delta: ${D}) sn: ${f.sn})`),U.timestampOffset=x)}}this.appendExecutor(l,d)},onStart:()=>{},onComplete:()=>{const U=self.performance.now();v.executeEnd=v.end=U,E.first===0&&(E.first=U),T&&T.first===0&&(T.first=U);const{sourceBuffer:D}=this,H={};for(const $ in D)H[$]=Ge.getBuffered(D[$]);this.appendError=0,this.hls.trigger(R.BUFFER_APPENDED,{type:d,frag:f,part:p,chunkMeta:g,parent:f.type,timeRanges:H})},onError:U=>{X.error(`[buffer-controller]: Error encountered while trying to append to the ${d} SourceBuffer`,U);const D={type:Qt.MEDIA_ERROR,parent:f.type,details:pt.BUFFER_APPEND_ERROR,frag:f,part:p,chunkMeta:g,error:U,err:U,fatal:!1};U.code===DOMException.QUOTA_EXCEEDED_ERR?D.details=pt.BUFFER_FULL_ERROR:(this.appendError++,D.details=pt.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(X.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),D.fatal=!0)),i.trigger(R.ERROR,D)}};n.append(O,d)}onBufferFlushing(t,e){const{operationQueue:i}=this,n=o=>({execute:this.removeExecutor.bind(this,o,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(R.BUFFER_FLUSHED,{type:o})},onError:l=>{X.warn(`[buffer-controller]: Failed to remove from ${o} SourceBuffer`,l)}});e.type?i.append(n(e.type),e.type):this.getSourceBufferTypes().forEach(o=>{i.append(n(o),o)})}onFragParsed(t,e){const{frag:i,part:n}=e,o=[],l=n?n.elementaryStreams:i.elementaryStreams;l[De.AUDIOVIDEO]?o.push("audiovideo"):(l[De.AUDIO]&&o.push("audio"),l[De.VIDEO]&&o.push("video"));const d=()=>{const f=self.performance.now();i.stats.buffering.end=f,n&&(n.stats.buffering.end=f);const p=n?n.stats:i.stats;this.hls.trigger(R.FRAG_BUFFERED,{frag:i,part:n,stats:p,id:i.type})};o.length===0&&X.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,n)=>{const o=this.sourceBuffer[n];return o&&(!e.type||e.type===n)&&(o.ending=!0,o.ended||(o.ended=!0,X.log(`[buffer-controller]: ${n} sourceBuffer now EOS`))),i&&!!(!o||o.ended)},!0)&&(X.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{const o=this.sourceBuffer[n];o&&(o.ending=!1)});const{mediaSource:i}=this;if(!i||i.readyState!=="open"){i&&X.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${i.readyState}`);return}X.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:n}=this;if(!i||e===null)return;const o=this.getSourceBufferTypes();if(!o.length)return;const l=e.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(!Wt(l)||l<0)return;const d=i.currentTime,f=e.levelTargetDuration,p=Math.max(l,f),g=Math.floor(d/f)*f-p;o.forEach(v=>{const A=n[v];if(A){const E=Ge.getBuffered(A);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(A.ended&&E.end(E.length-1)-d<f*2){X.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:n}=this,o=t.fragments[0].start+t.totalduration,l=i.duration,d=Wt(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(X.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(t)):(o>d&&o>l||!Wt(l))&&(X.log(`[buffer-controller]: Updating Media Source duration to ${o.toFixed(3)}`),n.duration=o)}updateSeekableRange(t){const e=this.mediaSource,i=t.fragments;if(i.length&&t.live&&e!=null&&e.setLiveSeekableRange){const n=Math.max(0,i[0].start),o=Math.max(n,n+t.totalduration);e.setLiveSeekableRange(n,o)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:i}=this,n=Object.keys(i).length;if(n&&!t||n===2){this.createSourceBuffers(i),this.pendingTracks={};const o=this.getSourceBufferTypes();if(o.length)this.hls.trigger(R.BUFFER_CREATED,{tracks:this.tracks}),o.forEach(l=>{e.executeNext(l)});else{const l=new Error("could not create source buffer for media codec(s)");this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:l,reason:l.message})}}}createSourceBuffers(t){const{sourceBuffer:e,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const n in t)if(!e[n]){const o=t[n];if(!o)throw Error(`source buffer exists for track ${n}, however track does not`);const l=o.levelCodec||o.codec,d=`${o.container};codecs=${l}`;X.log(`[buffer-controller]: creating sourceBuffer(${d})`);try{const f=e[n]=i.addSourceBuffer(d),p=n;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[n]={buffer:f,codec:l,container:o.container,levelCodec:o.levelCodec,metadata:o.metadata,id:o.id}}catch(f){X.error(`[buffer-controller]: error while trying to add sourceBuffer: ${f.message}`),this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.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`);X.error(`[buffer-controller]: ${i}`,e),this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.BUFFER_APPENDING_ERROR,error:i,fatal:!1});const n=this.operationQueue.current(t);n&&n.onError(e)}removeExecutor(t,e,i){const{media:n,mediaSource:o,operationQueue:l,sourceBuffer:d}=this,f=d[t];if(!n||!o||!f){X.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),l.shiftAndExecuteNext(t);return}const p=Wt(n.duration)?n.duration:1/0,g=Wt(o.duration)?o.duration:1/0,v=Math.max(0,e),A=Math.min(i,p,g);A>v&&!f.ending?(f.ended=!1,X.log(`[buffer-controller]: Removing [${v},${A}] from the ${t} SourceBuffer`),f.remove(v,A)):l.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:i,sourceBuffer:n}=this,o=n[e];if(!o){X.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){X.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);return}const{operationQueue:i}=this,n=e.map(o=>i.appendBlocker(o));Promise.all(n).then(()=>{t(),e.forEach(o=>{const l=this.sourceBuffer[o];l!=null&&l.updating||i.shiftAndExecuteNext(o)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,i){const n=this.sourceBuffer[t];if(!n)return;const o=i.bind(this,t);this.listeners[t].push({event:e,listener:o}),n.addEventListener(e,o)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach(i=>{e.removeEventListener(i.event,i.listener)})}}const Lf={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},Cf=function(s){let t=s;return Lf.hasOwnProperty(s)&&(t=Lf[s]),String.fromCharCode(t)},Rr=15,os=100,Jb={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},t4={17:2,18:4,21:6,22:8,23:10,19:13,20:15},e4={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},i4={25:2,26:4,29:6,30:8,31:10,27:13,28:15},r4=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class s4{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const i=typeof e=="function"?e():e;X.log(`${this.time} [${t}] ${i}`)}}}const un=function(s){const t=[];for(let e=0;e<s.length;e++)t.push(s[e].toString(16));return t};class If{constructor(t,e,i,n,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=n||"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 n=e[i];t.hasOwnProperty(n)&&(this[n]=t[n])}}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 n4{constructor(t,e,i,n,o,l){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new If(e,i,n,o,l)}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 a4{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<os;e++)this.chars.push(new n4);this.logger=t,this.pos=0,this.currPenState=new If}equals(t){let e=!0;for(let i=0;i<os;i++)if(!this.chars[i].equals(t.chars[i])){e=!1;break}return e}copy(t){for(let e=0;e<os;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<os;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>os&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=os)}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=Cf(t);if(this.pos>=os){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<os;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<os;i++){const n=this.chars[i].uchar;n!==" "&&(e=!1),t.push(n)}return e?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)}}class qc{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<Rr;e++)this.rows.push(new a4(t));this.logger=t,this.currRow=Rr-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let t=0;t<Rr;t++)this.rows[t].clear();this.currRow=Rr-1}equals(t){let e=!0;for(let i=0;i<Rr;i++)if(!this.rows[i].equals(t.rows[i])){e=!1;break}return e}copy(t){for(let e=0;e<Rr;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<Rr;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<Rr;d++)this.rows[d].clear();const o=this.currRow+1-this.nrRollUpRows,l=this.lastOutputScreen;if(l){const d=l.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(l.rows[o+p])}}this.currRow=e;const i=this.rows[this.currRow];if(t.indent!==null){const o=t.indent,l=Math.max(o-1,0);i.setCursor(t.indent),t.color=i.chars[l].penState.foreground}const n={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(n)}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="",n=-1;for(let o=0;o<Rr;o++){const l=this.rows[o].getTextString();l&&(n=o+1,t?e.push("Row "+n+": '"+l+"'"):e.push(l.trim()))}return e.length>0&&(t?i="["+e.join(" | ")+"]":i=e.join(`
197
- `)),i}getTextAndFormat(){return this.rows}}class Df{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 qc(i),this.nonDisplayedMemory=new qc(i),this.lastOutputScreen=new qc(i),this.currRollUpRow=this.displayedMemory.rows[Rr-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[Rr-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,n=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=n[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 xf{constructor(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const n=new s4;this.channels=[null,new Df(t,e,n),new Df(t+1,i,n)],this.cmdHistory=Of(),this.logger=n}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let i,n,o,l=!1;this.logger.time=t;for(let d=0;d<e.length;d+=2)if(n=e[d]&127,o=e[d+1]&127,!(n===0&&o===0)){if(this.logger.log(3,"["+un([e[d],e[d+1]])+"] -> ("+un([n,o])+")"),i=this.parseCmd(n,o),i||(i=this.parseMidrow(n,o)),i||(i=this.parsePAC(n,o)),i||(i=this.parseBackgroundAttributes(n,o)),!i&&(l=this.parseChars(n,o),l)){const f=this.currentChannel;f&&f>0?this.channels[f].insertChars(l):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!i&&!l&&this.logger.log(2,"Couldn't parse cleaned data "+un([n,o])+" orig: "+un([e[d],e[d+1]]))}}parseCmd(t,e){const{cmdHistory:i}=this,n=(t===20||t===28||t===21||t===29)&&e>=32&&e<=47,o=(t===23||t===31)&&e>=33&&e<=35;if(!(n||o))return!1;if(Pf(t,e,i))return Pn(null,null,i),this.logger.log(3,"Repeated command ("+un([t,e])+") is dropped"),!0;const l=t===20||t===21||t===23?1:2,d=this.channels[l];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),Pn(t,e,i),this.currentChannel=l,!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 n=this.channels[i];return n?(n.ccMIDROW(e),this.logger.log(3,"MIDROW ("+un([t,e])+")"),!0):!1}return!1}parsePAC(t,e){let i;const n=this.cmdHistory,o=(t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127,l=(t===16||t===24)&&e>=64&&e<=95;if(!(o||l))return!1;if(Pf(t,e,n))return Pn(null,null,n),!0;const d=t<=23?1:2;e>=64&&e<=95?i=d===1?Jb[t]:e4[t]:i=d===1?t4[t]:i4[t];const f=this.channels[d];return f?(f.setPAC(this.interpretPAC(i,e)),Pn(t,e,n),this.currentChannel=d,!0):!1}interpretPAC(t,e){let i;const n={color:null,italics:!1,indent:null,underline:!1,row:t};return e>95?i=e-96:i=e-64,n.underline=(i&1)===1,i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=Math.floor((i-16)/2)*4,n}parseChars(t,e){let i,n=null,o=null;if(t>=25?(i=2,o=t-8):(i=1,o=t),o>=17&&o<=19){let l;o===17?l=e+80:o===18?l=e+112:l=e+144,this.logger.log(2,"Special char '"+Cf(l)+"' in channel "+i),n=[l]}else t>=32&&t<=127&&(n=e===0?[t]:[t,e]);if(n){const l=un(n);this.logger.log(3,"Char codes = "+l.join(",")),Pn(t,e,this.cmdHistory)}return n}parseBackgroundAttributes(t,e){const i=(t===16||t===24)&&e>=32&&e<=47,n=(t===23||t===31)&&e>=45&&e<=47;if(!(i||n))return!1;let o;const l={};t===16||t===24?(o=Math.floor((e-32)/2),l.background=r4[o],e%2===1&&(l.background=l.background+"_semi")):e===45?l.background="transparent":(l.foreground="black",e===47&&(l.underline=!0));const d=t<=23?1:2;return this.channels[d].setBkgData(l),Pn(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=Of()}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const i=this.channels[e];i&&i.cueSplitAtTime(t)}}}function Pn(s,t,e){e.a=s,e.b=t}function Pf(s,t,e){return e.a===s&&e.b===t}function Of(){return{a:null,b:null}}class zo{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 Qc=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const s=["","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(s,d)}function n(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 l(d,f,p){const g=this,v={enumerable:!0};g.hasBeenReset=!1;let A="",E=!1,T=d,w=f,C=p,x=null,O="",U=!0,D="auto",H="start",$=50,z="middle",tt=50,at="middle";Object.defineProperty(g,"id",o({},v,{get:function(){return A},set:function(J){A=""+J}})),Object.defineProperty(g,"pauseOnExit",o({},v,{get:function(){return E},set:function(J){E=!!J}})),Object.defineProperty(g,"startTime",o({},v,{get:function(){return T},set:function(J){if(typeof J!="number")throw new TypeError("Start time must be set to a number.");T=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"endTime",o({},v,{get:function(){return w},set:function(J){if(typeof J!="number")throw new TypeError("End time must be set to a number.");w=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"text",o({},v,{get:function(){return C},set:function(J){C=""+J,this.hasBeenReset=!0}})),Object.defineProperty(g,"region",o({},v,{get:function(){return x},set:function(J){x=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"vertical",o({},v,{get:function(){return O},set:function(J){const St=i(J);if(St===!1)throw new SyntaxError("An invalid or illegal string was specified.");O=St,this.hasBeenReset=!0}})),Object.defineProperty(g,"snapToLines",o({},v,{get:function(){return U},set:function(J){U=!!J,this.hasBeenReset=!0}})),Object.defineProperty(g,"line",o({},v,{get:function(){return D},set:function(J){if(typeof J!="number"&&J!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");D=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"lineAlign",o({},v,{get:function(){return H},set:function(J){const St=n(J);if(!St)throw new SyntaxError("An invalid or illegal string was specified.");H=St,this.hasBeenReset=!0}})),Object.defineProperty(g,"position",o({},v,{get:function(){return $},set:function(J){if(J<0||J>100)throw new Error("Position must be between 0 and 100.");$=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"positionAlign",o({},v,{get:function(){return z},set:function(J){const St=n(J);if(!St)throw new SyntaxError("An invalid or illegal string was specified.");z=St,this.hasBeenReset=!0}})),Object.defineProperty(g,"size",o({},v,{get:function(){return tt},set:function(J){if(J<0||J>100)throw new Error("Size must be between 0 and 100.");tt=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"align",o({},v,{get:function(){return at},set:function(J){const St=n(J);if(!St)throw new SyntaxError("An invalid or illegal string was specified.");at=St,this.hasBeenReset=!0}})),g.displayState=void 0}return l.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},l}();class o4{decode(t,e){if(!t)return"";if(typeof t!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function Mf(s){function t(i,n,o,l){return(i|0)*3600+(n|0)*60+(o|0)+parseFloat(l||0)}const e=s.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?t(e[2],e[3],0,e[4]):t(e[1],e[2],e[3],e[4]):null}class l4{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 n=0;n<i.length;++n)if(e===i[n]){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 $f(s,t,e,i){const n=i?s.split(i):[s];for(const o in n){if(typeof n[o]!="string")continue;const l=n[o].split(e);if(l.length!==2)continue;const d=l[0],f=l[1];t(d,f)}}const Jc=new Qc(0,0,""),Yo=Jc.align==="middle"?"middle":"center";function c4(s,t,e){const i=s;function n(){const d=Mf(s);if(d===null)throw new Error("Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),d}function o(d,f){const p=new l4;$f(d,function(A,E){let T;switch(A){case"region":for(let w=e.length-1;w>=0;w--)if(e[w].id===E){p.set(A,e[w].region);break}break;case"vertical":p.alt(A,E,["rl","lr"]);break;case"line":T=E.split(","),p.integer(A,T[0]),p.percent(A,T[0])&&p.set("snapToLines",!1),p.alt(A,T[0],["auto"]),T.length===2&&p.alt("lineAlign",T[1],["start",Yo,"end"]);break;case"position":T=E.split(","),p.percent(A,T[0]),T.length===2&&p.alt("positionAlign",T[1],["start",Yo,"end","line-left","line-right","auto"]);break;case"size":p.percent(A,E);break;case"align":p.alt(A,E,["start",Yo,"end","left","right"]);break}},/:/,/\s/),f.region=p.get("region",null),f.vertical=p.get("vertical","");let g=p.get("line","auto");g==="auto"&&Jc.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",Yo);let v=p.get("position","auto");v==="auto"&&Jc.position===50&&(v=f.align==="start"||f.align==="left"?0:f.align==="end"||f.align==="right"?100:50),f.position=v}function l(){s=s.replace(/^\s+/,"")}if(l(),t.startTime=n(),l(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.slice(3),l(),t.endTime=n(),l(),o(s,t)}function Ff(s){return s.replace(/<br(?: \/)?>/gi,`
198
- `)}class h4{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new o4,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,l=0;for(o=Ff(o);l<o.length&&o[l]!=="\r"&&o[l]!==`
196
+ Aborting and switching to level ${J}`),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 n=i?i.stats:e.stats;if(e.type===Jt.MAIN&&this.bwEstimator.sampleTTFB(n.loading.first-n.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,l=this.hls.levels[e.level],d=(l.loaded?l.loaded.bytes:0)+n.loaded,f=(l.loaded?l.loaded.duration:0)+o;l.loaded={bytes:d,duration:f},l.realBitrate=Math.round(8*d/f)}if(e.bitrateTest){const o={stats:n,frag:e,part:i,id:e.type};this.onFragBuffered(R.FRAG_BUFFERED,o),e.bitrateTest=!1}}}onFragBuffered(t,e){const{frag:i,part:n}=e,o=n!=null&&n.stats.loaded?n.stats:i.stats;if(o.aborted||this.ignoreFragment(i))return;const l=o.parsing.end-o.loading.start-Math.min(o.loading.first-o.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(l,o.loaded),o.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=l/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 n=this.hls.levels;if(n.length>Math.max(t,i)&&n[t].loadError<=n[i].loadError)return t}return t!==-1&&(i=Math.min(t,i)),i}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:i}=this,{maxAutoLevel:n,config:o,minAutoLevel:l,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,A=(v?v.len:0)/p;let E=this.findBestLevel(g,l,n,A,o.abrBandWidthFactor,o.abrBandWidthUpFactor);if(E>=0)return E;X.trace(`[abr] ${A?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let T=f?Math.min(f,o.maxStarvationDelay):o.maxStarvationDelay,w=o.abrBandWidthFactor,C=o.abrBandWidthUpFactor;if(!A){const D=this.bitrateTestDelay;D&&(T=(f?Math.min(f,o.maxLoadingDelay):o.maxLoadingDelay)-D,X.trace(`[abr] bitrate test took ${Math.round(1e3*D)}ms, set first fragment max fetchDuration to ${Math.round(1e3*T)} ms`),w=C=1)}return E=this.findBestLevel(g,l,n,A+T,w,C),Math.max(E,0)}findBestLevel(t,e,i,n,o,l){var d;const{fragCurrent:f,partCurrent:p,lastLoadedFragLevel:g}=this,{levels:v}=this.hls,A=v[g],E=!!(A!=null&&(d=A.details)!=null&&d.live),T=A==null?void 0:A.codecSet,w=p?p.duration:f?f.duration:0,C=this.bwEstimator.getEstimateTTFB()/1e3;let D=e,M=-1;for(let U=i;U>=e;U--){const x=v[U];if(!x||T&&x.codecSet!==T){x&&(D=Math.min(U,D),M=Math.max(U,M));continue}M!==-1&&X.trace(`[abr] Skipped level(s) ${D}-${M} with CODECS:"${v[M].attrs.CODECS}"; not compatible with "${A.attrs.CODECS}"`);const G=x.details,$=(p?G==null?void 0:G.partTarget:G==null?void 0:G.averagetargetduration)||w;let Y;U<=g?Y=o*t:Y=l*t;const tt=v[U].maxBitrate,nt=this.getTimeToLoadFrag(C,Y,tt*$,G===void 0);if(X.trace(`[abr] level:${U} adjustedbw-bitrate:${Math.round(Y-tt)} avgDuration:${$.toFixed(1)} maxFetchDuration:${n.toFixed(1)} fetchDuration:${nt.toFixed(1)}`),Y>tt&&(nt===0||!Wt(nt)||E&&!this.bitrateTestDelay||nt<n))return U}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}}class Tf{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=Kb(t,e);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function Kb(s,t){const e=new Uint8Array(t);let i=0;for(let n=0;n<s.length;n++){const o=s[n];e.set(o,i),i+=o.length}return e}const kf=100;class Yb extends Nc{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:n,timescale:o}){if(i==="main"){const l=e.cc;this.initPTS[e.cc]={baseTime:n,timescale:o},this.log(`InitPTS for cc: ${l} found from main: ${n}`),this.videoTrackCC=l,this.state===wt.WAITING_INIT_PTS&&this.tick()}}startLoad(t){if(!this.levels){this.startPosition=t,this.state=wt.STOPPED;return}const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(kf),e>0&&t===-1?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=wt.IDLE):(this.loadedmetadata=!1,this.state=wt.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case wt.IDLE:this.doTickIdle();break;case wt.WAITING_TRACK:{var t;const{levels:i,trackId:n}=this,o=i==null||(t=i[n])==null?void 0:t.details;if(o){if(this.waitForCdnTuneIn(o))break;this.state=wt.WAITING_INIT_PTS}break}case wt.FRAG_LOADING_WAITING_RETRY:{var e;const i=performance.now(),n=this.retryDate;(!n||i>=n||(e=this.media)!=null&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=wt.IDLE);break}case wt.WAITING_INIT_PTS:{const i=this.waitingData;if(i){const{frag:n,part:o,cache:l,complete:d}=i;if(this.initPTS[n.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=wt.FRAG_LOADING;const f=l.flush(),p={frag:n,part:o,payload:f,networkDetails:null};this._handleFragmentLoadProgress(p),d&&super._handleFragmentLoadComplete(p)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${n.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const f=this.getLoadPosition(),p=Ge.bufferInfo(this.mediaBuffer,f,this.config.maxBufferHole);Dc(p.end,this.config.maxFragLookUpTolerance,n)<0&&(this.log(`Waiting fragment cc (${n.cc}) @ ${n.start} cancelled because another fragment at ${p.end} is needed`),this.clearWaitingFragment())}}else this.state=wt.IDLE}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=wt.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:n}=this,o=t.config;if(!(e!=null&&e[n])||!i&&(this.startFragRequested||!o.startFragPrefetch))return;const l=e[n],d=l.details;if(!d||d.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(d)){this.state=wt.WAITING_TRACK;return}const f=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&f&&(this.bufferFlushed=!1,this.afterBufferFlushed(f,xe.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=wt.ENDED;return}const A=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Jt.MAIN),E=p.len,T=this.getMaxBufferLength(A==null?void 0:A.len);if(E>=T&&!v)return;const w=d.fragments[0].start;let C=p.end;if(v&&i){const x=this.getLoadPosition();g&&v.attrs!==g.attrs&&(C=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(C,d),M=!1;if(D&&this.isLoopLoading(D,C)&&(M=!!D.gap,D=this.getNextFragmentLoopLoading(D,d,p,Jt.MAIN,T)),!D){this.bufferFlushed=!0;return}const U=A&&D.start>A.end+d.targetduration;if(U||!(A!=null&&A.len)&&p.len){const x=this.getAppendedFrag(D.start,Jt.MAIN);if(x===null||(M||(M=!!x.gap||!!U&&A.len===0),U&&!M||M&&p.nextStart&&p.nextStart<x.end))return}this.loadFragment(D,l,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 xa(i))}onAudioTrackSwitching(t,e){const i=!!e.url;this.trackId=e.id;const{fragCurrent:n}=this;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?this.setInterval(kf):this.resetTransmuxer(),i?(this.switchingTrack=e,this.state=wt.IDLE):(this.switchingTrack=null,this.bufferedTrack=e,this.state=wt.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:n}=this,{details:o,id:l}=e;if(!n){this.warn(`Audio tracks were reset while loading level ${l}`);return}this.log(`Track ${l} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""},duration:${o.totalduration}`);const d=n[l];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?(J0(o,p),f=o.fragments[0].start):f=this.alignPlaylists(o,d.details)}d.details=o,this.levelLastLoaded=l,!this.startFragRequested&&(this.mainDetails||!o.live)&&this.setStartPosition(d.details,f),this.state===wt.WAITING_TRACK&&!this.waitForCdnTuneIn(o)&&(this.state=wt.IDLE),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:n,payload:o}=t,{config:l,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=l.defaultAudioCodec||p.audioCodec||"mp4a.40.2";let A=this.transmuxer;A||(A=this.transmuxer=new Ef(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=n?n.index:-1,C=w!==-1,D=new Mc(i.level,i.sn,i.stats.chunkCount,o.byteLength,w,C);A.push(o,T,v,"",i,n,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:n,cache:new Tf,complete:!1};w.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=wt.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:n}=e;if(i.type!==Jt.AUDIO){if(!this.loadedmetadata&&i.type===Jt.MAIN){const o=this.videoBuffer||this.media;o&&Ge.getBuffered(o).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${n?" p: "+n.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,Yi({},o)))}this.fragBufferedComplete(i,n)}onError(t,e){var i;if(e.fatal){this.state=wt.ERROR;return}switch(e.details){case pt.FRAG_GAP:case pt.FRAG_PARSING_ERROR:case pt.FRAG_DECRYPT_ERROR:case pt.FRAG_LOAD_ERROR:case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_ERROR:case pt.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Jt.AUDIO,e);break;case pt.AUDIO_TRACK_LOAD_ERROR:case pt.AUDIO_TRACK_LOAD_TIMEOUT:case pt.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===wt.WAITING_TRACK&&((i=e.context)==null?void 0:i.type)===ke.AUDIO_TRACK&&(this.state=wt.IDLE);break;case pt.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 pt.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}onBufferFlushed(t,{type:e}){e===xe.AUDIO&&(this.bufferFlushed=!0,this.state===wt.ENDED&&(this.state=wt.IDLE))}_handleTransmuxComplete(t){var e;const i="audio",{hls:n}=this,{remuxResult:o,chunkMeta:l}=t,d=this.getCurrentContext(l);if(!d){this.resetWhenMissingContext(l);return}const{frag:f,part:p,level:g}=d,{details:v}=g,{audio:A,text:E,id3:T,initSegment:w}=o;if(this.fragContextChanged(f)||!v){this.fragmentTracker.removeFragment(f);return}if(this.state=wt.PARSING,this.switchingTrack&&A&&this.completeAudioSwitch(this.switchingTrack),w!=null&&w.tracks){const C=f.initSegment||f;this._bufferInitSegment(w.tracks,C,l),n.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:C,id:i,tracks:w.tracks})}if(A){const{startPTS:C,endPTS:D,startDTS:M,endDTS:U}=A;p&&(p.elementaryStreams[xe.AUDIO]={startPTS:C,endPTS:D,startDTS:M,endDTS:U}),f.setElementaryStreamInfo(xe.AUDIO,C,D,M,U),this.bufferFragmentData(A,f,p,l)}if(T!=null&&(e=T.samples)!=null&&e.length){const C=ui({id:i,frag:f,details:v},T);n.trigger(R.FRAG_PARSING_METADATA,C)}if(E){const C=ui({id:i,frag:f,details:v},E);n.trigger(R.FRAG_PARSING_USERDATA,C)}}_bufferInitSegment(t,e,i){if(this.state!==wt.PARSING)return;t.video&&delete t.video;const n=t.audio;if(!n)return;n.levelCodec=n.codec,n.id="audio",this.log(`Init audio buffer, container:${n.container}, codecs[parsed]=[${n.codec}]`),this.hls.trigger(R.BUFFER_CODECS,t);const o=n.initSegment;if(o!=null&&o.byteLength){const l={type:"audio",frag:e,part:null,chunkMeta:i,parent:e.type,data:o};this.hls.trigger(R.BUFFER_APPENDING,l)}this.tick()}loadFragment(t,e,i){const n=this.fragmentTracker.getState(t);if(this.fragCurrent=t,this.switchingTrack||n===yi.NOT_LOADED||n===yi.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=wt.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(t,e,i))}else this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){const{hls:e,media:i,bufferedTrack:n}=this,o=n==null?void 0:n.attrs,l=t.attrs;i&&o&&(o.CHANNELS!==l.CHANNELS||o.NAME!==l.NAME||o.LANGUAGE!==l.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,Yi({},t))}}class zb extends Pc{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:n,details:o}=e,l=this.tracksInGroup[i];if(!l||l.groupId!==n){this.warn(`Track with id:${i} and group:${n} not found in active group ${l.groupId}`);return}const d=l.details;l.details=e.details,this.log(`audio-track ${i} "${l.name}" lang:${l.lang} group:${n} 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 n=this.tracks.filter(l=>!i||l.groupId===i);this.selectDefaultTrack&&!n.some(l=>l.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;const o={audioTracks:n};this.log(`Updating audio tracks, ${n.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===ke.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 n=e[t],{groupId:o,name:l}=n;if(this.log(`Switching to audio-track ${t} "${l}" lang:${n.lang} group:${o}`),this.trackId=t,this.currentTrack=n,this.selectDefaultTrack=!1,this.hls.trigger(R.AUDIO_TRACK_SWITCHING,Yi({},n)),n.details&&!n.details.live)return;const d=this.switchParams(n.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:pt.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const n=e[i];if((!this.selectDefaultTrack||n.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]!==void 0&&t.attrs["STABLE-RENDITION-ID"]===n.attrs["STABLE-RENDITION-ID"]||t.name===n.name&&t.lang===n.lang))return n.id}return-1}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const i=e.id,n=e.groupId;let o=e.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn(`Could not construct new URL with HLS Delivery Directives: ${l}`)}this.log(`loading audio-track playlist ${i} "${e.name}" lang:${e.lang} group:${n}`),this.clearTimer(),this.hls.trigger(R.AUDIO_TRACK_LOADING,{url:o,id:i,groupId:n,deliveryDirectives:t||null})}}}function wf(s,t){if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(!Xb(s[e].attrs,t[e].attrs))return!1;return!0}function Xb(s,t){const e=s["STABLE-RENDITION-ID"];return e?e===t["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>s[i]!==t[i])}const Sf=500;class Zb extends Nc{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=wt.IDLE,this.setInterval(Sf),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:n}=e;if(this.fragPrevious=i,this.state=wt.IDLE,!n)return;const o=this.tracksBuffered[this.currentTrackId];if(!o)return;let l;const d=i.start;for(let p=0;p<o.length;p++)if(d>=o[p].start&&d<=o[p].end){l=o[p];break}const f=i.start+i.duration;l?l.end=f:(l={start:d,end:f},o.push(l)),this.fragmentTracker.fragBuffered(i)}onBufferFlushing(t,e){const{startOffset:i,endOffset:n}=e;if(i===0&&n!==Number.POSITIVE_INFINITY){const o=n-1;if(o<=0)return;e.endOffsetSubtitles=Math.max(0,o),this.tracksBuffered.forEach(l=>{for(let d=0;d<l.length;){if(l[d].end<=o){l.shift();continue}else if(l[d].start<o)l[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!==wt.STOPPED&&(this.state=wt.IDLE))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){if(wf(this.levels,e)){this.levels=e.map(i=>new xa(i));return}this.tracksBuffered=[],this.levels=e.map(i=>{const n=new xa(i);return this.tracksBuffered[n.id]=[],n}),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(Sf)}onSubtitleTrackLoaded(t,e){var i;const{details:n,id:o}=e,{currentTrackId:l,levels:d}=this;if(!d.length)return;const f=d[l];if(o>=d.length||o!==l||!f)return;this.mediaBuffer=this.mediaBufferTimeRanges;let p=0;if(n.live||(i=f.details)!=null&&i.live){const g=this.mainDetails;if(n.deltaUpdateFailed||!g)return;const v=g.fragments[0];f.details?(p=this.alignPlaylists(n,f.details),p===0&&v&&(p=v.start,Ic(n,p))):n.hasProgramDateTime&&g.hasProgramDateTime?(J0(n,g),p=n.fragments[0].start):v&&(p=v.start,Ic(n,p))}f.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(f.details,p),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===wt.IDLE&&(Da(null,n.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,n=e.decryptdata,o=this.hls;if(!this.fragContextChanged(e)&&i&&i.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){const l=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer).catch(d=>{throw o.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.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:l,tdecrypt:f}})}).catch(d=>{this.warn(`${d.name}: ${d.message}`),this.state=wt.IDLE})}}doTick(){if(!this.media){this.state=wt.IDLE;return}if(this.state===wt.IDLE){const{currentTrackId:t,levels:e}=this,i=e[t];if(!e.length||!i||!i.details)return;const{config:n}=this,o=this.getLoadPosition(),l=Ge.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o,n.maxBufferHole),{end:d,len:f}=l,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 A=g.fragments,E=A.length,T=g.edge;let w=null;const C=this.fragPrevious;if(d<T){const D=n.maxFragLookUpTolerance,M=d>T-D?0:D;w=Da(C,A,Math.max(A[0].start,d),M),!w&&C&&C.start<A[0].start&&(w=A[0])}else w=A[E-1];if(!w)return;if(w=this.mapToInitFragWhenRequired(w),w.sn!=="initSegment"){const D=w.sn-g.startSN,M=A[D-1];M&&M.cc===w.cc&&this.fragmentTracker.getState(M)===yi.NOT_LOADED&&(w=M)}this.fragmentTracker.getState(w)===yi.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 qb(this.tracksBuffered[this.currentTrackId]||[])}}class qb{constructor(t){this.buffered=void 0;const e=(i,n,o)=>{if(n=n>>>0,n>o-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${o})`);return t[n][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 Qb extends Pc{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),Zc(this.media.textTracks).forEach(t=>{Cn(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:n}=e,{trackId:o}=this,l=this.tracksInGroup[o];if(!l){this.warn(`Invalid subtitle track id ${i}`);return}const d=l.details;l.details=e.details,this.log(`subtitle track ${i} loaded [${n.startSN}-${n.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],n=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 l=this.findTrackId(n==null?void 0:n.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),l!==-1&&this.setSubtitleTrack(l,n)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId,n)}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const n=e[i];if((!this.selectDefaultTrack||n.default)&&(!t||t===n.name))return n.id}return-1}onError(t,e){e.fatal||!e.context||e.context.type===ke.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,n=e.groupId;let o=e.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn(`Could not construct new URL with HLS Delivery Directives: ${l}`)}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(R.SUBTITLE_TRACK_LOADING,{url:o,id:i,groupId:n,deliveryDirectives:t||null})}}toggleTrackModes(t){const{media:e,trackId:i}=this;if(!e)return;const n=Zc(e.textTracks),o=n.filter(d=>d.groupId===this.groupId);if(t===-1)[].slice.call(n).forEach(d=>{d.mode="disabled"});else{const d=o[i];d&&(d.mode="disabled")}const l=o[t];l&&(l.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(t,e){var i;const n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=t;return}if(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(t===-1||(i=n[t])!=null&&i.details)||t<-1||t>=n.length)return;this.clearTimer();const o=n[t];if(this.log(`Switching to subtitle-track ${t}`+(o?` "${o.name}" lang:${o.lang} group:${o.groupId}`:"")),this.trackId=t,o){const{id:l,groupId:d="",name:f,type:p,url:g}=o;this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:l,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=Zc(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 Zc(s){const t=[];for(let e=0;e<s.length;e++){const i=s[e];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&t.push(s[e])}return t}class Jb{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}),n={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(n,t),i}executeNext(t){const{buffers:e,queues:i}=this,n=e[t],o=i[t];if(o.length){const l=o[0];try{l.execute()}catch(d){X.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),l.onError(d),n!=null&&n.updating||(o.shift(),this.executeNext(t))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const Rf=$o(),Lf=/([ha]vc.)(?:\.[^.,]+)+/;class t4{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;X.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=()=>{X.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{X.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:i}=this;e&&e.src!==i&&X.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 Jb(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,X.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const i=this.media=e.media;if(i&&Rf){const n=this.mediaSource=new Rf;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(n),this._objectUrl=i.src,i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:i}=this;if(e){if(X.log("[buffer-controller]: media source detaching"),e.readyState==="open")try{e.endOfStream()}catch(n){X.warn(`[buffer-controller]: onMediaDetaching: ${n.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()):X.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){X.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,i)}}),this._initSourceBuffer()}onBufferCodecs(t,e){const i=this.getSourceBufferTypes().length;Object.keys(e).forEach(n=>{if(i){const o=this.tracks[n];if(o&&typeof o.buffer.changeType=="function"){const{id:l,codec:d,levelCodec:f,container:p,metadata:g}=e[n],v=(o.levelCodec||o.codec).replace(Lf,"$1"),A=(f||d).replace(Lf,"$1");if(v!==A){const E=`${p};codecs=${f||d}`;this.appendChangeType(n,E),X.log(`[buffer-controller]: switching codec ${v} to ${A}`),this.tracks[n]={buffer:o.buffer,codec:d,container:p,levelCodec:f,metadata:g,id:l}}}}else this.pendingTracks[n]=e[n]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(t,e){const{operationQueue:i}=this,n={execute:()=>{const o=this.sourceBuffer[t];o&&(X.log(`[buffer-controller]: changing ${t} sourceBuffer type to ${e}`),o.changeType(e)),i.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:o=>{X.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,o)}};i.append(n,t)}onBufferAppending(t,e){const{hls:i,operationQueue:n,tracks:o}=this,{data:l,type:d,frag:f,part:p,chunkMeta:g}=e,v=g.buffering[d],A=self.performance.now();v.start=A;const E=f.stats.buffering,T=p?p.stats.buffering:null;E.start===0&&(E.start=A),T&&T.start===0&&(T.start=A);const w=o.audio;let C=!1;d==="audio"&&(w==null?void 0:w.container)==="audio/mpeg"&&(C=!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(),C){const U=this.sourceBuffer[d];if(U){const x=D-U.timestampOffset;Math.abs(x)>=.1&&(X.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${D} (delta: ${x}) sn: ${f.sn})`),U.timestampOffset=D)}}this.appendExecutor(l,d)},onStart:()=>{},onComplete:()=>{const U=self.performance.now();v.executeEnd=v.end=U,E.first===0&&(E.first=U),T&&T.first===0&&(T.first=U);const{sourceBuffer:x}=this,G={};for(const $ in x)G[$]=Ge.getBuffered(x[$]);this.appendError=0,this.hls.trigger(R.BUFFER_APPENDED,{type:d,frag:f,part:p,chunkMeta:g,parent:f.type,timeRanges:G})},onError:U=>{X.error(`[buffer-controller]: Error encountered while trying to append to the ${d} SourceBuffer`,U);const x={type:Qt.MEDIA_ERROR,parent:f.type,details:pt.BUFFER_APPEND_ERROR,frag:f,part:p,chunkMeta:g,error:U,err:U,fatal:!1};U.code===DOMException.QUOTA_EXCEEDED_ERR?x.details=pt.BUFFER_FULL_ERROR:(this.appendError++,x.details=pt.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(X.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),x.fatal=!0)),i.trigger(R.ERROR,x)}};n.append(M,d)}onBufferFlushing(t,e){const{operationQueue:i}=this,n=o=>({execute:this.removeExecutor.bind(this,o,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(R.BUFFER_FLUSHED,{type:o})},onError:l=>{X.warn(`[buffer-controller]: Failed to remove from ${o} SourceBuffer`,l)}});e.type?i.append(n(e.type),e.type):this.getSourceBufferTypes().forEach(o=>{i.append(n(o),o)})}onFragParsed(t,e){const{frag:i,part:n}=e,o=[],l=n?n.elementaryStreams:i.elementaryStreams;l[xe.AUDIOVIDEO]?o.push("audiovideo"):(l[xe.AUDIO]&&o.push("audio"),l[xe.VIDEO]&&o.push("video"));const d=()=>{const f=self.performance.now();i.stats.buffering.end=f,n&&(n.stats.buffering.end=f);const p=n?n.stats:i.stats;this.hls.trigger(R.FRAG_BUFFERED,{frag:i,part:n,stats:p,id:i.type})};o.length===0&&X.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,n)=>{const o=this.sourceBuffer[n];return o&&(!e.type||e.type===n)&&(o.ending=!0,o.ended||(o.ended=!0,X.log(`[buffer-controller]: ${n} sourceBuffer now EOS`))),i&&!!(!o||o.ended)},!0)&&(X.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{const o=this.sourceBuffer[n];o&&(o.ending=!1)});const{mediaSource:i}=this;if(!i||i.readyState!=="open"){i&&X.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${i.readyState}`);return}X.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:n}=this;if(!i||e===null)return;const o=this.getSourceBufferTypes();if(!o.length)return;const l=e.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(!Wt(l)||l<0)return;const d=i.currentTime,f=e.levelTargetDuration,p=Math.max(l,f),g=Math.floor(d/f)*f-p;o.forEach(v=>{const A=n[v];if(A){const E=Ge.getBuffered(A);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(A.ended&&E.end(E.length-1)-d<f*2){X.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:n}=this,o=t.fragments[0].start+t.totalduration,l=i.duration,d=Wt(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(X.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(t)):(o>d&&o>l||!Wt(l))&&(X.log(`[buffer-controller]: Updating Media Source duration to ${o.toFixed(3)}`),n.duration=o)}updateSeekableRange(t){const e=this.mediaSource,i=t.fragments;if(i.length&&t.live&&e!=null&&e.setLiveSeekableRange){const n=Math.max(0,i[0].start),o=Math.max(n,n+t.totalduration);e.setLiveSeekableRange(n,o)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:i}=this,n=Object.keys(i).length;if(n&&!t||n===2){this.createSourceBuffers(i),this.pendingTracks={};const o=this.getSourceBufferTypes();if(o.length)this.hls.trigger(R.BUFFER_CREATED,{tracks:this.tracks}),o.forEach(l=>{e.executeNext(l)});else{const l=new Error("could not create source buffer for media codec(s)");this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:l,reason:l.message})}}}createSourceBuffers(t){const{sourceBuffer:e,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const n in t)if(!e[n]){const o=t[n];if(!o)throw Error(`source buffer exists for track ${n}, however track does not`);const l=o.levelCodec||o.codec,d=`${o.container};codecs=${l}`;X.log(`[buffer-controller]: creating sourceBuffer(${d})`);try{const f=e[n]=i.addSourceBuffer(d),p=n;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[n]={buffer:f,codec:l,container:o.container,levelCodec:o.levelCodec,metadata:o.metadata,id:o.id}}catch(f){X.error(`[buffer-controller]: error while trying to add sourceBuffer: ${f.message}`),this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.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`);X.error(`[buffer-controller]: ${i}`,e),this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:pt.BUFFER_APPENDING_ERROR,error:i,fatal:!1});const n=this.operationQueue.current(t);n&&n.onError(e)}removeExecutor(t,e,i){const{media:n,mediaSource:o,operationQueue:l,sourceBuffer:d}=this,f=d[t];if(!n||!o||!f){X.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),l.shiftAndExecuteNext(t);return}const p=Wt(n.duration)?n.duration:1/0,g=Wt(o.duration)?o.duration:1/0,v=Math.max(0,e),A=Math.min(i,p,g);A>v&&!f.ending?(f.ended=!1,X.log(`[buffer-controller]: Removing [${v},${A}] from the ${t} SourceBuffer`),f.remove(v,A)):l.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:i,sourceBuffer:n}=this,o=n[e];if(!o){X.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){X.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);return}const{operationQueue:i}=this,n=e.map(o=>i.appendBlocker(o));Promise.all(n).then(()=>{t(),e.forEach(o=>{const l=this.sourceBuffer[o];l!=null&&l.updating||i.shiftAndExecuteNext(o)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,i){const n=this.sourceBuffer[t];if(!n)return;const o=i.bind(this,t);this.listeners[t].push({event:e,listener:o}),n.addEventListener(e,o)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach(i=>{e.removeEventListener(i.event,i.listener)})}}const _f={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},Cf=function(s){let t=s;return _f.hasOwnProperty(s)&&(t=_f[s]),String.fromCharCode(t)},Rr=15,os=100,e4={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},i4={17:2,18:4,21:6,22:8,23:10,19:13,20:15},r4={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},s4={25:2,26:4,29:6,30:8,31:10,27:13,28:15},n4=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class a4{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const i=typeof e=="function"?e():e;X.log(`${this.time} [${t}] ${i}`)}}}const un=function(s){const t=[];for(let e=0;e<s.length;e++)t.push(s[e].toString(16));return t};class If{constructor(t,e,i,n,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=n||"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 n=e[i];t.hasOwnProperty(n)&&(this[n]=t[n])}}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 o4{constructor(t,e,i,n,o,l){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new If(e,i,n,o,l)}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 l4{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<os;e++)this.chars.push(new o4);this.logger=t,this.pos=0,this.currPenState=new If}equals(t){let e=!0;for(let i=0;i<os;i++)if(!this.chars[i].equals(t.chars[i])){e=!1;break}return e}copy(t){for(let e=0;e<os;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<os;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>os&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=os)}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=Cf(t);if(this.pos>=os){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<os;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<os;i++){const n=this.chars[i].uchar;n!==" "&&(e=!1),t.push(n)}return e?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)}}class qc{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<Rr;e++)this.rows.push(new l4(t));this.logger=t,this.currRow=Rr-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let t=0;t<Rr;t++)this.rows[t].clear();this.currRow=Rr-1}equals(t){let e=!0;for(let i=0;i<Rr;i++)if(!this.rows[i].equals(t.rows[i])){e=!1;break}return e}copy(t){for(let e=0;e<Rr;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<Rr;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<Rr;d++)this.rows[d].clear();const o=this.currRow+1-this.nrRollUpRows,l=this.lastOutputScreen;if(l){const d=l.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(l.rows[o+p])}}this.currRow=e;const i=this.rows[this.currRow];if(t.indent!==null){const o=t.indent,l=Math.max(o-1,0);i.setCursor(t.indent),t.color=i.chars[l].penState.foreground}const n={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(n)}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="",n=-1;for(let o=0;o<Rr;o++){const l=this.rows[o].getTextString();l&&(n=o+1,t?e.push("Row "+n+": '"+l+"'"):e.push(l.trim()))}return e.length>0&&(t?i="["+e.join(" | ")+"]":i=e.join(`
197
+ `)),i}getTextAndFormat(){return this.rows}}class xf{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 qc(i),this.nonDisplayedMemory=new qc(i),this.lastOutputScreen=new qc(i),this.currRollUpRow=this.displayedMemory.rows[Rr-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[Rr-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,n=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=n[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 Df{constructor(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const n=new a4;this.channels=[null,new xf(t,e,n),new xf(t+1,i,n)],this.cmdHistory=Of(),this.logger=n}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let i,n,o,l=!1;this.logger.time=t;for(let d=0;d<e.length;d+=2)if(n=e[d]&127,o=e[d+1]&127,!(n===0&&o===0)){if(this.logger.log(3,"["+un([e[d],e[d+1]])+"] -> ("+un([n,o])+")"),i=this.parseCmd(n,o),i||(i=this.parseMidrow(n,o)),i||(i=this.parsePAC(n,o)),i||(i=this.parseBackgroundAttributes(n,o)),!i&&(l=this.parseChars(n,o),l)){const f=this.currentChannel;f&&f>0?this.channels[f].insertChars(l):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!i&&!l&&this.logger.log(2,"Couldn't parse cleaned data "+un([n,o])+" orig: "+un([e[d],e[d+1]]))}}parseCmd(t,e){const{cmdHistory:i}=this,n=(t===20||t===28||t===21||t===29)&&e>=32&&e<=47,o=(t===23||t===31)&&e>=33&&e<=35;if(!(n||o))return!1;if(Pf(t,e,i))return Pn(null,null,i),this.logger.log(3,"Repeated command ("+un([t,e])+") is dropped"),!0;const l=t===20||t===21||t===23?1:2,d=this.channels[l];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),Pn(t,e,i),this.currentChannel=l,!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 n=this.channels[i];return n?(n.ccMIDROW(e),this.logger.log(3,"MIDROW ("+un([t,e])+")"),!0):!1}return!1}parsePAC(t,e){let i;const n=this.cmdHistory,o=(t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127,l=(t===16||t===24)&&e>=64&&e<=95;if(!(o||l))return!1;if(Pf(t,e,n))return Pn(null,null,n),!0;const d=t<=23?1:2;e>=64&&e<=95?i=d===1?e4[t]:r4[t]:i=d===1?i4[t]:s4[t];const f=this.channels[d];return f?(f.setPAC(this.interpretPAC(i,e)),Pn(t,e,n),this.currentChannel=d,!0):!1}interpretPAC(t,e){let i;const n={color:null,italics:!1,indent:null,underline:!1,row:t};return e>95?i=e-96:i=e-64,n.underline=(i&1)===1,i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=Math.floor((i-16)/2)*4,n}parseChars(t,e){let i,n=null,o=null;if(t>=25?(i=2,o=t-8):(i=1,o=t),o>=17&&o<=19){let l;o===17?l=e+80:o===18?l=e+112:l=e+144,this.logger.log(2,"Special char '"+Cf(l)+"' in channel "+i),n=[l]}else t>=32&&t<=127&&(n=e===0?[t]:[t,e]);if(n){const l=un(n);this.logger.log(3,"Char codes = "+l.join(",")),Pn(t,e,this.cmdHistory)}return n}parseBackgroundAttributes(t,e){const i=(t===16||t===24)&&e>=32&&e<=47,n=(t===23||t===31)&&e>=45&&e<=47;if(!(i||n))return!1;let o;const l={};t===16||t===24?(o=Math.floor((e-32)/2),l.background=n4[o],e%2===1&&(l.background=l.background+"_semi")):e===45?l.background="transparent":(l.foreground="black",e===47&&(l.underline=!0));const d=t<=23?1:2;return this.channels[d].setBkgData(l),Pn(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=Of()}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const i=this.channels[e];i&&i.cueSplitAtTime(t)}}}function Pn(s,t,e){e.a=s,e.b=t}function Pf(s,t,e){return e.a===s&&e.b===t}function Of(){return{a:null,b:null}}class zo{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 Qc=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const s=["","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(s,d)}function n(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 l(d,f,p){const g=this,v={enumerable:!0};g.hasBeenReset=!1;let A="",E=!1,T=d,w=f,C=p,D=null,M="",U=!0,x="auto",G="start",$=50,Y="middle",tt=50,nt="middle";Object.defineProperty(g,"id",o({},v,{get:function(){return A},set:function(J){A=""+J}})),Object.defineProperty(g,"pauseOnExit",o({},v,{get:function(){return E},set:function(J){E=!!J}})),Object.defineProperty(g,"startTime",o({},v,{get:function(){return T},set:function(J){if(typeof J!="number")throw new TypeError("Start time must be set to a number.");T=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"endTime",o({},v,{get:function(){return w},set:function(J){if(typeof J!="number")throw new TypeError("End time must be set to a number.");w=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"text",o({},v,{get:function(){return C},set:function(J){C=""+J,this.hasBeenReset=!0}})),Object.defineProperty(g,"region",o({},v,{get:function(){return D},set:function(J){D=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"vertical",o({},v,{get:function(){return M},set:function(J){const St=i(J);if(St===!1)throw new SyntaxError("An invalid or illegal string was specified.");M=St,this.hasBeenReset=!0}})),Object.defineProperty(g,"snapToLines",o({},v,{get:function(){return U},set:function(J){U=!!J,this.hasBeenReset=!0}})),Object.defineProperty(g,"line",o({},v,{get:function(){return x},set:function(J){if(typeof J!="number"&&J!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");x=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"lineAlign",o({},v,{get:function(){return G},set:function(J){const St=n(J);if(!St)throw new SyntaxError("An invalid or illegal string was specified.");G=St,this.hasBeenReset=!0}})),Object.defineProperty(g,"position",o({},v,{get:function(){return $},set:function(J){if(J<0||J>100)throw new Error("Position must be between 0 and 100.");$=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"positionAlign",o({},v,{get:function(){return Y},set:function(J){const St=n(J);if(!St)throw new SyntaxError("An invalid or illegal string was specified.");Y=St,this.hasBeenReset=!0}})),Object.defineProperty(g,"size",o({},v,{get:function(){return tt},set:function(J){if(J<0||J>100)throw new Error("Size must be between 0 and 100.");tt=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"align",o({},v,{get:function(){return nt},set:function(J){const St=n(J);if(!St)throw new SyntaxError("An invalid or illegal string was specified.");nt=St,this.hasBeenReset=!0}})),g.displayState=void 0}return l.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},l}();class c4{decode(t,e){if(!t)return"";if(typeof t!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function Mf(s){function t(i,n,o,l){return(i|0)*3600+(n|0)*60+(o|0)+parseFloat(l||0)}const e=s.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?t(e[2],e[3],0,e[4]):t(e[1],e[2],e[3],e[4]):null}class h4{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 n=0;n<i.length;++n)if(e===i[n]){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 $f(s,t,e,i){const n=i?s.split(i):[s];for(const o in n){if(typeof n[o]!="string")continue;const l=n[o].split(e);if(l.length!==2)continue;const d=l[0],f=l[1];t(d,f)}}const Jc=new Qc(0,0,""),Xo=Jc.align==="middle"?"middle":"center";function d4(s,t,e){const i=s;function n(){const d=Mf(s);if(d===null)throw new Error("Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),d}function o(d,f){const p=new h4;$f(d,function(A,E){let T;switch(A){case"region":for(let w=e.length-1;w>=0;w--)if(e[w].id===E){p.set(A,e[w].region);break}break;case"vertical":p.alt(A,E,["rl","lr"]);break;case"line":T=E.split(","),p.integer(A,T[0]),p.percent(A,T[0])&&p.set("snapToLines",!1),p.alt(A,T[0],["auto"]),T.length===2&&p.alt("lineAlign",T[1],["start",Xo,"end"]);break;case"position":T=E.split(","),p.percent(A,T[0]),T.length===2&&p.alt("positionAlign",T[1],["start",Xo,"end","line-left","line-right","auto"]);break;case"size":p.percent(A,E);break;case"align":p.alt(A,E,["start",Xo,"end","left","right"]);break}},/:/,/\s/),f.region=p.get("region",null),f.vertical=p.get("vertical","");let g=p.get("line","auto");g==="auto"&&Jc.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",Xo);let v=p.get("position","auto");v==="auto"&&Jc.position===50&&(v=f.align==="start"||f.align==="left"?0:f.align==="end"||f.align==="right"?100:50),f.position=v}function l(){s=s.replace(/^\s+/,"")}if(l(),t.startTime=n(),l(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.slice(3),l(),t.endTime=n(),l(),o(s,t)}function Ff(s){return s.replace(/<br(?: \/)?>/gi,`
198
+ `)}class u4{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new c4,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,l=0;for(o=Ff(o);l<o.length&&o[l]!=="\r"&&o[l]!==`
199
199
  `;)++l;const d=o.slice(0,l);return o[l]==="\r"&&++l,o[l]===`
200
- `&&++l,e.buffer=o.slice(l),d}function n(o){$f(o,function(l,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 l=!1;for(;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(l?l=!1:o=i(),e.state){case"HEADER":/:/.test(o)?n(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 Qc(0,0,""),e.state="CUE",o.indexOf("-->")===-1){e.cue.id=o;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{c4(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&&(l=!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+=`
200
+ `&&++l,e.buffer=o.slice(l),d}function n(o){$f(o,function(l,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 l=!1;for(;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(l?l=!1:o=i(),e.state){case"HEADER":/:/.test(o)?n(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 Qc(0,0,""),e.state="CUE",o.indexOf("-->")===-1){e.cue.id=o;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{d4(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&&(l=!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
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
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 d4=/\r\n|\n\r|\n|\r/g,th=function(s,t,e=0){return s.slice(e,e+t.length)===t},u4=function(s){let t=parseInt(s.slice(-3));const e=parseInt(s.slice(-6,-4)),i=parseInt(s.slice(-9,-7)),n=s.length>9?parseInt(s.substring(0,s.indexOf(":"))):0;if(!Wt(t)||!Wt(e)||!Wt(i)||!Wt(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${s}`);return t+=1e3*e,t+=60*1e3*i,t+=60*60*1e3*n,t},eh=function(s){let t=5381,e=s.length;for(;e;)t=t*33^s.charCodeAt(--e);return(t>>>0).toString()};function ih(s,t,e){return eh(s.toString())+eh(t.toString())+eh(e)}const f4=function(s,t,e){let i=s[t],n=s[i.prevCC];if(!n||!n.new&&i.new){s.ccOffset=s.presentationOffset=i.start,i.new=!1;return}for(;(o=n)!=null&&o.new;){var o;s.ccOffset+=i.start-n.start,i.new=!1,i=n,n=s[i.prevCC]}s.presentationOffset=e};function p4(s,t,e,i,n,o,l){const d=new h4,f=Nr(new Uint8Array(s)).trim().replace(d4,`
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 f4=/\r\n|\n\r|\n|\r/g,th=function(s,t,e=0){return s.slice(e,e+t.length)===t},p4=function(s){let t=parseInt(s.slice(-3));const e=parseInt(s.slice(-6,-4)),i=parseInt(s.slice(-9,-7)),n=s.length>9?parseInt(s.substring(0,s.indexOf(":"))):0;if(!Wt(t)||!Wt(e)||!Wt(i)||!Wt(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${s}`);return t+=1e3*e,t+=60*1e3*i,t+=60*60*1e3*n,t},eh=function(s){let t=5381,e=s.length;for(;e;)t=t*33^s.charCodeAt(--e);return(t>>>0).toString()};function ih(s,t,e){return eh(s.toString())+eh(t.toString())+eh(e)}const g4=function(s,t,e){let i=s[t],n=s[i.prevCC];if(!n||!n.new&&i.new){s.ccOffset=s.presentationOffset=i.start,i.new=!1;return}for(;(o=n)!=null&&o.new;){var o;s.ccOffset+=i.start-n.start,i.new=!1,i=n,n=s[i.prevCC]}s.presentationOffset=e};function m4(s,t,e,i,n,o,l){const d=new u4,f=Ur(new Uint8Array(s)).trim().replace(f4,`
204
204
  `).split(`
205
- `),p=[],g=t?Sb(t.baseTime,t.timescale):0;let v="00:00.000",A=0,E=0,T,w=!0;d.oncue=function(C){const x=e[i];let O=e.ccOffset;const U=(A-g)/9e4;if(x!=null&&x.new&&(E!==void 0?O=e.ccOffset=x.start:f4(e,i,U)),U){if(!t){T=new Error("Missing initPTS for VTT MPEGTS");return}O=U-e.presentationOffset}const D=C.endTime-C.startTime,H=pr((C.startTime+O-E)*9e4,n*9e4)/9e4;C.startTime=Math.max(H,0),C.endTime=Math.max(H+D,0);const $=C.text.trim();C.text=decodeURIComponent(encodeURIComponent($)),C.id||(C.id=ih(C.startTime,C.endTime,$)),C.endTime>0&&p.push(C)},d.onparsingerror=function(C){T=C},d.onflush=function(){if(T){l(T);return}o(p)},f.forEach(C=>{if(w)if(th(C,"X-TIMESTAMP-MAP=")){w=!1,C.slice(16).split(",").forEach(x=>{th(x,"LOCAL:")?v=x.slice(6):th(x,"MPEGTS:")&&(A=parseInt(x.slice(7)))});try{E=u4(v)/1e3}catch(x){T=x}return}else C===""&&(w=!1);d.parse(C+`
206
- `)}),d.flush()}const rh="stpp.ttml.im1t",Nf=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Uf=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,g4={left:"start",center:"center",right:"end",start:"start",end:"end"};function Bf(s,t,e,i){const n=be(new Uint8Array(s),["mdat"]);if(n.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const o=n.map(d=>Nr(d)),l=wb(t.baseTime,1,t.timescale);try{o.forEach(d=>e(m4(d,l)))}catch(d){i(d)}}function m4(s,t){const e=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("tt")[0];if(!e)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(i).reduce((p,g)=>(p[g]=e.getAttribute(`ttp:${g}`)||i[g],p),{}),o=e.getAttribute("xml:space")!=="preserve",l=Gf(sh(e,"styling","style")),d=Gf(sh(e,"layout","region")),f=sh(e,"body","[begin]");return[].map.call(f,p=>{const g=Vf(p,o);if(!g||!p.hasAttribute("begin"))return null;const v=ah(p.getAttribute("begin"),n),A=ah(p.getAttribute("dur"),n);let E=ah(p.getAttribute("end"),n);if(v===null)throw Hf(p);if(E===null){if(A===null)throw Hf(p);E=v+A}const T=new Qc(v-t,E-t,g);T.id=ih(T.startTime,T.endTime,T.text);const w=d[p.getAttribute("region")],C=l[p.getAttribute("style")],x=v4(w,C,l),{textAlign:O}=x;if(O){const U=g4[O];U&&(T.lineAlign=U),T.align=O}return ui(T,x),T}).filter(p=>p!==null)}function sh(s,t,e){const i=s.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(e)):[]}function Gf(s){return s.reduce((t,e)=>{const i=e.getAttribute("xml:id");return i&&(t[i]=e),t},{})}function Vf(s,t){return[].slice.call(s.childNodes).reduce((e,i,n)=>{var o;return i.nodeName==="br"&&n?e+`
207
- `:(o=i.childNodes)!=null&&o.length?Vf(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function v4(s,t,e){const i="http://www.w3.org/ns/ttml#styling";let n=null;const o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],l=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return l&&e.hasOwnProperty(l)&&(n=e[l]),o.reduce((d,f)=>{const p=nh(t,i,f)||nh(s,i,f)||nh(n,i,f);return p&&(d[f]=p),d},{})}function nh(s,t,e){return s&&s.hasAttributeNS(t,e)?s.getAttributeNS(t,e):null}function Hf(s){return new Error(`Could not parse ttml timestamp ${s}`)}function ah(s,t){if(!s)return null;let e=Mf(s);return e===null&&(Nf.test(s)?e=y4(s,t):Uf.test(s)&&(e=b4(s,t))),e}function y4(s,t){const e=Nf.exec(s),i=(e[4]|0)+(e[5]|0)/t.subFrameRate;return(e[1]|0)*3600+(e[2]|0)*60+(e[3]|0)+i/t.frameRate}function b4(s,t){const e=Uf.exec(s),i=Number(e[1]);switch(e[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}class A4{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=Wf(),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 zo(this,"textTrack1"),i=new zo(this,"textTrack2"),n=new zo(this,"textTrack3"),o=new zo(this,"textTrack4");this.cea608Parser1=new xf(1,e,i),this.cea608Parser2=new xf(3,n,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,n,o){let l=!1;for(let d=o.length;d--;){const f=o[d],p=T4(f[0],f[1],e,i);if(p>=0&&(f[0]=Math.min(f[0],e),f[1]=Math.max(f[1],i),l=!0,p/(i-e)>.5))return}if(l||o.push([e,i]),this.config.renderTextTracksNatively){const d=this.captionsTracks[t];this.Cues.newCue(d,e,i,n)}else{const d=this.Cues.newCue(null,e,i,n);this.hls.trigger(R.CUES_PARSED,{type:"captions",cues:d,track:t})}}onInitPtsFound(t,{frag:e,id:i,initPTS:n,timescale:o}){const{unparsedVttFrags:l}=this;i==="main"&&(this.initPTS[e.cc]={baseTime:n,timescale:o}),l.length&&(this.unparsedVttFrags=[],l.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 n=e.textTracks[i];if(n[t])return n}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:n}=this,{label:o,languageCode:l}=e[t],d=this.getExistingTrack(t);if(d)i[t]=d,Cn(i[t]),F0(i[t],n);else{const f=this.createTextTrack("captions",o,l);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,n={_id:t,label:i,kind:"captions",default:e.media?!!e.media.default:!1,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=n,this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}createTextTrack(t,e,i){const n=this.media;if(n)return n.addTextTrack(t,e,i)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:t}=this;Object.keys(t).forEach(e=>{Cn(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Wf(),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++)Cn(e[i])}onSubtitleTracksUpdated(t,e){const i=e.subtitleTracks||[],n=i.some(o=>o.textCodec===rh);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(wf(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((l,d)=>{let f;if(o&&d<o.length){let p=null;for(let g=0;g<o.length;g++)if(E4(o[g],l)){p=o[g];break}p&&(f=p)}if(f)Cn(f);else{const p=this._captionsOrSubtitlesFromCharacteristics(l);f=this.createTextTrack(p,l.name,l.lang),f&&(f.mode="disabled")}f&&(f.groupId=l.groupId,this.textTracks.push(f))})}else if(this.tracks.length){const o=this.tracks.map(l=>({label:l.name,kind:l.type.toLowerCase(),default:l.default,subtitleTrack:l}));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 n=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!n)return;const o=`textTrack${n[1]}`,l=this.captionsProperties[o];l&&(l.label=i.name,i.lang&&(l.languageCode=i.lang),l.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:n,lastSn:o,lastPartIndex:l}=this;if(!(!this.enabled||!(i&&n))&&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===l+1||(i.reset(),n.reset()),this.lastSn=p,this.lastPartIndex=g}}onFragLoaded(t,e){const{frag:i,payload:n}=e;if(i.type===Jt.SUBTITLE)if(n.byteLength){const o=i.decryptdata,l="stats"in e;if(o==null||!o.encrypted||l){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===rh?this._parseIMSC1(i,n):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;Bf(e,this.initPTS[t.cc],n=>{this._appendCues(n,t.level),i.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},n=>{X.log(`Failed to parse IMSC1: ${n}`),i.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:n})})}_parseVTTs(t){var e;const{frag:i,payload:n}=t,{initPTS:o,unparsedVttFrags:l}=this,d=o.length-1;if(!o[i.cc]&&d===-1){l.push(t);return}const f=this.hls,p=(e=i.initSegment)!=null&&e.data?dn(i.initSegment.data,new Uint8Array(n)):n;p4(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?l.push(t):this._fallbackToIMSC1(i,n),X.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||Bf(e,this.initPTS[t.cc],()=>{i.textCodec=rh,this._parseIMSC1(t,e)},()=>{i.textCodec="wvtt"})}_appendCues(t,e){const i=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[e];if(!n||n.mode==="disabled")return;t.forEach(o=>N0(n,o))}else{const n=this.tracks[e];if(!n)return;const o=n.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:n}=this;if(!this.enabled||!(i&&n))return;const{frag:o,samples:l}=e;if(!(o.type===Jt.MAIN&&this.closedCaptionsForLevel(o)==="NONE"))for(let d=0;d<l.length;d++){const f=l[d].bytes;if(f){const p=this.extractCea608Data(f);i.addData(l[d].pts,p[0]),n.addData(l[d].pts,p[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:i,endOffsetSubtitles:n,type:o}){const{media:l}=this;if(!(!l||l.currentTime<i)){if(!o||o==="video"){const{captionsTracks:d}=this;Object.keys(d).forEach(f=>Sc(d[f],e,i))}if(this.config.renderTextTracksNatively&&e===0&&n!==void 0){const{textTracks:d}=this;Object.keys(d).forEach(f=>Sc(d[f],e,n))}}}extractCea608Data(t){const e=[[],[]],i=t[0]&31;let n=2;for(let o=0;o<i;o++){const l=t[n++],d=127&t[n++],f=127&t[n++];if(!(d===0&&f===0)&&4&l){const p=3&l;(p===0||p===1)&&(e[p].push(d),e[p].push(f))}}return e}}function E4(s,t){return!!s&&s.label===t.name&&!(s.textTrack1||s.textTrack2)}function T4(s,t,e,i){return Math.min(t,i)-Math.max(s,e)}function Wf(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class oh{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((n,o)=>this.isLevelAllowed(n)&&o<=t);return this.clientRect=null,oh.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 n=(l,d)=>d?l.width!==d.width||l.height!==d.height:!0;let o=t.length-1;for(let l=0;l<t.length;l+=1){const d=t[l];if((d.width>=e||d.height>=i)&&n(d,t[l+1])){o=l;break}}return o}}class k4{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 n=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=n,n&&typeof n.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,i){const n=performance.now();if(e){if(this.lastTime){const o=n-this.lastTime,l=i-this.lastDroppedFrames,d=e-this.lastDecodedFrames,f=1e3*l/o,p=this.hls;if(p.trigger(R.FPS_DROP,{currentDropped:l,currentDecoded:d,totalDroppedFrames:i}),f>0&&l>p.config.fpsDroppedMonitoringThreshold*d){let g=p.currentLevel;X.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=n,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 Xo="[eme]";class On{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=On.CDMCleanupPromise?[On.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=X.debug.bind(X,Xo),this.log=X.log.bind(X,Xo),this.warn=X.warn.bind(X,Xo),this.error=X.error.bind(X,Xo),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,n=e[t];if(n)return n.licenseUrl;if(t===ei.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=(l,d,f)=>!!l&&f.indexOf(l)===d,n=e.map(l=>l.audioCodec).filter(i),o=e.map(l=>l.videoCodec).filter(i);return n.length+o.length===0&&o.push("avc1.42e01e"),new Promise((l,d)=>{const f=p=>{const g=p.shift();this.getMediaKeysPromise(g,n,o).then(v=>l({keySystem:g,mediaKeys:v})).catch(v=>{p.length?f(p):v instanceof gr?d(v):d(new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.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 n=`Configured requestMediaKeySystemAccess is not a function ${i}`;return d0===null&&self.location.protocol==="http:"&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return i(t,e)}getMediaKeysPromise(t,e,i){const n=Fv(t,e,i,this.config.drmSystemOptions),o=this.keySystemAccessPromises[t];let l=o==null?void 0:o.keySystemAccess;if(!l){this.log(`Requesting encrypted media "${t}" key-system access with config: ${JSON.stringify(n)}`),l=this.requestMediaKeySystemAccess(t,n);const d=this.keySystemAccessPromises[t]={keySystemAccess:l};return l.catch(f=>{this.log(`Failed to obtain access to key-system "${t}": ${f}`)}),l.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 l.then(()=>o.mediaKeys)}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:i}){this.log(`Creating key-system session "${e}" keyId: ${Ur.hexDump(t.keyId||[])}`);const n=i.createSession(),o={decryptdata:t,keySystem:e,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(o),o}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const i=this.createMediaKeySessionContext(t),n=this.getKeyIdString(e),o="cenc";this.keyIdToKeySessionPromise[n]=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 Ur.hexDump(t.keyId)}updateKeySession(t,e){var i;const n=t.mediaKeysSession;return this.log(`Updating key-session "${n.sessionId}" for keyID ${Ur.hexDump(((i=t.decryptdata)==null?void 0:i.keyId)||[])}
208
- } (data length: ${e&&e.byteLength})`),n.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 n=yc(this.config),o=t.map(l0).filter(l=>!!l&&n.indexOf(l)!==-1);return this.getKeySystemSelectionPromise(o).then(({keySystem:l})=>{const d=h0(l);d?e(d):i(new Error(`Unable to find format for key-system "${l}"`))}).catch(i)})}loadKey(t){const e=t.keyInfo.decryptdata,i=this.getKeyIdString(e),n=`(keyId: ${i} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${n}`);let o=this.keyIdToKeySessionPromise[i];return o||(o=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(e).then(({keySystem:l,mediaKeys:d})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${n}`),this.attemptSetMediaKeys(l,d).then(()=>{this.throwIfDestroyed();const f=this.createMediaKeySessionContext({keySystem:l,mediaKeys:d,decryptdata:e}),p="cenc";return this.generateRequestWithPreferredKeySession(f,p,e.pssh,"playlist-key")}))),o.catch(l=>this.handleError(l))),o}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof gr?this.hls.trigger(R.ERROR,t.data):this.hls.trigger(R.ERROR,{type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const n=l0(t.keyFormat),o=n?[n]:yc(this.config);return this.attemptKeySystemAccess(o)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=yc(this.config)),t.length===0)throw new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.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 n,o;if(e==="sinf"&&this.config.drmSystems[ei.FAIRPLAY]){const g=Li(new Uint8Array(i));try{const v=vc(JSON.parse(g).sinf),A=b0(new Uint8Array(v));if(!A)return;n=A.subarray(8,24),o=ei.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const g=oy(i);if(g===null)return;g.version===0&&g.systemId===c0.WIDEVINE&&g.data&&(n=g.data.subarray(8,24)),o=$v(g.systemId)}if(!o||!n)return;const l=Ur.hexDump(n),{keyIdToKeySessionPromise:d,mediaKeySessions:f}=this;let p=d[l];for(let g=0;g<f.length;g++){const v=f[g],A=v.decryptdata;if(A.pssh||!A.keyId)continue;const E=Ur.hexDump(A.keyId);if(l===E||A.uri.replace(/-/g,"").indexOf(l)!==-1){p=d[E],delete d[E],A.pssh=new Uint8Array(i),A.keyId=n,p=d[l]=p.then(()=>this.generateRequestWithPreferredKeySession(v,e,i,"encrypted-event-key-match"));break}}p||(p=d[l]=this.getKeySystemSelectionPromise([o]).then(({keySystem:g,mediaKeys:v})=>{var A;this.throwIfDestroyed();const E=new La("ISO-23001-7",l,(A=h0(g))!=null?A:"");return E.pssh=new Uint8Array(i),E.keyId=n,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 n=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(n),n.then(()=>{this.log(`Media-keys set for "${t}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(o=>i.indexOf(o)===-1)})}generateRequestWithPreferredKeySession(t,e,i,n){var o,l;const d=(o=this.config.drmSystems)==null||(l=o[t.keySystem])==null?void 0:l.generateRequest;if(d)try{const A=d.call(this.hls,e,i,t);if(!A)throw new Error("Invalid response from configured generateRequest filter");e=A.initDataType,i=t.decryptdata.pssh=A.initData?new Uint8Array(A.initData):null}catch(A){var f;if(this.warn(A.message),(f=this.hls)!=null&&f.config.debug)throw A}if(i===null)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(t);const p=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${n}": ${p} (init data type: ${e} length: ${i?i.byteLength:null})`);const g=new zc;t.mediaKeysSession.onmessage=A=>{const E=t.mediaKeysSession;if(!E){g.emit("error",new Error("invalid state"));return}const{messageType:T,message:w}=A;this.log(`"${T}" message event for session "${E.sessionId}" message size: ${w.byteLength}`),T==="license-request"||T==="license-renewal"?this.renewLicense(t,w).catch(C=>{this.handleError(C),g.emit("error",C)}):T==="license-release"?t.keySystem===ei.FAIRPLAY&&(this.updateKeySession(t,o0("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${T}"`)},t.mediaKeysSession.onkeystatuseschange=A=>{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((A,E)=>{g.on("error",E),g.on("keyStatus",T=>{T.startsWith("usable")?A():T==="output-restricted"?E(new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):T==="internal-error"?E(new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.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 A;this.log(`Request generated for key-session "${(A=t.mediaKeysSession)==null?void 0:A.sessionId}" keyId: ${p}`)}).catch(A=>{throw new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_NO_SESSION,error:A,fatal:!1},`Error generating key-session request: ${A}`)}).then(()=>v).catch(A=>{throw g.removeAllListeners(),this.removeSession(t),A}).then(()=>(g.removeAllListeners(),t))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach((e,i)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${Ur.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Ur.hexDump(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e})}fetchServerCertificate(t){const e=this.config,i=e.loader,n=new i(e),o=this.getServerCertificateUrl(t);return o?(this.log(`Fetching serverCertificate for "${t}"`),new Promise((l,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:(A,E,T,w)=>{l(A.data)},onError:(A,E,T,w)=>{d(new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:zi({url:f.url,data:void 0},A)},`"${t}" certificate request failed (${o}). Status: ${A.code} (${A.text})`))},onTimeout:(A,E,T)=>{d(new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:{url:f.url,data:void 0}},`"${t}" certificate request timed out (${o})`))},onAbort:(A,E,T)=>{d(new Error("aborted"))}};n.load(f,g,v)})):Promise.resolve()}setMediaKeysServerCertificate(t,e,i){return new Promise((n,o)=>{t.setServerCertificate(i).then(l=>{this.log(`setServerCertificate ${l?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${e}"`),n(t)}).catch(l=>{o(new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:l,fatal:!0},l.message))})})}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then(i=>this.updateKeySession(t,new Uint8Array(i)).catch(n=>{throw new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:n,fatal:!0},n.message)}))}setupLicenseXHR(t,e,i,n){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,n)}).catch(l=>{if(!i.decryptdata)throw l;return t.open("POST",e,!0),o.call(this.hls,t,e,i,n)}).then(l=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:l||n})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:n}))}requestLicense(t,e){const i=this.config.keyLoadPolicy.default;return new Promise((n,o)=>{const l=this.getLicenseServerUrl(t.keySystem);this.log(`Sending license request to URL: ${l}`);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,l,t)}catch(g){this.error(g)}n(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 gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:d,response:{url:l,data:void 0,code:d.status,text:d.statusText}},`License Request XHR failed (${l}). 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(n,o)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=d,this.setupLicenseXHR(d,l,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={},La.clearKeyUriToKeyIdMap();const i=e.length;On.CDMCleanupPromise=Promise.all(e.map(n=>this.removeSession(n)).concat(t==null?void 0:t.setMediaKeys(null).catch(n=>{this.log(`Could not clear media keys: ${n}. media.src: ${t==null?void 0:t.src}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)}).catch(n=>{this.log(`Could not close sessions and clear media keys: ${n}. 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((n,o)=>(n.indexOf(o.keyFormat)===-1&&n.push(o.keyFormat),n),[]);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 n=this.mediaKeySessions.indexOf(t);return n>-1&&this.mediaKeySessions.splice(n,1),e.remove().catch(o=>{this.log(`Could not remove session: ${o}`)}).then(()=>e.close()).catch(o=>{this.log(`Could not close session: ${o}`)})}}}On.CDMCleanupPromise=void 0;class gr 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 w4=1;var Zi={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const S4="h";class Ls{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=n=>{try{this.apply(n,{ot:Zi.MANIFEST,su:!this.initialized})}catch(o){X.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=n=>{try{const o=n.frag,l=this.hls.levels[o.level],d=this.getObjectType(o),f={d:o.duration*1e3,ot:d};(d===Zi.VIDEO||d===Zi.AUDIO||d==Zi.MUXED)&&(f.br=l.bitrate/1e3,f.tb=this.getTopBandwidth(d)/1e3,f.bl=this.getBufferLength(d)),this.apply(n,f)}catch(o){X.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||Ls.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,n;this.audioBuffer=(i=e.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(n=e.tracks.video)==null?void 0:n.buffer}createData(){var t;return{v:w4,sf:S4,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){ui(e,this.createData());const i=e.ot===Zi.INIT||e.ot===Zi.VIDEO||e.ot===Zi.MUXED;if(this.starved&&i&&(e.bs=!0,e.su=!0,this.starved=!1),e.su==null&&(e.su=this.buffering),this.useHeaders){const n=Ls.toHeaders(e);if(!Object.keys(n).length)return;t.headers||(t.headers={}),ui(t.headers,n)}else{const n=Ls.toQuery(e);if(!n)return;t.url=Ls.appendQueryToUri(t.url,n)}}getObjectType(t){const{type:e}=t;if(e==="subtitle")return Zi.TIMED_TEXT;if(t.sn==="initSegment")return Zi.INIT;if(e==="audio")return Zi.AUDIO;if(e==="main")return this.hls.audioTracks.length?Zi.VIDEO:Zi.MUXED}getTopBandwidth(t){let e=0,i;const n=this.hls;if(t===Zi.AUDIO)i=n.audioTracks;else{const o=n.maxAutoLevel,l=o>-1?o+1:n.levels.length;i=n.levels.slice(0,l)}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===Zi.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!e?NaN:Ge.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(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,o,l){e(n),this.loader.load(n,o,l)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,i=t||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,o,l){e(n),this.loader.load(n,o,l)}}}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,n=f=>Math.round(f),o=f=>n(f/100)*100,l={br:n,d:n,bl:o,dl:o,mtp:o,nor:f=>encodeURIComponent(f),rtp:o,tb:n},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=l[f];g&&(p=g(p));const v=typeof p;let A;f==="ot"||f==="sf"||f==="st"?A=`${f}=${p}`:v==="boolean"?A=f:v==="number"?A=`${f}=${p}`:A=`${f}=${JSON.stringify(p)}`,e.push(A)}return e.join(",")}static toHeaders(t){const e=Object.keys(t),i={},n=["Object","Request","Session","Status"],o=[{},{},{},{}],l={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=l[d]!=null?l[d]:1;o[f][d]=t[d]}for(let d=0;d<o.length;d++){const f=Ls.serialize(o[d]);f&&(i[`CMCD-${n[d]}`]=f)}return i}static toQuery(t){return`CMCD=${encodeURIComponent(Ls.serialize(t))}`}static appendQueryToUri(t,e){if(!e)return t;const i=t.includes("?")?"&":"?";return`${t}${i}${e}`}}const R4=3e5;class _4{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=X.log.bind(X,"[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)===Di.SendAlternateToPenaltyBox&&i.flags===fr.MoveAllAlternatesMatchingHost){let n=this.pathwayPriority;const o=this.pathwayId;this.penalizedPathways[o]||(this.penalizedPathways[o]=performance.now()),!n&&this.levels&&(n=this.levels.reduce((l,d)=>(l.indexOf(d.pathwayId)===-1&&l.push(d.pathwayId),l),[])),n&&n.length>1&&(this.updatePathwayPriority(n),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,n=performance.now();Object.keys(i).forEach(o=>{n-i[o]>R4&&delete i[o]});for(let o=0;o<t.length;o++){const l=t[o];if(i[l])continue;if(l===this.pathwayId)return;const d=this.hls.nextLoadLevel,f=this.hls.levels[d];if(e=this.getLevelsForPathway(l),e.length>0){this.log(`Setting Pathway to "${l}"`),this.pathwayId=l,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={},n={};t.forEach(o=>{const{ID:l,"BASE-ID":d,"URI-REPLACEMENT":f}=o;if(e.some(g=>g.pathwayId===l))return;const p=this.getLevelsForPathway(d).map(g=>{const v=ui({},g);v.details=void 0,v.url=Kf(g.uri,g.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f);const A=new ti(g.attrs);A["PATHWAY-ID"]=l;const E=A.AUDIO&&`${A.AUDIO}_clone_${l}`,T=A.SUBTITLES&&`${A.SUBTITLES}_clone_${l}`;E&&(i[A.AUDIO]=E,A.AUDIO=E),T&&(n[A.SUBTITLES]=T,A.SUBTITLES=T),v.attrs=A;const w=new Ia(v);return Uo(w,"audio",E),Uo(w,"text",T),w});e.push(...p),jf(this.audioTracks,i,f,l),jf(this.subtitleTracks,n,f,l)})}loadSteeringManifest(t){const e=this.hls.config,i=e.loader;this.loader&&this.loader.destroy(),this.loader=new i(e);let n;try{n=new self.URL(t)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${t}`);return}if(n.protocol!=="data:"){const g=(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate)|0;n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+g)}const o={responseType:"json",url:n.href},l=e.steeringManifestLoadPolicy.default,d=l.errorRetry||l.timeoutRetry||{},f={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:d.maxNumRetry||0,retryDelay:d.retryDelayMs||0,maxRetryDelay:d.maxRetryDelayMs||0},p={onSuccess:(g,v,A,E)=>{this.log(`Loaded steering manifest: "${n}"`);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":C,"PATHWAY-PRIORITY":x}=T;if(w)try{this.uri=new self.URL(w,n).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${w}`);return}this.scheduleRefresh(this.uri||A.url),C&&this.clonePathways(C),x&&this.updatePathwayPriority(x)},onError:(g,v,A,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 C=w.getResponseHeader("Retry-After");C&&(T=parseFloat(C)*1e3)}this.log(`Steering manifest ${v.url} rate limited`);return}this.scheduleRefresh(this.uri||v.url,T)},onTimeout:(g,v,A)=>{this.log(`Timeout loading steering manifest (${v.url})`),this.scheduleRefresh(this.uri||v.url)}};this.log(`Requesting steering manifest: ${n}`),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 jf(s,t,e,i){s&&Object.keys(t).forEach(n=>{const o=s.filter(l=>l.groupId===n).map(l=>{const d=ui({},l);return d.details=void 0,d.attrs=new ti(d.attrs),d.url=d.attrs.URI=Kf(l.url,l.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),d.groupId=d.attrs["GROUP-ID"]=t[n],d.attrs["PATHWAY-ID"]=i,d});s.push(...o)})}function Kf(s,t,e,i){const{HOST:n,PARAMS:o,[e]:l}=i;let d;t&&(d=l==null?void 0:l[t],d&&(s=d));const f=new self.URL(s);return n&&!d&&(f.host=n),o&&Object.keys(o).sort().forEach(p=>{p&&f.searchParams.set(p,o[p])}),f.href}const L4=/^age:\s*[\d.]+\s*$/im;class zf{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 Io,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,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;const o=this.xhrSetup;o?Promise.resolve().then(()=>{if(!this.stats.aborted)return o(i,e.url)}).catch(l=>(i.open("GET",e.url,!0),o(i,e.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,e,t)}).catch(l=>{this.callbacks.onError({code:i.status,text:l.message},e,i,n)}):this.openAndSendXhr(i,e,t)}openAndSendXhr(t,e,i){t.readyState||t.open("GET",e.url,!0);const n=this.context.headers,{maxTimeToFirstByteMs:o,maxLoadTimeMs:l}=i.loadPolicy;if(n)for(const d in n)t.setRequestHeader(d,n[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&&Wt(o)?o:l,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 n=e.readyState,o=this.config;if(!i.aborted&&n>=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)))),n===4)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const l=e.status,d=e.responseType!=="text";if(l>=200&&l<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:l};this.callbacks.onSuccess(v,i,t,e)}else{const f=o.loadPolicy.errorRetry,p=i.retry;No(f,p,!1,l)?this.retry(f):(X.error(`${l} while loading ${t.url}`),this.callbacks.onError({code:l,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(No(e,i,!0))this.retry(e);else{X.warn(`timeout while loading ${this.context.url}`);const n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:i}=this;this.retryDelay=Dc(t,i.retry),i.retry++,X.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&&L4.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 C4(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const I4=/(\d+)-(\d+)\/(\d+)/;class Yf{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||O4,this.controller=new self.AbortController,this.stats=new Io}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 n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();const o=D4(t,this.controller.signal),l=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&&Wt(p)?p:g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(n,t,this.response)},e.timeout),self.fetch(this.request).then(v=>{this.response=this.loader=v;const A=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(n,t,this.response)},g-(A-n.loading.start)),!v.ok){const{status:E,statusText:T}=v;throw new M4(T||"fetch, bad network response",E,v)}return n.loading.first=A,n.total=P4(v.headers)||n.total,l&&Wt(e.highWaterMark)?this.loadProgressively(v,n,t,e.highWaterMark,l):d?v.arrayBuffer():t.responseType==="json"?v.json():v.text()}).then(v=>{const{response:A}=this;self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const E=v[f];E&&(n.loaded=n.total=E);const T={url:A.url,data:v,code:A.status};l&&!Wt(e.highWaterMark)&&l(n,t,v,A),i.onSuccess(T,n,t,A)}).catch(v=>{if(self.clearTimeout(this.requestTimeout),n.aborted)return;const A=v&&v.code||0,E=v?v.message:null;i.onError({code:A,text:E},t,v?v.details:null,n)})}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,n=0,o){const l=new Tf,d=t.body.getReader(),f=()=>d.read().then(p=>{if(p.done)return l.dataLength&&o(e,i,l.flush(),t),Promise.resolve(new ArrayBuffer(0));const g=p.value,v=g.length;return e.loaded+=v,v<n||l.dataLength?(l.push(g),l.dataLength>=n&&o(e,i,l.flush(),t)):o(e,i,g,t),f()}).catch(()=>Promise.reject());return f()}}function D4(s,t){const e={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(ui({},s.headers))};return s.rangeEnd&&e.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),e}function x4(s){const t=I4.exec(s);if(t)return parseInt(t[2])-parseInt(t[1])+1}function P4(s){const t=s.get("Content-Range");if(t){const i=x4(t);if(Wt(i))return i}const e=s.get("Content-Length");if(e)return parseInt(e)}function O4(s,t){return new self.Request(s.url,t)}class M4 extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const $4=/\s/,F4={newCue(s,t,e,i){const n=[];let o,l,d,f,p;const g=self.VTTCue||self.TextTrackCue;for(let A=0;A<i.rows.length;A++)if(o=i.rows[A],d=!0,f=0,p="",!o.isEmpty()){var v;for(let w=0;w<o.chars.length;w++)$4.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=Ff(p.trim()),T=ih(t,e,E);s!=null&&(v=s.cues)!=null&&v.getCueById(T)||(l=new g(t,e,E),l.id=T,l.line=A+1,l.align="left",l.position=10+Math.min(80,Math.floor(f*8/32)*10),n.push(l))}return s&&n.length&&(n.sort((A,E)=>A.line==="auto"||E.line==="auto"?0:A.line>8&&E.line>8?E.line-A.line:A.line-E.line),n.forEach(A=>N0(s,A))),n}},N4={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},U4=zi(zi({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:zf,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Hb,bufferController:Qb,capLevelController:oh,errorController:My,fpsController:k4,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:d0,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:N4},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},B4()),{},{subtitleStreamController:Yb,subtitleTrackController:Zb,timelineController:A4,audioStreamController:jb,audioTrackController:Kb,emeController:On,cmcdController:Ls,contentSteeringController:_4});function B4(){return{cueHandler:F4,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 G4(s,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(t.liveMaxLatencyDurationCount!==void 0&&(t.liveSyncDurationCount===void 0||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(t.liveMaxLatencyDuration!==void 0&&(t.liveSyncDuration===void 0||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const e=lh(s),i=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(o=>{const l=`${o==="level"?"playlist":o}LoadPolicy`,d=t[l]===void 0,f=[];n.forEach(p=>{const g=`${o}Loading${p}`,v=t[g];if(v!==void 0&&d){f.push(g);const A=e[l].default;switch(t[l]={default:A},p){case"TimeOut":A.maxLoadTimeMs=v,A.maxTimeToFirstByteMs=v;break;case"MaxRetry":A.errorRetry.maxNumRetry=v,A.timeoutRetry.maxNumRetry=v;break;case"RetryDelay":A.errorRetry.retryDelayMs=v,A.timeoutRetry.retryDelayMs=v;break;case"MaxRetryTimeout":A.errorRetry.maxRetryDelayMs=v,A.timeoutRetry.maxRetryDelayMs=v;break}}}),f.length&&X.warn(`hls.js config: "${f.join('", "')}" setting(s) are deprecated, use "${l}": ${JSON.stringify(t[l])}`)}),zi(zi({},e),t)}function lh(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(lh):Object.keys(s).reduce((t,e)=>(t[e]=lh(s[e]),t),{}):s}function V4(s){const t=s.loader;t!==Yf&&t!==zf?(X.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):C4()&&(s.loader=Yf,s.progressive=!0,s.enableSoftwareAES=!0,X.log("[config]: Progressive streaming enabled, using FetchLoader"))}class ls{static get version(){return"1.4.12"}static isSupported(){return tb()}static get Events(){return R}static get ErrorTypes(){return Qt}static get ErrorDetails(){return pt}static get DefaultConfig(){return ls.defaultConfig?ls.defaultConfig:U4}static set DefaultConfig(t){ls.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new zc,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,Rv(t.debug||!1,"Hls instance");const e=this.config=G4(ls.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&V4(e);const{abrController:i,bufferController:n,capLevelController:o,errorController:l,fpsController:d}=e,f=new l(this),p=this.abrController=new i(this),g=this.bufferController=new n(this),v=this.capLevelController=new o(this),A=new d(this),E=new my(this),T=new Ey(this),w=e.contentSteeringController,C=w?new w(this):null,x=this.levelController=new Fy(this,C),O=new Ny(this),U=new By(this.config),D=this.streamController=new Gb(this,O,U);v.setStreamController(D),A.setStreamController(D);const H=[E,x,D];C&&H.splice(1,0,C),this.networkControllers=H;const $=[p,g,v,A,T,O];this.audioTrackController=this.createController(e.audioTrackController,H);const z=e.audioStreamController;z&&H.push(new z(this,O,U)),this.subtitleTrackController=this.createController(e.subtitleTrackController,H);const tt=e.subtitleStreamController;tt&&H.push(new tt(this,O,U)),this.createController(e.timelineController,$),U.emeController=this.emeController=this.createController(e.emeController,$),this.cmcdController=this.createController(e.cmcdController,$),this.latencyController=this.createController(Ty,$),this.coreComponents=$,H.push(f);const at=f.onErrorOut;typeof at=="function"&&this.on(R.ERROR,at,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,n){this._emitter.off(t,e,i,n)}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){X.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:pt.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){X.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){X.log("attachMedia"),this._media=t,this.trigger(R.MEDIA_ATTACHING,{media:t})}detachMedia(){X.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,i=this.url,n=this.url=pc.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});X.log(`loadSource:${n}`),e&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(R.MANIFEST_LOADING,{url:t})}startLoad(t=-1){X.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){X.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){X.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){X.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){X.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){X.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){X.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){X.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){X.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&&(X.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){Lc.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 n=0;n<i;n++)if(t[n].maxBitrate>=e)return n;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:i}=this;let n;if(e===-1&&t&&t.length?n=t.length-1:n=e,i)for(let o=n;o--;){const l=t[o].attrs["HDCP-LEVEL"];if(l&&l<=i)return o}return n}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}}ls.defaultConfig=void 0;function H4(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function W4(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function ch(s){const{id:t,key:e,src:i,playlist:n,duration:o}=s;return new Promise(l=>{let d=null;const f=document.createElement("video");if(f.playsInline=!0,f.muted=!0,f.loop=!1,n&&!H4()&&ls.isSupported()){let p=!1;d=new ls({autoStartLoad:!0,xhrSetup:g=>{const{open:v}=g,A=n.split("?")[1];g.open=function(E,T,w){T.toString().includes("?")||(T+="?"+A),v.apply(this,[E,T,w])}}}),d.loadSource(n),d.attachMedia(f),d.startLoadOnce=(g=-1,v)=>{if(d&&!p){const A=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=A!==-1?A:d.firstLevel}},d.on(ls.Events.LEVEL_LOADED,async()=>{p||d==null||d.stopLoad(),l({id:t,key:e,hls:d,config:s,node:f})})}else{f.src=i;let p=!1;if(f.startLoadOnce=()=>{p||(f.preload="auto",f.load(),p=!0)},o)f.preload="none",l({id:t,key:e,hls:d,config:s,node:f});else{f.preload="metadata";const g=async()=>{l({id:t,key:e,hls:d,config:s,node:f}),f.removeEventListener("loadedmetadata",g)};f.addEventListener("loadedmetadata",g)}}})}async function Xf(s){return s.duration===1/0?new Promise(t=>{s.currentTime=Number.MAX_SAFE_INTEGER,s.ontimeupdate=()=>{s.ontimeupdate=null,t(s.duration),s.currentTime=0}}):s.duration}const j4=ks(async function(s){return new FontFace(s.name,`url(${s.woff2??s.url})`,{style:s.style,weight:s.weight}).load()},{cacheKey:([s])=>JSON.stringify(s)});let K4=class{constructor(s){this._hasPlayed=!1,this._memoKey=null,this._lastDeps=null,this._duration=0,this._scenes=null,this._videos={},this._videoMeta={},this._videoState={},this._resolveVideo=ks(async t=>{const{id:e,key:i}=t,n=await ch(t);n.node.volume=this.host.volume,n.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},l=Object.keys(o).reduce((d,f)=>{const p=f,g=o[p]({id:e,key:i,node:n.node});return d[p]=g,n.node.addEventListener(f,g),d},{});return{...n,listeners:l}},{cacheKey:([{id:t,key:e,src:i,playlist:n}])=>JSON.stringify({id:t,key:e,src:i==null?void 0:i.split("?")[0],playlist:n==null?void 0:n.split("?")[0]})}),this._resolveVideoMeta=ks(async(t,e)=>{const{id:i,captions:n,duration:o,startOffset:l,endOffset:d}=t,f=o??await Xf(e),p=(l??0)*f,g=(1-(d??0))*f;return{id:i,captions:n,start:p,duration:g-p}},{cacheKey:([{id:t,key:e,captions:i,duration:n,startOffset:o,endOffset:l}])=>JSON.stringify({id:t,key:e,captions:i,duration:n,startOffset:o,endOffset:l})}),this._handleLoadedData=({id:t,key:e,node:i})=>()=>{var n,o;const l=this.videoState[e];if(!(l!=null&&l.initialised)){this.videoState={...this.videoState,[e]:{...l,initialised:!0,waiting:!1,buffered:(l==null?void 0:l.buffered)??[]}};const d=(o=(n=this.scenes)==null?void 0:n.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],n=this._getBufferSegments({key:t,node:e,duration:this.host.duration});this.videoState={...this.videoState,[t]:{...i,buffered:n}}},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 n=this.videoState[e];n!=null&&n.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 n=new ss(`Video error - answer ${t} failed to load`);this.host.dispatchEvent(new ErrorEvent("error",{bubbles:!0,composed:!0,error:n,message:n.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(n=>{var o,l;if((o=this.videos)!=null&&o[t]){const d=(l=i.listeners)==null?void 0:l[n];d&&i.node.removeEventListener(n,d)}}),delete this.videos[t])},this.host=s,this.host.addController(this)}set hasPlayed(s){s!==this._hasPlayed&&(this._hasPlayed=s,this.host.requestUpdate())}get hasPlayed(){return this._hasPlayed}set duration(s){!isNaN(s)&&s!==this._duration&&(this._duration=s,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(s){s!==this._scenes&&(this._scenes=s,this.host.requestUpdate())}get scenes(){return this._scenes}set videos(s){s!==this._videos&&(this._videos=s,this.host.requestUpdate())}get videos(){return this._videos}set videoMeta(s){s!==this._videoMeta&&(this._videoMeta=s,this.host.requestUpdate())}get videoMeta(){return this._videoMeta}set videoState(s){s!==this._videoState&&(this._videoState=s,this.host.requestUpdate())}get videoState(){return this._videoState}_getBufferSegments({key:s,node:t,duration:e}){var i;const n=t==null?void 0:t.buffered,o=[],{start:l,video:d,videoMeta:f}=((i=this.scenes)==null?void 0:i.scenes.find(({video:p})=>s===(p==null?void 0:p.key)))??{};if(t&&n&&d&&f&&typeof l<"u")for(let p=0;p<n.length;p++){const g=n.start(p),v=n.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)+l)/e*100),end:Math.min((Math.min(v-f.start,f.duration)+l)/e*100,100)})}return o}_setupTask(){new ro(this.host,async([s,t,e,i,n,o])=>{try{let l=null;if(this.host._errors=[],e||s){if(this.host._processing=!0,e){let f=null;if(i)try{f=await(await fetch(i,{method:"GET"})).text()}catch{const g=new ss("Track failed to fetch");this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:g,message:g.message}))}const p={questions:{items:[{answer:{id:"source",media:{[e.includes(".m3u8")?"playlist":"video"]:e},captions:{current:f}}}]}};try{this.scenes=await kn({data:p,template:t,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(g){l=new ss(`Source template error - ${g.message}`),this.scenes=await kn({data:p,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}}else try{this.scenes=await kn({data:s,template:t,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(f){l=new ss(`Data template error - ${f.message}`),this.scenes=await kn({data:s,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}if(this.scenes.scenes.length===0)throw new ss("Template error - no scenes created",!0);Object.keys(this.videos).forEach(f=>{this.scenes.scenes.find(({video:p})=>f===(p==null?void 0:p.key))||this._videos[f].node.pause()});const d=this.scenes.scenes.reduce((f,{video:p})=>(p&&(f[p.key]=p),f),{});Object.keys(this.videos).join("|")!==Object.keys(d).join("|")&&this.host.reset(0,!1),this.videos=d,this.videoState={...this.videoState,...this.scenes.scenes.reduce((f,{video:p,start:g,duration:v})=>{var A;const E=(p==null?void 0:p.key)??`${g}-${v}`,T=this._getBufferSegments({key:E,node:p==null?void 0:p.node,duration:this.scenes.duration});return f[E]={initialised:!p,waiting:!!p,...this.videoState[E],buffered:p?T:(A=this.videoState[E])==null?void 0:A.buffered},f},{})},this.videoMeta=this.scenes.scenes.reduce((f,{video:p,videoMeta:g})=>(p&&g&&(f[p.key]=g),f),{}),(await Promise.all(this.scenes.fonts.map(f=>j4(f)))).forEach(f=>{document.fonts.add(f)}),this.duration=this.scenes.duration,this.host.paused&&this.host.reset(this.host.currentTime,!this.host.paused)}l&&this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:l,message:l.message}))}catch(l){this.scenes=null,this.duration=0,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:l,message:l.message}))}finally{this.host._processing=!1}},()=>{const s=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===s)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=s,this._lastDeps=t,t})}_setVideoCurrentTime({time:s,scene:t}){const{start:e,video:i,videoMeta:n}=t;if(i&&i.node&&n&&typeof e<"u"){const o=s-e;i.node.currentTime=Math.max(n.start,Math.min(n.start+n.duration,o+n.start))}}setVideosCurrentTime(s){var t;(t=this.scenes)==null||t.scenes.forEach(e=>{this._setVideoCurrentTime({time:s,scene:e})})}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(s=>{this._cleanupVideo(s)}),this.videos={}}};function z4(s){s.requestFullscreen?s.requestFullscreen():s.mozRequestFullScreen?s.mozRequestFullScreen():s.webkitRequestFullscreen?s.webkitRequestFullscreen():s.msRequestFullscreen&&s.msRequestFullscreen()}function Y4(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const hh=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen","preview"],X4={id:"captions",event:"captions:click",label:"Closed Captions"},Z4={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},Zf={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}]},q4={id:"playbackRate",label:"Playback playbackRate",subItems:Zf};class Q4 extends Ud{constructor(t){if(super(t),this.element=null,this.observer=void 0,t.type!==En.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)),Es}}const dh=Tn(Q4);var qf=Number.isNaN||function(s){return typeof s=="number"&&s!==s};function J4(s,t){return!!(s===t||qf(s)&&qf(t))}function tA(s,t){if(s.length!==t.length)return!1;for(var e=0;e<s.length;e++)if(!J4(s[e],t[e]))return!1;return!0}function eA(s,t){t===void 0&&(t=tA);var e=null;function i(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];if(e&&e.lastThis===this&&t(n,e.lastArgs))return e.lastResult;var l=s.apply(this,n);return e={lastResult:l,lastArgs:n,lastThis:this},l}return i.clear=function(){e=null},i}const iA=eA(()=>{const s=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=lu.map(n=>({load:!1,font:new FontFace(n.family,`url(${n.url})`,{style:n.style})}));return[{load:!0,font:s},{load:!0,font:t},{load:!0,font:e},...i]}),Gr={"red-120":"#feeded","red-130":"#fcd5d0","red-400":"#e84a4a","red-500":"#c51c3a","red-700":"#a21c39","red-800":"#850231","red-900":"#580A2D","teal-80":"#f3fafa","teal-100":"#d6f1f1","teal-200":"#ace3e3","teal-300":"#7acace","teal-400":"#4faab2","teal-500":"#358f97","teal-600":"#287179","teal-700":"#22555c","teal-800":"#21484e","teal-900":"#1f3d42","teal-950":"#0d2126","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"},rA={colors:Gr,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 ${Gr["dark-100"]}`,medium:`0 .125rem .625rem ${Gr["dark-100"]}`,large:`0 .25rem 1rem ${Gr["dark-50"]}`,xl:`.25rem .25rem 1rem ${Gr["dark-250"]}`,xxl:`0 .25rem 2rem ${Gr["dark-100"]}`,xxxl:`.25rem .25rem 3rem ${Gr["dark-250"]}`,toolbar:`0 -.625rem .625rem ${Gr["dark-50"]}`,text:`0 0 .25rem ${Gr["dark-250"]}`},timings:{fast:".1s",normal:".2s",slow:".3s"},easings:{linear:"linear"},focusOutline:{width:".2rem",color:Gr["dark-400"]},iconSizes:{small:"0.75rem",medium:"1rem",large:"1.5rem"}},Qf=Vm.flatten(rA,{delimiter:"-"}),sA=Object.keys(Qf).map(s=>ta(`:host { --${s}: ${Qf[s]}; }`)),nA=s=>{class t extends s{firstUpdated(){iA().forEach(({load:i,font:n})=>{document.fonts.add(n),i&&n.load()})}}return t.styles=[(s==null?void 0:s.styles)??[],sA,hi`
205
+ `),p=[],g=t?Lb(t.baseTime,t.timescale):0;let v="00:00.000",A=0,E=0,T,w=!0;d.oncue=function(C){const D=e[i];let M=e.ccOffset;const U=(A-g)/9e4;if(D!=null&&D.new&&(E!==void 0?M=e.ccOffset=D.start:g4(e,i,U)),U){if(!t){T=new Error("Missing initPTS for VTT MPEGTS");return}M=U-e.presentationOffset}const x=C.endTime-C.startTime,G=pr((C.startTime+M-E)*9e4,n*9e4)/9e4;C.startTime=Math.max(G,0),C.endTime=Math.max(G+x,0);const $=C.text.trim();C.text=decodeURIComponent(encodeURIComponent($)),C.id||(C.id=ih(C.startTime,C.endTime,$)),C.endTime>0&&p.push(C)},d.onparsingerror=function(C){T=C},d.onflush=function(){if(T){l(T);return}o(p)},f.forEach(C=>{if(w)if(th(C,"X-TIMESTAMP-MAP=")){w=!1,C.slice(16).split(",").forEach(D=>{th(D,"LOCAL:")?v=D.slice(6):th(D,"MPEGTS:")&&(A=parseInt(D.slice(7)))});try{E=p4(v)/1e3}catch(D){T=D}return}else C===""&&(w=!1);d.parse(C+`
206
+ `)}),d.flush()}const rh="stpp.ttml.im1t",Nf=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Uf=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,v4={left:"start",center:"center",right:"end",start:"start",end:"end"};function Bf(s,t,e,i){const n=be(new Uint8Array(s),["mdat"]);if(n.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const o=n.map(d=>Ur(d)),l=Rb(t.baseTime,1,t.timescale);try{o.forEach(d=>e(y4(d,l)))}catch(d){i(d)}}function y4(s,t){const e=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("tt")[0];if(!e)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(i).reduce((p,g)=>(p[g]=e.getAttribute(`ttp:${g}`)||i[g],p),{}),o=e.getAttribute("xml:space")!=="preserve",l=Gf(sh(e,"styling","style")),d=Gf(sh(e,"layout","region")),f=sh(e,"body","[begin]");return[].map.call(f,p=>{const g=Vf(p,o);if(!g||!p.hasAttribute("begin"))return null;const v=ah(p.getAttribute("begin"),n),A=ah(p.getAttribute("dur"),n);let E=ah(p.getAttribute("end"),n);if(v===null)throw Hf(p);if(E===null){if(A===null)throw Hf(p);E=v+A}const T=new Qc(v-t,E-t,g);T.id=ih(T.startTime,T.endTime,T.text);const w=d[p.getAttribute("region")],C=l[p.getAttribute("style")],D=b4(w,C,l),{textAlign:M}=D;if(M){const U=v4[M];U&&(T.lineAlign=U),T.align=M}return ui(T,D),T}).filter(p=>p!==null)}function sh(s,t,e){const i=s.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(e)):[]}function Gf(s){return s.reduce((t,e)=>{const i=e.getAttribute("xml:id");return i&&(t[i]=e),t},{})}function Vf(s,t){return[].slice.call(s.childNodes).reduce((e,i,n)=>{var o;return i.nodeName==="br"&&n?e+`
207
+ `:(o=i.childNodes)!=null&&o.length?Vf(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function b4(s,t,e){const i="http://www.w3.org/ns/ttml#styling";let n=null;const o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],l=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return l&&e.hasOwnProperty(l)&&(n=e[l]),o.reduce((d,f)=>{const p=nh(t,i,f)||nh(s,i,f)||nh(n,i,f);return p&&(d[f]=p),d},{})}function nh(s,t,e){return s&&s.hasAttributeNS(t,e)?s.getAttributeNS(t,e):null}function Hf(s){return new Error(`Could not parse ttml timestamp ${s}`)}function ah(s,t){if(!s)return null;let e=Mf(s);return e===null&&(Nf.test(s)?e=A4(s,t):Uf.test(s)&&(e=E4(s,t))),e}function A4(s,t){const e=Nf.exec(s),i=(e[4]|0)+(e[5]|0)/t.subFrameRate;return(e[1]|0)*3600+(e[2]|0)*60+(e[3]|0)+i/t.frameRate}function E4(s,t){const e=Uf.exec(s),i=Number(e[1]);switch(e[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}class T4{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=Wf(),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 zo(this,"textTrack1"),i=new zo(this,"textTrack2"),n=new zo(this,"textTrack3"),o=new zo(this,"textTrack4");this.cea608Parser1=new Df(1,e,i),this.cea608Parser2=new Df(3,n,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,n,o){let l=!1;for(let d=o.length;d--;){const f=o[d],p=w4(f[0],f[1],e,i);if(p>=0&&(f[0]=Math.min(f[0],e),f[1]=Math.max(f[1],i),l=!0,p/(i-e)>.5))return}if(l||o.push([e,i]),this.config.renderTextTracksNatively){const d=this.captionsTracks[t];this.Cues.newCue(d,e,i,n)}else{const d=this.Cues.newCue(null,e,i,n);this.hls.trigger(R.CUES_PARSED,{type:"captions",cues:d,track:t})}}onInitPtsFound(t,{frag:e,id:i,initPTS:n,timescale:o}){const{unparsedVttFrags:l}=this;i==="main"&&(this.initPTS[e.cc]={baseTime:n,timescale:o}),l.length&&(this.unparsedVttFrags=[],l.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 n=e.textTracks[i];if(n[t])return n}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:n}=this,{label:o,languageCode:l}=e[t],d=this.getExistingTrack(t);if(d)i[t]=d,Cn(i[t]),F0(i[t],n);else{const f=this.createTextTrack("captions",o,l);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,n={_id:t,label:i,kind:"captions",default:e.media?!!e.media.default:!1,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=n,this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}createTextTrack(t,e,i){const n=this.media;if(n)return n.addTextTrack(t,e,i)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:t}=this;Object.keys(t).forEach(e=>{Cn(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Wf(),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++)Cn(e[i])}onSubtitleTracksUpdated(t,e){const i=e.subtitleTracks||[],n=i.some(o=>o.textCodec===rh);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(wf(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((l,d)=>{let f;if(o&&d<o.length){let p=null;for(let g=0;g<o.length;g++)if(k4(o[g],l)){p=o[g];break}p&&(f=p)}if(f)Cn(f);else{const p=this._captionsOrSubtitlesFromCharacteristics(l);f=this.createTextTrack(p,l.name,l.lang),f&&(f.mode="disabled")}f&&(f.groupId=l.groupId,this.textTracks.push(f))})}else if(this.tracks.length){const o=this.tracks.map(l=>({label:l.name,kind:l.type.toLowerCase(),default:l.default,subtitleTrack:l}));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 n=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!n)return;const o=`textTrack${n[1]}`,l=this.captionsProperties[o];l&&(l.label=i.name,i.lang&&(l.languageCode=i.lang),l.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:n,lastSn:o,lastPartIndex:l}=this;if(!(!this.enabled||!(i&&n))&&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===l+1||(i.reset(),n.reset()),this.lastSn=p,this.lastPartIndex=g}}onFragLoaded(t,e){const{frag:i,payload:n}=e;if(i.type===Jt.SUBTITLE)if(n.byteLength){const o=i.decryptdata,l="stats"in e;if(o==null||!o.encrypted||l){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===rh?this._parseIMSC1(i,n):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;Bf(e,this.initPTS[t.cc],n=>{this._appendCues(n,t.level),i.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},n=>{X.log(`Failed to parse IMSC1: ${n}`),i.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:n})})}_parseVTTs(t){var e;const{frag:i,payload:n}=t,{initPTS:o,unparsedVttFrags:l}=this,d=o.length-1;if(!o[i.cc]&&d===-1){l.push(t);return}const f=this.hls,p=(e=i.initSegment)!=null&&e.data?dn(i.initSegment.data,new Uint8Array(n)):n;m4(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?l.push(t):this._fallbackToIMSC1(i,n),X.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||Bf(e,this.initPTS[t.cc],()=>{i.textCodec=rh,this._parseIMSC1(t,e)},()=>{i.textCodec="wvtt"})}_appendCues(t,e){const i=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[e];if(!n||n.mode==="disabled")return;t.forEach(o=>N0(n,o))}else{const n=this.tracks[e];if(!n)return;const o=n.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:n}=this;if(!this.enabled||!(i&&n))return;const{frag:o,samples:l}=e;if(!(o.type===Jt.MAIN&&this.closedCaptionsForLevel(o)==="NONE"))for(let d=0;d<l.length;d++){const f=l[d].bytes;if(f){const p=this.extractCea608Data(f);i.addData(l[d].pts,p[0]),n.addData(l[d].pts,p[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:i,endOffsetSubtitles:n,type:o}){const{media:l}=this;if(!(!l||l.currentTime<i)){if(!o||o==="video"){const{captionsTracks:d}=this;Object.keys(d).forEach(f=>Sc(d[f],e,i))}if(this.config.renderTextTracksNatively&&e===0&&n!==void 0){const{textTracks:d}=this;Object.keys(d).forEach(f=>Sc(d[f],e,n))}}}extractCea608Data(t){const e=[[],[]],i=t[0]&31;let n=2;for(let o=0;o<i;o++){const l=t[n++],d=127&t[n++],f=127&t[n++];if(!(d===0&&f===0)&&4&l){const p=3&l;(p===0||p===1)&&(e[p].push(d),e[p].push(f))}}return e}}function k4(s,t){return!!s&&s.label===t.name&&!(s.textTrack1||s.textTrack2)}function w4(s,t,e,i){return Math.min(t,i)-Math.max(s,e)}function Wf(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class oh{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((n,o)=>this.isLevelAllowed(n)&&o<=t);return this.clientRect=null,oh.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 n=(l,d)=>d?l.width!==d.width||l.height!==d.height:!0;let o=t.length-1;for(let l=0;l<t.length;l+=1){const d=t[l];if((d.width>=e||d.height>=i)&&n(d,t[l+1])){o=l;break}}return o}}class S4{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 n=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=n,n&&typeof n.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,i){const n=performance.now();if(e){if(this.lastTime){const o=n-this.lastTime,l=i-this.lastDroppedFrames,d=e-this.lastDecodedFrames,f=1e3*l/o,p=this.hls;if(p.trigger(R.FPS_DROP,{currentDropped:l,currentDecoded:d,totalDroppedFrames:i}),f>0&&l>p.config.fpsDroppedMonitoringThreshold*d){let g=p.currentLevel;X.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=n,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 Zo="[eme]";class On{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=On.CDMCleanupPromise?[On.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=X.debug.bind(X,Zo),this.log=X.log.bind(X,Zo),this.warn=X.warn.bind(X,Zo),this.error=X.error.bind(X,Zo),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,n=e[t];if(n)return n.licenseUrl;if(t===ei.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=(l,d,f)=>!!l&&f.indexOf(l)===d,n=e.map(l=>l.audioCodec).filter(i),o=e.map(l=>l.videoCodec).filter(i);return n.length+o.length===0&&o.push("avc1.42e01e"),new Promise((l,d)=>{const f=p=>{const g=p.shift();this.getMediaKeysPromise(g,n,o).then(v=>l({keySystem:g,mediaKeys:v})).catch(v=>{p.length?f(p):v instanceof gr?d(v):d(new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.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 n=`Configured requestMediaKeySystemAccess is not a function ${i}`;return d0===null&&self.location.protocol==="http:"&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return i(t,e)}getMediaKeysPromise(t,e,i){const n=Uv(t,e,i,this.config.drmSystemOptions),o=this.keySystemAccessPromises[t];let l=o==null?void 0:o.keySystemAccess;if(!l){this.log(`Requesting encrypted media "${t}" key-system access with config: ${JSON.stringify(n)}`),l=this.requestMediaKeySystemAccess(t,n);const d=this.keySystemAccessPromises[t]={keySystemAccess:l};return l.catch(f=>{this.log(`Failed to obtain access to key-system "${t}": ${f}`)}),l.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 l.then(()=>o.mediaKeys)}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:i}){this.log(`Creating key-system session "${e}" keyId: ${Br.hexDump(t.keyId||[])}`);const n=i.createSession(),o={decryptdata:t,keySystem:e,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(o),o}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const i=this.createMediaKeySessionContext(t),n=this.getKeyIdString(e),o="cenc";this.keyIdToKeySessionPromise[n]=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 Br.hexDump(t.keyId)}updateKeySession(t,e){var i;const n=t.mediaKeysSession;return this.log(`Updating key-session "${n.sessionId}" for keyID ${Br.hexDump(((i=t.decryptdata)==null?void 0:i.keyId)||[])}
208
+ } (data length: ${e&&e.byteLength})`),n.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 n=yc(this.config),o=t.map(l0).filter(l=>!!l&&n.indexOf(l)!==-1);return this.getKeySystemSelectionPromise(o).then(({keySystem:l})=>{const d=h0(l);d?e(d):i(new Error(`Unable to find format for key-system "${l}"`))}).catch(i)})}loadKey(t){const e=t.keyInfo.decryptdata,i=this.getKeyIdString(e),n=`(keyId: ${i} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${n}`);let o=this.keyIdToKeySessionPromise[i];return o||(o=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(e).then(({keySystem:l,mediaKeys:d})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${n}`),this.attemptSetMediaKeys(l,d).then(()=>{this.throwIfDestroyed();const f=this.createMediaKeySessionContext({keySystem:l,mediaKeys:d,decryptdata:e}),p="cenc";return this.generateRequestWithPreferredKeySession(f,p,e.pssh,"playlist-key")}))),o.catch(l=>this.handleError(l))),o}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof gr?this.hls.trigger(R.ERROR,t.data):this.hls.trigger(R.ERROR,{type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const n=l0(t.keyFormat),o=n?[n]:yc(this.config);return this.attemptKeySystemAccess(o)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=yc(this.config)),t.length===0)throw new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.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 n,o;if(e==="sinf"&&this.config.drmSystems[ei.FAIRPLAY]){const g=_i(new Uint8Array(i));try{const v=vc(JSON.parse(g).sinf),A=b0(new Uint8Array(v));if(!A)return;n=A.subarray(8,24),o=ei.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const g=cy(i);if(g===null)return;g.version===0&&g.systemId===c0.WIDEVINE&&g.data&&(n=g.data.subarray(8,24)),o=Nv(g.systemId)}if(!o||!n)return;const l=Br.hexDump(n),{keyIdToKeySessionPromise:d,mediaKeySessions:f}=this;let p=d[l];for(let g=0;g<f.length;g++){const v=f[g],A=v.decryptdata;if(A.pssh||!A.keyId)continue;const E=Br.hexDump(A.keyId);if(l===E||A.uri.replace(/-/g,"").indexOf(l)!==-1){p=d[E],delete d[E],A.pssh=new Uint8Array(i),A.keyId=n,p=d[l]=p.then(()=>this.generateRequestWithPreferredKeySession(v,e,i,"encrypted-event-key-match"));break}}p||(p=d[l]=this.getKeySystemSelectionPromise([o]).then(({keySystem:g,mediaKeys:v})=>{var A;this.throwIfDestroyed();const E=new Ca("ISO-23001-7",l,(A=h0(g))!=null?A:"");return E.pssh=new Uint8Array(i),E.keyId=n,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 n=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(n),n.then(()=>{this.log(`Media-keys set for "${t}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(o=>i.indexOf(o)===-1)})}generateRequestWithPreferredKeySession(t,e,i,n){var o,l;const d=(o=this.config.drmSystems)==null||(l=o[t.keySystem])==null?void 0:l.generateRequest;if(d)try{const A=d.call(this.hls,e,i,t);if(!A)throw new Error("Invalid response from configured generateRequest filter");e=A.initDataType,i=t.decryptdata.pssh=A.initData?new Uint8Array(A.initData):null}catch(A){var f;if(this.warn(A.message),(f=this.hls)!=null&&f.config.debug)throw A}if(i===null)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(t);const p=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${n}": ${p} (init data type: ${e} length: ${i?i.byteLength:null})`);const g=new Yc;t.mediaKeysSession.onmessage=A=>{const E=t.mediaKeysSession;if(!E){g.emit("error",new Error("invalid state"));return}const{messageType:T,message:w}=A;this.log(`"${T}" message event for session "${E.sessionId}" message size: ${w.byteLength}`),T==="license-request"||T==="license-renewal"?this.renewLicense(t,w).catch(C=>{this.handleError(C),g.emit("error",C)}):T==="license-release"?t.keySystem===ei.FAIRPLAY&&(this.updateKeySession(t,o0("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${T}"`)},t.mediaKeysSession.onkeystatuseschange=A=>{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((A,E)=>{g.on("error",E),g.on("keyStatus",T=>{T.startsWith("usable")?A():T==="output-restricted"?E(new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):T==="internal-error"?E(new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.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 A;this.log(`Request generated for key-session "${(A=t.mediaKeysSession)==null?void 0:A.sessionId}" keyId: ${p}`)}).catch(A=>{throw new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_NO_SESSION,error:A,fatal:!1},`Error generating key-session request: ${A}`)}).then(()=>v).catch(A=>{throw g.removeAllListeners(),this.removeSession(t),A}).then(()=>(g.removeAllListeners(),t))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach((e,i)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${Br.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Br.hexDump(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e})}fetchServerCertificate(t){const e=this.config,i=e.loader,n=new i(e),o=this.getServerCertificateUrl(t);return o?(this.log(`Fetching serverCertificate for "${t}"`),new Promise((l,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:(A,E,T,w)=>{l(A.data)},onError:(A,E,T,w)=>{d(new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:Yi({url:f.url,data:void 0},A)},`"${t}" certificate request failed (${o}). Status: ${A.code} (${A.text})`))},onTimeout:(A,E,T)=>{d(new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:{url:f.url,data:void 0}},`"${t}" certificate request timed out (${o})`))},onAbort:(A,E,T)=>{d(new Error("aborted"))}};n.load(f,g,v)})):Promise.resolve()}setMediaKeysServerCertificate(t,e,i){return new Promise((n,o)=>{t.setServerCertificate(i).then(l=>{this.log(`setServerCertificate ${l?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${e}"`),n(t)}).catch(l=>{o(new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:l,fatal:!0},l.message))})})}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then(i=>this.updateKeySession(t,new Uint8Array(i)).catch(n=>{throw new gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:n,fatal:!0},n.message)}))}setupLicenseXHR(t,e,i,n){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,n)}).catch(l=>{if(!i.decryptdata)throw l;return t.open("POST",e,!0),o.call(this.hls,t,e,i,n)}).then(l=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:l||n})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:n}))}requestLicense(t,e){const i=this.config.keyLoadPolicy.default;return new Promise((n,o)=>{const l=this.getLicenseServerUrl(t.keySystem);this.log(`Sending license request to URL: ${l}`);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,l,t)}catch(g){this.error(g)}n(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 gr({type:Qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:d,response:{url:l,data:void 0,code:d.status,text:d.statusText}},`License Request XHR failed (${l}). 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(n,o)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=d,this.setupLicenseXHR(d,l,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={},Ca.clearKeyUriToKeyIdMap();const i=e.length;On.CDMCleanupPromise=Promise.all(e.map(n=>this.removeSession(n)).concat(t==null?void 0:t.setMediaKeys(null).catch(n=>{this.log(`Could not clear media keys: ${n}. media.src: ${t==null?void 0:t.src}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)}).catch(n=>{this.log(`Could not close sessions and clear media keys: ${n}. 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((n,o)=>(n.indexOf(o.keyFormat)===-1&&n.push(o.keyFormat),n),[]);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 n=this.mediaKeySessions.indexOf(t);return n>-1&&this.mediaKeySessions.splice(n,1),e.remove().catch(o=>{this.log(`Could not remove session: ${o}`)}).then(()=>e.close()).catch(o=>{this.log(`Could not close session: ${o}`)})}}}On.CDMCleanupPromise=void 0;class gr 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 R4=1;var Zi={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const L4="h";class _s{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=n=>{try{this.apply(n,{ot:Zi.MANIFEST,su:!this.initialized})}catch(o){X.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=n=>{try{const o=n.frag,l=this.hls.levels[o.level],d=this.getObjectType(o),f={d:o.duration*1e3,ot:d};(d===Zi.VIDEO||d===Zi.AUDIO||d==Zi.MUXED)&&(f.br=l.bitrate/1e3,f.tb=this.getTopBandwidth(d)/1e3,f.bl=this.getBufferLength(d)),this.apply(n,f)}catch(o){X.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||_s.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,n;this.audioBuffer=(i=e.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(n=e.tracks.video)==null?void 0:n.buffer}createData(){var t;return{v:R4,sf:L4,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){ui(e,this.createData());const i=e.ot===Zi.INIT||e.ot===Zi.VIDEO||e.ot===Zi.MUXED;if(this.starved&&i&&(e.bs=!0,e.su=!0,this.starved=!1),e.su==null&&(e.su=this.buffering),this.useHeaders){const n=_s.toHeaders(e);if(!Object.keys(n).length)return;t.headers||(t.headers={}),ui(t.headers,n)}else{const n=_s.toQuery(e);if(!n)return;t.url=_s.appendQueryToUri(t.url,n)}}getObjectType(t){const{type:e}=t;if(e==="subtitle")return Zi.TIMED_TEXT;if(t.sn==="initSegment")return Zi.INIT;if(e==="audio")return Zi.AUDIO;if(e==="main")return this.hls.audioTracks.length?Zi.VIDEO:Zi.MUXED}getTopBandwidth(t){let e=0,i;const n=this.hls;if(t===Zi.AUDIO)i=n.audioTracks;else{const o=n.maxAutoLevel,l=o>-1?o+1:n.levels.length;i=n.levels.slice(0,l)}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===Zi.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!e?NaN:Ge.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(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,o,l){e(n),this.loader.load(n,o,l)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,i=t||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,o,l){e(n),this.loader.load(n,o,l)}}}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,n=f=>Math.round(f),o=f=>n(f/100)*100,l={br:n,d:n,bl:o,dl:o,mtp:o,nor:f=>encodeURIComponent(f),rtp:o,tb:n},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=l[f];g&&(p=g(p));const v=typeof p;let A;f==="ot"||f==="sf"||f==="st"?A=`${f}=${p}`:v==="boolean"?A=f:v==="number"?A=`${f}=${p}`:A=`${f}=${JSON.stringify(p)}`,e.push(A)}return e.join(",")}static toHeaders(t){const e=Object.keys(t),i={},n=["Object","Request","Session","Status"],o=[{},{},{},{}],l={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=l[d]!=null?l[d]:1;o[f][d]=t[d]}for(let d=0;d<o.length;d++){const f=_s.serialize(o[d]);f&&(i[`CMCD-${n[d]}`]=f)}return i}static toQuery(t){return`CMCD=${encodeURIComponent(_s.serialize(t))}`}static appendQueryToUri(t,e){if(!e)return t;const i=t.includes("?")?"&":"?";return`${t}${i}${e}`}}const _4=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=X.log.bind(X,"[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)===xi.SendAlternateToPenaltyBox&&i.flags===fr.MoveAllAlternatesMatchingHost){let n=this.pathwayPriority;const o=this.pathwayId;this.penalizedPathways[o]||(this.penalizedPathways[o]=performance.now()),!n&&this.levels&&(n=this.levels.reduce((l,d)=>(l.indexOf(d.pathwayId)===-1&&l.push(d.pathwayId),l),[])),n&&n.length>1&&(this.updatePathwayPriority(n),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,n=performance.now();Object.keys(i).forEach(o=>{n-i[o]>_4&&delete i[o]});for(let o=0;o<t.length;o++){const l=t[o];if(i[l])continue;if(l===this.pathwayId)return;const d=this.hls.nextLoadLevel,f=this.hls.levels[d];if(e=this.getLevelsForPathway(l),e.length>0){this.log(`Setting Pathway to "${l}"`),this.pathwayId=l,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={},n={};t.forEach(o=>{const{ID:l,"BASE-ID":d,"URI-REPLACEMENT":f}=o;if(e.some(g=>g.pathwayId===l))return;const p=this.getLevelsForPathway(d).map(g=>{const v=ui({},g);v.details=void 0,v.url=Kf(g.uri,g.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f);const A=new ti(g.attrs);A["PATHWAY-ID"]=l;const E=A.AUDIO&&`${A.AUDIO}_clone_${l}`,T=A.SUBTITLES&&`${A.SUBTITLES}_clone_${l}`;E&&(i[A.AUDIO]=E,A.AUDIO=E),T&&(n[A.SUBTITLES]=T,A.SUBTITLES=T),v.attrs=A;const w=new xa(v);return Bo(w,"audio",E),Bo(w,"text",T),w});e.push(...p),jf(this.audioTracks,i,f,l),jf(this.subtitleTracks,n,f,l)})}loadSteeringManifest(t){const e=this.hls.config,i=e.loader;this.loader&&this.loader.destroy(),this.loader=new i(e);let n;try{n=new self.URL(t)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${t}`);return}if(n.protocol!=="data:"){const g=(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate)|0;n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+g)}const o={responseType:"json",url:n.href},l=e.steeringManifestLoadPolicy.default,d=l.errorRetry||l.timeoutRetry||{},f={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:d.maxNumRetry||0,retryDelay:d.retryDelayMs||0,maxRetryDelay:d.maxRetryDelayMs||0},p={onSuccess:(g,v,A,E)=>{this.log(`Loaded steering manifest: "${n}"`);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":C,"PATHWAY-PRIORITY":D}=T;if(w)try{this.uri=new self.URL(w,n).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${w}`);return}this.scheduleRefresh(this.uri||A.url),C&&this.clonePathways(C),D&&this.updatePathwayPriority(D)},onError:(g,v,A,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 C=w.getResponseHeader("Retry-After");C&&(T=parseFloat(C)*1e3)}this.log(`Steering manifest ${v.url} rate limited`);return}this.scheduleRefresh(this.uri||v.url,T)},onTimeout:(g,v,A)=>{this.log(`Timeout loading steering manifest (${v.url})`),this.scheduleRefresh(this.uri||v.url)}};this.log(`Requesting steering manifest: ${n}`),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 jf(s,t,e,i){s&&Object.keys(t).forEach(n=>{const o=s.filter(l=>l.groupId===n).map(l=>{const d=ui({},l);return d.details=void 0,d.attrs=new ti(d.attrs),d.url=d.attrs.URI=Kf(l.url,l.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),d.groupId=d.attrs["GROUP-ID"]=t[n],d.attrs["PATHWAY-ID"]=i,d});s.push(...o)})}function Kf(s,t,e,i){const{HOST:n,PARAMS:o,[e]:l}=i;let d;t&&(d=l==null?void 0:l[t],d&&(s=d));const f=new self.URL(s);return n&&!d&&(f.host=n),o&&Object.keys(o).sort().forEach(p=>{p&&f.searchParams.set(p,o[p])}),f.href}const I4=/^age:\s*[\d.]+\s*$/im;class Yf{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 xo,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,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;const o=this.xhrSetup;o?Promise.resolve().then(()=>{if(!this.stats.aborted)return o(i,e.url)}).catch(l=>(i.open("GET",e.url,!0),o(i,e.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,e,t)}).catch(l=>{this.callbacks.onError({code:i.status,text:l.message},e,i,n)}):this.openAndSendXhr(i,e,t)}openAndSendXhr(t,e,i){t.readyState||t.open("GET",e.url,!0);const n=this.context.headers,{maxTimeToFirstByteMs:o,maxLoadTimeMs:l}=i.loadPolicy;if(n)for(const d in n)t.setRequestHeader(d,n[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&&Wt(o)?o:l,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 n=e.readyState,o=this.config;if(!i.aborted&&n>=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)))),n===4)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const l=e.status,d=e.responseType!=="text";if(l>=200&&l<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:l};this.callbacks.onSuccess(v,i,t,e)}else{const f=o.loadPolicy.errorRetry,p=i.retry;Uo(f,p,!1,l)?this.retry(f):(X.error(`${l} while loading ${t.url}`),this.callbacks.onError({code:l,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(Uo(e,i,!0))this.retry(e);else{X.warn(`timeout while loading ${this.context.url}`);const n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:i}=this;this.retryDelay=xc(t,i.retry),i.retry++,X.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&&I4.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 x4(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const D4=/(\d+)-(\d+)\/(\d+)/;class zf{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||$4,this.controller=new self.AbortController,this.stats=new xo}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 n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();const o=P4(t,this.controller.signal),l=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&&Wt(p)?p:g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(n,t,this.response)},e.timeout),self.fetch(this.request).then(v=>{this.response=this.loader=v;const A=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(n,t,this.response)},g-(A-n.loading.start)),!v.ok){const{status:E,statusText:T}=v;throw new F4(T||"fetch, bad network response",E,v)}return n.loading.first=A,n.total=M4(v.headers)||n.total,l&&Wt(e.highWaterMark)?this.loadProgressively(v,n,t,e.highWaterMark,l):d?v.arrayBuffer():t.responseType==="json"?v.json():v.text()}).then(v=>{const{response:A}=this;self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const E=v[f];E&&(n.loaded=n.total=E);const T={url:A.url,data:v,code:A.status};l&&!Wt(e.highWaterMark)&&l(n,t,v,A),i.onSuccess(T,n,t,A)}).catch(v=>{if(self.clearTimeout(this.requestTimeout),n.aborted)return;const A=v&&v.code||0,E=v?v.message:null;i.onError({code:A,text:E},t,v?v.details:null,n)})}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,n=0,o){const l=new Tf,d=t.body.getReader(),f=()=>d.read().then(p=>{if(p.done)return l.dataLength&&o(e,i,l.flush(),t),Promise.resolve(new ArrayBuffer(0));const g=p.value,v=g.length;return e.loaded+=v,v<n||l.dataLength?(l.push(g),l.dataLength>=n&&o(e,i,l.flush(),t)):o(e,i,g,t),f()}).catch(()=>Promise.reject());return f()}}function P4(s,t){const e={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(ui({},s.headers))};return s.rangeEnd&&e.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),e}function O4(s){const t=D4.exec(s);if(t)return parseInt(t[2])-parseInt(t[1])+1}function M4(s){const t=s.get("Content-Range");if(t){const i=O4(t);if(Wt(i))return i}const e=s.get("Content-Length");if(e)return parseInt(e)}function $4(s,t){return new self.Request(s.url,t)}class F4 extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const N4=/\s/,U4={newCue(s,t,e,i){const n=[];let o,l,d,f,p;const g=self.VTTCue||self.TextTrackCue;for(let A=0;A<i.rows.length;A++)if(o=i.rows[A],d=!0,f=0,p="",!o.isEmpty()){var v;for(let w=0;w<o.chars.length;w++)N4.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=Ff(p.trim()),T=ih(t,e,E);s!=null&&(v=s.cues)!=null&&v.getCueById(T)||(l=new g(t,e,E),l.id=T,l.line=A+1,l.align="left",l.position=10+Math.min(80,Math.floor(f*8/32)*10),n.push(l))}return s&&n.length&&(n.sort((A,E)=>A.line==="auto"||E.line==="auto"?0:A.line>8&&E.line>8?E.line-A.line:A.line-E.line),n.forEach(A=>N0(s,A))),n}},B4={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},G4=Yi(Yi({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:Yf,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:jb,bufferController:t4,capLevelController:oh,errorController:Fy,fpsController:S4,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:d0,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:B4},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},V4()),{},{subtitleStreamController:Zb,subtitleTrackController:Qb,timelineController:T4,audioStreamController:Yb,audioTrackController:zb,emeController:On,cmcdController:_s,contentSteeringController:C4});function V4(){return{cueHandler:U4,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 H4(s,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(t.liveMaxLatencyDurationCount!==void 0&&(t.liveSyncDurationCount===void 0||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(t.liveMaxLatencyDuration!==void 0&&(t.liveSyncDuration===void 0||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const e=lh(s),i=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(o=>{const l=`${o==="level"?"playlist":o}LoadPolicy`,d=t[l]===void 0,f=[];n.forEach(p=>{const g=`${o}Loading${p}`,v=t[g];if(v!==void 0&&d){f.push(g);const A=e[l].default;switch(t[l]={default:A},p){case"TimeOut":A.maxLoadTimeMs=v,A.maxTimeToFirstByteMs=v;break;case"MaxRetry":A.errorRetry.maxNumRetry=v,A.timeoutRetry.maxNumRetry=v;break;case"RetryDelay":A.errorRetry.retryDelayMs=v,A.timeoutRetry.retryDelayMs=v;break;case"MaxRetryTimeout":A.errorRetry.maxRetryDelayMs=v,A.timeoutRetry.maxRetryDelayMs=v;break}}}),f.length&&X.warn(`hls.js config: "${f.join('", "')}" setting(s) are deprecated, use "${l}": ${JSON.stringify(t[l])}`)}),Yi(Yi({},e),t)}function lh(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(lh):Object.keys(s).reduce((t,e)=>(t[e]=lh(s[e]),t),{}):s}function W4(s){const t=s.loader;t!==zf&&t!==Yf?(X.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):x4()&&(s.loader=zf,s.progressive=!0,s.enableSoftwareAES=!0,X.log("[config]: Progressive streaming enabled, using FetchLoader"))}class ls{static get version(){return"1.4.12"}static isSupported(){return ib()}static get Events(){return R}static get ErrorTypes(){return Qt}static get ErrorDetails(){return pt}static get DefaultConfig(){return ls.defaultConfig?ls.defaultConfig:G4}static set DefaultConfig(t){ls.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Yc,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,_v(t.debug||!1,"Hls instance");const e=this.config=H4(ls.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&W4(e);const{abrController:i,bufferController:n,capLevelController:o,errorController:l,fpsController:d}=e,f=new l(this),p=this.abrController=new i(this),g=this.bufferController=new n(this),v=this.capLevelController=new o(this),A=new d(this),E=new yy(this),T=new ky(this),w=e.contentSteeringController,C=w?new w(this):null,D=this.levelController=new Uy(this,C),M=new By(this),U=new Vy(this.config),x=this.streamController=new Hb(this,M,U);v.setStreamController(x),A.setStreamController(x);const G=[E,D,x];C&&G.splice(1,0,C),this.networkControllers=G;const $=[p,g,v,A,T,M];this.audioTrackController=this.createController(e.audioTrackController,G);const Y=e.audioStreamController;Y&&G.push(new Y(this,M,U)),this.subtitleTrackController=this.createController(e.subtitleTrackController,G);const tt=e.subtitleStreamController;tt&&G.push(new tt(this,M,U)),this.createController(e.timelineController,$),U.emeController=this.emeController=this.createController(e.emeController,$),this.cmcdController=this.createController(e.cmcdController,$),this.latencyController=this.createController(wy,$),this.coreComponents=$,G.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,n){this._emitter.off(t,e,i,n)}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){X.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:pt.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){X.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){X.log("attachMedia"),this._media=t,this.trigger(R.MEDIA_ATTACHING,{media:t})}detachMedia(){X.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,i=this.url,n=this.url=pc.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});X.log(`loadSource:${n}`),e&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(R.MANIFEST_LOADING,{url:t})}startLoad(t=-1){X.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){X.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){X.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){X.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){X.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){X.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){X.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){X.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){X.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&&(X.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){_c.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 n=0;n<i;n++)if(t[n].maxBitrate>=e)return n;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:i}=this;let n;if(e===-1&&t&&t.length?n=t.length-1:n=e,i)for(let o=n;o--;){const l=t[o].attrs["HDCP-LEVEL"];if(l&&l<=i)return o}return n}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}}ls.defaultConfig=void 0;function j4(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function K4(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function ch(s){const{id:t,key:e,src:i,playlist:n,duration:o}=s;return new Promise(l=>{let d=null;const f=document.createElement("video");if(f.playsInline=!0,f.muted=!0,f.loop=!1,n&&!j4()&&ls.isSupported()){let p=!1;d=new ls({autoStartLoad:!0,xhrSetup:g=>{const{open:v}=g,A=n.split("?")[1];g.open=function(E,T,w){T.toString().includes("?")||(T+="?"+A),v.apply(this,[E,T,w])}}}),d.loadSource(n),d.attachMedia(f),d.startLoadOnce=(g=-1,v)=>{if(d&&!p){const A=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=A!==-1?A:d.firstLevel}},d.on(ls.Events.LEVEL_LOADED,async()=>{p||d==null||d.stopLoad(),l({id:t,key:e,hls:d,config:s,node:f})})}else{f.src=i;let p=!1;if(f.startLoadOnce=()=>{p||(f.preload="auto",f.load(),p=!0)},o)f.preload="none",l({id:t,key:e,hls:d,config:s,node:f});else{f.preload="metadata";const g=async()=>{l({id:t,key:e,hls:d,config:s,node:f}),f.removeEventListener("loadedmetadata",g)};f.addEventListener("loadedmetadata",g)}}})}async function Xf(s){return s.duration===1/0?new Promise(t=>{s.currentTime=Number.MAX_SAFE_INTEGER,s.ontimeupdate=()=>{s.ontimeupdate=null,t(s.duration),s.currentTime=0}}):s.duration}const Y4=ks(async function(s){return new FontFace(s.name,`url(${s.woff2??s.url})`,{style:s.style,weight:s.weight}).load()},{cacheKey:([s])=>JSON.stringify(s)});let z4=class{constructor(s){this._hasPlayed=!1,this._memoKey=null,this._lastDeps=null,this._duration=0,this._scenes=null,this._videos={},this._videoMeta={},this._videoState={},this._resolveVideo=ks(async t=>{const{id:e,key:i}=t,n=await ch(t);n.node.volume=this.host.volume,n.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},l=Object.keys(o).reduce((d,f)=>{const p=f,g=o[p]({id:e,key:i,node:n.node});return d[p]=g,n.node.addEventListener(f,g),d},{});return{...n,listeners:l}},{cacheKey:([{id:t,key:e,src:i,playlist:n}])=>JSON.stringify({id:t,key:e,src:i==null?void 0:i.split("?")[0],playlist:n==null?void 0:n.split("?")[0]})}),this._resolveVideoMeta=ks(async(t,e)=>{const{id:i,captions:n,duration:o,startOffset:l,endOffset:d}=t,f=o??await Xf(e),p=(l??0)*f,g=(1-(d??0))*f;return{id:i,captions:n,start:p,duration:g-p}},{cacheKey:([{id:t,key:e,captions:i,duration:n,startOffset:o,endOffset:l}])=>JSON.stringify({id:t,key:e,captions:i,duration:n,startOffset:o,endOffset:l})}),this._handleLoadedData=({id:t,key:e,node:i})=>()=>{var n,o;const l=this.videoState[e];if(!(l!=null&&l.initialised)){this.videoState={...this.videoState,[e]:{...l,initialised:!0,waiting:!1,buffered:(l==null?void 0:l.buffered)??[]}};const d=(o=(n=this.scenes)==null?void 0:n.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],n=this._getBufferSegments({key:t,node:e,duration:this.host.duration});this.videoState={...this.videoState,[t]:{...i,buffered:n}}},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 n=this.videoState[e];n!=null&&n.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 n=new Nr(`Video error - answer ${t} failed to load`);this.host.dispatchEvent(new ErrorEvent("error",{bubbles:!0,composed:!0,error:n,message:n.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(n=>{var o,l;if((o=this.videos)!=null&&o[t]){const d=(l=i.listeners)==null?void 0:l[n];d&&i.node.removeEventListener(n,d)}}),delete this.videos[t])},this.host=s,this.host.addController(this)}set hasPlayed(s){s!==this._hasPlayed&&(this._hasPlayed=s,this.host.requestUpdate())}get hasPlayed(){return this._hasPlayed}set duration(s){!isNaN(s)&&s!==this._duration&&(this._duration=s,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(s){s!==this._scenes&&(this._scenes=s,this.host.requestUpdate())}get scenes(){return this._scenes}set videos(s){s!==this._videos&&(this._videos=s,this.host.requestUpdate())}get videos(){return this._videos}set videoMeta(s){s!==this._videoMeta&&(this._videoMeta=s,this.host.requestUpdate())}get videoMeta(){return this._videoMeta}set videoState(s){s!==this._videoState&&(this._videoState=s,this.host.requestUpdate())}get videoState(){return this._videoState}_getBufferSegments({key:s,node:t,duration:e}){var i;const n=t==null?void 0:t.buffered,o=[],{start:l,video:d,videoMeta:f}=((i=this.scenes)==null?void 0:i.scenes.find(({video:p})=>s===(p==null?void 0:p.key)))??{};if(t&&n&&d&&f&&typeof l<"u")for(let p=0;p<n.length;p++){const g=n.start(p),v=n.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)+l)/e*100),end:Math.min((Math.min(v-f.start,f.duration)+l)/e*100,100)})}return o}_setupTask(){new so(this.host,async([s,t,e,i,n,o])=>{try{let l=null;if(this.host._errors=[],e||s){if(this.host._processing=!0,e){let f=null;if(i)try{f=await(await fetch(i,{method:"GET"})).text()}catch(g){const v=new Nr("Track failed to fetch",g);this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:v,message:v.message}))}const p={questions:{items:[{answer:{id:"source",media:{[e.includes(".m3u8")?"playlist":"video"]:e},captions:{current:f}}}]}};try{this.scenes=await kn({data:p,template:t,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(g){try{this.scenes=await kn({data:p,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(v){throw new Nr("Fatal source template error",v,!0)}l=new Nr("Source template error",g)}}else try{this.scenes=await kn({data:s,template:t,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(f){try{this.scenes=await kn({data:s,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(p){throw new Nr("Fatal data template error",p,!0)}l=new Nr("Data template error",f)}Object.keys(this.videos).forEach(f=>{this.scenes.scenes.find(({video:p})=>f===(p==null?void 0:p.key))||this._videos[f].node.pause()});const d=this.scenes.scenes.reduce((f,{video:p})=>(p&&(f[p.key]=p),f),{});Object.keys(this.videos).join("|")!==Object.keys(d).join("|")&&this.host.reset(0,!1),this.videos=d,this.videoState={...this.videoState,...this.scenes.scenes.reduce((f,{video:p,start:g,duration:v})=>{var A;const E=(p==null?void 0:p.key)??`${g}-${v}`,T=this._getBufferSegments({key:E,node:p==null?void 0:p.node,duration:this.scenes.duration});return f[E]={initialised:!p,waiting:!!p,...this.videoState[E],buffered:p?T:(A=this.videoState[E])==null?void 0:A.buffered},f},{})},this.videoMeta=this.scenes.scenes.reduce((f,{video:p,videoMeta:g})=>(p&&g&&(f[p.key]=g),f),{}),(await Promise.all(this.scenes.fonts.map(f=>Y4(f)))).forEach(f=>{document.fonts.add(f)}),this.duration=this.scenes.duration,this.host.paused&&this.host.reset(this.host.currentTime,!this.host.paused)}l&&this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:l,message:l.message}))}catch(l){this.scenes=null,this.duration=0,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:l,message:l.message}))}finally{this.host._processing=!1}},()=>{const s=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===s)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=s,this._lastDeps=t,t})}_setVideoCurrentTime({time:s,scene:t}){const{start:e,video:i,videoMeta:n}=t;if(i&&i.node&&n&&typeof e<"u"){const o=s-e;i.node.currentTime=Math.max(n.start,Math.min(n.start+n.duration,o+n.start))}}setVideosCurrentTime(s){var t;(t=this.scenes)==null||t.scenes.forEach(e=>{this._setVideoCurrentTime({time:s,scene:e})})}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(s=>{this._cleanupVideo(s)}),this.videos={}}};function X4(s){s.requestFullscreen?s.requestFullscreen():s.mozRequestFullScreen?s.mozRequestFullScreen():s.webkitRequestFullscreen?s.webkitRequestFullscreen():s.msRequestFullscreen&&s.msRequestFullscreen()}function Z4(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const hh=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen","preview"],q4={id:"captions",event:"captions:click",label:"Closed Captions"},Q4={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},Zf={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}]},J4={id:"playbackRate",label:"Playback playbackRate",subItems:Zf};class tA extends Ud{constructor(t){if(super(t),this.element=null,this.observer=void 0,t.type!==En.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)),Es}}const dh=Tn(tA);var qf=Number.isNaN||function(s){return typeof s=="number"&&s!==s};function eA(s,t){return!!(s===t||qf(s)&&qf(t))}function iA(s,t){if(s.length!==t.length)return!1;for(var e=0;e<s.length;e++)if(!eA(s[e],t[e]))return!1;return!0}function rA(s,t){t===void 0&&(t=iA);var e=null;function i(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];if(e&&e.lastThis===this&&t(n,e.lastArgs))return e.lastResult;var l=s.apply(this,n);return e={lastResult:l,lastArgs:n,lastThis:this},l}return i.clear=function(){e=null},i}const sA=rA(()=>{const s=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=lu.map(n=>({load:!1,font:new FontFace(n.family,`url(${n.url})`,{style:n.style})}));return[{load:!0,font:s},{load:!0,font:t},{load:!0,font:e},...i]}),Vr={"red-120":"#feeded","red-130":"#fcd5d0","red-400":"#e84a4a","red-500":"#c51c3a","red-700":"#a21c39","red-800":"#850231","red-900":"#580A2D","teal-80":"#f3fafa","teal-100":"#d6f1f1","teal-200":"#ace3e3","teal-300":"#7acace","teal-400":"#4faab2","teal-500":"#358f97","teal-600":"#287179","teal-700":"#22555c","teal-800":"#21484e","teal-900":"#1f3d42","teal-950":"#0d2126","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"},nA={colors:Vr,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 ${Vr["dark-100"]}`,medium:`0 .125rem .625rem ${Vr["dark-100"]}`,large:`0 .25rem 1rem ${Vr["dark-50"]}`,xl:`.25rem .25rem 1rem ${Vr["dark-250"]}`,xxl:`0 .25rem 2rem ${Vr["dark-100"]}`,xxxl:`.25rem .25rem 3rem ${Vr["dark-250"]}`,toolbar:`0 -.625rem .625rem ${Vr["dark-50"]}`,text:`0 0 .25rem ${Vr["dark-250"]}`},timings:{fast:".1s",normal:".2s",slow:".3s"},easings:{linear:"linear"},focusOutline:{width:".2rem",color:Vr["dark-400"]},iconSizes:{small:"0.75rem",medium:"1rem",large:"1.5rem"}},Qf=Wm.flatten(nA,{delimiter:"-"}),aA=Object.keys(Qf).map(s=>ta(`:host { --${s}: ${Qf[s]}; }`)),oA=s=>{class t extends s{firstUpdated(){sA().forEach(({load:i,font:n})=>{document.fonts.add(n),i&&n.load()})}}return t.styles=[(s==null?void 0:s.styles)??[],aA,hi`
209
209
  :host {
210
210
  font-family: var(--fontFamilies-sans);
211
211
  font-size: var(--fontSizes-medium);
@@ -286,12 +286,12 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
286
286
  scroll-behavior: auto !important;
287
287
  }
288
288
  }
289
- `],t},Le=nA(ts),aA=(s,t)=>(typeof window<"u"&&(window.customElements.get(s)??window.customElements.define(s,t)),t),oA=(s,t)=>{const{kind:e,elements:i}=t;return{kind:e,elements:i,finisher(n){typeof window<"u"&&(window.customElements.get(s)??window.customElements.define(s,n))}}},Ni=s=>t=>typeof t=="function"?aA(s,t):oA(s,t);class lA{constructor(t){this._memoKey=null,this._lastDeps=null,this._scenes=null,this._video=null,this._handleSeeked=()=>{this.host._draw()},this._resolveVideo=ks(async e=>{const i=await ch(e);return i.node.play=async()=>{},i.node.addEventListener("seeked",this._handleSeeked),i},{cacheKey:([{id:e,src:i,playlist:n}])=>JSON.stringify({id:e,src:i==null?void 0:i.split("?")[0],playlist:n==null?void 0:n.split("?")[0]})}),this._resolveAnswer=ks(async e=>{const{id:i,key:n,poster:o}=e,{node:l}=await ch(e),d=new Image;return{id:i,key:n,config:e,node:l,getSource:()=>(o&&d.src!==o&&(d.onload=()=>{this.host._draw()},d.src=o),d)}},{cacheKey:([{id:e,src:i,playlist:n,poster:o}])=>JSON.stringify({id:e,src:i==null?void 0:i.split("?")[0],playlist:n==null?void 0:n.split("?")[0],poster:o==null?void 0:o.split("?")[0]})}),this._resolveVideoMeta=ks(async(e,i)=>{const{id:n,duration:o,startOffset:l,endOffset:d}=e,f=o??await Xf(i),p=(l??0)*f,g=(1-(d??0))*f;return{id:n,start:p,duration:g-p}},{cacheKey:([{id:e,duration:i,startOffset:n,endOffset:o}])=>JSON.stringify({id:e,duration:i,startOffset:n,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 ro(this.host,async([t,e,i])=>{var n,o;try{if(t){const l=t.includes(".m3u8")?"playlist":"video";try{this.scenes=await kn({data:{questions:{items:[{answer:{id:"source",media:{[l]:t}}}]}},template:i},this._resolveVideo,this._resolveVideoMeta)}catch(d){throw new ss(`Video preview source template error: ${d.message}`)}this._video=((o=(n=this.scenes.scenes[0])==null?void 0:n.video)==null?void 0:o.node)??null}else if(e)try{this.scenes=await kn({data:e,template:i},this._resolveAnswer,this._resolveVideoMeta)}catch(l){throw new ss(`Video preview data template error: ${l.message}`)}}catch(l){this.scenes=null,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:l,message:l.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 Jf(s,t,e){return Math.min(Math.max(t,s),e)}function uh(s,t={}){const e=Math.max(0,s||0),i=Math.floor(e/3600),n=Math.floor(e%3600/60),o=Math.floor(e%3600%60),l=Math.floor(e%1*1e3);let d=i?`${i}:${`${n}`.padStart(2,"0")}:${`${o}`.padStart(2,"0")}`:`${n}:${`${o}`.padStart(2,"0")}`;return t.includeMs&&(d+=`:${`${l}`.padStart(3,"0")}`),d}var cA=Object.defineProperty,hA=Object.getOwnPropertyDescriptor,Mn=(s,t,e,i)=>{for(var n=i>1?void 0:i?hA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&cA(t,e,n),n};let Cs=class extends Le{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return Xt`<button
289
+ `],t},_e=oA(es),lA=(s,t)=>(typeof window<"u"&&(window.customElements.get(s)??window.customElements.define(s,t)),t),cA=(s,t)=>{const{kind:e,elements:i}=t;return{kind:e,elements:i,finisher(n){typeof window<"u"&&(window.customElements.get(s)??window.customElements.define(s,n))}}},Ni=s=>t=>typeof t=="function"?lA(s,t):cA(s,t);class hA{constructor(t){this._memoKey=null,this._lastDeps=null,this._scenes=null,this._video=null,this._handleSeeked=()=>{this.host._draw()},this._resolveVideo=ks(async e=>{const i=await ch(e);return i.node.play=async()=>{},i.node.addEventListener("seeked",this._handleSeeked),i},{cacheKey:([{id:e,src:i,playlist:n}])=>JSON.stringify({id:e,src:i==null?void 0:i.split("?")[0],playlist:n==null?void 0:n.split("?")[0]})}),this._resolveAnswer=ks(async e=>{const{id:i,key:n,poster:o}=e,{node:l}=await ch(e),d=new Image;return{id:i,key:n,config:e,node:l,getSource:()=>(o&&d.src!==o&&(d.onload=()=>{this.host._draw()},d.src=o),d)}},{cacheKey:([{id:e,src:i,playlist:n,poster:o}])=>JSON.stringify({id:e,src:i==null?void 0:i.split("?")[0],playlist:n==null?void 0:n.split("?")[0],poster:o==null?void 0:o.split("?")[0]})}),this._resolveVideoMeta=ks(async(e,i)=>{const{id:n,duration:o,startOffset:l,endOffset:d}=e,f=o??await Xf(i),p=(l??0)*f,g=(1-(d??0))*f;return{id:n,start:p,duration:g-p}},{cacheKey:([{id:e,duration:i,startOffset:n,endOffset:o}])=>JSON.stringify({id:e,duration:i,startOffset:n,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 so(this.host,async([t,e,i])=>{var n,o;try{if(t){const l=t.includes(".m3u8")?"playlist":"video";try{this.scenes=await kn({data:{questions:{items:[{answer:{id:"source",media:{[l]:t}}}]}},template:i},this._resolveVideo,this._resolveVideoMeta)}catch(d){throw new Nr("Video preview source template error",d)}this._video=((o=(n=this.scenes.scenes[0])==null?void 0:n.video)==null?void 0:o.node)??null}else if(e)try{this.scenes=await kn({data:e,template:i},this._resolveAnswer,this._resolveVideoMeta)}catch(l){throw new Nr("Video preview data template error",l)}}catch(l){this.scenes=null,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:l,message:l.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 Jf(s,t,e){return Math.min(Math.max(t,s),e)}function uh(s,t={}){const e=Math.max(0,s||0),i=Math.floor(e/3600),n=Math.floor(e%3600/60),o=Math.floor(e%3600%60),l=Math.floor(e%1*1e3);let d=i?`${i}:${`${n}`.padStart(2,"0")}:${`${o}`.padStart(2,"0")}`:`${n}:${`${o}`.padStart(2,"0")}`;return t.includeMs&&(d+=`:${`${l}`.padStart(3,"0")}`),d}var dA=Object.defineProperty,uA=Object.getOwnPropertyDescriptor,Mn=(s,t,e,i)=>{for(var n=i>1?void 0:i?uA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&dA(t,e,n),n};let Cs=class extends _e{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return Xt`<button
290
290
  class=${Be({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"})}
291
291
  >
292
292
  <slot></slot>
293
293
  ${this.icon&&Xt`<vmp-icon icon=${this.icon}></vmp-icon>`}
294
- </button>`}};Cs.styles=[Le.styles??[],hi`
294
+ </button>`}};Cs.styles=[_e.styles??[],hi`
295
295
  :host {
296
296
  --button-padding: var(--vu-button-padding, var(--space-s));
297
297
  --button-color: var(--vu-button-color, var(--colors-dark-640));
@@ -528,14 +528,14 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
528
528
  <path
529
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"
530
530
  />
531
- </svg>`};var dA=Object.defineProperty,uA=Object.getOwnPropertyDescriptor,ep=(s,t,e,i)=>{for(var n=i>1?void 0:i?uA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&dA(t,e,n),n};let Zo=class extends Le{render(){return!this.icon||!Object.keys(tp).includes(this.icon)?null:tp[this.icon]()}};Zo.styles=[Le.styles??[],hi`
531
+ </svg>`};var fA=Object.defineProperty,pA=Object.getOwnPropertyDescriptor,ep=(s,t,e,i)=>{for(var n=i>1?void 0:i?pA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&fA(t,e,n),n};let qo=class extends _e{render(){return!this.icon||!Object.keys(tp).includes(this.icon)?null:tp[this.icon]()}};qo.styles=[_e.styles??[],hi`
532
532
  :host {
533
533
  display: flex;
534
534
  align-items: center;
535
535
  justify-content: center;
536
536
  flex-shrink: 0;
537
537
  }
538
- `],ep([Et({type:String})],Zo.prototype,"icon",2),Zo=ep([Ni("vmp-icon")],Zo);var fA=Object.defineProperty,pA=Object.getOwnPropertyDescriptor,$n=(s,t,e,i)=>{for(var n=i>1?void 0:i?pA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&fA(t,e,n),n};let Is=class extends Le{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return Xt`
538
+ `],ep([Et({type:String})],qo.prototype,"icon",2),qo=ep([Ni("vmp-icon")],qo);var gA=Object.defineProperty,mA=Object.getOwnPropertyDescriptor,$n=(s,t,e,i)=>{for(var n=i>1?void 0:i?mA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&gA(t,e,n),n};let Is=class extends _e{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return Xt`
539
539
  <vmp-button
540
540
  ?active=${this.active}
541
541
  size=${di(this.size)}
@@ -547,7 +547,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
547
547
  icon=${di(this.icon)}
548
548
  ></vmp-icon>
549
549
  </vmp-button>
550
- `}};Is.styles=[Le.styles??[],hi`
550
+ `}};Is.styles=[_e.styles??[],hi`
551
551
  .tiny::part(svg) {
552
552
  height: 12px;
553
553
  width: 12px;
@@ -562,16 +562,16 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
562
562
  height: 32px;
563
563
  width: 32px;
564
564
  }
565
- `],$n([Et({type:Boolean})],Is.prototype,"active",2),$n([Et({type:String})],Is.prototype,"size",2),$n([Et({type:String})],Is.prototype,"rounded",2),$n([Et({type:String})],Is.prototype,"weight",2),$n([Et({type:String})],Is.prototype,"icon",2),Is=$n([Ni("vmp-icon-button")],Is);var gA=Object.defineProperty,mA=Object.getOwnPropertyDescriptor,qi=(s,t,e,i)=>{for(var n=i>1?void 0:i?mA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&gA(t,e,n),n};let cs=class extends Le{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=Vl,this._currentTime=0,this._sceneController=new lA(this),this._canvasRef=Si(),this._previewRef=Si(),this._previewTimeRef=Si(),this._handleScrubberMouseEnter=({detail:{x:s,y:t,elementLeft:e,elementRight:i}})=>{var n,o;if((n=this._previewRef)!=null&&n.value){const l=this._previewRef.value.getBoundingClientRect(),d=(o=this._previewRef.value.getRootNode().host)==null?void 0:o.getBoundingClientRect();l&&d&&(this._previewRef.value.style.opacity="1",this._previewRef.value.style.transform=`translate3d(${Jf(e-d.left,s-d.left-l.width/2,i-d.left-l.width)}px, ${t-d.top-l.height-28}px, 0)`)}},this._handleScrubberMouseMove=({detail:{time:s,x:t,elementLeft:e,elementRight:i}})=>{var n,o,l,d,f,p,g,v;if(this._currentTime=s,(n=this._sceneController.scenes)!=null&&n.scenes.length){const A=(f=(d=(l=(o=this._sceneController.scenes)==null?void 0:o.scenes)==null?void 0:l.find(({start:E,duration:T,video:w})=>w&&s>=E&&s<=E+T))==null?void 0:d.video)==null?void 0:f.node;if(A&&(A.currentTime=s),this._draw(),(p=this._previewRef)!=null&&p.value){const E=this._previewRef.value.getBoundingClientRect(),T=(g=this._previewRef.value.getRootNode().host)==null?void 0:g.getBoundingClientRect();if(E&&T){const w=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[,C]=Array.from(w.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${Jf(e-T.left,t-T.left-E.width/2,i-T.left-E.width)}px, ${C[1]}px, 0)`}}this._previewTimeRef.value&&this._previewTimeRef.value.setAttribute("content",uh(Math.max(0,Math.min(this._currentTime,(v=this._sceneController.scenes)==null?void 0:v.duration))))}},this._handleScrubberMouseLeave=()=>{var s;(s=this._previewRef)!=null&&s.value&&(this._previewRef.value.style.opacity="0")},this._handleScrubberResize=({detail:{y:s}})=>{var t,e;if((t=this._previewRef)!=null&&t.value){const i=this._previewRef.value.getBoundingClientRect(),n=(e=this._previewRef.value.getRootNode().host)==null?void 0:e.getBoundingClientRect();if(i&&n){const o=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[l]=Array.from(o.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${l[1]}px, ${s-n.top-i.height-28}px, 0)`}}}}_draw(s=this._currentTime){var t,e;this._sceneController.scenes&&this._canvasRef.value&&((e=this.compilation)==null||e.call(this,{currentTime:Math.max(0,Math.min(s,(t=this._sceneController.scenes)==null?void 0:t.duration)),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 s;const{height:t,width:e}=Hl({resolution:180,aspectRatio:this.aspectRatio}),i=((s=this._sceneController.scenes)==null?void 0:s.scenes.length)??0;return!this.disabled&&(this.src||i>1)?Xt`
565
+ `],$n([Et({type:Boolean})],Is.prototype,"active",2),$n([Et({type:String})],Is.prototype,"size",2),$n([Et({type:String})],Is.prototype,"rounded",2),$n([Et({type:String})],Is.prototype,"weight",2),$n([Et({type:String})],Is.prototype,"icon",2),Is=$n([Ni("vmp-icon-button")],Is);var vA=Object.defineProperty,yA=Object.getOwnPropertyDescriptor,qi=(s,t,e,i)=>{for(var n=i>1?void 0:i?yA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&vA(t,e,n),n};let cs=class extends _e{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=Hl,this._currentTime=0,this._sceneController=new hA(this),this._canvasRef=Si(),this._previewRef=Si(),this._previewTimeRef=Si(),this._handleScrubberMouseEnter=({detail:{x:s,y:t,elementLeft:e,elementRight:i}})=>{var n,o;if((n=this._previewRef)!=null&&n.value){const l=this._previewRef.value.getBoundingClientRect(),d=(o=this._previewRef.value.getRootNode().host)==null?void 0:o.getBoundingClientRect();l&&d&&(this._previewRef.value.style.opacity="1",this._previewRef.value.style.transform=`translate3d(${Jf(e-d.left,s-d.left-l.width/2,i-d.left-l.width)}px, ${t-d.top-l.height-28}px, 0)`)}},this._handleScrubberMouseMove=({detail:{time:s,x:t,elementLeft:e,elementRight:i}})=>{var n,o,l,d,f,p,g,v;if(this._currentTime=s,(n=this._sceneController.scenes)!=null&&n.scenes.length){const A=(f=(d=(l=(o=this._sceneController.scenes)==null?void 0:o.scenes)==null?void 0:l.find(({start:E,duration:T,video:w})=>w&&s>=E&&s<=E+T))==null?void 0:d.video)==null?void 0:f.node;if(A&&(A.currentTime=s),this._draw(),(p=this._previewRef)!=null&&p.value){const E=this._previewRef.value.getBoundingClientRect(),T=(g=this._previewRef.value.getRootNode().host)==null?void 0:g.getBoundingClientRect();if(E&&T){const w=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[,C]=Array.from(w.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${Jf(e-T.left,t-T.left-E.width/2,i-T.left-E.width)}px, ${C[1]}px, 0)`}}this._previewTimeRef.value&&this._previewTimeRef.value.setAttribute("content",uh(Math.max(0,Math.min(this._currentTime,(v=this._sceneController.scenes)==null?void 0:v.duration))))}},this._handleScrubberMouseLeave=()=>{var s;(s=this._previewRef)!=null&&s.value&&(this._previewRef.value.style.opacity="0")},this._handleScrubberResize=({detail:{y:s}})=>{var t,e;if((t=this._previewRef)!=null&&t.value){const i=this._previewRef.value.getBoundingClientRect(),n=(e=this._previewRef.value.getRootNode().host)==null?void 0:e.getBoundingClientRect();if(i&&n){const o=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[l]=Array.from(o.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${l[1]}px, ${s-n.top-i.height-28}px, 0)`}}}}_draw(s=this._currentTime){var t,e;this._sceneController.scenes&&this._canvasRef.value&&((e=this.compilation)==null||e.call(this,{currentTime:Math.max(0,Math.min(s,(t=this._sceneController.scenes)==null?void 0:t.duration)),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 s;const{height:t,width:e}=Wl({resolution:180,aspectRatio:this.aspectRatio}),i=((s=this._sceneController.scenes)==null?void 0:s.scenes.length)??0;return!this.disabled&&(this.src||i>1)?Xt`
566
566
  <div
567
567
  ${Ri(this._previewRef)}
568
568
  class="preview"
569
- style=${va({width:this.aspectRatio>1?"140px":void 0,height:this.aspectRatio<=1?"140px":void 0,aspectRatio:this.aspectRatio})}
569
+ style=${ya({width:this.aspectRatio>1?"140px":void 0,height:this.aspectRatio<=1?"140px":void 0,aspectRatio:this.aspectRatio})}
570
570
  >
571
571
  <canvas ${Ri(this._canvasRef)} class="preview-canvas" width=${e} height=${t}></canvas>
572
572
  <vmp-text ${Ri(this._previewTimeRef)} class="preview-text" size="small"></vmp-text>
573
573
  </div>
574
- `:null}};cs.styles=[Le.styles??[],hi`
574
+ `:null}};cs.styles=[_e.styles??[],hi`
575
575
  .preview {
576
576
  position: absolute;
577
577
  display: flex;
@@ -602,7 +602,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
602
602
  color: var(--colors-light-1000);
603
603
  font-variant-numeric: tabular-nums;
604
604
  }
605
- `],qi([Et({type:String})],cs.prototype,"src",2),qi([Et({type:Object})],cs.prototype,"data",2),qi([Et({type:Object})],cs.prototype,"template",2),qi([Et({type:Boolean})],cs.prototype,"disabled",2),qi([Et({type:Number})],cs.prototype,"aspectRatio",2),qi([Et({attribute:!1})],cs.prototype,"compilation",2),cs=qi([Ni("vmp-video-preview-content")],cs);let Ds=class extends Le{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=Vl}render(){return Xt`
605
+ `],qi([Et({type:String})],cs.prototype,"src",2),qi([Et({type:Object})],cs.prototype,"data",2),qi([Et({type:Object})],cs.prototype,"template",2),qi([Et({type:Boolean})],cs.prototype,"disabled",2),qi([Et({type:Number})],cs.prototype,"aspectRatio",2),qi([Et({attribute:!1})],cs.prototype,"compilation",2),cs=qi([Ni("vmp-video-preview-content")],cs);let xs=class extends _e{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=Hl}render(){return Xt`
606
606
  <vmp-video-preview-content
607
607
  ?disabled=${this.disabled}
608
608
  .src=${this.src}
@@ -611,16 +611,16 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
611
611
  .aspectRatio=${this.aspectRatio}
612
612
  .compilation=${this.compilation}
613
613
  ></vmp-video-preview-content>
614
- `}};qi([Et({type:String})],Ds.prototype,"src",2),qi([Et({type:Object})],Ds.prototype,"data",2),qi([Et({type:Object})],Ds.prototype,"template",2),qi([Et({type:Boolean})],Ds.prototype,"disabled",2),qi([Et({type:Number})],Ds.prototype,"aspectRatio",2),qi([Et({attribute:!1})],Ds.prototype,"compilation",2),Ds=qi([Ni("vmp-video-preview")],Ds);class vA extends la{constructor(t){if(super(t),t.type!==En.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}update(t,[e]){return e==null||e(t.element),Es}}const ip=Tn(vA);class yA{constructor(t){this.hiddenControls=[],this._measureRef=Si(),this._prevControlsWidth=0,this._hideables={},this._showables={},this._onResize=e=>{var i,n,o;const l=this._measureRef.value,d=(o=(n=(i=e==null?void 0:e[0])==null?void 0:i.borderBoxSize)==null?void 0:n[0])==null?void 0:o.inlineSize;if(l&&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(;l.scrollWidth>l.offsetWidth;){const p=Object.keys(this._hideables).find(v=>this._hideables[v].hideIndex===f.length);if(!p)break;const g=this._hideables[p].element;g&&(g.style.display="none"),f.push(p),Object.keys(this._showables).forEach(v=>{this._showables[v].showOn.some(A=>f.includes(A))&&(this._showables[v].element.style.display="flex")})}this.hiddenControls=f,this._prevControlsWidth=d,this.host.requestUpdate()}},this.host=t}measure(){return Ri(this._measureRef)}contain(){return dh(this._onResize)}hide(t,e){return ip(i=>{this._hideables[t]={element:i,hideIndex:e}})}show(t,e){return ip(i=>{this._showables[t]={element:i,showOn:e}})}}const fh=`.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)}
615
- `;var bA=Object.defineProperty,AA=Object.getOwnPropertyDescriptor,Oa=(s,t,e,i)=>{for(var n=i>1?void 0:i?AA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&bA(t,e,n),n};let fn=class extends Le{constructor(){super(...arguments),this.semibold=!1,this.truncate=!1,this.size="medium",this.content=""}render(){return Xt`
614
+ `}};qi([Et({type:String})],xs.prototype,"src",2),qi([Et({type:Object})],xs.prototype,"data",2),qi([Et({type:Object})],xs.prototype,"template",2),qi([Et({type:Boolean})],xs.prototype,"disabled",2),qi([Et({type:Number})],xs.prototype,"aspectRatio",2),qi([Et({attribute:!1})],xs.prototype,"compilation",2),xs=qi([Ni("vmp-video-preview")],xs);class bA extends la{constructor(t){if(super(t),t.type!==En.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}update(t,[e]){return e==null||e(t.element),Es}}const ip=Tn(bA);class AA{constructor(t){this.hiddenControls=[],this._measureRef=Si(),this._prevControlsWidth=0,this._hideables={},this._showables={},this._onResize=e=>{var i,n,o;const l=this._measureRef.value,d=(o=(n=(i=e==null?void 0:e[0])==null?void 0:i.borderBoxSize)==null?void 0:n[0])==null?void 0:o.inlineSize;if(l&&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(;l.scrollWidth>l.offsetWidth;){const p=Object.keys(this._hideables).find(v=>this._hideables[v].hideIndex===f.length);if(!p)break;const g=this._hideables[p].element;g&&(g.style.display="none"),f.push(p),Object.keys(this._showables).forEach(v=>{this._showables[v].showOn.some(A=>f.includes(A))&&(this._showables[v].element.style.display="flex")})}this.hiddenControls=f,this._prevControlsWidth=d,this.host.requestUpdate()}},this.host=t}measure(){return Ri(this._measureRef)}contain(){return dh(this._onResize)}hide(t,e){return ip(i=>{this._hideables[t]={element:i,hideIndex:e}})}show(t,e){return ip(i=>{this._showables[t]={element:i,showOn:e}})}}const fh=`.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)}
615
+ `;var EA=Object.defineProperty,TA=Object.getOwnPropertyDescriptor,Ma=(s,t,e,i)=>{for(var n=i>1?void 0:i?TA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&EA(t,e,n),n};let fn=class extends _e{constructor(){super(...arguments),this.semibold=!1,this.truncate=!1,this.size="medium",this.content=""}render(){return Xt`
616
616
  <div
617
617
  part="content"
618
618
  class=${Be({semibold:this.semibold,truncate:this.truncate,[this.size]:!0})}
619
- style=${va({fontFamily:vo({text:this.content,font:"var(--fontFamilies-sans)"})})}
619
+ style=${ya({fontFamily:yo({text:this.content,font:"var(--fontFamilies-sans)"})})}
620
620
  >
621
621
  ${this.content}
622
622
  </div>
623
- `}};fn.styles=[Le.styles??[],hi`
623
+ `}};fn.styles=[_e.styles??[],hi`
624
624
  :host {
625
625
  --text-size: var(--fontSizes-medium);
626
626
  --text-line-height: var(--lineHeights-medium);
@@ -657,7 +657,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
657
657
  text-overflow: ellipsis;
658
658
  overflow: hidden;
659
659
  }
660
- `],Oa([Et({type:Boolean})],fn.prototype,"semibold",2),Oa([Et({type:Boolean})],fn.prototype,"truncate",2),Oa([Et({type:String})],fn.prototype,"size",2),Oa([Et({type:String})],fn.prototype,"content",2),fn=Oa([Ni("vmp-text")],fn);var EA=Object.defineProperty,TA=Object.getOwnPropertyDescriptor,Ma=(s,t,e,i)=>{for(var n=i>1?void 0:i?TA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&EA(t,e,n),n};let pn=class extends Le{constructor(){super(...arguments),this.activeItems=[],this.visibleItems=null,this.subItemsActive=null,this.tippy=null,this._contentRef=Si()}_handleBackClick(){this.subItemsActive=null,this.visibleItems=this.items??null}willUpdate(){this.visibleItems=this.visibleItems??this.items??null}updated(){var s,t;const e=(t=(s=this.items)==null?void 0:s.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 s;const t=(s=this.shadowRoot)==null?void 0:s.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=ln(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 s;super.disconnectedCallback(),(s=this.tippy)==null||s.destroy()}render(){var s,t;return Xt`
660
+ `],Ma([Et({type:Boolean})],fn.prototype,"semibold",2),Ma([Et({type:Boolean})],fn.prototype,"truncate",2),Ma([Et({type:String})],fn.prototype,"size",2),Ma([Et({type:String})],fn.prototype,"content",2),fn=Ma([Ni("vmp-text")],fn);var kA=Object.defineProperty,wA=Object.getOwnPropertyDescriptor,$a=(s,t,e,i)=>{for(var n=i>1?void 0:i?wA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&kA(t,e,n),n};let pn=class extends _e{constructor(){super(...arguments),this.activeItems=[],this.visibleItems=null,this.subItemsActive=null,this.tippy=null,this._contentRef=Si()}_handleBackClick(){this.subItemsActive=null,this.visibleItems=this.items??null}willUpdate(){this.visibleItems=this.visibleItems??this.items??null}updated(){var s,t;const e=(t=(s=this.items)==null?void 0:s.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 s;const t=(s=this.shadowRoot)==null?void 0:s.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=ln(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 s;super.disconnectedCallback(),(s=this.tippy)==null||s.destroy()}render(){var s,t;return Xt`
661
661
  <slot></slot>
662
662
  <div ${Ri(this._contentRef)} class="content">
663
663
  <div class="title">
@@ -683,7 +683,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
683
683
  </button>
684
684
  `)}
685
685
  </div>
686
- `}};pn.styles=[Le.styles??[],ta(fh),hi`
686
+ `}};pn.styles=[_e.styles??[],ta(fh),hi`
687
687
  :host {
688
688
  display: flex;
689
689
  }
@@ -745,12 +745,12 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
745
745
  height: 20px;
746
746
  width: 20px;
747
747
  }
748
- `],Ma([Et({type:Object})],pn.prototype,"items",2),Ma([Et({type:Array})],pn.prototype,"activeItems",2),Ma([vi()],pn.prototype,"visibleItems",2),Ma([vi()],pn.prototype,"subItemsActive",2),pn=Ma([Ni("vmp-menu")],pn);var kA=Object.defineProperty,wA=Object.getOwnPropertyDescriptor,ph=(s,t,e,i)=>{for(var n=i>1?void 0:i?wA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&kA(t,e,n),n};let $a=class extends Le{constructor(){super(...arguments),this.content="",this.disabled=!1,this.tippy=null,this._contentRef=Si()}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var s;const t=(s=this.shadowRoot)==null?void 0:s.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=ln(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!1,placement:"top",zIndex:1e4,appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var s;super.disconnectedCallback(),(s=this.tippy)==null||s.destroy()}updated(){var s,t;this.disabled?(s=this.tippy)==null||s.disable():(t=this.tippy)==null||t.enable()}render(){return Xt`
748
+ `],$a([Et({type:Object})],pn.prototype,"items",2),$a([Et({type:Array})],pn.prototype,"activeItems",2),$a([vi()],pn.prototype,"visibleItems",2),$a([vi()],pn.prototype,"subItemsActive",2),pn=$a([Ni("vmp-menu")],pn);var SA=Object.defineProperty,RA=Object.getOwnPropertyDescriptor,ph=(s,t,e,i)=>{for(var n=i>1?void 0:i?RA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&SA(t,e,n),n};let Fa=class extends _e{constructor(){super(...arguments),this.content="",this.disabled=!1,this.tippy=null,this._contentRef=Si()}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var s;const t=(s=this.shadowRoot)==null?void 0:s.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=ln(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!1,placement:"top",zIndex:1e4,appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var s;super.disconnectedCallback(),(s=this.tippy)==null||s.destroy()}updated(){var s,t;this.disabled?(s=this.tippy)==null||s.disable():(t=this.tippy)==null||t.enable()}render(){return Xt`
749
749
  <slot></slot>
750
750
  <div ${Ri(this._contentRef)} class="content">
751
751
  <vmp-text content=${this.content}></vmp-text>
752
752
  </div>
753
- `}};$a.styles=[Le.styles??[],ta(fh),hi`
753
+ `}};Fa.styles=[_e.styles??[],ta(fh),hi`
754
754
  :host {
755
755
  display: flex;
756
756
  }
@@ -764,7 +764,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
764
764
  background: var(--colors-dark-800);
765
765
  border-radius: var(--radii-medium);
766
766
  }
767
- `],ph([Et({type:String})],$a.prototype,"content",2),ph([Et({type:Boolean})],$a.prototype,"disabled",2),$a=ph([Ni("vmp-tooltip")],$a);var SA=Object.defineProperty,RA=Object.getOwnPropertyDescriptor,gh=(s,t,e,i)=>{for(var n=i>1?void 0:i?RA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&SA(t,e,n),n};let Fa=class extends Le{constructor(){super(...arguments),this.volume=1,this.muted=!1,this.tippy=null,this._contentRef=Si(),this._anchorRef=Si(),this._menuOpen=!1}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{this._anchorRef.value&&this._contentRef.value&&(this.tippy=ln(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 s;super.disconnectedCallback(),(s=this.tippy)==null||s.destroy()}render(){return Xt`
767
+ `],ph([Et({type:String})],Fa.prototype,"content",2),ph([Et({type:Boolean})],Fa.prototype,"disabled",2),Fa=ph([Ni("vmp-tooltip")],Fa);var LA=Object.defineProperty,_A=Object.getOwnPropertyDescriptor,gh=(s,t,e,i)=>{for(var n=i>1?void 0:i?_A(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&LA(t,e,n),n};let Na=class extends _e{constructor(){super(...arguments),this.volume=1,this.muted=!1,this.tippy=null,this._contentRef=Si(),this._anchorRef=Si(),this._menuOpen=!1}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{this._anchorRef.value&&this._contentRef.value&&(this.tippy=ln(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 s;super.disconnectedCallback(),(s=this.tippy)==null||s.destroy()}render(){return Xt`
768
768
  <vmp-icon-button
769
769
  ${Ri(this._anchorRef)}
770
770
  icon=${this.muted||this.volume===0?"muted":this.volume<1/3?"volume-low":this.volume<2/3?"volume-medium":"volume-high"}
@@ -784,7 +784,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
784
784
  @blur=${()=>{var s;return(s=this.tippy)==null?void 0:s.hide()}}
785
785
  />
786
786
  </div>
787
- `}};Fa.styles=[Le.styles??[],ta(fh),hi`
787
+ `}};Na.styles=[_e.styles??[],ta(fh),hi`
788
788
  .content {
789
789
  --volume-slider-height: 4px;
790
790
  --volume-slider-width: 78px;
@@ -912,7 +912,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
912
912
  --volume-slider-height: 8px;
913
913
  color: var(--colors-light-800);
914
914
  }
915
- `],gh([Et({type:Number})],Fa.prototype,"volume",2),gh([Et({type:Boolean})],Fa.prototype,"muted",2),Fa=gh([Ni("vmp-volume-button")],Fa);var _A=Object.defineProperty,LA=Object.getOwnPropertyDescriptor,qo=(s,t,e,i)=>{for(var n=i>1?void 0:i?LA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&_A(t,e,n),n};let Fn=class extends Le{constructor(){super(...arguments),this.duration=0,this.currentTime=0,this.buffer=[],this._containerRef=Si(),this._handleContainerResize=()=>{var s;const t=(s=this._containerRef.value)==null?void 0:s.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:resize",{detail:t,bubbles:!0,composed:!0}))},this._handleMouseEnter=s=>{var t;const e=(t=this._containerRef.value)==null?void 0:t.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:mouseenter",{detail:{x:s.clientX,y:s.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=s=>{var t;const e=(t=this._containerRef.value)==null?void 0:t.getBoundingClientRect(),i=(s.clientX-((e==null?void 0:e.left)??0))/((e==null?void 0:e.width)??1);this.dispatchEvent(new CustomEvent("scrubber:mousemove",{detail:{x:s.clientX,y:s.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=s=>{this.dispatchEvent(new CustomEvent("scrubber:mouseleave",{detail:{x:s.clientX,y:s.clientY},bubbles:!0,composed:!0}))}}render(){var s;const t=((s=this.buffer)==null?void 0:s.sort((e,i)=>e.start<i.start?-1:i.start<e.start?1:0).reduce((e,{start:i,end:n},o)=>{const l=e[o-1],d=Math.floor(i),f=Math.ceil(n);return e.push({id:i,start:Math.max(0,d),end:Math.min(f,100)}),l&&l.end>=i-1&&(e[o].start=l.end),e},[]))??[];return Xt`
915
+ `],gh([Et({type:Number})],Na.prototype,"volume",2),gh([Et({type:Boolean})],Na.prototype,"muted",2),Na=gh([Ni("vmp-volume-button")],Na);var CA=Object.defineProperty,IA=Object.getOwnPropertyDescriptor,Qo=(s,t,e,i)=>{for(var n=i>1?void 0:i?IA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&CA(t,e,n),n};let Fn=class extends _e{constructor(){super(...arguments),this.duration=0,this.currentTime=0,this.buffer=[],this._containerRef=Si(),this._handleContainerResize=()=>{var s;const t=(s=this._containerRef.value)==null?void 0:s.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:resize",{detail:t,bubbles:!0,composed:!0}))},this._handleMouseEnter=s=>{var t;const e=(t=this._containerRef.value)==null?void 0:t.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:mouseenter",{detail:{x:s.clientX,y:s.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=s=>{var t;const e=(t=this._containerRef.value)==null?void 0:t.getBoundingClientRect(),i=(s.clientX-((e==null?void 0:e.left)??0))/((e==null?void 0:e.width)??1);this.dispatchEvent(new CustomEvent("scrubber:mousemove",{detail:{x:s.clientX,y:s.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=s=>{this.dispatchEvent(new CustomEvent("scrubber:mouseleave",{detail:{x:s.clientX,y:s.clientY},bubbles:!0,composed:!0}))}}render(){var s;const t=((s=this.buffer)==null?void 0:s.sort((e,i)=>e.start<i.start?-1:i.start<e.start?1:0).reduce((e,{start:i,end:n},o)=>{const l=e[o-1],d=Math.floor(i),f=Math.ceil(n);return e.push({id:i,start:Math.max(0,d),end:Math.min(f,100)}),l&&l.end>=i-1&&(e[o].start=l.end),e},[]))??[];return Xt`
916
916
  <div
917
917
  class="container"
918
918
  ${Ri(this._containerRef)}
@@ -935,7 +935,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
935
935
  <div class="buffer" style=${`left: ${e.start}%; width: ${e.end-e.start}%`}></div>
936
936
  `)}
937
937
  </div>
938
- `}};Fn.styles=[Le.styles??[],hi`
938
+ `}};Fn.styles=[_e.styles??[],hi`
939
939
  :host {
940
940
  --player-scrubber-height: 8px;
941
941
  --player-scrubber-shadow-width: 4000px;
@@ -1068,7 +1068,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1068
1068
  --player-scrubber-height: 16px;
1069
1069
  color: var(--colors-light-800);
1070
1070
  }
1071
- `],qo([Et({type:Number})],Fn.prototype,"duration",2),qo([Et({type:Number})],Fn.prototype,"currentTime",2),qo([Et({type:Array})],Fn.prototype,"buffer",2),Fn=qo([Ni("vmp-progress-scrubber")],Fn);var CA=Object.defineProperty,IA=Object.getOwnPropertyDescriptor,Ci=(s,t,e,i)=>{for(var n=i>1?void 0:i?IA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&CA(t,e,n),n};let fi=class extends Le{constructor(){super(...arguments),this.resizeHider=new yA(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=hh,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:s}){this.volumeMenuOpen=s}_handleLevelsMenuOpen({detail:s}){this.levelsMenuOpen=s}_handlePlaybackMenuToggle({detail:s}){this.playbackRateMenuOpen=s}_handleSettingsMenuToggle({detail:s}){this.settingsMenuOpen=s}hideMenus(){var s,t;(t=Array.from((s=this.shadowRoot)==null?void 0:s.querySelectorAll("vmp-menu, vmp-tooltip, vmp-volume-button")))==null||t.forEach(e=>{var i;(i=e.tippy)==null||i.hide()})}render(){var s,t,e,i,n,o,l,d,f,p,g,v,A;const E=((s=this.levels)==null?void 0:s.map((G,q)=>{const At=Math.min(G.width,G.height);return{id:`level-${q.toString()}`,event:"level:click",label:`${At}p`,value:{resolution:At,level:q}}}))??[],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},C=(t=T.items)==null?void 0:t.find(({value:G})=>G.level===this.level),x=["levels","playback-rate","captions","fullscreen"].filter(G=>{var q;return(q=this.controls)==null?void 0:q.includes(G)}),O={title:"Settings",items:[X4,Z4,w,q4].filter(({id:G})=>x.includes(G)&&this.resizeHider.hiddenControls.includes(G))},U=(e=this.controls)==null?void 0:e.includes("progress"),D=(i=this.controls)==null?void 0:i.includes("navigation"),H=(n=this.controls)==null?void 0:n.includes("play"),$=(o=this.controls)==null?void 0:o.includes("volume"),z=(l=this.controls)==null?void 0:l.includes("current-time"),tt=(d=this.controls)==null?void 0:d.includes("duration"),at=(f=this.controls)==null?void 0:f.includes("levels"),J=(p=this.controls)==null?void 0:p.includes("speed"),St=(g=this.controls)==null?void 0:g.includes("captions"),mt=(v=this.controls)==null?void 0:v.includes("fullscreen"),Ot=H||$||z||tt||at||J||St||mt,Vt=[`level-${(A=this.level)==null?void 0:A.toString()}`,`playback-rate-${this.playbackRate.toString()}`,this.captions&&"captions",this.fullscreen&&"fullscreen"].filter(Boolean);return Xt`
1071
+ `],Qo([Et({type:Number})],Fn.prototype,"duration",2),Qo([Et({type:Number})],Fn.prototype,"currentTime",2),Qo([Et({type:Array})],Fn.prototype,"buffer",2),Fn=Qo([Ni("vmp-progress-scrubber")],Fn);var xA=Object.defineProperty,DA=Object.getOwnPropertyDescriptor,Ci=(s,t,e,i)=>{for(var n=i>1?void 0:i?DA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&xA(t,e,n),n};let fi=class extends _e{constructor(){super(...arguments),this.resizeHider=new AA(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=hh,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:s}){this.volumeMenuOpen=s}_handleLevelsMenuOpen({detail:s}){this.levelsMenuOpen=s}_handlePlaybackMenuToggle({detail:s}){this.playbackRateMenuOpen=s}_handleSettingsMenuToggle({detail:s}){this.settingsMenuOpen=s}hideMenus(){var s,t;(t=Array.from((s=this.shadowRoot)==null?void 0:s.querySelectorAll("vmp-menu, vmp-tooltip, vmp-volume-button")))==null||t.forEach(e=>{var i;(i=e.tippy)==null||i.hide()})}render(){var s,t,e,i,n,o,l,d,f,p,g,v,A;const E=((s=this.levels)==null?void 0:s.map((V,q)=>{const At=Math.min(V.width,V.height);return{id:`level-${q.toString()}`,event:"level:click",label:`${At}p`,value:{resolution:At,level:q}}}))??[],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},C=(t=T.items)==null?void 0:t.find(({value:V})=>V.level===this.level),D=["levels","playback-rate","captions","fullscreen"].filter(V=>{var q;return(q=this.controls)==null?void 0:q.includes(V)}),M={title:"Settings",items:[q4,Q4,w,J4].filter(({id:V})=>D.includes(V)&&this.resizeHider.hiddenControls.includes(V))},U=(e=this.controls)==null?void 0:e.includes("progress"),x=(i=this.controls)==null?void 0:i.includes("navigation"),G=(n=this.controls)==null?void 0:n.includes("play"),$=(o=this.controls)==null?void 0:o.includes("volume"),Y=(l=this.controls)==null?void 0:l.includes("current-time"),tt=(d=this.controls)==null?void 0:d.includes("duration"),nt=(f=this.controls)==null?void 0:f.includes("levels"),J=(p=this.controls)==null?void 0:p.includes("speed"),St=(g=this.controls)==null?void 0:g.includes("captions"),mt=(v=this.controls)==null?void 0:v.includes("fullscreen"),Ot=G||$||Y||tt||nt||J||St||mt,Vt=[`level-${(A=this.level)==null?void 0:A.toString()}`,`playback-rate-${this.playbackRate.toString()}`,this.captions&&"captions",this.fullscreen&&"fullscreen"].filter(Boolean);return Xt`
1072
1072
  <div
1073
1073
  ${this.resizeHider.measure()}
1074
1074
  ${this.resizeHider.contain()}
@@ -1091,7 +1091,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1091
1091
  <div class="section">
1092
1092
  <div
1093
1093
  ${this.resizeHider.hide("navigation",6)}
1094
- class=${Be({navigation:!0,hidden:!D})}
1094
+ class=${Be({navigation:!0,hidden:!x})}
1095
1095
  >
1096
1096
  <vmp-icon-button
1097
1097
  icon="arrow-left"
@@ -1107,7 +1107,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1107
1107
  ></vmp-icon-button>
1108
1108
  </div>
1109
1109
  <vmp-icon-button
1110
- class=${Be({hidden:!H})}
1110
+ class=${Be({hidden:!G})}
1111
1111
  icon=${this.playing?"pause":"play"}
1112
1112
  weight="heavy"
1113
1113
  rounded="full"
@@ -1123,7 +1123,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1123
1123
  <div class="time">
1124
1124
  <vmp-text
1125
1125
  ${this.resizeHider.hide("current-time",1)}
1126
- class=${Be({hidden:!z})}
1126
+ class=${Be({hidden:!Y})}
1127
1127
  ?semibold=${!0}
1128
1128
  content="${uh(this.currentTime)}${tt?"/":null}"
1129
1129
  ></vmp-text>
@@ -1138,7 +1138,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1138
1138
  <div class="section">
1139
1139
  <vmp-menu
1140
1140
  ${this.resizeHider.hide("levels",0)}
1141
- class=${Be({hidden:!at||E.length<=0})}
1141
+ class=${Be({hidden:!nt||E.length<=0})}
1142
1142
  .items=${T}
1143
1143
  .activeItems=${Vt}
1144
1144
  @menu:toggle=${this._handleLevelsMenuOpen}
@@ -1187,7 +1187,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1187
1187
  </vmp-tooltip>
1188
1188
  <vmp-menu
1189
1189
  ${this.resizeHider.show("settings",["levels","playback-rate","captions","fullscreen"])}
1190
- .items=${O}
1190
+ .items=${M}
1191
1191
  .activeItems=${Vt}
1192
1192
  @menu:toggle=${this._handleSettingsMenuToggle}
1193
1193
  >
@@ -1198,7 +1198,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1198
1198
  </div>
1199
1199
  </div>
1200
1200
  </div>
1201
- `}};fi.styles=[Le.styles??[],hi`
1201
+ `}};fi.styles=[_e.styles??[],hi`
1202
1202
  :host {
1203
1203
  --controls-border-radius: var(--player-border-radius, 0px);
1204
1204
 
@@ -1269,17 +1269,17 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1269
1269
  .hidden {
1270
1270
  display: none;
1271
1271
  }
1272
- `],Ci([Et({type:Boolean})],fi.prototype,"playing",2),Ci([Et({type:Number})],fi.prototype,"volume",2),Ci([Et({type:Boolean})],fi.prototype,"muted",2),Ci([Et({type:Number})],fi.prototype,"currentTime",2),Ci([Et({type:Number})],fi.prototype,"duration",2),Ci([Et({type:Number})],fi.prototype,"level",2),Ci([Et({type:Number})],fi.prototype,"playbackRate",2),Ci([Et({type:Array})],fi.prototype,"buffer",2),Ci([Et({type:Array,attribute:!1})],fi.prototype,"levels",2),Ci([Et({type:Boolean})],fi.prototype,"captions",2),Ci([Et({type:Boolean})],fi.prototype,"fullscreen",2),Ci([Et({type:Array})],fi.prototype,"controls",2),Ci([vi()],fi.prototype,"volumeMenuOpen",2),Ci([vi()],fi.prototype,"levelsMenuOpen",2),Ci([vi()],fi.prototype,"playbackRateMenuOpen",2),Ci([vi()],fi.prototype,"settingsMenuOpen",2),fi=Ci([Ni("vmp-player-controls")],fi);var DA=Object.defineProperty,xA=Object.getOwnPropertyDescriptor,PA=(s,t,e,i)=>{for(var n=i>1?void 0:i?xA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&DA(t,e,n),n};let mh=class extends Le{render(){return Xt`<vmp-icon icon="loading"></vmp-icon>`}};mh.styles=[Le.styles??[],hi`
1272
+ `],Ci([Et({type:Boolean})],fi.prototype,"playing",2),Ci([Et({type:Number})],fi.prototype,"volume",2),Ci([Et({type:Boolean})],fi.prototype,"muted",2),Ci([Et({type:Number})],fi.prototype,"currentTime",2),Ci([Et({type:Number})],fi.prototype,"duration",2),Ci([Et({type:Number})],fi.prototype,"level",2),Ci([Et({type:Number})],fi.prototype,"playbackRate",2),Ci([Et({type:Array})],fi.prototype,"buffer",2),Ci([Et({type:Array,attribute:!1})],fi.prototype,"levels",2),Ci([Et({type:Boolean})],fi.prototype,"captions",2),Ci([Et({type:Boolean})],fi.prototype,"fullscreen",2),Ci([Et({type:Array})],fi.prototype,"controls",2),Ci([vi()],fi.prototype,"volumeMenuOpen",2),Ci([vi()],fi.prototype,"levelsMenuOpen",2),Ci([vi()],fi.prototype,"playbackRateMenuOpen",2),Ci([vi()],fi.prototype,"settingsMenuOpen",2),fi=Ci([Ni("vmp-player-controls")],fi);var PA=Object.defineProperty,OA=Object.getOwnPropertyDescriptor,MA=(s,t,e,i)=>{for(var n=i>1?void 0:i?OA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&PA(t,e,n),n};let mh=class extends _e{render(){return Xt`<vmp-icon icon="loading"></vmp-icon>`}};mh.styles=[_e.styles??[],hi`
1273
1273
  :host {
1274
1274
  display: flex;
1275
1275
  align-items: center;
1276
1276
  justify-content: center;
1277
1277
  }
1278
- `],mh=PA([Ni("vmp-loading-spinner")],mh);var OA=Object.defineProperty,MA=Object.getOwnPropertyDescriptor,rp=(s,t,e,i)=>{for(var n=i>1?void 0:i?MA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&OA(t,e,n),n};let Qo=class extends Le{constructor(){super(...arguments),this.caption=""}render(){return Xt`
1278
+ `],mh=MA([Ni("vmp-loading-spinner")],mh);var $A=Object.defineProperty,FA=Object.getOwnPropertyDescriptor,rp=(s,t,e,i)=>{for(var n=i>1?void 0:i?FA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&$A(t,e,n),n};let Jo=class extends _e{constructor(){super(...arguments),this.caption=""}render(){return Xt`
1279
1279
  <div class="container">
1280
1280
  <vmp-text content=${this.caption} size="large"></vmp-text>
1281
1281
  </div>
1282
- `}};Qo.styles=[Le.styles??[],hi`
1282
+ `}};Jo.styles=[_e.styles??[],hi`
1283
1283
  .container {
1284
1284
  display: block;
1285
1285
  margin: 0 var(--space-small);
@@ -1298,7 +1298,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1298
1298
  /* Line height controls the spacing between the cloned boxes so has to override the default */
1299
1299
  line-height: 2.2;
1300
1300
  }
1301
- `],rp([Et({type:String})],Qo.prototype,"caption",2),Qo=rp([Ni("vmp-captions")],Qo);var $A=Object.defineProperty,FA=Object.getOwnPropertyDescriptor,Pi=(s,t,e,i)=>{for(var n=i>1?void 0:i?FA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&$A(t,e,n),n};const NA=3e3;let bi=class extends Le{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=hh,this.showControls=!0,this._hasTouched=!1,this._playerControlsRef=Si()}_startHideControls(){clearTimeout(this._controlHideTimeout),this._controlHideTimeout=setTimeout(()=>{this.showControls=!1,this._hasTouched=!1},NA)}_immediateShowControls(){this.showControls=!0,clearTimeout(this._controlHideTimeout)}_immediateHideControls(){this.showControls=!1,this._hasTouched=!1,clearTimeout(this._controlHideTimeout)}willUpdate(s){var t;s.has("playing")&&this.playing&&this._startHideControls(),s.has("showControls")&&this.playing&&!this.showControls&&((t=this._playerControlsRef.value)==null||t.hideMenus())}render(){var s;const t=(s=this.controls)==null?void 0:s.includes("play-large"),e=this.playing&&!this.showControls,i=!!(t&&!this.playing);return Xt`
1301
+ `],rp([Et({type:String})],Jo.prototype,"caption",2),Jo=rp([Ni("vmp-captions")],Jo);var NA=Object.defineProperty,UA=Object.getOwnPropertyDescriptor,Pi=(s,t,e,i)=>{for(var n=i>1?void 0:i?UA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&NA(t,e,n),n};const BA=3e3;let bi=class extends _e{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=hh,this.showControls=!0,this._hasTouched=!1,this._playerControlsRef=Si()}_startHideControls(){clearTimeout(this._controlHideTimeout),this._controlHideTimeout=setTimeout(()=>{this.showControls=!1,this._hasTouched=!1},BA)}_immediateShowControls(){this.showControls=!0,clearTimeout(this._controlHideTimeout)}_immediateHideControls(){this.showControls=!1,this._hasTouched=!1,clearTimeout(this._controlHideTimeout)}willUpdate(s){var t;s.has("playing")&&this.playing&&this._startHideControls(),s.has("showControls")&&this.playing&&!this.showControls&&((t=this._playerControlsRef.value)==null||t.hideMenus())}render(){var s;const t=(s=this.controls)==null?void 0:s.includes("play-large"),e=this.playing&&!this.showControls,i=!!(t&&!this.playing);return Xt`
1302
1302
  <div
1303
1303
  class=${Be({container:!0,hide:e})}
1304
1304
  @mousemove=${()=>{this._immediateShowControls(),this._startHideControls()}}
@@ -1344,7 +1344,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1344
1344
  ></vmp-player-controls>
1345
1345
  </div>
1346
1346
  </div>
1347
- `}};bi.styles=[Le.styles??[],hi`
1347
+ `}};bi.styles=[_e.styles??[],hi`
1348
1348
  :host {
1349
1349
  --overlay-border-radius: var(--player-border-radius, 0px);
1350
1350
  }
@@ -1416,7 +1416,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1416
1416
  vmp-captions.hiddenControls {
1417
1417
  transform: translateY(calc(var(--space-small) * -1));
1418
1418
  }
1419
- `],Pi([Et({type:Boolean})],bi.prototype,"loading",2),Pi([Et({type:Boolean})],bi.prototype,"playing",2),Pi([Et({type:Number})],bi.prototype,"volume",2),Pi([Et({type:Boolean})],bi.prototype,"muted",2),Pi([Et({type:Number})],bi.prototype,"currentTime",2),Pi([Et({type:Number})],bi.prototype,"duration",2),Pi([Et({type:Array,attribute:!1})],bi.prototype,"levels",2),Pi([Et({type:Number})],bi.prototype,"level",2),Pi([Et({type:Number})],bi.prototype,"playbackRate",2),Pi([Et({type:String})],bi.prototype,"caption",2),Pi([Et({type:Array})],bi.prototype,"buffer",2),Pi([Et({type:Boolean})],bi.prototype,"captions",2),Pi([Et({type:Boolean})],bi.prototype,"fullscreen",2),Pi([Et({type:Array})],bi.prototype,"controls",2),Pi([vi()],bi.prototype,"showControls",2),bi=Pi([Ni("vmp-player-overlay")],bi);var UA=Object.defineProperty,BA=Object.getOwnPropertyDescriptor,si=(s,t,e,i)=>{for(var n=i>1?void 0:i?BA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&UA(t,e,n),n};const GA=1e3/60;let ii=class extends Le{constructor(){super(...arguments),this.burnCaptions=!1,this.debug=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=Vl,this._sceneController=new K4(this),this._drawController=new bv(this),this._observer=null,this._wasPlaying=!1,this._manualMute=this.muted,this._seekerRAF=null,this._seekerTimeout=null,this._lastWaiting=!1,this._lastTimestamp=null,this._playerRef=Si(),this._canvasRef=Si(),this._pageHidden=document.visibilityState==="hidden",this._aspectRatio=this.propAspectRatio,this._processing=!1,this._waiting=!1,this._errors=[],this._seeking=!1,this._captions=!1,this._fullscreen=!1,this._initialised=null,this._paused=!0,this._playbackRate=1,this._volume=null,this._muted=null,this._videoResolution=-1,this._handleContainerResize=()=>{var s;(s=this.shadowRoot)!=null&&s.host&&!this.propAspectRatio&&(this._aspectRatio=this.shadowRoot.host.clientWidth/this.shadowRoot.host.clientHeight)},this._handleCanvasResize=()=>{this.draw()},this._loop=()=>{this._endLoop(),this._pageHidden?this._seekerTimeout=setTimeout(this._seeker,GA):this._seekerRAF=requestAnimationFrame(this._seeker)},this._endLoop=()=>{this._seekerRAF&&cancelAnimationFrame(this._seekerRAF),this._seekerTimeout&&clearTimeout(this._seekerTimeout),this._seekerRAF=null,this._seekerTimeout=null},this._seeker=(s=performance.now())=>{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")),s-(this._lastTimestamp??0)>1e3/this.sceneConfig.frameRate&&(this._drawController.currentTime=this._drawController.currentTime+(s-(this._lastTimestamp??s))/1e3*this.playbackRate,this._lastTimestamp=s),this._lastWaiting=this._waiting,this._drawController.currentTime>=this.duration&&(this.pause(),this.dispatchEvent(new CustomEvent("ended")))),this.paused||this._loop()},this._handleError=s=>{this._errors=[...this.errors,s.error],s.error.fatal&&this.pause()},this._handleFullscreenChange=()=>{document.fullscreenElement?this._fullscreen=!0:this._fullscreen=!1},this._handleVisibilityChange=()=>{this._pageHidden=document.visibilityState==="hidden",this.paused||this._loop()}}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 initialised(){return this._initialised=this._initialised??new Promise(s=>{const t=setInterval(()=>{this.errors.find(e=>e.fatal)&&s(!1),!this.loading&&!this.processing&&this.scenes.length>0&&s(!0)},500);setTimeout(()=>{clearInterval(t),s(!1)},60*1e3)}),this._initialised}get duration(){return this._sceneController.duration}get scene(){return this._drawController.activeScenes[this._drawController.activeScenes.length-1]}get scenes(){var s;return((s=this._sceneController.scenes)==null?void 0:s.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((s,{video:t,start:e,duration:i})=>{const n=(t==null?void 0:t.key)??`${e}-${i}`;return s[n]=this.videoState[n],s},{})}set paused(s){s!==this._paused&&(this._paused=s,this.requestUpdate(),this.dispatchEvent(new CustomEvent(s?"pause":"play")))}get paused(){return this._paused}set playbackRate(s){s!==this._playbackRate&&(this._playbackRate=s,this.scenes.forEach(({video:t})=>{t&&(t.node.playbackRate=s)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:s})))}get playbackRate(){return this._playbackRate}set volume(s){const t=Math.min(1,Math.max(0,s));t!==this._volume&&(this.scenes.forEach(({video:e})=>{e&&(e.node.volume=t)}),localStorage.setItem("vmp-player-volume",t.toString()),this._volume=t,t>0&&(this.muted=!1),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:s})))}get volume(){return this._volume??(this._volume=parseFloat(localStorage.getItem("vmp-player-volume")??"1"))}set muted(s){this.scenes.forEach(({video:t})=>{t&&(t.node.muted=s)}),s!==this._muted&&(this._muted=s,localStorage.setItem("vmp-player-muted",s.toString()),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:s?0:this.volume})))}get muted(){return this._muted??(this._muted=this.autoplay||localStorage.getItem("vmp-player-muted")==="true")}set videoResolution(s){s!==this._videoResolution&&(this._videoResolution=s,this.scenes.forEach(({video:t})=>{if(t!=null&&t.hls){const e=t.hls.levels.findIndex(i=>Math.min(i.height,i.width)===s);t.hls.currentLevel=e??-1}}),this.requestUpdate())}get videoResolution(){return this._videoResolution}set currentTime(s){s!==this._drawController.currentTime&&(this._drawController.currentTime=s,this._sceneController.setVideosCurrentTime(s))}get currentTime(){return this._drawController.currentTime}reset(s=0,t=!1){this._lastTimestamp=null,this._drawController.currentTime=s,this._sceneController.setVideosCurrentTime(s),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._loop()}pause(){this._endLoop(),this.paused=!0,this.scenes.forEach(({video:s})=>{s&&s.node.pause()})}draw(s){return this._drawController.draw(s)}setScene(s){var t,e;if((t=this._sceneController)!=null&&t.scenes){const i=(e=this.scenes)==null?void 0:e[s];if(!i){const n=new ss(`No scene at index: ${s}`);return this.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:n,message:n.message}))}this.reset(i.start+this._sceneController.scenes.transitionDuration,!this.paused)}}toggleFullscreen(s){s??this.fullscreen?Y4():this._playerRef.value&&z4(this._playerRef.value)}connectedCallback(){var s;super.connectedCallback(),this.addEventListener("error",this._handleError),document.addEventListener("fullscreenchange",this._handleFullscreenChange),document.addEventListener("visibilitychange",this._handleVisibilityChange),(s=this.shadowRoot)!=null&&s.host&&(this._observer=new ResizeObserver(this._handleContainerResize),this._observer.observe(this.shadowRoot.host))}willUpdate(){this.propAspectRatio&&(this._aspectRatio=this.propAspectRatio)}updated(s){s.has("propAspectRatio")&&!this.propAspectRatio&&this._handleContainerResize(),this.autoplay&&!this.processing&&!this._sceneController.hasPlayed&&s.has("_processing")&&this.play()}disconnectedCallback(){var s;super.disconnectedCallback(),(s=this._observer)==null||s.disconnect(),document.removeEventListener("fullscreenchange",this._handleFullscreenChange),document.removeEventListener("visibilitychange",this._handleVisibilityChange)}_renderStyles(){return this.propAspectRatio?typeof this.propAspectRatio=="number"?Xt`
1419
+ `],Pi([Et({type:Boolean})],bi.prototype,"loading",2),Pi([Et({type:Boolean})],bi.prototype,"playing",2),Pi([Et({type:Number})],bi.prototype,"volume",2),Pi([Et({type:Boolean})],bi.prototype,"muted",2),Pi([Et({type:Number})],bi.prototype,"currentTime",2),Pi([Et({type:Number})],bi.prototype,"duration",2),Pi([Et({type:Array,attribute:!1})],bi.prototype,"levels",2),Pi([Et({type:Number})],bi.prototype,"level",2),Pi([Et({type:Number})],bi.prototype,"playbackRate",2),Pi([Et({type:String})],bi.prototype,"caption",2),Pi([Et({type:Array})],bi.prototype,"buffer",2),Pi([Et({type:Boolean})],bi.prototype,"captions",2),Pi([Et({type:Boolean})],bi.prototype,"fullscreen",2),Pi([Et({type:Array})],bi.prototype,"controls",2),Pi([vi()],bi.prototype,"showControls",2),bi=Pi([Ni("vmp-player-overlay")],bi);var GA=Object.defineProperty,VA=Object.getOwnPropertyDescriptor,si=(s,t,e,i)=>{for(var n=i>1?void 0:i?VA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&GA(t,e,n),n};const HA=1e3/60;let ii=class extends _e{constructor(){super(...arguments),this.burnCaptions=!1,this.debug=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=Hl,this._sceneController=new z4(this),this._drawController=new Ev(this),this._observer=null,this._wasPlaying=!1,this._manualMute=this.muted,this._seekerRAF=null,this._seekerTimeout=null,this._lastWaiting=!1,this._lastTimestamp=null,this._playerRef=Si(),this._canvasRef=Si(),this._pageHidden=document.visibilityState==="hidden",this._aspectRatio=this.propAspectRatio,this._processing=!1,this._waiting=!1,this._errors=[],this._seeking=!1,this._captions=!1,this._fullscreen=!1,this._initialised=null,this._paused=!0,this._playbackRate=1,this._volume=null,this._muted=null,this._videoResolution=-1,this._handleContainerResize=()=>{var s;(s=this.shadowRoot)!=null&&s.host&&!this.propAspectRatio&&(this._aspectRatio=this.shadowRoot.host.clientWidth/this.shadowRoot.host.clientHeight)},this._handleCanvasResize=()=>{this.draw()},this._loop=()=>{this._endLoop(),this._pageHidden?this._seekerTimeout=setTimeout(this._seeker,HA):this._seekerRAF=requestAnimationFrame(this._seeker)},this._endLoop=()=>{this._seekerRAF&&cancelAnimationFrame(this._seekerRAF),this._seekerTimeout&&clearTimeout(this._seekerTimeout),this._seekerRAF=null,this._seekerTimeout=null},this._seeker=(s=performance.now())=>{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")),s-(this._lastTimestamp??0)>1e3/this.sceneConfig.frameRate&&(this._drawController.currentTime=this._drawController.currentTime+(s-(this._lastTimestamp??s))/1e3*this.playbackRate,this._lastTimestamp=s),this._lastWaiting=this._waiting,this._drawController.currentTime>=this.duration&&(this.pause(),this.dispatchEvent(new CustomEvent("ended")))),this.paused||this._loop()},this._handleError=s=>{this._errors=[...this.errors,s.error],s.error.fatal&&this.pause()},this._handleFullscreenChange=()=>{document.fullscreenElement?this._fullscreen=!0:this._fullscreen=!1},this._handleVisibilityChange=()=>{this._pageHidden=document.visibilityState==="hidden",this.paused||this._loop()}}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 initialised(){return this._initialised=this._initialised??new Promise(s=>{const t=setInterval(()=>{this.errors.find(e=>e.fatal)&&s(!1),!this.loading&&!this.processing&&this.scenes.length>0&&s(!0)},500);setTimeout(()=>{clearInterval(t),s(!1)},60*1e3)}),this._initialised}get duration(){return this._sceneController.duration}get scene(){return this._drawController.activeScenes[this._drawController.activeScenes.length-1]}get scenes(){var s;return((s=this._sceneController.scenes)==null?void 0:s.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((s,{video:t,start:e,duration:i})=>{const n=(t==null?void 0:t.key)??`${e}-${i}`;return s[n]=this.videoState[n],s},{})}set paused(s){s!==this._paused&&(this._paused=s,this.requestUpdate(),this.dispatchEvent(new CustomEvent(s?"pause":"play")))}get paused(){return this._paused}set playbackRate(s){s!==this._playbackRate&&(this._playbackRate=s,this.scenes.forEach(({video:t})=>{t&&(t.node.playbackRate=s)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:s})))}get playbackRate(){return this._playbackRate}set volume(s){const t=Math.min(1,Math.max(0,s));t!==this._volume&&(this.scenes.forEach(({video:e})=>{e&&(e.node.volume=t)}),localStorage.setItem("vmp-player-volume",t.toString()),this._volume=t,t>0&&(this.muted=!1),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:s})))}get volume(){return this._volume??(this._volume=parseFloat(localStorage.getItem("vmp-player-volume")??"1"))}set muted(s){this.scenes.forEach(({video:t})=>{t&&(t.node.muted=s)}),s!==this._muted&&(this._muted=s,localStorage.setItem("vmp-player-muted",s.toString()),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:s?0:this.volume})))}get muted(){return this._muted??(this._muted=this.autoplay||localStorage.getItem("vmp-player-muted")==="true")}set videoResolution(s){s!==this._videoResolution&&(this._videoResolution=s,this.scenes.forEach(({video:t})=>{if(t!=null&&t.hls){const e=t.hls.levels.findIndex(i=>Math.min(i.height,i.width)===s);t.hls.currentLevel=e??-1}}),this.requestUpdate())}get videoResolution(){return this._videoResolution}set currentTime(s){s!==this._drawController.currentTime&&(this._drawController.currentTime=s,this._sceneController.setVideosCurrentTime(s))}get currentTime(){return this._drawController.currentTime}reset(s=0,t=!1){this._lastTimestamp=null,this._drawController.currentTime=s,this._sceneController.setVideosCurrentTime(s),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._loop()}pause(){this._endLoop(),this.paused=!0,this.scenes.forEach(({video:s})=>{s&&s.node.pause()})}draw(s){return this._drawController.draw(s)}setScene(s){var t,e;if((t=this._sceneController)!=null&&t.scenes){const i=(e=this.scenes)==null?void 0:e[s];if(!i){const n=new Nr(`No scene at index: ${s}`);return this.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:n,message:n.message}))}this.reset(i.start+this._sceneController.scenes.transitionDuration,!this.paused)}}toggleFullscreen(s){s??this.fullscreen?Z4():this._playerRef.value&&X4(this._playerRef.value)}connectedCallback(){var s;super.connectedCallback(),this.addEventListener("error",this._handleError),document.addEventListener("fullscreenchange",this._handleFullscreenChange),document.addEventListener("visibilitychange",this._handleVisibilityChange),(s=this.shadowRoot)!=null&&s.host&&(this._observer=new ResizeObserver(this._handleContainerResize),this._observer.observe(this.shadowRoot.host))}willUpdate(){this.propAspectRatio&&(this._aspectRatio=this.propAspectRatio)}updated(s){s.has("propAspectRatio")&&!this.propAspectRatio&&this._handleContainerResize(),this.autoplay&&!this.processing&&!this._sceneController.hasPlayed&&s.has("_processing")&&this.play()}disconnectedCallback(){var s;super.disconnectedCallback(),(s=this._observer)==null||s.disconnect(),document.removeEventListener("fullscreenchange",this._handleFullscreenChange),document.removeEventListener("visibilitychange",this._handleVisibilityChange)}_renderStyles(){return this.propAspectRatio?typeof this.propAspectRatio=="number"?Xt`
1420
1420
  <style>
1421
1421
  :host {
1422
1422
  aspect-ratio: ${this.propAspectRatio};
@@ -1437,14 +1437,14 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1437
1437
  <vmp-text semibold content="An error has occurred when attempting to play this video."></vmp-text>
1438
1438
  <vmp-text semibold content="Please try again later."></vmp-text>
1439
1439
  </div>
1440
- </div>`}render(){var s,t,e,i,n,o;const l=this.loading||this.processing||!this.scenes||this.duration<=0,{height:d,width:f}=Hl({resolution:((s=this.sceneConfig)==null?void 0:s.resolution)??720,aspectRatio:this.aspectRatio}),p=Object.keys(this.sceneVideoState).reduce((O,U)=>O.concat(this.sceneVideoState[U].buffered??[]),[]),g=l?[]:(t=this.controls??hh)==null?void 0:t.filter(O=>!(O==="fullscreen"&&W4()||O==="navigation"&&(!this.scenes||this.scenes.length<=1))),v=!(g!=null&&g.includes("preview")),A=(((e=this.scenes)==null?void 0:e.length)??0)-1,E=((i=this.scenes)==null?void 0:i.findIndex(O=>O===this._drawController.activeScenes[0]))??0,T=(o=(n=this._drawController.activeScenes[0])==null?void 0:n.video)==null?void 0:o.hls,w=this.loading||this.waiting||this.processing,C=!this.src&&!this.data,x=!!this.errors.find(O=>O.fatal);return Xt`
1440
+ </div>`}render(){var s,t,e,i,n,o;const l=this.loading||this.processing||!this.scenes||this.duration<=0,{height:d,width:f}=Wl({resolution:((s=this.sceneConfig)==null?void 0:s.resolution)??720,aspectRatio:this.aspectRatio}),p=Object.keys(this.sceneVideoState).reduce((M,U)=>M.concat(this.sceneVideoState[U].buffered??[]),[]),g=l?[]:(t=this.controls??hh)==null?void 0:t.filter(M=>!(M==="fullscreen"&&K4()||M==="navigation"&&(!this.scenes||this.scenes.length<=1))),v=!(g!=null&&g.includes("preview")),A=(((e=this.scenes)==null?void 0:e.length)??0)-1,E=((i=this.scenes)==null?void 0:i.findIndex(M=>M===this._drawController.activeScenes[0]))??0,T=(o=(n=this._drawController.activeScenes[0])==null?void 0:n.video)==null?void 0:o.hls,w=this.loading||this.waiting||this.processing,C=!this.src&&!this.data,D=!!this.errors.find(M=>M.fatal);return Xt`
1441
1441
  ${this._renderStyles()}
1442
1442
  <div
1443
1443
  ${Ri(this._playerRef)}
1444
1444
  class=${Be({player:!0,responsive:!this.propAspectRatio})}
1445
- style=${va({aspectRatio:this.aspectRatio})}
1445
+ style=${ya({aspectRatio:this.aspectRatio})}
1446
1446
  >
1447
- ${!w&&(C||x)?this._renderError():Xt`<canvas
1447
+ ${!w&&(C||D)?this._renderError():Xt`<canvas
1448
1448
  ${Ri(this._canvasRef)}
1449
1449
  ${this._drawController.canvas()}
1450
1450
  ${dh(this._handleCanvasResize)}
@@ -1469,17 +1469,17 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1469
1469
  .controls=${g}
1470
1470
  ?captions=${this.captions}
1471
1471
  ?fullscreen=${this.fullscreen}
1472
- @navigate:back=${O=>{O.defaultPrevented||this.setScene(E<=0?A:E-1)}}
1473
- @navigate:forward=${O=>{O.defaultPrevented||this.setScene(E>=A?0:E+1)}}
1474
- @play:click=${({detail:O})=>{l||(O?this.pause():(this.muted=this._manualMute,this.play()))}}
1475
- @volume:click=${({detail:O})=>{this.muted=!O,this._manualMute=!O}}
1476
- @level:click=${({detail:O})=>{this.videoResolution=O.value.resolution}}
1477
- @playbackRate:click=${({detail:O})=>{this.playbackRate=O.value??1}}
1472
+ @navigate:back=${M=>{M.defaultPrevented||this.setScene(E<=0?A:E-1)}}
1473
+ @navigate:forward=${M=>{M.defaultPrevented||this.setScene(E>=A?0:E+1)}}
1474
+ @play:click=${({detail:M})=>{l||(M?this.pause():(this.muted=this._manualMute,this.play()))}}
1475
+ @volume:click=${({detail:M})=>{this.muted=!M,this._manualMute=!M}}
1476
+ @level:click=${({detail:M})=>{this.videoResolution=M.value.resolution}}
1477
+ @playbackRate:click=${({detail:M})=>{this.playbackRate=M.value??1}}
1478
1478
  @captions:click=${()=>{this._captions=!this._captions}}
1479
1479
  @fullscreen:click=${()=>{this.toggleFullscreen()}}
1480
- @input=${O=>{const U=O.composedPath()[0],D=U.getAttribute("key");if(D==="scrubber"){const H=parseFloat(U.value);this._drawController.currentTime=H,this._sceneController.setVideosCurrentTime(H),this.dispatchEvent(new CustomEvent("seeking",{detail:H}))}D==="volume"&&(this.volume=parseFloat(U.value))}}
1481
- @pointerdown=${O=>{O.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!0,this._wasPlaying=!this.paused,this.paused||this.pause())}}
1482
- @pointerup=${O=>{O.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!1,this._wasPlaying&&(this.play(),this._wasPlaying=!1),this.dispatchEvent(new CustomEvent("seeked",{detail:this._drawController.currentTime})))}}
1480
+ @input=${M=>{const U=M.composedPath()[0],x=U.getAttribute("key");if(x==="scrubber"){const G=parseFloat(U.value);this._drawController.currentTime=G,this._sceneController.setVideosCurrentTime(G),this.dispatchEvent(new CustomEvent("seeking",{detail:G}))}x==="volume"&&(this.volume=parseFloat(U.value))}}
1481
+ @pointerdown=${M=>{M.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!0,this._wasPlaying=!this.paused,this.paused||this.pause())}}
1482
+ @pointerup=${M=>{M.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!1,this._wasPlaying&&(this.play(),this._wasPlaying=!1),this.dispatchEvent(new CustomEvent("seeked",{detail:this._drawController.currentTime})))}}
1483
1483
  ></vmp-player-overlay>
1484
1484
  <vmp-video-preview
1485
1485
  ?disabled=${v}
@@ -1490,7 +1490,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1490
1490
  .compilation=${this.compilation}
1491
1491
  ></vmp-video-preview>`}
1492
1492
  </div>
1493
- `}};ii.styles=[Le.styles??[],hi`
1493
+ `}};ii.styles=[_e.styles??[],hi`
1494
1494
  :host {
1495
1495
  --player-border-radius: var(--vouch-media-player-border-radius, 0px);
1496
1496
 
@@ -1551,7 +1551,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1551
1551
  top: 0;
1552
1552
  left: 0;
1553
1553
  }
1554
- `],si([Et({type:Object})],ii.prototype,"data",2),si([Et({type:Object})],ii.prototype,"template",2),si([Et({type:Boolean})],ii.prototype,"burnCaptions",2),si([Et({type:Boolean})],ii.prototype,"debug",2),si([Et({type:String})],ii.prototype,"src",2),si([Et({type:String})],ii.prototype,"track",2),si([Et({type:Number,attribute:"aspectratio"})],ii.prototype,"propAspectRatio",2),si([Et({type:String})],ii.prototype,"preload",2),si([Et({type:Boolean})],ii.prototype,"autoplay",2),si([Et({type:Boolean})],ii.prototype,"loading",2),si([Et({type:Array})],ii.prototype,"controls",2),si([Et({attribute:!1})],ii.prototype,"compilation",2),si([vi()],ii.prototype,"_pageHidden",2),si([vi()],ii.prototype,"_aspectRatio",2),si([vi()],ii.prototype,"_processing",2),si([vi()],ii.prototype,"_waiting",2),si([vi()],ii.prototype,"_errors",2),si([vi()],ii.prototype,"_seeking",2),si([vi()],ii.prototype,"_captions",2),si([vi()],ii.prototype,"_fullscreen",2),ii=si([Ni("vmp-media-player")],ii);var VA=Object.defineProperty,HA=Object.getOwnPropertyDescriptor,Ui=(s,t,e,i)=>{for(var n=i>1?void 0:i?HA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&VA(t,e,n),n};ie.PlayerEmbed=class extends Um(ts){constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="auto",this.autoplay=!1,this.aspectRatio=0,this.eventController=new Tg(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 Kg(this),this._trackingController=new Nm(this)}get fetching(){return this._fetcherController.fetching}_renderStyles(){return this.aspectRatio?typeof this.aspectRatio=="number"?Xt`
1554
+ `],si([Et({type:Object})],ii.prototype,"data",2),si([Et({type:Object})],ii.prototype,"template",2),si([Et({type:Boolean})],ii.prototype,"burnCaptions",2),si([Et({type:Boolean})],ii.prototype,"debug",2),si([Et({type:String})],ii.prototype,"src",2),si([Et({type:String})],ii.prototype,"track",2),si([Et({type:Number,attribute:"aspectratio"})],ii.prototype,"propAspectRatio",2),si([Et({type:String})],ii.prototype,"preload",2),si([Et({type:Boolean})],ii.prototype,"autoplay",2),si([Et({type:Boolean})],ii.prototype,"loading",2),si([Et({type:Array})],ii.prototype,"controls",2),si([Et({attribute:!1})],ii.prototype,"compilation",2),si([vi()],ii.prototype,"_pageHidden",2),si([vi()],ii.prototype,"_aspectRatio",2),si([vi()],ii.prototype,"_processing",2),si([vi()],ii.prototype,"_waiting",2),si([vi()],ii.prototype,"_errors",2),si([vi()],ii.prototype,"_seeking",2),si([vi()],ii.prototype,"_captions",2),si([vi()],ii.prototype,"_fullscreen",2),ii=si([Ni("vmp-media-player")],ii);var WA=Object.defineProperty,jA=Object.getOwnPropertyDescriptor,Ui=(s,t,e,i)=>{for(var n=i>1?void 0:i?jA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&WA(t,e,n),n};ie.PlayerEmbed=class extends Gm(es){constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="auto",this.autoplay=!1,this.aspectRatio=0,this.eventController=new Tg(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 Kg(this),this._trackingController=new Bm(this)}get fetching(){return this._fetcherController.fetching}_renderStyles(){return this.aspectRatio?typeof this.aspectRatio=="number"?Xt`
1555
1555
  <style>
1556
1556
  :host {
1557
1557
  aspect-ratio: ${this.aspectRatio};
@@ -1581,12 +1581,12 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1581
1581
  :host {
1582
1582
  display: flex;
1583
1583
  }
1584
- `],Ui([Et({type:Object})],ie.PlayerEmbed.prototype,"data",2),Ui([Et({type:String})],ie.PlayerEmbed.prototype,"vouchId",2),Ui([Et({type:String})],ie.PlayerEmbed.prototype,"templateId",2),Ui([Et({type:Array})],ie.PlayerEmbed.prototype,"questions",2),Ui([Et({type:String})],ie.PlayerEmbed.prototype,"env",2),Ui([Et({type:String})],ie.PlayerEmbed.prototype,"apiKey",2),Ui([Et({type:Boolean})],ie.PlayerEmbed.prototype,"disableTracking",2),Ui([Et({type:String})],ie.PlayerEmbed.prototype,"trackingSource",2),Ui([Et({type:Array})],ie.PlayerEmbed.prototype,"controls",2),Ui([Et({type:String})],ie.PlayerEmbed.prototype,"preload",2),Ui([Et({type:Boolean})],ie.PlayerEmbed.prototype,"autoplay",2),Ui([Et({type:Number})],ie.PlayerEmbed.prototype,"aspectRatio",2),Ui([vi()],ie.PlayerEmbed.prototype,"vouch",2),Ui([vi()],ie.PlayerEmbed.prototype,"template",2),ie.PlayerEmbed=Ui([to("vouch-embed-player")],ie.PlayerEmbed);function Jo(s,t,e,i=20,n=0){let o=[];if(n>=i)return o;const l=f=>{const p=f.assignedNodes().filter(g=>g.nodeType===1);return p.length>0?Jo(p[0].parentElement,t,e,i,n+1):[]},d=Array.from(s.children||[]);for(const f of d)t(f)||(e(f)&&o.push(f),f.shadowRoot!=null?o.push(...Jo(f.shadowRoot,t,e,i,n+1)):f.tagName==="SLOT"?o.push(...l(f)):o.push(...Jo(f,t,e,i,n+1)));return o}function sp(s){return s.hasAttribute("hidden")||s.hasAttribute("aria-hidden")&&s.getAttribute("aria-hidden")!=="false"||s.style.display==="none"||s.style.opacity==="0"||s.style.visibility==="hidden"||s.style.visibility==="collapse"}function WA(s){return s.hasAttribute("disabled")||s.hasAttribute("aria-disabled")&&s.getAttribute("aria-disabled")!=="false"}function jA(s){return s.getAttribute("tabindex")==="-1"||sp(s)||WA(s)?!1:s.hasAttribute("tabindex")||(s instanceof HTMLAnchorElement||s instanceof HTMLAreaElement)&&s.hasAttribute("href")||s instanceof HTMLButtonElement||s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement||s instanceof HTMLIFrameElement}const vh=new Map;function KA(s,t,e){const i=vh.get(e);i!=null&&window.clearTimeout(i),vh.set(e,window.setTimeout(()=>{s(),vh.delete(e)},t))}const np=document.createElement("template");np.innerHTML=`
1584
+ `],Ui([Et({type:Object})],ie.PlayerEmbed.prototype,"data",2),Ui([Et({type:String})],ie.PlayerEmbed.prototype,"vouchId",2),Ui([Et({type:String})],ie.PlayerEmbed.prototype,"templateId",2),Ui([Et({type:Array})],ie.PlayerEmbed.prototype,"questions",2),Ui([Et({type:String})],ie.PlayerEmbed.prototype,"env",2),Ui([Et({type:String})],ie.PlayerEmbed.prototype,"apiKey",2),Ui([Et({type:Boolean})],ie.PlayerEmbed.prototype,"disableTracking",2),Ui([Et({type:String})],ie.PlayerEmbed.prototype,"trackingSource",2),Ui([Et({type:Array})],ie.PlayerEmbed.prototype,"controls",2),Ui([Et({type:String})],ie.PlayerEmbed.prototype,"preload",2),Ui([Et({type:Boolean})],ie.PlayerEmbed.prototype,"autoplay",2),Ui([Et({type:Number})],ie.PlayerEmbed.prototype,"aspectRatio",2),Ui([vi()],ie.PlayerEmbed.prototype,"vouch",2),Ui([vi()],ie.PlayerEmbed.prototype,"template",2),ie.PlayerEmbed=Ui([eo("vouch-embed-player")],ie.PlayerEmbed);function tl(s,t,e,i=20,n=0){let o=[];if(n>=i)return o;const l=f=>{const p=f.assignedNodes().filter(g=>g.nodeType===1);return p.length>0?tl(p[0].parentElement,t,e,i,n+1):[]},d=Array.from(s.children||[]);for(const f of d)t(f)||(e(f)&&o.push(f),f.shadowRoot!=null?o.push(...tl(f.shadowRoot,t,e,i,n+1)):f.tagName==="SLOT"?o.push(...l(f)):o.push(...tl(f,t,e,i,n+1)));return o}function sp(s){return s.hasAttribute("hidden")||s.hasAttribute("aria-hidden")&&s.getAttribute("aria-hidden")!=="false"||s.style.display==="none"||s.style.opacity==="0"||s.style.visibility==="hidden"||s.style.visibility==="collapse"}function KA(s){return s.hasAttribute("disabled")||s.hasAttribute("aria-disabled")&&s.getAttribute("aria-disabled")!=="false"}function YA(s){return s.getAttribute("tabindex")==="-1"||sp(s)||KA(s)?!1:s.hasAttribute("tabindex")||(s instanceof HTMLAnchorElement||s instanceof HTMLAreaElement)&&s.hasAttribute("href")||s instanceof HTMLButtonElement||s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement||s instanceof HTMLIFrameElement}const vh=new Map;function zA(s,t,e){const i=vh.get(e);i!=null&&window.clearTimeout(i),vh.set(e,window.setTimeout(()=>{s(),vh.delete(e)},t))}const np=document.createElement("template");np.innerHTML=`
1585
1585
  <div id="start"></div>
1586
1586
  <div id="backup"></div>
1587
1587
  <slot></slot>
1588
1588
  <div id="end"></div>
1589
- `;class zA extends HTMLElement{constructor(){super(),this.debounceId=Math.random().toString(),this._focused=!1;const t=this.attachShadow({mode:"open"});t.appendChild(np.content.cloneNode(!0)),this.$backup=t.querySelector("#backup"),this.$start=t.querySelector("#start"),this.$end=t.querySelector("#end"),this.focusLastElement=this.focusLastElement.bind(this),this.focusFirstElement=this.focusFirstElement.bind(this),this.onFocusIn=this.onFocusIn.bind(this),this.onFocusOut=this.onFocusOut.bind(this)}static get observedAttributes(){return["inactive"]}get inactive(){return this.hasAttribute("inactive")}set inactive(t){t?this.setAttribute("inactive",""):this.removeAttribute("inactive")}get focused(){return this._focused}connectedCallback(){this.$start.addEventListener("focus",this.focusLastElement),this.$end.addEventListener("focus",this.focusFirstElement),this.addEventListener("focusin",this.onFocusIn),this.addEventListener("focusout",this.onFocusOut),this.render()}disconnectedCallback(){this.$start.removeEventListener("focus",this.focusLastElement),this.$end.removeEventListener("focus",this.focusFirstElement),this.removeEventListener("focusin",this.onFocusIn),this.removeEventListener("focusout",this.onFocusOut)}attributeChangedCallback(){this.render()}focusFirstElement(){this.trapFocus()}focusLastElement(){this.trapFocus(!0)}getFocusableElements(){return Jo(this,sp,jA)}trapFocus(t){if(this.inactive)return;let e=this.getFocusableElements();e.length>0?(t?e[e.length-1].focus():e[0].focus(),this.$backup.setAttribute("tabindex","-1")):(this.$backup.setAttribute("tabindex","0"),this.$backup.focus())}onFocusIn(){this.updateFocused(!0)}onFocusOut(){this.updateFocused(!1)}updateFocused(t){KA(()=>{this.focused!==t&&(this._focused=t,this.render())},0,this.debounceId)}render(){this.$start.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.$end.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.focused?this.setAttribute("focused",""):this.removeAttribute("focused")}}window.customElements.define("focus-trap",zA);var YA=Object.defineProperty,XA=Object.getOwnPropertyDescriptor,yh=(s,t,e,i)=>{for(var n=i>1?void 0:i?XA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&YA(t,e,n),n};let Na=class extends ts{constructor(){super(...arguments),this.open=!1,this.aspectRatio=0}render(){return Xt`
1589
+ `;class XA extends HTMLElement{constructor(){super(),this.debounceId=Math.random().toString(),this._focused=!1;const t=this.attachShadow({mode:"open"});t.appendChild(np.content.cloneNode(!0)),this.$backup=t.querySelector("#backup"),this.$start=t.querySelector("#start"),this.$end=t.querySelector("#end"),this.focusLastElement=this.focusLastElement.bind(this),this.focusFirstElement=this.focusFirstElement.bind(this),this.onFocusIn=this.onFocusIn.bind(this),this.onFocusOut=this.onFocusOut.bind(this)}static get observedAttributes(){return["inactive"]}get inactive(){return this.hasAttribute("inactive")}set inactive(t){t?this.setAttribute("inactive",""):this.removeAttribute("inactive")}get focused(){return this._focused}connectedCallback(){this.$start.addEventListener("focus",this.focusLastElement),this.$end.addEventListener("focus",this.focusFirstElement),this.addEventListener("focusin",this.onFocusIn),this.addEventListener("focusout",this.onFocusOut),this.render()}disconnectedCallback(){this.$start.removeEventListener("focus",this.focusLastElement),this.$end.removeEventListener("focus",this.focusFirstElement),this.removeEventListener("focusin",this.onFocusIn),this.removeEventListener("focusout",this.onFocusOut)}attributeChangedCallback(){this.render()}focusFirstElement(){this.trapFocus()}focusLastElement(){this.trapFocus(!0)}getFocusableElements(){return tl(this,sp,YA)}trapFocus(t){if(this.inactive)return;let e=this.getFocusableElements();e.length>0?(t?e[e.length-1].focus():e[0].focus(),this.$backup.setAttribute("tabindex","-1")):(this.$backup.setAttribute("tabindex","0"),this.$backup.focus())}onFocusIn(){this.updateFocused(!0)}onFocusOut(){this.updateFocused(!1)}updateFocused(t){zA(()=>{this.focused!==t&&(this._focused=t,this.render())},0,this.debounceId)}render(){this.$start.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.$end.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.focused?this.setAttribute("focused",""):this.removeAttribute("focused")}}window.customElements.define("focus-trap",XA);var ZA=Object.defineProperty,qA=Object.getOwnPropertyDescriptor,yh=(s,t,e,i)=>{for(var n=i>1?void 0:i?qA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&ZA(t,e,n),n};let Ua=class extends es{constructor(){super(...arguments),this.open=!1,this.aspectRatio=0}render(){return Xt`
1590
1590
  <div
1591
1591
  class=${Be({container:!0,hidden:!this.open})}
1592
1592
  >
@@ -1597,7 +1597,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1597
1597
  <focus-trap>
1598
1598
  <div
1599
1599
  class=${Be({"video-frame":!0,grow:this.aspectRatio===0})}
1600
- style=${va({aspectRatio:this.aspectRatio})}
1600
+ style=${ya({aspectRatio:this.aspectRatio})}
1601
1601
  >
1602
1602
  <slot></slot>
1603
1603
  <vmp-icon-button
@@ -1609,7 +1609,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1609
1609
  </div>
1610
1610
  </focus-trap>
1611
1611
  </div>
1612
- `}};Na.styles=[hi`
1612
+ `}};Ua.styles=[hi`
1613
1613
  :host {
1614
1614
  --vouch-media-player-border-radius: var(--vu-media-player-border-radius, 12px);
1615
1615
  --overlay-background-color: var(--vu-overlay-background-color, black);
@@ -1672,11 +1672,11 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1672
1672
  right: 0;
1673
1673
  margin: 10px;
1674
1674
  }
1675
- `],yh([Et({type:Boolean})],Na.prototype,"open",2),yh([Et({type:Number})],Na.prototype,"aspectRatio",2),Na=yh([to("vouch-embed-dialog-overlay")],Na);var ZA=Object.defineProperty,qA=Object.getOwnPropertyDescriptor,nr=(s,t,e,i)=>{for(var n=i>1?void 0:i?qA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&ZA(t,e,n),n};let Qi=class extends ts{constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="none",this.disableAutoplay=!1,this.aspectRatio=0,this._mediaPlayerRef=Si(),this.open=!1,this._handleToggle=()=>{var s,t,e;this.open=!this.open,this.open?!this.disableAutoplay&&((s=this._mediaPlayerRef)!=null&&s.value)&&(this._mediaPlayerRef.value.muted=!1,this._mediaPlayerRef.value.play()):(e=(t=this._mediaPlayerRef)==null?void 0:t.value)==null||e.pause()},this._handleClose=()=>{var s,t;this.open=!1,(t=(s=this._mediaPlayerRef)==null?void 0:s.value)==null||t.pause()},this._handleDocumentKeyUp=s=>{s.key==="Escape"&&this._handleClose()}}connectedCallback(){super.connectedCallback(),document.addEventListener("dialogembed:click",this._handleToggle),document.addEventListener("keyup",this._handleDocumentKeyUp),document.addEventListener("close:click",this._handleClose),document.addEventListener("overlay:click",this._handleClose)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("dialogembed:click",this._handleToggle),document.removeEventListener("keyup",this._handleDocumentKeyUp),document.removeEventListener("close:click",this._handleClose),document.removeEventListener("overlay:click",this._handleClose)}createRenderRoot(){return document.body}render(){return Xt`
1675
+ `],yh([Et({type:Boolean})],Ua.prototype,"open",2),yh([Et({type:Number})],Ua.prototype,"aspectRatio",2),Ua=yh([eo("vouch-embed-dialog-overlay")],Ua);var QA=Object.defineProperty,JA=Object.getOwnPropertyDescriptor,nr=(s,t,e,i)=>{for(var n=i>1?void 0:i?JA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&QA(t,e,n),n};let Qi=class extends es{constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="none",this.disableAutoplay=!1,this.aspectRatio=0,this._mediaPlayerRef=Si(),this.open=!1,this._handleToggle=()=>{var s,t,e;this.open=!this.open,this.open?!this.disableAutoplay&&((s=this._mediaPlayerRef)!=null&&s.value)&&(this._mediaPlayerRef.value.muted=!1,this._mediaPlayerRef.value.play()):(e=(t=this._mediaPlayerRef)==null?void 0:t.value)==null||e.pause()},this._handleClose=()=>{var s,t;this.open=!1,(t=(s=this._mediaPlayerRef)==null?void 0:s.value)==null||t.pause()},this._handleDocumentKeyUp=s=>{s.key==="Escape"&&this._handleClose()}}connectedCallback(){super.connectedCallback(),document.addEventListener("dialogembed:click",this._handleToggle),document.addEventListener("keyup",this._handleDocumentKeyUp),document.addEventListener("close:click",this._handleClose),document.addEventListener("overlay:click",this._handleClose)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("dialogembed:click",this._handleToggle),document.removeEventListener("keyup",this._handleDocumentKeyUp),document.removeEventListener("close:click",this._handleClose),document.removeEventListener("overlay:click",this._handleClose)}createRenderRoot(){return document.body}render(){return Xt`
1676
1676
  <vouch-embed-dialog-overlay ?open=${this.open} aspectRatio=${this.aspectRatio}>
1677
1677
  <vouch-embed-player
1678
1678
  ${Ri(this._mediaPlayerRef)}
1679
- style=${va({maxWidth:"100%",maxHeight:"100%"})}
1679
+ style=${ya({maxWidth:"100%",maxHeight:"100%"})}
1680
1680
  ?autoplay=${!1}
1681
1681
  vouchId=${di(this.vouchId)}
1682
1682
  templateId=${di(this.templateId)}
@@ -1690,7 +1690,7 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1690
1690
  aspectRatio=${this.aspectRatio}
1691
1691
  ></vouch-embed-player>
1692
1692
  </vouch-embed-dialog-overlay>
1693
- `}};nr([Et({type:String})],Qi.prototype,"vouchId",2),nr([Et({type:String})],Qi.prototype,"templateId",2),nr([Et({type:Array})],Qi.prototype,"questions",2),nr([Et({type:String})],Qi.prototype,"env",2),nr([Et({type:String})],Qi.prototype,"apiKey",2),nr([Et({type:Boolean})],Qi.prototype,"disableTracking",2),nr([Et({type:String})],Qi.prototype,"trackingSource",2),nr([Et({type:Array})],Qi.prototype,"controls",2),nr([Et({type:String})],Qi.prototype,"preload",2),nr([Et({type:Boolean})],Qi.prototype,"disableAutoplay",2),nr([Et({type:Number})],Qi.prototype,"aspectRatio",2),nr([vi()],Qi.prototype,"open",2),Qi=nr([to("vouch-embed-dialog-portal")],Qi);var QA=Object.defineProperty,JA=Object.getOwnPropertyDescriptor,mr=(s,t,e,i)=>{for(var n=i>1?void 0:i?JA(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&QA(t,e,n),n};ie.DialogEmbed=class extends ts{constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="none",this.disableAutoplay=!1,this.aspectRatio=0,this._handleRootClick=()=>{this.dispatchEvent(new CustomEvent("dialogembed:click",{bubbles:!0,composed:!0}))}}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._handleRootClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._handleRootClick)}render(){return Xt`
1693
+ `}};nr([Et({type:String})],Qi.prototype,"vouchId",2),nr([Et({type:String})],Qi.prototype,"templateId",2),nr([Et({type:Array})],Qi.prototype,"questions",2),nr([Et({type:String})],Qi.prototype,"env",2),nr([Et({type:String})],Qi.prototype,"apiKey",2),nr([Et({type:Boolean})],Qi.prototype,"disableTracking",2),nr([Et({type:String})],Qi.prototype,"trackingSource",2),nr([Et({type:Array})],Qi.prototype,"controls",2),nr([Et({type:String})],Qi.prototype,"preload",2),nr([Et({type:Boolean})],Qi.prototype,"disableAutoplay",2),nr([Et({type:Number})],Qi.prototype,"aspectRatio",2),nr([vi()],Qi.prototype,"open",2),Qi=nr([eo("vouch-embed-dialog-portal")],Qi);var tE=Object.defineProperty,eE=Object.getOwnPropertyDescriptor,mr=(s,t,e,i)=>{for(var n=i>1?void 0:i?eE(t,e):t,o=s.length-1,l;o>=0;o--)(l=s[o])&&(n=(i?l(t,e,n):l(n))||n);return i&&n&&tE(t,e,n),n};ie.DialogEmbed=class extends es{constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="none",this.disableAutoplay=!1,this.aspectRatio=0,this._handleRootClick=()=>{this.dispatchEvent(new CustomEvent("dialogembed:click",{bubbles:!0,composed:!0}))}}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._handleRootClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._handleRootClick)}render(){return Xt`
1694
1694
  <slot>
1695
1695
  <vmp-button size="large">Play</vmp-button>
1696
1696
  </slot>
@@ -1717,5 +1717,5 @@ ${t}`,dm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),um=Objec
1717
1717
  width: fit-content;
1718
1718
  height: fit-content;
1719
1719
  }
1720
- `],mr([Et({type:String})],ie.DialogEmbed.prototype,"vouchId",2),mr([Et({type:String})],ie.DialogEmbed.prototype,"templateId",2),mr([Et({type:Array})],ie.DialogEmbed.prototype,"questions",2),mr([Et({type:String})],ie.DialogEmbed.prototype,"env",2),mr([Et({type:String})],ie.DialogEmbed.prototype,"apiKey",2),mr([Et({type:Boolean})],ie.DialogEmbed.prototype,"disableTracking",2),mr([Et({type:String})],ie.DialogEmbed.prototype,"trackingSource",2),mr([Et({type:Array})],ie.DialogEmbed.prototype,"controls",2),mr([Et({type:String})],ie.DialogEmbed.prototype,"preload",2),mr([Et({type:Boolean})],ie.DialogEmbed.prototype,"disableAutoplay",2),mr([Et({type:Number})],ie.DialogEmbed.prototype,"aspectRatio",2),ie.DialogEmbed=mr([to("vouch-embed-dialog")],ie.DialogEmbed);function Vr(s){if(typeof s!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(s))}function ap(s,t){for(var e="",i=0,n=-1,o=0,l,d=0;d<=s.length;++d){if(d<s.length)l=s.charCodeAt(d);else{if(l===47)break;l=47}if(l===47){if(!(n===d-1||o===1))if(n!==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("/")),n=d,o=0;continue}}else if(e.length===2||e.length===1){e="",i=0,n=d,o=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+="/"+s.slice(n+1,d):e=s.slice(n+1,d),i=d-n-1;n=d,o=0}else l===46&&o!==-1?++o:o=-1}return e}function tE(s,t){var e=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+i:e+s+i:i}var Nn={resolve:function(){for(var t="",e=!1,i,n=arguments.length-1;n>=-1&&!e;n--){var o;n>=0?o=arguments[n]:(i===void 0&&(i=process.cwd()),o=i),Vr(o),o.length!==0&&(t=o+"/"+t,e=o.charCodeAt(0)===47)}return t=ap(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(Vr(t),t.length===0)return".";var e=t.charCodeAt(0)===47,i=t.charCodeAt(t.length-1)===47;return t=ap(t,!e),t.length===0&&!e&&(t="."),t.length>0&&i&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return Vr(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];Vr(i),i.length>0&&(t===void 0?t=i:t+="/"+i)}return t===void 0?".":Nn.normalize(t)},relative:function(t,e){if(Vr(t),Vr(e),t===e||(t=Nn.resolve(t),e=Nn.resolve(e),t===e))return"";for(var i=1;i<t.length&&t.charCodeAt(i)===47;++i);for(var n=t.length,o=n-i,l=1;l<e.length&&e.charCodeAt(l)===47;++l);for(var d=e.length,f=d-l,p=o<f?o:f,g=-1,v=0;v<=p;++v){if(v===p){if(f>p){if(e.charCodeAt(l+v)===47)return e.slice(l+v+1);if(v===0)return e.slice(l+v)}else o>p&&(t.charCodeAt(i+v)===47?g=v:v===0&&(g=0));break}var A=t.charCodeAt(i+v),E=e.charCodeAt(l+v);if(A!==E)break;A===47&&(g=v)}var T="";for(v=i+g+1;v<=n;++v)(v===n||t.charCodeAt(v)===47)&&(T.length===0?T+="..":T+="/..");return T.length>0?T+e.slice(l+g):(l+=g,e.charCodeAt(l)===47&&++l,e.slice(l))},_makeLong:function(t){return t},dirname:function(t){if(Vr(t),t.length===0)return".";for(var e=t.charCodeAt(0),i=e===47,n=-1,o=!0,l=t.length-1;l>=1;--l)if(e=t.charCodeAt(l),e===47){if(!o){n=l;break}}else o=!1;return n===-1?i?"/":".":i&&n===1?"//":t.slice(0,n)},basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Vr(t);var i=0,n=-1,o=!0,l;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(l=t.length-1;l>=0;--l){var p=t.charCodeAt(l);if(p===47){if(!o){i=l+1;break}}else f===-1&&(o=!1,f=l+1),d>=0&&(p===e.charCodeAt(d)?--d===-1&&(n=l):(d=-1,n=f))}return i===n?n=f:n===-1&&(n=t.length),t.slice(i,n)}else{for(l=t.length-1;l>=0;--l)if(t.charCodeAt(l)===47){if(!o){i=l+1;break}}else n===-1&&(o=!1,n=l+1);return n===-1?"":t.slice(i,n)}},extname:function(t){Vr(t);for(var e=-1,i=0,n=-1,o=!0,l=0,d=t.length-1;d>=0;--d){var f=t.charCodeAt(d);if(f===47){if(!o){i=d+1;break}continue}n===-1&&(o=!1,n=d+1),f===46?e===-1?e=d:l!==1&&(l=1):e!==-1&&(l=-1)}return e===-1||n===-1||l===0||l===1&&e===n-1&&e===i+1?"":t.slice(e,n)},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 tE("/",t)},parse:function(t){Vr(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var i=t.charCodeAt(0),n=i===47,o;n?(e.root="/",o=1):o=0;for(var l=-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?l===-1?l=g:v!==1&&(v=1):l!==-1&&(v=-1)}return l===-1||f===-1||v===0||v===1&&l===f-1&&l===d+1?f!==-1&&(d===0&&n?e.base=e.name=t.slice(1,f):e.base=e.name=t.slice(d,f)):(d===0&&n?(e.name=t.slice(1,l),e.base=t.slice(1,f)):(e.name=t.slice(d,l),e.base=t.slice(d,f)),e.ext=t.slice(l,f)),d>0?e.dir=t.slice(0,d-1):n&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};Nn.posix=Nn;var eE=Nn;const{basename:op,extname:iE}=eE;class rE{constructor(){let t=(()=>typeof ao>"u")(),e="image/png",i="image/jpeg",n="image/jpeg",o="image/webp",l="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:n,webp:o}:{png:e,jpg:i,jpeg:n,pdf:l,svg:d},mimes:t?{[e]:"png",[i]:"jpg",[o]:"webp"}:{[e]:"png",[i]:"jpg",[l]:"pdf",[d]:"svg"}})}toMime(t){return this.formats[(t||"").replace(/^\./,"").toLowerCase()]}fromMime(t){return this.mimes[t]}}function sE(s,{filename:t="",extension:e="",format:w,page:n,quality:o,matte:l,density:d,outline:f,archive:E}={}){var{fromMime:g,toMime:v,expected:A}=new rE,E=E||"canvas",T=w||e.replace(/@\d+x$/i,"")||iE(t),w=g(v(T)||T),C=v(w),x=s.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 ${A})`);if(!x)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let O,U,D=t.replace(/{(\d*)}/g,($,z)=>(U=!0,z=parseInt(z,10),O=isFinite(z)?z:isFinite(O)?O:-1,"{}")),H=n>0?n-1:n<0?x+n:void 0;if(isFinite(H)&&H<0||H>=x)throw new RangeError(x==1?`Canvas only has a ‘page 1’ (${H} is out of bounds)`:`Canvas has pages 1–${x} (${H} is out of bounds)`);if(s=isFinite(H)?[s[H]]:U||w=="pdf"?s:s.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 $=(e||op(t,T)).match(/@(\d+)x$/i);d=$?parseInt($[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:D,format:w,mime:C,pages:s,padding:O,quality:o,matte:l,density:d,outline:f,archive:E}}class tl{static for(t){return new tl().append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=this.crc|0,i=this.table,n=0,o=t.length|0;n<o;n++)e=e>>>8^i[(e^t[n])&255];return this.crc=e,this}}tl.prototype.table=(()=>{var s,t,e,i=[];for(s=0;s<256;s++){for(e=s,t=0;t<8;t++)e=e&1?e>>>1^3988292384:e>>>1;i[s]=e}return i})();function bh(s){let t=new Uint8Array(s),e=new DataView(t.buffer),i={array:t,view:e,size:s,set8(n,o){return e.setUint8(n,o),i},set16(n,o){return e.setUint16(n,o,!0),i},set32(n,o){return e.setUint32(n,o,!0),i},bytes(n,o){return t.set(o,n),i}};return i}const el=class el{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,n=el.encoder.encode(`${this.directory}/${i?"":t}`),o=new Uint8Array(i?0:await e.arrayBuffer()),l=30+n.length,d=l+o.length,f=16,{offset:p}=this,g=bh(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,tl.for(o)).set32(14,o.length).set32(18,o.length).set16(22,n.length);p+=l;let v=bh(l+o.length+f).set32(0,67324752).bytes(4,g.array).bytes(30,n).bytes(l,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:n,header:g,payload:v}),this.offset=p}toBuffer(){let t=this.files.reduce((v,{name:A})=>46+A.length+v,0),e=bh(t+22),i=0;for(var{offset:n,name:o,header:l,folder:d}of this.files)e.set32(i,33639248).set16(i+4,20).bytes(i+6,l.array).set8(i+38,d?16:0).set32(i+42,n).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"})}};I2(el,"encoder",new TextEncoder);let Ah=el;const Eh=(s,t,e,i)=>{if(i){let{width:n,height:o}=s,l=Object.assign(document.createElement("canvas"),{width:n,height:o}),d=l.getContext("2d");d.fillStyle=i,d.fillRect(0,0,n,o),d.drawImage(s,0,0),s=l}return new Promise((n,o)=>s.toBlob(n,t,e))},nE=(...s)=>Eh(...s).then(t=>t.arrayBuffer()),aE=async(s,t,e,i,n)=>{lp(n,await Eh(s,t,e,i))},oE=async(s,t,e,i,n,o,l)=>{let d=g=>o.replace("{}",String(g+1).padStart(l,"0")),f=op(n,".zip")||"archive",p=new Ah(f);await Promise.all(s.map(async(g,v)=>{let A=d(v);await p.add(A,await Eh(g,t,e,i))})),lp(`${f}.zip`,p.blob)},lp=(s,t)=>{const e=window.URL.createObjectURL(t),i=document.createElement("a");i.style.display="none",i.href=e,i.setAttribute("download",s),typeof i.download>"u"&&i.setAttribute("target","_blank"),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>window.URL.revokeObjectURL(e),100)};var lE={asBuffer:nE,asDownload:aE,asZipDownload:oE,atScale:(s,t,e)=>s.map(i=>{if(t==1&&!e)return i.canvas;let n=document.createElement("canvas"),o=n.getContext("2d"),l=i.canvas?i.canvas:i;return n.width=l.width*t,n.height=l.height*t,e&&(o.fillStyle=e,o.fillRect(0,0,n.width,n.height)),o.scale(t,t),o.drawImage(l,0,0),n}),options:sE};const{asBuffer:Th,asDownload:cE,asZipDownload:hE,atScale:kh,options:wh}=lE,cp=Symbol.for("toDataURL"),dE=s=>{let t=Object.assign(new hp,{crossOrigin:"Anonymous",src:s});return t.decode().then(()=>t)};class uE{constructor(t,e){let i=document.createElement("canvas"),n=[];Object.defineProperty(i,"async",{value:!0,writable:!1,enumerable:!0});for(var[o,l]of Object.entries({png:()=>Th(i,"image/png"),jpg:()=>Th(i,"image/jpeg"),pages:()=>n.concat(i).map(d=>d.getContext("2d"))}))Object.defineProperty(i,o,{get:l});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),n.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=wh(this.pages,{filename:d,...f}),{pattern:g,padding:v,mime:A,quality:E,matte:T,density:w,archive:C}=p,x=kh(p.pages,w);return v==null?cE(x[0],A,E,T,d):hE(x,A,E,T,C,g,v)},toBuffer(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=wh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:A,pages:E,density:T}=p,w=kh(E,T,A)[0];return Th(w,g,v,A)},[cp]:i.toDataURL.bind(i),toDataURL(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=wh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:A,pages:E,density:T}=p,w=kh(E,T,A)[0],C=w[w===i?cp:"toDataURL"](g,v);return Promise.resolve(C)}})}}const{CanvasRenderingContext2D:fE,CanvasGradient:pE,CanvasPattern:gE,Image:hp,ImageData:mE,Path2D:vE,DOMMatrix:yE,DOMRect:bE,DOMPoint:AE}=window;var dp={Canvas:uE,loadImage:dE,CanvasRenderingContext2D:fE,CanvasGradient:pE,CanvasPattern:gE,Image:hp,ImageData:mE,Path2D:vE,DOMMatrix:yE,DOMRect:bE,DOMPoint:AE};const up=Qr({__proto__:null,default:Ul(dp)},[dp]);return Object.defineProperty(ie,Symbol.toStringTag,{value:"Module"}),ie}({});
1720
+ `],mr([Et({type:String})],ie.DialogEmbed.prototype,"vouchId",2),mr([Et({type:String})],ie.DialogEmbed.prototype,"templateId",2),mr([Et({type:Array})],ie.DialogEmbed.prototype,"questions",2),mr([Et({type:String})],ie.DialogEmbed.prototype,"env",2),mr([Et({type:String})],ie.DialogEmbed.prototype,"apiKey",2),mr([Et({type:Boolean})],ie.DialogEmbed.prototype,"disableTracking",2),mr([Et({type:String})],ie.DialogEmbed.prototype,"trackingSource",2),mr([Et({type:Array})],ie.DialogEmbed.prototype,"controls",2),mr([Et({type:String})],ie.DialogEmbed.prototype,"preload",2),mr([Et({type:Boolean})],ie.DialogEmbed.prototype,"disableAutoplay",2),mr([Et({type:Number})],ie.DialogEmbed.prototype,"aspectRatio",2),ie.DialogEmbed=mr([eo("vouch-embed-dialog")],ie.DialogEmbed);function Hr(s){if(typeof s!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(s))}function ap(s,t){for(var e="",i=0,n=-1,o=0,l,d=0;d<=s.length;++d){if(d<s.length)l=s.charCodeAt(d);else{if(l===47)break;l=47}if(l===47){if(!(n===d-1||o===1))if(n!==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("/")),n=d,o=0;continue}}else if(e.length===2||e.length===1){e="",i=0,n=d,o=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+="/"+s.slice(n+1,d):e=s.slice(n+1,d),i=d-n-1;n=d,o=0}else l===46&&o!==-1?++o:o=-1}return e}function iE(s,t){var e=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+i:e+s+i:i}var Nn={resolve:function(){for(var t="",e=!1,i,n=arguments.length-1;n>=-1&&!e;n--){var o;n>=0?o=arguments[n]:(i===void 0&&(i=process.cwd()),o=i),Hr(o),o.length!==0&&(t=o+"/"+t,e=o.charCodeAt(0)===47)}return t=ap(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(Hr(t),t.length===0)return".";var e=t.charCodeAt(0)===47,i=t.charCodeAt(t.length-1)===47;return t=ap(t,!e),t.length===0&&!e&&(t="."),t.length>0&&i&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return Hr(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];Hr(i),i.length>0&&(t===void 0?t=i:t+="/"+i)}return t===void 0?".":Nn.normalize(t)},relative:function(t,e){if(Hr(t),Hr(e),t===e||(t=Nn.resolve(t),e=Nn.resolve(e),t===e))return"";for(var i=1;i<t.length&&t.charCodeAt(i)===47;++i);for(var n=t.length,o=n-i,l=1;l<e.length&&e.charCodeAt(l)===47;++l);for(var d=e.length,f=d-l,p=o<f?o:f,g=-1,v=0;v<=p;++v){if(v===p){if(f>p){if(e.charCodeAt(l+v)===47)return e.slice(l+v+1);if(v===0)return e.slice(l+v)}else o>p&&(t.charCodeAt(i+v)===47?g=v:v===0&&(g=0));break}var A=t.charCodeAt(i+v),E=e.charCodeAt(l+v);if(A!==E)break;A===47&&(g=v)}var T="";for(v=i+g+1;v<=n;++v)(v===n||t.charCodeAt(v)===47)&&(T.length===0?T+="..":T+="/..");return T.length>0?T+e.slice(l+g):(l+=g,e.charCodeAt(l)===47&&++l,e.slice(l))},_makeLong:function(t){return t},dirname:function(t){if(Hr(t),t.length===0)return".";for(var e=t.charCodeAt(0),i=e===47,n=-1,o=!0,l=t.length-1;l>=1;--l)if(e=t.charCodeAt(l),e===47){if(!o){n=l;break}}else o=!1;return n===-1?i?"/":".":i&&n===1?"//":t.slice(0,n)},basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Hr(t);var i=0,n=-1,o=!0,l;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(l=t.length-1;l>=0;--l){var p=t.charCodeAt(l);if(p===47){if(!o){i=l+1;break}}else f===-1&&(o=!1,f=l+1),d>=0&&(p===e.charCodeAt(d)?--d===-1&&(n=l):(d=-1,n=f))}return i===n?n=f:n===-1&&(n=t.length),t.slice(i,n)}else{for(l=t.length-1;l>=0;--l)if(t.charCodeAt(l)===47){if(!o){i=l+1;break}}else n===-1&&(o=!1,n=l+1);return n===-1?"":t.slice(i,n)}},extname:function(t){Hr(t);for(var e=-1,i=0,n=-1,o=!0,l=0,d=t.length-1;d>=0;--d){var f=t.charCodeAt(d);if(f===47){if(!o){i=d+1;break}continue}n===-1&&(o=!1,n=d+1),f===46?e===-1?e=d:l!==1&&(l=1):e!==-1&&(l=-1)}return e===-1||n===-1||l===0||l===1&&e===n-1&&e===i+1?"":t.slice(e,n)},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 iE("/",t)},parse:function(t){Hr(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var i=t.charCodeAt(0),n=i===47,o;n?(e.root="/",o=1):o=0;for(var l=-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?l===-1?l=g:v!==1&&(v=1):l!==-1&&(v=-1)}return l===-1||f===-1||v===0||v===1&&l===f-1&&l===d+1?f!==-1&&(d===0&&n?e.base=e.name=t.slice(1,f):e.base=e.name=t.slice(d,f)):(d===0&&n?(e.name=t.slice(1,l),e.base=t.slice(1,f)):(e.name=t.slice(d,l),e.base=t.slice(d,f)),e.ext=t.slice(l,f)),d>0?e.dir=t.slice(0,d-1):n&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};Nn.posix=Nn;var rE=Nn;const{basename:op,extname:sE}=rE;class nE{constructor(){let t=(()=>typeof oo>"u")(),e="image/png",i="image/jpeg",n="image/jpeg",o="image/webp",l="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:n,webp:o}:{png:e,jpg:i,jpeg:n,pdf:l,svg:d},mimes:t?{[e]:"png",[i]:"jpg",[o]:"webp"}:{[e]:"png",[i]:"jpg",[l]:"pdf",[d]:"svg"}})}toMime(t){return this.formats[(t||"").replace(/^\./,"").toLowerCase()]}fromMime(t){return this.mimes[t]}}function aE(s,{filename:t="",extension:e="",format:w,page:n,quality:o,matte:l,density:d,outline:f,archive:E}={}){var{fromMime:g,toMime:v,expected:A}=new nE,E=E||"canvas",T=w||e.replace(/@\d+x$/i,"")||sE(t),w=g(v(T)||T),C=v(w),D=s.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 ${A})`);if(!D)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let M,U,x=t.replace(/{(\d*)}/g,($,Y)=>(U=!0,Y=parseInt(Y,10),M=isFinite(Y)?Y:isFinite(M)?M:-1,"{}")),G=n>0?n-1:n<0?D+n:void 0;if(isFinite(G)&&G<0||G>=D)throw new RangeError(D==1?`Canvas only has a ‘page 1’ (${G} is out of bounds)`:`Canvas has pages 1–${D} (${G} is out of bounds)`);if(s=isFinite(G)?[s[G]]:U||w=="pdf"?s:s.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 $=(e||op(t,T)).match(/@(\d+)x$/i);d=$?parseInt($[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:C,pages:s,padding:M,quality:o,matte:l,density:d,outline:f,archive:E}}class el{static for(t){return new el().append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=this.crc|0,i=this.table,n=0,o=t.length|0;n<o;n++)e=e>>>8^i[(e^t[n])&255];return this.crc=e,this}}el.prototype.table=(()=>{var s,t,e,i=[];for(s=0;s<256;s++){for(e=s,t=0;t<8;t++)e=e&1?e>>>1^3988292384:e>>>1;i[s]=e}return i})();function bh(s){let t=new Uint8Array(s),e=new DataView(t.buffer),i={array:t,view:e,size:s,set8(n,o){return e.setUint8(n,o),i},set16(n,o){return e.setUint16(n,o,!0),i},set32(n,o){return e.setUint32(n,o,!0),i},bytes(n,o){return t.set(o,n),i}};return i}const il=class il{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,n=il.encoder.encode(`${this.directory}/${i?"":t}`),o=new Uint8Array(i?0:await e.arrayBuffer()),l=30+n.length,d=l+o.length,f=16,{offset:p}=this,g=bh(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,el.for(o)).set32(14,o.length).set32(18,o.length).set16(22,n.length);p+=l;let v=bh(l+o.length+f).set32(0,67324752).bytes(4,g.array).bytes(30,n).bytes(l,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:n,header:g,payload:v}),this.offset=p}toBuffer(){let t=this.files.reduce((v,{name:A})=>46+A.length+v,0),e=bh(t+22),i=0;for(var{offset:n,name:o,header:l,folder:d}of this.files)e.set32(i,33639248).set16(i+4,20).bytes(i+6,l.array).set8(i+38,d?16:0).set32(i+42,n).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"})}};I2(il,"encoder",new TextEncoder);let Ah=il;const Eh=(s,t,e,i)=>{if(i){let{width:n,height:o}=s,l=Object.assign(document.createElement("canvas"),{width:n,height:o}),d=l.getContext("2d");d.fillStyle=i,d.fillRect(0,0,n,o),d.drawImage(s,0,0),s=l}return new Promise((n,o)=>s.toBlob(n,t,e))},oE=(...s)=>Eh(...s).then(t=>t.arrayBuffer()),lE=async(s,t,e,i,n)=>{lp(n,await Eh(s,t,e,i))},cE=async(s,t,e,i,n,o,l)=>{let d=g=>o.replace("{}",String(g+1).padStart(l,"0")),f=op(n,".zip")||"archive",p=new Ah(f);await Promise.all(s.map(async(g,v)=>{let A=d(v);await p.add(A,await Eh(g,t,e,i))})),lp(`${f}.zip`,p.blob)},lp=(s,t)=>{const e=window.URL.createObjectURL(t),i=document.createElement("a");i.style.display="none",i.href=e,i.setAttribute("download",s),typeof i.download>"u"&&i.setAttribute("target","_blank"),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>window.URL.revokeObjectURL(e),100)};var hE={asBuffer:oE,asDownload:lE,asZipDownload:cE,atScale:(s,t,e)=>s.map(i=>{if(t==1&&!e)return i.canvas;let n=document.createElement("canvas"),o=n.getContext("2d"),l=i.canvas?i.canvas:i;return n.width=l.width*t,n.height=l.height*t,e&&(o.fillStyle=e,o.fillRect(0,0,n.width,n.height)),o.scale(t,t),o.drawImage(l,0,0),n}),options:aE};const{asBuffer:Th,asDownload:dE,asZipDownload:uE,atScale:kh,options:wh}=hE,cp=Symbol.for("toDataURL"),fE=s=>{let t=Object.assign(new hp,{crossOrigin:"Anonymous",src:s});return t.decode().then(()=>t)};class pE{constructor(t,e){let i=document.createElement("canvas"),n=[];Object.defineProperty(i,"async",{value:!0,writable:!1,enumerable:!0});for(var[o,l]of Object.entries({png:()=>Th(i,"image/png"),jpg:()=>Th(i,"image/jpeg"),pages:()=>n.concat(i).map(d=>d.getContext("2d"))}))Object.defineProperty(i,o,{get:l});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),n.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=wh(this.pages,{filename:d,...f}),{pattern:g,padding:v,mime:A,quality:E,matte:T,density:w,archive:C}=p,D=kh(p.pages,w);return v==null?dE(D[0],A,E,T,d):uE(D,A,E,T,C,g,v)},toBuffer(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=wh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:A,pages:E,density:T}=p,w=kh(E,T,A)[0];return Th(w,g,v,A)},[cp]:i.toDataURL.bind(i),toDataURL(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=wh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:A,pages:E,density:T}=p,w=kh(E,T,A)[0],C=w[w===i?cp:"toDataURL"](g,v);return Promise.resolve(C)}})}}const{CanvasRenderingContext2D:gE,CanvasGradient:mE,CanvasPattern:vE,Image:hp,ImageData:yE,Path2D:bE,DOMMatrix:AE,DOMRect:EE,DOMPoint:TE}=window;var dp={Canvas:pE,loadImage:fE,CanvasRenderingContext2D:gE,CanvasGradient:mE,CanvasPattern:vE,Image:hp,ImageData:yE,Path2D:bE,DOMMatrix:AE,DOMRect:EE,DOMPoint:TE};const up=Jr({__proto__:null,default:Bl(dp)},[dp]);return Object.defineProperty(ie,Symbol.toStringTag,{value:"Module"}),ie}({});
1721
1721
  //# sourceMappingURL=embeds.iife.js.map