@vouchfor/embeds 0.0.0-experiment.90d5928 → 0.0.0-experiment.90dc1dd
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/es/browser-91e16108.js +733 -0
- package/dist/es/browser-91e16108.js.map +1 -0
- package/dist/es/embeds.js +12 -1499
- package/dist/es/embeds.js.map +1 -1
- package/dist/es/index-14de0872.js +16482 -0
- package/dist/es/index-14de0872.js.map +1 -0
- package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
- package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
- package/dist/es/src/components/DialogEmbed/index.d.ts +36 -0
- package/dist/es/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
- package/dist/es/{components/Embed → src/components/PlayerEmbed}/controllers/fetcher.d.ts +5 -4
- package/dist/es/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
- package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
- package/dist/es/{components/Embed → src/components/PlayerEmbed}/index.d.ts +28 -19
- package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +3 -0
- package/dist/es/src/index.d.ts +2 -0
- package/dist/iife/dialog-embed/browser-8829205f.js +433 -0
- package/dist/iife/dialog-embed/browser-8829205f.js.map +1 -0
- package/dist/iife/dialog-embed/embed.iife.js +1722 -0
- package/dist/iife/dialog-embed/embed.iife.js.map +1 -0
- package/dist/iife/dialog-embed/embed.js +5 -0
- package/dist/iife/dialog-embed/embed.js.map +1 -0
- package/dist/iife/dialog-embed/index-64277c3d.js +33265 -0
- package/dist/iife/dialog-embed/index-64277c3d.js.map +1 -0
- package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
- package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
- package/dist/iife/dialog-embed/src/components/DialogEmbed/index.d.ts +36 -0
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +14 -0
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/index.d.ts +73 -0
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/tests/data.d.ts +3 -0
- package/dist/iife/dialog-embed/src/index.d.ts +2 -0
- package/dist/iife/dialog-embed/src/utils/env.d.ts +12 -0
- package/dist/iife/dialog-embed/src/utils/events.d.ts +2 -0
- package/dist/iife/embeds.iife.js +642 -326
- package/dist/iife/embeds.iife.js.map +1 -1
- package/dist/iife/player-embed/browser-5865adfa.js +433 -0
- package/dist/iife/player-embed/browser-5865adfa.js.map +1 -0
- package/dist/iife/player-embed/embed.iife.js +1584 -0
- package/dist/iife/player-embed/embed.iife.js.map +1 -0
- package/dist/iife/player-embed/embed.js +5 -0
- package/dist/iife/player-embed/embed.js.map +1 -0
- package/dist/iife/player-embed/index-653d8046.js +32820 -0
- package/dist/iife/player-embed/index-653d8046.js.map +1 -0
- package/dist/iife/player-embed/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
- package/dist/iife/player-embed/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
- package/dist/iife/player-embed/src/components/DialogEmbed/index.d.ts +36 -0
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +14 -0
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
- package/dist/iife/player-embed/src/components/PlayerEmbed/index.d.ts +73 -0
- package/dist/iife/player-embed/src/components/PlayerEmbed/tests/data.d.ts +3 -0
- package/dist/iife/player-embed/src/index.d.ts +2 -0
- package/dist/iife/player-embed/src/utils/env.d.ts +12 -0
- package/dist/iife/player-embed/src/utils/events.d.ts +2 -0
- package/package.json +13 -5
- package/src/components/DialogEmbed/Dialog.stories.ts +91 -0
- package/src/components/DialogEmbed/DialogOverlay.ts +131 -0
- package/src/components/DialogEmbed/DialogPortal.ts +126 -0
- package/src/components/DialogEmbed/index.ts +97 -0
- package/src/components/{Embed/Embed.stories.ts → PlayerEmbed/PlayerEmbed.stories.ts} +27 -14
- package/src/components/{Embed → PlayerEmbed}/controllers/event-forwarder.ts +6 -5
- package/src/components/PlayerEmbed/controllers/fetcher.ts +152 -0
- package/src/components/PlayerEmbed/controllers/tracking/index.ts +224 -0
- package/src/components/PlayerEmbed/controllers/tracking/utils.ts +95 -0
- package/src/components/{Embed → PlayerEmbed}/index.ts +78 -27
- package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +80 -0
- package/src/components/PlayerEmbed/tests/data.ts +183 -0
- package/src/index.ts +2 -1
- package/dist/es/components/Embed/controllers/tracking.d.ts +0 -28
- package/dist/es/index.d.ts +0 -1
- package/src/components/Embed/controllers/fetcher.ts +0 -113
- package/src/components/Embed/controllers/tracking.ts +0 -261
- /package/dist/es/{utils → src/utils}/env.d.ts +0 -0
- /package/dist/es/{utils → src/utils}/events.d.ts +0 -0
@@ -0,0 +1,1584 @@
|
|
1
|
+
var Qk=Object.defineProperty;var Jk=(Ft,Xr,Lr)=>Xr in Ft?Qk(Ft,Xr,{enumerable:!0,configurable:!0,writable:!0,value:Lr}):Ft[Xr]=Lr;var ug=(Ft,Xr,Lr)=>(Jk(Ft,typeof Xr!="symbol"?Xr+"":Xr,Lr),Lr);var playerEmbed=function(Ft){var zp;"use strict";function Xr(s,e){for(var t=0;t<e.length;t++){const i=e[t];if(typeof i!="string"&&!Array.isArray(i)){for(const n in i)if(n!=="default"&&!(n in s)){const a=Object.getOwnPropertyDescriptor(i,n);a&&Object.defineProperty(s,n,a.get?a:{enumerable:!0,get:()=>i[n]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2019 Google LLC
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
5
|
+
*/const Lr=globalThis,Sl=Lr.ShadowRoot&&(Lr.ShadyCSS===void 0||Lr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,dh=Symbol(),ph=new WeakMap;let dg=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==dh)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Sl&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=ph.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&ph.set(t,e))}return e}toString(){return this.cssText}};const pg=s=>new dg(typeof s=="string"?s:s+"",void 0,dh),mg=(s,e)=>{if(Sl)s.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),n=Lr.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=t.cssText,s.appendChild(i)}},mh=Sl?s=>s:s=>s instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return pg(t)})(s):s;/**
|
6
|
+
* @license
|
7
|
+
* Copyright 2017 Google LLC
|
8
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
9
|
+
*/const{is:gg,defineProperty:vg,getOwnPropertyDescriptor:yg,getOwnPropertyNames:Ag,getOwnPropertySymbols:Eg,getPrototypeOf:xg}=Object,ds=globalThis,gh=ds.trustedTypes,bg=gh?gh.emptyScript:"",kl=ds.reactiveElementPolyfillSupport,Yn=(s,e)=>s,Qo={toAttribute(s,e){switch(e){case Boolean:s=s?bg:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,e){let t=s;switch(e){case Boolean:t=s!==null;break;case Number:t=s===null?null:Number(s);break;case Object:case Array:try{t=JSON.parse(s)}catch{t=null}}return t}},wl=(s,e)=>!gg(s,e),vh={attribute:!0,type:String,converter:Qo,reflect:!1,hasChanged:wl};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),ds.litPropertyMetadata??(ds.litPropertyMetadata=new WeakMap);let Xn=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=vh){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(e,i,t);n!==void 0&&vg(this.prototype,e,n)}}static getPropertyDescriptor(e,t,i){const{get:n,set:a}=yg(this.prototype,e)??{get(){return this[t]},set(l){this[t]=l}};return{get(){return n==null?void 0:n.call(this)},set(l){const h=n==null?void 0:n.call(this);a.call(this,l),this.requestUpdate(e,h,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??vh}static _$Ei(){if(this.hasOwnProperty(Yn("elementProperties")))return;const e=xg(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Yn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Yn("properties"))){const t=this.properties,i=[...Ag(t),...Eg(t)];for(const n of i)this.createProperty(n,t[n])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,n]of t)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const n=this._$Eu(t,i);n!==void 0&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const n of i)t.unshift(mh(n))}else e!==void 0&&t.push(mh(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$Eg=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$ES(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$E_??(this._$E_=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$E_)==null||t.delete(e)}_$ES(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return mg(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$E_)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$E_)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t){var a;const i=this.constructor.elementProperties.get(e),n=this.constructor._$Eu(e,i);if(n!==void 0&&i.reflect===!0){const l=(((a=i.converter)==null?void 0:a.toAttribute)!==void 0?i.converter:Qo).toAttribute(t,i.type);this._$Em=e,l==null?this.removeAttribute(n):this.setAttribute(n,l),this._$Em=null}}_$AK(e,t){var a;const i=this.constructor,n=i._$Eh.get(e);if(n!==void 0&&this._$Em!==n){const l=i.getPropertyOptions(n),h=typeof l.converter=="function"?{fromAttribute:l.converter}:((a=l.converter)==null?void 0:a.fromAttribute)!==void 0?l.converter:Qo;this._$Em=n,this[n]=h.fromAttribute(t,l.type),this._$Em=null}}requestUpdate(e,t,i,n=!1,a){if(e!==void 0){if(i??(i=this.constructor.getPropertyOptions(e)),!(i.hasChanged??wl)(n?a:this[e],t))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$Eg=this._$EP())}C(e,t,i){this._$AL.has(e)||this._$AL.set(e,t),i.reflect===!0&&this._$Em!==e&&(this._$Ej??(this._$Ej=new Set)).add(e)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!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[a,l]of this._$Ep)this[a]=l;this._$Ep=void 0}const n=this.constructor.elementProperties;if(n.size>0)for(const[a,l]of n)l.wrapped!==!0||this._$AL.has(a)||this[a]===void 0||this.C(a,this[a],l)}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$E_)==null||i.forEach(n=>{var a;return(a=n.hostUpdate)==null?void 0:a.call(n)}),this.update(t)):this._$ET()}catch(n){throw e=!1,this._$ET(),n}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$E_)==null||t.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(t=>this._$EO(t,this[t]))),this._$ET()}updated(e){}firstUpdated(e){}};Xn.elementStyles=[],Xn.shadowRootOptions={mode:"open"},Xn[Yn("elementProperties")]=new Map,Xn[Yn("finalized")]=new Map,kl==null||kl({ReactiveElement:Xn}),(ds.reactiveElementVersions??(ds.reactiveElementVersions=[])).push("2.0.2");/**
|
10
|
+
* @license
|
11
|
+
* Copyright 2017 Google LLC
|
12
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
13
|
+
*/const Zn=globalThis,Jo=Zn.trustedTypes,yh=Jo?Jo.createPolicy("lit-html",{createHTML:s=>s}):void 0,_l="$lit$",Zr=`lit$${(Math.random()+"").slice(9)}$`,Rl="?"+Zr,Tg=`<${Rl}>`,Ws=document,ea=()=>Ws.createComment(""),qn=s=>s===null||typeof s!="object"&&typeof s!="function",Ah=Array.isArray,Eh=s=>Ah(s)||typeof(s==null?void 0:s[Symbol.iterator])=="function",Ll=`[
|
14
|
+
\f\r]`,Qn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,xh=/-->/g,bh=/>/g,js=RegExp(`>|${Ll}(?:([^\\s"'>=/]+)(${Ll}*=${Ll}*(?:[^
|
15
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Th=/'/g,Sh=/"/g,kh=/^(?:script|style|textarea|title)$/i,ps=Symbol.for("lit-noChange"),ii=Symbol.for("lit-nothing"),wh=new WeakMap,Ks=Ws.createTreeWalker(Ws,129);function _h(s,e){if(!Array.isArray(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return yh!==void 0?yh.createHTML(e):e}const Rh=(s,e)=>{const t=s.length-1,i=[];let n,a=e===2?"<svg>":"",l=Qn;for(let h=0;h<t;h++){const d=s[h];let p,m,g=-1,A=0;for(;A<d.length&&(l.lastIndex=A,m=l.exec(d),m!==null);)A=l.lastIndex,l===Qn?m[1]==="!--"?l=xh:m[1]!==void 0?l=bh:m[2]!==void 0?(kh.test(m[2])&&(n=RegExp("</"+m[2],"g")),l=js):m[3]!==void 0&&(l=js):l===js?m[0]===">"?(l=n??Qn,g=-1):m[1]===void 0?g=-2:(g=l.lastIndex-m[2].length,p=m[1],l=m[3]===void 0?js:m[3]==='"'?Sh:Th):l===Sh||l===Th?l=js:l===xh||l===bh?l=Qn:(l=js,n=void 0);const x=l===js&&s[h+1].startsWith("/>")?" ":"";a+=l===Qn?d+Tg:g>=0?(i.push(p),d.slice(0,g)+_l+d.slice(g)+Zr+x):d+Zr+(g===-2?h:x)}return[_h(s,a+(s[t]||"<?>")+(e===2?"</svg>":"")),i]};let Cl=class hg{constructor({strings:e,_$litType$:t},i){let n;this.parts=[];let a=0,l=0;const h=e.length-1,d=this.parts,[p,m]=Rh(e,t);if(this.el=hg.createElement(p,i),Ks.currentNode=this.el.content,t===2){const g=this.el.content.firstChild;g.replaceWith(...g.childNodes)}for(;(n=Ks.nextNode())!==null&&d.length<h;){if(n.nodeType===1){if(n.hasAttributes())for(const g of n.getAttributeNames())if(g.endsWith(_l)){const A=m[l++],x=n.getAttribute(g).split(Zr),b=/([.?@])?(.*)/.exec(A);d.push({type:1,index:a,name:b[2],strings:x,ctor:b[1]==="."?Ch:b[1]==="?"?Ih:b[1]==="@"?Dh:Jn}),n.removeAttribute(g)}else g.startsWith(Zr)&&(d.push({type:6,index:a}),n.removeAttribute(g));if(kh.test(n.tagName)){const g=n.textContent.split(Zr),A=g.length-1;if(A>0){n.textContent=Jo?Jo.emptyScript:"";for(let x=0;x<A;x++)n.append(g[x],ea()),Ks.nextNode(),d.push({type:2,index:++a});n.append(g[A],ea())}}}else if(n.nodeType===8)if(n.data===Rl)d.push({type:2,index:a});else{let g=-1;for(;(g=n.data.indexOf(Zr,g+1))!==-1;)d.push({type:7,index:a}),g+=Zr.length-1}a++}}static createElement(e,t){const i=Ws.createElement("template");return i.innerHTML=e,i}};function zs(s,e,t=s,i){var l,h;if(e===ps)return e;let n=i!==void 0?(l=t._$Co)==null?void 0:l[i]:t._$Cl;const a=qn(e)?void 0:e._$litDirective$;return(n==null?void 0:n.constructor)!==a&&((h=n==null?void 0:n._$AO)==null||h.call(n,!1),a===void 0?n=void 0:(n=new a(s),n._$AT(s,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=n:t._$Cl=n),n!==void 0&&(e=zs(s,n._$AS(s,e.values),n,i)),e}let Lh=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,n=((e==null?void 0:e.creationScope)??Ws).importNode(t,!0);Ks.currentNode=n;let a=Ks.nextNode(),l=0,h=0,d=i[0];for(;d!==void 0;){if(l===d.index){let p;d.type===2?p=new Il(a,a.nextSibling,this,e):d.type===1?p=new d.ctor(a,d.name,d.strings,this,e):d.type===6&&(p=new Oh(a,this,e)),this._$AV.push(p),d=i[++h]}l!==(d==null?void 0:d.index)&&(a=Ks.nextNode(),l++)}return Ks.currentNode=Ws,n}p(e){let t=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}},Il=class fg{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,n){this.type=2,this._$AH=ii,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=n,this._$Cv=(n==null?void 0:n.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=zs(this,e,t),qn(e)?e===ii||e==null||e===""?(this._$AH!==ii&&this._$AR(),this._$AH=ii):e!==this._$AH&&e!==ps&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):Eh(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==ii&&qn(this._$AH)?this._$AA.nextSibling.data=e:this.$(Ws.createTextNode(e)),this._$AH=e}g(e){var a;const{values:t,_$litType$:i}=e,n=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Cl.createElement(_h(i.h,i.h[0]),this.options)),i);if(((a=this._$AH)==null?void 0:a._$AD)===n)this._$AH.p(t);else{const l=new Lh(n,this),h=l.u(this.options);l.p(t),this.$(h),this._$AH=l}}_$AC(e){let t=wh.get(e.strings);return t===void 0&&wh.set(e.strings,t=new Cl(e)),t}T(e){Ah(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,n=0;for(const a of e)n===t.length?t.push(i=new fg(this.k(ea()),this.k(ea()),this,this.options)):i=t[n],i._$AI(a),n++;n<t.length&&(this._$AR(i&&i._$AB.nextSibling,n),t.length=n)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e&&e!==this._$AB;){const n=e.nextSibling;e.remove(),e=n}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},Jn=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,n,a){this.type=1,this._$AH=ii,this._$AN=void 0,this.element=e,this.name=t,this._$AM=n,this.options=a,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ii}_$AI(e,t=this,i,n){const a=this.strings;let l=!1;if(a===void 0)e=zs(this,e,t,0),l=!qn(e)||e!==this._$AH&&e!==ps,l&&(this._$AH=e);else{const h=e;let d,p;for(e=a[0],d=0;d<a.length-1;d++)p=zs(this,h[i+d],t,d),p===ps&&(p=this._$AH[d]),l||(l=!qn(p)||p!==this._$AH[d]),p===ii?e=ii:e!==ii&&(e+=(p??"")+a[d+1]),this._$AH[d]=p}l&&!n&&this.O(e)}O(e){e===ii?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},Ch=class extends Jn{constructor(){super(...arguments),this.type=3}O(e){this.element[this.name]=e===ii?void 0:e}},Ih=class extends Jn{constructor(){super(...arguments),this.type=4}O(e){this.element.toggleAttribute(this.name,!!e&&e!==ii)}},Dh=class extends Jn{constructor(e,t,i,n,a){super(e,t,i,n,a),this.type=5}_$AI(e,t=this){if((e=zs(this,e,t,0)??ii)===ps)return;const i=this._$AH,n=e===ii&&i!==ii||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,a=e!==ii&&(i===ii||n);n&&this.element.removeEventListener(this.name,this,i),a&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}},Oh=class{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){zs(this,e)}};const Sg={j:_l,P:Zr,A:Rl,C:1,M:Rh,L:Lh,R:Eh,V:zs,D:Il,I:Jn,H:Ih,N:Dh,U:Ch,B:Oh},Dl=Zn.litHtmlPolyfillSupport;Dl==null||Dl(Cl,Il),(Zn.litHtmlVersions??(Zn.litHtmlVersions=[])).push("3.1.0");/**
|
16
|
+
* @license
|
17
|
+
* Copyright 2019 Google LLC
|
18
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
19
|
+
*/const ta=globalThis,Ol=ta.ShadowRoot&&(ta.ShadyCSS===void 0||ta.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Pl=Symbol(),Ph=new WeakMap;let $h=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==Pl)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Ol&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=Ph.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Ph.set(t,e))}return e}toString(){return this.cssText}};const eo=s=>new $h(typeof s=="string"?s:s+"",void 0,Pl),Ei=(s,...e)=>{const t=s.length===1?s[0]:e.reduce((i,n,a)=>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[a+1],s[0]);return new $h(t,s,Pl)},kg=(s,e)=>{if(Ol)s.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),n=ta.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=t.cssText,s.appendChild(i)}},Mh=Ol?s=>s:s=>s instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return eo(t)})(s):s;/**
|
20
|
+
* @license
|
21
|
+
* Copyright 2017 Google LLC
|
22
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
23
|
+
*/const{is:wg,defineProperty:_g,getOwnPropertyDescriptor:Rg,getOwnPropertyNames:Lg,getOwnPropertySymbols:Cg,getPrototypeOf:Ig}=Object,ms=globalThis,Fh=ms.trustedTypes,Dg=Fh?Fh.emptyScript:"",$l=ms.reactiveElementPolyfillSupport,to=(s,e)=>s,Ml={toAttribute(s,e){switch(e){case Boolean:s=s?Dg:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,e){let t=s;switch(e){case Boolean:t=s!==null;break;case Number:t=s===null?null:Number(s);break;case Object:case Array:try{t=JSON.parse(s)}catch{t=null}}return t}},Nh=(s,e)=>!wg(s,e),Uh={attribute:!0,type:String,converter:Ml,reflect:!1,hasChanged:Nh};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),ms.litPropertyMetadata??(ms.litPropertyMetadata=new WeakMap);let yn=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Uh){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(e,i,t);n!==void 0&&_g(this.prototype,e,n)}}static getPropertyDescriptor(e,t,i){const{get:n,set:a}=Rg(this.prototype,e)??{get(){return this[t]},set(l){this[t]=l}};return{get(){return n==null?void 0:n.call(this)},set(l){const h=n==null?void 0:n.call(this);a.call(this,l),this.requestUpdate(e,h,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Uh}static _$Ei(){if(this.hasOwnProperty(to("elementProperties")))return;const e=Ig(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(to("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(to("properties"))){const t=this.properties,i=[...Lg(t),...Cg(t)];for(const n of i)this.createProperty(n,t[n])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,n]of t)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const n=this._$Eu(t,i);n!==void 0&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const n of i)t.unshift(Mh(n))}else e!==void 0&&t.push(Mh(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$Eg=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$ES(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$E_??(this._$E_=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$E_)==null||t.delete(e)}_$ES(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return kg(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$E_)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$E_)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t){var a;const i=this.constructor.elementProperties.get(e),n=this.constructor._$Eu(e,i);if(n!==void 0&&i.reflect===!0){const l=(((a=i.converter)==null?void 0:a.toAttribute)!==void 0?i.converter:Ml).toAttribute(t,i.type);this._$Em=e,l==null?this.removeAttribute(n):this.setAttribute(n,l),this._$Em=null}}_$AK(e,t){var a;const i=this.constructor,n=i._$Eh.get(e);if(n!==void 0&&this._$Em!==n){const l=i.getPropertyOptions(n),h=typeof l.converter=="function"?{fromAttribute:l.converter}:((a=l.converter)==null?void 0:a.fromAttribute)!==void 0?l.converter:Ml;this._$Em=n,this[n]=h.fromAttribute(t,l.type),this._$Em=null}}requestUpdate(e,t,i,n=!1,a){if(e!==void 0){if(i??(i=this.constructor.getPropertyOptions(e)),!(i.hasChanged??Nh)(n?a:this[e],t))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$Eg=this._$EP())}C(e,t,i){this._$AL.has(e)||this._$AL.set(e,t),i.reflect===!0&&this._$Em!==e&&(this._$Ej??(this._$Ej=new Set)).add(e)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!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[a,l]of this._$Ep)this[a]=l;this._$Ep=void 0}const n=this.constructor.elementProperties;if(n.size>0)for(const[a,l]of n)l.wrapped!==!0||this._$AL.has(a)||this[a]===void 0||this.C(a,this[a],l)}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$E_)==null||i.forEach(n=>{var a;return(a=n.hostUpdate)==null?void 0:a.call(n)}),this.update(t)):this._$ET()}catch(n){throw e=!1,this._$ET(),n}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$E_)==null||t.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(t=>this._$EO(t,this[t]))),this._$ET()}updated(e){}firstUpdated(e){}};yn.elementStyles=[],yn.shadowRootOptions={mode:"open"},yn[to("elementProperties")]=new Map,yn[to("finalized")]=new Map,$l==null||$l({ReactiveElement:yn}),(ms.reactiveElementVersions??(ms.reactiveElementVersions=[])).push("2.0.2");/**
|
24
|
+
* @license
|
25
|
+
* Copyright 2017 Google LLC
|
26
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
27
|
+
*/const io=globalThis,ia=io.trustedTypes,Bh=ia?ia.createPolicy("lit-html",{createHTML:s=>s}):void 0,Gh="$lit$",gs=`lit$${(Math.random()+"").slice(9)}$`,Vh="?"+gs,Og=`<${Vh}>`,Ys=document,ro=()=>Ys.createComment(""),so=s=>s===null||typeof s!="object"&&typeof s!="function",Hh=Array.isArray,Pg=s=>Hh(s)||typeof(s==null?void 0:s[Symbol.iterator])=="function",Fl=`[
|
28
|
+
\f\r]`,no=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Wh=/-->/g,jh=/>/g,Xs=RegExp(`>|${Fl}(?:([^\\s"'>=/]+)(${Fl}*=${Fl}*(?:[^
|
29
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Kh=/'/g,zh=/"/g,Yh=/^(?:script|style|textarea|title)$/i,$g=s=>(e,...t)=>({_$litType$:s,strings:e,values:t}),it=$g(1),vs=Symbol.for("lit-noChange"),fi=Symbol.for("lit-nothing"),Xh=new WeakMap,Zs=Ys.createTreeWalker(Ys,129);function Zh(s,e){if(!Array.isArray(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return Bh!==void 0?Bh.createHTML(e):e}const Mg=(s,e)=>{const t=s.length-1,i=[];let n,a=e===2?"<svg>":"",l=no;for(let h=0;h<t;h++){const d=s[h];let p,m,g=-1,A=0;for(;A<d.length&&(l.lastIndex=A,m=l.exec(d),m!==null);)A=l.lastIndex,l===no?m[1]==="!--"?l=Wh:m[1]!==void 0?l=jh:m[2]!==void 0?(Yh.test(m[2])&&(n=RegExp("</"+m[2],"g")),l=Xs):m[3]!==void 0&&(l=Xs):l===Xs?m[0]===">"?(l=n??no,g=-1):m[1]===void 0?g=-2:(g=l.lastIndex-m[2].length,p=m[1],l=m[3]===void 0?Xs:m[3]==='"'?zh:Kh):l===zh||l===Kh?l=Xs:l===Wh||l===jh?l=no:(l=Xs,n=void 0);const x=l===Xs&&s[h+1].startsWith("/>")?" ":"";a+=l===no?d+Og:g>=0?(i.push(p),d.slice(0,g)+Gh+d.slice(g)+gs+x):d+gs+(g===-2?h:x)}return[Zh(s,a+(s[t]||"<?>")+(e===2?"</svg>":"")),i]};class oo{constructor({strings:e,_$litType$:t},i){let n;this.parts=[];let a=0,l=0;const h=e.length-1,d=this.parts,[p,m]=Mg(e,t);if(this.el=oo.createElement(p,i),Zs.currentNode=this.el.content,t===2){const g=this.el.content.firstChild;g.replaceWith(...g.childNodes)}for(;(n=Zs.nextNode())!==null&&d.length<h;){if(n.nodeType===1){if(n.hasAttributes())for(const g of n.getAttributeNames())if(g.endsWith(Gh)){const A=m[l++],x=n.getAttribute(g).split(gs),b=/([.?@])?(.*)/.exec(A);d.push({type:1,index:a,name:b[2],strings:x,ctor:b[1]==="."?Ng:b[1]==="?"?Ug:b[1]==="@"?Bg:ra}),n.removeAttribute(g)}else g.startsWith(gs)&&(d.push({type:6,index:a}),n.removeAttribute(g));if(Yh.test(n.tagName)){const g=n.textContent.split(gs),A=g.length-1;if(A>0){n.textContent=ia?ia.emptyScript:"";for(let x=0;x<A;x++)n.append(g[x],ro()),Zs.nextNode(),d.push({type:2,index:++a});n.append(g[A],ro())}}}else if(n.nodeType===8)if(n.data===Vh)d.push({type:2,index:a});else{let g=-1;for(;(g=n.data.indexOf(gs,g+1))!==-1;)d.push({type:7,index:a}),g+=gs.length-1}a++}}static createElement(e,t){const i=Ys.createElement("template");return i.innerHTML=e,i}}function An(s,e,t=s,i){var l,h;if(e===vs)return e;let n=i!==void 0?(l=t._$Co)==null?void 0:l[i]:t._$Cl;const a=so(e)?void 0:e._$litDirective$;return(n==null?void 0:n.constructor)!==a&&((h=n==null?void 0:n._$AO)==null||h.call(n,!1),a===void 0?n=void 0:(n=new a(s),n._$AT(s,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=n:t._$Cl=n),n!==void 0&&(e=An(s,n._$AS(s,e.values),n,i)),e}let Fg=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,n=((e==null?void 0:e.creationScope)??Ys).importNode(t,!0);Zs.currentNode=n;let a=Zs.nextNode(),l=0,h=0,d=i[0];for(;d!==void 0;){if(l===d.index){let p;d.type===2?p=new ao(a,a.nextSibling,this,e):d.type===1?p=new d.ctor(a,d.name,d.strings,this,e):d.type===6&&(p=new Gg(a,this,e)),this._$AV.push(p),d=i[++h]}l!==(d==null?void 0:d.index)&&(a=Zs.nextNode(),l++)}return Zs.currentNode=Ys,n}p(e){let t=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}};class ao{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,n){this.type=2,this._$AH=fi,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=n,this._$Cv=(n==null?void 0:n.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=An(this,e,t),so(e)?e===fi||e==null||e===""?(this._$AH!==fi&&this._$AR(),this._$AH=fi):e!==this._$AH&&e!==vs&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):Pg(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==fi&&so(this._$AH)?this._$AA.nextSibling.data=e:this.$(Ys.createTextNode(e)),this._$AH=e}g(e){var a;const{values:t,_$litType$:i}=e,n=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=oo.createElement(Zh(i.h,i.h[0]),this.options)),i);if(((a=this._$AH)==null?void 0:a._$AD)===n)this._$AH.p(t);else{const l=new Fg(n,this),h=l.u(this.options);l.p(t),this.$(h),this._$AH=l}}_$AC(e){let t=Xh.get(e.strings);return t===void 0&&Xh.set(e.strings,t=new oo(e)),t}T(e){Hh(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,n=0;for(const a of e)n===t.length?t.push(i=new ao(this.k(ro()),this.k(ro()),this,this.options)):i=t[n],i._$AI(a),n++;n<t.length&&(this._$AR(i&&i._$AB.nextSibling,n),t.length=n)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e&&e!==this._$AB;){const n=e.nextSibling;e.remove(),e=n}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class ra{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,n,a){this.type=1,this._$AH=fi,this._$AN=void 0,this.element=e,this.name=t,this._$AM=n,this.options=a,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=fi}_$AI(e,t=this,i,n){const a=this.strings;let l=!1;if(a===void 0)e=An(this,e,t,0),l=!so(e)||e!==this._$AH&&e!==vs,l&&(this._$AH=e);else{const h=e;let d,p;for(e=a[0],d=0;d<a.length-1;d++)p=An(this,h[i+d],t,d),p===vs&&(p=this._$AH[d]),l||(l=!so(p)||p!==this._$AH[d]),p===fi?e=fi:e!==fi&&(e+=(p??"")+a[d+1]),this._$AH[d]=p}l&&!n&&this.O(e)}O(e){e===fi?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Ng extends ra{constructor(){super(...arguments),this.type=3}O(e){this.element[this.name]=e===fi?void 0:e}}class Ug extends ra{constructor(){super(...arguments),this.type=4}O(e){this.element.toggleAttribute(this.name,!!e&&e!==fi)}}class Bg extends ra{constructor(e,t,i,n,a){super(e,t,i,n,a),this.type=5}_$AI(e,t=this){if((e=An(this,e,t,0)??fi)===vs)return;const i=this._$AH,n=e===fi&&i!==fi||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,a=e!==fi&&(i===fi||n);n&&this.element.removeEventListener(this.name,this,i),a&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}}class Gg{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){An(this,e)}}const Nl=io.litHtmlPolyfillSupport;Nl==null||Nl(oo,ao),(io.litHtmlVersions??(io.litHtmlVersions=[])).push("3.1.0");const Vg=(s,e,t)=>{const i=(t==null?void 0:t.renderBefore)??e;let n=i._$litPart$;if(n===void 0){const a=(t==null?void 0:t.renderBefore)??null;i._$litPart$=n=new ao(e.insertBefore(ro(),a),a,void 0,t??{})}return n._$AI(s),n};/**
|
30
|
+
* @license
|
31
|
+
* Copyright 2017 Google LLC
|
32
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
33
|
+
*/let En=class extends yn{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Vg(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return vs}};En._$litElement$=!0,En.finalized=!0,(zp=globalThis.litElementHydrateSupport)==null||zp.call(globalThis,{LitElement:En});const Ul=globalThis.litElementPolyfillSupport;Ul==null||Ul({LitElement:En}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.2");/**
|
34
|
+
* @license
|
35
|
+
* Copyright 2017 Google LLC
|
36
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
37
|
+
*/const Hg=s=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(s,e)}):customElements.define(s,e)};/**
|
38
|
+
* @license
|
39
|
+
* Copyright 2017 Google LLC
|
40
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
41
|
+
*/const Wg={attribute:!0,type:String,converter:Qo,reflect:!1,hasChanged:wl},jg=(s=Wg,e,t)=>{const{kind:i,metadata:n}=t;let a=globalThis.litPropertyMetadata.get(n);if(a===void 0&&globalThis.litPropertyMetadata.set(n,a=new Map),a.set(t.name,s),i==="accessor"){const{name:l}=t;return{set(h){const d=e.get.call(this);e.set.call(this,h),this.requestUpdate(l,d,s)},init(h){return h!==void 0&&this.C(l,void 0,s),h}}}if(i==="setter"){const{name:l}=t;return function(h){const d=this[l];e.call(this,h),this.requestUpdate(l,d,s)}}throw Error("Unsupported decorator location: "+i)};function De(s){return(e,t)=>typeof t=="object"?jg(s,e,t):((i,n,a)=>{const l=n.hasOwnProperty(a);return n.constructor.createProperty(a,l?{...i,wrapped:!0}:i),l?Object.getOwnPropertyDescriptor(n,a):void 0})(s,e,t)}/**
|
42
|
+
* @license
|
43
|
+
* Copyright 2017 Google LLC
|
44
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
45
|
+
*/function xi(s){return De({...s,state:!0,attribute:!1})}/**
|
46
|
+
* @license
|
47
|
+
* Copyright 2018 Google LLC
|
48
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
49
|
+
*/const qs=s=>s??ii;/**
|
50
|
+
* @license
|
51
|
+
* Copyright 2020 Google LLC
|
52
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
53
|
+
*/const{D:Kg}=Sg,zg=s=>s.strings===void 0,qh=()=>document.createComment(""),lo=(s,e,t)=>{var a;const i=s._$AA.parentNode,n=e===void 0?s._$AB:e._$AA;if(t===void 0){const l=i.insertBefore(qh(),n),h=i.insertBefore(qh(),n);t=new Kg(l,h,s,s.options)}else{const l=t._$AB.nextSibling,h=t._$AM,d=h!==s;if(d){let p;(a=t._$AQ)==null||a.call(t,s),t._$AM=s,t._$AP!==void 0&&(p=s._$AU)!==h._$AU&&t._$AP(p)}if(l!==n||d){let p=t._$AA;for(;p!==l;){const m=p.nextSibling;i.insertBefore(p,n),p=m}}}return t},Qs=(s,e,t=s)=>(s._$AI(e,t),s),Yg={},Xg=(s,e=Yg)=>s._$AH=e,Zg=s=>s._$AH,Bl=s=>{var i;(i=s._$AP)==null||i.call(s,!1,!0);let e=s._$AA;const t=s._$AB.nextSibling;for(;e!==t;){const n=e.nextSibling;e.remove(),e=n}};/**
|
54
|
+
* @license
|
55
|
+
* Copyright 2017 Google LLC
|
56
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
57
|
+
*/const xn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},bn=s=>(...e)=>({_$litDirective$:s,values:e});let co=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};/**
|
58
|
+
* @license
|
59
|
+
* Copyright 2017 Google LLC
|
60
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
61
|
+
*/const uo=(s,e)=>{var i;const t=s._$AN;if(t===void 0)return!1;for(const n of t)(i=n._$AO)==null||i.call(n,e,!1),uo(n,e);return!0},sa=s=>{let e,t;do{if((e=s._$AM)===void 0)break;t=e._$AN,t.delete(s),s=e}while((t==null?void 0:t.size)===0)},Qh=s=>{for(let e;e=s._$AM;s=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(s))break;t.add(s),Jg(e)}};function qg(s){this._$AN!==void 0?(sa(this),this._$AM=s,Qh(this)):this._$AM=s}function Qg(s,e=!1,t=0){const i=this._$AH,n=this._$AN;if(n!==void 0&&n.size!==0)if(e)if(Array.isArray(i))for(let a=t;a<i.length;a++)uo(i[a],!1),sa(i[a]);else i!=null&&(uo(i,!1),sa(i));else uo(this,s)}const Jg=s=>{s.type==xn.CHILD&&(s._$AP??(s._$AP=Qg),s._$AQ??(s._$AQ=qg))};let Jh=class extends co{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,i){super._$AT(e,t,i),Qh(this),this.isConnected=e._$AU}_$AO(e,t=!0){var i,n;e!==this.isConnected&&(this.isConnected=e,e?(i=this.reconnected)==null||i.call(this):(n=this.disconnected)==null||n.call(this)),t&&(uo(this,e),sa(this))}setValue(e){if(zg(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}};/**
|
62
|
+
* @license
|
63
|
+
* Copyright 2020 Google LLC
|
64
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
65
|
+
*/const _i=()=>new e2;let e2=class{};const Gl=new WeakMap,Ri=bn(class extends Jh{render(s){return ii}update(s,[e]){var i;const t=e!==this.G;return t&&this.G!==void 0&&this.ot(void 0),(t||this.rt!==this.lt)&&(this.G=e,this.ct=(i=s.options)==null?void 0:i.host,this.ot(this.lt=s.element)),ii}ot(s){if(typeof this.G=="function"){const e=this.ct??globalThis;let t=Gl.get(e);t===void 0&&(t=new WeakMap,Gl.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ct,void 0),t.set(this.G,s),s!==void 0&&this.G.call(this.ct,s)}else this.G.value=s}get rt(){var s,e;return typeof this.G=="function"?(s=Gl.get(this.ct??globalThis))==null?void 0:s.get(this.G):(e=this.G)==null?void 0:e.value}disconnected(){this.rt===this.lt&&this.ot(void 0)}reconnected(){this.ot(this.lt)}});function t2(s,e,t){function i(n){t.dispatchEvent(new CustomEvent(n.type,n))}return e.addEventListener(s,i),()=>{e.removeEventListener(s,i)}}class i2{constructor(e,t){this._events=[],this._cleanup=[],this._forwardElementRef=_i(),this.host=e,this._events=t,e.addController(this)}register(){return Ri(this._forwardElementRef)}hostConnected(){requestAnimationFrame(()=>{this._events.forEach(e=>{this._forwardElementRef.value&&this._cleanup.push(t2(e,this._forwardElementRef.value,this.host))})})}hostDisconnected(){this._cleanup.forEach(e=>{e()}),this._cleanup=[]}}/**
|
66
|
+
* @license
|
67
|
+
* Copyright 2019 Google LLC
|
68
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
69
|
+
*/const na=globalThis,Vl=na.ShadowRoot&&(na.ShadyCSS===void 0||na.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,e0=Symbol(),t0=new WeakMap;let r2=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==e0)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Vl&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=t0.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&t0.set(t,e))}return e}toString(){return this.cssText}};const s2=s=>new r2(typeof s=="string"?s:s+"",void 0,e0),n2=(s,e)=>{if(Vl)s.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),n=na.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=t.cssText,s.appendChild(i)}},i0=Vl?s=>s:s=>s instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return s2(t)})(s):s;/**
|
70
|
+
* @license
|
71
|
+
* Copyright 2017 Google LLC
|
72
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
73
|
+
*/const{is:o2,defineProperty:a2,getOwnPropertyDescriptor:l2,getOwnPropertyNames:c2,getOwnPropertySymbols:u2,getPrototypeOf:h2}=Object,ys=globalThis,r0=ys.trustedTypes,f2=r0?r0.emptyScript:"",Hl=ys.reactiveElementPolyfillSupport,ho=(s,e)=>s,Wl={toAttribute(s,e){switch(e){case Boolean:s=s?f2:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,e){let t=s;switch(e){case Boolean:t=s!==null;break;case Number:t=s===null?null:Number(s);break;case Object:case Array:try{t=JSON.parse(s)}catch{t=null}}return t}},jl=(s,e)=>!o2(s,e),s0={attribute:!0,type:String,converter:Wl,reflect:!1,hasChanged:jl};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),ys.litPropertyMetadata??(ys.litPropertyMetadata=new WeakMap);class fo extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=s0){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(e,i,t);n!==void 0&&a2(this.prototype,e,n)}}static getPropertyDescriptor(e,t,i){const{get:n,set:a}=l2(this.prototype,e)??{get(){return this[t]},set(l){this[t]=l}};return{get(){return n==null?void 0:n.call(this)},set(l){const h=n==null?void 0:n.call(this);a.call(this,l),this.requestUpdate(e,h,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??s0}static _$Ei(){if(this.hasOwnProperty(ho("elementProperties")))return;const e=h2(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(ho("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ho("properties"))){const t=this.properties,i=[...c2(t),...u2(t)];for(const n of i)this.createProperty(n,t[n])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,n]of t)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const n=this._$Eu(t,i);n!==void 0&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const n of i)t.unshift(i0(n))}else e!==void 0&&t.push(i0(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$Eg=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$ES??(this._$ES=[])).push(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$ES)==null||t.splice(this._$ES.indexOf(e)>>>0,1)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return n2(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$ES)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t){var a;const i=this.constructor.elementProperties.get(e),n=this.constructor._$Eu(e,i);if(n!==void 0&&i.reflect===!0){const l=(((a=i.converter)==null?void 0:a.toAttribute)!==void 0?i.converter:Wl).toAttribute(t,i.type);this._$Em=e,l==null?this.removeAttribute(n):this.setAttribute(n,l),this._$Em=null}}_$AK(e,t){var a;const i=this.constructor,n=i._$Eh.get(e);if(n!==void 0&&this._$Em!==n){const l=i.getPropertyOptions(n),h=typeof l.converter=="function"?{fromAttribute:l.converter}:((a=l.converter)==null?void 0:a.fromAttribute)!==void 0?l.converter:Wl;this._$Em=n,this[n]=h.fromAttribute(t,l.type),this._$Em=null}}requestUpdate(e,t,i,n=!1,a){if(e!==void 0){if(i??(i=this.constructor.getPropertyOptions(e)),!(i.hasChanged??jl)(n?a:this[e],t))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$Eg=this._$EP())}C(e,t,i){this._$AL.has(e)||this._$AL.set(e,t),i.reflect===!0&&this._$Em!==e&&(this._$Ej??(this._$Ej=new Set)).add(e)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this._$Ep){for(const[a,l]of this._$Ep)this[a]=l;this._$Ep=void 0}const n=this.constructor.elementProperties;if(n.size>0)for(const[a,l]of n)l.wrapped!==!0||this._$AL.has(a)||this[a]===void 0||this.C(a,this[a],l)}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$ES)==null||i.forEach(n=>{var a;return(a=n.hostUpdate)==null?void 0:a.call(n)}),this.update(t)):this._$ET()}catch(n){throw e=!1,this._$ET(),n}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$ES)==null||t.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(t=>this._$EO(t,this[t]))),this._$ET()}updated(e){}firstUpdated(e){}}fo.elementStyles=[],fo.shadowRootOptions={mode:"open"},fo[ho("elementProperties")]=new Map,fo[ho("finalized")]=new Map,Hl==null||Hl({ReactiveElement:fo}),(ys.reactiveElementVersions??(ys.reactiveElementVersions=[])).push("2.0.0");/**
|
74
|
+
* @license
|
75
|
+
* Copyright 2017 Google LLC
|
76
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
77
|
+
*/const d2=Symbol();class oa{get taskComplete(){return this.t||(this.status===1?this.t=new Promise((e,t)=>{this.i=e,this.o=t}):this.status===3?this.t=Promise.reject(this.h):this.t=Promise.resolve(this.l)),this.t}constructor(e,t,i){var a;this.u=0,this.status=0,(this.p=e).addController(this);const n=typeof t=="object"?t:{task:t,args:i};this._=n.task,this.v=n.args,this.j=n.argsEqual??p2,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=(a=this.A)==null?void 0:a.call(this))}hostUpdate(){this.autoRun===!0&&this.O()}hostUpdated(){this.autoRun==="afterUpdate"&&this.O()}A(){if(this.v===void 0)return;const e=this.v();if(!Array.isArray(e))throw Error("The args function must return an array");return e}async O(){const e=this.A(),t=this.k;this.k=e,e===t||e===void 0||t!==void 0&&this.j(t,e)||await this.run(e)}async run(e){var l,h,d,p,m;let t,i;e??(e=this.A()),this.k=e,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 a=!1;try{t=await this._(e,{signal:this.T.signal})}catch(g){a=!0,i=g}if(this.u===n){if(t===d2)this.status=0;else{if(a===!1){try{(h=this.m)==null||h.call(this,t)}catch{}this.status=2,(d=this.i)==null||d.call(this,t)}else{try{(p=this.g)==null||p.call(this,i)}catch{}this.status=3,(m=this.o)==null||m.call(this,i)}this.l=t,this.h=i}this.p.requestUpdate()}}abort(e){var t;this.status===1&&((t=this.T)==null||t.abort(e))}get value(){return this.l}get error(){return this.h}render(e){var t,i,n,a;switch(this.status){case 0:return(t=e.initial)==null?void 0:t.call(e);case 1:return(i=e.pending)==null?void 0:i.call(e);case 2:return(n=e.complete)==null?void 0:n.call(e,this.value);case 3:return(a=e.error)==null?void 0:a.call(e,this.error);default:throw Error("Unexpected status: "+this.status)}}}const p2=(s,e)=>s===e||s.length===e.length&&s.every((t,i)=>!jl(t,e[i]));let aa;const m2=new Uint8Array(16);function g2(){if(!aa&&(aa=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!aa))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return aa(m2)}const bi=[];for(let s=0;s<256;++s)bi.push((s+256).toString(16).slice(1));function v2(s,e=0){return bi[s[e+0]]+bi[s[e+1]]+bi[s[e+2]]+bi[s[e+3]]+"-"+bi[s[e+4]]+bi[s[e+5]]+"-"+bi[s[e+6]]+bi[s[e+7]]+"-"+bi[s[e+8]]+bi[s[e+9]]+"-"+bi[s[e+10]]+bi[s[e+11]]+bi[s[e+12]]+bi[s[e+13]]+bi[s[e+14]]+bi[s[e+15]]}const n0={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Js(s,e,t){if(n0.randomUUID&&!e&&!s)return n0.randomUUID();s=s||{};const i=s.random||(s.rng||g2)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(let n=0;n<16;++n)e[t+n]=i[n];return e}return v2(i)}const o0="https://d2rxhdlm2q91uk.cloudfront.net",y2="https://d1ix11aj5kfygl.cloudfront.net",A2="https://d157jlwnudd93d.cloudfront.net",a0="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",E2="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",x2="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",b2="http://localhost:6060/v2",T2="https://embed-dev.vouchfor.com/v2",S2="https://embed-staging.vouchfor.com/v2",k2="https://embed.vouchfor.com/v2";function la(s){if(!["local","dev","staging","prod"].includes(s))throw new Error(`Unknown environment: ${s}`);if(s==="local")return{videoUrl:o0,publicApiUrl:a0,embedApiUrl:b2};if(s==="dev")return{videoUrl:o0,publicApiUrl:a0,embedApiUrl:T2};if(s==="staging")return{videoUrl:y2,publicApiUrl:E2,embedApiUrl:S2};if(s==="prod")return{videoUrl:A2,publicApiUrl:x2,embedApiUrl:k2}}class w2{constructor(e){this._fetching=!1,this.getVouch=async(t,i,n)=>{var m;const{embedApiUrl:a}=la(t),l=Js(),h=await fetch(`${a}/vouches/${n}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",l]]}),d=await h.json();return this.host.dispatchEvent(new CustomEvent("vouch:loaded",{detail:d==null?void 0:d.id})),((m=h==null?void 0:h.headers)==null?void 0:m.get("X-Cache-Check"))!==l&&fetch(`${a}/vouches/${n}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),d},this.getTemplate=async(t,i,n)=>{var m;const{embedApiUrl:a}=la(t),l=Js(),h=await fetch(`${a}/templates/${n}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",l]]}),d=await h.json();return((m=h==null?void 0:h.headers)==null?void 0:m.get("X-Cache-Check"))!==l&&fetch(`${a}/templates/${n}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),d},this.host=e,new oa(this.host,async([t,i,n,a,l])=>{var h,d,p,m;try{if(e.vouch=void 0,e.template=void 0,n){let g;l&&(this.fetching=!0,g=await this.getTemplate(t,i,l)),this._vouch=n,e.template=g??((d=(h=n==null?void 0:n.settings)==null?void 0:h.template)==null?void 0:d.instance)}else if(a){this.fetching=!0;const[g,A]=await Promise.all([this.getVouch(t,i,a),l?this.getTemplate(t,i,l):null]);this._vouch=g,e.template=A??((m=(p=g==null?void 0:g.settings)==null?void 0:p.template)==null?void 0:m.instance)}}finally{this.fetching=!1}},()=>[e.env,e.apiKey,e.data,e.vouchId,e.templateId]),new oa(this.host,([t,i])=>{e.vouch=t?{...t,questions:{items:t==null?void 0:t.questions.items.filter((n,a)=>!(i!=null&&i.length)||(i==null?void 0:i.includes(a+1)))}}:void 0},()=>[this._vouch,e.questions])}set fetching(e){this._fetching!==e&&(this._fetching=e,this.host.requestUpdate())}get fetching(){return this._fetching}}const _2=(s,e,t,i)=>{if(t==="length"||t==="prototype"||t==="arguments"||t==="caller")return;const n=Object.getOwnPropertyDescriptor(s,t),a=Object.getOwnPropertyDescriptor(e,t);!R2(n,a)&&i||Object.defineProperty(s,t,a)},R2=function(s,e){return s===void 0||s.configurable||s.writable===e.writable&&s.enumerable===e.enumerable&&s.configurable===e.configurable&&(s.writable||s.value===e.value)},L2=(s,e)=>{const t=Object.getPrototypeOf(e);t!==Object.getPrototypeOf(s)&&Object.setPrototypeOf(s,t)},C2=(s,e)=>`/* Wrapped ${s}*/
|
78
|
+
${e}`,I2=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),D2=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),O2=(s,e,t)=>{const i=t===""?"":`with ${t.trim()}() `,n=C2.bind(null,i,e.toString());Object.defineProperty(n,"name",D2),Object.defineProperty(s,"toString",{...I2,value:n})};function P2(s,e,{ignoreNonConfigurable:t=!1}={}){const{name:i}=s;for(const n of Reflect.ownKeys(e))_2(s,e,n,t);return L2(s,e),O2(s,e,i),s}const $2=new WeakMap,l0=new WeakMap;function Kl(s,{cacheKey:e,cache:t=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(...a){var p;const l=e?e(a):a[0],h=t.get(l);if(h)return h.data;const d=s.apply(this,a);if(t.set(l,{data:d,maxAge:i?Date.now()+i:Number.POSITIVE_INFINITY}),typeof i=="number"&&i!==Number.POSITIVE_INFINITY){const m=setTimeout(()=>{t.delete(l)},i);(p=m.unref)==null||p.call(m);const g=l0.get(s)??new Set;g.add(m),l0.set(s,g)}return d};return P2(n,s,{ignoreNonConfigurable:!0}),$2.set(n,t),n}var ca=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ua(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var bt={},zl={},nt={};Object.defineProperty(nt,"__esModule",{value:!0}),nt.default=nt.Wrap=nt.Unit=nt.PrintOptions=nt.PositionType=nt.Overflow=nt.NodeType=nt.MeasureMode=nt.LogLevel=nt.Justify=nt.Gutter=nt.FlexDirection=nt.ExperimentalFeature=nt.Errata=nt.Edge=nt.Display=nt.Direction=nt.Dimension=nt.Align=void 0;let qr=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}({});nt.Align=qr;let Yl=function(s){return s[s.Width=0]="Width",s[s.Height=1]="Height",s}({});nt.Dimension=Yl;let ha=function(s){return s[s.Inherit=0]="Inherit",s[s.LTR=1]="LTR",s[s.RTL=2]="RTL",s}({});nt.Direction=ha;let Xl=function(s){return s[s.Flex=0]="Flex",s[s.None=1]="None",s}({});nt.Display=Xl;let Cr=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}({});nt.Edge=Cr;let po=function(s){return s[s.None=0]="None",s[s.StretchFlexBasis=1]="StretchFlexBasis",s[s.All=2147483647]="All",s[s.Classic=2147483646]="Classic",s}({});nt.Errata=po;let fa=function(s){return s[s.WebFlexBasis=0]="WebFlexBasis",s[s.AbsolutePercentageAgainstPaddingEdge=1]="AbsolutePercentageAgainstPaddingEdge",s[s.FixJNILocalRefOverflows=2]="FixJNILocalRefOverflows",s}({});nt.ExperimentalFeature=fa;let mo=function(s){return s[s.Column=0]="Column",s[s.ColumnReverse=1]="ColumnReverse",s[s.Row=2]="Row",s[s.RowReverse=3]="RowReverse",s}({});nt.FlexDirection=mo;let da=function(s){return s[s.Column=0]="Column",s[s.Row=1]="Row",s[s.All=2]="All",s}({});nt.Gutter=da;let en=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}({});nt.Justify=en;let tn=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}({});nt.LogLevel=tn;let pa=function(s){return s[s.Undefined=0]="Undefined",s[s.Exactly=1]="Exactly",s[s.AtMost=2]="AtMost",s}({});nt.MeasureMode=pa;let Zl=function(s){return s[s.Default=0]="Default",s[s.Text=1]="Text",s}({});nt.NodeType=Zl;let ma=function(s){return s[s.Visible=0]="Visible",s[s.Hidden=1]="Hidden",s[s.Scroll=2]="Scroll",s}({});nt.Overflow=ma;let ga=function(s){return s[s.Static=0]="Static",s[s.Relative=1]="Relative",s[s.Absolute=2]="Absolute",s}({});nt.PositionType=ga;let va=function(s){return s[s.Layout=1]="Layout",s[s.Style=2]="Style",s[s.Children=4]="Children",s}({});nt.PrintOptions=va;let go=function(s){return s[s.Undefined=0]="Undefined",s[s.Point=1]="Point",s[s.Percent=2]="Percent",s[s.Auto=3]="Auto",s}({});nt.Unit=go;let ya=function(s){return s[s.NoWrap=0]="NoWrap",s[s.Wrap=1]="Wrap",s[s.WrapReverse=2]="WrapReverse",s}({});nt.Wrap=ya;var M2={ALIGN_AUTO:qr.Auto,ALIGN_FLEX_START:qr.FlexStart,ALIGN_CENTER:qr.Center,ALIGN_FLEX_END:qr.FlexEnd,ALIGN_STRETCH:qr.Stretch,ALIGN_BASELINE:qr.Baseline,ALIGN_SPACE_BETWEEN:qr.SpaceBetween,ALIGN_SPACE_AROUND:qr.SpaceAround,DIMENSION_WIDTH:Yl.Width,DIMENSION_HEIGHT:Yl.Height,DIRECTION_INHERIT:ha.Inherit,DIRECTION_LTR:ha.LTR,DIRECTION_RTL:ha.RTL,DISPLAY_FLEX:Xl.Flex,DISPLAY_NONE:Xl.None,EDGE_LEFT:Cr.Left,EDGE_TOP:Cr.Top,EDGE_RIGHT:Cr.Right,EDGE_BOTTOM:Cr.Bottom,EDGE_START:Cr.Start,EDGE_END:Cr.End,EDGE_HORIZONTAL:Cr.Horizontal,EDGE_VERTICAL:Cr.Vertical,EDGE_ALL:Cr.All,ERRATA_NONE:po.None,ERRATA_STRETCH_FLEX_BASIS:po.StretchFlexBasis,ERRATA_ALL:po.All,ERRATA_CLASSIC:po.Classic,EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS:fa.WebFlexBasis,EXPERIMENTAL_FEATURE_ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE:fa.AbsolutePercentageAgainstPaddingEdge,EXPERIMENTAL_FEATURE_FIX_JNILOCAL_REF_OVERFLOWS:fa.FixJNILocalRefOverflows,FLEX_DIRECTION_COLUMN:mo.Column,FLEX_DIRECTION_COLUMN_REVERSE:mo.ColumnReverse,FLEX_DIRECTION_ROW:mo.Row,FLEX_DIRECTION_ROW_REVERSE:mo.RowReverse,GUTTER_COLUMN:da.Column,GUTTER_ROW:da.Row,GUTTER_ALL:da.All,JUSTIFY_FLEX_START:en.FlexStart,JUSTIFY_CENTER:en.Center,JUSTIFY_FLEX_END:en.FlexEnd,JUSTIFY_SPACE_BETWEEN:en.SpaceBetween,JUSTIFY_SPACE_AROUND:en.SpaceAround,JUSTIFY_SPACE_EVENLY:en.SpaceEvenly,LOG_LEVEL_ERROR:tn.Error,LOG_LEVEL_WARN:tn.Warn,LOG_LEVEL_INFO:tn.Info,LOG_LEVEL_DEBUG:tn.Debug,LOG_LEVEL_VERBOSE:tn.Verbose,LOG_LEVEL_FATAL:tn.Fatal,MEASURE_MODE_UNDEFINED:pa.Undefined,MEASURE_MODE_EXACTLY:pa.Exactly,MEASURE_MODE_AT_MOST:pa.AtMost,NODE_TYPE_DEFAULT:Zl.Default,NODE_TYPE_TEXT:Zl.Text,OVERFLOW_VISIBLE:ma.Visible,OVERFLOW_HIDDEN:ma.Hidden,OVERFLOW_SCROLL:ma.Scroll,POSITION_TYPE_STATIC:ga.Static,POSITION_TYPE_RELATIVE:ga.Relative,POSITION_TYPE_ABSOLUTE:ga.Absolute,PRINT_OPTIONS_LAYOUT:va.Layout,PRINT_OPTIONS_STYLE:va.Style,PRINT_OPTIONS_CHILDREN:va.Children,UNIT_UNDEFINED:go.Undefined,UNIT_POINT:go.Point,UNIT_PERCENT:go.Percent,UNIT_AUTO:go.Auto,WRAP_NO_WRAP:ya.NoWrap,WRAP_WRAP:ya.Wrap,WRAP_WRAP_REVERSE:ya.WrapReverse};nt.default=M2,Object.defineProperty(zl,"__esModule",{value:!0}),zl.default=N2;var As=F2(nt);function c0(s){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(c0=function(i){return i?t:e})(s)}function F2(s,e){if(!e&&s&&s.__esModule)return s;if(s===null||typeof s!="object"&&typeof s!="function")return{default:s};var t=c0(e);if(t&&t.has(s))return t.get(s);var i={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in s)if(a!=="default"&&Object.prototype.hasOwnProperty.call(s,a)){var l=n?Object.getOwnPropertyDescriptor(s,a):null;l&&(l.get||l.set)?Object.defineProperty(i,a,l):i[a]=s[a]}return i.default=s,t&&t.set(s,i),i}function N2(s){function e(n,a,l){const h=n[a];n[a]=function(){for(var d=arguments.length,p=new Array(d),m=0;m<d;m++)p[m]=arguments[m];return l.call(this,h,...p)}}for(const n of["setPosition","setMargin","setFlexBasis","setWidth","setHeight","setMinWidth","setMinHeight","setMaxWidth","setMaxHeight","setPadding"]){const a={[As.Unit.Point]:s.Node.prototype[n],[As.Unit.Percent]:s.Node.prototype[`${n}Percent`],[As.Unit.Auto]:s.Node.prototype[`${n}Auto`]};e(s.Node.prototype,n,function(l){for(var h=arguments.length,d=new Array(h>1?h-1:0),p=1;p<h;p++)d[p-1]=arguments[p];const m=d.pop();let g,A;if(m==="auto")g=As.Unit.Auto,A=void 0;else if(typeof m=="object")g=m.unit,A=m.valueOf();else if(g=typeof m=="string"&&m.endsWith("%")?As.Unit.Percent:As.Unit.Point,A=parseFloat(m),!Number.isNaN(m)&&Number.isNaN(A))throw new Error(`Invalid value ${m} for ${n}`);if(!a[g])throw new Error(`Failed to execute "${n}": Unsupported unit '${m}'`);return A!==void 0?a[g].call(this,...d,A):a[g].call(this,...d)})}function t(n){return s.MeasureCallback.implement({measure:function(){const{width:a,height:l}=n(...arguments);return{width:a??NaN,height:l??NaN}}})}e(s.Node.prototype,"setMeasureFunc",function(n,a){return a?n.call(this,t(a)):this.unsetMeasureFunc()});function i(n){return s.DirtiedCallback.implement({dirtied:n})}return e(s.Node.prototype,"setDirtiedFunc",function(n,a){n.call(this,i(a))}),e(s.Config.prototype,"free",function(){s.Config.destroy(this)}),e(s.Node,"create",(n,a)=>a?s.Node.createWithConfig(a):s.Node.createDefault()),e(s.Node.prototype,"free",function(){s.Node.destroy(this)}),e(s.Node.prototype,"freeRecursive",function(){for(let n=0,a=this.getChildCount();n<a;++n)this.getChild(0).freeRecursive();this.free()}),e(s.Node.prototype,"calculateLayout",function(n){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:NaN,l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:NaN,h=arguments.length>3&&arguments[3]!==void 0?arguments[3]:As.Direction.LTR;return n.call(this,a,l,h)}),{Config:s.Config,Node:s.Node,...As.default}}var u0={exports:{}};(function(s,e){var t=(()=>{var i=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(n){n=n||{};var a;a||(a=typeof n<"u"?n:{});var l,h;a.ready=new Promise(function(R,L){l=R,h=L});var d=Object.assign({},a),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 m=a.print||console.log.bind(console),g=a.printErr||console.warn.bind(console);Object.assign(a,d),d=null;var A;a.wasmBinary&&(A=a.wasmBinary),a.noExitRuntime;function x(){this.buffer=new ArrayBuffer(B/65536*65536)}function b(){}function S(R){this.exports=function(V){function X(gi){return gi.set=function(ut,nr){this[ut]=nr},gi.get=function(ut){return this[ut]},gi}for(var Z,ye=new Uint8Array(123),Te=25;Te>=0;--Te)ye[48+Te]=52+Te,ye[65+Te]=Te,ye[97+Te]=26+Te;ye[43]=62,ye[47]=63;function le(gi,ut,nr){for(var Gi,ge,Br=0,c=ut,xe=nr.length,Bn=ut+(xe*3>>2)-(nr[xe-2]=="=")-(nr[xe-1]=="=");Br<xe;Br+=4)Gi=ye[nr.charCodeAt(Br+1)],ge=ye[nr.charCodeAt(Br+2)],gi[c++]=ye[nr.charCodeAt(Br)]<<2|Gi>>4,c<Bn&&(gi[c++]=Gi<<4|ge>>2),c<Bn&&(gi[c++]=ge<<6|ye[nr.charCodeAt(Br+3)])}function Pe(gi){le(Z,1024,"T25seSBsZWFmIG5vZGVzIHdpdGggY3VzdG9tIG1lYXN1cmUgZnVuY3Rpb25zIHNob3VsZCBtYW51YWxseSBtYXJrIHRoZW1zZWx2ZXMgYXMgZGlydHkAaXNEaXJ0eQBtYXJrRGlydHkAZGVzdHJveQBzZXREaXNwbGF5AGdldERpc3BsYXkAc2V0RmxleAAtKyAgIDBYMHgALTBYKzBYIDBYLTB4KzB4IDB4AHNldEZsZXhHcm93AGdldEZsZXhHcm93AHNldE92ZXJmbG93AGdldE92ZXJmbG93AGNhbGN1bGF0ZUxheW91dABnZXRDb21wdXRlZExheW91dAB1bnNpZ25lZCBzaG9ydABnZXRDaGlsZENvdW50AHVuc2lnbmVkIGludABzZXRKdXN0aWZ5Q29udGVudABnZXRKdXN0aWZ5Q29udGVudABzZXRBbGlnbkNvbnRlbnQAZ2V0QWxpZ25Db250ZW50AGdldFBhcmVudABpbXBsZW1lbnQAc2V0TWF4SGVpZ2h0UGVyY2VudABzZXRIZWlnaHRQZXJjZW50AHNldE1pbkhlaWdodFBlcmNlbnQAc2V0RmxleEJhc2lzUGVyY2VudABzZXRQb3NpdGlvblBlcmNlbnQAc2V0TWFyZ2luUGVyY2VudABzZXRNYXhXaWR0aFBlcmNlbnQAc2V0V2lkdGhQZXJjZW50AHNldE1pbldpZHRoUGVyY2VudABzZXRQYWRkaW5nUGVyY2VudABjcmVhdGVEZWZhdWx0AHVuaXQAcmlnaHQAaGVpZ2h0AHNldE1heEhlaWdodABnZXRNYXhIZWlnaHQAc2V0SGVpZ2h0AGdldEhlaWdodABzZXRNaW5IZWlnaHQAZ2V0TWluSGVpZ2h0AGdldENvbXB1dGVkSGVpZ2h0AGdldENvbXB1dGVkUmlnaHQAbGVmdABnZXRDb21wdXRlZExlZnQAcmVzZXQAX19kZXN0cnVjdABmbG9hdAB1aW50NjRfdAB1c2VXZWJEZWZhdWx0cwBzZXRVc2VXZWJEZWZhdWx0cwBzZXRBbGlnbkl0ZW1zAGdldEFsaWduSXRlbXMAc2V0RmxleEJhc2lzAGdldEZsZXhCYXNpcwBDYW5ub3QgZ2V0IGxheW91dCBwcm9wZXJ0aWVzIG9mIG11bHRpLWVkZ2Ugc2hvcnRoYW5kcwB1c2VMZWdhY3lTdHJldGNoQmVoYXZpb3VyAHNldFVzZUxlZ2FjeVN0cmV0Y2hCZWhhdmlvdXIAc2V0UG9pbnRTY2FsZUZhY3RvcgBNZWFzdXJlQ2FsbGJhY2tXcmFwcGVyAERpcnRpZWRDYWxsYmFja1dyYXBwZXIAQ2Fubm90IHJlc2V0IGEgbm9kZSBzdGlsbCBhdHRhY2hlZCB0byBhIG93bmVyAHNldEJvcmRlcgBnZXRCb3JkZXIAZ2V0Q29tcHV0ZWRCb3JkZXIAdW5zaWduZWQgY2hhcgB0b3AAZ2V0Q29tcHV0ZWRUb3AAc2V0RmxleFdyYXAAZ2V0RmxleFdyYXAAc2V0R2FwAGdldEdhcAAlcABzZXRIZWlnaHRBdXRvAHNldEZsZXhCYXNpc0F1dG8Ac2V0TWFyZ2luQXV0bwBzZXRXaWR0aEF1dG8AU2NhbGUgZmFjdG9yIHNob3VsZCBub3QgYmUgbGVzcyB0aGFuIHplcm8Ac2V0QXNwZWN0UmF0aW8AZ2V0QXNwZWN0UmF0aW8Ac2V0UG9zaXRpb24AZ2V0UG9zaXRpb24Abm90aWZ5T25EZXN0cnVjdGlvbgBzZXRGbGV4RGlyZWN0aW9uAGdldEZsZXhEaXJlY3Rpb24Ac2V0TWFyZ2luAGdldE1hcmdpbgBnZXRDb21wdXRlZE1hcmdpbgBuYW4AYm90dG9tAGdldENvbXB1dGVkQm90dG9tAGJvb2wAZW1zY3JpcHRlbjo6dmFsAHNldEZsZXhTaHJpbmsAZ2V0RmxleFNocmluawBNZWFzdXJlQ2FsbGJhY2sARGlydGllZENhbGxiYWNrAHdpZHRoAHNldE1heFdpZHRoAGdldE1heFdpZHRoAHNldFdpZHRoAGdldFdpZHRoAHNldE1pbldpZHRoAGdldE1pbldpZHRoAGdldENvbXB1dGVkV2lkdGgAdW5zaWduZWQgbG9uZwBzdGQ6OndzdHJpbmcAc3RkOjpzdHJpbmcAc3RkOjp1MTZzdHJpbmcAc3RkOjp1MzJzdHJpbmcAc2V0UGFkZGluZwBnZXRQYWRkaW5nAGdldENvbXB1dGVkUGFkZGluZwBBdHRlbXB0aW5nIHRvIGNvbnN0cnVjdCBZR05vZGUgd2l0aCBudWxsIGNvbmZpZwBUcmllZCB0byBjb25zdHJ1Y3QgWUdOb2RlIHdpdGggbnVsbCBjb25maWcAY3JlYXRlV2l0aENvbmZpZwBpbmYAc2V0QWxpZ25TZWxmAGdldEFsaWduU2VsZgBTaXplAHZhbHVlAFZhbHVlAGNyZWF0ZQBtZWFzdXJlAHNldFBvc2l0aW9uVHlwZQBnZXRQb3NpdGlvblR5cGUAaXNSZWZlcmVuY2VCYXNlbGluZQBzZXRJc1JlZmVyZW5jZUJhc2VsaW5lAGNvcHlTdHlsZQBkb3VibGUATm9kZQBleHRlbmQAaW5zZXJ0Q2hpbGQAZ2V0Q2hpbGQAcmVtb3ZlQ2hpbGQAdm9pZABhdmFpbGFibGVIZWlnaHQgaXMgaW5kZWZpbml0ZSBzbyBoZWlnaHRNZWFzdXJlTW9kZSBtdXN0IGJlIFlHTWVhc3VyZU1vZGVVbmRlZmluZWQAYXZhaWxhYmxlV2lkdGggaXMgaW5kZWZpbml0ZSBzbyB3aWR0aE1lYXN1cmVNb2RlIG11c3QgYmUgWUdNZWFzdXJlTW9kZVVuZGVmaW5lZABzZXRFeHBlcmltZW50YWxGZWF0dXJlRW5hYmxlZABpc0V4cGVyaW1lbnRhbEZlYXR1cmVFbmFibGVkAGRpcnRpZWQAQ2Fubm90IHJlc2V0IGEgbm9kZSB3aGljaCBzdGlsbCBoYXMgY2hpbGRyZW4gYXR0YWNoZWQAdW5zZXRNZWFzdXJlRnVuYwB1bnNldERpcnRpZWRGdW5jAHNldEVycmF0YQBnZXRFcnJhdGEARXhwZWN0IGN1c3RvbSBiYXNlbGluZSBmdW5jdGlvbiB0byBub3QgcmV0dXJuIE5hTgBOQU4ASU5GAGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHNob3J0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBzaG9ydD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBpbnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGZsb2F0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQ4X3Q+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8Y2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgY2hhcj4Ac3RkOjpiYXNpY19zdHJpbmc8dW5zaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8c2lnbmVkIGNoYXI+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGRvdWJsZT4AQ2hpbGQgYWxyZWFkeSBoYXMgYSBvd25lciwgaXQgbXVzdCBiZSByZW1vdmVkIGZpcnN0LgBDYW5ub3Qgc2V0IG1lYXN1cmUgZnVuY3Rpb246IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAENhbm5vdCBhZGQgY2hpbGQ6IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAChudWxsKQAlcwoAAQAAAAMAAAAAAAAAAgAAAAMAAAABAAAAAgAAAAAAAAABAAAAAQ=="),le(Z,4338,"wH8DAAAAAADAfwAAAABpaQB2AHZp"),le(Z,4368,"exsAAHkbAAC5GwAAsxsAALkbAACzGwAAaWlpZmlmaQCsGwAAfBsAAHZpaQB9GwAAwBsAAGlpaQ=="),le(Z,4432,"xwAAAMgAAADJ"),le(Z,4452,"xwAAAMoAAADLAAAArBs="),le(Z,4480,"exsAALkbAACzGwAAuRsAALMbAADAGwAAuxsAAMAbAABpaWlpAAAAAKwbAACRGwAArBsAAJMbAACUGwAAwBs="),le(Z,4552,"zAAAAM0AAADO"),le(Z,4572,"zAAAAM8AAADLAAAAlxsAAKwbAACXGw=="),le(Z,4608,"rBsAAJcbAACzGwAArRsAAHZpaWlpAAAArBsAAJcbAAC5GwAAdmlpZgAAAACsGwAAlxsAAK0bAAB2aWlpAAAAAKwbAACXGwAAsxsAAK0bAACYGwAAsxsAAK0bAACYGwAAsxsAAJgbAABpAGRpaQB2aWlkAACcGwAAnBsAAJcbAACsGwAAnBsAAKwbAACcGwAAmxsAAKwbAACcGwAAsxsAAKwbAACcGwAAsxsAALobAAB2aWlpZAAAAKwbAACcGwAAuhsAALMbAACdGwAAmhsAAJ0bAACzGwAAmhsAAJ0bAAC6GwAAnRsAALobAACdGwAAsxsAAGRpaWkAAAAAuRsAAJwbAACzGwAAZmlpaQAAAACsGwAAnBsAAJwbAAC0GwAArBsAAJwbAACcGwAAtBsAAJ0bAACcGwAAnBsAAJwbAACcGwAAtBsAAK0bAACcGwAArBsAAJwbAACtGwAArBsAAJwbAAB5GwAArBsAAJwbAACRGwAArRsAAJ0bAAAAAAAArBsAAJwbAAC6GwAAuhsAALMbAAB2aWlkZGkAAJkbAACdGw=="),le(Z,5040,"GQAKABkZGQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAAZABEKGRkZAwoHAAEACQsYAAAJBgsAAAsABhkAAAAZGRk="),le(Z,5121,"DgAAAAAAAAAAGQAKDRkZGQANAAACAAkOAAAACQAOAAAO"),le(Z,5179,"DA=="),le(Z,5191,"EwAAAAATAAAAAAkMAAAAAAAMAAAM"),le(Z,5237,"EA=="),le(Z,5249,"DwAAAAQPAAAAAAkQAAAAAAAQAAAQ"),le(Z,5295,"Eg=="),le(Z,5307,"EQAAAAARAAAAAAkSAAAAAAASAAASAAAaAAAAGhoa"),le(Z,5362,"GgAAABoaGgAAAAAAAAk="),le(Z,5411,"FA=="),le(Z,5423,"FwAAAAAXAAAAAAkUAAAAAAAUAAAU"),le(Z,5469,"Fg=="),le(Z,5481,"FQAAAAAVAAAAAAkWAAAAAAAWAAAWAAAwMTIzNDU2Nzg5QUJDREVG"),le(Z,5556,"1Q=="),le(Z,5596,"//////////8="),le(Z,5664,"8B8BAAAAAAAF"),le(Z,5684,"0A=="),le(Z,5708,"0QAAANIAAADUGw=="),le(Z,5732,"Ag=="),le(Z,5748,"//////////8="),le(Z,5816,"BQ=="),le(Z,5828,"0w=="),le(Z,5852,"0QAAANQAAADoGwAAAAQ="),le(Z,5876,"AQ=="),le(Z,5892,"/////wo="),le(Z,5960,"1g==")}var Ie=new ArrayBuffer(16),Ge=new Int32Array(Ie),Ye=new Float32Array(Ie),yt=new Float64Array(Ie);function mt(gi){return Ge[gi]}function Le(gi,ut){Ge[gi]=ut}function ki(){return yt[0]}function $i(gi){yt[0]=gi}function St(){throw new Error("abort")}function mi(gi){Ye[2]=gi}function He(){return Ye[2]}function pl(gi){var ut=gi.a,nr=ut.a,Gi=nr.buffer;nr.grow=qk;var ge=new Int8Array(Gi),Br=new Int16Array(Gi),c=new Int32Array(Gi),xe=new Uint8Array(Gi),Bn=new Uint16Array(Gi),em=new Uint32Array(Gi),C=new Float32Array(Gi),Ht=new Float64Array(Gi),Wt=Math.imul,v=Math.fround,zt=Math.abs,yr=Math.clz32,zb=Math.min,Yb=Math.max,Xe=NaN,tm=1/0,_e=ut.b,wi=ut.c,ls=ut.d,cs=ut.e,Ps=ut.f,Gn=ut.g,Wo=ut.h,ml=ut.i,Wu=ut.j,ju=ut.k,Ku=ut.l,im=ut.m,rm=ut.n,sm=ut.o,nm=ut.p,om=ut.q,Xb=ut.r,Zb=ut.s,qb=ut.t,Qb=ut.u,Jb=ut.v,eT=ut.w,tT=ut.x,iT=ut.y,rT=ut.z,sT=ut.A,nT=ut.B,oT=ut.C,aT=ut.D,be=73712,Vi=0;function am(r,o,u,f,y,E,T,k,D,j,te,fe,ee,ie){var M=0,H=v(0),z=0,J=v(0),oe=0,ae=v(0),ve=0,Ae=v(0),Ce=0,Me=0,Ne=v(0),We=0,Je=0,lt=v(0),vt=v(0),Lt=v(0),Pt=v(0),Mt=0,jt=v(0),Xt=v(0),si=0,ni=0,Ai=v(0),Mi=0,Fi=0,Ni=0,ji=0,tr=v(0),ir=0,_r=0,Rr=0,jr=0,Kr=v(0),zr=0,Yr=0,us=0,hs=0,fs=v(0),Ns=0,Us=0,Bs=0,Gs=v(0),Vs=0,Hs=v(0),zo=0,Yo=v(0),Xo=v(0),Zo=v(0),qo=0,Tl=v(0),ah=0,lh=v(0),ch=v(0),uh=v(0),hh=v(0),fh=0,rg=0,sg=0,ng=0,og=0,ag=0,lg=0,cg=0,Zt=0,qt=v(0),zn=v(0);M=be-384|0,be=M;e:{r:{i:{if(!(y&&o!=o)){if(!(E&&u!=u)){if(z=(D?0:4)+te|0,c[z>>2]=c[z>>2]+1,z=c[r+24>>2]&3,ah=(f|0)<=1?1:f,ji=z||ah,ge[r+300|0]=xe[r+300|0]&252|ji&3,z=r+252|0,f=((ji|0)!=1)<<3,Ns=(ji|0)==2?3:2,ae=dt(r,Ns,T),C[z+f>>2]=ae,oe=z,z=((ji|0)==1)<<3,vt=kt(r,Ns,T),C[oe+z>>2]=vt,Ae=dt(r,0,T),C[r+256>>2]=Ae,Pt=kt(r,0,T),C[r+264>>2]=Pt,oe=r+268|0,Zt=oe+f|0,qt=gt(r,Ns),C[Zt>>2]=qt,Zt=z+oe|0,qt=wt(r,Ns),C[Zt>>2]=qt,H=gt(r,0),C[r+272>>2]=H,jt=wt(r,0),C[r+280>>2]=jt,oe=f,f=r+284|0,Zt=oe+f|0,qt=Dt(r,Ns,T),C[Zt>>2]=qt,Zt=f+z|0,qt=Ot(r,Ns,T),C[Zt>>2]=qt,J=Dt(r,0,T),C[r+288>>2]=J,Ne=Ot(r,0,T),C[r+296>>2]=Ne,ae=v(ae+vt),vt=v(Ae+Pt),f=c[r+8>>2],f){Ae=v(v(v(C[r+284>>2]+C[r+292>>2])+C[r+268>>2])+C[r+276>>2]),u=v(E?u-vt:Xe),H=v(v(J+Ne)+H),J=v(y?o-ae:Xe),o=J;t:{if(o!=o)break t;if(o=v(J-Ae),o!=o){o=v(0);break t}o=ht(o,v(0))}ae=v(H+jt),H=u;t:{if(u!=u)break t;if(H=v(u-ae),H!=H){H=v(0);break t}H=ht(H,v(0))}if(!((y|0)!=1|(E|0)!=1)){o=Yt(r,2,J,T),f=o!=o,H=v(v(Dt(r,2,T)+gt(r,2))+v(Ot(r,2,T)+wt(r,2)));t:{if(!(f|H!=H)){o=ht(o,H);break t}o=f?H:o}C[r+516>>2]=o,o=Yt(r,0,u,k),f=o!=o,u=v(v(Dt(r,0,T)+gt(r,0))+v(Ot(r,0,T)+wt(r,0)));t:{if(!(f|u!=u)){o=ht(o,u);break t}o=f?u:o}C[r+520>>2]=o;break e}t:{if(xe[r+4|0]&16){$e[f|0](M+24|0,r,o,y,H,E,0);break t}$e[f|0](M+24|0,r,o,y,H,E)}c[te+20>>2]=c[te+20>>2]+1,f=(ie<<2)+te|0,c[f+24>>2]=c[f+24>>2]+1,o=v(Ae+C[M+24>>2]),o=Yt(r,2,y?(y|0)==2?o:J:o,T),f=o!=o,H=v(v(Dt(r,2,T)+gt(r,2))+v(Ot(r,2,T)+wt(r,2)));t:{if(!(f|H!=H)){o=ht(o,H);break t}o=f?H:o}C[r+516>>2]=o,o=v(ae+C[M+28>>2]),o=Yt(r,0,E?(E|0)==2?o:u:o,k),f=o!=o,u=v(v(Dt(r,0,T)+gt(r,0))+v(Ot(r,0,T)+wt(r,0)));t:{if(!(f|u!=u)){o=ht(o,u);break t}o=f?u:o}C[r+520>>2]=o;break e}if(f=c[r+556>>2],ie=c[r+560>>2],(f|0)==(ie|0)){vt=v(u-vt),o=Yt(r,2,y&-3?v(o-ae):v(v(v(C[r+284>>2]+C[r+292>>2])+C[r+268>>2])+C[r+276>>2]),T),f=o!=o,u=v(v(Dt(r,2,T)+gt(r,2))+v(Ot(r,2,T)+wt(r,2)));t:{if(!(f|u!=u)){o=ht(o,u);break t}o=f?u:o}C[r+516>>2]=o,o=Yt(r,0,E&-3?vt:v(v(v(J+Ne)+H)+jt),k),f=o!=o,u=v(v(Dt(r,0,T)+gt(r,0))+v(Ot(r,0,T)+wt(r,0)));t:{if(!(f|u!=u)){o=ht(o,u);break t}o=f?u:o}C[r+520>>2]=o;break e}t:{if(D||(H=v(o-ae),J=v(u-vt),!(!(!(H<=v(0))|(y|0)!=2)&H==H|!(!(J<=v(0))|(E|0)!=2)&J==J)&((y|0)!=1|(E|0)!=1)))break t;o=Yt(r,2,H!=H||(y|0)==2&&H<v(0)?v(0):H,T),f=o!=o,u=v(v(Dt(r,2,T)+gt(r,2))+v(Ot(r,2,T)+wt(r,2)));s:{if(!(f|u!=u)){o=ht(o,u);break s}o=f?u:o}C[r+516>>2]=o,o=Yt(r,0,J!=J||(E|0)==2&&J<v(0)?v(0):J,k),f=o!=o,u=v(v(Dt(r,0,T)+gt(r,0))+v(Ot(r,0,T)+wt(r,0)));s:{if(!(f|u!=u)){o=ht(o,u);break s}o=f?u:o}C[r+520>>2]=o;break e}for(si=ie-f|0,jr=si>>2;z=c[f>>2],c[z+552>>2]!=(r|0)&&(oe=c[r+568>>2],z=xm(c[oe>>2],xe[oe+8|0],z,r,Ce,0),c[f>>2]=z,c[z+552>>2]=r),Ce=Ce+1|0,f=f+4|0,(ie|0)!=(f|0););ge[r+300|0]=xe[r+300|0]&251,Ce=3,Mi=c[r+24>>2],f=Mi>>>2&3;t:{s:{n:{if((ji|0)==2){ie=0;o:switch(f-2|0){case 0:break t;case 1:break o;default:break n}Ce=2;break t}if(Ce=2,ie=0,f>>>0>1)break s}ie=Ce}Ce=f}lh=v(o-ae),Kr=v(v(Dt(r,Ce,T)+gt(r,Ce))+v(Ot(r,Ce,T)+wt(r,Ce))),jt=v(Dt(r,ie,T)+gt(r,ie)),tr=v(jt+v(Ot(r,ie,T)+wt(r,ie))),ir=Ce>>>0>1,Ae=fm(r,0,lh,ir?Kr:tr,T),ch=v(u-vt),Xt=fm(r,1,ch,ir?tr:Kr,k),Pt=ir?Xt:Ae,vt=ir?Ae:Xt,zr=c[r+560>>2],z=c[r+556>>2],Fi=ir?y:E;t:{if((Fi|0)!=1)break t;if((z|0)==(zr|0))break i;for(f=z;;){oe=c[f>>2];s:{if(!Im(oe))break s;if(Je=0,ve)break t;n:{o:{if(!c[oe+552>>2]){H=v(0);break o}if(u=C[oe+32>>2],u!=u&&(H=v(0),u=C[oe+28>>2],!(u>v(0))))break o;if(H=u,u!=u)break n}if(v(zt(H))<v(9999999747378752e-20))break t}if(o=jn(oe),o!=o){ve=oe;break s}if(ve=oe,v(zt(o))<v(9999999747378752e-20))break t}if(Je=ve,f=f+4|0,(zr|0)==(f|0))break}}if((z|0)==(zr|0))break i;for(zo=(ji|0)<=1?1:ji,Us=Ae!=Ae,Yr=Us|(y|0)!=1,us=Xt==Xt,Bs=Ae==Ae,H=v(0);;){We=c[z>>2],hm(We),oe=c[We+24>>2];t:{if(oe&4194304){if(mm(We,0),f=xe[We+4|0],oe=f|1,ge[We+4|0]=oe,!(f&4))break t;ge[We+4|0]=oe&251;break t}if(D&&(f=oe&3,bm(We,f||zo,vt,Pt,Ae),oe=c[We+24>>2]),(oe&196608)==131072)break t;s:{if((We|0)==(Je|0)){c[Je+308>>2]=0,c[Je+304>>2]=ee,u=v(0);break s}hs=c[r+24>>2],f=hs>>>2&3;n:{o:{if((ji|0)!=2)break o;ve=3;a:switch(f-2|0){case 0:break n;case 1:break a;default:break o}ve=2;break n}ve=f}_r=ve>>>0>1,ae=_r?Ae:Xt,u=v(0),o=C[We+40>>2];n:{o:{Me=c[We+40>>2];a:{if((Me|0)==2139156720)break a;if((Me|0)==2140081935)break o;f=4336;l:{if((Me|0)!=2141891242){if(o==o)break l;f=4344}u=C[f>>2];c:{u:switch(Me=c[f+4>>2],Me|0){case 0:case 3:break u;default:break c}if(o=v(Xe),!(C[We+28>>2]>v(0)))break n;Me=ge[c[We+568>>2]+8|0]&1,f=Me?2143289344:0,Me=Me?3:1,u=(Le(2,f),He())}switch(o=v(Xe),Me-1|0){case 0:break o;case 1:break a;default:break n}}if(u=(Le(2,(Me&-1073741825)+536870912|0),He()),!(Me&1073741824))break o}o=v(v(ae*u)*v(.009999999776482582));break n}o=u}u=C[We+572>>2],Me=0;n:{o:switch(Mt=c[We+576>>2],Mt|0){case 0:case 3:break n;default:break o}if(J=C[We+572>>2],!((Mt|0)!=1|J!=J)){if(u<v(0))break n;Me=1;break n}if(Me=1,(Mt|0)!=2|J!=J||(Me=0,u<v(0)))break n;Me=Bs}J=C[We+580>>2],f=0;n:{o:switch(ni=c[We+584>>2],ni|0){case 0:case 3:break n;default:break o}if(Ne=C[We+580>>2],!((ni|0)!=1|Ne!=Ne)){if(J<v(0))break n;f=1;break n}if(f=1,(ni|0)!=2|Ne!=Ne||(f=0,J<v(0)))break n;f=us}n:{o:{if(!(o!=o|ae!=ae)){if(u=C[We+308>>2],(!(ge[c[We+568>>2]+12|0]&1)|c[We+304>>2]==(ee|0))&u==u)break n;if(u=v(v(Dt(We,ve,Ae)+gt(We,ve))+v(Ot(We,ve,Ae)+wt(We,ve))),!(u<=o)&o<u)break o;u=o;break o}if(Me&_r){J=v(v(Dt(We,2,Ae)+gt(We,2))+v(Ot(We,2,Ae)+wt(We,2))),o=v(Xe);a:switch(Mt-1|0){case 1:u=v(v(Ae*u)*v(.009999999776482582));case 0:if(o=u,J<=o)break o;break;default:break a}if(!(o==o|J==J)){u=o;break o}if(o<J){u=J;break o}u=o!=o?J:o;break o}if(!(_r|f^1)){o=v(v(Dt(We,0,Ae)+gt(We,0))+v(Ot(We,0,Ae)+wt(We,0))),u=v(Xe);a:switch(ni-1|0){case 1:J=v(v(Xt*J)*v(.009999999776482582));case 0:if(u=J,o<=u)break o;break;default:break a}if(u!=u&o!=o)break o;if(o>u){u=o;break o}u=u!=u?o:u;break o}if(c[M+360>>2]=2143289344,c[M+24>>2]=2143289344,Ni=0,c[M+356>>2]=0,c[M+352>>2]=0,Ne=v(dt(We,2,Ae)+kt(We,2,Ae)),lt=dt(We,0,Ae),Lt=kt(We,0,Ae),ae=v(Xe),Rr=0,o=v(Xe),Me){a:{l:switch(Mt-1|0){case 0:o=u;break a;case 1:break l;default:break a}o=v(v(Ae*u)*v(.009999999776482582))}c[M+356>>2]=1,o=v(Ne+o),C[M+24>>2]=o,Rr=1}if(lt=v(lt+Lt),f){u=v(Xe);a:{l:switch(ni-1|0){case 0:u=J;break a;case 1:break l;default:break a}u=v(v(Xt*J)*v(.009999999776482582))}c[M+352>>2]=1,ae=v(lt+u),C[M+360>>2]=ae,Ni=1}Mt=(hs&3145728)==2097152,ni=ve>>>0<2;a:{l:{c:{if(!(Mt&ni)){if(Mt|Us)break l;if(o!=o)break c;break l}if(Us|o==o)break a}Rr=2,c[M+356>>2]=2,C[M+24>>2]=Ae,o=Ae}l:{if(!Mt||ni){if(Mt|Xt!=Xt)break a;if(ae!=ae)break l;break a}if(ae==ae|Xt!=Xt)break a}Ni=2,c[M+352>>2]=2,C[M+360>>2]=Xt,ae=Xt}u=C[We+224>>2],Mt=u!=u;a:{if(Mt)break a;l:{if(!(_r|(Rr|0)!=1)){c[M+352>>2]=1,C[M+360>>2]=lt+v(v(o-Ne)/u);break l}if(ni|(Ni|0)!=1)break a;c[M+356>>2]=1,C[M+24>>2]=v(v(ae-lt)*u)+Ne}Ni=1,Rr=1}oe=oe>>>13&7,oe=oe||hs>>>10&7;a:{if((oe|0)==5|(Rr|0)==1|(_r|(Me|Yr))|(oe|0)!=4||(c[M+356>>2]=1,C[M+24>>2]=Ae,Mt))break a;Ni=1,c[M+352>>2]=1,C[M+360>>2]=v(Ae-Ne)/u}a:{if(ni|(E|0)!=1|Xt!=Xt|f|(oe|0)!=4|(Ni|0)==1||(c[M+352>>2]=1,C[M+360>>2]=Xt,Mt))break a;c[M+356>>2]=1,C[M+24>>2]=v(Xt-lt)*u}if(Vn(We,2,Ae,Ae,M+356|0,M+24|0),Vn(We,0,Xt,Ae,M+352|0,M+360|0),pn(We,C[M+24>>2],C[M+360>>2],ji,c[M+356>>2],c[M+352>>2],Ae,Xt,0,5,j,te,fe,ee),o=C[(We+(c[(ve<<2)+4320>>2]<<2)|0)+516>>2],f=o!=o,u=v(v(Dt(We,ve,Ae)+gt(We,ve))+v(Ot(We,ve,Ae)+wt(We,ve))),!(f|u!=u)){u=ht(o,u);break o}u=f?u:o}C[We+308>>2]=u}c[We+304>>2]=ee}H=v(H+v(u+v(dt(We,Ce,Ae)+kt(We,Ce,Ae))))}if(z=z+4|0,(zr|0)==(z|0))break}break r}c[M>>2]=3072,or(r,M),er(),St()}c[M+16>>2]=3154,or(r,M+16|0),er(),St()}H=v(0)}o=v(H+v(0)),Yo=ir?k:T,Gs=ir?T:k,si>>>0>=5&&(o=v(v(gl(r,Ce,Pt)*v(jr-1>>>0))+o)),f=o>vt,zr=Mi&786432,us=(Fi|0)==2&&zr&&f?1:Fi,We=ir?E:y,_r=(We|0)==1,rg=_r&(D^1),ir=Ce>>>0<2,sg=We&-3,Us=r+208|0,E=ie<<2,ni=E+4288|0,ng=_r&!zr,og=(We|0)!=1|D,z=Ce<<2,Rr=z+4288|0,Bs=z+4320|0,hs=Pt==Pt,ag=hs<<1,Mt=E+4320|0,lg=!Fi|!f,zo=M+52|0,uh=gl(r,ie,Pt),oe=0,f=0,Ni=0;r:{for(;;){Fi=f,Wi(M+24|0,0,44),f=c[r+560>>2],E=c[r+556>>2];i:{if((f|0)==(E|0))break i;if(f=f-E|0,(f|0)<0)break r;if(z=Ko(M+360|0,f>>2,0,zo),f=c[M+44>>2],E=c[M+48>>2]-f|0,E=$s(c[M+364>>2]-E|0,f,E),f=c[M+44>>2],c[M+364>>2]=f,c[M+44>>2]=E,ve=c[M+368>>2],Me=c[M+372>>2],E=c[M+48>>2],c[M+368>>2]=E,Je=c[M+52>>2],c[M+48>>2]=ve,c[M+52>>2]=Me,c[M+372>>2]=Je,c[z>>2]=f,(f|0)!=(E|0)&&(c[M+368>>2]=E+((f-E|0)+3&-4)),!f)break i;vi(f)}Je=c[r+24>>2],f=Je>>>2&3;i:{t:{if(E=Je&3,((E||ah)|0)!=2)break t;ve=3;s:switch(f-2|0){case 0:break i;case 1:break s;default:break t}ve=2;break i}ve=f}H=gl(r,ve,Ae),z=oe,Me=c[r+560>>2],E=c[r+556>>2];i:{if(z>>>0>=Me-E>>2>>>0)break i;for(Je=Je&786432,u=v(0);;){if(Me-E>>2>>>0<=z>>>0)break r;if(f=c[(z<<2)+E>>2],si=c[f+24>>2],!(si&4194304|(si&196608)==131072)){if(c[f+548>>2]=Fi,o=dt(f,ve,Ae),J=kt(f,ve,Ae),E=c[M+24>>2],ae=(z|0)==(oe|0)?v(0):H,o=v(o+J),J=C[f+308>>2],Ne=Yt(f,ve,J,Gs),!(!E||!(v(ae+v(o+v(u+Ne)))>vt)|!Je))break i;if(c[M+24>>2]=E+1,ae=v(ae+v(o+Ne)),C[M+28>>2]=ae+C[M+28>>2],Im(f)){t:{if(!c[f+552>>2]){o=v(0);break t}if(o=C[f+32>>2],o==o)break t;o=C[f+28>>2],o=o>v(0)?o:v(0)}C[M+32>>2]=o+C[M+32>>2],Zt=M,qt=v(C[M+36>>2]-v(jn(f)*J)),C[Zt+36>>2]=qt}E=c[M+48>>2];t:{if((E|0)!=c[M+52>>2]){c[E>>2]=f,c[M+48>>2]=E+4;break t}if(E=E-c[M+44>>2]|0,si=E>>2,Me=si+1|0,Me>>>0>=1073741824)break r;if(Mi=E>>1,Me=Ko(M+360|0,E>>>0>=2147483644?1073741823:Me>>>0<Mi>>>0?Mi:Me,si,zo),c[c[M+368>>2]>>2]=f,c[M+368>>2]=c[M+368>>2]+4,f=c[M+44>>2],E=c[M+48>>2]-f|0,E=$s(c[M+364>>2]-E|0,f,E),f=c[M+44>>2],c[M+364>>2]=f,c[M+44>>2]=E,si=c[M+368>>2],Mi=c[M+372>>2],E=c[M+48>>2],c[M+368>>2]=E,Yr=c[M+52>>2],c[M+48>>2]=si,c[M+52>>2]=Mi,c[M+372>>2]=Yr,c[Me>>2]=f,(f|0)!=(E|0)&&(c[M+368>>2]=E+((f-E|0)+3&-4)),!f)break t;vi(f)}E=c[r+556>>2],Me=c[r+560>>2],u=v(u+ae)}if(z=z+1|0,!(z>>>0<Me-E>>2>>>0))break}}Lt=C[M+32>>2],!(Lt>v(0))|!(Lt<v(1))||(c[M+32>>2]=1065353216,Lt=v(1)),Ai=C[M+36>>2],!(Ai>v(0))|!(Ai<v(1))||(c[M+36>>2]=1065353216,Ai=v(1)),c[M+40>>2]=z,Ne=C[M+28>>2],ve=c[M+24>>2],Ni&&vi(Ni),J=C[M+56>>2],si=c[M+48>>2],Ni=c[M+44>>2];i:{t:{s:{n:{if((us|0)==1)break n;u=v(0),o=C[Us>>2];o:{a:{f=c[Us>>2];l:{if((f|0)==2139156720)break l;if((f|0)==2140081935)break a;E=4336;c:{if((f|0)!=2141891242){if(o==o)break c;E=4344}switch(u=C[E>>2],o=v(Xe),c[E+4>>2]-1|0){case 0:break a;case 1:break l;default:break o}}if(u=(Le(2,(f&-1073741825)+536870912|0),He()),!(f&1073741824))break a}o=v(v(u*T)*v(.009999999776482582));break o}o=u}u=v(0),H=C[r+216>>2];o:{a:{f=c[r+216>>2];l:{if((f|0)==2139156720)break l;if((f|0)==2140081935)break a;E=4336;c:{if((f|0)!=2141891242){if(H==H)break c;E=4344}switch(u=C[E>>2],H=v(Xe),c[E+4>>2]-1|0){case 0:break a;case 1:break l;default:break o}}if(u=(Le(2,(f&-1073741825)+536870912|0),He()),!(f&1073741824))break a}H=v(v(u*T)*v(.009999999776482582));break o}H=u}u=v(0),ae=C[r+212>>2];o:{a:{f=c[r+212>>2];l:{if((f|0)==2139156720)break l;if((f|0)==2140081935)break a;E=4336;c:{if((f|0)!=2141891242){if(ae==ae)break c;E=4344}switch(u=C[E>>2],ae=v(Xe),c[E+4>>2]-1|0){case 0:break a;case 1:break l;default:break o}}if(u=(Le(2,(f&-1073741825)+536870912|0),He()),!(f&1073741824))break a}ae=v(v(u*k)*v(.009999999776482582));break o}ae=u}u=v(0),lt=C[r+220>>2];o:{a:{f=c[r+220>>2];l:{if((f|0)==2139156720)break l;if((f|0)==2140081935)break a;E=4336;c:{if((f|0)!=2141891242){if(lt==lt)break c;E=4344}switch(u=C[E>>2],lt=v(Xe),c[E+4>>2]-1|0){case 0:break a;case 1:break l;default:break o}}if(u=(Le(2,(f&-1073741825)+536870912|0),He()),!(f&1073741824))break a}lt=v(v(u*k)*v(.009999999776482582));break o}lt=u}if(f=Ce>>>0>1,u=v((f?o:ae)-Kr),u==u&u>Ne||(u=v((f?H:lt)-Kr),u==u&u<Ne))break s;if(ge[c[r+568>>2]+16|0]&1)break n;if(u=Ne,!c[r+552>>2]|Lt==v(0))break t;o=C[r+32>>2];o:{a:{if(o==o){u=o;break a}if(u=C[r+28>>2],!(u>v(0)))break o}if(u!=u){u=vt;break t}o=C[r+32>>2]}if(o!=o&&(u=Ne,o=C[r+28>>2],!(o>v(0)))||(u=vt,o!=v(0)))break t;u=Ne;break t}u=vt}if(u!=u)break t;J=v(u-Ne);break i}if(!(Ne<v(0)))break i;J=v(-Ne)}if(vt=u,!rg){i:{if((si|0)==(Ni|0)){ae=v(0);break i}for(lt=v(0),E=Ni;;){f=c[E>>2],Ne=C[f+308>>2],u=Yt(f,Ce,Ne,Gs);t:{if(J<v(0)){if(o=v(u*v(-jn(f))),!(o>v(0)|o<v(0)))break t;H=v(v(v(J/Ai)*o)+u),o=Yt(f,Ce,H,vt),Me=o!=o,ae=v(v(Dt(f,Ce,Ae)+gt(f,Ce))+v(Ot(f,Ce,Ae)+wt(f,Ce)));s:{if(!(Me|ae!=ae)){o=ht(o,ae);break s}o=Me?ae:o}if(H!=H|o!=o|o==H)break t;lt=v(lt+v(o-u)),Ai=v(v(jn(f)*Ne)+Ai);break t}if(!(J>v(0))|!c[f+552>>2]||(H=C[f+32>>2],H!=H&&(H=C[f+28>>2],!(H>v(0))))||!(H<v(0)|H>v(0)))break t;ae=v(v(v(J/Lt)*H)+u),o=Yt(f,Ce,ae,vt),Me=o!=o,Ne=v(v(Dt(f,Ce,Ae)+gt(f,Ce))+v(Ot(f,Ce,Ae)+wt(f,Ce)));s:{if(!(Me|Ne!=Ne)){o=ht(o,Ne);break s}o=Me?Ne:o}if(ae!=ae|o!=o|o==ae)break t;Lt=v(Lt-H),lt=v(lt+v(o-u))}if(E=E+4|0,(si|0)==(E|0))break}for(lt=v(J-lt),Xo=v(lt/Ai),Zo=v(lt/Lt),qo=_r&(lg|!(xe[r+26|0]&12)),Yr=!qo,Mi=c[Mt>>2],ae=v(0),Me=Ni;;){f=c[Me>>2],Ne=Yt(f,Ce,C[f+308>>2],Gs);t:{s:{if(lt<v(0)){if(H=Ne,o=v(H*v(-jn(f))),o==v(0))break t;o=Ai==v(0)?v(Ne+o):v(v(Xo*o)+Ne);break s}if(H=Ne,!(lt>v(0))|!c[f+552>>2]||(o=C[f+32>>2],o!=o&&(o=C[f+28>>2],!(o>v(0))))||!(o<v(0)|o>v(0)))break t;o=v(v(Zo*o)+Ne)}if(o=Yt(f,Ce,o,vt),E=o!=o,u=v(v(Dt(f,Ce,Ae)+gt(f,Ce))+v(Ot(f,Ce,Ae)+wt(f,Ce))),!(E|u!=u)){H=ht(o,u);break t}H=E?u:o}o=dt(f,Ce,Ae),u=kt(f,Ce,Ae),Lt=dt(f,ie,Ae),Tl=kt(f,ie,Ae),u=v(o+u),hh=v(H+u),C[M+352>>2]=hh,c[M+344>>2]=1,Lt=v(Lt+Tl),o=C[f+224>>2];t:{if(o==o){c[M+348>>2]=1,u=v(hh-u),C[M+356>>2]=Lt+v(ir?u*o:u/o);break t}s:{if(Vs=Pt!=Pt,Vs)break s;Je=(Mi<<3)+f|0,o=C[Je+572>>2];n:{o:{a:{l:switch(E=c[Je+576>>2],E|0){case 0:case 3:break a;default:break l}if(u=C[Je+572>>2],(E|0)!=1|u!=u)break o;if(!(Yr|!(o<v(0))))break n;break s}if(!qo)break s;break n}if(Yr|(!(o<v(0))|((E|0)!=2|u!=u)))break s}if(E=c[f+24>>2]>>>13&7,E||(E=c[r+24>>2]>>>10&7),(E|0)!=4||(gn(M+24|0,f,ie),c[M+28>>2]==3)||(mn(M+360|0,f,ie),c[M+364>>2]==3))break s;c[M+348>>2]=1,C[M+356>>2]=Pt;break t}Je=(Mi<<3)+f|0,u=C[Je+572>>2];s:{n:{o:{a:{l:switch(E=c[Je+576>>2],E|0){case 0:case 3:break a;default:break l}if(o=C[Je+572>>2],!((E|0)!=1|o!=o)){if(o=u,o<v(0))break a;break s}if((E|0)!=2|o!=o)break o;if(Vs)break a;if(!(u<v(0)))break n}c[M+348>>2]=ag,C[M+356>>2]=Pt;break t}o=v(Xe);o:switch(E-1|0){case 1:break n;case 0:break o;default:break s}o=u;break s}o=v(v(Pt*u)*v(.009999999776482582))}o=v(Lt+o),C[M+356>>2]=o,c[M+348>>2]=(_r|(E|0)!=2)&o==o}Vn(f,Ce,vt,Ae,M+344|0,M+352|0),Vn(f,ie,Pt,Ae,M+348|0,M+356|0),Je=(Mi<<3)+f|0,o=C[Je+572>>2];t:{s:{n:{o:switch(E=c[Je+576>>2],E|0){case 0:case 3:break n;default:break o}if(u=C[Je+572>>2],!((E|0)!=1|u!=u)){if(o<v(0))break n;break s}if((E|0)!=2|u!=u)break s;if(o<v(0))break n;if(Je=0,hs)break t}if(Je=0,E=c[f+24>>2]>>>13&7,E||(E=c[r+24>>2]>>>10&7),(E|0)!=4||(gn(M+24|0,f,ie),c[M+28>>2]==3))break t;mn(M+360|0,f,ie),Je=c[M+364>>2]!=3;break t}Je=0}o=C[M+352>>2],u=C[M+356>>2],E=Ce>>>0>1,Lt=E?o:u,o=E?u:o,Vs=c[M+344>>2],fh=c[M+348>>2],cg=E?Vs:fh,Vs=E?fh:Vs,E=(Je^1)&D,pn(f,Lt,o,xe[r+300|0]&3,cg,Vs,Ae,Xt,E,E?4:7,j,te,fe,ee),ae=v(ae+v(H-Ne)),E=xe[r+300|0];t:{s:{if(E&4){Je=E&251;break s}if(Je=E&251,E=0,!(xe[f+300|0]&4))break t}E=4}if(ge[r+300|0]=E|Je,Me=Me+4|0,(si|0)==(Me|0))break}}J=v(J-ae)}f=xe[r+300|0],ge[r+300|0]=f&251|(J<v(0)?4:f&4),lt=v(Dt(r,Ce,T)+gt(r,Ce)),Xo=v(Ot(r,Ce,T)+wt(r,Ce)),Ne=gl(r,Ce,T);i:{if(!(!(J>v(0))|(us|0)!=2)){ae=v(0),u=v(0);t:{s:{f=Us+(c[Bs>>2]<<2)|0,o=C[f>>2],f=c[f>>2],E=(f|0)==2139156720;n:{if(!E){if(Me=(f|0)==2140081935,Me)break s;if(Je=(f|0)==2141891242,Je|o!=o)break i;if(Me)break s;if(Je)break i;if(u=(Le(2,(f&-1073741825)+536870912|0),He()),!(f&1073741824))break n}u=v(v(Gs*u)*v(.009999999776482582))}if(u!=u)break i;u=v(0);n:{if(E)break n;if((f|0)==2140081935)break s;E=4336;o:{if((f|0)!=2141891242){if(o==o)break o;E=4344}switch(u=C[E>>2],H=v(Xe),c[E+4>>2]-1|0){case 0:break s;case 1:break n;default:break t}}if(u=(Le(2,(f&-1073741825)+536870912|0),He()),!(f&1073741824))break s}H=v(v(Gs*u)*v(.009999999776482582));break t}H=u}if(o=v(v(v(H-lt)-Xo)-v(vt-J)),o!=o)break i;ae=ht(o,v(0));break i}ae=J}Je=z>>>0<=oe>>>0;i:{if(!Je){for(si=c[r+556>>2],f=c[r+560>>2]-si>>2,Mi=f>>>0<oe>>>0?oe:f,Me=0,f=oe;;){if((f|0)==(Mi|0))break r;if(E=c[si+(f<<2)>>2],(c[E+24>>2]&196608)!=131072&&(Yr=M+24|0,gn(Yr,E,Ce),qo=c[M+28>>2],mn(Yr,E,Ce),Me=(((qo|0)==3)+Me|0)+(c[M+28>>2]==3)|0),f=f+1|0,(z|0)==(f|0))break}if(Lt=v(0),u=Ne,Me)break i}Lt=v(0),Me=0,u=Ne;t:switch((c[r+24>>2]>>>4&7)-1|0){case 0:Lt=v(ae*v(.5));break i;case 1:Lt=ae;break i;case 2:if(ve>>>0<2)break i;u=v(Ne+v((qt=v(0),zn=ht(ae,v(0)),Zt=ae!=ae,(Zt?qt:zn)/v(ve-1>>>0))));break i;case 4:Lt=v(ae/v(ve+1>>>0)),u=v(Ne+Lt);break i;case 3:break t;default:break i}Lt=v(v(ae*v(.5))/v(ve>>>0)),u=v(v(Lt+Lt)+Ne)}if(o=v(lt+Lt),J=v(0),si=Sm(r),Je)u=v(0);else{for(Mi=z-1|0,Zo=v(ae/v(Me|0)),lt=v(0),H=v(0),f=oe;;){if(E=c[r+556>>2],c[r+560>>2]-E>>2>>>0<=f>>>0)break r;E=c[E+(f<<2)>>2],ve=E+228|0,Hi(M+24|0,ve,320),u=v(u-((f|0)==(Mi|0)?Ne:v(0))),Me=c[E+24>>2];i:{if(Me&4194304)break i;t:{if((Me&196608)==131072){if(!ar(E,Ce))break t;if(!D)break i;ae=Ms(E,Ce,vt),Ai=gt(r,Ce),Tl=dt(E,Ce,Ae),C[ve+(c[Rr>>2]<<2)>>2]=Tl+v(ae+Ai);break i}if(gn(M+360|0,E,Ce),o=v(o+(c[M+364>>2]==3?Zo:v(-0))),D&&(Me=ve,ve=c[Rr>>2]<<2,C[Me+ve>>2]=o+C[ve+(M+24|0)>>2]),mn(M+360|0,E,Ce),o=v(o+(c[M+364>>2]==3?Zo:v(-0))),!og){o=v(o+v(v(u+v(dt(E,Ce,Ae)+kt(E,Ce,Ae)))+C[M+104>>2])),J=Pt;break i}if(ve=E+516|0,o=v(o+v(u+v(C[ve+(c[Bs>>2]<<2)>>2]+v(dt(E,Ce,Ae)+kt(E,Ce,Ae))))),si){ae=vl(E),Ai=dt(E,0,Ae),ae=v(ae+Ai),Ai=v(v(C[E+520>>2]+v(dt(E,0,Ae)+kt(E,0,Ae)))-ae),E=lt!=lt;s:{if(!(E|ae!=ae)){lt=ht(lt,ae);break s}lt=E?ae:lt}if(E=H!=H,!(E|Ai!=Ai)){H=ht(H,Ai);break i}H=E?Ai:H;break i}if(ae=v(C[ve+(c[Mt>>2]<<2)>>2]+v(dt(E,ie,Ae)+kt(E,ie,Ae))),E=J!=J,!(ae!=ae|E)){J=ht(J,ae);break i}J=E?ae:J;break i}if(!D)break i;E=c[Rr>>2]<<2,ae=C[E+(M+24|0)>>2],Zt=E+ve|0,qt=v(Lt+v(ae+gt(r,Ce))),C[Zt>>2]=qt}if(f=f+1|0,(z|0)==(f|0))break}u=v(H+lt)}if(J=si?u:J,ae=Pt,!sg){u=Yt(r,ie,v(tr+J),Yo),f=u!=u,H=v(v(Dt(r,ie,T)+gt(r,ie))+v(Ot(r,ie,T)+wt(r,ie)));i:{if(!(f|H!=H)){u=ht(u,H);break i}u=f?H:u}ae=v(u-tr)}u=Yt(r,ie,v(tr+(ng?Pt:J)),Yo),f=u!=u,H=v(v(Dt(r,ie,T)+gt(r,ie))+v(Ot(r,ie,T)+wt(r,ie)));i:{if(!(f|H!=H)){u=ht(u,H);break i}u=f?H:u}if(H=v(u-tr),!(Je|!D))for(;;){if(f=c[r+556>>2],c[r+560>>2]-f>>2>>>0<=oe>>>0)break r;ve=c[f+(oe<<2)>>2],f=c[ve+24>>2];i:{if(f&4194304)break i;if((f&196608)==131072){t:{if(!ar(ve,ie)){E=c[ni>>2];break t}if(u=Ms(ve,ie,Pt),J=gt(r,ie),Ne=dt(ve,ie,Ae),E=c[ni>>2],u=v(Ne+v(u+J)),C[(ve+(E<<2)|0)+228>>2]=u,u==u)break i}Zt=ve+(E<<2)|0,qt=v(gt(r,ie)+dt(ve,ie,Ae)),C[Zt+228>>2]=qt;break i}E=f>>>13&7,E||(E=c[r+24>>2]>>>10&7);t:{s:{if((E|0)==5){E=c[r+24>>2]&8?5:1;break s}if((E|0)!=4||(gn(M+24|0,ve,ie),E=4,c[M+28>>2]==3)||(mn(M+360|0,ve,ie),c[M+364>>2]==3))break s;E=ve+(c[Mt>>2]<<3)|0,J=C[E+572>>2];n:{o:switch(f=c[E+576>>2],f|0){case 0:case 3:break n;default:break o}if(Ne=C[E+572>>2],!((f|0)!=1|Ne!=Ne)){if(u=jt,J<v(0))break n;break t}if(u=jt,hs&!(J<v(0))|((f|0)!=2|Ne!=Ne))break t}J=C[(ve+(c[Bs>>2]<<2)|0)+516>>2],u=H,Ne=C[ve+224>>2],Ne==Ne&&(u=v(v(dt(ve,ie,Ae)+kt(ve,ie,Ae))+v(ir?J*Ne:J/Ne))),C[M+360>>2]=u,Zt=M,qt=v(J+v(dt(ve,Ce,Ae)+kt(ve,Ce,Ae))),C[Zt+24>>2]=qt,c[M+356>>2]=1,c[M+352>>2]=1,Vn(ve,Ce,vt,Ae,M+356|0,M+24|0),Vn(ve,ie,Pt,Ae,M+352|0,M+360|0),J=C[M+360>>2],Ne=C[M+24>>2],f=Ce>>>0>1,u=f?J:Ne,J=f?Ne:J,f=(zr|0)!=0&(c[r+24>>2]&896)!=512,pn(ve,J,u,ji,!(f&ir|J!=J),(!f|ir)&u==u,Ae,Xt,1,2,j,te,fe,ee),u=jt;break t}u=C[(ve+(c[Mt>>2]<<2)|0)+516>>2],J=dt(ve,ie,Ae),Ne=kt(ve,ie,Ae),gn(M+24|0,ve,ie),J=v(ae-v(u+v(J+Ne)));s:{if(c[M+28>>2]!=3||(mn(M+360|0,ve,ie),c[M+364>>2]!=3))break s;u=v(J*v(.5)),u=v(jt+(qt=v(0),zn=ht(u,v(0)),Zt=u!=u,Zt?qt:zn));break t}if(mn(M+24|0,ve,ie),u=jt,c[M+28>>2]==3)break t;if(gn(M+24|0,ve,ie),c[M+28>>2]==3){u=v(jt+(qt=v(0),zn=ht(J,v(0)),Zt=J!=J,Zt?qt:zn));break t}s:switch(E-1|0){case 1:u=v(jt+v(J*v(.5)));break t;case 0:break t;default:break s}u=v(jt+J)}f=ve+(c[ni>>2]<<2)|0,C[f+228>>2]=u+v(fs+C[f+228>>2])}if(oe=oe+1|0,(oe|0)==(z|0))break}u=v((Fi?uh:v(0))+H),f=Hs!=Hs,o=v(Xo+o);i:{if(!(f|o!=o)){Hs=ht(Hs,o);break i}Hs=f?o:Hs}if(fs=v(fs+u),f=Fi+1|0,oe=z,!(jr>>>0>z>>>0))break}i:{if(!D||!zr&&!Sm(r))break i;lt=v(0);t:{s:{if(Pt!=Pt)break s;o=v(Pt-fs);n:switch((c[r+24>>2]>>>7&7)-2|0){case 0:jt=v(jt+v(o*v(.5)));break s;case 2:if(!(Pt>fs))break s;lt=v(o/v(f>>>0));break s;case 5:if(Pt>fs){if(jt=v(jt+v(o/v(f<<1>>>0))),f>>>0<2)break s;lt=v(o/v(f>>>0));break t}jt=v(jt+v(o*v(.5)));break s;case 4:if(!(Pt>fs)|f>>>0<2)break s;lt=v(o/v(Fi>>>0));break t;case 1:break n;default:break s}jt=v(jt+o)}if(!f)break i}for(Me=0,f=0,E=0;;){if(J=v(0),u=v(0),o=v(0),H=v(0),z=f,jr>>>0>f>>>0){t:{for(;;){if(E=c[r+556>>2],c[r+560>>2]-E>>2>>>0<=z>>>0)break r;oe=c[E+(z<<2)>>2],ve=c[oe+24>>2];s:{if(ve&4194304|(ve&196608)==131072)break s;if(E=z,c[oe+548>>2]!=(Me|0))break t;o=C[(oe+(c[Mt>>2]<<2)|0)+516>>2];n:{if(!(o>=v(0)))break n;if(E=u!=u,o=v(o+v(dt(oe,ie,Ae)+kt(oe,ie,Ae))),!(E|o!=o)){u=ht(u,o);break n}u=E?o:u}if(E=ve>>>13&7,E||(E=c[r+24>>2]>>>10&7),!(xe[r+24|0]&8)|(E|0)!=5)break s;o=vl(oe),ae=dt(oe,0,Ae),o=v(o+ae),ae=v(v(C[oe+520>>2]+v(dt(oe,0,Ae)+kt(oe,0,Ae)))-o),E=u!=u,oe=H!=H;n:{if(!(oe|o!=o)){H=ht(H,o);break n}H=oe?o:H}oe=J!=J;n:{if(!(oe|ae!=ae)){J=ht(J,ae);break n}J=oe?ae:J}if(o=v(H+J),!(E|o!=o)){u=ht(u,o);break s}u=E?o:u}if(z=z+1|0,(jr|0)==(z|0))break}E=jr}o=u}if(ae=v(jt+(Me?uh:v(0))),u=v(lt+o),jt=v(ae+u),f>>>0<E>>>0)for(Ne=v(ae+H);;){if(z=c[r+556>>2],c[r+560>>2]-z>>2>>>0<=f>>>0)break r;oe=c[z+(f<<2)>>2],z=c[oe+24>>2];t:{if(z&4194304|(z&196608)==131072)break t;z=z>>>13&7,z||(z=c[r+24>>2]>>>10&7);s:{n:switch(z-1|0){case 4:if(xe[r+24|0]&8)break s;case 0:o=dt(oe,ie,Ae),C[(oe+(c[ni>>2]<<2)|0)+228>>2]=ae+o;break t;case 2:o=kt(oe,ie,Ae),z=oe+228|0,C[z+(c[ni>>2]<<2)>>2]=v(jt-o)-C[(z+(c[Mt>>2]<<2)|0)+288>>2];break t;case 1:z=oe+228|0,C[z+(c[ni>>2]<<2)>>2]=ae+v(v(u-C[(z+(c[Mt>>2]<<2)|0)+288>>2])*v(.5));break t;case 3:break n;default:break t}o=dt(oe,ie,Ae),C[(oe+(c[ni>>2]<<2)|0)+228>>2]=ae+o,ve=oe+(c[Mt>>2]<<3)|0,o=C[ve+572>>2];n:{o:switch(z=c[ve+576>>2],z|0){case 0:case 3:break n;default:break o}if(H=C[ve+572>>2],!((z|0)!=1|H!=H)){if(o<v(0))break n;break t}if(hs&!(o<v(0))|((z|0)!=2|H!=H))break t}n:{if(Ce>>>0>=2){J=u,o=C[oe+516>>2],H=v(o+v(dt(oe,Ce,Ae)+kt(oe,Ce,Ae)));break n}J=v(C[oe+520>>2]+v(dt(oe,ie,Ae)+kt(oe,ie,Ae))),o=C[oe+516>>2],H=u}n:{o:{if(!(H!=H|o!=o)){if(v(zt(v(H-o)))<v(9999999747378752e-20))break o;break n}if(H==H|o==o)break n}if(o=C[oe+520>>2],z=o!=o,!(z|J!=J)){if(!(v(zt(v(J-o)))<v(9999999747378752e-20)))break n;break t}if(J==J)break n;if(z)break t}pn(oe,H,J,ji,1,1,Ae,Xt,1,3,j,te,fe,ee);break t}Zt=oe,qt=v(v(Ne-vl(oe))+Ms(oe,0,Pt)),C[Zt+232>>2]=qt}if(f=f+1|0,(E|0)==(f|0))break}if(z=(Me|0)!=(Fi|0),Me=Me+1|0,f=E,!z)break}}ve=r+516|0,o=Yt(r,2,lh,T),f=o!=o,u=v(v(Dt(r,2,T)+gt(r,2))+v(Ot(r,2,T)+wt(r,2)));i:{if(!(f|u!=u)){o=ht(o,u);break i}o=f?u:o}C[ve>>2]=o,o=Yt(r,0,ch,k),f=o!=o,u=v(v(Dt(r,0,T)+gt(r,0))+v(Ot(r,0,T)+wt(r,0)));i:{if(!(f|u!=u)){o=ht(o,u);break i}o=f?u:o}C[r+520>>2]=o;i:{t:{s:{if(us&&(f=c[r+24>>2]>>>20&3,(f|0)==2|(us|0)!=2))break s;if(o=Yt(r,Ce,Hs,Gs),f=o!=o,u=v(v(Dt(r,Ce,T)+gt(r,Ce))+v(Ot(r,Ce,T)+wt(r,Ce))),!(f|u!=u)){o=ht(o,u);break t}o=f?u:o;break t}if((us|0)!=2|(f|0)!=2)break i;u=v(Kr+vt),f=u!=u,o=Yt(r,Ce,Hs,Gs);s:{if(!(f|o!=o)){o=th(u,o);break s}o=f?o:u}if(f=o!=o,!(f|Kr!=Kr)){o=ht(o,Kr);break t}o=f?Kr:o}C[ve+(c[Bs>>2]<<2)>>2]=o}i:{t:{s:{if(We&&(E=(We|0)!=2,f=c[r+24>>2]>>>20&3,E|(f|0)==2))break s;if(o=Yt(r,ie,v(tr+fs),Yo),f=o!=o,u=v(v(Dt(r,ie,T)+gt(r,ie))+v(Ot(r,ie,T)+wt(r,ie))),!(f|u!=u)){o=ht(o,u);break t}o=f?u:o;break t}if(E|(f|0)!=2)break i;u=v(tr+Pt),f=u!=u,o=Yt(r,ie,v(tr+fs),Yo);s:{if(!(f|o!=o)){o=th(u,o);break s}o=f?o:u}if(f=o!=o,!(f|tr!=tr)){o=ht(o,tr);break t}o=f?tr:o}C[ve+(c[Mt>>2]<<2)>>2]=o}i:{if(!D)break i;if((c[r+24>>2]&786432)==524288)for(E=jr>>>0<=1?1:jr,D=c[r+556>>2],oe=c[r+560>>2]-D>>2,f=0;z=0,z=f>>>0<oe>>>0?c[D+(f<<2)>>2]:z,(c[z+24>>2]&196608)!=131072&&(z=z+228|0,Me=z+(c[ni>>2]<<2)|0,Je=c[Mt>>2]<<2,C[Me>>2]=v(C[Je+ve>>2]-C[Me>>2])-C[(z+Je|0)+288>>2]),f=f+1|0,(E|0)!=(f|0););if(E=c[r+556>>2],D=c[r+560>>2],(E|0)!=(D|0))for(Me=((Ce>>>0>1?us:y)|0)!=0;;){y=c[E>>2];t:{if((c[y+24>>2]&4390912)!=131072)break t;H=Ae,vt=Xt,xe[c[r+568>>2]+12|0]&2&&(vt=C[r+520>>2],H=C[r+516>>2]),f=c[r+24>>2]>>>2&3;s:{n:{if((ji|0)==2){oe=0,z=3;o:switch(f-2|0){case 0:break s;case 1:break o;default:break n}z=2;break s}if(oe=0,f>>>0<=1)break n;z=f;break s}z=f,oe=Ns}k=v(dt(y,2,H)+kt(y,2,H)),T=dt(y,0,H),J=kt(y,0,H),o=C[y+572>>2];s:{n:{o:switch(f=c[y+576>>2],f|0){case 0:case 3:break n;default:break o}u=C[y+572>>2];o:{if(!((f|0)!=1|u!=u)){if(u=o,!(o<v(0)))break o;break n}a:{if(!((f|0)!=2|u!=u)){if(H!=H|o<v(0))break n;break a}u=v(Xe);l:switch(f-1|0){case 1:break a;case 0:break l;default:break o}u=o;break o}u=v(v(H*o)*v(.009999999776482582))}u=v(k+u);break s}if(u=v(Xe),!ar(y,2)||!El(y,2))break s;if(o=Yt(y,2,v(v(C[r+516>>2]-v(gt(r,2)+wt(r,2)))-v(Ms(y,2,H)+jo(y,2,H))),H),f=o!=o,u=v(v(Dt(y,2,H)+gt(y,2))+v(Ot(y,2,H)+wt(y,2))),!(f|u!=u)){u=ht(o,u);break s}u=f?u:o}J=v(T+J);s:{n:{o:{a:{l:{c:{u:{Je=u!=u,T=C[y+580>>2];d:{h:{p:switch(f=c[y+584>>2],f|0){case 0:case 3:break h;default:break p}o=C[y+580>>2];p:{if(!((f|0)!=1|o!=o)){if(o=T,!(o<v(0)))break p;break h}v:{if(!((f|0)!=2|o!=o)){if(vt!=vt|T<v(0))break h;break v}o=v(Xe);y:switch(f-1|0){case 1:break v;case 0:break y;default:break p}o=T;break p}o=v(v(vt*T)*v(.009999999776482582))}o=v(J+o);break d}h:{if(ar(y,0)&&El(y,0))break h;if(o=v(Xe),u==u)break u;break o}if(o=Yt(y,0,v(v(C[r+520>>2]-v(gt(r,0)+wt(r,0)))-v(Ms(y,0,vt)+jo(y,0,vt))),vt),f=o!=o,T=v(v(Dt(y,0,H)+gt(y,0))+v(Ot(y,0,H)+wt(y,0))),!(f|T!=T)){o=ht(o,T);break d}o=f?T:o}if((Je|0)==(o!=o|0)||(ae=C[y+224>>2],ae!=ae))break l;if(u!=u){u=v(v(v(o-J)*ae)+k);break l}if(o==o)break l;break c}if(ae=C[y+224>>2],ae!=ae)break a}o=v(J+v(v(u-k)/ae))}if(u!=u)break o;if(o==o)break s}f=0;break n}f=1}Je=H>v(0),Fi=f&Me&z>>>0<2,u=Fi&&Je?H:u,f=f^1,pn(y,u,o,ji,Fi&&Je?2:f,o==o,u,o,0,6,j,te,fe,ee),u=v(C[y+516>>2]+zm(y,2,H)),o=v(C[y+520>>2]+zm(y,0,H))}pn(y,u,o,ji,1,1,u,o,1,1,j,te,fe,ee);s:{n:{o:{if(!El(y,z)||ar(y,z))break o;f=c[(z<<2)+4320>>2]<<2,o=z>>>0<2?vt:H,o=v(v(v(v(C[f+ve>>2]-C[(f+y|0)+516>>2])-wt(r,z))-kt(y,z,o))-jo(y,z,o));break n}if(!(ar(y,z)|(c[r+24>>2]&112)!=16)){f=c[(z<<2)+4320>>2]<<2,o=v(v(C[f+ve>>2]-C[(f+y|0)+516>>2])*v(.5));break n}if(!(ar(y,z)|(c[r+24>>2]&112)!=32)){f=c[(z<<2)+4320>>2]<<2,o=v(C[f+ve>>2]-C[(f+y|0)+516>>2]);break n}if(!(xe[c[r+568>>2]+12|0]&2)||!ar(y,z))break s;o=C[ve+(c[(z<<2)+4320>>2]<<2)>>2],o=v(v(Ms(y,z,o)+gt(r,z))+dt(y,z,o))}C[(y+(c[(z<<2)+4288>>2]<<2)|0)+228>>2]=o}s:{n:{if(!El(y,oe)||ar(y,oe))break n;f=c[(oe<<2)+4320>>2]<<2,o=z>>>0<2?H:vt,o=v(v(v(v(C[f+ve>>2]-C[(f+y|0)+516>>2])-wt(r,oe))-kt(y,oe,o))-jo(y,oe,o));break s}n:{if(ar(y,oe)||(f=c[y+24>>2]>>>13&7,f||(f=c[r+24>>2]>>>10&7),(f|0)!=2))break n;f=c[(oe<<2)+4320>>2]<<2,o=v(v(C[f+ve>>2]-C[(f+y|0)+516>>2])*v(.5));break s}n:{if(ar(y,oe))break n;z=c[y+24>>2]>>>13&7,f=c[r+24>>2],z=z||f>>>10&7;o:{if((z|0)==5){if((f&786432)==524288)break o;break n}if(((z|0)==3|0)==((f&786432)==524288|0))break n}f=c[(oe<<2)+4320>>2]<<2,o=v(C[f+ve>>2]-C[(f+y|0)+516>>2]);break s}if(!(xe[c[r+568>>2]+12|0]&2)||!ar(y,oe))break t;o=C[ve+(c[(oe<<2)+4320>>2]<<2)>>2],o=v(v(Ms(y,oe,o)+gt(r,oe))+dt(y,oe,o))}C[(y+(c[(oe<<2)+4288>>2]<<2)|0)+228>>2]=o}if(E=E+4|0,(D|0)==(E|0))break}if(!((ie|Ce)&1))break i;for(E=ie&1,D=Ce&1,j=jr>>>0<=1?1:jr,te=(ie<<2)+4304|0,fe=(Ce<<2)+4304|0,ee=c[r+556>>2],ie=c[r+560>>2]-ee>>2,r=0;;){if((r|0)==(ie|0))break r;f=c[ee+(r<<2)>>2];t:{if(xe[f+26|0]&64||(D&&(y=f+228|0,z=c[Bs>>2]<<2,C[y+(c[fe>>2]<<2)>>2]=v(C[z+ve>>2]-C[(y+z|0)+288>>2])-C[y+(c[Rr>>2]<<2)>>2]),!E))break t;f=f+228|0,y=c[Mt>>2]<<2,C[f+(c[te>>2]<<2)>>2]=v(C[y+ve>>2]-C[(f+y|0)+288>>2])-C[f+(c[ni>>2]<<2)>>2]}if(r=r+1|0,(j|0)==(r|0))break}}if(!Ni)break e;vi(Ni);break e}Ps(),St()}be=M+384|0}function lm(){var r=0,o=0;Gn(7032,7033,7034,0,4352,17,4355,0,4355,0,2529,4357,18),r=he(8),c[r>>2]=8,c[r+4>>2]=1,_e(7032,2922,6,4368,4392,19,r|0,1),Gn(7036,7037,7038,7032,4352,20,4352,21,4352,22,2001,4357,23),r=he(4),c[r>>2]=24,_e(7036,2359,2,4400,4408,25,r|0,0),ls(7032,1398,2,4412,4420,26,27),ls(7032,3027,3,4500,4512,28,29),Gn(7056,7057,7058,0,4352,30,4355,0,4355,0,2545,4357,31),r=he(8),c[r>>2]=8,c[r+4>>2]=1,_e(7056,3293,2,4520,4408,32,r|0,1),Gn(7059,7060,7061,7056,4352,33,4352,34,4352,35,2024,4357,36),r=he(4),c[r>>2]=37,_e(7059,2359,2,4528,4408,38,r|0,0),ls(7056,1398,2,4536,4420,39,40),ls(7056,3027,3,4500,4512,28,41),Gn(7062,7063,7064,0,4352,42,4355,0,4355,0,2861,4357,43),nm(7062,1,4584,4352,44,45),ls(7062,2915,1,4584,4352,44,45),ls(7062,1129,2,4588,4408,46,47),r=he(8),c[r+4>>2]=0,c[r>>2]=48,_e(7062,3234,4,4608,4624,49,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=50,_e(7062,1981,3,4632,4644,51,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=52,_e(7062,1952,3,4652,4664,53,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=54,_e(7062,3389,3,4672,4664,55,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=56,_e(7062,1800,3,4652,4664,53,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=57,_e(7062,3264,3,4684,4512,58,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=59,_e(7062,1926,2,4696,4420,60,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=61,_e(7062,3399,2,4704,4420,62,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=63,_e(7062,1785,2,4696,4420,60,r|0,0),Ku(7065,1271,4712,64,4357,65),Kn(1732,0),Kn(1612,8),Kn(2145,16),Kn(2455,24),Kn(2561,32),Kn(1618,40),ju(7065),Ku(7035,2898,4712,66,4357,67),Nm(2561,0),Nm(1618,8),ju(7035),Ku(7066,2909,4712,68,4357,69),r=he(4),c[r>>2]=8,o=he(4),c[o>>2]=8,ml(7066,2903,7098,4714,70,r|0,7098,4718,71,o|0),r=he(4),c[r>>2]=0,o=he(4),c[o>>2]=0,ml(7066,1607,7091,4420,72,r|0,7091,4664,73,o|0),ju(7066),Gn(7067,7068,7069,0,4352,74,4355,0,4355,0,3022,4357,75),nm(7067,1,4724,4352,76,77),ls(7067,1593,1,4724,4352,76,77),ls(7067,2851,2,4728,4420,78,79),ls(7067,1129,2,4736,4408,80,81),r=he(8),c[r+4>>2]=0,c[r>>2]=82,_e(7067,1753,2,4736,4408,83,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=84,_e(7067,3005,3,4744,4664,85,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=86,_e(7067,2930,3,4756,4664,87,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=88,_e(7067,2335,4,4768,4784,89,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=90,_e(7067,1485,4,4768,4784,89,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=91,_e(7067,1356,3,4756,4664,87,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=92,_e(7067,1818,3,4756,4664,87,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=93,_e(7067,2872,3,4756,4664,87,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=94,_e(7067,2379,3,4756,4664,87,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=95,_e(7067,2164,3,4756,4664,87,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=96,_e(7067,1320,3,4756,4664,87,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=97,_e(7067,2413,4,4768,4784,89,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=98,_e(7067,1504,4,4768,4784,89,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=99,_e(7067,2236,3,4756,4664,87,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=100,_e(7067,1220,3,4756,4664,87,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=101,_e(7067,1137,3,4756,4664,87,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=102,_e(7067,1159,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=104,_e(7067,1846,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=105,_e(7067,1465,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=106,_e(7067,2219,2,4736,4408,83,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=107,_e(7067,1196,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=108,_e(7067,2501,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=109,_e(7067,2591,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=110,_e(7067,1540,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=111,_e(7067,2250,2,4736,4408,83,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=112,_e(7067,1651,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=113,_e(7067,1428,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=114,_e(7067,2205,2,4736,4408,83,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=115,_e(7067,2609,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=116,_e(7067,1556,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=117,_e(7067,1671,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=118,_e(7067,1445,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=119,_e(7067,2567,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=120,_e(7067,1521,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=121,_e(7067,1625,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=122,_e(7067,1408,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=123,_e(7067,2305,3,4792,4718,103,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=124,_e(7067,2093,4,4768,4784,89,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=125,_e(7067,2719,4,4768,4784,89,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=126,_e(7067,1575,4,4768,4784,89,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=127,_e(7067,2188,4,4768,4784,89,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=128,_e(7067,2946,2,4804,4420,129,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=130,_e(7067,2347,3,4812,4512,131,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=132,_e(7067,1372,2,4804,4420,129,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=133,_e(7067,1832,2,4804,4420,129,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=134,_e(7067,2885,2,4804,4420,129,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=135,_e(7067,2396,2,4804,4420,129,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=136,_e(7067,2176,2,4804,4420,129,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=137,_e(7067,1338,2,4804,4420,129,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=138,_e(7067,2423,3,4812,4512,131,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=139,_e(7067,1859,2,4824,4420,140,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=141,_e(7067,1208,2,4832,4714,142,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=143,_e(7067,2515,2,4832,4714,142,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=144,_e(7067,2600,2,4824,4420,140,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=145,_e(7067,1661,2,4824,4420,140,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=146,_e(7067,2621,2,4824,4420,140,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=147,_e(7067,1684,2,4824,4420,140,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=148,_e(7067,2579,2,4824,4420,140,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=149,_e(7067,1638,2,4824,4420,140,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=150,_e(7067,2320,2,4832,4714,142,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=151,_e(7067,2103,3,4840,4852,152,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=153,_e(7067,1232,2,4804,4420,129,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=154,_e(7067,1148,2,4804,4420,129,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=155,_e(7067,2730,3,4812,4512,131,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=156,_e(7067,2195,3,4860,4872,157,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=158,_e(7067,3034,4,4880,4624,159,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=160,_e(7067,3055,3,4896,4664,161,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=162,_e(7067,1293,2,4908,4420,163,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=164,_e(7067,1388,2,4916,4420,165,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=166,_e(7067,3046,3,4924,4512,167,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=168,_e(7067,2962,2,4936,4420,169,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=170,_e(7067,2982,3,4944,4664,171,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=172,_e(7067,3357,3,4956,4664,173,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=174,_e(7067,3355,2,4736,4408,83,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=175,_e(7067,3374,3,4968,4664,176,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=177,_e(7067,3372,2,4736,4408,83,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=178,_e(7067,1119,2,4736,4408,83,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=179,_e(7067,1111,2,4980,4420,180,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=181,_e(7067,1244,5,4992,5012,182,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=183,_e(7067,1737,2,4832,4714,142,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=184,_e(7067,1715,2,4832,4714,142,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=185,_e(7067,2149,2,4832,4714,142,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=186,_e(7067,2462,2,4832,4714,142,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=187,_e(7067,2633,2,4832,4714,142,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=188,_e(7067,1697,2,4832,4714,142,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=189,_e(7067,1260,2,5020,4420,190,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=191,_e(7067,2433,3,4840,4852,152,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=192,_e(7067,2113,3,4840,4852,152,r|0,0),r=he(8),c[r+4>>2]=0,c[r>>2]=193,_e(7067,2741,3,4840,4852,152,r|0,0)}function lT(r,o,u,f,y,E){r=r|0,o=+o,u=u|0,f=f|0,y=y|0,E=E|0;var T=0,k=0,D=0,j=0,te=0,fe=0,ee=0,ie=0,M=0,H=0,z=0,J=0,oe=0,ae=0,ve=0,Ae=0,Ce=0,Me=0,Ne=0;ee=be-560|0,be=ee,c[ee+44>>2]=0,$i(+o),T=mt(1)|0,mt(0)|0;e:{if((T|0)<0){oe=1,Me=1177,o=-o,$i(+o),T=mt(1)|0,mt(0)|0;break e}if(y&2048){oe=1,Me=1180;break e}oe=y&1,Me=oe?1183:1178,Ne=!oe}e:{if((T&2146435072)==2146435072){T=oe+3|0,yi(r,32,u,T,y&-65537),hi(r,Me,oe),f=E&32,hi(r,o!=o?f?2451:3459:f?2868:3463,3),yi(r,32,u,T,y^8192),ie=(u|0)<(T|0)?T:u;break e}ve=ee+16|0;r:{i:{t:{if(o=_m(o,ee+44|0),o=o+o,o!=0){if(T=c[ee+44>>2],c[ee+44>>2]=T-1,Ae=E|32,(Ae|0)!=97)break t;break r}if(Ae=E|32,(Ae|0)==97)break r;te=c[ee+44>>2],fe=(f|0)<0?6:f;break i}te=T-29|0,c[ee+44>>2]=te,o=o*268435456,fe=(f|0)<0?6:f}for(z=(ee+48|0)+((te|0)>=0?288:0)|0,k=z;o<4294967296&o>=0?f=~~o>>>0:f=0,c[k>>2]=f,k=k+4|0,o=(o-+(f>>>0))*1e9,o!=0;);i:{if((te|0)<=0){f=te,T=k,D=z;break i}for(D=z,f=te;;){M=(f|0)>=29?29:f,T=k-4|0;t:{if(D>>>0>T>>>0)break t;for(f=0;j=c[T>>2],Ce=f,f=M&31,(M&63)>>>0>=32?(ie=j<<f,f=0):(ie=(1<<f)-1&j>>>32-f,f=j<<f),Ce=Ce+f|0,j=ie+H|0,f=pm(Ce,f>>>0>Ce>>>0?j+1|0:j,1e9),j=eh(f,Vi,-1e9,0)+Ce|0,c[T>>2]=j,T=T-4|0,D>>>0<=T>>>0;);if(!f)break t;D=D-4|0,c[D>>2]=f}for(;T=k,D>>>0<T>>>0&&(k=T-4|0,!c[k>>2]););if(f=c[ee+44>>2]-M|0,c[ee+44>>2]=f,k=T,!((f|0)>0))break}}if((f|0)<0)for(ae=((fe+25>>>0)/9|0)+1|0,H=(Ae|0)==102;;){f=0-f|0,ie=(f|0)>=9?9:f;i:{if(T>>>0<=D>>>0){k=c[D>>2];break i}for(M=1e9>>>ie|0,j=-1<<ie^-1,f=0,k=D;Ce=f,f=c[k>>2],c[k>>2]=Ce+(f>>>ie|0),f=Wt(M,f&j),k=k+4|0,k>>>0<T>>>0;);if(k=c[D>>2],!f)break i;c[T>>2]=f,T=T+4|0}if(f=ie+c[ee+44>>2]|0,c[ee+44>>2]=f,D=(!k<<2)+D|0,k=H?z:D,T=T-k>>2>(ae|0)?k+(ae<<2)|0:T,!((f|0)<0))break}f=0;i:{if(T>>>0<=D>>>0||(f=Wt(z-D>>2,9),k=10,j=c[D>>2],j>>>0<10))break i;for(;f=f+1|0,k=Wt(k,10),j>>>0>=k>>>0;);}if(k=(fe-((Ae|0)!=102?f:0)|0)-((Ae|0)==103&(fe|0)!=0)|0,(k|0)<(Wt(T-z>>2,9)-9|0)){if(M=k+9216|0,j=(M|0)/9|0,te=((((te|0)<0?4:292)+ee|0)+(j<<2)|0)-4048|0,k=10,ie=M+Wt(j,-9)|0,(ie|0)<=7)for(;k=Wt(k,10),ie=ie+1|0,(ie|0)!=8;);M=c[te>>2],ae=(M>>>0)/(k>>>0)|0,H=Wt(ae,k),j=te+4|0;i:{if((M|0)==(H|0)&(j|0)==(T|0))break i;M=M-H|0;t:{if(!(ae&1)&&(o=9007199254740992,!(ge[te-4|0]&1)|((k|0)!=1e9|D>>>0>=te>>>0)))break t;o=9007199254740994}if(J=(T|0)==(j|0)?1:1.5,j=k>>>1|0,J=j>>>0>M>>>0?.5:(j|0)==(M|0)?J:1.5,xe[Me|0]!=45|Ne||(J=-J,o=-o),c[te>>2]=H,o+J==o)break i;if(f=k+H|0,c[te>>2]=f,f>>>0>=1e9)for(;c[te>>2]=0,te=te-4|0,te>>>0<D>>>0&&(D=D-4|0,c[D>>2]=0),f=c[te>>2]+1|0,c[te>>2]=f,f>>>0>999999999;);if(f=Wt(z-D>>2,9),k=10,j=c[D>>2],j>>>0<10)break i;for(;f=f+1|0,k=Wt(k,10),j>>>0>=k>>>0;);}k=te+4|0,T=T>>>0>k>>>0?k:T}for(;j=T,M=T>>>0<=D>>>0,!M&&(T=j-4|0,!c[T>>2]););i:{if((Ae|0)!=103){te=y&8;break i}if(k=fe||1,T=(k|0)>(f|0)&(f|0)>-5,fe=(T?f^-1:-1)+k|0,E=(T?-1:-2)+E|0,te=y&8,te)break i;T=-9;t:{if(M||(te=c[j-4>>2],!te)||(ie=10,T=0,(te>>>0)%10|0))break t;for(;k=T,T=T+1|0,ie=Wt(ie,10),!((te>>>0)%(ie>>>0)|0););T=k^-1}if(k=Wt(j-z>>2,9),(E&-33)==70){te=0,T=(T+k|0)-9|0,T=(T|0)>0?T:0,fe=(T|0)>(fe|0)?fe:T;break i}te=0,T=((f+k|0)+T|0)-9|0,T=(T|0)>0?T:0,fe=(T|0)>(fe|0)?fe:T}if(ie=-1,M=te|fe,((M?2147483645:2147483646)|0)<(fe|0))break e;H=(((M|0)!=0)+fe|0)+1|0,k=E&-33;i:{if((k|0)==70){if((H^2147483647)<(f|0))break e;T=(f|0)>0?f:0;break i}if(T=f>>31,T=Hn((T^f)-T|0,0,ve),(ve-T|0)<=1)for(;T=T-1|0,ge[T|0]=48,(ve-T|0)<2;);if(ae=T-2|0,ge[ae|0]=E,ge[T-1|0]=(f|0)<0?45:43,T=ve-ae|0,(T|0)>(H^2147483647))break e}if(f=T+H|0,(f|0)>(oe^2147483647))break e;H=f+oe|0,yi(r,32,u,H,y),hi(r,Me,oe),yi(r,48,u,H,y^65536);i:{t:{s:{if((k|0)==70){for(E=ee+16|0,f=E|8,te=E|9,k=D>>>0>z>>>0?z:D,D=k;;){T=Hn(c[D>>2],0,te);n:{if((k|0)!=(D|0)){if(ee+16>>>0>=T>>>0)break n;for(;T=T-1|0,ge[T|0]=48,ee+16>>>0<T>>>0;);break n}if((T|0)!=(te|0))break n;ge[ee+24|0]=48,T=f}if(hi(r,T,te-T|0),D=D+4|0,!(z>>>0>=D>>>0))break}if(M&&hi(r,4275,1),(fe|0)<=0|D>>>0>=j>>>0)break s;for(;;){if(T=Hn(c[D>>2],0,te),T>>>0>ee+16>>>0)for(;T=T-1|0,ge[T|0]=48,ee+16>>>0<T>>>0;);if(hi(r,T,(fe|0)>=9?9:fe),T=fe-9|0,D=D+4|0,j>>>0<=D>>>0)break t;if(f=(fe|0)>9,fe=T,!f)break}break t}n:{if((fe|0)<0)break n;for(z=D>>>0<j>>>0?j:D+4|0,E=ee+16|0,f=E|8,j=E|9,k=D;;){T=Hn(c[k>>2],0,j),(j|0)==(T|0)&&(ge[ee+24|0]=48,T=f);o:{if((k|0)!=(D|0)){if(ee+16>>>0>=T>>>0)break o;for(;T=T-1|0,ge[T|0]=48,ee+16>>>0<T>>>0;);break o}if(hi(r,T,1),T=T+1|0,!(te|fe))break o;hi(r,4275,1)}if(E=j-T|0,hi(r,T,(E|0)>(fe|0)?fe:E),fe=fe-E|0,k=k+4|0,z>>>0<=k>>>0)break n;if(!((fe|0)>=0))break}}yi(r,48,fe+18|0,18,0),hi(r,ae,ve-ae|0);break i}T=fe}yi(r,48,T+9|0,9,0)}yi(r,32,u,H,y^8192),ie=(u|0)<(H|0)?H:u;break e}te=(E<<26>>31&9)+Me|0;r:{if(f>>>0>11)break r;for(T=12-f|0,J=16;J=J*16,T=T-1|0,!!T;);if(xe[te|0]==45){o=-(J+(-o-J));break r}o=o+J-J}for(z=oe|2,D=E&32,k=c[ee+44>>2],T=k>>31,T=Hn((T^k)-T|0,0,ve),(ve|0)==(T|0)&&(ge[ee+15|0]=48,T=ee+15|0),fe=T-2|0,ge[fe|0]=E+15,ge[T-1|0]=(k|0)<0?45:43,T=y&8,k=ee+16|0;E=k,zt(o)<2147483648?j=~~o:j=-2147483648,ge[k|0]=D|xe[j+5504|0],o=(o-+(j|0))*16,k=E+1|0,!(T|(f|0)>0)&o==0|(k-(ee+16|0)|0)!=1||(ge[E+1|0]=46,k=E+2|0),o!=0;);if(ie=-1,T=ve-fe|0,E=T+z|0,(2147483645-E|0)<(f|0))break e;r:{i:{if(!f||(D=k-(ee+16|0)|0,(D-2|0)>=(f|0)))break i;f=f+2|0;break r}D=k-(ee+16|0)|0,f=D}E=f+E|0,yi(r,32,u,E,y),hi(r,te,z),yi(r,48,u,E,y^65536),hi(r,ee+16|0,D),yi(r,48,f-D|0,0,0),hi(r,fe,T),yi(r,32,u,E,y^8192),ie=(u|0)<(E|0)?E:u}return be=ee+560|0,ie|0}function cm(r,o,u,f,y,E,T){var k=0,D=0,j=0,te=0,fe=0,ee=0,ie=0,M=0,H=0,z=0,J=0,oe=0,ae=0,ve=0,Ae=0,Ce=0,Me=0,Ne=0,We=0,Je=0;j=be-80|0,be=j,c[j+76>>2]=o,Ne=j+55|0,ae=j+56|0;e:{r:{i:{t:{s:for(;;){if(te=o,(H^2147483647)<(k|0))break t;H=k+H|0;n:{o:{a:{if(k=te,D=xe[k|0],D)for(;;){l:{o=D&255;c:{if(!o){o=k;break c}if((o|0)!=37)break l;for(D=k;;){if(xe[D+1|0]!=37){o=D;break c}if(k=k+1|0,fe=xe[D+2|0],o=D+2|0,D=o,(fe|0)!=37)break}}if(k=k-te|0,Me=H^2147483647,(k|0)>(Me|0))break t;if(r&&hi(r,te,k),k)continue s;c[j+76>>2]=o,k=o+1|0,J=-1,D=ge[o+1|0],!bl(D)|xe[o+2|0]!=36||(J=D-48|0,ve=1,k=o+3|0),c[j+76>>2]=k,M=0,D=ge[k|0],o=D-32|0;c:{if(o>>>0>31){fe=k;break c}if(fe=k,o=1<<o,!(o&75913))break c;for(;;){if(fe=k+1|0,c[j+76>>2]=fe,M=o|M,D=ge[k+1|0],o=D-32|0,o>>>0>=32)break c;if(k=fe,o=1<<o,!(o&75913))break}}c:{if((D|0)==42){o=ge[fe+1|0];u:{if(!(!bl(o)|xe[fe+2|0]!=36)){c[((o<<2)+y|0)-192>>2]=10,D=fe+3|0,ve=1,z=c[((ge[fe+1|0]<<3)+f|0)-384>>2];break u}if(ve)break a;if(D=fe+1|0,!r){c[j+76>>2]=D,ve=0,z=0;break c}o=c[u>>2],c[u>>2]=o+4,ve=0,z=c[o>>2]}if(c[j+76>>2]=D,(z|0)>=0)break c;z=0-z|0,M=M|8192;break c}if(z=Dm(j+76|0),(z|0)<0)break t;D=c[j+76>>2]}k=0,ie=-1;c:{if(xe[D|0]!=46){o=D,oe=0;break c}if(xe[D+1|0]==42){o=ge[D+2|0];u:{if(!(!bl(o)|xe[D+3|0]!=36)){c[((o<<2)+y|0)-192>>2]=10,o=D+4|0,ie=c[((ge[D+2|0]<<3)+f|0)-384>>2];break u}if(ve)break a;if(o=D+2|0,ie=0,!r)break u;D=c[u>>2],c[u>>2]=D+4,ie=c[D>>2]}c[j+76>>2]=o,oe=(ie^-1)>>>31|0;break c}c[j+76>>2]=D+1,ie=Dm(j+76|0),o=c[j+76>>2],oe=1}for(;;){if(ee=k,fe=28,Ae=o,k=ge[o|0],k-123>>>0<4294967238)break i;if(o=Ae+1|0,k=xe[(k+Wt(ee,58)|0)+4975|0],!(k-1>>>0<8))break}c[j+76>>2]=o;c:{u:{if((k|0)!=27){if(!k)break i;if((J|0)>=0){c[(J<<2)+y>>2]=k,k=(J<<3)+f|0,D=c[k+4>>2],c[j+64>>2]=c[k>>2],c[j+68>>2]=D;break u}if(!r)break n;ym(j- -64|0,k,u,T);break c}if((J|0)>=0)break i}if(k=0,!r)continue s}D=M&-65537,M=M&8192?D:M,J=0,Ce=1167,fe=ae;c:{u:{d:{h:{p:{v:{y:{f:{m:{A:{g:{b:{T:{E:{S:{x:switch(k=ge[Ae|0],k=ee&&(k&15)==3?k&-33:k,k-88|0){case 11:break c;case 9:case 13:case 14:case 15:break u;case 27:break y;case 12:case 17:break A;case 23:break g;case 0:case 32:break b;case 24:break T;case 22:break E;case 29:break S;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 o;default:break x}x:switch(k-65|0){case 0:case 4:case 5:case 6:break u;case 2:break p;case 1:case 3:break o;default:break x}if((k|0)==83)break v;break o}D=c[j+64>>2],ee=c[j+68>>2],k=1167;break m}k=0;E:switch(ee&255){case 0:c[c[j+64>>2]>>2]=H;continue s;case 1:c[c[j+64>>2]>>2]=H;continue s;case 2:te=c[j+64>>2],c[te>>2]=H,c[te+4>>2]=H>>31;continue s;case 3:Br[c[j+64>>2]>>1]=H;continue s;case 4:ge[c[j+64>>2]]=H;continue s;case 6:c[c[j+64>>2]>>2]=H;continue s;case 7:break E;default:continue s}te=c[j+64>>2],c[te>>2]=H,c[te+4>>2]=H>>31;continue s}ie=ie>>>0<=8?8:ie,M=M|8,k=120}if(te=ae,D=c[j+64>>2],ee=c[j+68>>2],D|ee)for(We=k&32;te=te-1|0,ge[te|0]=We|xe[(D&15)+5504|0],Je=!ee&D>>>0>15|(ee|0)!=0,Ae=ee,ee=ee>>>4|0,D=(Ae&15)<<28|D>>>4,!!Je;);if(!(M&8)|!(c[j+64>>2]|c[j+68>>2]))break f;Ce=(k>>>4|0)+1167|0,J=2;break f}if(k=ae,te=c[j+68>>2],ee=te,D=c[j+64>>2],te|D)for(;k=k-1|0,ge[k|0]=D&7|48,Ae=!ee&D>>>0>7|(ee|0)!=0,te=ee,ee=te>>>3|0,D=(te&7)<<29|D>>>3,!!Ae;);if(te=k,!(M&8))break f;k=ae-te|0,ie=(k|0)<(ie|0)?ie:k+1|0;break f}if(D=c[j+64>>2],k=c[j+68>>2],ee=k,(k|0)<0){te=0-(ee+((D|0)!=0)|0)|0,ee=te,D=0-D|0,c[j+64>>2]=D,c[j+68>>2]=te,J=1,k=1167;break m}if(M&2048){J=1,k=1168;break m}J=M&1,k=J?1169:1167}Ce=k,te=Hn(D,ee,ae)}if((ie|0)<0&&oe)break t;if(M=oe?M&-65537:M,k=c[j+64>>2],D=c[j+68>>2],!((k|D)!=0|ie)){te=ae,ie=0;break o}k=!(k|D)+(ae-te|0)|0,ie=(k|0)<(ie|0)?ie:k;break o}M=0,oe=ie>>>0>=2147483647?2147483647:ie,ee=oe,fe=(ee|0)!=0;y:{f:{k=c[j+64>>2],te=k||4277,k=te;m:{A:{g:{if(!(k&3)|!ee)break g;for(;;){if(M=xe[k|0],!M)break A;if(ee=ee-1|0,fe=(ee|0)!=0,k=k+1|0,!(k&3))break g;if(!ee)break}}if(!fe)break f;g:{if(!(!xe[k|0]|ee>>>0<4))for(;;){if(fe=c[k>>2],(fe^-1)&fe-16843009&-2139062144)break g;if(k=k+4|0,ee=ee-4|0,!(ee>>>0>3))break}if(!ee)break f}fe=0;break m}fe=1}for(;;){if(!fe){M=xe[k|0],fe=1;continue}if(!M)break y;if(k=k+1|0,ee=ee-1|0,!ee)break f;fe=0}}k=0}if(k=k?k-te|0:oe,fe=k+te|0,(ie|0)>=0){M=D,ie=k;break o}if(M=D,ie=k,xe[fe|0])break t;break o}if(ie){D=c[j+64>>2];break h}k=0,yi(r,32,z,0,M);break d}c[j+12>>2]=0,c[j+8>>2]=c[j+64>>2],D=j+8|0,c[j+64>>2]=D,ie=-1}k=0;h:{for(;;){if(te=c[D>>2],!te)break h;if(te=Fm(j+4|0,te),fe=(te|0)<0,!(fe|te>>>0>ie-k>>>0)){if(D=D+4|0,k=k+te|0,ie>>>0>k>>>0)continue;break h}break}if(fe)break r}if(fe=61,(k|0)<0)break i;if(yi(r,32,z,k,M),!k){k=0;break d}for(fe=0,D=c[j+64>>2];;){if(te=c[D>>2],!te||(te=Fm(j+4|0,te),fe=te+fe|0,fe>>>0>k>>>0))break d;if(hi(r,j+4|0,te),D=D+4|0,!(k>>>0>fe>>>0))break}}yi(r,32,z,k,M^8192),k=(k|0)<(z|0)?z:k;continue s}if((ie|0)<0&&oe)break t;if(fe=61,k=$e[E|0](r,Ht[j+64>>3],z,ie,M,k)|0,(k|0)>=0)continue s;break i}ge[j+55|0]=c[j+64>>2],ie=1,te=Ne,M=D;break o}D=xe[k+1|0],k=k+1|0}if(r)break e;if(!ve)break n;for(k=1;;){if(r=c[(k<<2)+y>>2],r){if(ym((k<<3)+f|0,r,u,T),H=1,k=k+1|0,(k|0)!=10)continue;break e}break}if(H=1,k>>>0>=10)break e;for(;;){if(c[(k<<2)+y>>2])break a;if(k=k+1|0,(k|0)==10)break}break e}fe=28;break i}if(ee=fe-te|0,ie=(ie|0)>(ee|0)?ie:ee,(ie|0)>(J^2147483647))break t;if(fe=61,D=ie+J|0,k=(D|0)<(z|0)?z:D,(Me|0)<(k|0))break i;yi(r,32,k,D,M),hi(r,Ce,J),yi(r,48,k,D,M^65536),yi(r,48,ie,ee,0),hi(r,te,ee),yi(r,32,k,D,M^8192);continue}break}H=0;break e}fe=61}c[1781]=fe}H=-1}return be=j+80|0,H}function cT(r,o,u,f){r=r|0,o=+o,u=+u,f=f|0;var y=v(0),E=v(0),T=0,k=v(0),D=0,j=v(0),te=0,fe=v(0),ee=0;ee=be+-64|0,be=ee,T=c[r>>2],Wi(ee+8|0,0,56),c[1755]=c[1755]+1,hm(T),k=v(o),E=C[T+572>>2];e:{r:{i:switch(r=c[T+576>>2],r|0){case 0:case 3:break r;default:break i}y=C[T+572>>2];i:{if(!((r|0)!=1|y!=y)){if(y=E,!(y<v(0)))break i;break r}t:{if(!((r|0)!=2|y!=y)){if(k!=k|E<v(0))break r;break t}y=v(Xe);s:switch(r-1|0){case 1:break t;case 0:break s;default:break i}y=E;break i}y=v(v(E*k)*v(.009999999776482582))}fe=v(y+v(dt(T,2,k)+kt(T,2,k))),te=1;break e}y=v(0),E=C[T+216>>2];r:{i:{r=c[T+216>>2];t:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;te=4336;n:{if((r|0)!=2141891242){if(E==E)break n;te=4344}switch(y=C[te>>2],c[te+4>>2]-1|0){case 0:break t;case 1:break s;default:break i}}if(y=(Le(2,(r&-1073741825)+536870912|0),He()),!(r&1073741824))break t}y=v(v(y*k)*v(.009999999776482582))}if(y!=y)break i;y=v(0);t:{if((r|0)==2139156720)break t;if((r|0)==2140081935)break r;D=4336;s:{if((r|0)!=2141891242){if(E==E)break s;D=4344}switch(y=C[D>>2],fe=v(Xe),te=2,c[D+4>>2]-1|0){case 1:break t;case 0:break r;default:break e}}if(y=(Le(2,(r&-1073741825)+536870912|0),He()),!(r&1073741824))break r}fe=v(v(y*k)*v(.009999999776482582)),te=2;break e}te=k==k,fe=k;break e}te=2,fe=y}j=v(u),E=C[T+580>>2];e:{r:{i:switch(r=c[T+584>>2],r|0){case 0:case 3:break r;default:break i}y=C[T+580>>2];i:{if(!((r|0)!=1|y!=y)){if(y=E,!(y<v(0)))break i;break r}t:{if(!((r|0)!=2|y!=y)){if(j!=j|E<v(0))break r;break t}y=v(Xe);s:switch(r-1|0){case 1:break t;case 0:break s;default:break i}y=E;break i}y=v(v(E*j)*v(.009999999776482582))}E=v(y+v(dt(T,0,k)+kt(T,0,k))),r=1;break e}y=v(0),E=C[T+220>>2];r:{i:{r=c[T+220>>2];t:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;D=4336;n:{if((r|0)!=2141891242){if(E==E)break n;D=4344}switch(y=C[D>>2],c[D+4>>2]-1|0){case 0:break t;case 1:break s;default:break i}}if(y=(Le(2,(r&-1073741825)+536870912|0),He()),!(r&1073741824))break t}y=v(v(y*j)*v(.009999999776482582))}if(y!=y)break i;y=v(0);t:{if((r|0)==2139156720)break t;if((r|0)==2140081935)break r;D=4336;s:{if((r|0)!=2141891242){if(E==E)break s;D=4344}switch(y=C[D>>2],E=v(Xe),r=2,c[D+4>>2]-1|0){case 0:break r;case 1:break t;default:break e}}if(y=(Le(2,(r&-1073741825)+536870912|0),He()),!(r&1073741824))break r}E=v(v(y*j)*v(.009999999776482582)),r=2;break e}r=j==j,E=j;break e}r=2,E=y}pn(T,fe,E,f,te,r,k,j,1,0,c[T+568>>2],ee+8|0,0,c[1755])&&(bm(T,xe[T+300|0]&3,k,j,k),Am(T,+C[c[T+568>>2]+20>>2],0,0)),be=ee- -64|0}function uT(r,o){r=r|0,o=o|0;var u=0,f=v(0),y=0,E=0,T=v(0),k=0,D=0,j=0,te=v(0);e:{D=c[o>>2],o=c[r>>2];r:{if((c[D+24>>2]^c[o+24>>2])&8388607)break r;te=C[D+40>>2],y=c[D+40>>2],f=C[o+40>>2];i:{t:{if(u=c[o+40>>2],(u|0)!=2139156720){if(T=v(Xe),r=3,(u|0)==2141891242)break i;if((u|0)!=2140081935)break t;T=v(0),r=1;break i}r=2;break i}if(r=0,f!=f)break i;T=(Le(2,(u&-1073741825)+536870912|0),He()),r=u&1073741824?2:1}i:{t:{if((y|0)!=2139156720){if(f=v(Xe),u=3,(y|0)==2141891242)break i;if((y|0)!=2140081935)break t;f=v(0),u=1;break i}f=v(0),u=2;break i}if(u=0,te!=te)break i;f=(Le(2,(y&-1073741825)+536870912|0),He()),u=y&1073741824?2:1}if((u|0)!=(r|0)|!(!r|T!=T&f!=f|v(zt(v(T-f)))<v(9999999747378752e-20))||(u=o+44|0,E=D+44|0,c[u>>2]!=c[E>>2]))break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(k=r<<2,c[k+u>>2]!=c[E+k>>2])break}if(y>>>0<8)break r}if(u=o+80|0,E=D+80|0,c[u>>2]!=c[E>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(k=r<<2,c[k+u>>2]!=c[E+k>>2])break}if(y>>>0<8)break r}if(u=o+116|0,E=D+116|0,c[u>>2]!=c[E>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(k=r<<2,c[k+u>>2]!=c[E+k>>2])break}if(y>>>0<8)break r}if(u=o+152|0,E=D+152|0,c[u>>2]!=c[E>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(k=r<<2,c[k+u>>2]!=c[E+k>>2])break}if(y>>>0<8)break r}if(u=o+188|0,E=D+188|0,c[u>>2]!=c[E>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==3)break i;if(k=r<<2,c[k+u>>2]!=c[E+k>>2])break}if(y>>>0<2)break r}for(k=D+200|0,j=o+200|0,r=0,y=1;;){i:{if(r=r<<2,u=c[r+k>>2],E=c[r+j>>2],!y)break i;if(y=0,r=1,(u|0)==(E|0))continue}break}if((u|0)!=(E|0))break r;for(k=D+208|0,j=o+208|0,r=0,y=1;;){i:{if(r=r<<2,u=c[r+k>>2],E=c[r+j>>2],!y)break i;if(y=0,r=1,(u|0)==(E|0))continue}break}if((u|0)!=(E|0))break r;for(k=D+216|0,j=o+216|0,r=0,y=1;;){i:{if(r=r<<2,u=c[r+k>>2],E=c[r+j>>2],!y)break i;if(y=0,r=1,(u|0)==(E|0))continue}break}if((u|0)!=(E|0)||(T=C[D+28>>2],r=T!=T,f=C[o+28>>2],(r|0)==(f==f|0)|!(r|f!=f)&f!=T)||(f=C[o+32>>2],T=C[D+32>>2],(f==f|0)==(T!=T|0)|f==f&f!=T)||(T=C[D+36>>2],r=T!=T,f=C[o+36>>2],(r|0)==(f==f|0)|!r&f!=T))break r;if(r=0,f=C[o+224>>2],f!=f&&(r=1,T=C[D+224>>2],T!=T)||(T=f,f=C[D+224>>2],T==f|f!=f&r))break e}for(Hi(o+24|0,D+24|0,204);;){if(r=xe[o+4|0],r&4)break e;if(ge[o+4|0]=r|4,r=c[o+20>>2],r&&$e[r|0](o),c[o+308>>2]=2143289344,o=c[o+552>>2],!o)break}}}function hT(r,o){r=r|0,o=o|0;var u=0,f=0,y=0,E=0,T=0,k=0,D=0,j=0,te=0,fe=0,ee=0,ie=0,M=0,H=0,z=0,J=0;u=o,o=c[o>>2]+7&-8,c[u>>2]=o+16,M=r,D=c[o>>2],f=c[o+4>>2],r=c[o+12>>2],ee=r,T=be-32|0,be=T,r=r&2147483647,k=r,y=r-1006698496|0,r=r-1140785152|0,u=c[o+8>>2],o=u;e:{if((y|0)==(r|0)&o>>>0<o>>>0|r>>>0>y>>>0){if(r=u,u=ee<<4|r>>>28,o=r<<4|f>>>28,r=u,f=f&268435455,(f|0)==134217728&(D|0)!=0|f>>>0>134217728){r=r+1073741824|0,o=o+1|0,r=o?r:r+1|0;break e}if(r=r+1073741824|0,D|(f|0)!=134217728)break e;f=o&1,o=f+o|0,r=o>>>0<f>>>0?r+1|0:r;break e}if(!(!o&(k|0)==2147418112?!(f|D):k>>>0<2147418112)){r=u,u=ee<<4|r>>>28,o=r<<4|f>>>28,r=u&524287|2146959360;break e}if(o=0,r=2146435072,k>>>0>1140785151||(r=0,ie=k>>>16|0,ie>>>0<15249))break e;o=D,r=f,y=ee&65535|65536,k=y,fe=u,E=u,j=ie-15233|0;r:{if(j&64){u=o,y=j+-64|0,o=y&31,(y&63)>>>0>=32?(r=u<<o,E=0):(r=(1<<o)-1&u>>>32-o|r<<o,E=u<<o),y=r,o=0,r=0;break r}if(!j)break r;te=E,E=j&31,(j&63)>>>0>=32?(u=te<<E,E=0):(u=(1<<E)-1&te>>>32-E|y<<E,E=te<<E),y=u,H=E,te=o,u=64-j|0,E=u&31,(u&63)>>>0>=32?(u=0,o=r>>>E|0):(u=r>>>E|0,o=((1<<E)-1&r)<<32-E|te>>>E),E=H|o,y=u|y,o=j&31,(j&63)>>>0>=32?(u=te<<o,o=0):(u=(1<<o)-1&te>>>32-o|r<<o,o=te<<o),r=u}c[T+16>>2]=o,c[T+20>>2]=r,c[T+24>>2]=E,c[T+28>>2]=y,o=15361-ie|0;r:{if(o&64){f=fe,o=o+-64|0,r=o&31,(o&63)>>>0>=32?(u=0,D=k>>>r|0):(u=k>>>r|0,D=((1<<r)-1&k)<<32-r|f>>>r),f=u,fe=0,k=0;break r}if(!o)break r;y=fe,r=64-o|0,u=r&31,(r&63)>>>0>=32?(r=y<<u,E=0):(r=(1<<u)-1&y>>>32-u|k<<u,E=y<<u),y=D,D=o&31,(o&63)>>>0>=32?(u=0,y=f>>>D|0):(u=f>>>D|0,y=((1<<D)-1&f)<<32-D|y>>>D),D=E|y,f=r|u,y=fe,u=o&31,(o&63)>>>0>=32?(r=0,fe=k>>>u|0):(r=k>>>u|0,fe=((1<<u)-1&k)<<32-u|y>>>u),k=r}if(c[T>>2]=D,c[T+4>>2]=f,c[T+8>>2]=fe,c[T+12>>2]=k,o=c[T+8>>2],r=c[T+12>>2]<<4|o>>>28,o=o<<4,u=c[T>>2],k=c[T+4>>2],o=k>>>28|o,f=k&268435455,u=u|(c[T+16>>2]|c[T+24>>2]|(c[T+20>>2]|c[T+28>>2]))!=0,(f|0)==134217728&(u|0)!=0|f>>>0>134217728){o=o+1|0,r=o?r:r+1|0;break e}if(u|(f|0)!=134217728)break e;u=o,o=o+(o&1)|0,r=u>>>0>o>>>0?r+1|0:r}be=T+32|0,Le(0,o|0),Le(1,ee&-2147483648|r),z=M,J=+ki(),Ht[z>>3]=J}function pn(r,o,u,f,y,E,T,k,D,j,te,fe,ee,ie){var M=v(0),H=0,z=0,J=0,oe=0,ae=v(0),ve=0,Ae=0,Ce=v(0);e:{if(!(c[r+312>>2]!=(ie|0)&&xe[r+4|0]&4)&&(oe=0,c[r+316>>2]==(f|0)))break e;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,oe=1}ve=ee+1|0;e:{r:{i:{t:{if(c[r+8>>2]){if(ae=dt(r,2,T),Ce=kt(r,2,T),M=v(dt(r,0,T)+kt(r,0,T)),ee=r+524|0,ae=v(ae+Ce),dm(y,o,E,u,c[r+532>>2],C[ee>>2],c[r+536>>2],C[r+528>>2],C[r+540>>2],C[r+544>>2],ae,M,te))break i;if(z=c[r+320>>2],!z)break t;for(H=r+324|0;;){if(ee=H+Wt(J,24)|0,dm(y,o,E,u,c[ee+8>>2],C[ee>>2],c[ee+12>>2],C[ee+4>>2],C[ee+16>>2],C[ee+20>>2],ae,M,te))break i;if(J=J+1|0,(z|0)==(J|0))break}break t}if(!D){if(Ae=c[r+320>>2],!Ae)break t;for(z=r+324|0;;){H=Wt(J,24),ee=H+z|0,M=C[ee>>2];s:{n:{if(!(M!=M|o!=o)){if(v(zt(v(M-o)))<v(9999999747378752e-20))break n;break s}if(M==M|o==o)break s}H=z+H|0,M=C[H+4>>2];n:{if(!(M!=M|u!=u)){if(v(zt(v(M-u)))<v(9999999747378752e-20))break n;break s}if(M==M|u==u)break s}if(c[H+8>>2]!=(y|0))break s;if(c[H+12>>2]==(E|0))break i}if(J=J+1|0,(Ae|0)==(J|0))break}break t}ee=r+524|0,M=C[ee>>2];s:{if(!(M!=M|o!=o)){if(v(zt(v(M-o)))<v(9999999747378752e-20))break s;break t}if(M==M|o==o)break t}H=c[r+532>>2]==(y|0)&&c[r+536>>2]==(E|0)?ee:0,M=C[r+528>>2],ee=M!=M,z=u!=u;s:{if(ee|z){ee=ee&z;break s}ee=v(zt(v(M-u)))<v(9999999747378752e-20)}ee=ee?H:0;break i}am(r,o,u,f,y,E,T,k,D,te,fe,ve,ie,j),c[r+316>>2]=f;break r}if(!(!ee|oe)){C[r+516>>2]=C[ee+16>>2],C[r+520>>2]=C[ee+20>>2],f=(D?12:16)+fe|0,c[f>>2]=c[f>>2]+1;break e}if(am(r,o,u,f,y,E,T,k,D,te,fe,ve,ie,j),c[r+316>>2]=f,ee)break e}ee=c[r+320>>2],f=ee+1|0,f>>>0>em[fe+8>>2]&&(c[fe+8>>2]=f),(ee|0)==8&&(c[r+320>>2]=0,ee=0),D?f=r+524|0:(c[r+320>>2]=ee+1,f=(Wt(ee,24)+r|0)+324|0),c[f+12>>2]=E,c[f+8>>2]=y,C[f+4>>2]=u,C[f>>2]=o,C[f+16>>2]=C[r+516>>2],C[f+20>>2]=C[r+520>>2],ee=0}e:{if(!D||(f=c[r+520>>2],c[r+244>>2]=c[r+516>>2],c[r+248>>2]=f,f=xe[r+4|0],y=f|1,ge[r+4|0]=y,!(f&4)))break e;ge[r+4|0]=y&251}return c[r+312>>2]=ie,!ee|oe}function zu(r){r=r|0;var o=0,u=0,f=0,y=0,E=0,T=0,k=0,D=0,j=0,te=0,fe=0;k=8;e:{if(r>>>0>4294967239)break e;r:{for(;;){k=k>>>0<=8?8:k,o=c[1751],E=o,y=c[1750],r=r>>>0<=8?8:r+3&-4;i:{if(r>>>0<=127){T=(r>>>3|0)-1|0;break i}if(f=yr(r),T=((r>>>29-f^4)-(f<<2)|0)+110|0,r>>>0<=4095)break i;f=((r>>>30-f^2)-(f<<1)|0)+71|0,T=f>>>0>=63?63:f}if(u=T&31,(T&63)>>>0>=32?(f=0,o=o>>>u|0):(f=o>>>u|0,o=((1<<u)-1&o)<<32-u|y>>>u),o|f){for(;;){y=f;i:{if(o|f){u=f-1|0,D=u+1|0,E=u,u=o-1|0,E=(u|0)!=-1?D:E,f=yr(f^E),f=(f|0)==32?yr(o^u)+32|0:f,u=63-f|0,Vi=0-(f>>>0>63)|0;break i}Vi=0,u=64}E=u,u=E&31,(E&63)>>>0>=32?(f=0,o=y>>>u|0):(f=y>>>u|0,o=((1<<u)-1&y)<<32-u|o>>>u),D=o,T=E+T|0,u=T<<4,o=c[u+5976>>2],E=u+5968|0;i:{if((o|0)!=(E|0)){if(y=Zu(o,k,r),y)break e;y=c[o+4>>2],c[y+8>>2]=c[o+8>>2],c[c[o+8>>2]+4>>2]=y,c[o+8>>2]=E,y=u+5972|0,c[o+4>>2]=c[y>>2],c[y>>2]=o,c[c[o+4>>2]+8>>2]=o,T=T+1|0,o=(f&1)<<31|D>>>1,f=f>>>1|0;break i}j=c[1751],E=T&63,o=E,y=o&31,o>>>0>=32?(o=0,u=-1>>>y|0):(o=-1>>>y|0,u=o|(1<<y)-1<<32-y),u=u&-2,y=E&31,E>>>0>=32?(o=u<<y,u=0):(o=(1<<y)-1&u>>>32-y|o<<y,u=u<<y),te=u,y=o,E=0-T&63,u=E,o=u&31,u>>>0>=32?(o=-1<<o,u=0):(u=-1<<o,o=u|(1<<o)-1&-1>>>32-o),fe=u&-2,u=E&31,E>>>0>=32?(E=0,o=o>>>u|0):(E=o>>>u|0,o=((1<<u)-1&o)<<32-u|fe>>>u),o=o|te,Vi=y|E,c[1750]=c[1750]&o,c[1751]=Vi&j,o=D^1}if(!(o|f))break}E=c[1751],y=c[1750]}i:{if(y|E){f=yr(E),u=63-((f|0)==32?yr(y)+32|0:f)|0,o=u<<4,f=c[o+5976>>2];t:{if(!E&y>>>0<1073741824||(T=99,o=o+5968|0,(o|0)==(f|0)))break t;for(;;){if(!T)break t;if(y=Zu(f,k,r),y)break e;if(T=T-1|0,f=c[f+8>>2],(o|0)==(f|0))break}f=o}if(Xu(r+48|0))break i;if(!f||(o=(u<<4)+5968|0,(o|0)==(f|0)))break r;for(;;){if(y=Zu(f,k,r),y)break e;if(f=c[f+8>>2],(o|0)==(f|0))break}break r}if(!Xu(r+48|0))break r}if(y=0,k-1&k)break e;if(!(r>>>0<=4294967239))break}break e}y=0}return y|0}function fT(r,o,u){r=r|0,o=o|0,u=u|0;var f=0,y=0,E=0,T=0,k=0,D=0,j=0,te=0,fe=0,ee=0;k=be-80|0,be=k,r=c[r>>2];e:{r:{if(D=c[o>>2],!c[D+552>>2]){if(c[r+8>>2])break r;o=c[r+556>>2],T=o+(u<<2)|0,f=c[r+560>>2],y=r+564|0,E=c[y>>2];i:{if(f>>>0<E>>>0){if((f|0)==(T|0)){c[T>>2]=D,c[r+560>>2]=T+4;break i}if(u=f,o=f-4|0,f>>>0>o>>>0)for(;c[u>>2]=c[o>>2],u=u+4|0,o=o+4|0,f>>>0>o>>>0;);c[r+560>>2]=u,o=T+4|0,(o|0)!=(f|0)&&(o=f-o|0,$s(f-(o&-4)|0,T,o)),c[T>>2]=D;break i}if(f=(f-o>>2)+1|0,f>>>0>=1073741824)break e;o=E-o|0,E=o>>1,y=Ko(k+32|0,o>>>0>=2147483644?1073741823:f>>>0<E>>>0?E:f,u,y),u=c[y+8>>2];t:{if((u|0)!=c[y+12>>2])break t;if(o=c[y+4>>2],f=c[y>>2],o>>>0>f>>>0){f=((o-f>>2)+1|0)/-2<<2,j=f+o|0,E=o,o=u-o|0,u=$s(j,E,o)+o|0,c[y+8>>2]=u,c[y+4>>2]=f+c[y+4>>2];break t}o=(u|0)==(f|0)?1:u-f>>1,E=Ko(k+56|0,o,o>>>2|0,c[y+16>>2]),f=c[E+8>>2],o=c[y+4>>2],u=c[y+8>>2];s:{if((o|0)==(u|0)){u=f,f=o;break s}for(u=(u-o|0)+f|0;c[f>>2]=c[o>>2],o=o+4|0,f=f+4|0,(f|0)!=(u|0););o=c[y+8>>2],f=c[y+4>>2]}if(j=c[y>>2],c[y>>2]=c[E>>2],c[E>>2]=j,c[y+4>>2]=c[E+4>>2],c[E+4>>2]=f,c[y+8>>2]=u,c[E+8>>2]=o,te=c[y+12>>2],c[y+12>>2]=c[E+12>>2],c[E+12>>2]=te,(o|0)!=(f|0)&&(c[E+8>>2]=((f-o|0)+3&-4)+o),!j)break t;vi(j),u=c[y+8>>2]}if(c[u>>2]=D,c[y+8>>2]=c[y+8>>2]+4,o=c[r+556>>2],u=T-o|0,fe=y,ee=$s(c[y+4>>2]-u|0,o,u),c[fe+4>>2]=ee,f=c[r+560>>2]-T|0,T=$s(c[y+8>>2],T,f),o=c[r+556>>2],c[r+556>>2]=c[y+4>>2],c[y+4>>2]=o,u=c[r+560>>2],c[r+560>>2]=f+T,c[y+8>>2]=u,f=c[r+564>>2],c[r+564>>2]=c[y+12>>2],c[y>>2]=o,c[y+12>>2]=f,(o|0)!=(u|0)&&(c[y+8>>2]=u+((o-u|0)+3&-4)),!o)break i;vi(o)}for(c[D+552>>2]=r;o=xe[r+4|0],!!(!(o&4)&&(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],r)););be=k+80|0;return}c[k+16>>2]=4075,or(r,k+16|0),er(),St()}c[k>>2]=4208,or(r,k),er(),St()}Ps(),St()}function um(r,o){var u=0,f=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,ge[r+4|0]=xe[r+4|0]&128,f=Wi(r+44|0,0,36);c[f+(u<<2)>>2]=2143289344,u=u+1|0,(u|0)!=9;);for(u=0,f=Wi(r+80|0,0,36);c[f+(u<<2)>>2]=2143289344,u=u+1|0,(u|0)!=9;);for(u=0,f=Wi(r+116|0,0,36);c[f+(u<<2)>>2]=2143289344,u=u+1|0,(u|0)!=9;);for(u=0,f=Wi(r+152|0,0,36);c[f+(u<<2)>>2]=2143289344,u=u+1|0,(u|0)!=9;);for(u=0,c[r+196>>2]=0,f=r+188|0,c[f>>2]=0,c[f+4>>2]=0;c[f+(u<<2)>>2]=2143289344,u=u+1|0,(u|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,Wi(r+228|0,0,288),c[r+244>>2]=2143289344,c[r+248>>2]=2143289344,Wi(r+252|0,0,49),c[r+308>>2]=2143289344,f=r+516|0,u=r+324|0;c[u+16>>2]=-1082130432,c[u+20>>2]=-1082130432,c[u+8>>2]=0,c[u+12>>2]=0,c[u>>2]=-1082130432,c[u+4>>2]=-1082130432,u=u+24|0,(f|0)!=(u|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]=o,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,Hm((o|0)!=0,2760),ge[r+4|0]=xe[r+4|0]|1,ge[o+8|0]&1&&(c[r+24>>2]=c[r+24>>2]&-909|520),r}function Yt(r,o,u,f){var y=v(0),E=v(0),T=0,k=v(0);e:{r:{i:{t:{s:{n:{if(o>>>0<=1){E=C[r+212>>2],o=c[r+212>>2];o:{if((o|0)==2139156720)break o;if((o|0)==2140081935)break n;T=4336;a:{if((o|0)!=2141891242){if(E==E)break a;T=4344}switch(y=C[T>>2],E=v(Xe),c[T+4>>2]-1|0){case 0:break n;case 1:break o;default:break s}}if(y=(Le(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break n}E=v(v(y*f)*v(.009999999776482582));break s}E=C[r+208>>2];o:{a:{o=c[r+208>>2];l:{if((o|0)==2139156720)break l;if((o|0)==2140081935)break a;T=4336;c:{if((o|0)!=2141891242){if(E==E)break c;T=4344}switch(y=C[T>>2],E=v(Xe),c[T+4>>2]-1|0){case 0:break a;case 1:break l;default:break o}}if(y=(Le(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break a}E=v(v(y*f)*v(.009999999776482582));break o}E=y}y=v(0),k=C[r+216>>2],r=c[r+216>>2];o:{if((r|0)==2139156720)break o;if((r|0)==2140081935)break i;o=4336;a:{if((r|0)!=2141891242){if(k==k)break a;o=4344}switch(y=C[o>>2],c[o+4>>2]-1|0){case 1:break o;case 0:break t;default:break r}}if(y=(Le(2,(r&-1073741825)+536870912|0),He()),!(r&1073741824))break t}y=v(v(y*f)*v(.009999999776482582));break t}E=y}y=v(0),k=C[r+220>>2],r=c[r+220>>2];s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break i;o=4336;n:{if((r|0)!=2141891242){if(k==k)break n;o=4344}switch(y=C[o>>2],c[o+4>>2]-1|0){case 1:break s;case 0:break t;default:break r}}if(y=(Le(2,(r&-1073741825)+536870912|0),He()),!(r&1073741824))break t}y=v(v(y*f)*v(.009999999776482582))}if(!(y>=v(0)))break r}if(u>y)break e}if(!(E>=v(0)))return u;y=u<E?E:u}return y}function hm(r){var o=0,u=0,f=v(0),y=v(0),E=v(0),T=0,k=0,D=0,j=0,te=0,fe=0,ee=0,ie=0,M=0;for(T=be-16|0,c[T+8>>2]=0,c[T+12>>2]=1,te=r+200|0,fe=r+572|0,ee=r+208|0,ie=r+216|0,r=0;;){M=r,j=c[(T+8|0)+(r<<2)>>2],k=j<<2,r=ie+k|0,f=C[r>>2];e:{r:{i:{t:{s:{n:{if(o=c[r>>2],D=(o|0)==2139156720,!(D|(o|0)==2140081935|(o|0)==2141891242)&f!=f)break n;r=k+ee|0,y=C[r>>2],u=c[r>>2];o:{a:{if((u|0)!=2139156720){if(E=v(Xe),r=3,(u|0)==2141891242)break o;if((u|0)!=2140081935)break a;E=v(0),r=1;break o}E=v(0),r=2;break o}if(r=0,y!=y)break o;E=(Le(2,(u&-1073741825)+536870912|0),He()),r=u&1073741824?2:1}u=r;o:{a:{if(!D){if(y=v(Xe),r=3,(o|0)==2141891242)break o;if((o|0)!=2140081935)break a;y=v(0),r=1;break o}y=v(0),r=2;break o}if(r=0,f!=f)break o;y=(Le(2,(o&-1073741825)+536870912|0),He()),r=o&1073741824?2:1}if((u|0)!=(r|0)|!(!r|y!=y&E!=E|v(zt(v(y-E)))<v(9999999747378752e-20)))break n;if(r=0,D)break s;if((o|0)==2140081935)break r;if((o|0)==2141891242)break i;if(f!=f)break t;r=(o&-1073741825)+536870912|0,o=o&1073741824?2:1;break e}if(r=0,o=k+te|0,f=C[o>>2],o=c[o>>2],(o|0)==2139156720)break s;if((o|0)==2140081935)break r;if((o|0)==2141891242)break i;if(f!=f)break t;r=(o&-1073741825)+536870912|0,o=o&1073741824?2:1;break e}o=2;break e}r=2143289344,o=0;break e}r=2143289344,o=3;break e}o=1}if(u=(j<<3)+fe|0,c[u+4>>2]=o,c[u>>2]=r,r=1,!!(M&1))break}}function Hi(r,o,u){var f=0,y=0,E=0;if(u>>>0>=512)return iT(r|0,o|0,u|0),r;y=r+u|0;e:{if(!((r^o)&3)){r:{if(!(r&3)){u=r;break r}if(!u){u=r;break r}for(u=r;;){if(ge[u|0]=xe[o|0],o=o+1|0,u=u+1|0,!(u&3))break r;if(!(u>>>0<y>>>0))break}}f=y&-4;r:{if(f>>>0<64||(E=f+-64|0,E>>>0<u>>>0))break r;for(;c[u>>2]=c[o>>2],c[u+4>>2]=c[o+4>>2],c[u+8>>2]=c[o+8>>2],c[u+12>>2]=c[o+12>>2],c[u+16>>2]=c[o+16>>2],c[u+20>>2]=c[o+20>>2],c[u+24>>2]=c[o+24>>2],c[u+28>>2]=c[o+28>>2],c[u+32>>2]=c[o+32>>2],c[u+36>>2]=c[o+36>>2],c[u+40>>2]=c[o+40>>2],c[u+44>>2]=c[o+44>>2],c[u+48>>2]=c[o+48>>2],c[u+52>>2]=c[o+52>>2],c[u+56>>2]=c[o+56>>2],c[u+60>>2]=c[o+60>>2],o=o- -64|0,u=u- -64|0,E>>>0>=u>>>0;);}if(u>>>0>=f>>>0)break e;for(;c[u>>2]=c[o>>2],o=o+4|0,u=u+4|0,f>>>0>u>>>0;);break e}if(y>>>0<4){u=r;break e}if(f=y-4|0,f>>>0<r>>>0){u=r;break e}for(u=r;ge[u|0]=xe[o|0],ge[u+1|0]=xe[o+1|0],ge[u+2|0]=xe[o+2|0],ge[u+3|0]=xe[o+3|0],o=o+4|0,u=u+4|0,f>>>0>=u>>>0;);}if(u>>>0<y>>>0)for(;ge[u|0]=xe[o|0],o=o+1|0,u=u+1|0,(y|0)!=(u|0););return r}function fm(r,o,u,f,y){var E=v(0),T=0,k=v(0),D=v(0),j=0,te=0,fe=v(0),ee=v(0),ie=0;if(k=v(u-f),te=k!=k,!te){u=v(0),T=(o<<2)+r|0,E=C[T+208>>2];e:{r:{T=c[T+208>>2];i:{t:{if((T|0)==2139156720)break t;if((T|0)==2140081935)break r;j=4336;s:{if((T|0)!=2141891242){if(E==E)break s;j=4344}switch(u=C[j>>2],c[j+4>>2]-1|0){case 0:break i;case 1:break t;default:break e}}if(u=(Le(2,(T&-1073741825)+536870912|0),He()),!(T&1073741824))break i}u=v(v(u*y)*v(.009999999776482582))}if(u==u)break r;break e}D=v(u-f)}u=v(0),r=(o<<2)+r|0,E=C[r+216>>2];e:{r:{o=c[r+216>>2];i:{t:{if((o|0)==2139156720)break t;if((o|0)==2140081935)break r;r=4336;s:{if((o|0)!=2141891242){if(E==E)break s;r=4344}switch(u=C[r>>2],E=v(34028234663852886e22),c[r+4>>2]-1|0){case 0:break i;case 1:break t;default:break e}}if(u=(Le(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break i}u=v(v(u*y)*v(.009999999776482582))}if(u==u)break r;E=v(34028234663852886e22);break e}E=v(u-f)}if(u=(fe=k,ee=th(k,E),ie=E!=E|te,ie?fe:ee),r=u!=u,!(r|D!=D))return ht(u,D);k=r?D:u}return k}function dm(r,o,u,f,y,E,T,k,D,j,te,fe,ee){var ie=v(0),M=v(0),H=0,z=0,J=v(0),oe=v(0),ae=v(0),ve=0,Ae=0;if(D<v(0)|j<v(0))r=0;else{J=E,oe=o,ae=f,M=k;e:{if(!ee||(ie=C[ee+20>>2],M=k,ie==v(0)))break e;ve=+ie,oe=Hr(+o,ve,0,0),ae=Hr(+f,ve,0,0),J=Hr(+E,ve,0,0),M=Hr(+k,ve,0,0)}ie=M,ee=0;e:{if((r|0)!=(y|0))break e;if(Ae=J!=J,ee=oe!=oe,Ae|ee){ee=ee&Ae;break e}ee=v(zt(v(J-oe)))<v(9999999747378752e-20)}Ae=ee;e:{if((u|0)!=(T|0))break e;if(H=ie!=ie,ee=ae!=ae,H|ee){H=ee&H;break e}H=v(zt(v(ie-ae)))<v(9999999747378752e-20)}z=1,ee=1;e:{if(Ae)break e;o=v(o-te);r:{if((r|0)==1)break r;if(r=(r|0)!=2,!(r|y)){if(!(o>=D))break r;break e}if(ee=0,!(o<E)|(r|(y|0)!=2|(o!=o|E!=E|D!=D))||(ee=1,o>=D))break e}if(y=o!=o,r=D!=D,y|r){ee=r&y;break e}ee=v(zt(v(o-D)))<v(9999999747378752e-20)}e:{if(H)break e;o=v(f-fe);r:{if((u|0)==1)break r;if(r=(u|0)!=2,!(r|T)){if(!(o>=j))break r;break e}if(z=0,!(o<k)|(r|(T|0)!=2|(o!=o|k!=k|j!=j))||(z=1,o>=j))break e}if(u=o!=o,r=j!=j,u|r){z=r&u;break e}z=v(zt(v(o-j)))<v(9999999747378752e-20)}r=ee&z}return r}function Yu(r){var o=0,u=0,f=0,y=0,E=0,T=0,k=0,D=0;if($i(+r),E=mt(1)|0,f=mt(0)|0,y=E>>>20&2047,(y|0)==2047)return r=r*1,r/r;if(o=f<<1,T=E<<1|f>>>31,!o&(T|0)==2145386496|T>>>0<2145386496)return!o&(T|0)==2145386496?r*0:r;e:{if(!y){if(y=0,u=f<<12,o=E<<12|f>>>20,(o|0)>0|(o|0)>=0)for(;y=y-1|0,o=o<<1|u>>>31,u=u<<1,!!((o|0)>0|(o|0)>=0););o=1-y|0,u=o&31,(o&63)>>>0>=32?(o=f<<u,f=0):(o=(1<<u)-1&f>>>32-u|E<<u,f=f<<u);break e}o=E&1048575|1048576}if(u=f,(y|0)>1023){for(;;){e:{if(f=o+-1048576|0,(f|0)<0||(o=f,o|u))break e;return r*0}if(o=o<<1|u>>>31,u=u<<1,y=y-1|0,!((y|0)>1023))break}y=1023}e:{if(f=o+-1048576|0,(f|0)<0||(o=f,o|u))break e;return r*0}if((o|0)==1048575|o>>>0<1048575)for(;y=y-1|0,f=o>>>0<524288,T=o<<1|u>>>31,u=u<<1,o=T,!!f;);return D=E&-2147483648,T=o+-1048576|y<<20,k=u,E=o,k=u,f=1-y|0,u=f&31,(f&63)>>>0>=32?(o=0,f=E>>>u|0):(o=E>>>u|0,f=((1<<u)-1&E)<<32-u|k>>>u),u=(y|0)>0,Le(0,(u?k:f)|0),Le(1,(u?T:o)|D),+ki()}function Xu(r){var o=0,u=0,f=0,y=0,E=0;f=c[1416],o=r+7&-8,u=f+o|0;e:{r:{if(u>>>0<=f>>>0&&o||u>>>0>ig()<<16>>>0&&!(tT(u|0)|0))break r;c[1416]=u;break e}c[1781]=48,f=-1}if((f|0)!=-1){o=r+f|0,u=o-16|0,c[u+12>>2]=16,c[u>>2]=16,r=c[1748],r?E=c[r+8>>2]:E=0;e:{r:{if((E|0)==(f|0)){if(y=f-(c[f-4>>2]&-2)|0,E=c[y-4>>2],c[r+8>>2]=o,r=y-(E&-2)|0,o=-16,!(ge[(r+c[r>>2]|0)-4|0]&1))break r;o=c[r+4>>2],c[o+8>>2]=c[r+8>>2],c[c[r+8>>2]+4>>2]=o,u=u-r|0,c[r>>2]=u;break e}c[f+12>>2]=16,c[f>>2]=16,c[f+8>>2]=o,c[f+4>>2]=r,c[1748]=f,o=16}r=o+f|0,u=u-r|0,c[r>>2]=u}c[((u&-4)+r|0)-4>>2]=u|1,o=c[r>>2]-8|0;e:{if(o>>>0<=127){u=(o>>>3|0)-1|0;break e}if(y=yr(o),u=((o>>>29-y^4)-(y<<2)|0)+110|0,o>>>0<=4095)break e;u=((o>>>30-y^2)-(y<<1)|0)+71|0,u=u>>>0>=63?63:u}o=u<<4,c[r+4>>2]=o+5968,o=o+5976|0,c[r+8>>2]=c[o>>2],c[o>>2]=r,c[c[r+8>>2]+4>>2]=r,o=c[1750],y=c[1751],r=u&31,(u&63)>>>0>=32?(u=1<<r,E=0):(E=1<<r,u=E-1&1>>>32-r),c[1750]=E|o,c[1751]=u|y}return(f|0)!=-1}function pm(r,o,u){var f=0,y=0,E=0,T=0,k=0,D=0,j=0,te=0,fe=0;e:{r:{i:{t:{s:{n:{o:{a:{l:{c:{if(o){if(!u)break c;break l}r=(r>>>0)/(u>>>0)|0,Vi=0;break e}if(!r)break a;break o}if(!(u-1&u))break n;E=(yr(u)+33|0)-yr(o)|0,T=0-E|0;break t}r=(o>>>0)/0|0,Vi=0;break e}if(f=32-yr(o)|0,f>>>0<31)break s;break i}if((u|0)==1)break r;E=u?31-yr(u-1^u)|0:32,u=E&31,(E&63)>>>0>=32?r=o>>>u|0:(f=o>>>u|0,r=((1<<u)-1&o)<<32-u|r>>>u),Vi=f;break e}E=f+1|0,T=63-f|0}if(f=E&63,y=f&31,f>>>0>=32?(f=0,k=o>>>y|0):(f=o>>>y|0,k=((1<<y)-1&o)<<32-y|r>>>y),T=T&63,y=T&31,T>>>0>=32?(o=r<<y,r=0):(o=(1<<y)-1&r>>>32-y|o<<y,r=r<<y),E)for(T=u-1|0,fe=(T|0)==-1?-1:0;D=f<<1|k>>>31,f=k<<1|o>>>31,y=fe-(D+(f>>>0>T>>>0)|0)>>31,j=u&y,k=f-j|0,f=D-(f>>>0<j>>>0)|0,o=o<<1|r>>>31,r=te|r<<1,te=y&1,E=E-1|0,!!E;);Vi=o<<1|r>>>31,r=te|r<<1;break e}r=0,o=0}Vi=o}return r}function gl(r,o,u){var f=v(0),y=v(0);e:{r:{i:{if((o&-2)==2){if(o=c[r+188>>2],f=C[r+188>>2],(o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|f==f||(o=c[r+196>>2],f=C[r+196>>2],(o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|f==f))break i;break r}if(o=c[r+192>>2],f=C[r+192>>2],(o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|f==f||(f=C[r+196>>2],o=c[r+196>>2],(o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242))break i;if(f!=f)break r}f=v(0);i:{t:{if((o|0)==2139156720)break t;if((o|0)==2140081935)break e;r=4336;s:{if((o|0)!=2141891242){if(f=(Le(2,o),He()),f==f)break s;r=4344}switch(f=C[r>>2],y=v(Xe),c[r+4>>2]-1|0){case 0:break e;case 1:break t;default:break i}}if(f=(Le(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break e}y=v(v(f*u)*v(.009999999776482582))}return y}f=v(0)}return f}function mm(r,o){var u=0,f=0,y=0,E=0,T=0,k=0;for(u=be-320|0,be=u,f=Wi(u,0,288),u=f,c[u+16>>2]=2143289344,c[u+20>>2]=2143289344,Wi(u+24|0,0,49),c[u+80>>2]=2143289344,E=u+288|0,y=u+96|0;u=y,c[u+16>>2]=-1082130432,c[u+20>>2]=-1082130432,c[u+8>>2]=0,c[u+12>>2]=0,c[u>>2]=-1082130432,c[u+4>>2]=-1082130432,y=u+24|0,(E|0)!=(y|0););if(c[f+312>>2]=-1082130432,c[f+316>>2]=-1082130432,c[f+304>>2]=0,c[f+308>>2]=0,c[f+296>>2]=-1082130432,c[f+300>>2]=-1082130432,c[f+288>>2]=2143289344,c[f+292>>2]=2143289344,Hi(r+228|0,f,320),c[r+244>>2]=0,c[r+248>>2]=0,ge[r+4|0]=xe[r+4|0]|1,y=c[r+556>>2],T=c[r+560>>2],(y|0)!=(T|0))for(;u=c[y>>2],c[u+552>>2]!=(r|0)&&(E=c[r+568>>2],u=xm(c[E>>2],xe[E+8|0],u,r,k,o),c[y>>2]=u,c[u+552>>2]=r,u=c[y>>2]),mm(u,o),k=k+1|0,y=y+4|0,(T|0)!=(y|0););be=f+320|0}function Zu(r,o,u){var f=0,y=0,E=0,T=0;if(f=r+4|0,y=(f+o|0)-1&0-o,o=c[r>>2],y+u>>>0<=(o+r|0)-4>>>0){E=c[r+4>>2],c[E+8>>2]=c[r+8>>2],c[c[r+8>>2]+4>>2]=E,(f|0)!=(y|0)&&(y=y-f|0,E=r-(c[r-4>>2]&-2)|0,f=y+c[E>>2]|0,c[E>>2]=f,c[(E+(f&-4)|0)-4>>2]=f,r=r+y|0,o=o-y|0,c[r>>2]=o);e:{if(u+24>>>0<=o>>>0){f=(r+u|0)+8|0,o=(o-u|0)-8|0,c[f>>2]=o,c[(f+(o&-4)|0)-4>>2]=o|1,y=c[f>>2]-8|0;r:{if(y>>>0<=127){o=(y>>>3|0)-1|0;break r}if(E=yr(y),o=((y>>>29-E^4)-(E<<2)|0)+110|0,y>>>0<=4095)break r;o=((y>>>30-E^2)-(E<<1)|0)+71|0,o=o>>>0>=63?63:o}y=o<<4,c[f+4>>2]=y+5968,y=y+5976|0,c[f+8>>2]=c[y>>2],c[y>>2]=f,c[c[f+8>>2]+4>>2]=f,y=c[1750],E=c[1751],f=o&31,(o&63)>>>0>=32?(o=1<<f,f=0):(T=1<<f,o=T-1&1>>>32-f,f=T),c[1750]=f|y,c[1751]=o|E,o=u+8|0,c[r>>2]=o,c[((o&-4)+r|0)-4>>2]=o;break e}c[(r+o|0)-4>>2]=o}r=r+4|0}else r=0;return r}function dT(r,o){r=r|0,o=o|0;var u=0,f=0,y=0,E=0;y=be-320|0,be=y,r=c[r>>2];e:{if(c[r+560>>2]==c[r+556>>2]||(f=c[o>>2],o=c[f+552>>2],!wm(r,f)))break e;if((r|0)==(o|0)){for(u=Wi(y,0,288),o=u,c[o+16>>2]=2143289344,c[o+20>>2]=2143289344,Wi(o+24|0,0,49),c[o+80>>2]=2143289344,E=o+288|0,o=o+96|0;c[o+16>>2]=-1082130432,c[o+20>>2]=-1082130432,c[o+8>>2]=0,c[o+12>>2]=0,c[o>>2]=-1082130432,c[o+4>>2]=-1082130432,o=o+24|0,(E|0)!=(o|0););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,Hi(f+228|0,u,320),c[f+552>>2]=0}for(;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}be=y+320|0}function gm(r){r=r|0;var o=0,u=0,f=0,y=0,E=0,T=0,k=0;if(r){if(T=be-32|0,be=T,o=c[r>>2],f=c[o+552>>2],f&&(wm(f,o),c[o+552>>2]=0),f=c[o+556>>2],u=c[o+560>>2],(f|0)!=(u|0))for(u=u-f>>2,y=u>>>0<=1?1:u,u=0;c[c[(u<<2)+f>>2]+552>>2]=0,u=u+1|0,(y|0)!=(u|0););c[o+560>>2]=f,u=o+564|0;e:{if(c[u>>2]==(f|0)||(u=Ko(T+8|0,0,0,u),y=c[o+556>>2],E=c[o+560>>2]-y|0,f=c[u+4>>2]-E|0,E=$s(f,y,E),y=c[o+556>>2],c[o+556>>2]=E,c[u+4>>2]=y,E=c[o+560>>2],c[o+560>>2]=c[u+8>>2],c[u+8>>2]=E,k=c[o+564>>2],c[o+564>>2]=c[u+12>>2],c[u>>2]=y,c[u+12>>2]=k,(y|0)!=(E|0)&&(c[u+8>>2]=E+((y-E|0)+3&-4)),!y))break e;vi(y),f=c[o+556>>2]}f&&(c[o+560>>2]=f,vi(f)),vi(o),o=c[r+8>>2],c[r+8>>2]=0,o&&$e[c[c[o>>2]+4>>2]](o),o=c[r+4>>2],c[r+4>>2]=0,o&&$e[c[c[o>>2]+4>>2]](o),be=T+32|0,vi(r)}}function pT(r){r=r|0;var o=0,u=0,f=0;f=be-624|0,be=f,o=c[r+4>>2],c[r+4>>2]=0,o&&$e[c[c[o>>2]+4>>2]](o),o=c[r+8>>2],c[r+8>>2]=0,o&&$e[c[c[o>>2]+4>>2]](o);e:{if(r=c[r>>2],c[r+560>>2]==c[r+556>>2]){if(c[r+552>>2])break e;o=um(f+32|0,c[r+568>>2]),u=c[o+4>>2],c[r>>2]=c[o>>2],c[r+4>>2]=u,u=c[o+20>>2],c[r+16>>2]=c[o+16>>2],c[r+20>>2]=u,u=c[o+12>>2],c[r+8>>2]=c[o+8>>2],c[r+12>>2]=u,Hi(r+24|0,o+24|0,204),Hi(r+228|0,o+228|0,328),u=c[r+556>>2],u&&(c[r+560>>2]=u,vi(u)),c[r+556>>2]=c[o+556>>2],c[r+560>>2]=c[o+560>>2],c[r+564>>2]=c[o+564>>2],c[r+584>>2]=c[o+584>>2],u=c[o+580>>2],c[r+576>>2]=c[o+576>>2],c[r+580>>2]=u,u=c[o+572>>2],c[r+568>>2]=c[o+568>>2],c[r+572>>2]=u,be=f+624|0;return}c[f+16>>2]=3301,or(r,f+16|0),er(),St()}c[f>>2]=2047,or(r,f),er(),St()}function vm(){aT(7084,3067),oT(7085,2480,1,1,0),cs(7086,2140,1,-128,127),cs(7087,2133,1,-128,127),cs(7088,2131,1,0,255),cs(7089,1287,2,-32768,32767),cs(7090,1278,2,0,65535),cs(7091,1316,4,-2147483648,2147483647),cs(7092,1307,4,0,-1),cs(7093,2659,4,-2147483648,2147483647),cs(7094,2650,4,0,-1),Ym(7095,1777,-2147483648,2147483647),Ym(7096,1776,0,-1),rm(7097,1770,4),rm(7098,3015,8),sm(7099,2677),sm(7100,3904),Wu(7101,4,2664),Wu(7102,2,2689),Wu(7103,4,2704),nT(7104,2485),wi(7105,0,3835),wi(7106,0,3937),wi(7107,1,3865),wi(7108,2,3467),wi(7109,3,3498),wi(7110,4,3538),wi(7111,5,3567),wi(7112,4,3974),wi(7113,5,4004),wi(7106,0,3669),wi(7107,1,3636),wi(7108,2,3735),wi(7109,3,3701),wi(7110,4,3802),wi(7111,5,3768),wi(7114,6,3605),wi(7115,7,4043)}function $s(r,o,u){var f=0,y=0;e:{if((r|0)==(o|0))break e;if(y=r+u|0,o-y>>>0<=0-(u<<1)>>>0)return Hi(r,o,u);f=(r^o)&3;r:{i:{if(r>>>0<o>>>0){if(f){f=r;break r}if(!(r&3)){f=r;break i}for(f=r;;){if(!u)break e;if(ge[f|0]=xe[o|0],o=o+1|0,u=u-1|0,f=f+1|0,!(f&3))break}break i}t:{if(f)break t;if(y&3)for(;;){if(!u)break e;if(u=u-1|0,f=u+r|0,ge[f|0]=xe[o+u|0],!(f&3))break}if(u>>>0<=3)break t;for(;u=u-4|0,c[u+r>>2]=c[o+u>>2],u>>>0>3;);}if(!u)break e;for(;u=u-1|0,ge[u+r|0]=xe[o+u|0],!!u;);break e}if(u>>>0<=3)break r;for(;c[f>>2]=c[o>>2],o=o+4|0,f=f+4|0,u=u-4|0,u>>>0>3;);}if(!u)break e;for(;ge[f|0]=xe[o|0],f=f+1|0,o=o+1|0,u=u-1|0,!!u;);}return r}function ym(r,o,u,f){e:switch(o-9|0){case 0:o=c[u>>2],c[u>>2]=o+4,c[r>>2]=c[o>>2];return;case 6:o=c[u>>2],c[u>>2]=o+4,o=Br[o>>1],c[r>>2]=o,c[r+4>>2]=o>>31;return;case 7:o=c[u>>2],c[u>>2]=o+4,c[r>>2]=Bn[o>>1],c[r+4>>2]=0;return;case 8:o=c[u>>2],c[u>>2]=o+4,o=ge[o|0],c[r>>2]=o,c[r+4>>2]=o>>31;return;case 9:o=c[u>>2],c[u>>2]=o+4,c[r>>2]=xe[o|0],c[r+4>>2]=0;return;case 16:o=c[u>>2]+7&-8,c[u>>2]=o+8,Ht[r>>3]=Ht[o>>3];return;case 17:$e[f|0](r,u);default:return;case 1:case 4:case 14:o=c[u>>2],c[u>>2]=o+4,o=c[o>>2],c[r>>2]=o,c[r+4>>2]=o>>31;return;case 2:case 5:case 11:case 15:o=c[u>>2],c[u>>2]=o+4,c[r>>2]=c[o>>2],c[r+4>>2]=0;return;case 3:case 10:case 12:case 13:break e}o=c[u>>2]+7&-8,c[u>>2]=o+8,u=c[o+4>>2],c[r>>2]=c[o>>2],c[r+4>>2]=u}function Am(r,o,u,f){var y=0,E=0,T=0,k=0,D=0,j=0,te=0,fe=0,ee=0,ie=v(0),M=v(0),H=v(0),z=0,J=v(0);e:{if(o==0||(ie=C[r+248>>2],M=C[r+244>>2],H=C[r+232>>2],D=+C[r+228>>2],y=xe[r+4|0]&8,E=y>>>3|0,z=r,J=Hr(D,o,0,E),C[z+228>>2]=J,j=+H,z=r,J=Hr(j,o,0,E),C[z+232>>2]=J,te=+M,T=Yu(te*o),E=T==T&zt(T)<1e-4,k=!(E|T!=T?E:zt(T+-1)<1e-4),fe=+ie,T=Yu(fe*o),E=T==T&zt(T)<1e-4,ee=!(E|T!=T?E:zt(T+-1)<1e-4),E=0,u=D+u,y=(y|0)!=0,z=r,J=v(Hr(u+te,o,y&k,y&!k)-Hr(u,o,0,y)),C[z+244>>2]=J,f=j+f,z=r,J=v(Hr(f+fe,o,y&ee,y&!ee)-Hr(f,o,0,y)),C[z+248>>2]=J,y=c[r+560>>2],k=c[r+556>>2],(y|0)==(k|0)))break e;for(y=y-k>>2,k=y>>>0<=1?1:y;y=c[r+556>>2],c[r+560>>2]-y>>2>>>0>E>>>0?y=c[y+(E<<2)>>2]:y=0,Am(y,o,u,f),E=E+1|0,(k|0)!=(E|0););}}function Wi(r,o,u){var f=0,y=0,E=0,T=0;e:{if(!u||(ge[r|0]=o,f=r+u|0,ge[f-1|0]=o,u>>>0<3)||(ge[r+2|0]=o,ge[r+1|0]=o,ge[f-3|0]=o,ge[f-2|0]=o,u>>>0<7)||(ge[r+3|0]=o,ge[f-4|0]=o,u>>>0<9)||(f=0-r&3,y=f+r|0,o=Wt(o&255,16843009),c[y>>2]=o,f=u-f&-4,u=f+y|0,c[u-4>>2]=o,f>>>0<9)||(c[y+8>>2]=o,c[y+4>>2]=o,c[u-8>>2]=o,c[u-12>>2]=o,f>>>0<25)||(c[y+24>>2]=o,c[y+20>>2]=o,c[y+16>>2]=o,c[y+12>>2]=o,c[u-16>>2]=o,c[u-20>>2]=o,c[u-24>>2]=o,c[u-28>>2]=o,T=y&4|24,u=f-T|0,u>>>0<32))break e;for(f=eh(o,0,1,1),E=Vi,o=y+T|0;c[o+24>>2]=f,c[o+28>>2]=E,c[o+16>>2]=f,c[o+20>>2]=E,c[o+8>>2]=f,c[o+12>>2]=E,c[o>>2]=f,c[o+4>>2]=E,o=o+32|0,u=u-32|0,u>>>0>31;);}return r}function vi(r){r=r|0;var o=0,u=0,f=0,y=0,E=0;if(r){o=r-4|0,y=c[o>>2],u=y,f=o,E=c[r-8>>2],r=E&-2,(r|0)!=(E|0)&&(f=o-r|0,u=c[f+4>>2],c[u+8>>2]=c[f+8>>2],c[c[f+8>>2]+4>>2]=u,u=r+y|0),r=o+y|0,o=c[r>>2],(o|0)!=c[(r+o|0)-4>>2]&&(y=c[r+4>>2],c[y+8>>2]=c[r+8>>2],c[c[r+8>>2]+4>>2]=y,u=o+u|0),c[f>>2]=u,c[((u&-4)+f|0)-4>>2]=u|1,o=c[f>>2]-8|0;e:{if(o>>>0<=127){r=(o>>>3|0)-1|0;break e}if(u=yr(o),r=((o>>>29-u^4)-(u<<2)|0)+110|0,o>>>0<=4095)break e;r=((o>>>30-u^2)-(u<<1)|0)+71|0,r=r>>>0>=63?63:r}o=r<<4,c[f+4>>2]=o+5968,o=o+5976|0,c[f+8>>2]=c[o>>2],c[o>>2]=f,c[c[f+8>>2]+4>>2]=f,o=c[1750],u=c[1751],f=r&31,(r&63)>>>0>=32?(r=1<<f,y=0):(y=1<<f,r=y-1&1>>>32-f),c[1750]=y|o,c[1751]=r|u}}function mT(r,o,u){r=r|0,o=o|0,u=u|0;var f=0,y=0,E=0,T=0,k=0,D=0,j=0;f=be-32|0,be=f,y=c[r+28>>2],c[f+16>>2]=y,E=c[r+20>>2],c[f+28>>2]=u,c[f+24>>2]=o,o=E-y|0,c[f+20>>2]=o,E=o+u|0,D=2,o=f+16|0;e:{for(;;){r:{i:{t:{if(!Km(rT(c[r+60>>2],o|0,D|0,f+12|0)|0)){if(T=c[f+12>>2],(T|0)==(E|0))break t;if((T|0)>=0)break i;break r}if((E|0)!=-1)break r}o=c[r+44>>2],c[r+28>>2]=o,c[r+20>>2]=o,c[r+16>>2]=o+c[r+48>>2],r=u;break e}k=c[o+4>>2],j=k>>>0<T>>>0,y=(j<<3)+o|0,k=T-(j?k:0)|0,c[y>>2]=k+c[y>>2],o=(j?12:4)+o|0,c[o>>2]=c[o>>2]-k,E=E-T|0,D=D-j|0,o=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,(D|0)==2)break e;r=u-c[o+4>>2]|0}return be=f+32|0,r|0}function gT(r){r=r|0;var o=0,u=0,f=0,y=0,E=0;u=be-96|0,be=u,c[u>>2]=r,f=be-16|0,be=f,c[f+12>>2]=u,r=be-144|0,be=r,r=Hi(r,5520,144),E=u+16|0,o=E,c[r+44>>2]=o,c[r+20>>2]=o,y=-2-o|0,y=y>>>0>=2147483647?2147483647:y,c[r+48>>2]=y,o=o+y|0,c[r+28>>2]=o,c[r+16>>2]=o,Em(r,2202,u,0,0),y&&(o=c[r+20>>2],ge[o-((o|0)==c[r+16>>2])|0]=0),be=r+144|0,be=f+16|0,r=E;e:{if(r&3)for(;;){if(!xe[r|0])break e;if(r=r+1|0,!(r&3))break}for(;o=r,r=r+4|0,f=c[o>>2],!((f^-1)&f-16843009&-2139062144););for(;r=o,o=r+1|0,!!xe[r|0];);}return r=(r-E|0)+1|0,o=zu(r),o?r=Hi(o,E,r):r=0,be=u+96|0,r|0}function Em(r,o,u,f,y){var E=0,T=0,k=0,D=0;E=be-208|0,be=E,c[E+204>>2]=u,u=E+160|0,Wi(u,0,40),c[E+200>>2]=c[E+204>>2];e:{if((cm(0,o,E+200|0,E+80|0,u,f,y)|0)<0){y=-1;break e}D=c[r+76>>2]>=0,T=c[r>>2],c[r+72>>2]<=0&&(c[r>>2]=T&-33);r:{i:{t:{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,k=c[r+44>>2],c[r+44>>2]=E;break t}if(c[r+16>>2])break i}if(u=-1,Om(r))break r}u=cm(r,o,E+200|0,E+80|0,E+160|0,f,y)}if(k&&($e[c[r+36>>2]](r,0,0)|0,c[r+48>>2]=0,c[r+44>>2]=k,c[r+28>>2]=0,o=c[r+20>>2],c[r+16>>2]=0,c[r+20>>2]=0,u=o?u:-1),o=r,r=c[r>>2],c[o>>2]=r|T&32,y=r&32?-1:u,!D)break e}return be=E+208|0,y}function vl(r){var o=0,u=v(0),f=0,y=0,E=0,T=0,k=0,D=v(0),j=0;E=be-16|0,be=E,o=c[r+12>>2];e:{if(o){D=C[r+520>>2],u=C[r+516>>2];r:{if(xe[r+4|0]&32){u=v($e[o|0](r,u,D,0));break r}u=v($e[o|0](r,u,D))}if(u==u)break e;c[E>>2]=3409,or(r,E),er(),St()}r:{i:{if(T=c[r+556>>2],o=c[r+560>>2],(T|0)!=(o|0)){for(o=o-T>>2,j=o>>>0<=1?1:o;;){if(y=c[(k<<2)+T>>2],!c[y+548>>2]){if(o=c[y+24>>2],(o&196608)!=131072){if(o=o>>>13&7,o||(o=c[r+24>>2]>>>10&7),xe[y+4|0]&2|(xe[r+24|0]&8?(o|0)==5:0))break i;f=f||y}if(k=k+1|0,(j|0)!=(k|0))continue}break}if(f)break r}u=C[r+520>>2];break e}f=y}u=v(vl(f)+C[f+232>>2])}return be=E+16|0,u}function Vn(r,o,u,f,y,E){var T=0,k=v(0),D=0,j=v(0);T=(c[(o<<2)+4320>>2]<<2)+r|0,k=C[T+216>>2];e:{r:{T=c[T+216>>2];i:{if((T|0)==2139156720)break i;if((T|0)==2140081935)break r;D=4336;t:{if((T|0)!=2141891242){if(k==k)break t;D=4344}switch(j=C[D>>2],k=v(Xe),c[D+4>>2]-1|0){case 0:break r;case 1:break i;default:break e}}if(j=(Le(2,(T&-1073741825)+536870912|0),He()),!(T&1073741824))break r}k=v(v(j*u)*v(.009999999776482582));break e}k=j}f=v(k+v(dt(r,o,f)+kt(r,o,f)));e:{r:{i:switch(c[y>>2]){case 1:case 2:u=C[E>>2],f=f!=f||u<f?u:f;break r;case 0:break i;default:break e}if(f!=f)break e;c[y>>2]=2}C[E>>2]=f}}function Dt(r,o,u){var f=v(0),y=v(0),E=0,T=v(0);r=r+116|0,E=c[(o<<2)+4288>>2];e:{if((o&-2)==2){o=Gr(r,4,E,2140081935);break e}o=Vr(r,E,2140081935)}e:{r:{i:{t:{if((o|0)==2139156720)break t;if((o|0)==2140081935)break e;r=4336;s:{if((o|0)!=2141891242){if(f=(Le(2,o),He()),f==f)break s;r=4344}switch(f=C[r>>2],y=v(Xe),c[r+4>>2]-1|0){case 0:break i;case 1:break t;default:break r}}if(f=(Le(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break i}f=v(v(f*u)*v(.009999999776482582))}if(f>=v(0))return f;if(y=f,f<v(0))break e}T=y==y?y:v(0)}return T}function Ot(r,o,u){var f=v(0),y=v(0),E=0,T=v(0);r=r+116|0,E=c[(o<<2)+4304>>2];e:{if((o&-2)==2){o=Gr(r,5,E,2140081935);break e}o=Vr(r,E,2140081935)}e:{r:{i:{t:{if((o|0)==2139156720)break t;if((o|0)==2140081935)break e;r=4336;s:{if((o|0)!=2141891242){if(f=(Le(2,o),He()),f==f)break s;r=4344}switch(f=C[r>>2],y=v(Xe),c[r+4>>2]-1|0){case 0:break i;case 1:break t;default:break r}}if(f=(Le(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break i}f=v(v(f*u)*v(.009999999776482582))}if(f>=v(0))return f;if(y=f,f<v(0))break e}T=y==y?y:v(0)}return T}function xm(r,o,u,f,y,E){var T=0;e:{r:{if(r){i:{if(o&4){E=$e[r|0](u,f,y,E)|0;break i}E=$e[r|0](u,f,y)|0}if(E)break r}if(E=he(588),o=Hi(E,u,552),c[o+564>>2]=0,c[o+556>>2]=0,c[o+560>>2]=0,y=c[u+556>>2],f=c[u+560>>2],(y|0)!=(f|0)){if(T=f-y|0,(T|0)<0)break e;for(r=he(T),c[o+556>>2]=r,c[o+564>>2]=r+T;c[r>>2]=c[y>>2],r=r+4|0,y=y+4|0,(f|0)!=(y|0););c[o+560>>2]=r}r=c[u+572>>2],c[o+568>>2]=c[u+568>>2],c[o+572>>2]=r,c[o+584>>2]=c[u+584>>2],r=c[u+580>>2],c[o+576>>2]=c[u+576>>2],c[o+580>>2]=r,c[o+552>>2]=0}return E}Ps(),St()}function or(r,o){var u=0,f=0,y=0;y=be-16|0,be=y,c[y+12>>2]=o;e:{r:{if(!r){o=c[y+12>>2];break r}if(o=c[y+12>>2],u=c[r+568>>2],!u)break r;if(f=c[u+4>>2],xe[u+8|0]&8){$e[f|0](u,r,5,0,4284,o)|0;break e}$e[f|0](u,r,5,4284,o)|0;break e}r:{if(!xe[7016]){u=he(28),c[u+20>>2]=1065353216,c[u+24>>2]=0,c[u+12>>2]=0,c[u+16>>2]=0,c[u>>2]=0,ge[u+8|0]=0,f=1,c[u+4>>2]=1,c[1753]=u,ge[7016]=1,c[1752]=c[1752]+1;break r}if(u=c[1753],f=c[u+4>>2],!(xe[u+8|0]&8))break r;$e[f|0](u,r,5,0,4284,o)|0;break e}$e[f|0](u,r,5,4284,o)|0}be=y+16|0}function jo(r,o,u){var f=v(0),y=0,E=v(0);r=r+80|0,y=c[(o<<2)+4304>>2];e:{r:{if((o&-2)==2){o=Gr(r,5,y,2140081935);break r}o=Vr(r,y,2140081935)}r:{i:{if((o|0)==2139156720)break i;if((o|0)==2140081935)break e;r=4336;t:{if((o|0)!=2141891242){if(f=(Le(2,o),He()),f==f)break t;r=4344}switch(f=C[r>>2],E=v(Xe),c[r+4>>2]-1|0){case 0:break e;case 1:break i;default:break r}}if(f=(Le(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break e}E=v(v(f*u)*v(.009999999776482582))}return E}return f}function Ms(r,o,u){var f=v(0),y=0,E=v(0);r=r+80|0,y=c[(o<<2)+4288>>2];e:{r:{if((o&-2)==2){o=Gr(r,4,y,2140081935);break r}o=Vr(r,y,2140081935)}r:{i:{if((o|0)==2139156720)break i;if((o|0)==2140081935)break e;r=4336;t:{if((o|0)!=2141891242){if(f=(Le(2,o),He()),f==f)break t;r=4344}switch(f=C[r>>2],E=v(Xe),c[r+4>>2]-1|0){case 0:break e;case 1:break i;default:break r}}if(f=(Le(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break e}E=v(v(f*u)*v(.009999999776482582))}return E}return f}function Gr(r,o,u,f){var y=v(0);o=(o<<2)+r|0,y=C[o>>2],o=c[o>>2];e:{if((o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|y==y||(o=(u<<2)+r|0,y=C[o>>2],o=c[o>>2],(o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|y==y)||(o=c[r+24>>2],y=C[r+24>>2],(o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|y==y)||(y=C[r+32>>2],r=c[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(o=f,y!=y)))break e;o=r}return o}function vT(r,o){r=r|0,o=v(o);var u=0,f=0,y=0;if(u=be-16|0,be=u,r=c[r>>2],!(o>=v(0))){c[u>>2]=2263,f=be-16|0,be=f,c[f+12>>2]=u;e:{if(r)break e;if(xe[7016]){r=c[1753];break e}r=he(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,ge[r+8|0]=0,c[r+4>>2]=1,c[1753]=r,ge[7016]=1,c[1752]=c[1752]+1}y=c[r+4>>2];e:{if(xe[r+8|0]&8){$e[y|0](r,0,5,0,4284,u)|0;break e}$e[y|0](r,0,5,4284,u)|0}be=f+16|0,er(),St()}C[r+20>>2]=o==v(0)?v(0):o,be=u+16|0}function bm(r,o,u,f,y){var E=0,T=0,k=v(0),D=0;E=2,T=c[r+24>>2]>>>2&3;e:{r:{i:{if(!(!c[r+552>>2]|(o|0)!=2)){o=0,E=3;t:switch(T-2|0){case 0:break e;case 1:break t;default:break i}E=2;break e}if(o=0,T>>>0>1)break r}o=E}E=T}u=Vm(r,E,u),f=Vm(r,o,f),k=dt(r,E,y),T=r+228|0,D=E<<2,C[T+(c[D+4288>>2]<<2)>>2]=u+k,k=kt(r,E,y),C[T+(c[D+4304>>2]<<2)>>2]=u+k,u=dt(r,o,y),E=o<<2,C[T+(c[E+4288>>2]<<2)>>2]=f+u,u=kt(r,o,y),C[T+(c[E+4304>>2]<<2)>>2]=f+u}function yT(r,o,u,f,y,E){r=r|0,o=o|0,u=v(u),f=f|0,y=v(y),E=E|0;var T=0,k=0,D=0;T=be-48|0,be=T,D=c[o+8>>2];e:{if(ge[7052]&1){o=c[1762];break e}o=im(5,4480)|0,ge[7052]=1,c[1762]=o}c[T+40>>2]=E,C[T+32>>2]=y,c[T+24>>2]=f,C[T+16>>2]=u,k=+qb(o|0,D|0,2922,T+12|0,T+16|0);e:{if(k<4294967296&k>=0){o=~~k>>>0;break e}o=0}f=c[T+12>>2],E=c[o+4>>2],c[r>>2]=c[o>>2],c[r+4>>2]=E,E=c[o+12>>2],c[r+8>>2]=c[o+8>>2],c[r+12>>2]=E,Zb(f|0),be=T+48|0}function AT(r,o,u){r=r|0,o=o|0,u=u|0;var f=0,y=0,E=0,T=0;if(f=be-32|0,be=f,y=c[o>>2],y>>>0<2147483632){e:{r:{if(y>>>0>=11){E=(y|15)+1|0,T=he(E),c[f+16>>2]=E|-2147483648,c[f+8>>2]=T,c[f+12>>2]=y,E=y+T|0;break r}if(ge[f+19|0]=y,T=f+8|0,E=T+y|0,!y)break e}Hi(T,o+4|0,y)}return ge[E|0]=0,c[f>>2]=u,$e[r|0](f+24|0,f+8|0,f),Xb(c[f+24>>2]),r=c[f+24>>2],Wo(r|0),Wo(c[f>>2]),ge[f+19|0]<0&&vi(c[f+8>>2]),be=f+32|0,r|0}Ps(),St()}function hi(r,o,u){var f=0,y=0,E=0;if(!(xe[r|0]&32))e:{f=o,o=r,r=c[o+16>>2];r:{if(!r){if(Om(o))break r;r=c[o+16>>2]}if(E=c[o+20>>2],r-E>>>0<u>>>0){$e[c[o+36>>2]](o,f,u)|0;break e}i:{if(c[o+80>>2]<0)break i;for(r=u;;){if(y=r,!r)break i;if(r=y-1|0,xe[f+r|0]==10)break}if($e[c[o+36>>2]](o,f,y)>>>0<y>>>0)break r;f=f+y|0,u=u-y|0,E=c[o+20>>2]}Hi(E,f,u),c[o+20>>2]=c[o+20>>2]+u}}}function qu(r,o,u){var f=0,y=0,E=0;f=be-16|0,be=f,y=r+24|0,$e[o|0](f+8|0,y),E=c[f+12>>2];e:{if((c[c[f+8>>2]>>2]&7<<E)>>E==(u|0))break e;for($e[o|0](f+8|0,y),o=c[f+8>>2],y=o,E=c[o>>2],o=c[f+12>>2],c[y>>2]=E&(7<<o^-1)|(u&7)<<o;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}be=f+16|0}function Vr(r,o,u){var f=v(0);o=(o<<2)+r|0,f=C[o>>2],o=c[o>>2];e:{if((o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|f==f||(o=c[r+28>>2],f=C[r+28>>2],(o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|f==f)||(f=C[r+32>>2],r=c[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(o=u,f!=f)))break e;o=r}return o}function kt(r,o,u){var f=v(0),y=0;r=r+44|0,y=c[(o<<2)+4304>>2];e:{if((o&-2)==2){r=Gr(r,5,y,2140081935);break e}r=Vr(r,y,2140081935)}e:{if((r|0)!=2139156720){if((r|0)==2140081935|(r|0)==2141891242)break e;if(f=(Le(2,r),He()),f!=f)return v(Xe);if(f=(Le(2,(r&-1073741825)+536870912|0),He()),!(r&1073741824))break e}f=v(v(f*u)*v(.009999999776482582))}return f}function dt(r,o,u){var f=v(0),y=0;r=r+44|0,y=c[(o<<2)+4288>>2];e:{if((o&-2)==2){r=Gr(r,4,y,2140081935);break e}r=Vr(r,y,2140081935)}e:{if((r|0)!=2139156720){if((r|0)==2140081935|(r|0)==2141891242)break e;if(f=(Le(2,r),He()),f!=f)return v(Xe);if(f=(Le(2,(r&-1073741825)+536870912|0),He()),!(r&1073741824))break e}f=v(v(f*u)*v(.009999999776482582))}return f}function ET(r,o,u){r=r|0,o=o|0,u=u|0;var f=0,y=0,E=0,T=0,k=0;return y=c[r+84>>2],E=c[y>>2],f=c[y+4>>2],k=c[r+28>>2],T=c[r+20>>2]-k|0,T=f>>>0<T>>>0?f:T,T&&(Hi(E,k,T),E=T+c[y>>2]|0,c[y>>2]=E,f=c[y+4>>2]-T|0,c[y+4>>2]=f),f=u>>>0>f>>>0?f:u,f&&(Hi(E,o,f),E=f+c[y>>2]|0,c[y>>2]=E,c[y+4>>2]=c[y+4>>2]-f),ge[E|0]=0,o=c[r+44>>2],c[r+28>>2]=o,c[r+20>>2]=o,u|0}function wt(r,o){var u=v(0),f=0;r=r+152|0,f=c[(o<<2)+4304>>2];e:{if((o&-2)==2){r=Gr(r,5,f,2140081935);break e}r=Vr(r,f,2140081935)}u=v(0);e:{if((r|0)==2139156720||(u=v(0),(r|0)==2140081935))break e;r:{if((r|0)==2141891242||(u=(Le(2,r),He()),u!=u))break r;u=(Le(2,(r&-1073741825)+536870912|0),He());break e}u=v(Xe)}return ht(u,v(0))}function gt(r,o){var u=v(0),f=0;r=r+152|0,f=c[(o<<2)+4288>>2];e:{if((o&-2)==2){r=Gr(r,4,f,2140081935);break e}r=Vr(r,f,2140081935)}u=v(0);e:{if((r|0)==2139156720||(u=v(0),(r|0)==2140081935))break e;r:{if((r|0)==2141891242||(u=(Le(2,r),He()),u!=u))break r;u=(Le(2,(r&-1073741825)+536870912|0),He());break e}u=v(Xe)}return ht(u,v(0))}function xT(r,o,u){r=r|0,o=o|0,u=u|0;var f=0,y=0,E=v(0);f=2,o=c[o>>2]+(u<<2)|0,E=C[o+116>>2];e:{r:{if(o=c[o+116>>2],(o|0)!=2139156720){if(y=Xe,(o|0)==2141891242){f=3;break e}if((o|0)!=2140081935)break r;y=0,f=1;break e}break e}if(E!=E){f=0;break e}f=o&1073741824?2:1,y=(Le(2,(o&-1073741825)+536870912|0),+He())}Ht[r+8>>3]=y,c[r>>2]=f}function bT(r,o,u){r=r|0,o=o|0,u=u|0;var f=0,y=0,E=v(0);f=2,o=c[o>>2]+(u<<2)|0,E=C[o+80>>2];e:{r:{if(o=c[o+80>>2],(o|0)!=2139156720){if(y=Xe,(o|0)==2141891242){f=3;break e}if((o|0)!=2140081935)break r;y=0,f=1;break e}break e}if(E!=E){f=0;break e}f=o&1073741824?2:1,y=(Le(2,(o&-1073741825)+536870912|0),+He())}Ht[r+8>>3]=y,c[r>>2]=f}function TT(r,o,u){r=r|0,o=o|0,u=u|0;var f=0,y=0,E=v(0);f=2,o=c[o>>2]+(u<<2)|0,E=C[o+44>>2];e:{r:{if(o=c[o+44>>2],(o|0)!=2139156720){if(y=Xe,(o|0)==2141891242){f=3;break e}if((o|0)!=2140081935)break r;y=0,f=1;break e}break e}if(E!=E){f=0;break e}f=o&1073741824?2:1,y=(Le(2,(o&-1073741825)+536870912|0),+He())}Ht[r+8>>3]=y,c[r>>2]=f}function Hr(r,o,u,f){var y=0,E=0,T=0;r=r*o,y=Yu(r),y=y<0?y+1:y,T=y!=y;e:{if(!(T|!(zt(y)<1e-4))){r=r-y;break e}r:{if(y!=y){r=r-y;break r}if(r=r-y,!(zt(y+-1)<1e-4))break r;r=r+1;break e}if(u){r=r+1;break e}if(f)break e;E=0;r:{if(T||(E=1,y>.5))break r;E=zt(y+-.5)<1e-4?1:0}r=r+E}return r!=r|o!=o?v(Xe):v(r/o)}function Tm(r,o){var u=v(0);e:{if((o|0)!=2139156720){if((o|0)!=2140081935){if((o|0)!=2141891242)break e;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(u=(Le(2,o),He()),u!=u){c[r>>2]=2143289344,c[r+4>>2]=0;return}c[r+4>>2]=o&1073741824?2:1,c[r>>2]=(o&-1073741825)+536870912}function Sm(r){var o=0,u=0,f=0;u=c[r+24>>2];e:{if(!(u&8)||(o=1,(u&7168)==5120)||(o=0,f=c[r+560>>2],u=c[r+556>>2],(f|0)==(u|0)))break e;for(r=f-u>>2,f=r>>>0<=1?1:r,r=0;;){if(o=c[c[u+(r<<2)>>2]+24>>2],o=(o&196608)!=131072&(o&57344)==40960,o)break e;if(r=r+1|0,(f|0)==(r|0))break}}return o}function ST(r,o){r=r|0,o=o|0;var u=0,f=0,y=v(0);o=c[o>>2],y=C[o+220>>2];e:{r:{if(o=c[o+220>>2],(o|0)!=2139156720){if(f=Xe,u=3,(o|0)==2141891242)break e;if((o|0)!=2140081935)break r;f=0,u=1;break e}u=2;break e}if(u=0,y!=y)break e;f=(Le(2,(o&-1073741825)+536870912|0),+He()),u=o&1073741824?2:1}o=u,Ht[r+8>>3]=f,c[r>>2]=o}function kT(r,o){r=r|0,o=o|0;var u=0,f=0,y=v(0);o=c[o>>2],y=C[o+200>>2];e:{r:{if(o=c[o+200>>2],(o|0)!=2139156720){if(f=Xe,u=3,(o|0)==2141891242)break e;if((o|0)!=2140081935)break r;f=0,u=1;break e}u=2;break e}if(u=0,y!=y)break e;f=(Le(2,(o&-1073741825)+536870912|0),+He()),u=o&1073741824?2:1}o=u,Ht[r+8>>3]=f,c[r>>2]=o}function wT(r,o){r=r|0,o=o|0;var u=0,f=0,y=v(0);o=c[o>>2],y=C[o+204>>2];e:{r:{if(o=c[o+204>>2],(o|0)!=2139156720){if(f=Xe,u=3,(o|0)==2141891242)break e;if((o|0)!=2140081935)break r;f=0,u=1;break e}u=2;break e}if(u=0,y!=y)break e;f=(Le(2,(o&-1073741825)+536870912|0),+He()),u=o&1073741824?2:1}o=u,Ht[r+8>>3]=f,c[r>>2]=o}function _T(r,o){r=r|0,o=o|0;var u=0,f=0,y=v(0);o=c[o>>2],y=C[o+208>>2];e:{r:{if(o=c[o+208>>2],(o|0)!=2139156720){if(f=Xe,u=3,(o|0)==2141891242)break e;if((o|0)!=2140081935)break r;f=0,u=1;break e}u=2;break e}if(u=0,y!=y)break e;f=(Le(2,(o&-1073741825)+536870912|0),+He()),u=o&1073741824?2:1}o=u,Ht[r+8>>3]=f,c[r>>2]=o}function RT(r,o){r=r|0,o=o|0;var u=0,f=0,y=v(0);o=c[o>>2],y=C[o+212>>2];e:{r:{if(o=c[o+212>>2],(o|0)!=2139156720){if(f=Xe,u=3,(o|0)==2141891242)break e;if((o|0)!=2140081935)break r;f=0,u=1;break e}u=2;break e}if(u=0,y!=y)break e;f=(Le(2,(o&-1073741825)+536870912|0),+He()),u=o&1073741824?2:1}o=u,Ht[r+8>>3]=f,c[r>>2]=o}function LT(r,o){r=r|0,o=o|0;var u=0,f=0,y=v(0);o=c[o>>2],y=C[o+216>>2];e:{r:{if(o=c[o+216>>2],(o|0)!=2139156720){if(f=Xe,u=3,(o|0)==2141891242)break e;if((o|0)!=2140081935)break r;f=0,u=1;break e}u=2;break e}if(u=0,y!=y)break e;f=(Le(2,(o&-1073741825)+536870912|0),+He()),u=o&1073741824?2:1}o=u,Ht[r+8>>3]=f,c[r>>2]=o}function CT(r,o){r=r|0,o=o|0;var u=0;if(u=be-16|0,be=u,r=c[r>>2],(o|0)<6){be=u+16|0;e:{r:switch(o-4|0){case 0:if(o=r+260|0,(xe[r+300|0]&3)==2)break e;o=r+252|0;break e;case 1:if(o=r+252|0,(xe[r+300|0]&3)==2)break e;o=r+260|0;break e;default:break r}o=(r+(o<<2)|0)+252|0}return+C[o>>2]}c[u>>2]=1872,or(r,u),er(),St()}function IT(r,o){r=r|0,o=o|0;var u=0;if(u=be-16|0,be=u,r=c[r>>2],(o|0)<6){be=u+16|0;e:{r:switch(o-4|0){case 0:if(o=r+276|0,(xe[r+300|0]&3)==2)break e;o=r+268|0;break e;case 1:if(o=r+268|0,(xe[r+300|0]&3)==2)break e;o=r+276|0;break e;default:break r}o=(r+(o<<2)|0)+268|0}return+C[o>>2]}c[u>>2]=1872,or(r,u),er(),St()}function DT(r,o){r=r|0,o=o|0;var u=0;if(u=be-16|0,be=u,r=c[r>>2],(o|0)<6){be=u+16|0;e:{r:switch(o-4|0){case 0:if(o=r+292|0,(xe[r+300|0]&3)==2)break e;o=r+284|0;break e;case 1:if(o=r+284|0,(xe[r+300|0]&3)==2)break e;o=r+292|0;break e;default:break r}o=(r+(o<<2)|0)+284|0}return+C[o>>2]}c[u>>2]=1872,or(r,u),er(),St()}function OT(r,o){r=r|0,o=o|0;var u=0,f=v(0),y=v(0);f=v(Xe),o=c[o>>2],y=C[o+40>>2],o=c[o+40>>2],u=3;e:{if((o|0)==2141891242)break e;if((o|0)==2140081935){f=v(0),u=1;break e}if((o|0)==2139156720){f=v(0),u=2;break e}if(u=0,y!=y)break e;f=(Le(2,(o&-1073741825)+536870912|0),He()),u=o&1073741824?2:1}c[r>>2]=u,Ht[r+8>>3]=f}function Wr(r){var o=0,u=v(0);o=2143289344;e:{if(v(zt(r))==v(tm)|r!=r||(o=2139156720,r<v(10842021724855044e-35)&r>v(-10842021724855044e-35)|r==v(0)))break e;u=(Le(2,(mi(r),mt(2)&-2147483648|1602224127)),He()),o=(mi(r>v(0xffffff0000000000)||r<v(-0xffffff0000000000)?u:r),mt(2)-536870912|1073741824)}return o}function Ar(r){var o=0,u=v(0);o=2143289344;e:{if(v(zt(r))==v(tm)|r!=r||(o=2140081935,r<v(10842021724855044e-35)&r>v(-10842021724855044e-35)|r==v(0)))break e;u=(Le(2,(mi(r),mt(2)&-2147483648|1610612735)),He()),o=(mi(r>v(36893485948395848e3)||r<v(-36893485948395848e3)?u:r),mt(2)-536870912|0)}return o}function PT(r,o){r=r|0,o=o|0;var u=v(0),f=v(0);r=c[r>>2]+(o<<2)|0,f=C[r+188>>2];e:{r:{if(r=c[r+188>>2],(r|0)==2139156720|(r|0)==2140081935)break r;if(u=v(Xe),(r|0)==2141891242|f!=f)break e;if((r|0)==2139156720)break r;return v((Le(2,(r&-1073741825)+536870912|0),He()))}u=v(0)}return v(u)}function $T(r,o,u,f,y,E){r=r|0,o=o|0,u=v(u),f=f|0,y=v(y),E=E|0;var T=0,k=0;return T=be-16|0,be=T,k=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(k=c[k+c[o>>2]>>2]),$e[k|0](T,o,u,f,y,E),r=he(16),o=c[T+12>>2],c[r+8>>2]=c[T+8>>2],c[r+12>>2]=o,o=c[T+4>>2],c[r>>2]=c[T>>2],c[r+4>>2]=o,be=T+16|0,r|0}function km(r,o){e:{if(o){o=jm(c[o>>2]);break e}r:{if(xe[7016]){o=c[1753];break r}o=he(28),c[o+20>>2]=1065353216,c[o+24>>2]=0,c[o+12>>2]=0,c[o+16>>2]=0,c[o>>2]=0,ge[o+8|0]=0,c[o+4>>2]=1,c[1753]=o,ge[7016]=1,c[1752]=c[1752]+1}o=jm(o)}return c[r+4>>2]=0,c[r+8>>2]=0,c[r>>2]=o,c[o>>2]=r,r}function MT(r,o,u){r=r|0,o=o|0,u=+u;var f=0,y=0;e:{if(r=c[r>>2],o=r+(o<<2)|0,y=c[o+152>>2],f=Ar(v(u)),(y|0)==(f|0))break e;for(c[o+152>>2]=f;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function FT(r,o,u){r=r|0,o=o|0,u=+u;var f=0,y=0;e:{if(r=c[r>>2],o=r+(o<<2)|0,y=c[o+188>>2],f=Ar(v(u)),(y|0)==(f|0))break e;for(c[o+188>>2]=f;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function NT(r,o){r=r|0,o=o|0;var u=0,f=v(0);r=c[r>>2]+(o<<2)|0,f=C[r+152>>2];e:{r:{if(r=c[r+152>>2],(r|0)==2139156720|(r|0)==2140081935)break r;if(u=Xe,(r|0)==2141891242|f!=f)break e;if((r|0)==2139156720)break r;return Le(2,(r&-1073741825)+536870912|0),+He()}u=0}return+u}function UT(r,o){r=r|0,o=o|0;var u=0;e:{if(r=c[r>>2],u=c[r+24>>2],(u>>>20&3)==(o|0))break e;for(c[r+24>>2]=u&-3145729|o<<20&3145728;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Hn(r,o,u){var f=0,y=0,E=0;e:{if(!o){f=r;break e}for(;f=pm(r,o,10),y=Vi,r=eh(f,y,246,0)+r|0,u=u-1|0,ge[u|0]=r|48,E=o>>>0>9,r=f,o=y,!!E;);}if(f)for(;u=u-1|0,r=(f>>>0)/10|0,ge[u|0]=Wt(r,246)+f|48,o=f>>>0>9,f=r,!!o;);return u}function BT(r,o){r=r|0,o=o|0;var u=0;e:{if(r=c[r>>2],u=c[r+24>>2],(u>>>22&1)==(o|0))break e;for(c[r+24>>2]=u&-4194305|o<<22&4194304;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function GT(r,o){r=r|0,o=o|0;var u=0;e:{if(r=c[r>>2],u=c[r+24>>2],(u>>>18&3)==(o|0))break e;for(c[r+24>>2]=u&-786433|o<<18&786432;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function VT(r,o){r=r|0,o=o|0;var u=0;e:{if(r=c[r>>2],u=c[r+24>>2],(u>>>16&3)==(o|0))break e;for(c[r+24>>2]=u&-196609|o<<16&196608;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function HT(r,o){r=r|0,o=+o;var u=0,f=v(0),y=v(0);e:{if(f=v(o),r=c[r>>2],y=C[r+224>>2],f==y|f!=f&y!=y)break e;for(C[r+224>>2]=f;;){if(u=xe[r+4|0],u&4)break e;if(ge[r+4|0]=u|4,u=c[r+20>>2],u&&$e[u|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function WT(r,o){r=r|0,o=+o;var u=0,f=v(0),y=v(0);e:{if(f=v(o),r=c[r>>2],y=C[r+28>>2],f==y|f!=f&y!=y)break e;for(C[r+28>>2]=f;;){if(u=xe[r+4|0],u&4)break e;if(ge[r+4|0]=u|4,u=c[r+20>>2],u&&$e[u|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function jT(r,o){r=r|0,o=+o;var u=0,f=v(0),y=v(0);e:{if(f=v(o),r=c[r>>2],y=C[r+32>>2],f==y|f!=f&y!=y)break e;for(C[r+32>>2]=f;;){if(u=xe[r+4|0],u&4)break e;if(ge[r+4|0]=u|4,u=c[r+20>>2],u&&$e[u|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function KT(r,o){r=r|0,o=+o;var u=0,f=v(0),y=v(0);e:{if(f=v(o),r=c[r>>2],y=C[r+36>>2],f==y|f!=f&y!=y)break e;for(C[r+36>>2]=f;;){if(u=xe[r+4|0],u&4)break e;if(ge[r+4|0]=u|4,u=c[r+20>>2],u&&$e[u|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function zT(r,o){r=r|0,o=o|0;var u=0;e:{if(r=c[r>>2],u=c[r+24>>2],(u>>>4&7)==(o|0))break e;for(c[r+24>>2]=u&-113|o<<4&112;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function YT(r,o){r=r|0,o=o|0;var u=0;e:{if(r=c[r>>2],u=c[r+24>>2],(u>>>2&3)==(o|0))break e;for(c[r+24>>2]=u&-13|o<<2&12;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function XT(r,o){r=r|0,o=o|0;var u=0;e:{if(r=c[r>>2],u=xe[r+4|0],((u&2)>>>1|0)==(o|0))break e;for(ge[r+4|0]=u&253|(o?2:0);;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function ZT(r,o,u){r=r|0,o=o|0,u=u|0;var f=0,y=0;return f=be-16|0,be=f,y=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(y=c[y+c[o>>2]>>2]),$e[y|0](f,o,u),r=he(16),o=c[f+12>>2],c[r+8>>2]=c[f+8>>2],c[r+12>>2]=o,o=c[f+4>>2],c[r>>2]=c[f>>2],c[r+4>>2]=o,be=f+16|0,r|0}function wm(r,o){var u=0,f=0;e:{r:{if(u=c[r+556>>2],f=c[r+560>>2],(u|0)==(f|0))break r;for(;;){if(c[u>>2]==(o|0))break r;if(u=u+4|0,(f|0)==(u|0))break}break e}if((u|0)==(f|0))break e;return o=u+4|0,$s(u,o,f-o|0),c[r+560>>2]=f-4,1}return 0}function qT(r){r=r|0;var o=0,u=0;if(u=be-16|0,be=u,r=c[r>>2],c[r+8>>2]){for(;o=xe[r+4|0],!!(!(o&4)&&(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],r)););be=u+16|0;return}c[u>>2]=1024,or(r,u),er(),St()}function _m(r,o){var u=0,f=0,y=0;if($i(+r),f=mt(1)|0,y=mt(0)|0,u=f>>>20&2047,(u|0)!=2047){if(!u)return r==0?u=0:(r=_m(r*18446744073709552e3,o),u=c[o>>2]+-64|0),c[o>>2]=u,r;c[o>>2]=u-1022,Le(0,y|0),Le(1,f&-2146435073|1071644672),r=+ki()}return r}function QT(r,o){r=r|0,o=o|0;var u=0,f=0;return u=be-16|0,be=u,f=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(f=c[f+c[o>>2]>>2]),$e[f|0](u,o),r=he(16),o=c[u+12>>2],c[r+8>>2]=c[u+8>>2],c[r+12>>2]=o,o=c[u+4>>2],c[r>>2]=c[u>>2],c[r+4>>2]=o,be=u+16|0,r|0}function yl(r,o,u){var f=0;e:{if(f=r+24|0,c[(f+(o<<2)|0)+184>>2]==(u|0))break e;for(c[((o<<2)+f|0)+184>>2]=u;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Al(r,o,u){var f=0;e:{if(f=r+24|0,c[(f+(o<<2)|0)+192>>2]==(u|0))break e;for(c[((o<<2)+f|0)+192>>2]=u;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Wn(r,o,u){var f=0;e:{if(f=r+24|0,c[(f+(o<<2)|0)+176>>2]==(u|0))break e;for(c[((o<<2)+f|0)+176>>2]=u;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Qu(r,o){var u=0,f=0,y=0;e:{if(u=r+24|0,c[u+16>>2]==(o|0))break e;for(f=$e[9](u)|0,y=o,c[f+16>>2]=y;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Rm(r,o,u){var f=0;e:{if(f=r+24|0,c[(f+(o<<2)|0)+92>>2]==(u|0))break e;for(c[((o<<2)+f|0)+92>>2]=u;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Ju(r,o,u){var f=0;e:{if(f=r+24|0,c[(f+(o<<2)|0)+20>>2]==(u|0))break e;for(c[((o<<2)+f|0)+20>>2]=u;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function Lm(r,o,u){var f=0;e:{if(f=r+24|0,c[(f+(o<<2)|0)+56>>2]==(u|0))break e;for(c[((o<<2)+f|0)+56>>2]=u;;){if(o=xe[r+4|0],o&4)break e;if(ge[r+4|0]=o|4,o=c[r+20>>2],o&&$e[o|0](r),c[r+308>>2]=2143289344,r=c[r+552>>2],!r)break}}}function JT(){for(var r=0,o=0,u=0;o=r<<4,u=o+5968|0,c[o+5972>>2]=u,c[o+5976>>2]=u,r=r+1|0,(r|0)!=64;);Xu(48),c[1756]=16,c[1757]=0,lm(),c[1757]=c[1768],c[1768]=7024,c[1769]=198,c[1770]=0,vm(),c[1770]=c[1768],c[1768]=7076}function ar(r,o){var u=0,f=v(0);r=r+80|0,u=c[(o<<2)+4288>>2];e:{if((o&-2)==2){r=Gr(r,4,u,2143289344);break e}r=Vr(r,u,2143289344)}return(r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242?r=1:(f=(Le(2,r),He()),r=f==f),r}function El(r,o){var u=0,f=v(0);r=r+80|0,u=c[(o<<2)+4304>>2];e:{if((o&-2)==2){r=Gr(r,5,u,2143289344);break e}r=Vr(r,u,2143289344)}return(r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242?r=1:(f=(Le(2,r),He()),r=f==f),r}function eh(r,o,u,f){var y=0,E=0,T=0,k=0,D=0,j=0;return y=u>>>16|0,E=r>>>16|0,j=Wt(y,E),T=u&65535,k=r&65535,D=Wt(T,k),E=(D>>>16|0)+Wt(E,T)|0,y=(E&65535)+Wt(y,k)|0,Vi=(Wt(o,u)+j|0)+Wt(r,f)+(E>>>16)+(y>>>16)|0,D&65535|y<<16}function Cm(r,o){var u=0,f=0,y=0;f=be-16|0,be=f,u=xe[r+4|0],y=u&-17,ge[r+4|0]=y;e:{if(o){if(c[r+560>>2]!=c[r+556>>2])break e;u=y|8}else u=u&231;c[r+8>>2]=o,ge[r+4|0]=u,be=f+16|0;return}c[f>>2]=4128,or(r,f),er(),St()}function Im(r){var o=0,u=v(0);o=0;e:{if((c[r+24>>2]&196608)==131072)break e;r:{if(!c[r+552>>2]||(u=C[r+32>>2],u!=u&&(u=C[r+28>>2],!(u>v(0)))))break r;if(o=1,u!=v(0))break e}o=jn(r)!=v(0)}return o}function yi(r,o,u,f,y){var E=0;if(E=be-256|0,be=E,!(y&73728|(u|0)<=(f|0))){if(f=u-f|0,u=f>>>0<256,Wi(E,o&255,u?f:256),!u)for(;hi(r,E,256),f=f-256|0,f>>>0>255;);hi(r,E,f)}be=E+256|0}function mn(r,o,u){var f=0,y=v(0);e:{if((u&-2)==2&&(f=o- -64|0,y=C[f>>2],f=c[f>>2],(f|0)==2139156720|(f|0)==2140081935|(f|0)==2141891242|y==y))break e;f=c[((c[(u<<2)+4304>>2]<<2)+o|0)+44>>2]}Tm(r,f)}function gn(r,o,u){var f=0,y=v(0);e:{if((u&-2)==2&&(f=c[o+60>>2],y=C[o+60>>2],(f|0)==2139156720|(f|0)==2140081935|(f|0)==2141891242|y==y))break e;f=c[((c[(u<<2)+4288>>2]<<2)+o|0)+44>>2]}Tm(r,f)}function jn(r){var o=v(0),u=v(0);if(!c[r+552>>2])return v(0);o=C[r+36>>2];e:{if(o==o||(o=v(1),ge[c[r+568>>2]+8|0]&1)||(o=v(0),u=C[r+28>>2],!(u<v(0))))break e;o=v(-u)}return o}function Dm(r){var o=0,u=0,f=0;for(f=c[r>>2];;){if(u=ge[f|0],bl(u)){f=f+1|0,c[r>>2]=f,o>>>0<=214748364?(u=u-48|0,o=Wt(o,10),o=(u|0)>(o^2147483647)?-1:u+o|0):o=-1;continue}break}return o}function Ko(r,o,u,f){var y=0;c[r+12>>2]=0,c[r+16>>2]=f;e:{if(o){if(o>>>0>=1073741824)break e;y=he(o<<2)}return c[r>>2]=y,u=(u<<2)+y|0,c[r+8>>2]=u,c[r+12>>2]=(o<<2)+y,c[r+4>>2]=u,r}oh(),St()}function Om(r){var o=0;return o=c[r+72>>2],c[r+72>>2]=o-1|o,o=c[r>>2],o&8?(c[r>>2]=o|32,-1):(c[r+4>>2]=0,c[r+8>>2]=0,o=c[r+44>>2],c[r+28>>2]=o,c[r+20>>2]=o,c[r+16>>2]=o+c[r+48>>2],0)}function eS(r,o,u,f,y,E){r=r|0,o=o|0,u=v(u),f=f|0,y=v(y),E=E|0;var T=0;T=be-16|0,be=T,o=c[c[o>>2]+4>>2],$e[c[c[o>>2]+8>>2]](T,o,u,f,y,E),C[r>>2]=Ht[T>>3],C[r+4>>2]=Ht[T+8>>3],be=T+16|0}function tS(){var r=0,o=0;return o=he(4),r=he(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,ge[r+8|0]=0,c[r+4>>2]=1,c[1752]=c[1752]+1,c[o>>2]=r,o|0}function iS(r,o){r=r|0,o=o|0,o=c[o>>2],Ht[r>>3]=C[o+228>>2],Ht[r+8>>3]=C[o+236>>2],Ht[r+16>>3]=C[o+232>>2],Ht[r+24>>3]=C[o+240>>2],Ht[r+32>>3]=C[o+244>>2],Ht[r+40>>3]=C[o+248>>2]}function rS(r,o){r=r|0,o=o|0;var u=0,f=0;return u=be-48|0,be=u,f=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(f=c[f+c[o>>2]>>2]),$e[f|0](u,o),r=Hi(he(48),u,48),be=u+48|0,r|0}function sS(r,o,u,f){r=r|0,o=o|0,u=u|0,f=f|0;var y=0;return y=be-16|0,be=y,r=Km(Jb(c[r+60>>2],o|0,u|0,f&255,y+8|0)|0),be=y+16|0,Vi=r?-1:c[y+12>>2],(r?-1:c[y+8>>2])|0}function nS(r,o){r=r|0,o=o|0;var u=0,f=0;u=c[r>>2],r=c[u+556>>2];e:{if(c[u+560>>2]-r>>2>>>0<=o>>>0||(r=c[r+(o<<2)>>2],!r))break e;f=c[r>>2]}return f|0}function oS(r,o,u){if(r=r|0,o=o|0,u=u|0,o>>>0<3){o=1<<o,r=c[r>>2],u?o=o|c[r+12>>2]:o=c[r+12>>2]&(o^-1),c[r+12>>2]=o;return}Ps(),St()}function aS(r,o,u,f,y){r=r|0,o=o|0,u=+u,f=+f,y=y|0;var E=0;E=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(E=c[E+c[o>>2]>>2]),$e[E|0](o,u,f,y)}function lS(r,o,u){r=r|0,o=o|0,u=u|0;var f=0;return f=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(f=c[f+c[o>>2]>>2]),v(v($e[f|0](o,u)))}function Pm(r,o,u,f){r=r|0,o=o|0,u=u|0,f=f|0;var y=0;y=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(y=c[y+c[o>>2]>>2]),$e[y|0](o,u,f)}function $m(r,o,u){r=r|0,o=o|0,u=u|0;var f=0;return f=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(f=c[f+c[o>>2]>>2]),$e[f|0](o,u)|0}function cS(r,o,u,f){r=r|0,o=o|0,u=u|0,f=+f;var y=0;y=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(y=c[y+c[o>>2]>>2]),$e[y|0](o,u,f)}function uS(r,o,u){r=r|0,o=o|0,u=u|0;var f=0;return f=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(f=c[f+c[o>>2]>>2]),+$e[f|0](o,u)}function he(r){var o=0;r=r||1;e:{for(;;){if(o=zu(r),o)break e;if(o=c[2042],o){$e[o|0]();continue}break}Ps(),St()}return o}function hS(r,o,u){r=r|0,o=o|0,u=v(u);var f=0;f=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(f=c[f+c[o>>2]>>2]),$e[f|0](o,u)}function Fs(r,o,u){r=r|0,o=o|0,u=u|0;var f=0;f=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(f=c[f+c[o>>2]>>2]),$e[f|0](o,u)}function vn(r,o){r=r|0,o=o|0;var u=0;return u=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(u=c[u+c[o>>2]>>2]),$e[u|0](o)|0}function th(r,o){return mi(r),(mt(2)&2147483647)>>>0<=2139095040?(mi(o),(mt(2)&2147483647)>>>0>2139095040?r:v(zb(r,o))):o}function ht(r,o){return mi(r),(mt(2)&2147483647)>>>0<=2139095040?(mi(o),(mt(2)&2147483647)>>>0>2139095040?r:v(Yb(r,o))):o}function Mm(r,o){r=r|0,o=o|0;var u=0;return u=be-16|0,be=u,c[u+8>>2]=o,r=$e[r|0](u+8|0)|0,Wo(c[u+8>>2]),be=u+16|0,r|0}function fS(r,o,u){r=r|0,o=o|0,u=+u;var f=0;f=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(f=c[f+c[o>>2]>>2]),$e[f|0](o,u)}function dS(r,o,u,f,y){return u=u|0,f=f|0,y=y|0,u&&(u|0)!=5?Zm(5816,f,y)|0:Zm(5672,f,y)|0}function Fm(r,o){if(!r)return 0;e:{if(!((o&-128)==57216|o>>>0<=127)){c[1781]=25,r=-1;break e}ge[r|0]=o,r=1}return r}function pS(r,o){r=r|0,o=o|0;var u=0;return u=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(u=c[u+c[o>>2]>>2]),+$e[u|0](o)}function Nm(r,o){var u=0,f=0;u=he(4),c[u>>2]=o,f=he(4),c[f>>2]=o,ml(7035,r|0,7098,4714,196,u|0,7098,4718,197,f|0)}function Kn(r,o){var u=0,f=0;u=he(4),c[u>>2]=o,f=he(4),c[f>>2]=o,ml(7065,r|0,7098,4714,194,u|0,7098,4718,195,f|0)}function ih(r,o){var u=0;e:{if(ge[7044]&1){u=c[1760];break e}u=im(1,4464)|0,ge[7044]=1,c[1760]=u}Qb(u|0,r|0,o|0,0)}function mS(r,o){r=r|0,o=o|0;var u=0;u=c[r+8>>2],c[r+8>>2]=o,u&&$e[c[c[u>>2]+4>>2]](u),c[c[r>>2]+20>>2]=15}function gS(r,o,u){r=r|0,o=o|0,u=u|0;var f=0,y=0;f=r,y=om((ge[o+11|0]<0?c[o>>2]:o)|0,7036,c[u>>2])|0,c[f>>2]=y}function vS(r,o,u){r=r|0,o=o|0,u=u|0;var f=0,y=0;f=r,y=om((ge[o+11|0]<0?c[o>>2]:o)|0,7059,c[u>>2])|0,c[f>>2]=y}function Um(r,o){r=r|0,o=o|0;var u=0;u=c[r>>2],r=c[r+4>>2],o=(r>>1)+o|0,r&1&&(u=c[u+c[o>>2]>>2]),$e[u|0](o)}function yS(r){r=r|0;var o=v(0);return r=c[r>>2],o=C[r+36>>2],o!=o&&(o=ge[c[r+568>>2]+8|0]&1?v(1):v(0)),+o}function AS(r,o){r=r|0,o=o|0;var u=0;u=c[r+4>>2],c[r+4>>2]=o,u&&$e[c[c[u>>2]+4>>2]](u),Cm(c[r>>2],14)}function ES(r){r=r|0;var o=0;o=c[r+8>>2],c[r+8>>2]=0,o&&$e[c[c[o>>2]+4>>2]](o),c[c[r>>2]+20>>2]=0}function xS(r){r=r|0;var o=0;return o=he(12),ge[o+4|0]=0,c[o+8>>2]=c[r>>2],c[r>>2]=0,c[o>>2]=4432,o|0}function bS(r){r=r|0;var o=0;return o=he(12),ge[o+4|0]=0,c[o+8>>2]=c[r>>2],c[r>>2]=0,c[o>>2]=4552,o|0}function TS(){var r=0;if(r=c[1768],r)for(;$e[c[r>>2]](),r=c[r+4>>2],!!r;);}function SS(r){r=r|0;var o=0;o=c[r+4>>2],c[r+4>>2]=0,o&&$e[c[c[o>>2]+4>>2]](o),Cm(c[r>>2],0)}function Bm(r){return r=r|0,c[r>>2]=4572,xe[r+4|0]&&ih(c[r+8>>2],1759),Wo(c[r+8>>2]),r|0}function Gm(r){return r=r|0,c[r>>2]=4452,xe[r+4|0]&&ih(c[r+8>>2],1759),Wo(c[r+8>>2]),r|0}function kS(){var r=0;return r=he(16),c[r>>2]=0,c[r+4>>2]=0,c[r+8>>2]=0,c[r+12>>2]=0,r|0}function Vm(r,o,u){return ar(r,o)?Ms(r,o,u):(u=jo(r,o,u),u==u&&(u=v(-u)),u)}function Hm(r,o){var u=0;u=be-16|0,be=u,r||(c[u>>2]=o,or(0,u),er(),St()),be=u+16|0}function Wm(r){r=r|0;var o=0;r&&(o=c[r>>2],o&&vi(o),c[1752]=c[1752]-1,vi(r))}function wS(r,o){return r=r|0,o=o|0,o>>>0>=3&&(Ps(),St()),c[c[r>>2]+12>>2]>>>o&1}function _S(r,o,u,f,y){return r=r|0,o=o|0,u=u|0,f=f|0,y=y|0,$e[r|0](o,u,f,y)|0}function RS(){var r=0;return r=he(16),c[r+8>>2]=0,c[r+12>>2]=0,c[r>>2]=0,r|0}function LS(r){r=r|0;var o=v(0);return o=C[c[r>>2]+224>>2],+(o!=o?v(Xe):o)}function CS(r){return r=r|0,r=c[c[r>>2]+552>>2],r?c[r>>2]:0}function IS(r){r=r|0;var o=v(0);return o=C[c[r>>2]+32>>2],+(o==o?o:v(0))}function jm(r){var o=0;return o=um(he(588),r),Hm((r|0)!=0,2808),o}function DS(r,o){r=r|0,o=o|0,r=c[r>>2],c[r+16>>2]=c[r+16>>2]&-2|o}function OS(r){return r=r|0,r=c[r>>2],c[r+560>>2]-c[r+556>>2]>>2}function PS(r,o){r=r|0,o=o|0,r=c[r>>2],ge[r+8|0]=xe[r+8|0]&254|o}function $S(r){r=r|0,r=c[c[r>>2]+8>>2],$e[c[c[r>>2]+8>>2]](r)}function MS(r,o,u){r=r|0,o=o|0,u=+u,Ju(c[r>>2],o,Ar(v(u)))}function FS(r,o,u){r=r|0,o=o|0,u=+u,Ju(c[r>>2],o,Wr(v(u)))}function NS(r,o,u,f){return Vi=0,0}function US(r,o,u){r=r|0,o=o|0,u=+u,Rm(c[r>>2],o,Ar(v(u)))}function BS(r,o,u){r=r|0,o=o|0,u=+u,Rm(c[r>>2],o,Wr(v(u)))}function GS(r,o,u){r=r|0,o=o|0,u=+u,Lm(c[r>>2],o,Ar(v(u)))}function VS(r,o,u){r=r|0,o=o|0,u=+u,Lm(c[r>>2],o,Wr(v(u)))}function HS(r,o,u){r=r|0,o=o|0,u=u|0,c[c[r>>2]+o>>2]=u}function WS(r,o){r=r|0,o=o|0,Ju(c[r>>2],o,2141891242)}function rh(r,o,u){r=r|0,o=o|0,u=+u,Ht[c[r>>2]+o>>3]=u}function jS(r){return r=r|0,(xe[c[r>>2]+4|0]&2)>>>1|0}function KS(r){return r=r|0,(xe[c[r>>2]+4|0]&4)>>>2|0}function zS(r,o){r=r|0,o=o|0,c[r+4>>2]=10,c[r>>2]=o}function YS(r,o){r=r|0,o=o|0,c[r+4>>2]=13,c[r>>2]=o}function XS(r){return r=r|0,c[c[r>>2]+24>>2]>>>10&7}function ZS(r){return r=r|0,c[c[r>>2]+24>>2]>>>13&7}function sh(r,o){return r=r|0,o=o|0,+Ht[c[r>>2]+o>>3]}function qS(r){return r=r|0,c[c[r>>2]+24>>2]>>>18&3}function QS(r){return r=r|0,c[c[r>>2]+24>>2]>>>20&3}function JS(r){return r=r|0,c[c[r>>2]+24>>2]>>>22&1}function ek(r,o){return r=r|0,o=o|0,c[c[r>>2]+o>>2]}function tk(r,o){r=r|0,o=+o,Wn(c[r>>2],0,Ar(v(o)))}function ik(r,o){r=r|0,o=+o,Wn(c[r>>2],0,Wr(v(o)))}function rk(r,o){r=r|0,o=+o,Wn(c[r>>2],1,Ar(v(o)))}function sk(r,o){r=r|0,o=+o,Wn(c[r>>2],1,Wr(v(o)))}function nk(r,o){r=r|0,o=o|0,c[r+4>>2]=7,c[r>>2]=o}function ok(r,o){r=r|0,o=+o,yl(c[r>>2],0,Ar(v(o)))}function ak(r,o){r=r|0,o=+o,yl(c[r>>2],0,Wr(v(o)))}function lk(r,o){r=r|0,o=+o,yl(c[r>>2],1,Ar(v(o)))}function ck(r,o){r=r|0,o=+o,yl(c[r>>2],1,Wr(v(o)))}function uk(r,o){r=r|0,o=+o,Al(c[r>>2],0,Ar(v(o)))}function hk(r,o){r=r|0,o=+o,Al(c[r>>2],1,Ar(v(o)))}function fk(r,o){r=r|0,o=+o,Al(c[r>>2],1,Wr(v(o)))}function dk(r){return r=r|0,c[c[r>>2]+24>>2]>>>7&7}function pk(r){return r=r|0,c[c[r>>2]+24>>2]>>>2&3}function mk(r){return r=r|0,c[c[r>>2]+24>>2]>>>4&7}function xl(r){r=r|0,r&&$e[c[c[r>>2]+4>>2]](r)}function gk(r,o){r=r|0,o=+o,Al(c[r>>2],0,Wr(v(o)))}function Km(r){return r?(c[1781]=r,-1):0}function vk(r,o){r=r|0,o=+o,Qu(c[r>>2],Ar(v(o)))}function yk(r,o){r=r|0,o=+o,Qu(c[r>>2],Wr(v(o)))}function zm(r,o,u){return v(dt(r,o,u)+kt(r,o,u))}function Ak(r,o){return r=r|0,o=o|0,$e[r|0](o)|0}function Ym(r,o,u,f){eT(r|0,o|0,8,0,u|0,-1,f|0)}function Ek(r,o){r=r|0,o=o|0,c[c[r>>2]+16>>2]=o}function xk(r){return r=r|0,c[c[r>>2]+16>>2]&1}function bk(r){return r=r|0,Bn[c[r>>2]+26>>1]&3}function Tk(r){r=r|0,Wn(c[r>>2],0,2141891242)}function Sk(r){r=r|0,Wn(c[r>>2],1,2141891242)}function kk(r){return r=r|0,+C[c[r>>2]+228>>2]}function wk(r){return r=r|0,+C[c[r>>2]+236>>2]}function _k(r){return r=r|0,+C[c[r>>2]+232>>2]}function Rk(r){return r=r|0,+C[c[r>>2]+240>>2]}function Lk(r){return r=r|0,+C[c[r>>2]+244>>2]}function Ck(r){return r=r|0,+C[c[r>>2]+248>>2]}function Ik(r){return r=r|0,sT(c[r+60>>2])|0}function Dk(r){return r=r|0,c[c[r>>2]+16>>2]}function Ok(r){return r=r|0,ge[c[r>>2]+8|0]&1}function Pk(r,o){r=r|0,o=o|0,qu(c[r>>2],5,o)}function $k(r,o){r=r|0,o=o|0,qu(c[r>>2],6,o)}function Mk(r,o){r=r|0,o=o|0,qu(c[r>>2],7,o)}function Fk(r){r=r|0,Qu(c[r>>2],2141891242)}function Xm(r,o){r=r|0,o=o|0,$e[c[r>>2]](o)}function Nk(r){return r=r|0,km(he(12),r)|0}function Uk(r){r=r|0,ih(c[r+8>>2],3293)}function Zm(r,o,u){return Em(r,o,u,2,3)}function qm(r){return r=r|0,$e[r|0]()|0}function Qm(r,o){r=r|0,o=o|0,$e[r|0](o)}function Bk(){return Wi(he(48),0,48)|0}function er(){$e[c[1490]](),oh(),St()}function Gk(){return km(he(12),0)|0}function nh(r){r=r|0,r&&vi(r)}function bl(r){return r-48>>>0<10}function Vk(r){return 7032}function Hk(r){return 7036}function Wk(r){return 7056}function jk(r){return 7059}function Kk(r){return 7062}function zk(r){return 7067}function wr(r){return r=r|0,r|0}function Jm(r){r=r|0,ge[r+4|0]=1}function Yk(r){r=r|0,vi(Bm(r))}function Xk(r){r=r|0,vi(Gm(r))}function Zk(r){return 0}function eg(r){St()}function tg(){oh(),St()}function oh(){Ps(),St()}Z=xe,Pe();var $e=X([null,dS,lT,hT,wr,nk,zS,YS,wr,wr,wr,wr,wr,wr,eS,$S,lm,Vk,xl,$T,Hk,wr,wr,xl,Jm,Xm,Mm,xS,AT,gS,Wk,xl,Um,jk,wr,wr,xl,Jm,Xm,Mm,bS,vS,Kk,Wm,qm,tS,Qm,Wm,oS,Pm,vT,hS,DS,Fs,Ek,Fs,PS,wS,$m,xk,vn,Dk,vn,Ok,Bk,nh,kS,nh,RS,nh,sh,rh,ek,HS,zk,gm,qm,Gk,Ak,Nk,Qm,gm,pT,Um,uT,Fs,VT,Fs,GS,cS,VS,Pk,$k,Mk,YT,GT,zT,MS,FS,WS,UT,BT,WT,fS,vk,yk,Fk,jT,KT,tk,ik,Tk,rk,sk,Sk,ok,ak,lk,ck,uk,gk,hk,fk,HT,MT,US,BS,FT,bk,vn,bT,ZT,dk,XS,ZS,pk,qS,mk,TT,OT,QT,IS,pS,yS,kT,wT,_T,RT,LT,ST,LS,NT,uS,QS,JS,xT,PT,lS,fT,Pm,dT,Fs,OS,vn,CS,vn,nS,$m,jS,vn,XT,Fs,AS,Fs,SS,mS,Fs,ES,qT,KS,vn,cT,aS,kk,wk,_k,Rk,Lk,Ck,iS,rS,CT,IT,DT,sh,rh,sh,rh,vm,Gm,Xk,yT,eg,tg,Bm,Yk,Uk,eg,Ik,mT,sS,Zk,NS,ET,tg]);function ig(){return Gi.byteLength/65536|0}function qk(r){r=r|0;var o=ig()|0,u=o+r|0;if(o<u&&u<65536){var f=new ArrayBuffer(Wt(u,65536)),y=new Int8Array(f);y.set(ge),ge=new Int8Array(f),Br=new Int16Array(f),c=new Int32Array(f),xe=new Uint8Array(f),Bn=new Uint16Array(f),em=new Uint32Array(f),C=new Float32Array(f),Ht=new Float64Array(f),Gi=f,nr.buffer=Gi,Z=xe}return o}return{E:JT,F:gT,G:TS,H:zu,I:$e,J:vi,K:_S}}return pl(V)}(R)}var w=Error,P={};A=[],typeof P!="object"&&Re("no native wasm support detected");var $,N=!1;function I(R,L,V){V=L+V;for(var X="";!(L>=V);){var Z=R[L++];if(!Z)break;if(Z&128){var ye=R[L++]&63;if((Z&224)==192)X+=String.fromCharCode((Z&31)<<6|ye);else{var Te=R[L++]&63;Z=(Z&240)==224?(Z&15)<<12|ye<<6|Te:(Z&7)<<18|ye<<12|Te<<6|R[L++]&63,65536>Z?X+=String.fromCharCode(Z):(Z-=65536,X+=String.fromCharCode(55296|Z>>10,56320|Z&1023))}}else X+=String.fromCharCode(Z)}return X}var O,K,U,re,ne,Y,Ee,ce,we;function Oe(R){O=R,a.HEAP8=K=new Int8Array(R),a.HEAP16=re=new Int16Array(R),a.HEAP32=Y=new Int32Array(R),a.HEAPU8=U=new Uint8Array(R),a.HEAPU16=ne=new Uint16Array(R),a.HEAPU32=Ee=new Uint32Array(R),a.HEAPF32=ce=new Float32Array(R),a.HEAPF64=we=new Float64Array(R)}var B=a.INITIAL_MEMORY||16777216;a.wasmMemory?$=a.wasmMemory:$=new x,$&&(O=$.buffer),B=O.byteLength,Oe(O);var W,ke=[],F=[],G=[];function Q(){var R=a.preRun.shift();ke.unshift(R)}var me=0,pe=null;function Re(R){throw a.onAbort&&a.onAbort(R),R="Aborted("+R+")",g(R),N=!0,R=new w(R+". Build with -sASSERTIONS for more info."),h(R),R}function Ue(R){return R.startsWith("data:application/octet-stream;base64,")}var Ke;if(Ke="<<< WASM_BINARY_FILE >>>",!Ue(Ke)){var Ze=Ke;Ke=a.locateFile?a.locateFile(Ze,p):p+Ze}function pt(R){var L=Ke;try{try{if(L==Ke&&A)new Uint8Array(A);else{if(Ue(L)){try{var V=Wb(L.slice(37)),X=new Uint8Array(V.length);for(L=0;L<V.length;++L)X[L]=V.charCodeAt(L);var Z=X}catch{throw Error("Converting base64 string to bytes failed.")}var ye=Z}else ye=void 0;if(!ye)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(Pe){Re(Pe)}var Te=new b,le=new S(R)}catch(Pe){throw R=Pe.toString(),g("failed to compile wasm module: "+R),(R.includes("imported Memory")||R.includes("memory import"))&&g("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)."),Pe}return[le,Te]}function ft(R){for(;0<R.length;)R.shift()(a)}function Kt(R){if(R===void 0)return"_unknown";R=R.replace(/[^a-zA-Z0-9_]/g,"$");var L=R.charCodeAt(0);return 48<=L&&57>=L?"_"+R:R}function _t(R,L){return R=Kt(R),function(){return L.apply(this,arguments)}}var je=[{},{value:void 0},{value:null},{value:!0},{value:!1}],qe=[];function Be(R){var L=Error,V=_t(R,function(X){this.name=R,this.message=X,X=Error(X).stack,X!==void 0&&(this.stack=this.toString()+`
|
79
|
+
`+X.replace(/^Error(:[^\n]*)?\n/,""))});return V.prototype=Object.create(L.prototype),V.prototype.constructor=V,V.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},V}var ot=void 0;function Fe(R){throw new ot(R)}var It=R=>(R||Fe("Cannot use deleted val. handle = "+R),je[R].value),At=R=>{switch(R){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var L=qe.length?qe.pop():je.length;return je[L]={fa:1,value:R},L}},Ut=void 0,ci=void 0;function st(R){for(var L="";U[R];)L+=ci[U[R++]];return L}var Bt=[];function at(){for(;Bt.length;){var R=Bt.pop();R.L.Z=!1,R.delete()}}var $t=void 0,Gt={};function Ji(R,L){for(L===void 0&&Fe("ptr should not be undefined");R.P;)L=R.aa(L),R=R.P;return L}var Vt={};function Di(R){R=Kb(R);var L=st(R);return Os(R),L}function ns(R,L){var V=Vt[R];return V===void 0&&Fe(L+" has unknown type "+Di(R)),V}function ui(){}var Sr=!1;function Ls(R){--R.count.value,R.count.value===0&&(R.S?R.T.V(R.S):R.O.M.V(R.N))}function Cs(R,L,V){return L===V?R:V.P===void 0?null:(R=Cs(R,L,V.P),R===null?null:V.ma(R))}var sr={};function ue(R,L){return L=Ji(R,L),Gt[L]}var Ve=void 0;function Qe(R){throw new Ve(R)}function Et(R,L){return L.O&&L.N||Qe("makeClassHandle requires ptr and ptrType"),!!L.T!=!!L.S&&Qe("Both smartPtrType and smartPtr must be specified"),L.count={value:1},ct(Object.create(R,{L:{value:L}}))}function ct(R){return typeof FinalizationRegistry>"u"?(ct=L=>L,R):(Sr=new FinalizationRegistry(L=>{Ls(L.L)}),ct=L=>{var V=L.L;return V.S&&Sr.register(L,{L:V},L),L},ui=L=>{Sr.unregister(L)},ct(R))}var oi={};function Oi(R){for(;R.length;){var L=R.pop();R.pop()(L)}}function pr(R){return this.fromWireType(Y[R>>2])}var os={},mr={};function gr(R,L,V){function X(le){le=V(le),le.length!==R.length&&Qe("Mismatched type converter count");for(var Pe=0;Pe<R.length;++Pe)Pi(R[Pe],le[Pe])}R.forEach(function(le){mr[le]=L});var Z=Array(L.length),ye=[],Te=0;L.forEach((le,Pe)=>{Vt.hasOwnProperty(le)?Z[Pe]=Vt[le]:(ye.push(le),os.hasOwnProperty(le)||(os[le]=[]),os[le].push(()=>{Z[Pe]=Vt[le],++Te,Te===ye.length&&X(Z)}))}),ye.length===0&&X(Z)}function Is(R){switch(R){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+R)}}function Pi(R,L,V={}){if(!("argPackAdvance"in L))throw new TypeError("registerType registeredInstance requires argPackAdvance");var X=L.name;if(R||Fe('type "'+X+'" must have a positive integer typeid pointer'),Vt.hasOwnProperty(R)){if(V.ta)return;Fe("Cannot register type '"+X+"' twice")}Vt[R]=L,delete mr[R],os.hasOwnProperty(R)&&(L=os[R],delete os[R],L.forEach(Z=>Z()))}function Ho(R){Fe(R.L.O.M.name+" instance already deleted")}function vr(){}function Ds(R,L,V){if(R[L].R===void 0){var X=R[L];R[L]=function(){return R[L].R.hasOwnProperty(arguments.length)||Fe("Function '"+V+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+R[L].R+")!"),R[L].R[arguments.length].apply(this,arguments)},R[L].R=[],R[L].R[X.Y]=X}}function kb(R,L){a.hasOwnProperty(R)?(Fe("Cannot register public name '"+R+"' twice"),Ds(a,R,R),a.hasOwnProperty(void 0)&&Fe("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),a[R].R[void 0]=L):a[R]=L}function wb(R,L,V,X,Z,ye,Te,le){this.name=R,this.constructor=L,this.W=V,this.V=X,this.P=Z,this.oa=ye,this.aa=Te,this.ma=le,this.ia=[]}function Uu(R,L,V){for(;L!==V;)L.aa||Fe("Expected null or instance of "+V.name+", got an instance of "+L.name),R=L.aa(R),L=L.P;return R}function _b(R,L){return L===null?(this.da&&Fe("null is not a valid "+this.name),0):(L.L||Fe('Cannot pass "'+Hu(L)+'" as a '+this.name),L.L.N||Fe("Cannot pass deleted object as a pointer of type "+this.name),Uu(L.L.N,L.L.O.M,this.M))}function Rb(R,L){if(L===null){if(this.da&&Fe("null is not a valid "+this.name),this.ca){var V=this.ea();return R!==null&&R.push(this.V,V),V}return 0}if(L.L||Fe('Cannot pass "'+Hu(L)+'" as a '+this.name),L.L.N||Fe("Cannot pass deleted object as a pointer of type "+this.name),!this.ba&&L.L.O.ba&&Fe("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name),V=Uu(L.L.N,L.L.O.M,this.M),this.ca)switch(L.L.S===void 0&&Fe("Passing raw pointer to smart pointer is illegal"),this.Aa){case 0:L.L.T===this?V=L.L.S:Fe("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name);break;case 1:V=L.L.S;break;case 2:if(L.L.T===this)V=L.L.S;else{var X=L.clone();V=this.wa(V,At(function(){X.delete()})),R!==null&&R.push(this.V,V)}break;default:Fe("Unsupporting sharing policy")}return V}function Lb(R,L){return L===null?(this.da&&Fe("null is not a valid "+this.name),0):(L.L||Fe('Cannot pass "'+Hu(L)+'" as a '+this.name),L.L.N||Fe("Cannot pass deleted object as a pointer of type "+this.name),L.L.O.ba&&Fe("Cannot convert argument of type "+L.L.O.name+" to parameter type "+this.name),Uu(L.L.N,L.L.O.M,this.M))}function as(R,L,V,X){this.name=R,this.M=L,this.da=V,this.ba=X,this.ca=!1,this.V=this.wa=this.ea=this.ja=this.Aa=this.va=void 0,L.P!==void 0?this.toWireType=Rb:(this.toWireType=X?_b:Lb,this.U=null)}function Cb(R,L){a.hasOwnProperty(R)||Qe("Replacing nonexistant public symbol"),a[R]=L,a[R].Y=void 0}function Ib(R,L){var V=[];return function(){if(V.length=0,Object.assign(V,arguments),R.includes("j")){var X=a["dynCall_"+R];X=V&&V.length?X.apply(null,[L].concat(V)):X.call(null,L)}else X=W.get(L).apply(null,V);return X}}function kr(R,L){R=st(R);var V=R.includes("j")?Ib(R,L):W.get(L);return typeof V!="function"&&Fe("unknown function pointer with signature "+R+": "+L),V}var Yp=void 0;function ul(R,L){function V(ye){Z[ye]||Vt[ye]||(mr[ye]?mr[ye].forEach(V):(X.push(ye),Z[ye]=!0))}var X=[],Z={};throw L.forEach(V),new Yp(R+": "+X.map(Di).join([", "]))}function Bu(R,L,V,X,Z){var ye=L.length;2>ye&&Fe("argTypes array size mismatch! Must at least get return value and 'this' types!");var Te=L[1]!==null&&V!==null,le=!1;for(V=1;V<L.length;++V)if(L[V]!==null&&L[V].U===void 0){le=!0;break}var Pe=L[0].name!=="void",Ie=ye-2,Ge=Array(Ie),Ye=[],yt=[];return function(){if(arguments.length!==Ie&&Fe("function "+R+" called with "+arguments.length+" arguments, expected "+Ie+" args!"),yt.length=0,Ye.length=Te?2:1,Ye[0]=Z,Te){var mt=L[1].toWireType(yt,this);Ye[1]=mt}for(var Le=0;Le<Ie;++Le)Ge[Le]=L[Le+2].toWireType(yt,arguments[Le]),Ye.push(Ge[Le]);if(Le=X.apply(null,Ye),le)Oi(yt);else for(var ki=Te?1:2;ki<L.length;ki++){var $i=ki===1?mt:Ge[ki-2];L[ki].U!==null&&L[ki].U($i)}return mt=Pe?L[0].fromWireType(Le):void 0,mt}}function Gu(R,L){for(var V=[],X=0;X<R;X++)V.push(Ee[L+4*X>>2]);return V}function Vu(R){4<R&&--je[R].fa===0&&(je[R]=void 0,qe.push(R))}function Hu(R){if(R===null)return"null";var L=typeof R;return L==="object"||L==="array"||L==="function"?R.toString():""+R}function Db(R,L){switch(L){case 2:return function(V){return this.fromWireType(ce[V>>2])};case 3:return function(V){return this.fromWireType(we[V>>3])};default:throw new TypeError("Unknown float type: "+R)}}function Ob(R,L,V){switch(L){case 0:return V?function(X){return K[X]}:function(X){return U[X]};case 1:return V?function(X){return re[X>>1]}:function(X){return ne[X>>1]};case 2:return V?function(X){return Y[X>>2]}:function(X){return Ee[X>>2]};default:throw new TypeError("Unknown integer type: "+R)}}function Pb(R,L){for(var V="",X=0;!(X>=L/2);++X){var Z=re[R+2*X>>1];if(Z==0)break;V+=String.fromCharCode(Z)}return V}function $b(R,L,V){if(V===void 0&&(V=2147483647),2>V)return 0;V-=2;var X=L;V=V<2*R.length?V/2:R.length;for(var Z=0;Z<V;++Z)re[L>>1]=R.charCodeAt(Z),L+=2;return re[L>>1]=0,L-X}function Mb(R){return 2*R.length}function Fb(R,L){for(var V=0,X="";!(V>=L/4);){var Z=Y[R+4*V>>2];if(Z==0)break;++V,65536<=Z?(Z-=65536,X+=String.fromCharCode(55296|Z>>10,56320|Z&1023)):X+=String.fromCharCode(Z)}return X}function Nb(R,L,V){if(V===void 0&&(V=2147483647),4>V)return 0;var X=L;V=X+V-4;for(var Z=0;Z<R.length;++Z){var ye=R.charCodeAt(Z);if(55296<=ye&&57343>=ye){var Te=R.charCodeAt(++Z);ye=65536+((ye&1023)<<10)|Te&1023}if(Y[L>>2]=ye,L+=4,L+4>V)break}return Y[L>>2]=0,L-X}function Ub(R){for(var L=0,V=0;V<R.length;++V){var X=R.charCodeAt(V);55296<=X&&57343>=X&&++V,L+=4}return L}var Bb={};function Xp(R){var L=Bb[R];return L===void 0?st(R):L}var hl=[];function Gb(R){var L=hl.length;return hl.push(R),L}function Vb(R,L){for(var V=Array(R),X=0;X<R;++X)V[X]=ns(Ee[L+4*X>>2],"parameter "+X);return V}var Zp=[],Hb=[null,[],[]];ot=a.BindingError=Be("BindingError"),a.count_emval_handles=function(){for(var R=0,L=5;L<je.length;++L)je[L]!==void 0&&++R;return R},a.get_first_emval=function(){for(var R=5;R<je.length;++R)if(je[R]!==void 0)return je[R];return null},Ut=a.PureVirtualError=Be("PureVirtualError");for(var qp=Array(256),fl=0;256>fl;++fl)qp[fl]=String.fromCharCode(fl);ci=qp,a.getInheritedInstanceCount=function(){return Object.keys(Gt).length},a.getLiveInheritedInstances=function(){var R=[],L;for(L in Gt)Gt.hasOwnProperty(L)&&R.push(Gt[L]);return R},a.flushPendingDeletes=at,a.setDelayFunction=function(R){$t=R,Bt.length&&$t&&$t(at)},Ve=a.InternalError=Be("InternalError"),vr.prototype.isAliasOf=function(R){if(!(this instanceof vr&&R instanceof vr))return!1;var L=this.L.O.M,V=this.L.N,X=R.L.O.M;for(R=R.L.N;L.P;)V=L.aa(V),L=L.P;for(;X.P;)R=X.aa(R),X=X.P;return L===X&&V===R},vr.prototype.clone=function(){if(this.L.N||Ho(this),this.L.$)return this.L.count.value+=1,this;var R=ct,L=Object,V=L.create,X=Object.getPrototypeOf(this),Z=this.L;return R=R(V.call(L,X,{L:{value:{count:Z.count,Z:Z.Z,$:Z.$,N:Z.N,O:Z.O,S:Z.S,T:Z.T}}})),R.L.count.value+=1,R.L.Z=!1,R},vr.prototype.delete=function(){this.L.N||Ho(this),this.L.Z&&!this.L.$&&Fe("Object already scheduled for deletion"),ui(this),Ls(this.L),this.L.$||(this.L.S=void 0,this.L.N=void 0)},vr.prototype.isDeleted=function(){return!this.L.N},vr.prototype.deleteLater=function(){return this.L.N||Ho(this),this.L.Z&&!this.L.$&&Fe("Object already scheduled for deletion"),Bt.push(this),Bt.length===1&&$t&&$t(at),this.L.Z=!0,this},as.prototype.pa=function(R){return this.ja&&(R=this.ja(R)),R},as.prototype.ga=function(R){this.V&&this.V(R)},as.prototype.argPackAdvance=8,as.prototype.readValueFromPointer=pr,as.prototype.deleteObject=function(R){R!==null&&R.delete()},as.prototype.fromWireType=function(R){function L(){return this.ca?Et(this.M.W,{O:this.va,N:V,T:this,S:R}):Et(this.M.W,{O:this,N:R})}var V=this.pa(R);if(!V)return this.ga(R),null;var X=ue(this.M,V);if(X!==void 0)return X.L.count.value===0?(X.L.N=V,X.L.S=R,X.clone()):(X=X.clone(),this.ga(R),X);if(X=this.M.oa(V),X=sr[X],!X)return L.call(this);X=this.ba?X.ka:X.pointerType;var Z=Cs(V,this.M,X.M);return Z===null?L.call(this):this.ca?Et(X.M.W,{O:X,N:Z,T:this,S:R}):Et(X.M.W,{O:X,N:Z})},Yp=a.UnboundTypeError=Be("UnboundTypeError");var Wb=typeof atob=="function"?atob:function(R){var L="",V=0;R=R.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var X="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(R.charAt(V++)),Z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(R.charAt(V++)),ye="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(R.charAt(V++)),Te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(R.charAt(V++));X=X<<2|Z>>4,Z=(Z&15)<<4|ye>>2;var le=(ye&3)<<6|Te;L+=String.fromCharCode(X),ye!==64&&(L+=String.fromCharCode(Z)),Te!==64&&(L+=String.fromCharCode(le))}while(V<R.length);return L},jb={q:function(R,L,V){R=st(R),L=ns(L,"wrapper"),V=It(V);var X=[].slice,Z=L.M,ye=Z.W,Te=Z.P.W,le=Z.P.constructor;R=_t(R,function(){Z.P.ia.forEach((function(Ie){if(this[Ie]===Te[Ie])throw new Ut("Pure virtual function "+Ie+" must be implemented in JavaScript")}).bind(this)),Object.defineProperty(this,"__parent",{value:ye}),this.__construct.apply(this,X.call(arguments))}),ye.__construct=function(){this===ye&&Fe("Pass correct 'this' to __construct");var Ie=le.implement.apply(void 0,[this].concat(X.call(arguments)));ui(Ie);var Ge=Ie.L;Ie.notifyOnDestruction(),Ge.$=!0,Object.defineProperties(this,{L:{value:Ge}}),ct(this),Ie=Ge.N,Ie=Ji(Z,Ie),Gt.hasOwnProperty(Ie)?Fe("Tried to register registered instance: "+Ie):Gt[Ie]=this},ye.__destruct=function(){this===ye&&Fe("Pass correct 'this' to __destruct"),ui(this);var Ie=this.L.N;Ie=Ji(Z,Ie),Gt.hasOwnProperty(Ie)?delete Gt[Ie]:Fe("Tried to unregister unregistered instance: "+Ie)},R.prototype=Object.create(ye);for(var Pe in V)R.prototype[Pe]=V[Pe];return At(R)},k:function(R){var L=oi[R];delete oi[R];var V=L.ea,X=L.V,Z=L.ha,ye=Z.map(Te=>Te.sa).concat(Z.map(Te=>Te.ya));gr([R],ye,Te=>{var le={};return Z.forEach((Pe,Ie)=>{var Ge=Te[Ie],Ye=Pe.qa,yt=Pe.ra,mt=Te[Ie+Z.length],Le=Pe.xa,ki=Pe.za;le[Pe.na]={read:$i=>Ge.fromWireType(Ye(yt,$i)),write:($i,St)=>{var mi=[];Le(ki,$i,mt.toWireType(mi,St)),Oi(mi)}}}),[{name:L.name,fromWireType:function(Pe){var Ie={},Ge;for(Ge in le)Ie[Ge]=le[Ge].read(Pe);return X(Pe),Ie},toWireType:function(Pe,Ie){for(var Ge in le)if(!(Ge in Ie))throw new TypeError('Missing field: "'+Ge+'"');var Ye=V();for(Ge in le)le[Ge].write(Ye,Ie[Ge]);return Pe!==null&&Pe.push(X,Ye),Ye},argPackAdvance:8,readValueFromPointer:pr,U:X}]})},w:function(){},C:function(R,L,V,X,Z){var ye=Is(V);L=st(L),Pi(R,{name:L,fromWireType:function(Te){return!!Te},toWireType:function(Te,le){return le?X:Z},argPackAdvance:8,readValueFromPointer:function(Te){if(V===1)var le=K;else if(V===2)le=re;else if(V===4)le=Y;else throw new TypeError("Unknown boolean type size: "+L);return this.fromWireType(le[Te>>ye])},U:null})},g:function(R,L,V,X,Z,ye,Te,le,Pe,Ie,Ge,Ye,yt){Ge=st(Ge),ye=kr(Z,ye),le&&(le=kr(Te,le)),Ie&&(Ie=kr(Pe,Ie)),yt=kr(Ye,yt);var mt=Kt(Ge);kb(mt,function(){ul("Cannot construct "+Ge+" due to unbound types",[X])}),gr([R,L,V],X?[X]:[],function(Le){if(Le=Le[0],X)var ki=Le.M,$i=ki.W;else $i=vr.prototype;Le=_t(mt,function(){if(Object.getPrototypeOf(this)!==St)throw new ot("Use 'new' to construct "+Ge);if(mi.X===void 0)throw new ot(Ge+" has no accessible constructor");var pl=mi.X[arguments.length];if(pl===void 0)throw new ot("Tried to invoke ctor of "+Ge+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(mi.X).toString()+") parameters instead!");return pl.apply(this,arguments)});var St=Object.create($i,{constructor:{value:Le}});Le.prototype=St;var mi=new wb(Ge,Le,St,yt,ki,ye,le,Ie);ki=new as(Ge,mi,!0,!1),$i=new as(Ge+"*",mi,!1,!1);var He=new as(Ge+" const*",mi,!1,!0);return sr[R]={pointerType:$i,ka:He},Cb(mt,Le),[ki,$i,He]})},d:function(R,L,V,X,Z,ye,Te){var le=Gu(V,X);L=st(L),ye=kr(Z,ye),gr([],[R],function(Pe){function Ie(){ul("Cannot call "+Ge+" due to unbound types",le)}Pe=Pe[0];var Ge=Pe.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]);var Ye=Pe.M.constructor;return Ye[L]===void 0?(Ie.Y=V-1,Ye[L]=Ie):(Ds(Ye,L,Ge),Ye[L].R[V-1]=Ie),gr([],le,function(yt){return yt=Bu(Ge,[yt[0],null].concat(yt.slice(1)),null,ye,Te),Ye[L].R===void 0?(yt.Y=V-1,Ye[L]=yt):Ye[L].R[V-1]=yt,[]}),[]})},p:function(R,L,V,X,Z,ye){0<L||Re();var Te=Gu(L,V);Z=kr(X,Z),gr([],[R],function(le){le=le[0];var Pe="constructor "+le.name;if(le.M.X===void 0&&(le.M.X=[]),le.M.X[L-1]!==void 0)throw new ot("Cannot register multiple constructors with identical number of parameters ("+(L-1)+") for class '"+le.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return le.M.X[L-1]=()=>{ul("Cannot construct "+le.name+" due to unbound types",Te)},gr([],Te,function(Ie){return Ie.splice(1,0,null),le.M.X[L-1]=Bu(Pe,Ie,null,Z,ye),[]}),[]})},b:function(R,L,V,X,Z,ye,Te,le){var Pe=Gu(V,X);L=st(L),ye=kr(Z,ye),gr([],[R],function(Ie){function Ge(){ul("Cannot call "+Ye+" due to unbound types",Pe)}Ie=Ie[0];var Ye=Ie.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]),le&&Ie.M.ia.push(L);var yt=Ie.M.W,mt=yt[L];return mt===void 0||mt.R===void 0&&mt.className!==Ie.name&&mt.Y===V-2?(Ge.Y=V-2,Ge.className=Ie.name,yt[L]=Ge):(Ds(yt,L,Ye),yt[L].R[V-2]=Ge),gr([],Pe,function(Le){return Le=Bu(Ye,Le,Ie,ye,Te),yt[L].R===void 0?(Le.Y=V-2,yt[L]=Le):yt[L].R[V-2]=Le,[]}),[]})},B:function(R,L){L=st(L),Pi(R,{name:L,fromWireType:function(V){var X=It(V);return Vu(V),X},toWireType:function(V,X){return At(X)},argPackAdvance:8,readValueFromPointer:pr,U:null})},n:function(R,L,V){V=Is(V),L=st(L),Pi(R,{name:L,fromWireType:function(X){return X},toWireType:function(X,Z){return Z},argPackAdvance:8,readValueFromPointer:Db(L,V),U:null})},e:function(R,L,V,X,Z){L=st(L),Z===-1&&(Z=4294967295),Z=Is(V);var ye=le=>le;if(X===0){var Te=32-8*V;ye=le=>le<<Te>>>Te}V=L.includes("unsigned")?function(le,Pe){return Pe>>>0}:function(le,Pe){return Pe},Pi(R,{name:L,fromWireType:ye,toWireType:V,argPackAdvance:8,readValueFromPointer:Ob(L,Z,X!==0),U:null})},c:function(R,L,V){function X(ye){ye>>=2;var Te=Ee;return new Z(O,Te[ye+1],Te[ye])}var Z=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][L];V=st(V),Pi(R,{name:V,fromWireType:X,argPackAdvance:8,readValueFromPointer:X},{ta:!0})},o:function(R,L){L=st(L);var V=L==="std::string";Pi(R,{name:L,fromWireType:function(X){var Z=Ee[X>>2],ye=X+4;if(V)for(var Te=ye,le=0;le<=Z;++le){var Pe=ye+le;if(le==Z||U[Pe]==0){if(Te=Te?I(U,Te,Pe-Te):"",Ie===void 0)var Ie=Te;else Ie+=String.fromCharCode(0),Ie+=Te;Te=Pe+1}}else{for(Ie=Array(Z),le=0;le<Z;++le)Ie[le]=String.fromCharCode(U[ye+le]);Ie=Ie.join("")}return Os(X),Ie},toWireType:function(X,Z){Z instanceof ArrayBuffer&&(Z=new Uint8Array(Z));var ye,Te=typeof Z=="string";if(Te||Z instanceof Uint8Array||Z instanceof Uint8ClampedArray||Z instanceof Int8Array||Fe("Cannot pass non-string to std::string"),V&&Te){var le=0;for(ye=0;ye<Z.length;++ye){var Pe=Z.charCodeAt(ye);127>=Pe?le++:2047>=Pe?le+=2:55296<=Pe&&57343>=Pe?(le+=4,++ye):le+=3}ye=le}else ye=Z.length;if(le=Qp(4+ye+1),Pe=le+4,Ee[le>>2]=ye,V&&Te){if(Te=Pe,Pe=ye+1,ye=U,0<Pe){Pe=Te+Pe-1;for(var Ie=0;Ie<Z.length;++Ie){var Ge=Z.charCodeAt(Ie);if(55296<=Ge&&57343>=Ge){var Ye=Z.charCodeAt(++Ie);Ge=65536+((Ge&1023)<<10)|Ye&1023}if(127>=Ge){if(Te>=Pe)break;ye[Te++]=Ge}else{if(2047>=Ge){if(Te+1>=Pe)break;ye[Te++]=192|Ge>>6}else{if(65535>=Ge){if(Te+2>=Pe)break;ye[Te++]=224|Ge>>12}else{if(Te+3>=Pe)break;ye[Te++]=240|Ge>>18,ye[Te++]=128|Ge>>12&63}ye[Te++]=128|Ge>>6&63}ye[Te++]=128|Ge&63}}ye[Te]=0}}else if(Te)for(Te=0;Te<ye;++Te)Ie=Z.charCodeAt(Te),255<Ie&&(Os(Pe),Fe("String has UTF-16 code units that do not fit in 8 bits")),U[Pe+Te]=Ie;else for(Te=0;Te<ye;++Te)U[Pe+Te]=Z[Te];return X!==null&&X.push(Os,le),le},argPackAdvance:8,readValueFromPointer:pr,U:function(X){Os(X)}})},j:function(R,L,V){if(V=st(V),L===2)var X=Pb,Z=$b,ye=Mb,Te=()=>ne,le=1;else L===4&&(X=Fb,Z=Nb,ye=Ub,Te=()=>Ee,le=2);Pi(R,{name:V,fromWireType:function(Pe){for(var Ie=Ee[Pe>>2],Ge=Te(),Ye,yt=Pe+4,mt=0;mt<=Ie;++mt){var Le=Pe+4+mt*L;(mt==Ie||Ge[Le>>le]==0)&&(yt=X(yt,Le-yt),Ye===void 0?Ye=yt:(Ye+=String.fromCharCode(0),Ye+=yt),yt=Le+L)}return Os(Pe),Ye},toWireType:function(Pe,Ie){typeof Ie!="string"&&Fe("Cannot pass non-string to C++ string type "+V);var Ge=ye(Ie),Ye=Qp(4+Ge+L);return Ee[Ye>>2]=Ge>>le,Z(Ie,Ye+4,Ge+L),Pe!==null&&Pe.push(Os,Ye),Ye},argPackAdvance:8,readValueFromPointer:pr,U:function(Pe){Os(Pe)}})},l:function(R,L,V,X,Z,ye){oi[R]={name:st(L),ea:kr(V,X),V:kr(Z,ye),ha:[]}},i:function(R,L,V,X,Z,ye,Te,le,Pe,Ie){oi[R].ha.push({na:st(L),sa:V,qa:kr(X,Z),ra:ye,ya:Te,xa:kr(le,Pe),za:Ie})},D:function(R,L){L=st(L),Pi(R,{ua:!0,name:L,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},t:function(R,L,V,X,Z){R=hl[R],L=It(L),V=Xp(V);var ye=[];return Ee[X>>2]=At(ye),R(L,V,ye,Z)},u:function(R,L,V,X){R=hl[R],L=It(L),V=Xp(V),R(L,V,null,X)},h:Vu,m:function(R,L){var V=Vb(R,L),X=V[0];L=X.name+"_$"+V.slice(1).map(function(Te){return Te.name}).join("_")+"$";var Z=Zp[L];if(Z!==void 0)return Z;var ye=Array(R-1);return Z=Gb((Te,le,Pe,Ie)=>{for(var Ge=0,Ye=0;Ye<R-1;++Ye)ye[Ye]=V[Ye+1].readValueFromPointer(Ie+Ge),Ge+=V[Ye+1].argPackAdvance;for(Te=Te[le].apply(Te,ye),Ye=0;Ye<R-1;++Ye)V[Ye+1].la&&V[Ye+1].la(ye[Ye]);if(!X.ua)return X.toWireType(Pe,Te)}),Zp[L]=Z},r:function(R){4<R&&(je[R].fa+=1)},s:function(R){var L=It(R);Oi(L),Vu(R)},f:function(){Re("")},y:function(R,L,V){U.copyWithin(R,L,L+V)},x:function(R){var L=U.length;if(R>>>=0,2147483648<R)return!1;for(var V=1;4>=V;V*=2){var X=L*(1+.2/V);X=Math.min(X,R+100663296);var Z=Math;X=Math.max(R,X),Z=Z.min.call(Z,2147483648,X+(65536-X%65536)%65536);e:{try{$.grow(Z-O.byteLength+65535>>>16),Oe($.buffer);var ye=1;break e}catch{}ye=void 0}if(ye)return!0}return!1},A:function(){return 52},v:function(){return 70},z:function(R,L,V,X){for(var Z=0,ye=0;ye<V;ye++){var Te=Ee[L>>2],le=Ee[L+4>>2];L+=8;for(var Pe=0;Pe<le;Pe++){var Ie=U[Te+Pe],Ge=Hb[R];Ie===0||Ie===10?((R===1?m:g)(I(Ge,0)),Ge.length=0):Ge.push(Ie)}Z+=le}return Ee[X>>2]=Z,0},a:$},Un=function(){function R(V){a.asm=V.exports,W=a.asm.I,F.unshift(a.asm.E),me--,a.monitorRunDependencies&&a.monitorRunDependencies(me),me==0&&pe&&(V=pe,pe=null,V())}var L={a:jb};if(me++,a.monitorRunDependencies&&a.monitorRunDependencies(me),a.instantiateWasm)try{return a.instantiateWasm(L,R)}catch(V){g("Module.instantiateWasm callback failed with error: "+V),h(V)}return L=pt(L),R(L[0]),a.asm}();a.___wasm_call_ctors=Un.E;var Kb=a.___getTypeName=Un.F;a.__embind_initialize_bindings=Un.G;var Qp=a._malloc=Un.H,Os=a._free=Un.J;a.dynCall_jiji=Un.K;var dl;pe=function R(){dl||Jp(),dl||(pe=R)};function Jp(){function R(){if(!dl&&(dl=!0,a.calledRun=!0,!N)){if(ft(F),l(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;){var L=a.postRun.shift();G.unshift(L)}ft(G)}}if(!(0<me)){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)Q();ft(ke),0<me||(a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),R()},1)):R())}}if(a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);0<a.preInit.length;)a.preInit.pop()();return Jp(),n}})();s.exports=t})(u0);var U2=u0.exports;(function(s){Object.defineProperty(s,"__esModule",{value:!0});var e={};s.default=void 0;var t=n(zl),i=nt;Object.keys(i).forEach(function(d){d==="default"||d==="__esModule"||Object.prototype.hasOwnProperty.call(e,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 a=U2;var h=(0,t.default)(a());s.default=h})(bt);const h0=ua(bt);var f0=function(){};const B2=(s,e,t)=>Math.min(Math.max(t,s),e),d0=(s,e,t)=>{const i=e-s;return i===0?1:(t-s)/i},ql=(s,e,t)=>-t*s+t*e+s,p0=(s,e)=>t=>Math.max(Math.min(t,e),s),vo=s=>s%1?Number(s.toFixed(5)):s,Aa=/(-)?([\d]*\.?[\d])+/g,Ql=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))/gi,G2=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))$/i;function yo(s){return typeof s=="string"}const Ea={test:s=>typeof s=="number",parse:parseFloat,transform:s=>s},m0=Object.assign(Object.assign({},Ea),{transform:p0(0,1)});Object.assign(Object.assign({},Ea),{default:1});const Ao=(s=>({test:e=>yo(e)&&e.endsWith(s)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${s}`}))("%");Object.assign(Object.assign({},Ao),{parse:s=>Ao.parse(s)/100,transform:s=>Ao.transform(s*100)});const Jl=(s,e)=>t=>!!(yo(t)&&G2.test(t)&&t.startsWith(s)||e&&Object.prototype.hasOwnProperty.call(t,e)),g0=(s,e,t)=>i=>{if(!yo(i))return i;const[n,a,l,h]=i.match(Aa);return{[s]:parseFloat(n),[e]:parseFloat(a),[t]:parseFloat(l),alpha:h!==void 0?parseFloat(h):1}},rn={test:Jl("hsl","hue"),parse:g0("hue","saturation","lightness"),transform:({hue:s,saturation:e,lightness:t,alpha:i=1})=>"hsla("+Math.round(s)+", "+Ao.transform(vo(e))+", "+Ao.transform(vo(t))+", "+vo(m0.transform(i))+")"},V2=p0(0,255),ec=Object.assign(Object.assign({},Ea),{transform:s=>Math.round(V2(s))}),Es={test:Jl("rgb","red"),parse:g0("red","green","blue"),transform:({red:s,green:e,blue:t,alpha:i=1})=>"rgba("+ec.transform(s)+", "+ec.transform(e)+", "+ec.transform(t)+", "+vo(m0.transform(i))+")"};function H2(s){let e="",t="",i="",n="";return s.length>5?(e=s.substr(1,2),t=s.substr(3,2),i=s.substr(5,2),n=s.substr(7,2)):(e=s.substr(1,1),t=s.substr(2,1),i=s.substr(3,1),n=s.substr(4,1),e+=e,t+=t,i+=i,n+=n),{red:parseInt(e,16),green:parseInt(t,16),blue:parseInt(i,16),alpha:n?parseInt(n,16)/255:1}}const tc={test:Jl("#"),parse:H2,transform:Es.transform},xa={test:s=>Es.test(s)||tc.test(s)||rn.test(s),parse:s=>Es.test(s)?Es.parse(s):rn.test(s)?rn.parse(s):tc.parse(s),transform:s=>yo(s)?s:s.hasOwnProperty("red")?Es.transform(s):rn.transform(s)},v0="${c}",y0="${n}";function W2(s){var e,t,i,n;return isNaN(s)&&yo(s)&&((t=(e=s.match(Aa))===null||e===void 0?void 0:e.length)!==null&&t!==void 0?t:0)+((n=(i=s.match(Ql))===null||i===void 0?void 0:i.length)!==null&&n!==void 0?n:0)>0}function A0(s){typeof s=="number"&&(s=`${s}`);const e=[];let t=0;const i=s.match(Ql);i&&(t=i.length,s=s.replace(Ql,v0),e.push(...i.map(xa.parse)));const n=s.match(Aa);return n&&(s=s.replace(Aa,y0),e.push(...n.map(Ea.parse))),{values:e,numColors:t,tokenised:s}}function E0(s){return A0(s).values}function x0(s){const{values:e,numColors:t,tokenised:i}=A0(s),n=e.length;return a=>{let l=i;for(let h=0;h<n;h++)l=l.replace(h<t?v0:y0,h<t?xa.transform(a[h]):vo(a[h]));return l}}const j2=s=>typeof s=="number"?0:s;function K2(s){const e=E0(s);return x0(s)(e.map(j2))}const b0={test:W2,parse:E0,createTransformer:x0,getAnimatableNone:K2};function ic(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<.16666666666666666?s+(e-s)*6*t:t<.5?e:t<.6666666666666666?s+(e-s)*(.6666666666666666-t)*6:s}function T0({hue:s,saturation:e,lightness:t,alpha:i}){s/=360,e/=100,t/=100;let n=0,a=0,l=0;if(!e)n=a=l=t;else{const h=t<.5?t*(1+e):t+e-t*e,d=2*t-h;n=ic(d,h,s+.3333333333333333),a=ic(d,h,s),l=ic(d,h,s-.3333333333333333)}return{red:Math.round(n*255),green:Math.round(a*255),blue:Math.round(l*255),alpha:i}}const z2=(s,e,t)=>{const i=s*s,n=e*e;return Math.sqrt(Math.max(0,t*(n-i)+i))},Y2=[tc,Es,rn],S0=s=>Y2.find(e=>e.test(s)),k0=(s,e)=>{let t=S0(s),i=S0(e),n=t.parse(s),a=i.parse(e);t===rn&&(n=T0(n),t=Es),i===rn&&(a=T0(a),i=Es);const l=Object.assign({},n);return h=>{for(const d in l)d!=="alpha"&&(l[d]=z2(n[d],a[d],h));return l.alpha=ql(n.alpha,a.alpha,h),t.transform(l)}},X2=s=>typeof s=="number",Z2=(s,e)=>t=>e(s(t)),w0=(...s)=>s.reduce(Z2);function _0(s,e){return X2(s)?t=>ql(s,e,t):xa.test(s)?k0(s,e):C0(s,e)}const R0=(s,e)=>{const t=[...s],i=t.length,n=s.map((a,l)=>_0(a,e[l]));return a=>{for(let l=0;l<i;l++)t[l]=n[l](a);return t}},q2=(s,e)=>{const t=Object.assign(Object.assign({},s),e),i={};for(const n in t)s[n]!==void 0&&e[n]!==void 0&&(i[n]=_0(s[n],e[n]));return n=>{for(const a in i)t[a]=i[a](n);return t}};function L0(s){const e=b0.parse(s),t=e.length;let i=0,n=0,a=0;for(let l=0;l<t;l++)i||typeof e[l]=="number"?i++:e[l].hue!==void 0?a++:n++;return{parsed:e,numNumbers:i,numRGB:n,numHSL:a}}const C0=(s,e)=>{const t=b0.createTransformer(e),i=L0(s),n=L0(e);return i.numHSL===n.numHSL&&i.numRGB===n.numRGB&&i.numNumbers>=n.numNumbers?w0(R0(i.parsed,n.parsed),t):l=>`${l>0?e:s}`},Q2=(s,e)=>t=>ql(s,e,t);function J2(s){if(typeof s=="number")return Q2;if(typeof s=="string")return xa.test(s)?k0:C0;if(Array.isArray(s))return R0;if(typeof s=="object")return q2}function e1(s,e,t){const i=[],n=t||J2(s[0]),a=s.length-1;for(let l=0;l<a;l++){let h=n(s[l],s[l+1]);if(e){const d=Array.isArray(e)?e[l]:e;h=w0(d,h)}i.push(h)}return i}function t1([s,e],[t]){return i=>t(d0(s,e,i))}function i1(s,e){const t=s.length,i=t-1;return n=>{let a=0,l=!1;if(n<=s[0]?l=!0:n>=s[i]&&(a=i-1,l=!0),!l){let d=1;for(;d<t&&!(s[d]>n||d===i);d++);a=d-1}const h=d0(s[a],s[a+1],n);return e[a](h)}}function r1(s,e,{clamp:t=!0,ease:i,mixer:n}={}){const a=s.length;f0(a===e.length),f0(!i||!Array.isArray(i)||i.length===a-1),s[0]>s[a-1]&&(s=[].concat(s),e=[].concat(e),s.reverse(),e.reverse());const l=e1(e,i,n),h=a===2?t1(s,l):i1(s,l);return t?d=>h(B2(s[0],s[a-1],d)):h}const ba=s=>e=>1-s(1-e),rc=s=>e=>e<=.5?s(2*e)/2:(2-s(2*(1-e)))/2,s1=s=>e=>Math.pow(e,s),I0=s=>e=>e*e*((s+1)*e-s),n1=s=>{const e=I0(s);return t=>(t*=2)<1?.5*e(t):.5*(2-Math.pow(2,-10*(t-1)))},D0=1.525,o1=4/11,a1=8/11,l1=9/10,c1=s=>s,sc=s1(2),u1=ba(sc),h1=rc(sc),O0=s=>1-Math.sin(Math.acos(s)),P0=ba(O0),f1=rc(P0),nc=I0(D0),d1=ba(nc),p1=rc(nc),m1=n1(D0),g1=4356/361,v1=35442/1805,y1=16061/1805,Ta=s=>{if(s===1||s===0)return s;const e=s*s;return s<o1?7.5625*e:s<a1?9.075*e-9.9*s+3.4:s<l1?g1*e-v1*s+y1:10.8*s*s-20.52*s+10.72},A1=ba(Ta),E1=s=>s<.5?.5*(1-Ta(1-s*2)):.5*Ta(s*2-1)+.5,x1=(s,e,t,i)=>{if(t==="length"||t==="prototype"||t==="arguments"||t==="caller")return;const n=Object.getOwnPropertyDescriptor(s,t),a=Object.getOwnPropertyDescriptor(e,t);!b1(n,a)&&i||Object.defineProperty(s,t,a)},b1=function(s,e){return s===void 0||s.configurable||s.writable===e.writable&&s.enumerable===e.enumerable&&s.configurable===e.configurable&&(s.writable||s.value===e.value)},T1=(s,e)=>{const t=Object.getPrototypeOf(e);t!==Object.getPrototypeOf(s)&&Object.setPrototypeOf(s,t)},S1=(s,e)=>`/* Wrapped ${s}*/
|
80
|
+
${e}`,k1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),w1=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),_1=(s,e,t)=>{const i=t===""?"":`with ${t.trim()}() `,n=S1.bind(null,i,e.toString());Object.defineProperty(n,"name",w1),Object.defineProperty(s,"toString",{...k1,value:n})};function R1(s,e,{ignoreNonConfigurable:t=!1}={}){const{name:i}=s;for(const n of Reflect.ownKeys(e))x1(s,e,n,t);return T1(s,e),_1(s,e,i),s}const L1=new WeakMap;function xs(s,{cacheKey:e=([i])=>i,cache:t=new Map}={}){const i=new Map,n=function(...a){const l=e(a);if(i.has(l))return i.get(l);const h=(async()=>{try{if(t&&await t.has(l))return await t.get(l);const p=await s.apply(this,a);try{return p}finally{t&&await t.set(l,p)}}finally{i.delete(l)}})();return i.set(l,h),h};return R1(n,s,{ignoreNonConfigurable:!0}),L1.set(n,t),n}var oc={exports:{}};(function(s,e){(function(t,i){i(e)})(ca,function(t){function i(F){var G,Q,me=new Error(F);return G=me,Q=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(G,Q):G.__proto__=Q,me}function n(F,G,Q){var me=G.slice(0,Q).split(/\n/),pe=me.length,Re=me[pe-1].length+1;throw i(F+=" at line "+pe+" col "+Re+`:
|
81
|
+
|
82
|
+
`+G.split(/\n/)[pe-1]+`
|
83
|
+
`+Array(Re).join(" ")+"^")}i.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var a=new Function("return this")().Promise,l=!1;try{l=new Function("return (async function(){}).constructor")()}catch(F){if(!(F instanceof SyntaxError))throw F}function h(F,G){return Object.prototype.hasOwnProperty.call(F,G)}function d(F,G,Q){for(var me in G)h(G,me)&&(G[me]==null||typeof G[me]!="object"||me!=="storage"&&me!=="prefixes"||Q?F[me]=G[me]:F[me]=d({},G[me]));return F}var p=/^async +/,m=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,g=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,A=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,x=/[.*+\-?^${}()|[\]\\]/g;function b(F){return x.test(F)?F.replace(x,"\\$&"):F}function S(F,G){G.rmWhitespace&&(F=F.replace(/[\r\n]+/g,`
|
84
|
+
`).replace(/^\s+|\s+$/gm,"")),m.lastIndex=0,g.lastIndex=0,A.lastIndex=0;var Q=G.prefixes,me=[Q.h,Q.b,Q.i,Q.r,Q.c,Q.e].reduce(function(_t,je){return _t&&je?_t+"|"+b(je):je?b(je):_t},""),pe=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+b(G.tags[1])+")","g"),Re=new RegExp("([^]*?)"+b(G.tags[0])+"(-|_)?\\s*("+me+")?\\s*","g"),Ue=0,Ke=!1;function Ze(_t,je){var qe,Be={f:[]},ot=0,Fe="c";function It(Gt){var Ji=F.slice(Ue,Gt),Vt=Ji.trim();if(Fe==="f")Vt==="safe"?Be.raw=!0:G.async&&p.test(Vt)?(Vt=Vt.replace(p,""),Be.f.push([Vt,"",!0])):Be.f.push([Vt,""]);else if(Fe==="fp")Be.f[Be.f.length-1][1]+=Vt;else if(Fe==="err"){if(Vt){var Di=Ji.search(/\S/);n("invalid syntax",F,Ue+Di)}}else Be[Fe]=Vt;Ue=Gt+1}for(je==="h"||je==="b"||je==="c"?Fe="n":je==="r"&&(Be.raw=!0,je="i"),pe.lastIndex=Ue;(qe=pe.exec(F))!==null;){var At=qe[1],Ut=qe[2],ci=qe[3],st=qe[4],Bt=qe[5],at=qe.index;if(At)At==="("?(ot===0&&(Fe==="n"?(It(at),Fe="p"):Fe==="f"&&(It(at),Fe="fp")),ot++):At===")"?--ot===0&&Fe!=="c"&&(It(at),Fe="err"):ot===0&&At==="|"?(It(at),Fe="f"):At==="=>"&&(It(at),Ue+=1,Fe="res");else if(Ut)if(Ut==="/*"){var $t=F.indexOf("*/",pe.lastIndex);$t===-1&&n("unclosed comment",F,qe.index),pe.lastIndex=$t+2}else Ut==="'"?(g.lastIndex=qe.index,g.exec(F)?pe.lastIndex=g.lastIndex:n("unclosed string",F,qe.index)):Ut==='"'?(A.lastIndex=qe.index,A.exec(F)?pe.lastIndex=A.lastIndex:n("unclosed string",F,qe.index)):Ut==="`"&&(m.lastIndex=qe.index,m.exec(F)?pe.lastIndex=m.lastIndex:n("unclosed string",F,qe.index));else if(ci)return It(at),Ue=at+qe[0].length,Re.lastIndex=Ue,Ke=Bt,st&&je==="h"&&(je="s"),Be.t=je,Be}return n("unclosed tag",F,_t),Be}var pt=function _t(je,qe){je.b=[],je.d=[];var Be,ot=!1,Fe=[];function It(Di,ns){Di&&(Di=function(ui,Sr,Ls,Cs){var sr,ue;return typeof Sr.autoTrim=="string"?sr=ue=Sr.autoTrim:Array.isArray(Sr.autoTrim)&&(sr=Sr.autoTrim[1],ue=Sr.autoTrim[0]),(Ls||Ls===!1)&&(sr=Ls),(Cs||Cs===!1)&&(ue=Cs),sr==="slurp"&&ue==="slurp"?ui.trim():(sr==="_"||sr==="slurp"?ui=String.prototype.trimLeft?ui.trimLeft():ui.replace(/^[\s\uFEFF\xA0]+/,""):sr!=="-"&&sr!=="nl"||(ui=ui.replace(/^(?:\n|\r|\r\n)/,"")),ue==="_"||ue==="slurp"?ui=String.prototype.trimRight?ui.trimRight():ui.replace(/[\s\uFEFF\xA0]+$/,""):ue!=="-"&&ue!=="nl"||(ui=ui.replace(/(?:\n|\r|\r\n)$/,"")),ui)}(Di,G,Ke,ns))&&(Di=Di.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),Fe.push(Di))}for(;(Be=Re.exec(F))!==null;){var At,Ut=Be[1],ci=Be[2],st=Be[3]||"";for(var Bt in Q)if(Q[Bt]===st){At=Bt;break}It(Ut,ci),Ue=Be.index+Be[0].length,At||n("unrecognized tag type: "+st,F,Ue);var at=Ze(Be.index,At),$t=at.t;if($t==="h"){var Gt=at.n||"";G.async&&p.test(Gt)&&(at.a=!0,at.n=Gt.replace(p,"")),at=_t(at),Fe.push(at)}else if($t==="c"){if(je.n===at.n)return ot?(ot.d=Fe,je.b.push(ot)):je.d=Fe,je;n("Helper start and end don't match",F,Be.index+Be[0].length)}else if($t==="b"){ot?(ot.d=Fe,je.b.push(ot)):je.d=Fe;var Ji=at.n||"";G.async&&p.test(Ji)&&(at.a=!0,at.n=Ji.replace(p,"")),ot=at,Fe=[]}else if($t==="s"){var Vt=at.n||"";G.async&&p.test(Vt)&&(at.a=!0,at.n=Vt.replace(p,"")),Fe.push(at)}else Fe.push(at)}if(!qe)throw i('unclosed helper "'+je.n+'"');return It(F.slice(Ue,F.length),!1),je.d=Fe,je}({f:[]},!0);if(G.plugins)for(var ft=0;ft<G.plugins.length;ft++){var Kt=G.plugins[ft];Kt.processAST&&(pt.d=Kt.processAST(pt.d,G))}return pt.d}function w(F,G){var Q=S(F,G),me="var tR='';"+(G.useWith?"with("+G.varName+"||{}){":"")+O(Q,G)+"if(cb){cb(null,tR)} return tR"+(G.useWith?"}":"");if(G.plugins)for(var pe=0;pe<G.plugins.length;pe++){var Re=G.plugins[pe];Re.processFnString&&(me=Re.processFnString(me,G))}return me}function P(F,G){for(var Q=0;Q<G.length;Q++){var me=G[Q][0],pe=G[Q][1];F=(G[Q][2]?"await ":"")+"c.l('F','"+me+"')("+F,pe&&(F+=","+pe),F+=")"}return F}function $(F,G,Q,me,pe,Re){var Ue="{exec:"+(pe?"async ":"")+I(Q,G,F)+",params:["+me+"]";return Re&&(Ue+=",name:'"+Re+"'"),pe&&(Ue+=",async:true"),Ue+="}"}function N(F,G){for(var Q="[",me=0;me<F.length;me++){var pe=F[me];Q+=$(G,pe.res||"",pe.d,pe.p||"",pe.a,pe.n),me<F.length&&(Q+=",")}return Q+="]"}function I(F,G,Q){return"function("+G+"){var tR='';"+O(F,Q)+"return tR}"}function O(F,G){for(var Q=0,me=F.length,pe="";Q<me;Q++){var Re=F[Q];if(typeof Re=="string")pe+="tR+='"+Re+"';";else{var Ue=Re.t,Ke=Re.c||"",Ze=Re.f,pt=Re.n||"",ft=Re.p||"",Kt=Re.res||"",_t=Re.b,je=!!Re.a;if(Ue==="i"){G.defaultFilter&&(Ke="c.l('F','"+G.defaultFilter+"')("+Ke+")");var qe=P(Ke,Ze);!Re.raw&&G.autoEscape&&(qe="c.l('F','e')("+qe+")"),pe+="tR+="+qe+";"}else if(Ue==="h")if(G.storage.nativeHelpers.get(pt))pe+=G.storage.nativeHelpers.get(pt)(Re,G);else{var Be=(je?"await ":"")+"c.l('H','"+pt+"')("+$(G,Kt,Re.d,ft,je);Be+=_t?","+N(_t,G):",[]",pe+="tR+="+P(Be+=",c)",Ze)+";"}else Ue==="s"?pe+="tR+="+P((je?"await ":"")+"c.l('H','"+pt+"')({params:["+ft+"]},[],c)",Ze)+";":Ue==="e"&&(pe+=Ke+`
|
85
|
+
`)}}return pe}var K=function(){function F(G){this.cache=G}return F.prototype.define=function(G,Q){this.cache[G]=Q},F.prototype.get=function(G){return this.cache[G]},F.prototype.remove=function(G){delete this.cache[G]},F.prototype.reset=function(){this.cache={}},F.prototype.load=function(G){d(this.cache,G,!0)},F}();function U(F,G,Q,me){if(G&&G.length>0)throw i((me?"Native":"")+"Helper '"+F+"' doesn't accept blocks");if(Q&&Q.length>0)throw i((me?"Native":"")+"Helper '"+F+"' doesn't accept filters")}var re={"&":"&","<":"<",">":">",'"':""","'":"'"};function ne(F){return re[F]}var Y=new K({}),Ee=new K({each:function(F,G){var Q="",me=F.params[0];if(U("each",G,!1),F.async)return new Promise(function(Re){(function Ue(Ke,Ze,pt,ft,Kt){pt(Ke[Ze],Ze).then(function(_t){ft+=_t,Ze===Ke.length-1?Kt(ft):Ue(Ke,Ze+1,pt,ft,Kt)})})(me,0,F.exec,Q,Re)});for(var pe=0;pe<me.length;pe++)Q+=F.exec(me[pe],pe);return Q},foreach:function(F,G){var Q=F.params[0];if(U("foreach",G,!1),F.async)return new Promise(function(Re){(function Ue(Ke,Ze,pt,ft,Kt,_t){ft(Ze[pt],Ke[Ze[pt]]).then(function(je){Kt+=je,pt===Ze.length-1?_t(Kt):Ue(Ke,Ze,pt+1,ft,Kt,_t)})})(Q,Object.keys(Q),0,F.exec,"",Re)});var me="";for(var pe in Q)h(Q,pe)&&(me+=F.exec(pe,Q[pe]));return me},include:function(F,G,Q){U("include",G,!1);var me=Q.storage.templates.get(F.params[0]);if(!me)throw i('Could not fetch template "'+F.params[0]+'"');return me(F.params[1],Q)},extends:function(F,G,Q){var me=F.params[1]||{};me.content=F.exec();for(var pe=0;pe<G.length;pe++){var Re=G[pe];me[Re.name]=Re.exec()}var Ue=Q.storage.templates.get(F.params[0]);if(!Ue)throw i('Could not fetch template "'+F.params[0]+'"');return Ue(me,Q)},useScope:function(F,G){return U("useScope",G,!1),F.exec(F.params[0])}}),ce=new K({if:function(F,G){U("if",!1,F.f,!0);var Q="if("+F.p+"){"+O(F.d,G)+"}";if(F.b)for(var me=0;me<F.b.length;me++){var pe=F.b[me];pe.n==="else"?Q+="else{"+O(pe.d,G)+"}":pe.n==="elif"&&(Q+="else if("+pe.p+"){"+O(pe.d,G)+"}")}return Q},try:function(F,G){if(U("try",!1,F.f,!0),!F.b||F.b.length!==1||F.b[0].n!=="catch")throw i("native helper 'try' only accepts 1 block, 'catch'");var Q="try{"+O(F.d,G)+"}",me=F.b[0];return Q+="catch"+(me.res?"("+me.res+")":"")+"{"+O(me.d,G)+"}"},block:function(F,G){return U("block",F.b,F.f,!0),"if(!"+G.varName+"["+F.p+"]){tR+=("+I(F.d,"",G)+")()}else{tR+="+G.varName+"["+F.p+"]}"}}),we=new K({e:function(F){var G=String(F);return/[&<>"']/.test(G)?G.replace(/[&<>"']/g,ne):G}}),Oe={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(F,G){if(F==="H"){var Q=this.storage.helpers.get(G);if(Q)return Q;throw i("Can't find helper '"+G+"'")}if(F==="F"){var me=this.storage.filters.get(G);if(me)return me;throw i("Can't find filter '"+G+"'")}},async:!1,storage:{helpers:Ee,nativeHelpers:ce,filters:we,templates:Y},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function B(F,G){var Q={};return d(Q,Oe),G&&d(Q,G),F&&d(Q,F),Q.l.bind(Q),Q}function W(F,G){var Q=B(G||{}),me=Function;if(Q.async){if(!l)throw i("This environment doesn't support async/await");me=l}try{return new me(Q.varName,"c","cb",w(F,Q))}catch(pe){throw pe instanceof SyntaxError?i(`Bad template syntax
|
86
|
+
|
87
|
+
`+pe.message+`
|
88
|
+
`+Array(pe.message.length+1).join("=")+`
|
89
|
+
`+w(F,Q)):pe}}function ke(F,G){var Q;return G.cache&&G.name&&G.storage.templates.get(G.name)?G.storage.templates.get(G.name):(Q=typeof F=="function"?F:W(F,G),G.cache&&G.name&&G.storage.templates.define(G.name,Q),Q)}Oe.l.bind(Oe),t.compile=W,t.compileScope=O,t.compileScopeIntoFunction=I,t.compileToString=w,t.defaultConfig=Oe,t.filters=we,t.getConfig=B,t.helpers=Ee,t.nativeHelpers=ce,t.parse=S,t.render=function(F,G,Q,me){var pe=B(Q||{});if(!pe.async)return ke(F,pe)(G,pe);if(!me){if(typeof a=="function")return new a(function(Re,Ue){try{Re(ke(F,pe)(G,pe))}catch(Ke){Ue(Ke)}});throw i("Please provide a callback function, this env doesn't support Promises")}try{ke(F,pe)(G,pe,me)}catch(Re){return me(Re)}},t.templates=Y,Object.defineProperty(t,"__esModule",{value:!0})})})(oc,oc.exports);var Sa=oc.exports,ac={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof ca<"u"&&ca,i=function(){function a(){this.fetch=!1,this.DOMException=t.DOMException}return a.prototype=t,new a}();(function(a){(function(l){var h=typeof a<"u"&&a||typeof self<"u"&&self||typeof h<"u"&&h,d={searchParams:"URLSearchParams"in h,iterable:"Symbol"in h&&"iterator"in Symbol,blob:"FileReader"in h&&"Blob"in h&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in h,arrayBuffer:"ArrayBuffer"in h};function p(B){return B&&DataView.prototype.isPrototypeOf(B)}if(d.arrayBuffer)var m=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],g=ArrayBuffer.isView||function(B){return B&&m.indexOf(Object.prototype.toString.call(B))>-1};function A(B){if(typeof B!="string"&&(B=String(B)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(B)||B==="")throw new TypeError('Invalid character in header field name: "'+B+'"');return B.toLowerCase()}function x(B){return typeof B!="string"&&(B=String(B)),B}function b(B){var W={next:function(){var ke=B.shift();return{done:ke===void 0,value:ke}}};return d.iterable&&(W[Symbol.iterator]=function(){return W}),W}function S(B){this.map={},B instanceof S?B.forEach(function(W,ke){this.append(ke,W)},this):Array.isArray(B)?B.forEach(function(W){this.append(W[0],W[1])},this):B&&Object.getOwnPropertyNames(B).forEach(function(W){this.append(W,B[W])},this)}S.prototype.append=function(B,W){B=A(B),W=x(W);var ke=this.map[B];this.map[B]=ke?ke+", "+W:W},S.prototype.delete=function(B){delete this.map[A(B)]},S.prototype.get=function(B){return B=A(B),this.has(B)?this.map[B]:null},S.prototype.has=function(B){return this.map.hasOwnProperty(A(B))},S.prototype.set=function(B,W){this.map[A(B)]=x(W)},S.prototype.forEach=function(B,W){for(var ke in this.map)this.map.hasOwnProperty(ke)&&B.call(W,this.map[ke],ke,this)},S.prototype.keys=function(){var B=[];return this.forEach(function(W,ke){B.push(ke)}),b(B)},S.prototype.values=function(){var B=[];return this.forEach(function(W){B.push(W)}),b(B)},S.prototype.entries=function(){var B=[];return this.forEach(function(W,ke){B.push([ke,W])}),b(B)},d.iterable&&(S.prototype[Symbol.iterator]=S.prototype.entries);function w(B){if(B.bodyUsed)return Promise.reject(new TypeError("Already read"));B.bodyUsed=!0}function P(B){return new Promise(function(W,ke){B.onload=function(){W(B.result)},B.onerror=function(){ke(B.error)}})}function $(B){var W=new FileReader,ke=P(W);return W.readAsArrayBuffer(B),ke}function N(B){var W=new FileReader,ke=P(W);return W.readAsText(B),ke}function I(B){for(var W=new Uint8Array(B),ke=new Array(W.length),F=0;F<W.length;F++)ke[F]=String.fromCharCode(W[F]);return ke.join("")}function O(B){if(B.slice)return B.slice(0);var W=new Uint8Array(B.byteLength);return W.set(new Uint8Array(B)),W.buffer}function K(){return this.bodyUsed=!1,this._initBody=function(B){this.bodyUsed=this.bodyUsed,this._bodyInit=B,B?typeof B=="string"?this._bodyText=B:d.blob&&Blob.prototype.isPrototypeOf(B)?this._bodyBlob=B:d.formData&&FormData.prototype.isPrototypeOf(B)?this._bodyFormData=B:d.searchParams&&URLSearchParams.prototype.isPrototypeOf(B)?this._bodyText=B.toString():d.arrayBuffer&&d.blob&&p(B)?(this._bodyArrayBuffer=O(B.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):d.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(B)||g(B))?this._bodyArrayBuffer=O(B):this._bodyText=B=Object.prototype.toString.call(B):this._bodyText="",this.headers.get("content-type")||(typeof B=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):d.searchParams&&URLSearchParams.prototype.isPrototypeOf(B)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},d.blob&&(this.blob=function(){var B=w(this);if(B)return B;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 B=w(this);return B||(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($)}),this.text=function(){var B=w(this);if(B)return B;if(this._bodyBlob)return N(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(I(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},d.formData&&(this.formData=function(){return this.text().then(Y)}),this.json=function(){return this.text().then(JSON.parse)},this}var U=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function re(B){var W=B.toUpperCase();return U.indexOf(W)>-1?W:B}function ne(B,W){if(!(this instanceof ne))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');W=W||{};var ke=W.body;if(B instanceof ne){if(B.bodyUsed)throw new TypeError("Already read");this.url=B.url,this.credentials=B.credentials,W.headers||(this.headers=new S(B.headers)),this.method=B.method,this.mode=B.mode,this.signal=B.signal,!ke&&B._bodyInit!=null&&(ke=B._bodyInit,B.bodyUsed=!0)}else this.url=String(B);if(this.credentials=W.credentials||this.credentials||"same-origin",(W.headers||!this.headers)&&(this.headers=new S(W.headers)),this.method=re(W.method||this.method||"GET"),this.mode=W.mode||this.mode||null,this.signal=W.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&ke)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(ke),(this.method==="GET"||this.method==="HEAD")&&(W.cache==="no-store"||W.cache==="no-cache")){var F=/([?&])_=[^&]*/;if(F.test(this.url))this.url=this.url.replace(F,"$1_="+new Date().getTime());else{var G=/\?/;this.url+=(G.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}ne.prototype.clone=function(){return new ne(this,{body:this._bodyInit})};function Y(B){var W=new FormData;return B.trim().split("&").forEach(function(ke){if(ke){var F=ke.split("="),G=F.shift().replace(/\+/g," "),Q=F.join("=").replace(/\+/g," ");W.append(decodeURIComponent(G),decodeURIComponent(Q))}}),W}function Ee(B){var W=new S,ke=B.replace(/\r?\n[\t ]+/g," ");return ke.split("\r").map(function(F){return F.indexOf(`
|
90
|
+
`)===0?F.substr(1,F.length):F}).forEach(function(F){var G=F.split(":"),Q=G.shift().trim();if(Q){var me=G.join(":").trim();W.append(Q,me)}}),W}K.call(ne.prototype);function ce(B,W){if(!(this instanceof ce))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');W||(W={}),this.type="default",this.status=W.status===void 0?200:W.status,this.ok=this.status>=200&&this.status<300,this.statusText=W.statusText===void 0?"":""+W.statusText,this.headers=new S(W.headers),this.url=W.url||"",this._initBody(B)}K.call(ce.prototype),ce.prototype.clone=function(){return new ce(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new S(this.headers),url:this.url})},ce.error=function(){var B=new ce(null,{status:0,statusText:""});return B.type="error",B};var we=[301,302,303,307,308];ce.redirect=function(B,W){if(we.indexOf(W)===-1)throw new RangeError("Invalid status code");return new ce(null,{status:W,headers:{location:B}})},l.DOMException=h.DOMException;try{new l.DOMException}catch{l.DOMException=function(W,ke){this.message=W,this.name=ke;var F=Error(W);this.stack=F.stack},l.DOMException.prototype=Object.create(Error.prototype),l.DOMException.prototype.constructor=l.DOMException}function Oe(B,W){return new Promise(function(ke,F){var G=new ne(B,W);if(G.signal&&G.signal.aborted)return F(new l.DOMException("Aborted","AbortError"));var Q=new XMLHttpRequest;function me(){Q.abort()}Q.onload=function(){var Re={status:Q.status,statusText:Q.statusText,headers:Ee(Q.getAllResponseHeaders()||"")};Re.url="responseURL"in Q?Q.responseURL:Re.headers.get("X-Request-URL");var Ue="response"in Q?Q.response:Q.responseText;setTimeout(function(){ke(new ce(Ue,Re))},0)},Q.onerror=function(){setTimeout(function(){F(new TypeError("Network request failed"))},0)},Q.ontimeout=function(){setTimeout(function(){F(new TypeError("Network request failed"))},0)},Q.onabort=function(){setTimeout(function(){F(new l.DOMException("Aborted","AbortError"))},0)};function pe(Re){try{return Re===""&&h.location.href?h.location.href:Re}catch{return Re}}Q.open(G.method,pe(G.url),!0),G.credentials==="include"?Q.withCredentials=!0:G.credentials==="omit"&&(Q.withCredentials=!1),"responseType"in Q&&(d.blob?Q.responseType="blob":d.arrayBuffer&&G.headers.get("Content-Type")&&G.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(Q.responseType="arraybuffer")),W&&typeof W.headers=="object"&&!(W.headers instanceof S)?Object.getOwnPropertyNames(W.headers).forEach(function(Re){Q.setRequestHeader(Re,x(W.headers[Re]))}):G.headers.forEach(function(Re,Ue){Q.setRequestHeader(Ue,Re)}),G.signal&&(G.signal.addEventListener("abort",me),Q.onreadystatechange=function(){Q.readyState===4&&G.signal.removeEventListener("abort",me)}),Q.send(typeof G._bodyInit>"u"?null:G._bodyInit)})}return Oe.polyfill=!0,h.fetch||(h.fetch=Oe,h.Headers=S,h.Request=ne,h.Response=ce),l.Headers=S,l.Request=ne,l.Response=ce,l.fetch=Oe,l})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var n=t.fetch?t:i;e=n.fetch,e.default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,s.exports=e})(ac,ac.exports);var C1=ac.exports;const I1=ua(C1);function lc({canvas:s,scenes:e,currentTime:t}){if(e&&s){const i=e.scenes.filter(({start:a,duration:l})=>t>=a&&t<=a+l);if(i.length<=0)return;const n=s.getContext("2d");if(n){const a=e.transitionDuration,l=Math.max(...e.scenes.map(({start:h,duration:d})=>h+d));n.globalCompositeOperation="lighter",n.clearRect(0,0,s.width,s.height),i.forEach(({start:h,duration:d,draw:p,transitionCanvas:m})=>{if(n.globalAlpha=1,m.width=m.height=0,m.width=s.width,m.height=s.height,m.getContext("2d")){const A=h+d,x=h===0,b=A===l;p({currentTime:t,canvas:m}),!x&&t>=h&&t<=h+a?n.globalAlpha=Math.max(0,Math.min(1,(t-h)/a)):!b&&t>=A-a&&t<=A&&(n.globalAlpha=Math.max(0,Math.min(1,(A-t)/a))),n.drawImage(m,0,0,s.width,s.height)}})}}}function D1(s){if(typeof s=="string"){const[e,t]=s.split(":");return Math.min(parseFloat(e),parseFloat(t))}return s}function O1(s){if(typeof s=="string"){const[e,t]=s.split(":"),i=parseFloat(e),n=parseFloat(t);return i/n}return s}function cc({resolution:s,aspectRatio:e}){const t=D1(s),i=O1(e),n=i>=1,a=Math.min(n?t*i:t/i,t),l=Math.max(n?t*i:t/i,t);return{resolution:t,aspectRatio:i,height:n?a:l,width:n?l:a}}function P1({format:s,resolution:e,aspectRatio:t,sourceWidth:i,sourceHeight:n}){const{width:a,height:l}=cc({resolution:e,aspectRatio:t}),h=i/n,d=t>h;let p=1;if(s==="letterbox"||s==="letterbox-video")p=d?l/n:a/i;else if(s==="squarebox"){const b=Math.min(l,a);p=i>=n?b/n:b/i}else s==="crop"&&(p=d?a/i:l/n);const m=a/p,g=l/p,A=(i-m)/2,x=(n-g)/2;return{sx:A,sy:x,sWidth:m,sHeight:g,scale:p}}function Eo({source:s,sx:e,sy:t,sw:i,sh:n,dx:a,dy:l,dw:h,dh:d}){const p=(s==null?void 0:s.naturalWidth)??(s==null?void 0:s.videoWidth)??(s==null?void 0:s.width),m=(s==null?void 0:s.naturalHeight)??(s==null?void 0:s.videoHeight)??(s==null?void 0:s.height);e=e??0,t=t??0,i=i??p,n=n??m,i<0&&(e+=i,i=Math.abs(i)),n<0&&(t+=n,n=Math.abs(n)),h<0&&(a+=h,h=Math.abs(h)),d<0&&(l+=d,d=Math.abs(d));const g=Math.max(e,0),A=Math.min(e+i,p),x=Math.max(t,0),b=Math.min(t+n,m),S=h/i,w=d/n;return[s,g,x,A-g,b-x,e<0?a-e*S:a,t<0?l-t*w:l,(A-g)*S,(b-x)*w]}function $0({context:s,source:e,crop:t,format:i="letterbox",posX:n,posY:a,drawAreaWidth:l,drawAreaHeight:h,sourceWidth:d,sourceHeight:p,cropCanvas:m,letterboxCanvas:g}){const{x:A,y:x,width:b,height:S}=t??{},w=d*(A??0),P=p*(x??0),$=d*Math.min(1-(A??0),b??1),N=p*Math.min(1-(x??0),S??1),I=m.getContext("2d");if(I){m.width=$,m.height=N;const W=Eo({source:e,sx:w,sy:P,sw:$,sh:N,dx:0,dy:0,dw:$,dh:N});I.drawImage(...W)}const O=$/N,{sx:K,sy:U,sWidth:re,sHeight:ne,scale:Y}=P1({resolution:Math.min(l,h),aspectRatio:l/h,format:i,sourceWidth:$,sourceHeight:N}),Ee=m&&typeof s.filter<"u";if(i==="letterbox"||i==="squarebox"||i==="letterbox-video"&&!Ee){if(K<0){const W=Math.abs(K)*Y;s.fillStyle="black",s.beginPath(),s.rect(n,a,W,h),s.rect(n+l-W,a,W,h),s.fill(),s.closePath()}if(U<0){const W=Math.abs(U)*Y;s.fillStyle="black",s.beginPath(),s.rect(n,a,l,W),s.rect(n,a+h-W,l,W),s.fill(),s.closePath()}}if(i==="letterbox-video"&&Ee){const W=g.getContext("2d");if(W){g.width=$,g.height=N,s.save(),s.globalCompositeOperation="destination-out",s.fillRect(n,a,l,h);const ke=Eo({source:m,sx:K,sy:U,sw:re,sh:ne,dx:n,dy:a,dw:l,dh:h});s.globalCompositeOperation="source-over",s.drawImage(...ke),W.save();const F=1.2,G=-($*F-$)/2,Q=-(N*F-N)/2,me=Math.min($/20,N/20);if(W.filter=`blur(${me}px) brightness(20%)`,W.translate(G,Q),W.scale(F,F),W.drawImage(m,0,0,$,N),W.restore(),s.globalCompositeOperation="destination-over",K<0){const pe=l/O,Re=h/pe,Ue=Eo({source:g,sy:(1-Re)*N/2,sh:Re*N,dx:n,dy:a,dw:l,dh:h});s.drawImage(...Ue)}if(U<0){const pe=h*O,Re=l/pe,Ue=Eo({source:g,sx:(1-Re)*$/2,sw:Re*$,dx:n,dy:a,dw:l,dh:h});s.drawImage(...Ue)}s.restore()}}else{const W=Eo({source:m,sx:K,sy:U,sw:re,sh:ne,dx:n,dy:a,dw:l,dh:h});s.drawImage(...W)}const ce=K*-1*Y,we=U*-1*Y,Oe=l-ce*2,B=h-we*2;return{dx:ce,dy:we,dw:Oe,dh:B}}function M0({context:s,word:e,maxW:t=1/0}){const i=[],n=s.measureText(e);if(n.width<t)return[{text:e,metrics:n}];for(let a=0;a<e.length;a++){const l=i[i.length-1],h=((l==null?void 0:l.text)??"")+e[a],d=s.measureText(h);d.width<t?i[l?i.length-1:0]={text:h,metrics:d}:i.push({text:e[a],metrics:s.measureText(e[a])})}return i}const F0=Kl(({font:s,scale:e,context:t,maxW:i,maxH:n,text:a,minSize:l,maxSize:h})=>{var d,p;let m=0;if(h){m=(l??0)*e;let A=0;for(;h*e>m+1;){m+=1;const x=Ra({context:t,font:s,fontSize:m,text:a,maxW:i});if(A=x.reduce((b,S)=>(S.metrics.width>b&&(b=S.metrics.width),b),0),A>i||x.length*m>n){m-=1;break}}}else m=parseFloat(((p=(d=s.match(_a))==null?void 0:d.groups)==null?void 0:p.value)??"0")*e;return m},{cacheKey:([{font:s,text:e,minSize:t,maxSize:i,scale:n,maxW:a,maxH:l}])=>`${s}_${e}_${t}_${i}_${n}_${a}_${l}`});function $1(s,e){return typeof s=="number"?{top:s*e,right:s*e,bottom:s*e,left:s*e}:{top:typeof s.top=="number"?s.top*e:s.top,right:typeof s.right=="number"?s.right*e:s.right,bottom:typeof s.bottom=="number"?s.bottom*e:s.bottom,left:typeof s.left=="number"?s.left*e:s.left}}function N0(s,e){return typeof s=="number"?{top:s*e,right:s*e,bottom:s*e,left:s*e}:{top:(typeof s.top=="number"?s.top*e:s.top)??0,right:(typeof s.right=="number"?s.right*e:s.right)??0,bottom:(typeof s.bottom=="number"?s.bottom*e:s.bottom)??0,left:(typeof s.left=="number"?s.left*e:s.left)??0}}function U0(s,{layout:e,scale:t=1}){const{position:i="static",inset:n,width:a,height:l,minWidth:h,minHeight:d,maxWidth:p,maxHeight:m,flex:g,gap:A,margin:x,padding:b,direction:S="column",align:w="start",alignSelf:P,justify:$="start"}=e,N={static:bt.PositionType.Static,relative:bt.PositionType.Relative,absolute:bt.PositionType.Absolute};if(s.setPositionType(N[i]),n){const{top:U,right:re,bottom:ne,left:Y}=$1(n,t);U&&s.setPosition(bt.Edge.Top,U),re&&s.setPosition(bt.Edge.Right,re),ne&&s.setPosition(bt.Edge.Bottom,ne),Y&&s.setPosition(bt.Edge.Left,Y)}const I={row:bt.FlexDirection.Row,column:bt.FlexDirection.Column,"row-reverse":bt.FlexDirection.RowReverse,"column-reverse":bt.FlexDirection.ColumnReverse};s.setFlexDirection(I[S]);const O={start:bt.Align.FlexStart,end:bt.Align.FlexEnd,center:bt.Align.Center,stretch:bt.Align.Stretch};s.setAlignItems(O[w]),P&&s.setAlignSelf(O[P]);const K={start:bt.Justify.FlexStart,end:bt.Justify.FlexEnd,center:bt.Justify.Center,"space-between":bt.Justify.SpaceBetween,"space-around":bt.Justify.SpaceAround,"space-evenly":bt.Justify.SpaceEvenly};if(s.setJustifyContent(K[$]),x){const{top:U,right:re,bottom:ne,left:Y}=N0(x,t);s.setMargin(bt.Edge.Top,U),s.setMargin(bt.Edge.Right,re),s.setMargin(bt.Edge.Bottom,ne),s.setMargin(bt.Edge.Left,Y)}if(b){const{top:U,right:re,bottom:ne,left:Y}=N0(b,t);s.setPadding(bt.Edge.Top,U),s.setPadding(bt.Edge.Right,re),s.setPadding(bt.Edge.Bottom,ne),s.setPadding(bt.Edge.Left,Y)}g&&s.setFlex(g),s.setGap(bt.Gutter.All,(A??0)*t),a&&s.setWidth(typeof a=="number"?a*t:a),l&&(typeof l=="function"?s.setHeight("100%"):s.setHeight(typeof l=="number"?l*t:l)),h&&s.setMinWidth(typeof h=="number"?h*t:h),d&&s.setMinHeight(typeof d=="number"?d*t:d),p&&s.setMaxWidth(typeof p=="number"?p*t:p),m&&s.setMaxHeight(typeof m=="number"?m*t:m)}function B0({canvas:s,debug:e=!1,scale:t=1,position:i=[]}){i.forEach(({x:n,y:a,width:l,height:h,childNodes:d,element:p})=>{const m=s.getContext("2d",{alpha:!1});if(m){const{draw:g}=p;g&&(m.save(),g({scale:t,dx:n,dy:a,dw:l,dh:h}),e&&(m.strokeStyle="red",m.strokeRect(n,a,l,h))),B0({canvas:s,debug:e,scale:t,position:d}),m.restore()}})}function G0(s,e,t){const i=e.map((n,a)=>{const l=h0.Node.create(),{radius:h,elements:d=[],draw:p,...m}=n;return U0(l,{layout:m,scale:t}),s.insertChild(l,a),{node:l,element:n,childNodes:G0(l,d,t)}});return s.calculateLayout(),i}function V0(s,e,t=0,i=0){const{top:n,left:a}=s.getComputedLayout();return e.map(({node:l,element:h,childNodes:d})=>{const{top:p,left:m,width:g,height:A}=l.getComputedLayout(),x=t+m,b=i+p;return{x:a+x,y:n+b,width:g,height:A,element:h,childNodes:V0(s,d,x,b)}})}function H0(s,e){s.forEach(({node:t,element:i,childNodes:n})=>{const{height:a}=i;if(a&&typeof a=="function"){const l=t.getComputedWidth(),h=t.getComputedHeight(),d=a({width:l,maxHeight:h,scale:e});t.setHeight(d)}H0(n,e)})}function M1({canvas:s,origin:e,elements:t,...i}){const n={inset:{top:0,left:0},width:s.width,height:s.height,...e},a=h0.Node.create();U0(a,{layout:n}),a.calculateLayout();const{width:l,height:h}=a.getComputedLayout(),d=Math.min(l,h)/1080,p=G0(a,t,d);H0(p,d),a.calculateLayout();const m=V0(a,p);return B0({...i,scale:d,canvas:s,position:m})}const F1={linear:c1,easeIn:sc,easeInOut:h1,easeOut:u1,circIn:O0,circInOut:f1,circOut:P0,backIn:nc,backInOut:p1,backOut:d1,anticipate:m1,bounceIn:A1,bounceInOut:E1,bounceOut:Ta},ka=Kl((s,e,{clamp:t=!0,ease:i="easeIn",...n}={})=>r1(s,e,{...n,clamp:t,ease:F1[i]}),{cacheKey:([s,e,t])=>JSON.stringify({from:s,to:e,options:t})}),W0=[{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 wa({text:s,font:e}){let t=e;return W0.forEach(({family:i,regex:n})=>{n.exec(s)&&(t+=`, ${i}`)}),t}const Qr=1.8,_a=/(?<value>\d+\.?\d*)(?=px)/;function N1(s,e=1){return typeof s=="number"?{topLeft:s*e,topRight:s*e,bottomRight:s*e,bottomLeft:s*e}:{topLeft:((s==null?void 0:s.topLeft)??0)*e,topRight:((s==null?void 0:s.topRight)??0)*e,bottomRight:((s==null?void 0:s.bottomRight)??0)*e,bottomLeft:((s==null?void 0:s.bottomLeft)??0)*e}}function j0(s){const{visible:e,node:t}=s,i=[...(t==null?void 0:t.elements)??[],...(s==null?void 0:s.elements)??[]];return e??(t&&t.type!=="box"&&t.type!=="gradient"?!!t.value:i==null?void 0:i.some(n=>j0(n)))}function K0({debug:s=!1,canvas:e,cropCanvas:t,posterCanvas:i,letterboxCanvas:n,elements:a=[],currentTime:l,contentTime:h,sceneTime:d,totalDuration:p,contentDuration:m,sceneDuration:g}){return a.map(A=>{var x,b,S,w,P,$,N,I;const{node:O,transient:K=[{from:0,duration:1/0}]}=A,U=e.getContext("2d"),re={total:l,content:h,scene:d},ne={total:p,content:m,scene:g},Y=K.reduce((Ee,{type:ce="scene",from:we,duration:Oe,animation:B})=>{const W=we<0?ne[ce]+we:we;return re[ce]>=W&&re[ce]<=W+Oe&&Ee.push({type:ce,animation:B,duration:Oe,from:W}),Ee},[]);if(U&&Y.length>0&&j0(A)){let Ee=A.width,ce=A.height;if((O==null?void 0:O.type)==="text"&&O.value){const{align:we="left"}=O,Oe=wa({text:O.value,font:O.font});U.save(),U.font=Oe,U.textBaseline="top",U.textAlign=we,O.wrap?ce=({width:B,maxHeight:W,scale:ke})=>{var F,G;const Q=F0({font:Oe,scale:ke,context:U,maxW:B,maxH:W,text:O.value??"",minSize:(F=O.fill)==null?void 0:F.minSize,maxSize:(G=O.fill)==null?void 0:G.maxSize});return Ra({context:U,font:Oe,fontSize:Q,text:O.value??"",maxW:B}).length*Q}:(Ee=U.measureText(O.value).width,ce=parseFloat(((b=(x=Oe.match(_a))==null?void 0:x.groups)==null?void 0:b.value)??"0")),U.restore()}if((O==null?void 0:O.type)==="image"&&O.image&&O.size){const we=((S=O.image)==null?void 0:S.naturalWidth)??((w=O.image)==null?void 0:w.width),Oe=((P=O.image)==null?void 0:P.naturalHeight)??(($=O.image)==null?void 0:$.height),B=we/Oe,W=(N=O.size)==null?void 0:N.width,ke=(I=O.size)==null?void 0:I.height;Ee=W??(B>=1?(ke??0)*B:(ke??0)/B),ce=ke??(B<1?(W??0)*B:(W??0)/B)}return{...A,width:Ee,height:ce,elements:K0({debug:s,canvas:e,cropCanvas:t,posterCanvas:i,letterboxCanvas:n,elements:A.elements,currentTime:l,contentTime:h,sceneTime:d,totalDuration:p,contentDuration:m,sceneDuration:g}),draw:({dx:we,dy:Oe,dw:B,dh:W,scale:ke})=>{var F,G,Q,me,pe,Re,Ue,Ke,Ze,pt,ft,Kt,_t;if(Y.forEach(je=>{const{type:qe="scene",from:Be,duration:ot,animation:Fe={type:"fade",duration:.3333333333333333,easing:{in:"easeOut",out:"easeOut"}}}=je;if(Fe){const{type:It,duration:At,easing:{in:Ut="easeOut",out:ci="easeOut"}={}}=Fe;if(Be>0&&re[qe]<=Be+At)switch(It){case"fade":{const st=ka([Be,Be+At],[0,1],{ease:Ut});U.globalAlpha=st(re[qe]);break}case"slide":{const{options:st}=Fe,Bt={up:[{x:0,y:W},{x:0,y:0}],right:[{x:B,y:0},{x:0,y:0}],down:[{x:0,y:-W},{x:0,y:0}],left:[{x:-B,y:0},{x:0,y:0}]},at=ka([Be,Be+At],Bt[st.direction.in],{ease:Ut}),{x:$t,y:Gt}=at(re[qe]);U.translate($t,Gt);break}}if(Be+ot<ne[qe]&&Be+ot-At<=re[qe])switch(It){case"fade":{const st=ka([Be+ot-At,Be+ot],[1,0],{ease:ci});U.globalAlpha=st(re[qe]);break}case"slide":{const{options:st}=Fe,Bt={up:[{x:0,y:0},{x:0,y:-W}],right:[{x:0,y:0},{x:B,y:0}],down:[{x:0,y:0},{x:0,y:W}],left:[{x:0,y:0},{x:-B,y:0}]},at=ka([Be+ot-At,Be+ot],Bt[st.direction.out],{ease:ci}),{x:$t,y:Gt}=at(re[qe]);U.translate($t,Gt);break}}}}),O){const{type:je}=O;if(A.radius){const{topLeft:qe,topRight:Be,bottomRight:ot,bottomLeft:Fe}=N1(A.radius,ke);U.beginPath(),U.moveTo(we+Math.min(W/Qr,qe),Oe),U.lineTo(we+B-Math.min(W/Qr,Be),Oe),U.quadraticCurveTo(we+B,Oe,we+B,Oe+Math.min(W/Qr,Be)),U.lineTo(we+B,Oe+W-Math.min(W/Qr,ot)),U.quadraticCurveTo(we+B,Oe+W,we+B-Math.min(W/Qr,ot),Oe+W),U.lineTo(we+Math.min(W/Qr,Fe),Oe+W),U.quadraticCurveTo(we,Oe+W,we,Oe+W-Math.min(W/Qr,Fe)),U.lineTo(we,Oe+Math.min(W/Qr,qe)),U.quadraticCurveTo(we,Oe,we+Math.min(W/Qr,qe),Oe),U.closePath(),s&&(U.strokeStyle="blue",U.stroke()),U.clip()}if(je==="box"&&(U.fillStyle=O.background,U.fillRect(we,Oe,B,W)),je==="text"&&O.value){const{align:qe="left"}=O,Be=wa({text:O.value,font:O.font}),ot=F0({font:Be,scale:ke,context:U,maxW:B,maxH:W,text:O.value??"",minSize:(F=O.fill)==null?void 0:F.minSize,maxSize:(G=O.fill)==null?void 0:G.maxSize});U.font=Be.replace(_a,ot.toString()),U.textBaseline="top",U.fillStyle=O.color,U.textAlign=qe;const Fe={left:we,center:we+B/2,right:we+B};O.wrap?Ra({context:U,font:Be,fontSize:ot,text:O.value,maxW:B}).forEach((At,Ut)=>{U.fillText(At.text,Fe[qe],Oe+ot*Ut)}):U.fillText(O.value,Fe[qe],Oe)}if(je==="image"&&O.image&&U.drawImage(O.image,we,Oe,B,W),je==="video"&&((Q=O.video)!=null&&Q.node||(me=O.video)!=null&&me.getSource)){const qe=O.format??"letterbox",Be=((Re=(pe=O.video)==null?void 0:pe.getSource)==null?void 0:Re.call(pe,d))??O.video.node,ot=(Be==null?void 0:Be.videoWidth)??(Be==null?void 0:Be.naturalWidth)??(Be==null?void 0:Be.width),Fe=(Be==null?void 0:Be.videoHeight)??(Be==null?void 0:Be.naturalHeight)??(Be==null?void 0:Be.height);if(ot&&Fe){const{dx:At,dy:Ut,dw:ci,dh:st}=$0({context:U,cropCanvas:t,letterboxCanvas:n,source:Be,format:qe,crop:(Ue=O==null?void 0:O.value)==null?void 0:Ue.crop,sourceWidth:ot,sourceHeight:Fe,posX:we,posY:Oe,drawAreaWidth:B,drawAreaHeight:W});O.elements&&uc({debug:s,canvas:e,cropCanvas:t,posterCanvas:i,letterboxCanvas:n,elements:O.elements,currentTime:l,contentTime:h,sceneTime:d,totalDuration:p,contentDuration:m,sceneDuration:g,origin:{inset:{top:Math.max(Oe,Oe+Ut),left:Math.max(we,we+At)},width:Math.min(B,ci),height:Math.min(W,st)}})}const It=1/3;if(O.poster&&l>=0&&l<=It){U.save(),U.globalAlpha=1-l/It;const At=((Ke=O.poster)==null?void 0:Ke.naturalWidth)??((Ze=O.poster)==null?void 0:Ze.width),Ut=((pt=O.poster)==null?void 0:pt.naturalHeight)??((ft=O.poster)==null?void 0:ft.height);i.width=i.height=0,i.width=B,i.height=W;const ci=i.getContext("2d");if(ci&&At&&Ut){const{dx:st,dy:Bt,dw:at,dh:$t}=$0({context:ci,cropCanvas:t,letterboxCanvas:n,source:O.poster,format:qe,crop:(Kt=O==null?void 0:O.value)==null?void 0:Kt.crop,sourceWidth:At,sourceHeight:Ut,posX:0,posY:0,drawAreaWidth:B,drawAreaHeight:W});O.elements&&uc({debug:s,canvas:i,cropCanvas:t,posterCanvas:i,letterboxCanvas:n,elements:O.elements,currentTime:l,contentTime:h,sceneTime:d,totalDuration:p,contentDuration:m,sceneDuration:g,origin:{inset:{top:Math.max(0,Bt),left:Math.max(0,st)},width:Math.min(B,at),height:Math.min(W,$t)}}),U.drawImage(i,we,Oe,B,W),U.restore()}}}if(je==="gradient"&&O.value){const qe=U.createLinearGradient(we+B,Oe,we+B,Oe+W);(_t=O.value)==null||_t.forEach(Be=>{qe.addColorStop(Be.percent,Be.color)}),U.fillStyle=qe,U.fillRect(we,Oe,B,W)}}}}}}).filter(Boolean)}function uc({debug:s,canvas:e,cropCanvas:t,posterCanvas:i,letterboxCanvas:n,elements:a,currentTime:l,contentTime:h,sceneTime:d,totalDuration:p,contentDuration:m,sceneDuration:g,...A}){return M1({...A,debug:s,canvas:e,elements:K0({debug:s,canvas:e,cropCanvas:t,posterCanvas:i,letterboxCanvas:n,elements:a,currentTime:l,contentTime:h,sceneTime:d,totalDuration:p,contentDuration:m,sceneDuration:g})})}const Ra=Kl(({context:s,font:e,fontSize:t,text:i,maxW:n=1/0})=>{try{return s.save(),s.font=e.replace(_a,t.toString()),i.split(`
|
91
|
+
`).flatMap(l=>{const h=l.split(" ").filter(Boolean);return h.length?h.slice(1).reduce((d,p)=>{const g=`${d[d.length-1].text} ${p}`.trim(),A=s.measureText(g);return A.width>n?d=[...d,...M0({context:s,word:p,maxW:n})]:d[d.length-1]={text:g,metrics:A},d},M0({context:s,word:h[0],maxW:n})):{text:"",metrics:s.measureText("")}})}finally{s.restore()}},{cacheKey:([{font:s,fontSize:e,text:t,maxW:i}])=>`${s}_${e}_${t}_${i}`}),U1=/\d{0,2}:?\d{2}:\d{2}\.\d{3}\s-->\s\d{0,2}:?\d{2}:\d{2}\.\d{3}\s{1,2}.*/g,B1=/\d{0,2}:?\d{2}:\d{2}\.\d{3}/g;function z0(s){if(!s)return[];const e=s.match(U1);return e?e==null?void 0:e.map(t=>{const[i,n]=t.replace(`\r
|
92
|
+
`,`
|
93
|
+
`).split(`
|
94
|
+
`),[a,l]=i.match(B1)||[];return{start:a,end:l,text:n}}):[]}function La(s){const[e,t,i]=s.split(":");return i?parseInt(e)*60*60+parseInt(t)*60+parseFloat(i):parseInt(e)*60+parseInt(t)}function G1({canvas:s,dx:e,dy:t,dw:i,dh:n,sceneTime:a,vttCaptions:l}){if(l){const d=z0(l).find(({start:p,end:m})=>p&&m&&a>=La(p)&&a<La(m));if(d){const p=s.getContext("2d");if(p){const m=Math.min(i,n),g=m*.04,A=wa({text:l,font:`400 ${g}px Roobert Captions`});p.font=A,p.textBaseline="middle";const x=i*.9,b=Ra({context:p,font:A,fontSize:g,text:d.text,maxW:x});b.forEach(({text:S,metrics:w},P)=>{const $=e+(i-w.width)/2,N=t+(n*.85-(g+m*.03)*(b.length-1-P)),I=g*.8,O=g/1.5,K=e+(i-w.width-O)/2,U=N-I,re=w.width+O,ne=I*2,Y=p.globalAlpha;p.save(),p.globalAlpha=.8*Y,p.fillStyle="#000000",p.beginPath(),p.roundRect(K,U,re,ne,m*.01),p.fill(),p.closePath(),p.globalAlpha=Y,p.fillStyle="#FFFFFF",p.fillText(S,$,N),p.restore()})}}}}const V1={id:"073977ec-6384-4329-b7c5-8275fb513e74",name:"None",entityId:"none",templateId:"a95e537e-fb4d-4d2f-9c72-86c0925c7176",templates:[{id:"046f363c-960a-449c-ae5e-984ac6ab58c2",version:"2",name:"None",entityId:"none",templateId:"a95e537e-fb4d-4d2f-9c72-86c0925c7176",layouts:[{name:"none",tree:`[
|
95
|
+
{
|
96
|
+
"width": "100%",
|
97
|
+
"height": "100%",
|
98
|
+
"node": {
|
99
|
+
"type": "video",
|
100
|
+
"format": {{ it.videoFormat }},
|
101
|
+
"value": {
|
102
|
+
"id": {{ it.id }},
|
103
|
+
"key": {{ it.key }},
|
104
|
+
"src": {{@async resolve-source({ sources: [it.mp4, it.input] }) /}},
|
105
|
+
"playlist": {{@async resolve-source({ sources: [it.playlist] }) /}},
|
106
|
+
"poster": {{ it.poster }},
|
107
|
+
"captions": {{ it.captions }},
|
108
|
+
"duration": {{ it.duration }},
|
109
|
+
"startOffset": {{ it.startOffset }},
|
110
|
+
"endOffset": {{ it.endOffset }},
|
111
|
+
"crop": {
|
112
|
+
"x": {{ it.crop?.x }},
|
113
|
+
"y": {{ it.crop?.y }},
|
114
|
+
"width": {{ it.crop?.width }},
|
115
|
+
"height": {{ it.crop?.height }}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
]`}],content:[{scenes:[{layout:"none",data:`{
|
121
|
+
"id": {{ it.root?.answer?.id }},
|
122
|
+
"key": {{ it.root?.answer?.id + '-intro' }},
|
123
|
+
"mp4": {{ it.root?.answer?.media?.video }},
|
124
|
+
"input": {{ it.root?.answer?.media?.input }},
|
125
|
+
"playlist": {{ it.root?.answer?.media?.playlist }},
|
126
|
+
"poster": {{ it.root?.answer?.media?.thumbnail }},
|
127
|
+
"captions": {{ it.root?.answer?.captions?.current }},
|
128
|
+
"duration": {{ it.root?.answer?.metadata?.duration }},
|
129
|
+
"startOffset": {{ it.root?.answer?.settings?.startOffset }},
|
130
|
+
"endOffset": {{ it.root?.answer?.settings?.endOffset }},
|
131
|
+
"crop": {
|
132
|
+
"x": {{ it.root?.answer?.settings?.crop?.x }},
|
133
|
+
"y": {{ it.root?.answer?.settings?.crop?.y }},
|
134
|
+
"width": {{ it.root?.answer?.settings?.crop?.width }},
|
135
|
+
"height": {{ it.root?.answer?.settings?.crop?.height }}
|
136
|
+
}
|
137
|
+
}`}],root:"{{ it.intro?.questions?.items }}"},{scenes:[{layout:"none",data:`{
|
138
|
+
"id": {{ it.root?.answer?.id }},
|
139
|
+
"key": {{ it.root?.answer?.id + '-' + it.index }},
|
140
|
+
"mp4": {{ it.root?.answer?.media?.video }},
|
141
|
+
"input": {{ it.root?.answer?.media?.input }},
|
142
|
+
"playlist": {{ it.root?.answer?.media?.playlist }},
|
143
|
+
"poster": {{ it.root?.answer?.media?.thumbnail }},
|
144
|
+
"captions": {{ it.root?.answer?.captions?.current }},
|
145
|
+
"duration": {{ it.root?.answer?.metadata?.duration }},
|
146
|
+
"startOffset": {{ it.root?.answer?.settings?.startOffset }},
|
147
|
+
"endOffset": {{ it.root?.answer?.settings?.endOffset }},
|
148
|
+
"crop": {
|
149
|
+
"x": {{ it.root?.answer?.settings?.crop?.x }},
|
150
|
+
"y": {{ it.root?.answer?.settings?.crop?.y }},
|
151
|
+
"width": {{ it.root?.answer?.settings?.crop?.width }},
|
152
|
+
"height": {{ it.root?.answer?.settings?.crop?.height }}
|
153
|
+
}
|
154
|
+
}`}],root:"{{ it.questions?.items }}"},{scenes:[{layout:"none",data:`{
|
155
|
+
"id": {{ it.root?.answer?.id }},
|
156
|
+
"key": {{ it.root?.answer?.id + '-outro' }},
|
157
|
+
"mp4": {{ it.root?.answer?.media?.video }},
|
158
|
+
"input": {{ it.root?.answer?.media?.input }},
|
159
|
+
"playlist": {{ it.root?.answer?.media?.playlist }},
|
160
|
+
"poster": {{ it.root?.answer?.media?.thumbnail }},
|
161
|
+
"captions": {{ it.root?.answer?.captions?.current }},
|
162
|
+
"duration": {{ it.root?.answer?.metadata?.duration }},
|
163
|
+
"startOffset": {{ it.root?.answer?.settings?.startOffset }},
|
164
|
+
"endOffset": {{ it.root?.answer?.settings?.endOffset }},
|
165
|
+
"crop": {
|
166
|
+
"x": {{ it.root?.answer?.settings?.crop?.x }},
|
167
|
+
"y": {{ it.root?.answer?.settings?.crop?.y }},
|
168
|
+
"width": {{ it.root?.answer?.settings?.crop?.width }},
|
169
|
+
"height": {{ it.root?.answer?.settings?.crop?.height }}
|
170
|
+
}
|
171
|
+
}`}],root:"{{ it.outro?.questions?.items }}"}],system:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}],meta:{frameRate:30,resolution:720,transitionDuration:1/3},system:!0,default:0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};async function H1(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Kp);return new s.Image}return new Image}const Y0=xs(async function(e){return e?new Promise((t,i)=>{H1().then(n=>{n.onload=()=>{t(n)},n.onerror=a=>{i(a)},n.src=e})}):null});async function hc({element:s,meta:e},t,i){var n,a,l;let h={...s};const{node:d}=s;if((d==null?void 0:d.type)==="video"&&((n=d==null?void 0:d.value)!=null&&n.src||(a=d==null?void 0:d.value)!=null&&a.playlist)){const p=await t(d.value,e);let m;try{m=await Y0(d.value.poster)}catch{m=null}h={...h,node:{...d,video:p,poster:m,meta:await i(d.value,p.node,e)}}}if((d==null?void 0:d.type)==="image"&&d.value){let p;try{p=await Y0(d.value)}catch{p=null}h={...h,node:{...d,image:p}}}return h.node&&((l=s.node)!=null&&l.elements)&&(h.node.elements=await Promise.all(s.node.elements.map(p=>hc({element:p,meta:e},t,i)))),s.elements&&(h.elements=await Promise.all(s.elements.map(p=>hc({element:p,meta:e},t,i)))),h}async function Ca(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Kp),e=new s.Canvas;return e.gpu=!1,e}return document.createElement("canvas")}async function W1(s){var e;try{if((e=await I1(s,{method:"HEAD"}))!=null&&e.ok)return s}catch{return}}async function j1({sources:s}){let e=null;if(s){const t=s.filter(Boolean).map(i=>W1(i));e=(await Promise.all(t)).find(Boolean)}return e}function xo(s=[]){var e;for(const t of s){if(((e=t==null?void 0:t.node)==null?void 0:e.type)==="video")return t.node;const i=xo(t==null?void 0:t.elements);if(i)return i}}function K1(s,e){return s.reduce((t,i,n)=>[...t,i.map(({duration:a},l)=>n===s.length-1&&l===i.length-1?a:a-e)],[])}function z1(s){if(s===null||typeof s!="object")return!1;if(Object.getPrototypeOf(s)===null)return!0;let e=s;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(s)===e}function Y1(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 Ia(s){return s.flatMap(e=>e).reduce((e,t)=>e+t,0)}Sa.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${Y1(s)}"`:z1(s)||Array.isArray(s)?JSON.stringify(s):s),Sa.helpers.define("resolve-source",xs(async s=>{const{sources:e}=s.params[0]??{},t=e==null?void 0:e.filter(Boolean),i=t==null?void 0:t.find(l=>l.includes("blob:")),n=t==null?void 0:t.find(l=>!l.includes("http")),a=i??n??await j1({sources:e});return a?`"${a}"`:"null"},{cacheKey:([s])=>JSON.stringify(s.params[0]??{})}));const bo=(s,e,t)=>Sa.render(s,e,Sa.getConfig({autoEscape:!1,defaultFilter:"parse",async:!0,asyncHelpers:["resolve-source"],...t}));async function Tn({data:s,template:e,burnCaptions:t=!1,debug:i=!1},n,a){var l,h,d,p;const m=e??V1;if(!((l=m.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${m.id}`);let g=m.templates.find(({version:K})=>K===fc);if(!g){const K=m.templates.map(({version:U})=>`"${U}"`).join(", ");console.warn(`Template renderer expects template version "${fc}" but got ${K}`),g=m.templates[m.templates.length-1]}const A=await Promise.all(g.content.map(async({scenes:K,root:U})=>{const re={...m.options,...s,intro:m.intro,outro:m.outro};async function ne(Y,Ee){return Promise.all(K.map(async({layout:ce,duration:we,data:Oe,options:B})=>{var W,ke,F;const G={...re,index:Ee,root:Y},Q=Oe?JSON.parse(await bo(Oe,G)):{},me=B?JSON.parse(await bo(B,G)):{},pe=we?parseFloat(await bo(we,G)):NaN,Re=(W=g.layouts.find(ft=>ft.name===ce))==null?void 0:W.tree;if(!Re)throw new Error(`Layout tree "${ce}" not found in template "${g.id}" layouts.`);const Ue=JSON.parse(await bo(Re,{...Q,...me})),Ke=await Promise.all(Ue.flatMap(ft=>hc({element:ft,meta:m.meta},n,a))),Ze=xo(Ke);return{duration:(isNaN(pe)?null:pe)??((ke=Ze==null?void 0:Ze.meta)==null?void 0:ke.duration)??0,captions:(F=Ze==null?void 0:Ze.meta)==null?void 0:F.captions,elements:Ke}}))}if(U){const Y=JSON.parse(await bo(U,re));return Array.isArray(Y)?(await Promise.all(Y.map(async(Ee,ce)=>ne(Ee,ce)))).flatMap(Ee=>Ee):ne(Y,null)}return ne(s,null)}));if(A.every(K=>K.every(U=>{const re=xo(U.elements);return!(re!=null&&re.value.src)&&!(re!=null&&re.value.playlist)}))){const K=A.flatMap(U=>U.map(re=>{const ne=xo(re.elements);return!(ne!=null&&ne.value.src)&&!(ne!=null&&ne.value.playlist)&&(ne==null?void 0:ne.value.id)}).filter(Boolean)).join(", ");throw new Error(`Video(s) with ID ${K} failed to load, video can not be processed`)}if(A.every(K=>K.every(U=>U.duration<=0)))throw new Error("No scenes have any duration, video can not be processed");const S=A.reduce((K,U)=>{const re=U.filter(ne=>ne.duration>0);return re.length>0&&(K=[...K,re]),K},[]),w=((h=m.meta)==null?void 0:h.frameRate)??30,P=((d=m.meta)==null?void 0:d.resolution)??720,$=((p=m.meta)==null?void 0:p.transitionDuration)??1/3,N=K1(S,$),I=Ia(N);return{scenes:(await Promise.all(S.map((K,U)=>{const re=Ia(N[U]),ne=Ia(N.slice(0,U));return Promise.all(K.map(async({duration:Y,captions:Ee,elements:ce},we)=>{var Oe,B;const W=await Ca(),ke=await Ca(),F=await Ca(),G=await Ca(),Q=xo(ce),me=Ia([...N.slice(0,U),...N[U].slice(0,we)]);return{draw:({canvas:Re,currentTime:Ue})=>{const Ke=Math.max(0,Ue-ne),Ze=Math.max(0,Ue-me);uc({debug:i,canvas:Re,cropCanvas:W,posterCanvas:G,letterboxCanvas:ke,elements:ce,currentTime:Ue,contentTime:Ke,sceneTime:Ze,totalDuration:I,contentDuration:re,sceneDuration:Y}),Ee&&t&&G1({canvas:Re,dx:0,dy:0,dw:Re.width,dh:Re.height,vttCaptions:Ee,sceneTime:Ze+((Q==null?void 0:Q.meta.start)??0)})},duration:Y,transitionCanvas:F,start:me,video:Q==null?void 0:Q.video,videoMeta:Q==null?void 0:Q.meta,audio:{duration:Y,src:(Oe=Q==null?void 0:Q.value)==null?void 0:Oe.src,start:(B=Q==null?void 0:Q.meta)==null?void 0:B.start}}}))}))).flatMap(K=>K),frameRate:w,resolution:P,transitionDuration:$,fonts:g.fonts??[],duration:I}}const fc="2",X1={name:"@vouchfor/embeds",version:"0.0.0-experiment.90dc1dd",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:"experiment",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":"0.0.0-experiment.90dc1dd",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 Z1(s){const{publicApiUrl:e}=la(s),t=Js();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function q1(s){var a,l,h,d,p,m,g,A,x,b,S,w;if(typeof window>"u")return{client:null,tab:null,request:Js()};let e=(l=(a=window.localStorage)==null?void 0:a.getItem)==null?void 0:l.call(a,"vouch-uid-visitor"),t=(d=(h=window.localStorage)==null?void 0:h.getItem)==null?void 0:d.call(h,"vouch-uid-client"),i=(m=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:m.call(p,"vouch-uid-tab");const n=Js();return e||(e=Z1(s),(A=(g=window.localStorage)==null?void 0:g.setItem)==null||A.call(g,"vouch-uid-visitor",e)),t||(t=Js(),(b=(x=window.localStorage)==null?void 0:x.setItem)==null||b.call(x,"vouch-uid-client",t)),i||(i=Js(),(w=(S=window.sessionStorage)==null?void 0:S.setItem)==null||w.call(S,"vouch-uid-tab",i)),{client:t,tab:i,request:n,visitor:e}}function Q1(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function J1(s="embedded_player"){var n,a;const[e,t]=((a=(n=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:n.split)==null?void 0:a.call(n,"/"))??[],i={};return[...new URLSearchParams(location.search).entries()].forEach(([l,h])=>{if(/utm/.test(l)){const d=l.toLowerCase().replace(/[-_][a-z0-9]/g,p=>p.slice(-1).toUpperCase());i[d]=h}}),{source:s,time:new Date,region:t,country:e,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:X1.version,templateVersion:fc,...i}}const X0=1;class ev{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const n=Q1(i,this.host.vouch);!n||this.host.disableTracking||this._batchedEvents.push({event:t,payload:{...i,vouchId:n,time:new Date().toISOString()}})},this._sendTrackingEvent=()=>{if(this._batchedEvents.length<=0)return;const{publicApiUrl:t}=la(this.host.env),{client:i,tab:n,request:a,visitor:l}=q1(this.host.env);navigator.sendBeacon(`${t}/api/batchevents`,JSON.stringify({payload:{events:this._batchedEvents},context:{"x-uid-client":i,"x-uid-tab":n,"x-uid-request":a,"x-uid-visitor":l,"x-reporting-metadata":J1(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+X0&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:t,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]}},this._handleVouchLoaded=({detail:t})=>{t&&(this._hasLoaded[t]||(this._createTrackingEvent("VOUCH_LOADED",{vouchId:t}),this._hasLoaded[t]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._createTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:t,key:i}})=>{this._answersViewed[i]||(this._createTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:t}),this._answersViewed[i]=!0)},this._handleVideoTimeUpdate=({detail:{id:t,key:i,node:n}})=>{var a,l;!this.host.paused&&t===((l=(a=this.host.scene)==null?void 0:a.video)==null?void 0:l.id)&&(this._currentlyPlayingVideo={id:t,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:t,key:i}})=>{this._streamLatestTime[i]>this._streamStartTime[i]+X0&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:t,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=e,e.addController(this)}hostConnected(){requestAnimationFrame(()=>{var e,t,i,n;"onvisibilitychange"in document?document.addEventListener("visibilitychange",this._handleVisibilityChange):window.addEventListener("pagehide",this._handlePageHide),this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(e=this.host.mediaPlayer)==null||e.addEventListener("play",this._handlePlay),(t=this.host.mediaPlayer)==null||t.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 e,t,i,n;this._pageUnloading(),"onvisibilitychange"in document?document.removeEventListener("visibilitychange",this._handleVisibilityChange):window.removeEventListener("pagehide",this._handlePageHide),this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(e=this.host.mediaPlayer)==null||e.removeEventListener("play",this._handlePlay),(t=this.host.mediaPlayer)==null||t.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)}}/**
|
172
|
+
* @license
|
173
|
+
* Copyright 2018 Google LLC
|
174
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
175
|
+
*/const Qt=bn(class extends co{constructor(s){var e;if(super(s),s.type!==xn.ATTRIBUTE||s.name!=="class"||((e=s.strings)==null?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(s){return" "+Object.keys(s).filter(e=>s[e]).join(" ")+" "}update(s,[e]){var i,n;if(this.it===void 0){this.it=new Set,s.strings!==void 0&&(this.st=new Set(s.strings.join(" ").split(/\s/).filter(a=>a!=="")));for(const a in e)e[a]&&!((i=this.st)!=null&&i.has(a))&&this.it.add(a);return this.render(e)}const t=s.element.classList;for(const a of this.it)a in e||(t.remove(a),this.it.delete(a));for(const a in e){const l=!!e[a];l===this.it.has(a)||(n=this.st)!=null&&n.has(a)||(l?(t.add(a),this.it.add(a)):(t.remove(a),this.it.delete(a)))}return ps}});/**
|
176
|
+
* @license
|
177
|
+
* Copyright 2018 Google LLC
|
178
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
179
|
+
*/const Z0="important",tv=" !"+Z0,dc=bn(class extends co{constructor(s){var e;if(super(s),s.type!==xn.ATTRIBUTE||s.name!=="style"||((e=s.strings)==null?void 0:e.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((e,t)=>{const i=s[t];return i==null?e:e+`${t=t.includes("-")?t:t.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(s,[e]){const{style:t}=s.element;if(this.ut===void 0)return this.ut=new Set(Object.keys(e)),this.render(e);for(const i of this.ut)e[i]==null&&(this.ut.delete(i),i.includes("-")?t.removeProperty(i):t[i]=null);for(const i in e){const n=e[i];if(n!=null){this.ut.add(i);const a=typeof n=="string"&&n.endsWith(tv);i.includes("-")||a?t.setProperty(i,a?n.slice(0,-11):n,a?Z0:""):t[i]=n}}return ps}});function iv(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var q0={exports:{}};(function(s,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,a=/(?:\/|^)\.(?=\/)/g,l=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,h={buildAbsoluteURL:function(d,p,m){if(m=m||{},d=d.trim(),p=p.trim(),!p){if(!m.alwaysNormalize)return d;var g=h.parseURL(d);if(!g)throw new Error("Error trying to parse base URL.");return g.path=h.normalizePath(g.path),h.buildURLFromParts(g)}var A=h.parseURL(p);if(!A)throw new Error("Error trying to parse relative URL.");if(A.scheme)return m.alwaysNormalize?(A.path=h.normalizePath(A.path),h.buildURLFromParts(A)):p;var x=h.parseURL(d);if(!x)throw new Error("Error trying to parse base URL.");if(!x.netLoc&&x.path&&x.path[0]!=="/"){var b=n.exec(x.path);x.netLoc=b[1],x.path=b[2]}x.netLoc&&!x.path&&(x.path="/");var S={scheme:x.scheme,netLoc:A.netLoc,path:null,params:A.params,query:A.query,fragment:A.fragment};if(!A.netLoc&&(S.netLoc=x.netLoc,A.path[0]!=="/"))if(!A.path)S.path=x.path,A.params||(S.params=x.params,A.query||(S.query=x.query));else{var w=x.path,P=w.substring(0,w.lastIndexOf("/")+1)+A.path;S.path=h.normalizePath(P)}return S.path===null&&(S.path=m.alwaysNormalize?h.normalizePath(A.path):A.path),h.buildURLFromParts(S)},parseURL:function(d){var p=i.exec(d);return p?{scheme:p[1]||"",netLoc:p[2]||"",path:p[3]||"",params:p[4]||"",query:p[5]||"",fragment:p[6]||""}:null},normalizePath:function(d){for(d=d.split("").reverse().join("").replace(a,"");d.length!==(d=d.replace(l,"")).length;);return d.split("").reverse().join("")},buildURLFromParts:function(d){return d.scheme+d.netLoc+d.path+d.params+d.query+d.fragment}};s.exports=h})()})(q0);var pc=q0.exports;function Q0(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(s,n).enumerable})),t.push.apply(t,i)}return t}function Ki(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Q0(Object(t),!0).forEach(function(i){rv(s,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Q0(Object(t)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(t,i))})}return s}function rv(s,e,t){return e=nv(e),e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function ai(){return ai=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},ai.apply(this,arguments)}function sv(s,e){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var i=t.call(s,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}function nv(s){var e=sv(s,"string");return typeof e=="symbol"?e:String(e)}const ze=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)};let _=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}({}),et=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}({}),de=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 sn=function(){},mc={trace:sn,debug:sn,log:sn,warn:sn,info:sn,error:sn};let To=mc;function ov(s){const e=self.console[s];return e?e.bind(self.console,`[${s}] >`):sn}function av(s,...e){e.forEach(function(t){To[t]=s[t]?s[t].bind(s):ov(t)})}function lv(s,e){if(self.console&&s===!0||typeof s=="object"){av(s,"debug","log","info","warn","error");try{To.log(`Debug logs enabled for "${e}" in hls.js version 1.4.12`)}catch{To=mc}}else To=mc}const q=To,cv=/^(\d+)x(\d+)$/,J0=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Jt{constructor(e){typeof e=="string"&&(e=Jt.parseAttrList(e));for(const t in e)e.hasOwnProperty(t)&&(t.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;const i=new Uint8Array(t.length/2);for(let n=0;n<t.length/2;n++)i[n]=parseInt(t.slice(n*2,n*2+2),16);return i}else return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){const t=cv.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const i={},n='"';for(J0.lastIndex=0;(t=J0.exec(e))!==null;){let a=t[2];a.indexOf(n)===0&&a.lastIndexOf(n)===a.length-1&&(a=a.slice(1,-1));const l=t[1].trim();i[l]=a}return i}}function uv(s){return s!=="ID"&&s!=="CLASS"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function hv(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}class ef{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const i=t.attr;for(const n in i)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==i[n]){q.warn(`DATERANGE tag attribute: "${n}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=n;break}e=ai(new Jt({}),i,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const i=new Date(this.attr["END-DATE"]);ze(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 e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(ze(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&ze(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Da{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 Ct={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class tf{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Ct.AUDIO]:null,[Ct.VIDEO]:null,[Ct.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){const i=e.split("@",2),n=[];i.length===1?n[0]=t?t.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(e){this._url=e}}class gc extends tf{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Da,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=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.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||!ze(this.programDateTime))return null;const e=ze(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){const t=Object.keys(this.levelkeys),i=t.length;if(i>1||i===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,i,n,a,l=!1){const{elementaryStreams:h}=this,d=h[e];if(!d){h[e]={startPTS:t,endPTS:i,startDTS:n,endDTS:a,partial:l};return}d.startPTS=Math.min(d.startPTS,t),d.endPTS=Math.max(d.endPTS,i),d.startDTS=Math.min(d.startDTS,n),d.endDTS=Math.max(d.endDTS,a)}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[Ct.AUDIO]=null,e[Ct.VIDEO]=null,e[Ct.AUDIOVIDEO]=null}}class fv extends tf{constructor(e,t,i,n,a){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 Da,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=n;const l=e.enumeratedString("BYTERANGE");l&&this.setByteRange(l,a),a&&(this.fragOffset=a.fragOffset+a.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}const dv=10;class pv{constructor(e){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=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?ze(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||dv}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function vc(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0))}function mv(s){const e=rf(s).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function gv(s){const e=function(i,n,a){const l=i[n];i[n]=i[a],i[a]=l};e(s,0,3),e(s,1,2),e(s,4,5),e(s,6,7)}function vv(s){const e=s.split(":");let t=null;if(e[0]==="data"&&e.length===2){const i=e[1].split(";"),n=i[i.length-1].split(",");if(n.length===2){const a=n[0]==="base64",l=n[1];a?(i.splice(-1,1),t=vc(l)):t=mv(l)}}return t}function rf(s){return Uint8Array.from(unescape(encodeURIComponent(s)),e=>e.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 sf(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 nf={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function yv(s){if(s===nf.WIDEVINE)return ei.WIDEVINE}function of(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:e,widevineLicenseUrl:t}=s,i=e?[ei.FAIRPLAY,ei.WIDEVINE,ei.PLAYREADY,ei.CLEARKEY].filter(n=>!!e[n]):[];return!i[ei.WIDEVINE]&&t&&i.push(ei.WIDEVINE),i}const af=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Av(s,e,t,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 Ev(n,e,t,i)}function Ev(s,e,t,i){return[{initDataTypes:s,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(a=>({contentType:`audio/mp4; codecs="${a}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(a=>({contentType:`video/mp4; codecs="${a}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function nn(s,e,t){return Uint8Array.prototype.slice?s.slice(e,t):new Uint8Array(Array.prototype.slice.call(s,e,t))}const Ac=(s,e)=>e+10<=s.length&&s[e]===73&&s[e+1]===68&&s[e+2]===51&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128,lf=(s,e)=>e+10<=s.length&&s[e]===51&&s[e+1]===68&&s[e+2]===73&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128,Oa=(s,e)=>{const t=e;let i=0;for(;Ac(s,e);){i+=10;const n=Pa(s,e+6);i+=n,lf(s,e+10)&&(i+=10),e+=i}if(i>0)return s.subarray(t,t+i)},Pa=(s,e)=>{let t=0;return t=(s[e]&127)<<21,t|=(s[e+1]&127)<<14,t|=(s[e+2]&127)<<7,t|=s[e+3]&127,t},xv=(s,e)=>Ac(s,e)&&Pa(s,e+6)+10<=s.length-e,bv=s=>{const e=uf(s);for(let t=0;t<e.length;t++){const i=e[t];if(cf(i))return Rv(i)}},cf=s=>s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp",Tv=s=>{const e=String.fromCharCode(s[0],s[1],s[2],s[3]),t=Pa(s,4),i=10;return{type:e,size:t,data:s.subarray(i,i+t)}},uf=s=>{let e=0;const t=[];for(;Ac(s,e);){const i=Pa(s,e+6);e+=10;const n=e+i;for(;e+8<n;){const a=Tv(s.subarray(e)),l=Sv(a);l&&t.push(l),e+=a.size+10}lf(s,e)&&(e+=10)}return t},Sv=s=>s.type==="PRIV"?kv(s):s.type[0]==="W"?_v(s):wv(s),kv=s=>{if(s.size<2)return;const e=Ir(s.data,!0),t=new Uint8Array(s.data.subarray(e.length+1));return{key:s.type,info:e,data:t.buffer}},wv=s=>{if(s.size<2)return;if(s.type==="TXXX"){let t=1;const i=Ir(s.data.subarray(t),!0);t+=i.length+1;const n=Ir(s.data.subarray(t));return{key:s.type,info:i,data:n}}const e=Ir(s.data.subarray(1));return{key:s.type,data:e}},_v=s=>{if(s.type==="WXXX"){if(s.size<2)return;let t=1;const i=Ir(s.data.subarray(t),!0);t+=i.length+1;const n=Ir(s.data.subarray(t));return{key:s.type,info:i,data:n}}const e=Ir(s.data);return{key:s.type,data:e}},Rv=s=>{if(s.data.byteLength===8){const e=new Uint8Array(s.data),t=e[3]&1;let i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}},Ir=(s,e=!1)=>{const t=Lv();if(t){const p=t.decode(s);if(e){const m=p.indexOf("\0");return m!==-1?p.substring(0,m):p}return p.replace(/\0/g,"")}const i=s.length;let n,a,l,h="",d=0;for(;d<i;){if(n=s[d++],n===0&&e)return h;if(n===0||n===3)continue;switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:h+=String.fromCharCode(n);break;case 12:case 13:a=s[d++],h+=String.fromCharCode((n&31)<<6|a&63);break;case 14:a=s[d++],l=s[d++],h+=String.fromCharCode((n&15)<<12|(a&63)<<6|(l&63)<<0);break}}return h};let Ec;function Lv(){return!Ec&&typeof self.TextDecoder<"u"&&(Ec=new self.TextDecoder("utf-8")),Ec}const Dr={hexDump:function(s){let e="";for(let t=0;t<s.length;t++){let i=s[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}},$a=Math.pow(2,32)-1,Cv=[].push,hf={video:1,audio:2,id3:3,text:4};function Ti(s){return String.fromCharCode.apply(null,s)}function ff(s,e){const t=s[e]<<8|s[e+1];return t<0?65536+t:t}function rt(s,e){const t=df(s,e);return t<0?4294967296+t:t}function df(s,e){return s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3]}function xc(s,e,t){s[e]=t>>24,s[e+1]=t>>16&255,s[e+2]=t>>8&255,s[e+3]=t&255}function xt(s,e){const t=[];if(!e.length)return t;const i=s.byteLength;for(let n=0;n<i;){const a=rt(s,n),l=Ti(s.subarray(n+4,n+8)),h=a>1?n+a:i;if(l===e[0])if(e.length===1)t.push(s.subarray(n+8,h));else{const d=xt(s.subarray(n+8,h),e.slice(1));d.length&&Cv.apply(t,d)}n=h}return t}function Iv(s){const e=[],t=s[0];let i=8;const n=rt(s,i);i+=4;const a=0,l=0;t===0?i+=8:i+=16,i+=2;let h=s.length+l;const d=ff(s,i);i+=2;for(let p=0;p<d;p++){let m=i;const g=rt(s,m);m+=4;const A=g&2147483647;if((g&2147483648)>>>31===1)return q.warn("SIDX has hierarchical references (not supported)"),null;const b=rt(s,m);m+=4,e.push({referenceSize:A,subsegmentDuration:b,info:{duration:b/n,start:h,end:h+A-1}}),h+=A,m+=4,i=m}return{earliestPresentationTime:a,timescale:n,version:t,referencesCount:d,references:e}}function pf(s){const e=[],t=xt(s,["moov","trak"]);for(let n=0;n<t.length;n++){const a=t[n],l=xt(a,["tkhd"])[0];if(l){let h=l[0],d=h===0?12:20;const p=rt(l,d),m=xt(a,["mdia","mdhd"])[0];if(m){h=m[0],d=h===0?12:20;const g=rt(m,d),A=xt(a,["mdia","hdlr"])[0];if(A){const x=Ti(A.subarray(8,12)),b={soun:Ct.AUDIO,vide:Ct.VIDEO}[x];if(b){const S=xt(a,["mdia","minf","stbl","stsd"])[0];let w;S&&(w=Ti(S.subarray(12,16))),e[p]={timescale:g,type:b},e[b]={timescale:g,id:p,codec:w}}}}}}return xt(s,["moov","mvex","trex"]).forEach(n=>{const a=rt(n,4),l=e[a];l&&(l.default={duration:rt(n,12),flags:rt(n,20)})}),e}function Dv(s,e){if(!s||!e)return s;const t=e.keyId;return t&&e.isCommonEncryption&&xt(s,["moov","trak"]).forEach(n=>{const l=xt(n,["mdia","minf","stbl","stsd"])[0].subarray(8);let h=xt(l,["enca"]);const d=h.length>0;d||(h=xt(l,["encv"])),h.forEach(p=>{const m=d?p.subarray(28):p.subarray(78);xt(m,["sinf"]).forEach(A=>{const x=mf(A);if(x){const b=x.subarray(8,24);b.some(S=>S!==0)||(q.log(`[eme] Patching keyId in 'enc${d?"a":"v"}>sinf>>tenc' box: ${Dr.hexDump(b)} -> ${Dr.hexDump(t)}`),x.set(t,8))}})})}),s}function mf(s){const e=xt(s,["schm"])[0];if(e){const t=Ti(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return xt(s,["schi","tenc"])[0]}return q.error("[eme] missing 'schm' box"),null}function Ov(s,e){return xt(e,["moof","traf"]).reduce((t,i)=>{const n=xt(i,["tfdt"])[0],a=n[0],l=xt(i,["tfhd"]).reduce((h,d)=>{const p=rt(d,4),m=s[p];if(m){let g=rt(n,4);if(a===1){if(g===$a)return q.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),h;g*=$a+1,g+=rt(n,8)}const A=m.timescale||9e4,x=g/A;if(isFinite(x)&&(h===null||x<h))return x}return h},null);return l!==null&&isFinite(l)&&(t===null||l<t)?l:t},null)}function Pv(s,e){let t=0,i=0,n=0;const a=xt(s,["moof","traf"]);for(let l=0;l<a.length;l++){const h=a[l],d=xt(h,["tfhd"])[0],p=rt(d,4),m=e[p];if(!m)continue;const g=m.default,A=rt(d,0)|(g==null?void 0:g.flags);let x=g==null?void 0:g.duration;A&8&&(A&2?x=rt(d,12):x=rt(d,8));const b=m.timescale||9e4,S=xt(h,["trun"]);for(let w=0;w<S.length;w++){if(t=$v(S[w]),!t&&x){const P=rt(S[w],4);t=x*P}m.type===Ct.VIDEO?i+=t/b:m.type===Ct.AUDIO&&(n+=t/b)}}if(i===0&&n===0){let l=0;const h=xt(s,["sidx"]);for(let d=0;d<h.length;d++){const p=Iv(h[d]);p!=null&&p.references&&(l+=p.references.reduce((m,g)=>m+g.info.duration||0,0))}return l}return i||n}function $v(s){const e=rt(s,0);let t=8;e&1&&(t+=4),e&4&&(t+=4);let i=0;const n=rt(s,4);for(let a=0;a<n;a++){if(e&256){const l=rt(s,t);i+=l,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return i}function Mv(s,e,t){xt(e,["moof","traf"]).forEach(i=>{xt(i,["tfhd"]).forEach(n=>{const a=rt(n,4),l=s[a];if(!l)return;const h=l.timescale||9e4;xt(i,["tfdt"]).forEach(d=>{const p=d[0];let m=rt(d,4);if(p===0)m-=t*h,m=Math.max(m,0),xc(d,4,m);else{m*=Math.pow(2,32),m+=rt(d,8),m-=t*h,m=Math.max(m,0);const g=Math.floor(m/($a+1)),A=Math.floor(m%($a+1));xc(d,4,g),xc(d,8,A)}})})})}function Fv(s){const e={valid:null,remainder:null},t=xt(s,["moof"]);if(t){if(t.length<2)return e.remainder=s,e}else return e;const i=t[t.length-1];return e.valid=nn(s,0,i.byteOffset-8),e.remainder=nn(s,i.byteOffset-8),e}function on(s,e){const t=new Uint8Array(s.length+e.length);return t.set(s),t.set(e,s.length),t}function gf(s,e){const t=[],i=e.samples,n=e.timescale,a=e.id;let l=!1;return xt(i,["moof"]).map(d=>{const p=d.byteOffset-8;xt(d,["traf"]).map(g=>{const A=xt(g,["tfdt"]).map(x=>{const b=x[0];let S=rt(x,4);return b===1&&(S*=Math.pow(2,32),S+=rt(x,8)),S/n})[0];return A!==void 0&&(s=A),xt(g,["tfhd"]).map(x=>{const b=rt(x,4),S=rt(x,0)&16777215,w=(S&1)!==0,P=(S&2)!==0,$=(S&8)!==0;let N=0;const I=(S&16)!==0;let O=0;const K=(S&32)!==0;let U=8;b===a&&(w&&(U+=8),P&&(U+=4),$&&(N=rt(x,U),U+=4),I&&(O=rt(x,U),U+=4),K&&(U+=4),e.type==="video"&&(l=Nv(e.codec)),xt(g,["trun"]).map(re=>{const ne=re[0],Y=rt(re,0)&16777215,Ee=(Y&1)!==0;let ce=0;const we=(Y&4)!==0,Oe=(Y&256)!==0;let B=0;const W=(Y&512)!==0;let ke=0;const F=(Y&1024)!==0,G=(Y&2048)!==0;let Q=0;const me=rt(re,4);let pe=8;Ee&&(ce=rt(re,pe),pe+=4),we&&(pe+=4);let Re=ce+p;for(let Ue=0;Ue<me;Ue++){if(Oe?(B=rt(re,pe),pe+=4):B=N,W?(ke=rt(re,pe),pe+=4):ke=O,F&&(pe+=4),G&&(ne===0?Q=rt(re,pe):Q=df(re,pe),pe+=4),e.type===Ct.VIDEO){let Ke=0;for(;Ke<ke;){const Ze=rt(i,Re);if(Re+=4,Uv(l,i[Re])){const pt=i.subarray(Re,Re+Ze);vf(pt,l?2:1,s+Q/n,t)}Re+=Ze,Ke+=Ze+4}}s+=B/n}}))})})}),t}function Nv(s){if(!s)return!1;const e=s.indexOf("."),t=e<0?s:s.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function Uv(s,e){if(s){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function vf(s,e,t,i){const n=yf(s);let a=0;a+=e;let l=0,h=0,d=!1,p=0;for(;a<n.length;){l=0;do{if(a>=n.length)break;p=n[a++],l+=p}while(p===255);h=0;do{if(a>=n.length)break;p=n[a++],h+=p}while(p===255);const m=n.length-a;if(!d&&l===4&&a<n.length){if(d=!0,n[a++]===181){const A=ff(n,a);if(a+=2,A===49){const x=rt(n,a);if(a+=4,x===1195456820){const b=n[a++];if(b===3){const S=n[a++],w=31&S,P=64&S,$=P?2+w*3:0,N=new Uint8Array($);if(P){N[0]=S;for(let I=1;I<$;I++)N[I]=n[a++]}i.push({type:b,payloadType:l,pts:t,bytes:N})}}}}}else if(l===5&&h<m){if(d=!0,h>16){const g=[];for(let b=0;b<16;b++){const S=n[a++].toString(16);g.push(S.length==1?"0"+S:S),(b===3||b===5||b===7||b===9)&&g.push("-")}const A=h-16,x=new Uint8Array(A);for(let b=0;b<A;b++)x[b]=n[a++];i.push({payloadType:l,pts:t,uuid:g.join(""),userData:Ir(x),userDataBytes:x})}}else if(h<m)a+=h;else if(h>m)break}}function yf(s){const e=s.byteLength,t=[];let i=1;for(;i<e-2;)s[i]===0&&s[i+1]===0&&s[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return s;const n=e-t.length,a=new Uint8Array(n);let l=0;for(i=0;i<n;l++,i++)l===t[0]&&(l++,t.shift()),a[i]=s[l];return a}function Bv(s){const e=s[0];let t="",i="",n=0,a=0,l=0,h=0,d=0,p=0;if(e===0){for(;Ti(s.subarray(p,p+1))!=="\0";)t+=Ti(s.subarray(p,p+1)),p+=1;for(t+=Ti(s.subarray(p,p+1)),p+=1;Ti(s.subarray(p,p+1))!=="\0";)i+=Ti(s.subarray(p,p+1)),p+=1;i+=Ti(s.subarray(p,p+1)),p+=1,n=rt(s,12),a=rt(s,16),h=rt(s,20),d=rt(s,24),p=28}else if(e===1){p+=4,n=rt(s,p),p+=4;const g=rt(s,p);p+=4;const A=rt(s,p);for(p+=4,l=4294967296*g+A,Number.isSafeInteger(l)||(l=Number.MAX_SAFE_INTEGER,q.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),h=rt(s,p),p+=4,d=rt(s,p),p+=4;Ti(s.subarray(p,p+1))!=="\0";)t+=Ti(s.subarray(p,p+1)),p+=1;for(t+=Ti(s.subarray(p,p+1)),p+=1;Ti(s.subarray(p,p+1))!=="\0";)i+=Ti(s.subarray(p,p+1)),p+=1;i+=Ti(s.subarray(p,p+1)),p+=1}const m=s.subarray(p,s.byteLength);return{schemeIdUri:t,value:i,timeScale:n,presentationTime:l,presentationTimeDelta:a,eventDuration:h,id:d,payload:m}}function Gv(s,...e){const t=e.length;let i=8,n=t;for(;n--;)i+=e[n].byteLength;const a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=i&255,a.set(s,4),n=0,i=8;n<t;n++)a.set(e[n],i),i+=e[n].byteLength;return a}function Vv(s,e,t){if(s.byteLength!==16)throw new RangeError("Invalid system id");let i,n;if(e){i=1,n=new Uint8Array(e.length*16);for(let h=0;h<e.length;h++){const d=e[h];if(d.byteLength!==16)throw new RangeError("Invalid key");n.set(d,h*16)}}else i=0,n=new Uint8Array;let a;i>0?(a=new Uint8Array(4),e.length>0&&new DataView(a.buffer).setUint32(0,e.length,!1)):a=new Uint8Array;const l=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(l.buffer).setUint32(0,t.byteLength,!1),Gv([112,115,115,104],new Uint8Array([i,0,0,0]),s,a,n,l,t||new Uint8Array)}function Hv(s){if(!(s instanceof ArrayBuffer)||s.byteLength<32)return null;const e={version:0,systemId:"",kids:null,data:null},t=new DataView(s),i=t.getUint32(0);if(s.byteLength!==i&&i>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=Dr.hexDump(new Uint8Array(s,12,16));const a=t.getUint32(28);if(e.version===0){if(i-32<a)return null;e.data=new Uint8Array(s,32,a)}else if(e.version===1){e.kids=[];for(let l=0;l<a;l++)e.kids.push(new Uint8Array(s,32+l*16,16))}return e}let Ma={};class So{static clearKeyUriToKeyIdMap(){Ma={}}constructor(e,t,i,n=[1],a=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=n,this.iv=a,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="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(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&q.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const i=Wv(e);return new So(this.method,this.uri,"identity",this.keyFormatVersions,i)}const t=vv(this.uri);if(t)switch(this.keyFormat){case zi.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.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=Vv(i,null,t);const n=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),a=String.fromCharCode.apply(null,Array.from(n)),l=a.substring(a.indexOf("<"),a.length),p=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("KID")[0];if(p){const m=p.childNodes[0]?p.childNodes[0].nodeValue:p.getAttribute("VALUE");if(m){const g=vc(m).subarray(0,16);gv(g),this.keyId=g}}break}default:{let i=t.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=Ma[this.uri];if(!i){const n=Object.keys(Ma).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,n),Ma[this.uri]=i}this.keyId=i}return this}}function Wv(s){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=s>>8*(15-t)&255;return e}const Af=/\{\$([a-zA-Z0-9-_]+)\}/g;function Ef(s){return Af.test(s)}function Yi(s,e,t){if(s.variableList!==null||s.hasVariableRefs)for(let i=t.length;i--;){const n=t[i],a=e[n];a&&(e[n]=bc(s,a))}}function bc(s,e){if(s.variableList!==null||s.hasVariableRefs){const t=s.variableList;return e.replace(Af,i=>{const n=i.substring(2,i.length-1),a=t==null?void 0:t[n];return a===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),i):a})}return e}function xf(s,e,t){let i=s.variableList;i||(s.variableList=i={});let n,a;if("QUERYPARAM"in e){n=e.QUERYPARAM;try{const l=new self.URL(t).searchParams;if(l.has(n))a=l.get(n);else throw new Error(`"${n}" does not match any query parameter in URI: "${t}"`)}catch(l){s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${l.message}`))}}else n=e.NAME,a=e.VALUE;n in i?s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):i[n]=a||""}function jv(s,e,t){const i=e.IMPORT;if(t&&i in t){let n=s.variableList;n||(s.variableList=n={}),n[i]=t[i]}else s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function Fa(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const Kv={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},bf=Fa();function zv(s,e){const t=Kv[e];return!!t&&t[s.slice(0,4)]===!0}function Tc(s,e){var t;return(t=bf==null?void 0:bf.isTypeSupported(`${e||"video"}/mp4;codecs="${s}"`))!=null?t:!1}const Tf=/#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,Sf=/#EXT-X-MEDIA:(.*)/g,Yv=/^#EXT(?:INF|-X-TARGETDURATION):/m,kf=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Xv=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class Er{static findGroup(e,t){for(let i=0;i<e.length;i++){const n=e[i];if(n.id===t)return n}}static convertAVC1ToAVCOTI(e){const t=e.split(".");if(t.length>2){let i=t.shift()+".";return i+=parseInt(t.shift()).toString(16),i+=("000"+parseInt(t.shift()).toString(16)).slice(-4),i}return e}static resolve(e,t){return pc.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Yv.test(e)}static parseMasterPlaylist(e,t){const i=Ef(e),n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},a=[];Tf.lastIndex=0;let l;for(;(l=Tf.exec(e))!=null;)if(l[1]){var h;const p=new Jt(l[1]);Yi(n,p,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const m=bc(n,l[2]),g={attrs:p,bitrate:p.decimalInteger("AVERAGE-BANDWIDTH")||p.decimalInteger("BANDWIDTH"),name:p.NAME,url:Er.resolve(m,t)},A=p.decimalResolution("RESOLUTION");A&&(g.width=A.width,g.height=A.height),Zv((p.CODECS||"").split(/[ ,]+/).filter(x=>x),g),g.videoCodec&&g.videoCodec.indexOf("avc1")!==-1&&(g.videoCodec=Er.convertAVC1ToAVCOTI(g.videoCodec)),(h=g.unknownCodecs)!=null&&h.length||a.push(g),n.levels.push(g)}else if(l[3]){const p=l[3],m=l[4];switch(p){case"SESSION-DATA":{const g=new Jt(m);Yi(n,g,["DATA-ID","LANGUAGE","VALUE","URI"]);const A=g["DATA-ID"];A&&(n.sessionData===null&&(n.sessionData={}),n.sessionData[A]=g);break}case"SESSION-KEY":{const g=wf(m,t,n);g.encrypted&&g.isSupported()?(n.sessionKeys===null&&(n.sessionKeys=[]),n.sessionKeys.push(g)):q.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${m}"`);break}case"DEFINE":{{const g=new Jt(m);Yi(n,g,["NAME","VALUE","QUERYPARAM"]),xf(n,g,t)}break}case"CONTENT-STEERING":{const g=new Jt(m);Yi(n,g,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:Er.resolve(g["SERVER-URI"],t),pathwayId:g["PATHWAY-ID"]||"."};break}case"START":{n.startTimeOffset=_f(m);break}}}const d=a.length>0&&a.length<n.levels.length;return n.levels=d?a:n.levels,n.levels.length===0&&(n.playlistParsingError=new Error("no levels found in manifest")),n}static parseMasterPlaylistMedia(e,t,i){let n;const a={},l=i.levels,h={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 d=0;for(Sf.lastIndex=0;(n=Sf.exec(e))!==null;){const p=new Jt(n[1]),m=p.TYPE;if(m){const g=h[m],A=a[m]||[];a[m]=A,Yi(i,p,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const x={attrs:p,bitrate:0,id:d++,groupId:p["GROUP-ID"]||"",instreamId:p["INSTREAM-ID"],name:p.NAME||p.LANGUAGE||"",type:m,default:p.bool("DEFAULT"),autoselect:p.bool("AUTOSELECT"),forced:p.bool("FORCED"),lang:p.LANGUAGE,url:p.URI?Er.resolve(p.URI,t):""};if(g!=null&&g.length){const b=Er.findGroup(g,x.groupId)||g[0];Rf(x,b,"audioCodec"),Rf(x,b,"textCodec")}A.push(x)}}return a}static parseLevelPlaylist(e,t,i,n,a,l){const h=new pv(t),d=h.fragments;let p=null,m=0,g=0,A=0,x=0,b=null,S=new gc(n,t),w,P,$,N=-1,I=!1;for(kf.lastIndex=0,h.m3u8=e,h.hasVariableRefs=Ef(e);(w=kf.exec(e))!==null;){I&&(I=!1,S=new gc(n,t),S.start=A,S.sn=m,S.cc=x,S.level=i,p&&(S.initSegment=p,S.rawProgramDateTime=p.rawProgramDateTime,p.rawProgramDateTime=null));const re=w[1];if(re){S.duration=parseFloat(re);const ne=(" "+w[2]).slice(1);S.title=ne||null,S.tagList.push(ne?["INF",re,ne]:["INF",re])}else if(w[3]){if(ze(S.duration)){S.start=A,$&&If(S,$,h),S.sn=m,S.level=i,S.cc=x,S.urlId=a,d.push(S);const ne=(" "+w[3]).slice(1);S.relurl=bc(h,ne),Lf(S,b),b=S,A+=S.duration,m++,g=0,I=!0}}else if(w[4]){const ne=(" "+w[4]).slice(1);b?S.setByteRange(ne,b):S.setByteRange(ne)}else if(w[5])S.rawProgramDateTime=(" "+w[5]).slice(1),S.tagList.push(["PROGRAM-DATE-TIME",S.rawProgramDateTime]),N===-1&&(N=d.length);else{if(w=w[0].match(Xv),!w){q.warn("No matches on slow regex match for level playlist!");continue}for(P=1;P<w.length&&!(typeof w[P]<"u");P++);const ne=(" "+w[P]).slice(1),Y=(" "+w[P+1]).slice(1),Ee=w[P+2]?(" "+w[P+2]).slice(1):"";switch(ne){case"PLAYLIST-TYPE":h.type=Y.toUpperCase();break;case"MEDIA-SEQUENCE":m=h.startSN=parseInt(Y);break;case"SKIP":{const ce=new Jt(Y);Yi(h,ce,["RECENTLY-REMOVED-DATERANGES"]);const we=ce.decimalInteger("SKIPPED-SEGMENTS");if(ze(we)){h.skippedSegments=we;for(let B=we;B--;)d.unshift(null);m+=we}const Oe=ce.enumeratedString("RECENTLY-REMOVED-DATERANGES");Oe&&(h.recentlyRemovedDateranges=Oe.split(" "));break}case"TARGETDURATION":h.targetduration=Math.max(parseInt(Y),1);break;case"VERSION":h.version=parseInt(Y);break;case"EXTM3U":break;case"ENDLIST":h.live=!1;break;case"#":(Y||Ee)&&S.tagList.push(Ee?[Y,Ee]:[Y]);break;case"DISCONTINUITY":x++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([ne]);break;case"BITRATE":S.tagList.push([ne,Y]);break;case"DATERANGE":{const ce=new Jt(Y);Yi(h,ce,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Yi(h,ce,ce.clientAttrs);const we=new ef(ce,h.dateRanges[ce.ID]);we.isValid||h.skippedSegments?h.dateRanges[we.id]=we:q.warn(`Ignoring invalid DATERANGE tag: "${Y}"`),S.tagList.push(["EXT-X-DATERANGE",Y]);break}case"DEFINE":{{const ce=new Jt(Y);Yi(h,ce,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in ce?jv(h,ce,l):xf(h,ce,t)}break}case"DISCONTINUITY-SEQUENCE":x=parseInt(Y);break;case"KEY":{const ce=wf(Y,t,h);if(ce.isSupported()){if(ce.method==="NONE"){$=void 0;break}$||($={}),$[ce.keyFormat]&&($=ai({},$)),$[ce.keyFormat]=ce}else q.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${Y}"`);break}case"START":h.startTimeOffset=_f(Y);break;case"MAP":{const ce=new Jt(Y);if(Yi(h,ce,["BYTERANGE","URI"]),S.duration){const we=new gc(n,t);Cf(we,ce,i,$),p=we,S.initSegment=p,p.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=p.rawProgramDateTime)}else Cf(S,ce,i,$),p=S,I=!0;break}case"SERVER-CONTROL":{const ce=new Jt(Y);h.canBlockReload=ce.bool("CAN-BLOCK-RELOAD"),h.canSkipUntil=ce.optionalFloat("CAN-SKIP-UNTIL",0),h.canSkipDateRanges=h.canSkipUntil>0&&ce.bool("CAN-SKIP-DATERANGES"),h.partHoldBack=ce.optionalFloat("PART-HOLD-BACK",0),h.holdBack=ce.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const ce=new Jt(Y);h.partTarget=ce.decimalFloatingPoint("PART-TARGET");break}case"PART":{let ce=h.partList;ce||(ce=h.partList=[]);const we=g>0?ce[ce.length-1]:void 0,Oe=g++,B=new Jt(Y);Yi(h,B,["BYTERANGE","URI"]);const W=new fv(B,S,t,Oe,we);ce.push(W),S.duration+=W.duration;break}case"PRELOAD-HINT":{const ce=new Jt(Y);Yi(h,ce,["URI"]),h.preloadHint=ce;break}case"RENDITION-REPORT":{const ce=new Jt(Y);Yi(h,ce,["URI"]),h.renditionReports=h.renditionReports||[],h.renditionReports.push(ce);break}default:q.warn(`line parsed but not handled: ${w}`);break}}}b&&!b.relurl?(d.pop(),A-=b.duration,h.partList&&(h.fragmentHint=b)):h.partList&&(Lf(S,b),S.cc=x,h.fragmentHint=S,$&&If(S,$,h));const O=d.length,K=d[0],U=d[O-1];if(A+=h.skippedSegments*h.targetduration,A>0&&O&&U){h.averagetargetduration=A/O;const re=U.sn;h.endSN=re!=="initSegment"?re:0,h.live||(U.endList=!0),K&&(h.startCC=K.cc)}else h.endSN=0,h.startCC=0;return h.fragmentHint&&(A+=h.fragmentHint.duration),h.totalduration=A,h.endCC=x,N>0&&qv(d,N),h}}function wf(s,e,t){var i,n;const a=new Jt(s);Yi(t,a,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const l=(i=a.METHOD)!=null?i:"",h=a.URI,d=a.hexadecimalInteger("IV"),p=a.KEYFORMATVERSIONS,m=(n=a.KEYFORMAT)!=null?n:"identity";h&&a.IV&&!d&&q.error(`Invalid IV: ${a.IV}`);const g=h?Er.resolve(h,e):"",A=(p||"1").split("/").map(Number).filter(Number.isFinite);return new So(l,g,m,A,d)}function _f(s){const t=new Jt(s).decimalFloatingPoint("TIME-OFFSET");return ze(t)?t:null}function Zv(s,e){["video","audio","text"].forEach(t=>{const i=s.filter(n=>zv(n,t));if(i.length){const n=i.filter(a=>a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0);e[`${t}Codec`]=n.length>0?n[0]:i[0],s=s.filter(a=>i.indexOf(a)===-1)}}),e.unknownCodecs=s}function Rf(s,e,t){const i=e[t];i&&(s[t]=i)}function qv(s,e){let t=s[e];for(let i=e;i--;){const n=s[i];if(!n)return;n.programDateTime=t.programDateTime-n.duration*1e3,t=n}}function Lf(s,e){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):e!=null&&e.programDateTime&&(s.programDateTime=e.endProgramDateTime),ze(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function Cf(s,e,t,i){s.relurl=e.URI,e.BYTERANGE&&s.setByteRange(e.BYTERANGE),s.level=t,s.sn="initSegment",i&&(s.levelkeys=i),s.initSegment=null}function If(s,e,t){s.levelkeys=e;const{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(n=>e[n].isCommonEncryption)&&i.push(s)}var Tt={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},tt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Df(s){const{type:e}=s;switch(e){case Tt.AUDIO_TRACK:return tt.AUDIO;case Tt.SUBTITLE_TRACK:return tt.SUBTITLE;default:return tt.MAIN}}function Sc(s,e){let t=s.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class Qv{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(_.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_LOADING,this.onLevelLoading,this),e.off(_.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(_.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,n=t.loader,a=i||n,l=new a(t);return this.loaders[e.type]=l,l}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Tt.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(e,t){const{id:i,level:n,url:a,deliveryDirectives:l}=t;this.load({id:i,level:n,responseType:"text",type:Tt.LEVEL,url:a,deliveryDirectives:l})}onAudioTrackLoading(e,t){const{id:i,groupId:n,url:a,deliveryDirectives:l}=t;this.load({id:i,groupId:n,level:null,responseType:"text",type:Tt.AUDIO_TRACK,url:a,deliveryDirectives:l})}onSubtitleTrackLoading(e,t){const{id:i,groupId:n,url:a,deliveryDirectives:l}=t;this.load({id:i,groupId:n,level:null,responseType:"text",type:Tt.SUBTITLE_TRACK,url:a,deliveryDirectives:l})}load(e){var t;const i=this.hls.config;let n=this.getInternalLoader(e);if(n){const p=n.context;if(p&&p.url===e.url){q.trace("[playlist-loader]: playlist request ongoing");return}q.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),n.abort()}let a;if(e.type===Tt.MANIFEST?a=i.manifestLoadPolicy.default:a=ai({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part){let p;if(e.type===Tt.LEVEL&&e.level!==null?p=this.hls.levels[e.level].details:e.type===Tt.AUDIO_TRACK&&e.id!==null?p=this.hls.audioTracks[e.id].details:e.type===Tt.SUBTITLE_TRACK&&e.id!==null&&(p=this.hls.subtitleTracks[e.id].details),p){const m=p.partTarget,g=p.targetduration;if(m&&g){const A=Math.max(m*3,g*.8)*1e3;a=ai({},a,{maxTimeToFirstByteMs:Math.min(A,a.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(A,a.maxTimeToFirstByteMs)})}}}const l=a.errorRetry||a.timeoutRetry||{},h={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},d={onSuccess:(p,m,g,A)=>{const x=this.getInternalLoader(g);this.resetInternalLoader(g.type);const b=p.data;if(b.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(p,g,new Error("no EXTM3U delimiter"),A||null,m);return}m.parsing.start=performance.now(),Er.isMediaPlaylist(b)?this.handleTrackOrLevelPlaylist(p,m,g,A||null,x):this.handleMasterPlaylist(p,m,g,A)},onError:(p,m,g,A)=>{this.handleNetworkError(m,g,!1,p,A)},onTimeout:(p,m,g)=>{this.handleNetworkError(m,g,!0,void 0,p)}};n.load(e,h,d)}handleMasterPlaylist(e,t,i,n){const a=this.hls,l=e.data,h=Sc(e,i),d=Er.parseMasterPlaylist(l,h);if(d.playlistParsingError){this.handleManifestParsingError(e,i,d.playlistParsingError,n,t);return}const{contentSteering:p,levels:m,sessionData:g,sessionKeys:A,startTimeOffset:x,variableList:b}=d;this.variableList=b;const{AUDIO:S=[],SUBTITLES:w,"CLOSED-CAPTIONS":P}=Er.parseMasterPlaylistMedia(l,h,d);S.length&&!S.some(N=>!N.url)&&m[0].audioCodec&&!m[0].attrs.AUDIO&&(q.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),S.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Jt({}),bitrate:0,url:""})),a.trigger(_.MANIFEST_LOADED,{levels:m,audioTracks:S,subtitles:w,captions:P,contentSteering:p,url:h,stats:t,networkDetails:n,sessionData:g,sessionKeys:A,startTimeOffset:x,variableList:b})}handleTrackOrLevelPlaylist(e,t,i,n,a){const l=this.hls,{id:h,level:d,type:p}=i,m=Sc(e,i),g=ze(h)?h:0,A=ze(d)?d:g,x=Df(i),b=Er.parseLevelPlaylist(e.data,m,A,x,g,this.variableList);if(p===Tt.MANIFEST){const S={attrs:new Jt({}),bitrate:0,details:b,name:"",url:m};l.trigger(_.MANIFEST_LOADED,{levels:[S],audioTracks:[],url:m,stats:t,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=b,this.handlePlaylistLoaded(b,e,t,i,n,a)}handleManifestParsingError(e,t,i,n,a){this.hls.trigger(_.ERROR,{type:et.NETWORK_ERROR,details:de.MANIFEST_PARSING_ERROR,fatal:t.type===Tt.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:n,stats:a})}handleNetworkError(e,t,i=!1,n,a){let l=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${e.type}`;e.type===Tt.LEVEL?l+=`: ${e.level} id: ${e.id}`:(e.type===Tt.AUDIO_TRACK||e.type===Tt.SUBTITLE_TRACK)&&(l+=` id: ${e.id} group-id: "${e.groupId}"`);const h=new Error(l);q.warn(`[playlist-loader]: ${l}`);let d=de.UNKNOWN,p=!1;const m=this.getInternalLoader(e);switch(e.type){case Tt.MANIFEST:d=i?de.MANIFEST_LOAD_TIMEOUT:de.MANIFEST_LOAD_ERROR,p=!0;break;case Tt.LEVEL:d=i?de.LEVEL_LOAD_TIMEOUT:de.LEVEL_LOAD_ERROR,p=!1;break;case Tt.AUDIO_TRACK:d=i?de.AUDIO_TRACK_LOAD_TIMEOUT:de.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Tt.SUBTITLE_TRACK:d=i?de.SUBTITLE_TRACK_LOAD_TIMEOUT:de.SUBTITLE_LOAD_ERROR,p=!1;break}m&&this.resetInternalLoader(e.type);const g={type:et.NETWORK_ERROR,details:d,fatal:p,url:e.url,loader:m,context:e,error:h,networkDetails:t,stats:a};if(n){const A=(t==null?void 0:t.url)||e.url;g.response=Ki({url:A,data:void 0},n)}this.hls.trigger(_.ERROR,g)}handlePlaylistLoaded(e,t,i,n,a,l){const h=this.hls,{type:d,level:p,id:m,groupId:g,deliveryDirectives:A}=n,x=Sc(t,n),b=Df(n),S=typeof n.level=="number"&&b===tt.MAIN?p:void 0;if(!e.fragments.length){const P=new Error("No Segments found in Playlist");h.trigger(_.ERROR,{type:et.NETWORK_ERROR,details:de.LEVEL_EMPTY_ERROR,fatal:!1,url:x,error:P,reason:P.message,response:t,context:n,level:S,parent:b,networkDetails:a,stats:i});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const w=e.playlistParsingError;if(w){h.trigger(_.ERROR,{type:et.NETWORK_ERROR,details:de.LEVEL_PARSING_ERROR,fatal:!1,url:x,error:w,reason:w.message,response:t,context:n,level:S,parent:b,networkDetails:a,stats:i});return}switch(e.live&&l&&(l.getCacheAge&&(e.ageHeader=l.getCacheAge()||0),(!l.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),d){case Tt.MANIFEST:case Tt.LEVEL:h.trigger(_.LEVEL_LOADED,{details:e,level:S||0,id:m||0,stats:i,networkDetails:a,deliveryDirectives:A});break;case Tt.AUDIO_TRACK:h.trigger(_.AUDIO_TRACK_LOADED,{details:e,id:m||0,groupId:g||"",stats:i,networkDetails:a,deliveryDirectives:A});break;case Tt.SUBTITLE_TRACK:h.trigger(_.SUBTITLE_TRACK_LOADED,{details:e,id:m||0,groupId:g||"",stats:i,networkDetails:a,deliveryDirectives:A});break}}}function Of(s,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=s,e.dispatchEvent(t)}function Pf(s,e){const t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(e.id))try{if(s.addCue(e),!s.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){q.debug(`[texttrack-utils]: ${i}`);try{const n=new self.TextTrackCue(e.startTime,e.endTime,e.text);n.id=e.id,s.addCue(n)}catch(n){q.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${n}`)}}t==="disabled"&&(s.mode=t)}function Sn(s){const e=s.mode;if(e==="disabled"&&(s.mode="hidden"),s.cues)for(let t=s.cues.length;t--;)s.removeCue(s.cues[t]);e==="disabled"&&(s.mode=e)}function kc(s,e,t,i){const n=s.mode;if(n==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){const a=ey(s.cues,e,t);for(let l=0;l<a.length;l++)(!i||i(a[l]))&&s.removeCue(a[l])}n==="disabled"&&(s.mode=n)}function Jv(s,e){if(e<s[0].startTime)return 0;const t=s.length-1;if(e>s[t].endTime)return-1;let i=0,n=t;for(;i<=n;){const a=Math.floor((n+i)/2);if(e<s[a].startTime)n=a-1;else if(e>s[a].startTime&&i<t)i=a+1;else return a}return s[i].startTime-e<e-s[n].startTime?i:n}function ey(s,e,t){const i=[],n=Jv(s,e);if(n>-1)for(let a=n,l=s.length;a<l;a++){const h=s[a];if(h.startTime>=e&&h.endTime<=t)i.push(h);else if(h.startTime>t)return i}return i}var xr={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const ty=.25;function wc(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const Na=(()=>{const s=wc();try{new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function _c(s,e){return s.getTime()/1e3-e}function iy(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class ry{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(Sn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const i=e[t];if(i.kind==="metadata"&&i.label==="id3")return Of(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:n}}}=this;if(!i&&!n)return;const{samples:a}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=wc();for(let h=0;h<a.length;h++){const d=a[h].type;if(d===xr.emsg&&!i||!n)continue;const p=uf(a[h].data);if(p){const m=a[h].pts;let g=m+a[h].duration;g>Na&&(g=Na),g-m<=0&&(g=m+ty);for(let x=0;x<p.length;x++){const b=p[x];if(!cf(b)){this.updateId3CueEnds(m,d);const S=new l(m,g,"");S.value=b,d&&(S.type=d),this.id3Track.addCue(S)}}}}}updateId3CueEnds(e,t){var i;const n=(i=this.id3Track)==null?void 0:i.cues;if(n)for(let a=n.length;a--;){const l=n[a];l.type===t&&l.startTime<e&&l.endTime===Na&&(l.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:n}){const{id3Track:a,hls:l}=this;if(!l)return;const{config:{enableEmsgMetadataCues:h,enableID3MetadataCues:d}}=l;if(a&&(h||d)){let p;n==="audio"?p=m=>m.type===xr.audioId3&&d:n==="video"?p=m=>m.type===xr.emsg&&h:p=m=>m.type===xr.audioId3&&d||m.type===xr.emsg&&h,kc(a,t,i,p)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:n}=this,{dateRanges:a}=t,l=Object.keys(a);if(n){const m=Object.keys(i).filter(g=>!l.includes(g));for(let g=m.length;g--;){const A=m[g];Object.keys(i[A].cues).forEach(x=>{n.removeCue(i[A].cues[x])}),delete i[A]}}const h=t.fragments[t.fragments.length-1];if(l.length===0||!ze(h==null?void 0:h.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const d=h.programDateTime/1e3-h.start,p=wc();for(let m=0;m<l.length;m++){const g=l[m],A=a[g],x=i[g],b=(x==null?void 0:x.cues)||{};let S=(x==null?void 0:x.durationKnown)||!1;const w=_c(A.startDate,d);let P=Na;const $=A.endDate;if($)P=_c($,d),S=!0;else if(A.endOnNext&&!S){const I=l.reduce((O,K)=>{const U=a[K];return U.class===A.class&&U.id!==K&&U.startDate>A.startDate&&O.push(U),O},[]).sort((O,K)=>O.startDate.getTime()-K.startDate.getTime())[0];I&&(P=_c(I.startDate,d),S=!0)}const N=Object.keys(A.attr);for(let I=0;I<N.length;I++){const O=N[I];if(!uv(O))continue;let K=b[O];if(K)S&&!x.durationKnown&&(K.endTime=P);else{let U=A.attr[O];K=new p(w,P,""),hv(O)&&(U=iy(U)),K.value={key:O,data:U},K.type=xr.dateRange,K.id=g,this.id3Track.addCue(K),b[O]=K}}i[g]={cues:b,dateRange:A,durationKnown:S}}}}class sy{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(e===null)return null;const{holdBack:t,partHoldBack:i,targetduration:n}=e,{liveSyncDuration:a,liveSyncDurationCount:l,lowLatencyMode:h}=this.config,d=this.hls.userConfig;let p=h&&i||t;(d.liveSyncDuration||d.liveSyncDurationCount||p===0)&&(p=a!==void 0?a:l*n);const m=n,g=1;return p+Math.min(this.stallCount*g,m)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,i=this.levelDetails;if(e===null||t===null||i===null)return null;const n=i.edge,a=e-t-this.edgeStalled,l=n-i.totalduration,h=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(l,a),h)}get drift(){const{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e,levelDetails:t}=this;if(!e||!t)return 0;const i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(_.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(_.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(_.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(_.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var i;t.details===de.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&q.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const i=this.computeLatency();if(i===null)return;this._latency=i;const{lowLatencyMode:n,maxLiveSyncPlaybackRate:a}=this.config;if(!n||a===1)return;const l=this.targetLatency;if(l===null)return;const h=i-l,d=Math.min(this.maxLatency,l+t.targetduration),p=h<d;if(t.live&&p&&h>.05&&this.forwardBufferLength>1){const m=Math.min(2,Math.max(1,a)),g=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;e.playbackRate=Math.min(m,Math.max(1,g))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}const Rc=["NONE","TYPE-0","TYPE-1",null];var ko={No:"",Yes:"YES",v2:"v2"};function ny(s,e){const{canSkipUntil:t,canSkipDateRanges:i,endSN:n}=s,a=e!==void 0?e-n:0;return t&&a<t?i?ko.v2:ko.Yes:ko.No}class $f{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class wo{constructor(e){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=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>t).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(e){const t=e%this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}get audioGroupId(){var e;return(e=this.audioGroupIds)==null?void 0:e[this.urlId]}get textGroupId(){var e;return(e=this.textGroupIds)==null?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}}function Lc(s,e){const t=e.startPTS;if(ze(t)){let i=0,n;e.sn>s.sn?(i=t-s.start,n=s):(i=s.start-t,n=e),n.duration!==i&&(n.duration=i)}else e.sn>s.sn?s.cc===e.cc&&s.minEndPTS?e.start=s.start+(s.minEndPTS-s.start):e.start=s.start+s.duration:e.start=Math.max(s.start-e.duration,0)}function Mf(s,e,t,i,n,a){i-t<=0&&(q.warn("Fragment should have a positive duration",e),i=t+e.duration,a=n+e.duration);let h=t,d=i;const p=e.startPTS,m=e.endPTS;if(ze(p)){const w=Math.abs(p-t);ze(e.deltaPTS)?e.deltaPTS=Math.max(w,e.deltaPTS):e.deltaPTS=w,h=Math.max(t,p),t=Math.min(t,p),n=Math.min(n,e.startDTS),d=Math.min(i,m),i=Math.max(i,m),a=Math.max(a,e.endDTS)}const g=t-e.start;e.start!==0&&(e.start=t),e.duration=i-e.start,e.startPTS=t,e.maxStartPTS=h,e.startDTS=n,e.endPTS=i,e.minEndPTS=d,e.endDTS=a;const A=e.sn;if(!s||A<s.startSN||A>s.endSN)return 0;let x;const b=A-s.startSN,S=s.fragments;for(S[b]=e,x=b;x>0;x--)Lc(S[x],S[x-1]);for(x=b;x<S.length-1;x++)Lc(S[x],S[x+1]);return s.fragmentHint&&Lc(S[S.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,g}function oy(s,e){let t=null;const i=s.fragments;for(let d=i.length-1;d>=0;d--){const p=i[d].initSegment;if(p){t=p;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let n=0,a;if(cy(s,e,(d,p)=>{d.relurl&&(n=d.cc-p.cc),ze(d.startPTS)&&ze(d.endPTS)&&(p.start=p.startPTS=d.startPTS,p.startDTS=d.startDTS,p.maxStartPTS=d.maxStartPTS,p.endPTS=d.endPTS,p.endDTS=d.endDTS,p.minEndPTS=d.minEndPTS,p.duration=d.endPTS-d.startPTS,p.duration&&(a=p),e.PTSKnown=e.alignedSliding=!0),p.elementaryStreams=d.elementaryStreams,p.loader=d.loader,p.stats=d.stats,p.urlId=d.urlId,d.initSegment&&(p.initSegment=d.initSegment,t=d.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(p=>{var m;(!p.initSegment||p.initSegment.relurl===((m=t)==null?void 0:m.relurl))&&(p.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(d=>!d),e.deltaUpdateFailed){q.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let d=e.skippedSegments;d--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=ay(s.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const l=e.fragments;if(n){q.warn("discontinuity sliding from playlist, take drift into account");for(let d=0;d<l.length;d++)l[d].cc+=n}e.skippedSegments&&(e.startCC=e.fragments[0].cc),ly(s.partList,e.partList,(d,p)=>{p.elementaryStreams=d.elementaryStreams,p.stats=d.stats}),a?Mf(e,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):Ff(s,e),l.length&&(e.totalduration=e.edge-l[0].start),e.driftStartTime=s.driftStartTime,e.driftStart=s.driftStart;const h=e.advancedDateTime;if(e.advanced&&h){const d=e.edge;e.driftStart||(e.driftStartTime=h,e.driftStart=d),e.driftEndTime=h,e.driftEnd=d}else e.driftEndTime=s.driftEndTime,e.driftEnd=s.driftEnd,e.advancedDateTime=s.advancedDateTime}function ay(s,e,t){const i=ai({},s);return t&&t.forEach(n=>{delete i[n]}),Object.keys(e).forEach(n=>{const a=new ef(e[n].attr,i[n]);a.isValid?i[n]=a:q.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[n].attr)}"`)}),i}function ly(s,e,t){if(s&&e){let i=0;for(let n=0,a=s.length;n<=a;n++){const l=s[n],h=e[n+i];l&&h&&l.index===h.index&&l.fragment.sn===h.fragment.sn?t(l,h):i--}}}function cy(s,e,t){const i=e.skippedSegments,n=Math.max(s.startSN,e.startSN)-e.startSN,a=(s.fragmentHint?1:0)+(i?e.endSN:Math.min(s.endSN,e.endSN))-e.startSN,l=e.startSN-s.startSN,h=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,d=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments;for(let p=n;p<=a;p++){const m=d[l+p];let g=h[p];i&&!g&&p<i&&(g=e.fragments[p]=m),m&&g&&t(m,g)}}function Ff(s,e){const t=e.startSN+e.skippedSegments-s.startSN,i=s.fragments;t<0||t>=i.length||Cc(e,i[t].start)}function Cc(s,e){if(e){const t=s.fragments;for(let i=s.skippedSegments;i<t.length;i++)t[i].start+=e;s.fragmentHint&&(s.fragmentHint.start+=e)}}function uy(s,e=1/0){let t=1e3*s.targetduration;if(s.updated){const i=s.fragments,n=4;if(i.length&&t*n>e){const a=i[i.length-1].duration*1e3;a<t&&(t=a)}}else t/=2;return Math.round(t)}function hy(s,e,t){if(!(s!=null&&s.details))return null;const i=s.details;let n=i.fragments[e-i.startSN];return n||(n=i.fragmentHint,n&&n.sn===e)?n:e<i.startSN&&t&&t.sn===e?t:null}function Nf(s,e,t){var i;return s!=null&&s.details?Uf((i=s.details)==null?void 0:i.partList,e,t):null}function Uf(s,e,t){if(s)for(let i=s.length;i--;){const n=s[i];if(n.index===t&&n.fragment.sn===e)return n}return null}function Ua(s){switch(s.details){case de.FRAG_LOAD_TIMEOUT:case de.KEY_LOAD_TIMEOUT:case de.LEVEL_LOAD_TIMEOUT:case de.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Bf(s,e){const t=Ua(e);return s.default[`${t?"timeout":"error"}Retry`]}function Ic(s,e){const t=s.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*s.retryDelayMs,s.maxRetryDelayMs)}function Gf(s){return Ki(Ki({},s),{errorRetry:null,timeoutRetry:null})}function Ba(s,e,t,i){return!!s&&e<s.maxNumRetry&&(fy(i)||!!t)}function fy(s){return s===0&&navigator.onLine===!1||!!s&&(s<400||s>499)}const Vf={search:function(s,e){let t=0,i=s.length-1,n=null,a=null;for(;t<=i;){n=(t+i)/2|0,a=s[n];const l=e(a);if(l>0)t=n+1;else if(l<0)i=n-1;else return a}return null}};function dy(s,e,t){if(e===null||!Array.isArray(s)||!s.length||!ze(e))return null;const i=s[0].programDateTime;if(e<(i||0))return null;const n=s[s.length-1].endProgramDateTime;if(e>=(n||0))return null;t=t||0;for(let a=0;a<s.length;++a){const l=s[a];if(py(e,t,l))return l}return null}function _o(s,e,t=0,i=0){let n=null;if(s?n=e[s.sn-e[0].sn+1]||null:t===0&&e[0].start===0&&(n=e[0]),n&&Dc(t,i,n)===0)return n;const a=Vf.search(e,Dc.bind(null,t,i));return a&&(a!==s||!n)?a:n}function Dc(s=0,e=0,t){if(t.start<=s&&t.start+t.duration>s)return 0;const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=s?1:t.start-i>s&&t.start?-1:0}function py(s,e,t){const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>s}function my(s,e){return Vf.search(s,t=>t.cc<e?1:t.cc>e?-1:0)}const gy=3e5;var Li={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},lr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class vy{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=q.log.bind(q,"[info]:"),this.warn=q.warn.bind(q,"[warning]:"),this.error=q.error.bind(q,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(_.ERROR,this.onError,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(_.ERROR,this.onError,this),e.off(_.ERROR,this.onErrorOut,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return(e==null?void 0:e.type)===tt.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var i,n;if(t.fatal)return;const a=this.hls,l=t.context;switch(t.details){case de.FRAG_LOAD_ERROR:case de.FRAG_LOAD_TIMEOUT:case de.KEY_LOAD_ERROR:case de.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case de.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction={action:Li.DoNothing,flags:lr.None};return}case de.FRAG_GAP:case de.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Li.SendAlternateToPenaltyBox;return}case de.LEVEL_EMPTY_ERROR:case de.LEVEL_PARSING_ERROR:{var h,d;const p=t.parent===tt.MAIN?t.level:a.loadLevel;t.details===de.LEVEL_EMPTY_ERROR&&((h=t.context)!=null&&(d=h.levelDetails)!=null&&d.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,p):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,p))}return;case de.LEVEL_LOAD_ERROR:case de.LEVEL_LOAD_TIMEOUT:typeof(l==null?void 0:l.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l.level));return;case de.AUDIO_TRACK_LOAD_ERROR:case de.AUDIO_TRACK_LOAD_TIMEOUT:case de.SUBTITLE_LOAD_ERROR:case de.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){const p=a.levels[a.loadLevel];if(p&&(l.type===Tt.AUDIO_TRACK&&l.groupId===p.audioGroupId||l.type===Tt.SUBTITLE_TRACK&&l.groupId===p.textGroupId)){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.loadLevel),t.errorAction.action=Li.SendAlternateToPenaltyBox,t.errorAction.flags=lr.MoveAllAlternatesMatchingHost;return}}return;case de.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const p=a.levels[a.loadLevel],m=p==null?void 0:p.attrs["HDCP-LEVEL"];m&&(t.errorAction={action:Li.SendAlternateToPenaltyBox,flags:lr.MoveAllAlternatesMatchingHDCP,hdcpLevel:m})}return;case de.BUFFER_ADD_CODEC_ERROR:case de.REMUX_ALLOC_ERROR:t.errorAction=this.getLevelSwitchAction(t,(n=t.level)!=null?n:a.loadLevel);return;case de.INTERNAL_EXCEPTION:case de.BUFFER_APPENDING_ERROR:case de.BUFFER_APPEND_ERROR:case de.BUFFER_FULL_ERROR:case de.LEVEL_SWITCH_ERROR:case de.BUFFER_STALLED_ERROR:case de.BUFFER_SEEK_OVER_HOLE:case de.BUFFER_NUDGE_ON_STALL:t.errorAction={action:Li.DoNothing,flags:lr.None};return}if(t.type===et.KEY_SYSTEM_ERROR){const p=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,p);return}}getPlaylistRetryOrSwitchAction(e,t){var i;const n=this.hls,a=Bf(n.config.playlistLoadPolicy,e),l=this.playlistError++,h=(i=e.response)==null?void 0:i.code;if(Ba(a,l,Ua(e),h))return{action:Li.RetryRequest,flags:lr.None,retryConfig:a,retryCount:l};const p=this.getLevelSwitchAction(e,t);return a&&(p.retryConfig=a,p.retryCount=l),p}getFragRetryOrSwitchAction(e){const t=this.hls,i=this.getVariantLevelIndex(e.frag),n=t.levels[i],{fragLoadPolicy:a,keyLoadPolicy:l}=t.config,h=Bf(e.details.startsWith("key")?l:a,e),d=t.levels.reduce((g,A)=>g+A.fragmentError,0);if(n){var p;e.details!==de.FRAG_GAP&&n.fragmentError++;const g=(p=e.response)==null?void 0:p.code;if(Ba(h,d,Ua(e),g))return{action:Li.RetryRequest,flags:lr.None,retryConfig:h,retryCount:d}}const m=this.getLevelSwitchAction(e,i);return h&&(m.retryConfig=h,m.retryCount=d),m}getLevelSwitchAction(e,t){const i=this.hls;t==null&&(t=i.loadLevel);const n=this.hls.levels[t];if(n&&(n.loadError++,i.autoLevelEnabled)){var a,l;let h=-1;const{levels:d,loadLevel:p,minAutoLevel:m,maxAutoLevel:g}=i,A=(a=e.frag)==null?void 0:a.type,{type:x,groupId:b}=(l=e.context)!=null?l:{};for(let S=d.length;S--;){const w=(S+p)%d.length;if(w!==p&&w>=m&&w<=g&&d[w].loadError===0){const P=d[w];if(e.details===de.FRAG_GAP&&e.frag){const $=d[w].details;if($){const N=_o(e.frag,$.fragments,e.frag.start);if(N!=null&&N.gap)continue}}else{if(x===Tt.AUDIO_TRACK&&b===P.audioGroupId||x===Tt.SUBTITLE_TRACK&&b===P.textGroupId)continue;if(A===tt.AUDIO&&n.audioGroupId===P.audioGroupId||A===tt.SUBTITLE&&n.textGroupId===P.textGroupId)continue}h=w;break}}if(h>-1&&i.loadLevel!==h)return e.levelRetry=!0,this.playlistError=0,{action:Li.SendAlternateToPenaltyBox,flags:lr.None,nextAutoLevel:h}}return{action:Li.SendAlternateToPenaltyBox,flags:lr.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case Li.DoNothing:break;case Li.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==de.FRAG_GAP&&(t.fatal=!0);break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,i=e.errorAction;if(!i)return;const{flags:n,hdcpLevel:a,nextAutoLevel:l}=i;switch(n){case lr.None:this.switchLevel(e,l);break;case lr.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(e));break;case lr.MoveAllAlternatesMatchingHDCP:a&&(t.maxHdcpLevel=Rc[Rc.indexOf(a)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(e,l)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(e){const{hls:t,penalizedRenditions:i}=this,n=e.parent===tt.MAIN?e.level:t.loadLevel,a=t.levels[n],l=a.url.length,h=e.frag?e.frag.urlId:a.urlId;a.urlId===h&&(!e.frag||a.details)&&this.penalizeRendition(a,e);for(let d=1;d<l;d++){const p=(h+d)%l,m=i[p];if(!m||yy(m,e,i[h]))return this.warn(`Switching to Redundant Stream ${p+1}/${l}: "${a.url[p]}" after ${e.details}`),this.playlistError=0,t.levels.forEach(g=>{g.urlId=p}),t.nextLoadLevel=n,!0}return!1}penalizeRendition(e,t){const{penalizedRenditions:i}=this,n=i[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};n.lastErrorPerfMs=performance.now(),n.errors.push(t),n.details=e.details,i[e.urlId]=n}}function yy(s,e,t){if(performance.now()-s.lastErrorPerfMs>gy)return!0;const i=s.details;if(e.details===de.FRAG_GAP&&i&&e.frag){const n=e.frag.start,a=_o(null,i.fragments,n);if(a&&!a.gap)return!0}if(t&&s.errors.length<t.errors.length){const n=s.errors[s.errors.length-1];if(i&&n.frag&&e.frag&&Math.abs(n.frag.start-e.frag.start)>i.targetduration*3)return!0}return!1}class Oc{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=q.log.bind(q,`${t}:`),this.warn=q.warn.bind(q,`${t}:`),this.hls=e}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(e,t){const i=t==null?void 0:t.renditionReports;if(i){let n=-1;for(let a=0;a<i.length;a++){const l=i[a];let h;try{h=new self.URL(l.URI,t.url).href}catch(d){q.warn(`Could not construct new URL for Rendition Report: ${d}`),h=l.URI||""}if(h===e){n=a;break}else h===e.substring(0,h.length)&&(n=a)}if(n!==-1){const a=i[n],l=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn);let h=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const d=Math.min(t.age-t.partTarget,t.targetduration);h>=0&&d>t.partTarget&&(h+=1)}return new $f(l,h>=0?h:void 0,ko.No)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,i){const{details:n,stats:a}=t,l=self.performance.now(),h=a.loading.first?Math.max(0,l-a.loading.first):0;if(n.advancedDateTime=Date.now()-h,n.live||i!=null&&i.live){if(n.reloaded(i),i&&this.log(`live playlist ${e} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),i&&n.fragments.length>0&&oy(i,n),!this.canLoad||!n.live)return;let d,p,m;if(n.canBlockReload&&n.endSN&&n.advanced){const w=this.hls.config.lowLatencyMode,P=n.lastPartSn,$=n.endSN,N=n.lastPartIndex,I=N!==-1,O=P===$,K=w?0:N;I?(p=O?$+1:P,m=O?K:N+1):p=$+1;const U=n.age,re=U+n.ageHeader;let ne=Math.min(re-n.partTarget,n.targetduration*1.5);if(ne>0){if(i&&ne>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${ne} with playlist age: ${n.age}`),ne=0;else{const Y=Math.floor(ne/n.targetduration);if(p+=Y,m!==void 0){const Ee=Math.round(ne%n.targetduration/n.partTarget);m+=Ee}this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${U.toFixed(2)}s goal: ${ne} skip sn ${Y} to part ${m}`)}n.tuneInGoal=ne}if(d=this.getDeliveryDirectives(n,t.deliveryDirectives,p,m),w||!O){this.loadPlaylist(d);return}}else(n.canBlockReload||n.canSkipUntil)&&(d=this.getDeliveryDirectives(n,t.deliveryDirectives,p,m));const g=this.hls.mainForwardBufferInfo,A=g?g.end-g.len:0,x=(n.edge-A)*1e3,b=uy(n,x);n.updated&&l>this.requestScheduled+b&&(this.requestScheduled=a.loading.start),p!==void 0&&n.canBlockReload?this.requestScheduled=a.loading.first+b-(n.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+b<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=b);let S=this.requestScheduled-l;S=Math.max(0,S),this.log(`reload live playlist ${e} in ${Math.round(S)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(d),S)}else this.clearTimer()}getDeliveryDirectives(e,t,i,n){let a=ny(e,i);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,a=ko.No),new $f(i,n,a)}checkRetry(e){const t=e.details,i=Ua(e),n=e.errorAction,{action:a,retryCount:l=0,retryConfig:h}=n||{},d=!!n&&!!h&&(a===Li.RetryRequest||!n.resolved&&a===Li.SendAlternateToPenaltyBox);if(d){var p;if(this.requestScheduled=-1,l>=h.maxNumRetry)return!1;if(i&&(p=e.context)!=null&&p.deliveryDirectives)this.warn(`Retrying playlist loading ${l+1}/${h.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const m=Ic(h,l);this.timer=self.setTimeout(()=>this.loadPlaylist(),m),this.warn(`Retrying playlist loading ${l+1}/${h.maxNumRetry} after "${t}" in ${m}ms`)}e.levelRetry=!0,n.resolved=!0}return d}}let Pc;class Ay extends Oc{constructor(e,t){super(e,"[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=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this),e.on(_.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this),e.off(_.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(e,t){this.resetLevels()}onManifestLoaded(e,t){const i=[],n={};let a;t.levels.forEach(l=>{var h;const d=l.attrs;((h=l.audioCodec)==null?void 0:h.indexOf("mp4a.40.34"))!==-1&&(Pc||(Pc=/chrome|firefox/i.test(navigator.userAgent)),Pc&&(l.audioCodec=void 0));const{AUDIO:p,CODECS:m,"FRAME-RATE":g,"PATHWAY-ID":A,RESOLUTION:x,SUBTITLES:b}=d,w=`${`${A||"."}-`}${l.bitrate}-${x}-${g}-${m}`;a=n[w],a?a.addFallback(l):(a=new wo(l),n[w]=a,i.push(a)),Ga(a,"audio",p),Ga(a,"text",b)}),this.filterAndSortMediaOptions(i,t)}filterAndSortMediaOptions(e,t){let i=[],n=[],a=!1,l=!1,h=!1,d=e.filter(({audioCodec:x,videoCodec:b,width:S,height:w,unknownCodecs:P})=>(a||(a=!!(S&&w)),l||(l=!!b),h||(h=!!x),!(P!=null&&P.length)&&(!x||Tc(x,"audio"))&&(!b||Tc(b,"video"))));if((a||l)&&h&&(d=d.filter(({videoCodec:x,width:b,height:S})=>!!x||!!(b&&S))),d.length===0){Promise.resolve().then(()=>{if(this.hls){const x=new Error("no level with compatible codecs found in manifest");this.hls.trigger(_.ERROR,{type:et.MEDIA_ERROR,details:de.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:x,reason:x.message})}});return}t.audioTracks&&(i=t.audioTracks.filter(x=>!x.audioCodec||Tc(x.audioCodec,"audio")),Hf(i)),t.subtitles&&(n=t.subtitles,Hf(n));const p=d.slice(0);d.sort((x,b)=>x.attrs["HDCP-LEVEL"]!==b.attrs["HDCP-LEVEL"]?(x.attrs["HDCP-LEVEL"]||"")>(b.attrs["HDCP-LEVEL"]||"")?1:-1:x.bitrate!==b.bitrate?x.bitrate-b.bitrate:x.attrs["FRAME-RATE"]!==b.attrs["FRAME-RATE"]?x.attrs.decimalFloatingPoint("FRAME-RATE")-b.attrs.decimalFloatingPoint("FRAME-RATE"):x.attrs.SCORE!==b.attrs.SCORE?x.attrs.decimalFloatingPoint("SCORE")-b.attrs.decimalFloatingPoint("SCORE"):a&&x.height!==b.height?x.height-b.height:0);let m=p[0];if(this.steering&&(d=this.steering.filterParsedLevels(d),d.length!==p.length)){for(let x=0;x<p.length;x++)if(p[x].pathwayId===d[0].pathwayId){m=p[x];break}}this._levels=d;for(let x=0;x<d.length;x++)if(d[x]===m){this._firstLevel=x,this.log(`manifest loaded, ${d.length} level(s) found, first bitrate: ${m.bitrate}`);break}const g=h&&!l,A={levels:d,audioTracks:i,subtitleTracks:n,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:h,video:l,altAudio:!g&&i.some(x=>!!x.url)};this.hls.trigger(_.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(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const m=new Error("invalid level idx"),g=e<0;if(this.hls.trigger(_.ERROR,{type:et.OTHER_ERROR,details:de.LEVEL_SWITCH_ERROR,level:e,fatal:g,error:m,reason:m.message}),g)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,n=this.currentLevel,a=n?n.attrs["PATHWAY-ID"]:void 0,l=t[e],h=l.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=l,i===e&&l.details&&n&&a===h)return;this.log(`Switching to level ${e}${h?" with Pathway "+h:""} from level ${i}${a?" with Pathway "+a:""}`);const d=ai({},l,{level:e,maxBitrate:l.maxBitrate,attrs:l.attrs,uri:l.uri,urlId:l.urlId});delete d._attrs,delete d._urlId,this.hls.trigger(_.LEVEL_SWITCHING,d);const p=l.details;if(!p||p.live){const m=this.switchParams(l.uri,n==null?void 0:n.details);this.loadPlaylist(m)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this._firstLevel}else return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===Tt.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(t!==void 0&&t.type===tt.MAIN){const i=this._levels[t.level];i!==void 0&&(i.loadError=0)}}onLevelLoaded(e,t){var i;const{level:n,details:a}=t,l=this._levels[n];if(!l){var h;this.warn(`Invalid level index ${n}`),(h=t.deliveryDirectives)!=null&&h.skip&&(a.deltaUpdateFailed=!0);return}n===this.currentLevelIndex?(l.fragmentError===0&&(l.loadError=0),this.playlistLoaded(n,t,l.details)):(i=t.deliveryDirectives)!=null&&i.skip&&(a.deltaUpdateFailed=!0)}onAudioTrackSwitched(e,t){const i=this.currentLevel;if(!i)return;const n=this.hls.audioTracks[t.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==n){let a=-1;for(let l=0;l<i.audioGroupIds.length;l++)if(i.audioGroupIds[l]===n){a=l;break}a!==-1&&a!==i.urlId&&(i.urlId=a,this.canLoad&&this.startLoad())}}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){const n=i.urlId;let a=i.uri;if(e)try{a=e.addDirectives(a)}catch(h){this.warn(`Could not construct new URL with HLS Delivery Directives: ${h}`)}const l=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${l?" Pathway "+l:""} URI ${n+1}/${i.url.length} ${a}`),this.clearTimer(),this.hls.trigger(_.LEVEL_LOADING,{url:a,level:t,id:n,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e,t){const i=(a,l)=>l!==t,n=this._levels.filter((a,l)=>l!==e?!0:a.url.length>1&&t!==void 0?(a.url=a.url.filter(i),a.audioGroupIds&&(a.audioGroupIds=a.audioGroupIds.filter(i)),a.textGroupIds&&(a.textGroupIds=a.textGroupIds.filter(i)),a.urlId=0,!0):(this.steering&&this.steering.removeLevel(a),!1));this.hls.trigger(_.LEVELS_UPDATED,{levels:n})}onLevelsUpdated(e,{levels:t}){t.forEach((i,n)=>{const{details:a}=i;a!=null&&a.fragments&&a.fragments.forEach(l=>{l.level=n})}),this._levels=t}}function Ga(s,e,t){t&&(e==="audio"?(s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds[s.url.length-1]=t):e==="text"&&(s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds[s.url.length-1]=t))}function Hf(s){const e={};s.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}var di={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Ey{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(_.BUFFER_APPENDED,this.onBufferAppended,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(_.BUFFER_APPENDED,this.onBufferAppended,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const i=this.activePartLists[t];if(i)for(let n=i.length;n--;){const a=i[n];if(!a)break;const l=a.end;if(a.start<=e&&l!==null&&e<=l)return a}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:i}=this,n=Object.keys(i);for(let a=n.length;a--;){const l=i[n[a]];if((l==null?void 0:l.body.type)===t&&l.buffered){const h=l.body;if(h.start<=e&&e<=h.end)return h}}return null}detectEvictedFragments(e,t,i,n){this.timeRanges&&(this.timeRanges[e]=t);const a=(n==null?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach(l=>{const h=this.fragments[l];if(!h||a>=h.body.sn)return;if(!h.buffered&&!h.loaded){h.body.type===i&&this.removeFragment(h.body);return}const d=h.range[e];d&&d.time.some(p=>{const m=!this.isTimeBuffered(p.startPTS,p.endPTS,t);return m&&this.removeFragment(h.body),m})})}detectPartialFragments(e){const t=this.timeRanges,{frag:i,part:n}=e;if(!t||i.sn==="initSegment")return;const a=kn(i),l=this.fragments[a];if(!l||l.buffered&&i.gap)return;const h=!i.relurl;Object.keys(t).forEach(d=>{const p=i.elementaryStreams[d];if(!p)return;const m=t[d],g=h||p.partial===!0;l.range[d]=this.getBufferedTimes(i,n,g,m)}),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),Va(l)||this.removeParts(i.sn-1,i.type)):this.removeFragment(l.body)}removeParts(e,t){const i=this.activePartLists[t];i&&(this.activePartLists[t]=i.filter(n=>n.fragment.sn>=e))}fragBuffered(e,t){const i=kn(e);let n=this.fragments[i];!n&&t&&(n=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,n.buffered=!0)}getBufferedTimes(e,t,i,n){const a={time:[],partial:i},l=e.start,h=e.end,d=e.minEndPTS||h,p=e.maxStartPTS||l;for(let m=0;m<n.length;m++){const g=n.start(m)-this.bufferPadding,A=n.end(m)+this.bufferPadding;if(p>=g&&d<=A){a.time.push({startPTS:Math.max(l,n.start(m)),endPTS:Math.min(h,n.end(m))});break}else if(l<A&&h>g)a.partial=!0,a.time.push({startPTS:Math.max(l,n.start(m)),endPTS:Math.min(h,n.end(m))});else if(h<=g)break}return a}getPartialFragment(e){let t=null,i,n,a,l=0;const{bufferPadding:h,fragments:d}=this;return Object.keys(d).forEach(p=>{const m=d[p];m&&Va(m)&&(n=m.body.start-h,a=m.body.end+h,e>=n&&e<=a&&(i=Math.min(e-n,a-e),l<=i&&(t=m.body,l=i)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||Va(t))}getState(e){const t=kn(e),i=this.fragments[t];return i?i.buffered?Va(i)?di.PARTIAL:di.OK:di.APPENDING:di.NOT_LOADED}isTimeBuffered(e,t,i){let n,a;for(let l=0;l<i.length;l++){if(n=i.start(l)-this.bufferPadding,a=i.end(l)+this.bufferPadding,e>=n&&t<=a)return!0;if(t<=n)return!1}return!1}onFragLoaded(e,t){const{frag:i,part:n}=t;if(i.sn==="initSegment"||i.bitrateTest)return;const a=n?null:t,l=kn(i);this.fragments[l]={body:i,appendedPTS:null,loaded:a,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:i,part:n,timeRanges:a}=t;if(i.sn==="initSegment")return;const l=i.type;if(n){let h=this.activePartLists[l];h||(this.activePartLists[l]=h=[]),h.push(n)}this.timeRanges=a,Object.keys(a).forEach(h=>{const d=a[h];this.detectEvictedFragments(h,d,l,n)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=kn(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,n,a){n&&!this.hasGaps||Object.keys(this.fragments).forEach(l=>{const h=this.fragments[l];if(!h)return;const d=h.body;d.type!==i||n&&!d.gap||d.start<t&&d.end>e&&(h.buffered||a)&&this.removeFragment(d)})}removeFragment(e){const t=kn(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const n=e.sn;this.activePartLists[e.type]=i.filter(a=>a.fragment.sn!==n)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Va(s){var e,t,i;return s.buffered&&(s.body.gap||((e=s.range.video)==null?void 0:e.partial)||((t=s.range.audio)==null?void 0:t.partial)||((i=s.range.audiovideo)==null?void 0:i.partial))}function kn(s){return`${s.type}_${s.level}_${s.urlId}_${s.sn}`}const Wf=Math.pow(2,17);class xy{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const i=e.url;if(!i)return Promise.reject(new Jr({type:et.NETWORK_ERROR,details:de.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const n=this.config,a=n.fLoader,l=n.loader;return new Promise((h,d)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(x=>x[0]==="GAP")){d(Kf(e));return}else e.gap=!1;const p=this.loader=e.loader=a?new a(n):new l(n),m=jf(e),g=Gf(n.fragLoadPolicy.default),A={loadPolicy:g,timeout:g.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Wf};e.stats=p.stats,p.load(m,A,{onSuccess:(x,b,S,w)=>{this.resetLoader(e,p);let P=x.data;S.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(P.slice(0,16)),P=P.slice(16)),h({frag:e,part:null,payload:P,networkDetails:w})},onError:(x,b,S,w)=>{this.resetLoader(e,p),d(new Jr({type:et.NETWORK_ERROR,details:de.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Ki({url:i,data:void 0},x),error:new Error(`HTTP Error ${x.code} ${x.text}`),networkDetails:S,stats:w}))},onAbort:(x,b,S)=>{this.resetLoader(e,p),d(new Jr({type:et.NETWORK_ERROR,details:de.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:S,stats:x}))},onTimeout:(x,b,S)=>{this.resetLoader(e,p),d(new Jr({type:et.NETWORK_ERROR,details:de.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:S,stats:x}))},onProgress:(x,b,S,w)=>{t&&t({frag:e,part:null,payload:S,networkDetails:w})}})})}loadPart(e,t,i){this.abort();const n=this.config,a=n.fLoader,l=n.loader;return new Promise((h,d)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){d(Kf(e,t));return}const p=this.loader=e.loader=a?new a(n):new l(n),m=jf(e,t),g=Gf(n.fragLoadPolicy.default),A={loadPolicy:g,timeout:g.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Wf};t.stats=p.stats,p.load(m,A,{onSuccess:(x,b,S,w)=>{this.resetLoader(e,p),this.updateStatsFromPart(e,t);const P={frag:e,part:t,payload:x.data,networkDetails:w};i(P),h(P)},onError:(x,b,S,w)=>{this.resetLoader(e,p),d(new Jr({type:et.NETWORK_ERROR,details:de.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Ki({url:m.url,data:void 0},x),error:new Error(`HTTP Error ${x.code} ${x.text}`),networkDetails:S,stats:w}))},onAbort:(x,b,S)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,p),d(new Jr({type:et.NETWORK_ERROR,details:de.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:S,stats:x}))},onTimeout:(x,b,S)=>{this.resetLoader(e,p),d(new Jr({type:et.NETWORK_ERROR,details:de.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:S,stats:x}))}})})}updateStatsFromPart(e,t){const i=e.stats,n=t.stats,a=n.total;if(i.loaded+=n.loaded,a){const d=Math.round(e.duration/t.duration),p=Math.min(Math.round(i.loaded/a),d),g=(d-p)*Math.round(i.loaded/p);i.total=i.loaded+g}else i.total=Math.max(i.loaded,i.total);const l=i.loading,h=n.loading;l.start?l.first+=h.first-h.start:(l.start=h.start,l.first=h.first),l.end=h.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function jf(s,e=null){const t=e||s,i={frag:s,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},n=t.byteRangeStartOffset,a=t.byteRangeEndOffset;if(ze(n)&&ze(a)){var l;let h=n,d=a;if(s.sn==="initSegment"&&((l=s.decryptdata)==null?void 0:l.method)==="AES-128"){const p=a-n;p%16&&(d=a+(16-p%16)),n!==0&&(i.resetIV=!0,h=n-16)}i.rangeStart=h,i.rangeEnd=d}return i}function Kf(s,e){const t=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:et.MEDIA_ERROR,details:de.FRAG_GAP,fatal:!1,frag:s,error:t,networkDetails:null};return e&&(i.part=e),(e||s).stats.aborted=!0,new Jr(i)}class Jr extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class by{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const t in this.keyUriToKeyInfo){const i=this.keyUriToKeyInfo[t].loader;if(i){if(e&&e!==i.context.frag.type)return;i.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=de.KEY_LOAD_ERROR,i,n,a){return new Jr({type:et.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:i,networkDetails:n})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:n}=e;for(let a=0;a<t.length;a++){const l=t[a];if(n<=l.cc&&(i==="initSegment"||l.sn==="initSegment"||i<l.sn)){this.emeController.selectKeySystemFormat(l).then(h=>{l.setKeyFormat(h)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,n;t&&e.setKeyFormat(t);const a=e.decryptdata;if(!a){const p=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,de.KEY_LOAD_ERROR,p))}const l=a.uri;if(!l)return Promise.reject(this.createKeyLoadError(e,de.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${l}"`)));let h=this.keyUriToKeyInfo[l];if((i=h)!=null&&i.decryptdata.key)return a.key=h.decryptdata.key,Promise.resolve({frag:e,keyInfo:h});if((n=h)!=null&&n.keyLoadPromise){var d;switch((d=h.mediaKeySessionContext)==null?void 0:d.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return h.keyLoadPromise.then(p=>(a.key=p.keyInfo.decryptdata.key,{frag:e,keyInfo:h}))}}switch(h=this.keyUriToKeyInfo[l]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return a.keyFormat==="identity"?this.loadKeyHTTP(h,e):this.loadKeyEME(h,e);case"AES-128":return this.loadKeyHTTP(h,e);default:return Promise.reject(this.createKeyLoadError(e,de.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${a.method}"`)))}}loadKeyEME(e,t){const i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const n=this.emeController.loadKey(i);if(n)return(e.keyLoadPromise=n.then(a=>(e.mediaKeySessionContext=a,i))).catch(a=>{throw e.keyLoadPromise=null,a})}return Promise.resolve(i)}loadKeyHTTP(e,t){const i=this.config,n=i.loader,a=new n(i);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise((l,h)=>{const d={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},p=i.keyLoadPolicy.default,m={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},g={onSuccess:(A,x,b,S)=>{const{frag:w,keyInfo:P,url:$}=b;if(!w.decryptdata||P!==this.keyUriToKeyInfo[$])return h(this.createKeyLoadError(w,de.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),S));P.decryptdata.key=w.decryptdata.key=new Uint8Array(A.data),w.keyLoader=null,P.loader=null,l({frag:w,keyInfo:P})},onError:(A,x,b,S)=>{this.resetLoader(x),h(this.createKeyLoadError(t,de.KEY_LOAD_ERROR,new Error(`HTTP Error ${A.code} loading key ${A.text}`),b,Ki({url:d.url,data:void 0},A)))},onTimeout:(A,x,b)=>{this.resetLoader(x),h(this.createKeyLoadError(t,de.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),b))},onAbort:(A,x,b)=>{this.resetLoader(x),h(this.createKeyLoadError(t,de.INTERNAL_ABORTED,new Error("key loading aborted"),b))}};a.load(d,m,g)})}resetLoader(e){const{frag:t,keyInfo:i,url:n}=e,a=i.loader;t.keyLoader===a&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[n],a&&a.destroy()}}class Ty{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!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 Sy={length:0,start:()=>0,end:()=>0};class Nt{static isBuffered(e,t){try{if(e){const i=Nt.getBuffered(e);for(let n=0;n<i.length;n++)if(t>=i.start(n)&&t<=i.end(n))return!0}}catch{}return!1}static bufferInfo(e,t,i){try{if(e){const n=Nt.getBuffered(e),a=[];let l;for(l=0;l<n.length;l++)a.push({start:n.start(l),end:n.end(l)});return this.bufferedInfo(a,t,i)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.sort(function(p,m){const g=p.start-m.start;return g||m.end-p.end});let n=[];if(i)for(let p=0;p<e.length;p++){const m=n.length;if(m){const g=n[m-1].end;e[p].start-g<i?e[p].end>g&&(n[m-1].end=e[p].end):n.push(e[p])}else n.push(e[p])}else n=e;let a=0,l,h=t,d=t;for(let p=0;p<n.length;p++){const m=n[p].start,g=n[p].end;if(t+i>=m&&t<g)h=m,d=g,a=d-t;else if(t+i<m){l=m;break}}return{len:a,start:h||0,end:d||0,nextStart:l}}static getBuffered(e){try{return e.buffered}catch(t){return q.log("failed to get media.buffered",t),Sy}}}class $c{constructor(e,t,i,n=0,a=-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=Ha(),this.buffering={audio:Ha(),video:Ha(),audiovideo:Ha()},this.level=e,this.sn=t,this.id=i,this.size=n,this.part=a,this.partial=l}}function Ha(){return{start:0,executeStart:0,executeEnd:0,end:0}}function zf(s,e){let t=null;for(let i=0,n=s.length;i<n;i++){const a=s[i];if(a&&a.cc===e){t=a;break}}return t}function ky(s,e,t){return!!(e.details&&(t.endCC>t.startCC||s&&s.cc<t.startCC))}function wy(s,e,t=0){const i=s.fragments,n=e.fragments;if(!n.length||!i.length){q.log("No fragments to align");return}const a=zf(i,n[0].cc);if(!a||a&&!a.startPTS){q.log("No frag in previous level to align on");return}return a}function Yf(s,e){if(s){const t=s.start+e;s.start=s.startPTS=t,s.endPTS=t+s.duration}}function Mc(s,e){const t=e.fragments;for(let i=0,n=t.length;i<n;i++)Yf(t[i],s);e.fragmentHint&&Yf(e.fragmentHint,s),e.alignedSliding=!0}function _y(s,e,t){e&&(Ry(s,t,e),!t.alignedSliding&&e.details&&Ly(t,e.details),!t.alignedSliding&&e.details&&!t.skippedSegments&&Ff(e.details,t))}function Ry(s,e,t){if(ky(s,t,e)){const i=wy(t.details,e);i&&ze(i.start)&&(q.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),Mc(i.start,e))}}function Ly(s,e){if(!e.fragments.length||!s.hasProgramDateTime||!e.hasProgramDateTime)return;const t=e.fragments[0].programDateTime,i=s.fragments[0].programDateTime,n=(i-t)/1e3+e.fragments[0].start;n&&ze(n)&&(q.log(`Adjusting PTS using programDateTime delta ${i-t}ms, sliding:${n.toFixed(3)} ${s.url} `),Mc(n,s))}function Xf(s,e){if(!s.hasProgramDateTime||!e.hasProgramDateTime)return;const t=s.fragments,i=e.fragments;if(!t.length||!i.length)return;const n=Math.round(i.length/2)-1,a=i[n],l=zf(t,a.cc)||t[Math.round(t.length/2)-1],h=a.programDateTime,d=l.programDateTime;if(h===null||d===null)return;const p=(d-h)/1e3-(l.start-a.start);Mc(p,s)}class Cy{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class Iy{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function Dy(s){const e=s.byteLength,t=e&&new DataView(s.buffer).getUint8(e-1);return t?nn(s,0,e-t):s}class Oy{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),i=new Uint32Array(4);for(let n=0;n<4;n++)i[n]=t.getUint32(n*4);return i}initTable(){const e=this.sBox,t=this.invSBox,i=this.subMix,n=i[0],a=i[1],l=i[2],h=i[3],d=this.invSubMix,p=d[0],m=d[1],g=d[2],A=d[3],x=new Uint32Array(256);let b=0,S=0,w=0;for(w=0;w<256;w++)w<128?x[w]=w<<1:x[w]=w<<1^283;for(w=0;w<256;w++){let P=S^S<<1^S<<2^S<<3^S<<4;P=P>>>8^P&255^99,e[b]=P,t[P]=b;const $=x[b],N=x[$],I=x[N];let O=x[P]*257^P*16843008;n[b]=O<<24|O>>>8,a[b]=O<<16|O>>>16,l[b]=O<<8|O>>>24,h[b]=O,O=I*16843009^N*65537^$*257^b*16843008,p[P]=O<<24|O>>>8,m[P]=O<<16|O>>>16,g[P]=O<<8|O>>>24,A[P]=O,b?(b=$^x[x[x[I^$]]],S^=x[x[S]]):b=S=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let i=!0,n=0;for(;n<t.length&&i;)i=t[n]===this.key[n],n++;if(i)return;this.key=t;const a=this.keySize=t.length;if(a!==4&&a!==6&&a!==8)throw new Error("Invalid aes key size="+a);const l=this.ksRows=(a+6+1)*4;let h,d;const p=this.keySchedule=new Uint32Array(l),m=this.invKeySchedule=new Uint32Array(l),g=this.sBox,A=this.rcon,x=this.invSubMix,b=x[0],S=x[1],w=x[2],P=x[3];let $,N;for(h=0;h<l;h++){if(h<a){$=p[h]=t[h];continue}N=$,h%a===0?(N=N<<8|N>>>24,N=g[N>>>24]<<24|g[N>>>16&255]<<16|g[N>>>8&255]<<8|g[N&255],N^=A[h/a|0]<<24):a>6&&h%a===4&&(N=g[N>>>24]<<24|g[N>>>16&255]<<16|g[N>>>8&255]<<8|g[N&255]),p[h]=$=(p[h-a]^N)>>>0}for(d=0;d<l;d++)h=l-d,d&3?N=p[h]:N=p[h-4],d<4||h<=4?m[d]=N:m[d]=b[g[N>>>24]]^S[g[N>>>16&255]]^w[g[N>>>8&255]]^P[g[N&255]],m[d]=m[d]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){const n=this.keySize+6,a=this.invKeySchedule,l=this.invSBox,h=this.invSubMix,d=h[0],p=h[1],m=h[2],g=h[3],A=this.uint8ArrayToUint32Array_(i);let x=A[0],b=A[1],S=A[2],w=A[3];const P=new Int32Array(e),$=new Int32Array(P.length);let N,I,O,K,U,re,ne,Y,Ee,ce,we,Oe,B,W;const ke=this.networkToHostOrderSwap;for(;t<P.length;){for(Ee=ke(P[t]),ce=ke(P[t+1]),we=ke(P[t+2]),Oe=ke(P[t+3]),U=Ee^a[0],re=Oe^a[1],ne=we^a[2],Y=ce^a[3],B=4,W=1;W<n;W++)N=d[U>>>24]^p[re>>16&255]^m[ne>>8&255]^g[Y&255]^a[B],I=d[re>>>24]^p[ne>>16&255]^m[Y>>8&255]^g[U&255]^a[B+1],O=d[ne>>>24]^p[Y>>16&255]^m[U>>8&255]^g[re&255]^a[B+2],K=d[Y>>>24]^p[U>>16&255]^m[re>>8&255]^g[ne&255]^a[B+3],U=N,re=I,ne=O,Y=K,B=B+4;N=l[U>>>24]<<24^l[re>>16&255]<<16^l[ne>>8&255]<<8^l[Y&255]^a[B],I=l[re>>>24]<<24^l[ne>>16&255]<<16^l[Y>>8&255]<<8^l[U&255]^a[B+1],O=l[ne>>>24]<<24^l[Y>>16&255]<<16^l[U>>8&255]<<8^l[re&255]^a[B+2],K=l[Y>>>24]<<24^l[U>>16&255]<<16^l[re>>8&255]<<8^l[ne&255]^a[B+3],$[t]=ke(N^x),$[t+1]=ke(K^b),$[t+2]=ke(O^S),$[t+3]=ke(I^w),x=Ee,b=ce,S=we,w=Oe,t=t+4}return $.buffer}}const Py=16;class Fc{constructor(e,{removePKCS7Padding:t=!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=e.enableSoftwareAES,this.removePKCS7Padding=t,t)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:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?Dy(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i){return this.useSoftware?new Promise((n,a)=>{this.softwareDecrypt(new Uint8Array(e),t,i);const l=this.flush();l?n(l.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i)}softwareDecrypt(e,t,i){const{currentIV:n,currentResult:a,remainderData:l}=this;this.logOnce("JS AES decrypt"),l&&(e=on(l,e),this.remainderData=null);const h=this.getValidChunk(e);if(!h.length)return null;n&&(i=n);let d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new Oy),d.expandKey(t);const p=a;return this.currentResult=d.decrypt(h.buffer,0,i),this.currentIV=nn(h,-16).buffer,p||null}webCryptoDecrypt(e,t,i){const n=this.subtle;return(this.key!==t||!this.fastAesKey)&&(this.key=t,this.fastAesKey=new Iy(n,t)),this.fastAesKey.expandKey().then(a=>n?(this.logOnce("WebCrypto AES decrypt"),new Cy(n,new Uint8Array(i)).decrypt(e.buffer,a)):Promise.reject(new Error("web crypto not initialized"))).catch(a=>(q.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${a.name}: ${a.message}`),this.onWebCryptoError(e,t,i)))}onWebCryptoError(e,t,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i);const n=this.flush();if(n)return n.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%Py;return i!==e.length&&(t=nn(e,0,i),this.remainderData=nn(e,i)),t}logOnce(e){this.logEnabled&&(q.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const $y={toString:function(s){let e="";const t=s.length;for(let i=0;i<t;i++)e+=`[${s.start(i).toFixed(3)}-${s.end(i).toFixed(3)}]`;return e}},Se={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 Ty{constructor(e,t,i,n,a){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Se.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=a,this.logPrefix=n,this.log=q.log.bind(q,`${n}:`),this.warn=q.warn.bind(q,`${n}:`),this.hls=e,this.fragmentLoader=new xy(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Fc(e.config),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Se.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const i=t.partList;if(i!=null&&i.length){const a=i[i.length-1];return Nt.isBuffered(this.media,a.start+a.duration/2)}const n=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levels[this.levelLastLoaded])==null?void 0:e.details}}onMediaAttached(e,t){const i=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);const n=this.config;this.levels&&n.autoStartLoad&&this.state===Se.STOPPED&&this.startLoad(n.startPosition)}onMediaDetaching(){const e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:i,mediaBuffer:n,state:a}=this,l=i?i.currentTime:0,h=Nt.bufferInfo(n||i,l,e.maxBufferHole);if(this.log(`media seeking to ${ze(l)?l.toFixed(3):l}, state: ${a}`),this.state===Se.ENDED)this.resetLoadingState();else if(t){const d=e.maxFragLookUpTolerance,p=t.start-d,m=t.start+t.duration+d;if(!h.len||m<h.start||p>h.end){const g=l>m;(l<p||g)&&(g&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(l,1/0,this.playlistType,!0),this.lastCurrentTime=l),!this.loadedmetadata&&!h.len&&(this.nextLoadPosition=this.startPosition=l),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=Se.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,i){this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){const n=a=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${a.part?" p: "+a.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(a)};this._doFragLoad(e,t,i,n).then(a=>{if(!a)return;const l=this.state;if(this.fragContextChanged(e)){(l===Se.FRAG_LOADING||!this.fragCurrent&&l===Se.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=Se.IDLE);return}"payload"in a&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(_.FRAG_LOADED,a)),this._handleFragmentLoadComplete(a)}).catch(a=>{this.state===Se.STOPPED||this.state===Se.ERROR||(this.warn(a),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===di.APPENDING){const a=e.type,l=this.getFwdBufferInfo(this.mediaBuffer,a),h=Math.max(e.duration,l?l.len:this.config.maxBufferLength);this.reduceMaxBufferLength(h)&&i.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===di.PARTIAL&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,i=null){if(!(e-t))return;const n={startOffset:e,endOffset:t,type:i};this.hls.trigger(_.BUFFER_FLUSHING,n)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{if(!i||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:n}=this,{payload:a}=i,l=e.decryptdata;if(a&&a.byteLength>0&&l&&l.key&&l.iv&&l.method==="AES-128"){const h=self.performance.now();return this.decrypter.decrypt(new Uint8Array(a),l.key.buffer,l.iv.buffer).catch(d=>{throw n.trigger(_.ERROR,{type:et.MEDIA_ERROR,details:de.FRAG_DECRYPT_ERROR,fatal:!1,error:d,reason:d.message,frag:e}),d}).then(d=>{const p=self.performance.now();return n.trigger(_.FRAG_DECRYPTED,{frag:e,payload:d,stats:{tstart:h,tdecrypt:p}}),i.payload=d,i})}return i}).then(i=>{const{fragCurrent:n,hls:a,levels:l}=this;if(!l)throw new Error("init load aborted, missing levels");const h=e.stats;this.state=Se.IDLE,t.fragmentError=0,e.data=new Uint8Array(i.payload),h.parsing.start=h.buffering.start=self.performance.now(),h.parsing.end=h.buffering.end=self.performance.now(),i.frag===n&&a.trigger(_.FRAG_BUFFERED,{stats:h,frag:n,part:null,id:e.type}),this.tick()}).catch(i=>{this.state===Se.STOPPED||this.state===Se.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId}fragBufferedComplete(e,t){var i,n,a,l;const h=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===tt.MAIN?"level":"track"} ${e.level} (frag:[${((i=e.startPTS)!=null?i:NaN).toFixed(3)}-${((n=e.endPTS)!=null?n:NaN).toFixed(3)}] > buffer:${h?$y.toString(Nt.getBuffered(h)):"(detached)"})`),this.state=Se.IDLE,h&&(!this.loadedmetadata&&e.type==tt.MAIN&&h.buffered.length&&((a=this.fragCurrent)==null?void 0:a.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:i,part:n,partsLoaded:a}=e,l=!a||a.length===0||a.some(d=>!d),h=new $c(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!l);t.flush(h)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,n){var a;const l=t==null?void 0:t.details;if(!this.levels||!l)throw new Error(`frag load aborted, missing level${l?"":" detail"}s`);let h=null;if(e.encrypted&&!((a=e.decryptdata)!=null&&a.key)?(this.log(`Loading key for ${e.sn} of [${l.startSN}-${l.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=Se.KEY_LOADING,this.fragCurrent=e,h=this.keyLoader.load(e).then(m=>{if(!this.fragContextChanged(m.frag))return this.hls.trigger(_.KEY_LOADED,m),this.state===Se.KEY_LOADING&&(this.state=Se.IDLE),m}),this.hls.trigger(_.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(h=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&l.encryptedFragments.length&&this.keyLoader.loadClear(e,l.encryptedFragments),i=Math.max(e.start,i||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){const m=l.partList;if(m&&n){i>e.end&&l.fragmentHint&&(e=l.fragmentHint);const g=this.getNextPart(m,e,i);if(g>-1){const A=m[g];this.log(`Loading part sn: ${e.sn} p: ${A.index} cc: ${e.cc} of playlist [${l.startSN}-${l.endSN}] parts [0-${g}-${m.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=A.start+A.duration,this.state=Se.FRAG_LOADING;let x;return h?x=h.then(b=>!b||this.fragContextChanged(b.frag)?null:this.doFragPartsLoad(e,A,t,n)).catch(b=>this.handleFragLoadError(b)):x=this.doFragPartsLoad(e,A,t,n).catch(b=>this.handleFragLoadError(b)),this.hls.trigger(_.FRAG_LOADING,{frag:e,part:A,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):x}else if(!e.url||this.loadedEndOfParts(m,i))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${l?"of ["+l.startSN+"-"+l.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),ze(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Se.FRAG_LOADING;const d=this.config.progressive;let p;return d&&h?p=h.then(m=>!m||this.fragContextChanged(m==null?void 0:m.frag)?null:this.fragmentLoader.load(e,n)).catch(m=>this.handleFragLoadError(m)):p=Promise.all([this.fragmentLoader.load(e,d?n:void 0),h]).then(([m])=>(!d&&m&&n&&n(m),m)).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(_.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):p}doFragPartsLoad(e,t,i,n){return new Promise((a,l)=>{var h;const d=[],p=(h=i.details)==null?void 0:h.partList,m=g=>{this.fragmentLoader.loadPart(e,g,n).then(A=>{d[g.index]=A;const x=A.part;this.hls.trigger(_.FRAG_LOADED,A);const b=Nf(i,e.sn,g.index+1)||Uf(p,e.sn,g.index+1);if(b)m(b);else return a({frag:e,part:x,partsLoaded:d})}).catch(l)};m(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===de.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(_.ERROR,t)}else this.hls.trigger(_.ERROR,{type:et.OTHER_ERROR,details:de.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==Se.PARSING){!this.fragCurrent&&this.state!==Se.STOPPED&&this.state!==Se.ERROR&&(this.state=Se.IDLE);return}const{frag:i,part:n,level:a}=t,l=self.performance.now();i.stats.parsing.end=l,n&&(n.stats.parsing.end=l),this.updateLevelTiming(i,n,a,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:i}=this,{level:n,sn:a,part:l}=e;if(!(t!=null&&t[n]))return this.warn(`Levels object was unset while buffering fragment ${a} of level ${n}. The current chunk will not be buffered.`),null;const h=t[n],d=l>-1?Nf(h,a,l):null,p=d?d.fragment:hy(h,a,i);return p?(i&&i!==p&&(p.stats=i.stats),{frag:p,part:d,level:h}):null}bufferFragmentData(e,t,i,n,a){var l;if(!e||this.state!==Se.PARSING)return;const{data1:h,data2:d}=e;let p=h;if(h&&d&&(p=on(h,d)),!((l=p)!=null&&l.length))return;const m={type:e.type,frag:t,part:i,chunkMeta:n,parent:t.type,data:p};if(this.hls.trigger(_.BUFFER_APPENDING,m),e.dropped&&e.independent&&!i){if(a)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Nt.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const i=t.currentTime,n=Nt.bufferInfo(t,i,0),a=e.duration,l=Math.min(this.config.maxFragLookUpTolerance*2,a*.25),h=Math.max(Math.min(e.start-l,n.end-l),i+l);e.start-h>l&&this.flushMainBuffer(h,e.start)}getFwdBufferInfo(e,t){const i=this.getLoadPosition();return ze(i)?this.getFwdBufferInfoAtPos(e,i,t):null}getFwdBufferInfoAtPos(e,t,i){const{config:{maxBufferHole:n}}=this,a=Nt.bufferInfo(e,t,n);if(a.len===0&&a.nextStart!==void 0){const l=this.fragmentTracker.getBufferedFrag(t,i);if(l&&a.nextStart<l.end)return Nt.bufferInfo(e,t,Math.max(a.nextStart,n))}return a}getMaxBufferLength(e){const{config:t}=this;let i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e){const t=this.config,i=e||t.maxBufferLength;return t.maxMaxBufferLength>=i?(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,t=tt.MAIN){const i=this.fragmentTracker.getAppendedFrag(e,tt.MAIN);return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){const i=t.fragments,n=i.length;if(!n)return null;const{config:a}=this,l=i[0].start;let h;if(t.live){const d=a.initialLiveManifestSize;if(n<d)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${d})`),null;!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(h=this.getInitialLiveFragment(t,i),this.startPosition=h?this.hls.liveSyncPosition||h.start:e)}else e<=l&&(h=i[0]);if(!h){const d=a.lowLatencyMode?t.partEnd:t.fragmentEnd;h=this.getFragmentAtPosition(e,d,t)}return this.mapToInitFragWhenRequired(h)}isLoopLoading(e,t){const i=this.fragmentTracker.getState(e);return(i===di.OK||i===di.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,n,a){const l=e.gap,h=this.getNextFragment(this.nextLoadPosition,t);if(h===null)return h;if(e=h,l&&e&&!e.gap&&i.nextStart){const d=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n);if(d!==null&&i.len+d.len>=a)return this.log(`buffer full after gaps in "${n}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,i){let n=-1,a=!1,l=!0;for(let h=0,d=e.length;h<d;h++){const p=e[h];if(l=l&&!p.independent,n>-1&&i<p.start)break;const m=p.loaded;m?n=-1:(a||p.independent||l)&&p.fragment===t&&(n=h),a=m}return n}loadedEndOfParts(e,t){const i=e[e.length-1];return i&&t>i.start&&i.loaded}getInitialLiveFragment(e,t){const i=this.fragPrevious;let n=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),n=dy(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const a=i.sn+1;if(a>=e.startSN&&a<=e.endSN){const l=t[a-e.startSN];i.cc===l.cc&&(n=l,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=my(t,i.cc),n&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`))}}else{const a=this.hls.liveSyncPosition;a!==null&&(n=this.getFragmentAtPosition(a,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n}getFragmentAtPosition(e,t,i){const{config:n}=this;let{fragPrevious:a}=this,{fragments:l,endSN:h}=i;const{fragmentHint:d}=i,p=n.maxFragLookUpTolerance,m=i.partList,g=!!(n.lowLatencyMode&&m!=null&&m.length&&d);g&&d&&!this.bitrateTest&&(l=l.concat(d),h=d.sn);let A;if(e<t){const x=e>t-p?0:p;A=_o(a,l,e,x)}else A=l[l.length-1];if(A){const x=A.sn-i.startSN,b=this.fragmentTracker.getState(A);if((b===di.OK||b===di.PARTIAL&&A.gap)&&(a=A),a&&A.sn===a.sn&&(!g||m[0].fragment.sn>A.sn)&&a&&A.level===a.level){const w=l[x+1];A.sn<h&&this.fragmentTracker.getState(w)!==di.OK?A=w:A=null}}return A}synchronizeToLiveEdge(e){const{config:t,media:i}=this;if(!i)return;const n=this.hls.liveSyncPosition,a=i.currentTime,l=e.fragments[0].start,h=e.edge,d=a>=l-t.maxFragLookUpTolerance&&a<=h;if(n!==null&&i.duration>n&&(a<n||!d)){const p=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!d&&i.readyState<4||a<h-p)&&(this.loadedmetadata||(this.nextLoadPosition=n),i.readyState&&(this.warn(`Playback: ${a.toFixed(3)} is located too far from the end of live sliding playlist: ${h}, reset currentTime to : ${n.toFixed(3)}`),i.currentTime=n))}}alignPlaylists(e,t){const{levels:i,levelLastLoaded:n,fragPrevious:a}=this,l=n!==null?i[n]:null,h=e.fragments.length;if(!h)return this.warn("No fragments in live playlist"),0;const d=e.fragments[0].start,p=!t,m=e.alignedSliding&&ze(d);if(p||!m&&!d){_y(a,l,e);const g=e.fragments[0].start;return this.log(`Live playlist sliding: ${g.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${a?a.sn:"na"} fragments: ${h}`),g}return d}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;if(i<t&&(i=-1),i===-1||this.lastCurrentTime===-1){const n=this.startTimeOffset!==null,a=n?this.startTimeOffset:e.startTimeOffset;a!==null&&ze(a)?(i=t+a,a<0&&(i+=e.totalduration),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Start time offset ${a} found in ${n?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):e.live?i=this.hls.liveSyncPosition||t:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==Se.FRAG_LOADING_WAITING_RETRY)&&(this.state=Se.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const g=this.getCurrentContext(t.chunkMeta);g&&(t.frag=g.frag)}const i=t.frag;if(!i||i.type!==e||!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 a=t.details===de.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(i,!0);const l=t.errorAction,{action:h,retryCount:d=0,retryConfig:p}=l||{};if(l&&h===Li.RetryRequest&&p){var m;this.resetStartWhenNotLoaded((m=this.levelLastLoaded)!=null?m:i.level);const g=Ic(p,d);this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${d+1}/${p.maxNumRetry} in ${g}ms`),l.resolved=!0,this.retryDate=self.performance.now()+g,this.state=Se.FRAG_LOADING_WAITING_RETRY}else p&&l?(this.resetFragmentErrors(e),d<p.maxNumRetry?a||(l.resolved=!0):q.warn(`${t.details} reached or exceeded max retry (${d})`)):(l==null?void 0:l.action)===Li.SendAlternateToPenaltyBox?this.state=Se.WAITING_LEVEL:this.state=Se.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===Se.PARSING||this.state===Se.PARSED){const t=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,t),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len);const a=!n;return a&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===tt.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Se.STOPPED&&(this.state=Se.IDLE)}afterBufferFlushed(e,t,i){if(!e)return;const n=Nt.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,i),this.state===Se.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Se.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=this.levels?this.levels[e].details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){var t;this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((t=this.levelLastLoaded)!=null?t:e.level),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,n){var a;const l=i.details;if(!l){this.warn("level.details undefined");return}if(Object.keys(e.elementaryStreams).reduce((d,p)=>{const m=e.elementaryStreams[p];if(m){const g=m.endPTS-m.startPTS;if(g<=0)return this.warn(`Could not parse fragment ${e.sn} ${p} duration reliably (${g})`),d||!1;const A=n?0:Mf(l,e,m.startPTS,m.endPTS,m.startDTS,m.endDTS);return this.hls.trigger(_.LEVEL_PTS_UPDATED,{details:l,level:i,drift:A,type:p,frag:e,start:m.startPTS,end:m.endPTS}),!0}return d},!1))i.fragmentError=0;else if(((a=this.transmuxer)==null?void 0:a.error)===null){const d=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(i.fragmentError===0&&(i.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(d.message),this.hls.trigger(_.ERROR,{type:et.MEDIA_ERROR,details:de.FRAG_PARSING_ERROR,fatal:!1,error:d,frag:e,reason:`Found no media in msn ${e.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Se.PARSED,this.hls.trigger(_.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){if(e.event==="demuxerWorker"){var t,i,n;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((t=(i=this.levelLastLoaded)!=null?i:(n=this.fragCurrent)==null?void 0:n.level)!=null?t:0),this.resetLoadingState()}}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function Zf(){return self.SourceBuffer||self.WebKitSourceBuffer}function My(){const s=Fa();if(!s)return!1;const e=Zf(),t=s&&typeof s.isTypeSupported=="function"&&s.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function";return!!t&&!!i}function Fy(){var s;const e=Zf();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}function Ny(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Uy(){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"}),e=self.URL.createObjectURL(s);return{worker:new self.Worker(e),objectURL:e}}function By(s){const e=new self.URL(s,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function Or(s="",e=9e4){return{type:s,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class qf{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=on(this.cachedData,e),this.cachedData=null);let i=Oa(e,0),n=i?i.length:0,a;const l=this._audioTrack,h=this._id3Track,d=i?bv(i):void 0,p=e.length;for((this.basePTS===null||this.frameIndex===0&&ze(d))&&(this.basePTS=Gy(d,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&h.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:xr.audioId3,duration:Number.POSITIVE_INFINITY});n<p;){if(this.canParse(e,n)){const m=this.appendFrame(l,e,n);m?(this.frameIndex++,this.lastPTS=m.sample.pts,n+=m.length,a=n):n=p}else xv(e,n)?(i=Oa(e,n),h.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:xr.audioId3,duration:Number.POSITIVE_INFINITY}),n+=i.length,a=n):n++;if(n===p&&a!==p){const m=nn(e,a);this.cachedData?this.cachedData=on(this.cachedData,m):this.cachedData=m}}return{audioTrack:l,videoTrack:Or(),id3Track:h,textTrack:Or()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Or(),id3Track:this._id3Track,textTrack:Or()}}destroy(){}}const Gy=(s,e,t)=>{if(ze(s))return s*90;const i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};function Vy(s,e,t,i){let n,a,l,h;const d=navigator.userAgent.toLowerCase(),p=i,m=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=((e[t+2]&192)>>>6)+1;const g=(e[t+2]&60)>>>2;if(g>m.length-1){s.trigger(_.ERROR,{type:et.MEDIA_ERROR,details:de.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${g}`});return}return l=(e[t+2]&1)<<2,l|=(e[t+3]&192)>>>6,q.log(`manifest codec:${i}, ADTS type:${n}, samplingIndex:${g}`),/firefox/i.test(d)?g>=6?(n=5,h=new Array(4),a=g-3):(n=2,h=new Array(2),a=g):d.indexOf("android")!==-1?(n=2,h=new Array(2),a=g):(n=5,h=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&g>=6?a=g-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(g>=6&&l===1||/vivaldi/i.test(d))||!i&&l===1)&&(n=2,h=new Array(2)),a=g)),h[0]=n<<3,h[0]|=(g&14)>>1,h[1]|=(g&1)<<7,h[1]|=l<<3,n===5&&(h[1]|=(a&14)>>1,h[2]=(a&1)<<7,h[2]|=8,h[3]=0),{config:h,samplerate:m[g],channelCount:l,codec:"mp4a.40."+n,manifestCodec:p}}function Qf(s,e){return s[e]===255&&(s[e+1]&246)===240}function Jf(s,e){return s[e+1]&1?7:9}function Uc(s,e){return(s[e+3]&3)<<11|s[e+4]<<3|(s[e+5]&224)>>>5}function Hy(s,e){return e+5<s.length}function Wa(s,e){return e+1<s.length&&Qf(s,e)}function Wy(s,e){return Hy(s,e)&&Qf(s,e)&&Uc(s,e)<=s.length-e}function jy(s,e){if(Wa(s,e)){const t=Jf(s,e);if(e+t>=s.length)return!1;const i=Uc(s,e);if(i<=t)return!1;const n=e+i;return n===s.length||Wa(s,n)}return!1}function ed(s,e,t,i,n){if(!s.samplerate){const a=Vy(e,t,i,n);if(!a)return;s.config=a.config,s.samplerate=a.samplerate,s.channelCount=a.channelCount,s.codec=a.codec,s.manifestCodec=a.manifestCodec,q.log(`parsed codec:${s.codec}, rate:${a.samplerate}, channels:${a.channelCount}`)}}function td(s){return 9216e4/s}function Ky(s,e){const t=Jf(s,e);if(e+t<=s.length){const i=Uc(s,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function id(s,e,t,i,n){const a=td(s.samplerate),l=i+n*a,h=Ky(e,t);let d;if(h){const{frameLength:g,headerLength:A}=h,x=A+g,b=Math.max(0,t+x-e.length);b?(d=new Uint8Array(x-A),d.set(e.subarray(t+A,e.length),0)):d=e.subarray(t+A,t+x);const S={unit:d,pts:l};return b||s.samples.push(S),{sample:S,length:x,missing:b}}const p=e.length-t;return d=new Uint8Array(p),d.set(e.subarray(t,e.length),0),{sample:{unit:d,pts:l},length:p,missing:-1}}class zy extends qf{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,n){super.resetInitSegment(e,t,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let i=(Oa(e,0)||[]).length;for(let n=e.length;i<n;i++)if(jy(e,i))return q.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return Wy(e,t)}appendFrame(e,t,i){ed(e,this.observer,t,i,e.manifestCodec);const n=id(e,t,i,this.basePTS,this.frameIndex);if(n&&n.missing===0)return n}}const Yy=/\/emsg[-/]ID3/i;class Xy{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,i,n){const a=this.videoTrack=Or("video",1),l=this.audioTrack=Or("audio",1),h=this.txtTrack=Or("text",1);if(this.id3Track=Or("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const d=pf(e);if(d.video){const{id:p,timescale:m,codec:g}=d.video;a.id=p,a.timescale=h.timescale=m,a.codec=g}if(d.audio){const{id:p,timescale:m,codec:g}=d.audio;l.id=p,l.timescale=m,l.codec=g}h.id=hf.text,a.sampleDuration=0,a.duration=l.duration=n}resetContiguity(){this.remainderData=null}static probe(e){return e=e.length>16384?e.subarray(0,16384):e,xt(e,["moof"]).length>0}demux(e,t){this.timeOffset=t;let i=e;const n=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=on(this.remainderData,e));const h=Fv(i);this.remainderData=h.remainder,n.samples=h.valid||new Uint8Array}else n.samples=i;const l=this.extractID3Track(n,t);return a.samples=gf(t,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:l,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const n=this.extractID3Track(t,this.timeOffset);return i.samples=gf(e,t),{videoTrack:t,audioTrack:Or(),id3Track:n,textTrack:Or()}}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const n=xt(e.samples,["emsg"]);n&&n.forEach(a=>{const l=Bv(a);if(Yy.test(l.schemeIdUri)){const h=ze(l.presentationTime)?l.presentationTime/l.timeScale:t+l.presentationTimeDelta/l.timeScale;let d=l.eventDuration===4294967295?Number.POSITIVE_INFINITY:l.eventDuration/l.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);const p=l.payload;i.samples.push({data:p,len:p.byteLength,dts:h,pts:h,type:xr.emsg,duration:d})}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}let ja=null;const Zy=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],qy=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Qy=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Jy=[0,1,1,4];function rd(s,e,t,i,n){if(t+24>e.length)return;const a=sd(e,t);if(a&&t+a.frameLength<=e.length){const l=a.samplesPerFrame*9e4/a.sampleRate,h=i+n*l,d={unit:e.subarray(t,t+a.frameLength),pts:h,dts:h};return s.config=[],s.channelCount=a.channelCount,s.samplerate=a.sampleRate,s.samples.push(d),{sample:d,length:a.frameLength,missing:0}}}function sd(s,e){const t=s[e+1]>>3&3,i=s[e+1]>>1&3,n=s[e+2]>>4&15,a=s[e+2]>>2&3;if(t!==1&&n!==0&&n!==15&&a!==3){const l=s[e+2]>>1&1,h=s[e+3]>>6,d=t===3?3-i:i===3?3:4,p=Zy[d*14+n-1]*1e3,g=qy[(t===3?0:t===2?1:2)*3+a],A=h===3?1:2,x=Qy[t][i],b=Jy[i],S=x*8*b,w=Math.floor(x*p/g+l)*b;if(ja===null){const N=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ja=N?parseInt(N[1]):0}return!!ja&&ja<=87&&i===2&&p>=224e3&&h===0&&(s[e+3]=s[e+3]|128),{sampleRate:g,channelCount:A,frameLength:w,samplesPerFrame:S}}}function Bc(s,e){return s[e]===255&&(s[e+1]&224)===224&&(s[e+1]&6)!==0}function nd(s,e){return e+1<s.length&&Bc(s,e)}function eA(s,e){return Bc(s,e)&&4<=s.length-e}function tA(s,e){if(e+1<s.length&&Bc(s,e)){const i=sd(s,e);let n=4;i!=null&&i.frameLength&&(n=i.frameLength);const a=e+n;return a===s.length||nd(s,a)}return!1}class od{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,i=e.byteLength-t,n=new Uint8Array(4),a=Math.min(4,t);if(a===0)throw new Error("no bytes available");n.set(e.subarray(i,i+a)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=a*8,this.bytesAvailable-=a}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const i=this.word>>>32-t;if(e>32&&q.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,i=8,n;for(let a=0;a<e;a++)i!==0&&(n=this.readEG(),i=(t+n+256)%256),t=i===0?t:i}readSPS(){let e=0,t=0,i=0,n=0,a,l,h;const d=this.readUByte.bind(this),p=this.readBits.bind(this),m=this.readUEG.bind(this),g=this.readBoolean.bind(this),A=this.skipBits.bind(this),x=this.skipEG.bind(this),b=this.skipUEG.bind(this),S=this.skipScalingList.bind(this);d();const w=d();if(p(5),A(3),d(),b(),w===100||w===110||w===122||w===244||w===44||w===83||w===86||w===118||w===128){const K=m();if(K===3&&A(1),b(),b(),A(1),g())for(l=K!==3?8:12,h=0;h<l;h++)g()&&(h<6?S(16):S(64))}b();const P=m();if(P===0)m();else if(P===1)for(A(1),x(),x(),a=m(),h=0;h<a;h++)x();b(),A(1);const $=m(),N=m(),I=p(1);I===0&&A(1),A(1),g()&&(e=m(),t=m(),i=m(),n=m());let O=[1,1];if(g()&&g())switch(d()){case 1:O=[1,1];break;case 2:O=[12,11];break;case 3:O=[10,11];break;case 4:O=[16,11];break;case 5:O=[40,33];break;case 6:O=[24,11];break;case 7:O=[20,11];break;case 8:O=[32,11];break;case 9:O=[80,33];break;case 10:O=[18,11];break;case 11:O=[15,11];break;case 12:O=[64,33];break;case 13:O=[160,99];break;case 14:O=[4,3];break;case 15:O=[3,2];break;case 16:O=[2,1];break;case 255:{O=[d()<<8|d(),d()<<8|d()];break}}return{width:Math.ceil(($+1)*16-e*2-t*2),height:(2-I)*(N+1)*16-(I?2:4)*(i+n),pixelRatio:O}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class iA{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Fc(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,i){const n=e[t].unit;if(n.length<=16)return;const a=n.subarray(16,n.length-n.length%16),l=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(l).then(h=>{const d=new Uint8Array(h);n.set(d,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)})}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t);let n=0;for(let a=32;a<e.length-16;a+=160,n+=16)i.set(e.subarray(a,a+16),n);return i}getAvcDecryptedUnit(e,t){const i=new Uint8Array(t);let n=0;for(let a=32;a<e.length-16;a+=160,n+=16)e.set(i.subarray(n,n+16),a);return e}decryptAvcSample(e,t,i,n,a){const l=yf(a.data),h=this.getAvcEncryptedData(l);this.decryptBuffer(h.buffer).then(d=>{a.data=this.getAvcDecryptedUnit(l,d),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,n)})}decryptAvcSamples(e,t,i,n){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){n();return}const a=e[t].units;for(;!(i>=a.length);i++){const l=a[i];if(!(l.data.length<=48||l.type!==1&&l.type!==5)&&(this.decryptAvcSample(e,t,i,n,l),!this.decrypter.isSync()))return}}}}const Ci=188;class bs{constructor(e,t,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=e,this.config=t,this.typeSupported=i}static probe(e){const t=bs.syncOffset(e);return t>0&&q.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){const t=e.length;let i=Math.min(Ci*5,e.length-Ci)+1,n=0;for(;n<i;){let a=!1,l=-1,h=0;for(let d=n;d<t;d+=Ci)if(e[d]===71){if(h++,l===-1&&(l=d,l!==0&&(i=Math.min(l+Ci*99,e.length-Ci)+1)),a||(a=Gc(e,d)===0),a&&h>1&&(l===0&&h>2||d+Ci>i))return l}else{if(h)return-1;break}n++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:hf[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=bs.createTrack("video"),this._audioTrack=bs.createTrack("audio",n),this._id3Track=bs.createTrack("id3"),this._txtTrack=bs.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,this._duration=n}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_avcTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(e,t,i=!1,n=!1){i||(this.sampleAes=null);let a;const l=this._avcTrack,h=this._audioTrack,d=this._id3Track,p=this._txtTrack;let m=l.pid,g=l.pesData,A=h.pid,x=d.pid,b=h.pesData,S=d.pesData,w=null,P=this.pmtParsed,$=this._pmtId,N=e.length;if(this.remainderData&&(e=on(this.remainderData,e),N=e.length,this.remainderData=null),N<Ci&&!n)return this.remainderData=e,{audioTrack:h,videoTrack:l,id3Track:d,textTrack:p};const I=Math.max(0,bs.syncOffset(e));N-=(N-I)%Ci,N<e.byteLength&&!n&&(this.remainderData=new Uint8Array(e.buffer,N,e.buffer.byteLength-N));let O=0;for(let U=I;U<N;U+=Ci)if(e[U]===71){const re=!!(e[U+1]&64),ne=Gc(e,U),Y=(e[U+3]&48)>>4;let Ee;if(Y>1){if(Ee=U+5+e[U+4],Ee===U+Ci)continue}else Ee=U+4;switch(ne){case m:re&&(g&&(a=wn(g))&&this.parseAVCPES(l,p,a,!1),g={data:[],size:0}),g&&(g.data.push(e.subarray(Ee,U+Ci)),g.size+=U+Ci-Ee);break;case A:if(re){if(b&&(a=wn(b)))switch(h.segmentCodec){case"aac":this.parseAACPES(h,a);break;case"mp3":this.parseMPEGPES(h,a);break}b={data:[],size:0}}b&&(b.data.push(e.subarray(Ee,U+Ci)),b.size+=U+Ci-Ee);break;case x:re&&(S&&(a=wn(S))&&this.parseID3PES(d,a),S={data:[],size:0}),S&&(S.data.push(e.subarray(Ee,U+Ci)),S.size+=U+Ci-Ee);break;case 0:re&&(Ee+=e[Ee]+1),$=this._pmtId=rA(e,Ee);break;case $:{re&&(Ee+=e[Ee]+1);const ce=sA(e,Ee,this.typeSupported,i);m=ce.avc,m>0&&(l.pid=m),A=ce.audio,A>0&&(h.pid=A,h.segmentCodec=ce.segmentCodec),x=ce.id3,x>0&&(d.pid=x),w!==null&&!P&&(q.warn(`MPEG-TS PMT found at ${U} after unknown PID '${w}'. Backtracking to sync byte @${I} to parse all TS packets.`),w=null,U=I-188),P=this.pmtParsed=!0;break}case 17:case 8191:break;default:w=ne;break}}else O++;if(O>0){const U=new Error(`Found ${O} TS packet/s that do not start with 0x47`);this.observer.emit(_.ERROR,_.ERROR,{type:et.MEDIA_ERROR,details:de.FRAG_PARSING_ERROR,fatal:!1,error:U,reason:U.message})}l.pesData=g,h.pesData=b,d.pesData=S;const K={audioTrack:h,videoTrack:l,id3Track:d,textTrack:p};return n&&this.extractRemainingSamples(K),K}flush(){const{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:i,id3Track:n,textTrack:a}=e,l=i.pesData,h=t.pesData,d=n.pesData;let p;if(l&&(p=wn(l))?(this.parseAVCPES(i,a,p,!0),i.pesData=null):i.pesData=l,h&&(p=wn(h))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,p);break;case"mp3":this.parseMPEGPES(t,p);break}t.pesData=null}else h!=null&&h.size&&q.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=h;d&&(p=wn(d))?(this.parseID3PES(n,p),n.pesData=null):n.pesData=d}demuxSampleAes(e,t,i){const n=this.demux(e,i,!0,!this.config.progressive),a=this.sampleAes=new iA(this.observer,this.config,t);return this.decrypt(n,a)}decrypt(e,t){return new Promise(i=>{const{audioTrack:n,videoTrack:a}=e;n.samples&&n.segmentCodec==="aac"?t.decryptAacSamples(n.samples,0,()=>{a.samples?t.decryptAvcSamples(a.samples,0,0,()=>{i(e)}):i(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,()=>{i(e)})})}destroy(){this._duration=0}parseAVCPES(e,t,i,n){const a=this.parseAVCNALu(e,i.data);let l=this.avcSample,h,d=!1;i.data=null,l&&a.length&&!e.audFound&&(Ro(l,e),l=this.avcSample=Ka(!1,i.pts,i.dts,"")),a.forEach(p=>{var m;switch(p.type){case 1:{let A=!1;h=!0;const x=p.data;if(d&&x.length>4){const b=new od(x).readSliceType();(b===2||b===4||b===7||b===9)&&(A=!0)}if(A){var g;(g=l)!=null&&g.frame&&!l.key&&(Ro(l,e),l=this.avcSample=null)}l||(l=this.avcSample=Ka(!0,i.pts,i.dts,"")),l.frame=!0,l.key=A;break}case 5:h=!0,(m=l)!=null&&m.frame&&!l.key&&(Ro(l,e),l=this.avcSample=null),l||(l=this.avcSample=Ka(!0,i.pts,i.dts,"")),l.key=!0,l.frame=!0;break;case 6:{h=!0,vf(p.data,1,i.pts,t.samples);break}case 7:if(h=!0,d=!0,!e.sps){const A=p.data,b=new od(A).readSPS();e.width=b.width,e.height=b.height,e.pixelRatio=b.pixelRatio,e.sps=[A],e.duration=this._duration;const S=A.subarray(1,4);let w="avc1.";for(let P=0;P<3;P++){let $=S[P].toString(16);$.length<2&&($="0"+$),w+=$}e.codec=w}break;case 8:h=!0,e.pps||(e.pps=[p.data]);break;case 9:h=!1,e.audFound=!0,l&&Ro(l,e),l=this.avcSample=Ka(!1,i.pts,i.dts,"");break;case 12:h=!0;break;default:h=!1,l&&(l.debug+="unknown NAL "+p.type+" ");break}l&&h&&l.units.push(p)}),n&&l&&(Ro(l,e),this.avcSample=null)}getLastNalUnit(e){var t;let i=this.avcSample,n;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){const a=i.units;n=a[a.length-1]}return n}parseAVCNALu(e,t){const i=t.byteLength;let n=e.naluState||0;const a=n,l=[];let h=0,d,p,m,g=-1,A=0;for(n===-1&&(g=0,A=t[0]&31,n=0,h=1);h<i;){if(d=t[h++],!n){n=d?0:1;continue}if(n===1){n=d?0:2;continue}if(!d)n=3;else if(d===1){if(g>=0){const x={data:t.subarray(g,h-n-1),type:A};l.push(x)}else{const x=this.getLastNalUnit(e.samples);if(x&&(a&&h<=4-a&&x.state&&(x.data=x.data.subarray(0,x.data.byteLength-a)),p=h-n-1,p>0)){const b=new Uint8Array(x.data.byteLength+p);b.set(x.data,0),b.set(t.subarray(0,p),x.data.byteLength),x.data=b,x.state=0}}h<i?(m=t[h]&31,g=h,A=m,n=0):n=-1}else n=0}if(g>=0&&n>=0){const x={data:t.subarray(g,i),type:A,state:n};l.push(x)}if(l.length===0){const x=this.getLastNalUnit(e.samples);if(x){const b=new Uint8Array(x.data.byteLength+t.byteLength);b.set(x.data,0),b.set(t,x.data.byteLength),x.data=b}}return e.naluState=n,l}parseAACPES(e,t){let i=0;const n=this.aacOverFlow;let a=t.data;if(n){this.aacOverFlow=null;const g=n.missing,A=n.sample.unit.byteLength;if(g===-1){const x=new Uint8Array(A+a.byteLength);x.set(n.sample.unit,0),x.set(a,A),a=x}else{const x=A-g;n.sample.unit.set(a.subarray(0,g),x),e.samples.push(n.sample),i=n.missing}}let l,h;for(l=i,h=a.length;l<h-1&&!Wa(a,l);l++);if(l!==i){let g;const A=l<h-1;A?g=`AAC PES did not start with ADTS header,offset:${l}`:g="No ADTS header found in AAC PES";const x=new Error(g);if(q.warn(`parsing error: ${g}`),this.observer.emit(_.ERROR,_.ERROR,{type:et.MEDIA_ERROR,details:de.FRAG_PARSING_ERROR,fatal:!1,levelRetry:A,error:x,reason:g}),!A)return}ed(e,this.observer,a,l,this.audioCodec);let d;if(t.pts!==void 0)d=t.pts;else if(n){const g=td(e.samplerate);d=n.sample.pts+g}else{q.warn("[tsdemuxer]: AAC PES unknown PTS");return}let p=0,m;for(;l<h;)if(m=id(e,a,l,d,p),l+=m.length,m.missing){this.aacOverFlow=m;break}else for(p++;l<h-1&&!Wa(a,l);l++);}parseMPEGPES(e,t){const i=t.data,n=i.length;let a=0,l=0;const h=t.pts;if(h===void 0){q.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<n;)if(nd(i,l)){const d=rd(e,i,l,h,a);if(d)l+=d.length,a++;else break}else l++}parseID3PES(e,t){if(t.pts===void 0){q.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=ai({},t,{type:this._avcTrack?xr.emsg:xr.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function Ka(s,e,t,i){return{key:s,frame:!1,pts:e,dts:t,units:[],debug:i,length:0}}function Gc(s,e){return((s[e+1]&31)<<8)+s[e+2]}function rA(s,e){return(s[e+10]&31)<<8|s[e+11]}function sA(s,e,t,i){const n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},a=(s[e+1]&15)<<8|s[e+2],l=e+3+a-4,h=(s[e+10]&15)<<8|s[e+11];for(e+=12+h;e<l;){const d=Gc(s,e);switch(s[e]){case 207:if(!i){q.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:n.audio===-1&&(n.audio=d);break;case 21:n.id3===-1&&(n.id3=d);break;case 219:if(!i){q.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:n.avc===-1&&(n.avc=d);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?q.log("MPEG audio found, not supported in this browser"):n.audio===-1&&(n.audio=d,n.segmentCodec="mp3");break;case 36:q.warn("Unsupported HEVC stream type found");break}e+=((s[e+3]&15)<<8|s[e+4])+5}return n}function wn(s){let e=0,t,i,n,a,l;const h=s.data;if(!s||s.size===0)return null;for(;h[0].length<19&&h.length>1;){const p=new Uint8Array(h[0].length+h[1].length);p.set(h[0]),p.set(h[1],h[0].length),h[0]=p,h.splice(1,1)}if(t=h[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(i=(t[4]<<8)+t[5],i&&i>s.size-6)return null;const p=t[7];p&192&&(a=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,p&64?(l=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,a-l>54e5&&(q.warn(`${Math.round((a-l)/9e4)}s delta between PTS and DTS, align them`),a=l)):l=a),n=t[8];let m=n+9;if(s.size<=m)return null;s.size-=m;const g=new Uint8Array(s.size);for(let A=0,x=h.length;A<x;A++){t=h[A];let b=t.byteLength;if(m)if(m>b){m-=b;continue}else t=t.subarray(m),b-=m,m=0;g.set(t,e),e+=b}return i&&(i-=n+3),{data:g,pts:a,dts:l,len:i}}return null}function Ro(s,e){if(s.units.length&&s.frame){if(s.pts===void 0){const t=e.samples,i=t.length;if(i){const n=t[i-1];s.pts=n.pts,s.dts=n.dts}else{e.dropped++;return}}e.samples.push(s)}s.debug.length&&q.log(s.pts+"/"+s.dts+":"+s.debug)}class nA extends qf{resetInitSegment(e,t,i,n){super.resetInitSegment(e,t,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let i=(Oa(e,0)||[]).length;for(let n=e.length;i<n;i++)if(tA(e,i))return q.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return eA(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return rd(e,t,i,this.basePTS,this.frameIndex)}}class ad{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const Ts=Math.pow(2,32)-1;class se{static init(){se.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 e;for(e in se.types)se.types.hasOwnProperty(e)&&(se.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);se.HDLR_TYPES={video:t,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]),a=new Uint8Array([0,0,0,0,0,0,0,0]);se.STTS=se.STSC=se.STCO=a,se.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),se.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),se.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),se.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const l=new Uint8Array([105,115,111,109]),h=new Uint8Array([97,118,99,49]),d=new Uint8Array([0,0,0,1]);se.FTYP=se.box(se.types.ftyp,l,d,l,h),se.DINF=se.box(se.types.dinf,se.box(se.types.dref,n))}static box(e,...t){let i=8,n=t.length;const a=n;for(;n--;)i+=t[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(e,4),n=0,i=8;n<a;n++)l.set(t[n],i),i+=t[n].byteLength;return l}static hdlr(e){return se.box(se.types.hdlr,se.HDLR_TYPES[e])}static mdat(e){return se.box(se.types.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(Ts+1)),n=Math.floor(t%(Ts+1));return se.box(se.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,n>>24,n>>16&255,n>>8&255,n&255,85,196,0,0]))}static mdia(e){return se.box(se.types.mdia,se.mdhd(e.timescale,e.duration),se.hdlr(e.type),se.minf(e))}static mfhd(e){return se.box(se.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?se.box(se.types.minf,se.box(se.types.smhd,se.SMHD),se.DINF,se.stbl(e)):se.box(se.types.minf,se.box(se.types.vmhd,se.VMHD),se.DINF,se.stbl(e))}static moof(e,t,i){return se.box(se.types.moof,se.mfhd(e),se.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=se.trak(e[t]);return se.box.apply(null,[se.types.moov,se.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(se.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=se.trex(e[t]);return se.box.apply(null,[se.types.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(Ts+1)),n=Math.floor(t%(Ts+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,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 se.box(se.types.mvhd,a)}static sdtp(e){const t=e.samples||[],i=new Uint8Array(4+t.length);let n,a;for(n=0;n<t.length;n++)a=t[n].flags,i[n+4]=a.dependsOn<<4|a.isDependedOn<<2|a.hasRedundancy;return se.box(se.types.sdtp,i)}static stbl(e){return se.box(se.types.stbl,se.stsd(e),se.box(se.types.stts,se.STTS),se.box(se.types.stsc,se.STSC),se.box(se.types.stsz,se.STSZ),se.box(se.types.stco,se.STCO))}static avc1(e){let t=[],i=[],n,a,l;for(n=0;n<e.sps.length;n++)a=e.sps[n],l=a.byteLength,t.push(l>>>8&255),t.push(l&255),t=t.concat(Array.prototype.slice.call(a));for(n=0;n<e.pps.length;n++)a=e.pps[n],l=a.byteLength,i.push(l>>>8&255),i.push(l&255),i=i.concat(Array.prototype.slice.call(a));const h=se.box(se.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),d=e.width,p=e.height,m=e.pixelRatio[0],g=e.pixelRatio[1];return se.box(se.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,d>>8&255,d&255,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]),h,se.box(se.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),se.box(se.types.pasp,new Uint8Array([m>>24,m>>16&255,m>>8&255,m&255,g>>24,g>>16&255,g>>8&255,g&255])))}static esds(e){const t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static mp4a(e){const t=e.samplerate;return se.box(se.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]),se.box(se.types.esds,se.esds(e)))}static mp3(e){const t=e.samplerate;return se.box(se.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?se.box(se.types.stsd,se.STSD,se.mp3(e)):se.box(se.types.stsd,se.STSD,se.mp4a(e)):se.box(se.types.stsd,se.STSD,se.avc1(e))}static tkhd(e){const t=e.id,i=e.duration*e.timescale,n=e.width,a=e.height,l=Math.floor(i/(Ts+1)),h=Math.floor(i%(Ts+1));return se.box(se.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255,h>>24,h>>16&255,h>>8&255,h&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,a>>8&255,a&255,0,0]))}static traf(e,t){const i=se.sdtp(e),n=e.id,a=Math.floor(t/(Ts+1)),l=Math.floor(t%(Ts+1));return se.box(se.types.traf,se.box(se.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255])),se.box(se.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,l>>24,l>>16&255,l>>8&255,l&255])),se.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,se.box(se.types.trak,se.tkhd(e),se.mdia(e))}static trex(e){const t=e.id;return se.box(se.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const i=e.samples||[],n=i.length,a=12+16*n,l=new Uint8Array(a);let h,d,p,m,g,A;for(t+=8+a,l.set([e.type==="video"?1:0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,n&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),h=0;h<n;h++)d=i[h],p=d.duration,m=d.size,g=d.flags,A=d.cts,l.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,m>>>24&255,m>>>16&255,m>>>8&255,m&255,g.isLeading<<2|g.dependsOn,g.isDependedOn<<6|g.hasRedundancy<<4|g.paddingValue<<1|g.isNonSync,g.degradPrio&61440,g.degradPrio&15,A>>>24&255,A>>>16&255,A>>>8&255,A&255],12+16*h);return se.box(se.types.trun,l)}static initSegment(e){se.types||se.init();const t=se.moov(e),i=new Uint8Array(se.FTYP.byteLength+t.byteLength);return i.set(se.FTYP),i.set(t,se.FTYP.byteLength),i}}se.types=void 0,se.HDLR_TYPES=void 0,se.STTS=void 0,se.STSC=void 0,se.STCO=void 0,se.STSZ=void 0,se.VMHD=void 0,se.SMHD=void 0,se.STSD=void 0,se.FTYP=void 0,se.DINF=void 0;const ld=9e4;function Vc(s,e,t=1,i=!1){const n=s*e*t;return i?Math.round(n):n}function oA(s,e,t=1,i=!1){return Vc(s,e,1/t,i)}function Lo(s,e=!1){return Vc(s,1e3,1/ld,e)}function aA(s,e=1){return Vc(s,ld,1/e)}const lA=10*1e3,cd=1024,cA=1152;let za=null,Hc=null;class Wc{constructor(e,t,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=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,za===null){const l=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);za=l?parseInt(l[1]):0}if(Hc===null){const a=navigator.userAgent.match(/Safari\/(\d+)/i);Hc=a?parseInt(a[1]):0}}destroy(){}resetTimeStamp(e){q.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){q.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){q.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let t=!1;const i=e.reduce((n,a)=>{const l=a.pts-n;return l<-4294967296?(t=!0,cr(n,a.pts)):l>0?n:a.pts},e[0].pts);return t&&q.debug("PTS rollover detected"),i}remux(e,t,i,n,a,l,h,d){let p,m,g,A,x,b,S=a,w=a;const P=e.pid>-1,$=t.pid>-1,N=t.samples.length,I=e.samples.length>0,O=h&&N>0||N>1;if((!P||I)&&(!$||O)||this.ISGenerated||h){this.ISGenerated||(g=this.generateIS(e,t,a,l));const U=this.isVideoContiguous;let re=-1,ne;if(O&&(re=uA(t.samples),!U&&this.config.forceKeyFrameOnDiscontinuity))if(b=!0,re>0){q.warn(`[mp4-remuxer]: Dropped ${re} out of ${N} video samples due to a missing keyframe`);const Y=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(re),t.dropped+=re,w+=(t.samples[0].pts-Y)/t.inputTimeScale,ne=w}else re===-1&&(q.warn(`[mp4-remuxer]: No keyframe found out of ${N} video samples`),b=!1);if(this.ISGenerated){if(I&&O){const Y=this.getVideoStartPts(t.samples),ce=(cr(e.samples[0].pts,Y)-Y)/t.inputTimeScale;S+=Math.max(0,ce),w+=Math.max(0,-ce)}if(I){if(e.samplerate||(q.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),g=this.generateIS(e,t,a,l)),m=this.remuxAudio(e,S,this.isAudioContiguous,l,$||O||d===tt.AUDIO?w:void 0),O){const Y=m?m.endPTS-m.startPTS:0;t.inputTimeScale||(q.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),g=this.generateIS(e,t,a,l)),p=this.remuxVideo(t,w,U,Y)}}else O&&(p=this.remuxVideo(t,w,U,0));p&&(p.firstKeyFrame=re,p.independent=re!==-1,p.firstKeyFramePTS=ne)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(x=ud(i,a,this._initPTS,this._initDTS)),n.samples.length&&(A=hd(n,a,this._initPTS))),{audio:m,video:p,initSegment:g,independent:b,text:A,id3:x}}generateIS(e,t,i,n){const a=e.samples,l=t.samples,h=this.typeSupported,d={},p=this._initPTS;let m=!p||n,g="audio/mp4",A,x,b;if(m&&(A=x=1/0),e.config&&a.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":h.mpeg?(g="audio/mpeg",e.codec=""):h.mp3&&(e.codec="mp3");break}d.audio={id:"audio",container:g,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&h.mpeg?new Uint8Array(0):se.initSegment([e]),metadata:{channelCount:e.channelCount}},m&&(b=e.inputTimeScale,!p||b!==p.timescale?A=x=a[0].pts-Math.round(b*i):m=!1)}if(t.sps&&t.pps&&l.length&&(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:se.initSegment([t]),metadata:{width:t.width,height:t.height}},m))if(b=t.inputTimeScale,!p||b!==p.timescale){const S=this.getVideoStartPts(l),w=Math.round(b*i);x=Math.min(x,cr(l[0].dts,S)-w),A=Math.min(A,S-w)}else m=!1;if(Object.keys(d).length)return this.ISGenerated=!0,m?(this._initPTS={baseTime:A,timescale:b},this._initDTS={baseTime:x,timescale:b}):A=b=void 0,{tracks:d,initPTS:A,timescale:b}}remuxVideo(e,t,i,n){const a=e.inputTimeScale,l=e.samples,h=[],d=l.length,p=this._initPTS;let m=this.nextAvcDts,g=8,A=this.videoSampleDuration,x,b,S=Number.POSITIVE_INFINITY,w=Number.NEGATIVE_INFINITY,P=!1;if(!i||m===null){const F=t*a,G=l[0].pts-cr(l[0].dts,l[0].pts);m=F-G}const $=p.baseTime*a/p.timescale;for(let F=0;F<d;F++){const G=l[F];G.pts=cr(G.pts-$,m),G.dts=cr(G.dts-$,m),G.dts<l[F>0?F-1:F].dts&&(P=!0)}P&&l.sort(function(F,G){const Q=F.dts-G.dts,me=F.pts-G.pts;return Q||me}),x=l[0].dts,b=l[l.length-1].dts;const N=b-x,I=N?Math.round(N/(d-1)):A||e.inputTimeScale/30;if(i){const F=x-m,G=F>I,Q=F<-1;if((G||Q)&&(G?q.warn(`AVC: ${Lo(F,!0)} ms (${F}dts) hole between fragments detected, filling it`):q.warn(`AVC: ${Lo(-F,!0)} ms (${F}dts) overlapping between fragments detected`),!Q||m>=l[0].pts)){x=m;const me=l[0].pts-F;l[0].dts=x,l[0].pts=me,q.log(`Video: First PTS/DTS adjusted: ${Lo(me,!0)}/${Lo(x,!0)}, delta: ${Lo(F,!0)} ms`)}}x=Math.max(0,x);let O=0,K=0;for(let F=0;F<d;F++){const G=l[F],Q=G.units,me=Q.length;let pe=0;for(let Re=0;Re<me;Re++)pe+=Q[Re].data.length;K+=pe,O+=me,G.length=pe,G.dts=Math.max(G.dts,x),S=Math.min(G.pts,S),w=Math.max(G.pts,w)}b=l[d-1].dts;const U=K+4*O+8;let re;try{re=new Uint8Array(U)}catch(F){this.observer.emit(_.ERROR,_.ERROR,{type:et.MUX_ERROR,details:de.REMUX_ALLOC_ERROR,fatal:!1,error:F,bytes:U,reason:`fail allocating video mdat ${U}`});return}const ne=new DataView(re.buffer);ne.setUint32(0,U),re.set(se.types.mdat,4);let Y=!1,Ee=Number.POSITIVE_INFINITY,ce=Number.POSITIVE_INFINITY,we=Number.NEGATIVE_INFINITY,Oe=Number.NEGATIVE_INFINITY;for(let F=0;F<d;F++){const G=l[F],Q=G.units;let me=0;for(let Ue=0,Ke=Q.length;Ue<Ke;Ue++){const Ze=Q[Ue],pt=Ze.data,ft=Ze.data.byteLength;ne.setUint32(g,ft),g+=4,re.set(pt,g),g+=ft,me+=4+ft}let pe;if(F<d-1)A=l[F+1].dts-G.dts,pe=l[F+1].pts-G.pts;else{const Ue=this.config,Ke=F>0?G.dts-l[F-1].dts:I;if(pe=F>0?G.pts-l[F-1].pts:I,Ue.stretchShortVideoTrack&&this.nextAudioPts!==null){const Ze=Math.floor(Ue.maxBufferHole*a),pt=(n?S+n*a:this.nextAudioPts)-G.pts;pt>Ze?(A=pt-Ke,A<0?A=Ke:Y=!0,q.log(`[mp4-remuxer]: It is approximately ${pt/90} ms to the next segment; using duration ${A/90} ms for the last video frame.`)):A=Ke}else A=Ke}const Re=Math.round(G.pts-G.dts);Ee=Math.min(Ee,A),we=Math.max(we,A),ce=Math.min(ce,pe),Oe=Math.max(Oe,pe),h.push(new fd(G.key,A,me,Re))}if(h.length){if(za){if(za<70){const F=h[0].flags;F.dependsOn=2,F.isNonSync=0}}else if(Hc&&Oe-ce<we-Ee&&I/we<.025&&h[0].cts===0){q.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let F=x;for(let G=0,Q=h.length;G<Q;G++){const me=F+h[G].duration,pe=F+h[G].cts;if(G<Q-1){const Re=me+h[G+1].cts;h[G].duration=Re-pe}else h[G].duration=G?h[G-1].duration:I;h[G].cts=0,F=me}}}A=Y||!A?I:A,this.nextAvcDts=m=b+A,this.videoSampleDuration=A,this.isVideoContiguous=!0;const B=se.moof(e.sequenceNumber++,x,ai({},e,{samples:h})),W="video",ke={data1:B,data2:re,startPTS:S/a,endPTS:(w+A)/a,startDTS:x/a,endDTS:m/a,type:W,hasAudio:!1,hasVideo:!0,nb:h.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ke}remuxAudio(e,t,i,n,a){const l=e.inputTimeScale,h=e.samplerate?e.samplerate:l,d=l/h,p=e.segmentCodec==="aac"?cd:cA,m=p*d,g=this._initPTS,A=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,x=[],b=a!==void 0;let S=e.samples,w=A?0:8,P=this.nextAudioPts||-1;const $=t*l,N=g.baseTime*l/g.timescale;if(this.isAudioContiguous=i=i||S.length&&P>0&&(n&&Math.abs($-P)<9e3||Math.abs(cr(S[0].pts-N,$)-P)<20*m),S.forEach(function(W){W.pts=cr(W.pts-N,$)}),!i||P<0){if(S=S.filter(W=>W.pts>=0),!S.length)return;a===0?P=0:n&&!b?P=Math.max(0,$):P=S[0].pts}if(e.segmentCodec==="aac"){const W=this.config.maxAudioFramesDrift;for(let ke=0,F=P;ke<S.length;ke++){const G=S[ke],Q=G.pts,me=Q-F,pe=Math.abs(1e3*me/l);if(me<=-W*m&&b)ke===0&&(q.warn(`Audio frame @ ${(Q/l).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*me/l)} ms.`),this.nextAudioPts=P=F=Q);else if(me>=W*m&&pe<lA&&b){let Re=Math.round(me/m);F=Q-Re*m,F<0&&(Re--,F+=m),ke===0&&(this.nextAudioPts=P=F),q.warn(`[mp4-remuxer]: Injecting ${Re} audio frame @ ${(F/l).toFixed(3)}s due to ${Math.round(1e3*me/l)} ms gap.`);for(let Ue=0;Ue<Re;Ue++){const Ke=Math.max(F,0);let Ze=ad.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Ze||(q.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Ze=G.unit.subarray()),S.splice(ke,0,{unit:Ze,pts:Ke}),F+=m,ke++}}G.pts=F,F+=m}}let I=null,O=null,K,U=0,re=S.length;for(;re--;)U+=S[re].unit.byteLength;for(let W=0,ke=S.length;W<ke;W++){const F=S[W],G=F.unit;let Q=F.pts;if(O!==null){const pe=x[W-1];pe.duration=Math.round((Q-O)/d)}else if(i&&e.segmentCodec==="aac"&&(Q=P),I=Q,U>0){U+=w;try{K=new Uint8Array(U)}catch(pe){this.observer.emit(_.ERROR,_.ERROR,{type:et.MUX_ERROR,details:de.REMUX_ALLOC_ERROR,fatal:!1,error:pe,bytes:U,reason:`fail allocating audio mdat ${U}`});return}A||(new DataView(K.buffer).setUint32(0,U),K.set(se.types.mdat,4))}else return;K.set(G,w);const me=G.byteLength;w+=me,x.push(new fd(!0,p,me,0)),O=Q}const ne=x.length;if(!ne)return;const Y=x[x.length-1];this.nextAudioPts=P=O+d*Y.duration;const Ee=A?new Uint8Array(0):se.moof(e.sequenceNumber++,I/d,ai({},e,{samples:x}));e.samples=[];const ce=I/l,we=P/l,B={data1:Ee,data2:K,startPTS:ce,endPTS:we,startDTS:ce,endDTS:we,type:"audio",hasAudio:!0,hasVideo:!1,nb:ne};return this.isAudioContiguous=!0,B}remuxEmptyAudio(e,t,i,n){const a=e.inputTimeScale,l=e.samplerate?e.samplerate:a,h=a/l,d=this.nextAudioPts,p=this._initDTS,m=p.baseTime*9e4/p.timescale,g=(d!==null?d:n.startDTS*a)+m,A=n.endDTS*a+m,x=h*cd,b=Math.ceil((A-g)/x),S=ad.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(q.warn("[mp4-remuxer]: remux empty Audio"),!S){q.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const w=[];for(let P=0;P<b;P++){const $=g+P*x;w.push({unit:S,pts:$,dts:$})}return e.samples=w,this.remuxAudio(e,t,i,!1)}}function cr(s,e){let t;if(e===null)return s;for(e<s?t=-8589934592:t=8589934592;Math.abs(s-e)>4294967296;)s+=t;return s}function uA(s){for(let e=0;e<s.length;e++)if(s[e].key)return e;return-1}function ud(s,e,t,i){const n=s.samples.length;if(!n)return;const a=s.inputTimeScale;for(let h=0;h<n;h++){const d=s.samples[h];d.pts=cr(d.pts-t.baseTime*a/t.timescale,e*a)/a,d.dts=cr(d.dts-i.baseTime*a/i.timescale,e*a)/a}const l=s.samples;return s.samples=[],{samples:l}}function hd(s,e,t){const i=s.samples.length;if(!i)return;const n=s.inputTimeScale;for(let l=0;l<i;l++){const h=s.samples[l];h.pts=cr(h.pts-t.baseTime*n/t.timescale,e*n)/n}s.samples.sort((l,h)=>l.pts-h.pts);const a=s.samples;return s.samples=[],{samples:a}}class fd{constructor(e,t,i,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=i,this.cts=n,this.flags=new hA(e)}}class hA{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}}class fA{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(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,i,n){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(Dv(e,n)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:i}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const n=this.initData=pf(e);t||(t=dd(n.audio,Ct.AUDIO)),i||(i=dd(n.video,Ct.VIDEO));const a={};n.audio&&n.video?a.audiovideo={container:"video/mp4",codec:t+","+i,initSegment:e,id:"main"}:n.audio?a.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:n.video?a.video={container:"video/mp4",codec:i,initSegment:e,id:"main"}:q.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a}remux(e,t,i,n,a,l){var h,d;let{initPTS:p,lastEndTime:m}=this;const g={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};ze(m)||(m=this.lastEndTime=a||0);const A=t.samples;if(!(A!=null&&A.length))return g;const x={initPTS:void 0,timescale:1};let b=this.initData;if((h=b)!=null&&h.length||(this.generateInitSegment(A),b=this.initData),!((d=b)!=null&&d.length))return q.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),g;this.emitInitSegment&&(x.tracks=this.initTracks,this.emitInitSegment=!1);const S=Pv(A,b),w=Ov(b,A),P=w===null?a:w;(dA(p,P,a,S)||x.timescale!==p.timescale&&l)&&(x.initPTS=P-a,p&&p.timescale===1&&q.warn(`Adjusting initPTS by ${x.initPTS-p.baseTime}`),this.initPTS=p={baseTime:x.initPTS,timescale:1});const $=e?P-p.baseTime/p.timescale:m,N=$+S;Mv(b,A,p.baseTime/p.timescale),S>0?this.lastEndTime=N:(q.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const I=!!b.audio,O=!!b.video;let K="";I&&(K+="audio"),O&&(K+="video");const U={data1:A,startPTS:$,startDTS:$,endPTS:N,endDTS:N,type:K,hasAudio:I,hasVideo:O,nb:1,dropped:0};return g.audio=U.type==="audio"?U:void 0,g.video=U.type!=="audio"?U:void 0,g.initSegment=x,g.id3=ud(i,a,p,p),n.samples.length&&(g.text=hd(n,a,p)),g}}function dA(s,e,t,i){if(s===null)return!0;const n=Math.max(i,1),a=e-s.baseTime/s.timescale;return Math.abs(a-t)>n}function dd(s,e){const t=s==null?void 0:s.codec;return t&&t.length>4?t:t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":t==="avc1"||e===Ct.VIDEO?"avc1.42e01e":"mp4a.40.5"}let es;try{es=self.performance.now.bind(self.performance)}catch{q.debug("Unable to use Performance API on this environment"),es=typeof self<"u"&&self.Date.now}const jc=[{demux:Xy,remux:fA},{demux:bs,remux:Wc},{demux:zy,remux:Wc},{demux:nA,remux:Wc}];class pd{constructor(e,t,i,n,a){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=e,this.typeSupported=t,this.config=i,this.vendor=n,this.id=a}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,n){const a=i.transmuxing;a.executeStart=es();let l=new Uint8Array(e);const{currentTransmuxState:h,transmuxConfig:d}=this;n&&(this.currentTransmuxState=n);const{contiguous:p,discontinuity:m,trackSwitch:g,accurateTimeOffset:A,timeOffset:x,initSegmentChange:b}=n||h,{audioCodec:S,videoCodec:w,defaultInitPts:P,duration:$,initSegmentData:N}=d,I=pA(l,t);if(I&&I.method==="AES-128"){const re=this.getDecrypter();if(re.isSync()){let ne=re.softwareDecrypt(l,I.key.buffer,I.iv.buffer);if(i.part>-1&&(ne=re.flush()),!ne)return a.executeEnd=es(),Kc(i);l=new Uint8Array(ne)}else return this.decryptionPromise=re.webCryptoDecrypt(l,I.key.buffer,I.iv.buffer).then(ne=>{const Y=this.push(ne,null,i);return this.decryptionPromise=null,Y}),this.decryptionPromise}const O=this.needsProbing(m,g);if(O){const re=this.configureTransmuxer(l);if(re)return q.warn(`[transmuxer] ${re.message}`),this.observer.emit(_.ERROR,_.ERROR,{type:et.MEDIA_ERROR,details:de.FRAG_PARSING_ERROR,fatal:!1,error:re,reason:re.message}),a.executeEnd=es(),Kc(i)}(m||g||b||O)&&this.resetInitSegment(N,S,w,$,t),(m||b||O)&&this.resetInitialTimestamp(P),p||this.resetContiguity();const K=this.transmux(l,I,x,A,i),U=this.currentTransmuxState;return U.contiguous=!0,U.discontinuity=!1,U.trackSwitch=!1,a.executeEnd=es(),K}flush(e){const t=e.transmuxing;t.executeStart=es();const{decrypter:i,currentTransmuxState:n,decryptionPromise:a}=this;if(a)return a.then(()=>this.flush(e));const l=[],{timeOffset:h}=n;if(i){const g=i.flush();g&&l.push(this.push(g,null,e))}const{demuxer:d,remuxer:p}=this;if(!d||!p)return t.executeEnd=es(),[Kc(e)];const m=d.flush(h);return Ya(m)?m.then(g=>(this.flushRemux(l,g,e),l)):(this.flushRemux(l,m,e),l)}flushRemux(e,t,i){const{audioTrack:n,videoTrack:a,id3Track:l,textTrack:h}=t,{accurateTimeOffset:d,timeOffset:p}=this.currentTransmuxState;q.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const m=this.remuxer.remux(n,a,l,h,p,d,!0,this.id);e.push({remuxResult:m,chunkMeta:i}),i.transmuxing.executeEnd=es()}resetInitialTimestamp(e){const{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,n,a){const{demuxer:l,remuxer:h}=this;!l||!h||(l.resetInitSegment(e,t,i,n),h.resetInitSegment(e,t,i,a))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,n,a){let l;return t&&t.method==="SAMPLE-AES"?l=this.transmuxSampleAes(e,t,i,n,a):l=this.transmuxUnencrypted(e,i,n,a),l}transmuxUnencrypted(e,t,i,n){const{audioTrack:a,videoTrack:l,id3Track:h,textTrack:d}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(a,l,h,d,t,i,!1,this.id),chunkMeta:n}}transmuxSampleAes(e,t,i,n,a){return this.demuxer.demuxSampleAes(e,t,i).then(l=>({remuxResult:this.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,i,n,!1,this.id),chunkMeta:a}))}configureTransmuxer(e){const{config:t,observer:i,typeSupported:n,vendor:a}=this;let l;for(let g=0,A=jc.length;g<A;g++)if(jc[g].demux.probe(e)){l=jc[g];break}if(!l)return new Error("Failed to find demuxer by probing fragment data");const h=this.demuxer,d=this.remuxer,p=l.remux,m=l.demux;(!d||!(d instanceof p))&&(this.remuxer=new p(i,t,n,a)),(!h||!(h instanceof m))&&(this.demuxer=new m(i,t,n),this.probe=m.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Fc(this.config)),e}}function pA(s,e){let t=null;return s.byteLength>0&&e!=null&&e.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const Kc=s=>({remuxResult:{},chunkMeta:s});function Ya(s){return"then"in s&&s.then instanceof Function}class mA{constructor(e,t,i,n,a){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=n,this.defaultInitPts=a||null}}class gA{constructor(e,t,i,n,a,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=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=n,this.timeOffset=a,this.initSegmentChange=l}}var md={exports:{}};(function(s){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function n(d,p,m){this.fn=d,this.context=p,this.once=m||!1}function a(d,p,m,g,A){if(typeof m!="function")throw new TypeError("The listener must be a function");var x=new n(m,g||d,A),b=t?t+p:p;return d._events[b]?d._events[b].fn?d._events[b]=[d._events[b],x]:d._events[b].push(x):(d._events[b]=x,d._eventsCount++),d}function l(d,p){--d._eventsCount===0?d._events=new i:delete d._events[p]}function h(){this._events=new i,this._eventsCount=0}h.prototype.eventNames=function(){var p=[],m,g;if(this._eventsCount===0)return p;for(g in m=this._events)e.call(m,g)&&p.push(t?g.slice(1):g);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(m)):p},h.prototype.listeners=function(p){var m=t?t+p:p,g=this._events[m];if(!g)return[];if(g.fn)return[g.fn];for(var A=0,x=g.length,b=new Array(x);A<x;A++)b[A]=g[A].fn;return b},h.prototype.listenerCount=function(p){var m=t?t+p:p,g=this._events[m];return g?g.fn?1:g.length:0},h.prototype.emit=function(p,m,g,A,x,b){var S=t?t+p:p;if(!this._events[S])return!1;var w=this._events[S],P=arguments.length,$,N;if(w.fn){switch(w.once&&this.removeListener(p,w.fn,void 0,!0),P){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,m),!0;case 3:return w.fn.call(w.context,m,g),!0;case 4:return w.fn.call(w.context,m,g,A),!0;case 5:return w.fn.call(w.context,m,g,A,x),!0;case 6:return w.fn.call(w.context,m,g,A,x,b),!0}for(N=1,$=new Array(P-1);N<P;N++)$[N-1]=arguments[N];w.fn.apply(w.context,$)}else{var I=w.length,O;for(N=0;N<I;N++)switch(w[N].once&&this.removeListener(p,w[N].fn,void 0,!0),P){case 1:w[N].fn.call(w[N].context);break;case 2:w[N].fn.call(w[N].context,m);break;case 3:w[N].fn.call(w[N].context,m,g);break;case 4:w[N].fn.call(w[N].context,m,g,A);break;default:if(!$)for(O=1,$=new Array(P-1);O<P;O++)$[O-1]=arguments[O];w[N].fn.apply(w[N].context,$)}}return!0},h.prototype.on=function(p,m,g){return a(this,p,m,g,!1)},h.prototype.once=function(p,m,g){return a(this,p,m,g,!0)},h.prototype.removeListener=function(p,m,g,A){var x=t?t+p:p;if(!this._events[x])return this;if(!m)return l(this,x),this;var b=this._events[x];if(b.fn)b.fn===m&&(!A||b.once)&&(!g||b.context===g)&&l(this,x);else{for(var S=0,w=[],P=b.length;S<P;S++)(b[S].fn!==m||A&&!b[S].once||g&&b[S].context!==g)&&w.push(b[S]);w.length?this._events[x]=w.length===1?w[0]:w:l(this,x)}return this},h.prototype.removeAllListeners=function(p){var m;return p?(m=t?t+p:p,this._events[m]&&l(this,m)):(this._events=new i,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prefixed=t,h.EventEmitter=h,s.exports=h})(md);var vA=md.exports,zc=iv(vA);const Yc=Fa()||{isTypeSupported:()=>!1};class gd{constructor(e,t,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 a=e.config;this.hls=e,this.id=t,this.useWorker=!!a.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;const l=(p,m)=>{m=m||{},m.frag=this.frag,m.id=this.id,p===_.ERROR&&(this.error=m.error),this.hls.trigger(p,m)};this.observer=new zc,this.observer.on(_.FRAG_DECRYPTED,l),this.observer.on(_.ERROR,l);const h={mp4:Yc.isTypeSupported("video/mp4"),mpeg:Yc.isTypeSupported("audio/mpeg"),mp3:Yc.isTypeSupported('audio/mp4; codecs="mp3"')},d=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(a.workerPath||Ny())){try{a.workerPath?(q.log(`loading Web Worker ${a.workerPath} for "${t}"`),this.workerContext=By(a.workerPath)):(q.log(`injecting Web Worker for "${t}"`),this.workerContext=Uy()),this.onwmsg=g=>this.onWorkerMessage(g);const{worker:m}=this.workerContext;m.addEventListener("message",this.onwmsg),m.onerror=g=>{const A=new Error(`${g.message} (${g.filename}:${g.lineno})`);a.enableWorker=!1,q.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(_.ERROR,{type:et.OTHER_ERROR,details:de.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:A})},m.postMessage({cmd:"init",typeSupported:h,vendor:d,id:t,config:JSON.stringify(a)})}catch(m){q.warn(`Error setting up "${t}" Web Worker, fallback to inline`,m),this.resetWorker(),this.error=null,this.transmuxer=new pd(this.observer,h,a,d,t)}return}this.transmuxer=new pd(this.observer,h,a,d,t)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,i,n,a,l,h,d,p,m){var g,A;p.transmuxing.start=self.performance.now();const{transmuxer:x}=this,b=l?l.start:a.start,S=a.decryptdata,w=this.frag,P=!(w&&a.cc===w.cc),$=!(w&&p.level===w.level),N=w?p.sn-w.sn:-1,I=this.part?p.part-this.part.index:-1,O=N===0&&p.id>1&&p.id===(w==null?void 0:w.stats.chunkCount),K=!$&&(N===1||N===0&&(I===1||O&&I<=0)),U=self.performance.now();($||N||a.stats.parsing.start===0)&&(a.stats.parsing.start=U),l&&(I||!K)&&(l.stats.parsing.start=U);const re=!(w&&((g=a.initSegment)==null?void 0:g.url)===((A=w.initSegment)==null?void 0:A.url)),ne=new gA(P,K,d,$,b,re);if(!K||P||re){q.log(`[transmuxer-interface, ${a.type}]: Starting new transmux session for sn: ${p.sn} p: ${p.part} level: ${p.level} id: ${p.id}
|
180
|
+
discontinuity: ${P}
|
181
|
+
trackSwitch: ${$}
|
182
|
+
contiguous: ${K}
|
183
|
+
accurateTimeOffset: ${d}
|
184
|
+
timeOffset: ${b}
|
185
|
+
initSegmentChange: ${re}`);const Y=new mA(i,n,t,h,m);this.configureTransmuxer(Y)}if(this.frag=a,this.part=l,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:S,chunkMeta:p,state:ne},e instanceof ArrayBuffer?[e]:[]);else if(x){const Y=x.push(e,S,p,ne);Ya(Y)?(x.async=!0,Y.then(Ee=>{this.handleTransmuxComplete(Ee)}).catch(Ee=>{this.transmuxerError(Ee,p,"transmuxer-interface push error")})):(x.async=!1,this.handleTransmuxComplete(Y))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let i=t.flush(e);Ya(i)||t.async?(Ya(i)||(i=Promise.resolve(i)),i.then(a=>{this.handleFlushResult(a,e)}).catch(a=>{this.transmuxerError(a,e,"transmuxer-interface flush error")})):this.handleFlushResult(i,e)}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(_.ERROR,{type:et.MEDIA_ERROR,details:de.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(t)}onWorkerMessage(e){const t=e.data,i=this.hls;switch(t.event){case"init":{var n;const a=(n=this.workerContext)==null?void 0:n.objectURL;a&&self.URL.revokeObjectURL(a);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":q[t.data.logType]&&q[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,i.trigger(t.event,t.data);break}}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const yA=250,Xc=2,AA=.1,EA=.05;class xA{constructor(e,t,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=e,this.media=t,this.fragmentTracker=i,this.hls=n}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:i,media:n,stalled:a}=this;if(n===null)return;const{currentTime:l,seeking:h}=n,d=this.seeking&&!h,p=!this.seeking&&h;if(this.seeking=h,l!==e){if(this.moved=!0,a!==null){if(this.stallReported){const P=self.performance.now()-a;q.warn(`playback not stuck anymore @${l}, after ${Math.round(P)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(p||d){this.stalled=null;return}if(n.paused&&!h||n.ended||n.playbackRate===0||!Nt.getBuffered(n).length)return;const m=Nt.bufferInfo(n,l,0),g=m.len>0,A=m.nextStart||0;if(!g&&!A)return;if(h){const P=m.len>Xc,$=!A||t&&t.start<=l||A-l>Xc&&!this.fragmentTracker.getPartialFragment(l);if(P||$)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var x;const P=Math.max(A,m.start||0)-l,$=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,I=($==null||(x=$.details)==null?void 0:x.live)?$.details.targetduration*2:Xc,O=this.fragmentTracker.getPartialFragment(l);if(P>0&&(P<=I||O)){this._trySkipBufferHole(O);return}}const b=self.performance.now();if(a===null){this.stalled=b;return}const S=b-a;if(!h&&S>=yA&&(this._reportStall(m),!this.media))return;const w=Nt.bufferInfo(n,l,i.maxBufferHole);this._tryFixBufferStall(w,S)}_tryFixBufferStall(e,t){const{config:i,fragmentTracker:n,media:a}=this;if(a===null)return;const l=a.currentTime,h=n.getPartialFragment(l);h&&(this._trySkipBufferHole(h)||!this.media)||(e.len>i.maxBufferHole||e.nextStart&&e.nextStart-l<i.maxBufferHole)&&t>i.highBufferWatchdogPeriod*1e3&&(q.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:i,stallReported:n}=this;if(!n&&i){this.stallReported=!0;const a=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(e)})`);q.warn(a.message),t.trigger(_.ERROR,{type:et.MEDIA_ERROR,details:de.BUFFER_STALLED_ERROR,fatal:!1,error:a,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:i,media:n}=this;if(n===null)return 0;const a=n.currentTime,l=Nt.bufferInfo(n,a,0),h=a<l.start?l.start:l.nextStart;if(h){const d=l.len<=t.maxBufferHole,p=l.len>0&&l.len<1&&n.readyState<3,m=h-a;if(m>0&&(d||p)){if(m>t.maxBufferHole){const{fragmentTracker:A}=this;let x=!1;if(a===0){const b=A.getAppendedFrag(0,tt.MAIN);b&&h<b.end&&(x=!0)}if(!x){const b=e||A.getAppendedFrag(a,tt.MAIN);if(b){let S=!1,w=b.end;for(;w<h;){const P=A.getPartialFragment(w);if(P)w+=P.duration;else{S=!0;break}}if(S)return 0}}}const g=Math.max(h+EA,a+AA);if(q.warn(`skipping hole, adjusting currentTime from ${a} to ${g}`),this.moved=!0,this.stalled=null,n.currentTime=g,e&&!e.gap){const A=new Error(`fragment loaded with buffer holes, seeking from ${a} to ${g}`);i.trigger(_.ERROR,{type:et.MEDIA_ERROR,details:de.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:A,reason:A.message,frag:e})}return g}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:i,nudgeRetry:n}=this;if(i===null)return;const a=i.currentTime;if(this.nudgeRetry++,n<e.nudgeMaxRetry){const l=a+(n+1)*e.nudgeOffset,h=new Error(`Nudging 'currentTime' from ${a} to ${l}`);q.warn(h.message),i.currentTime=l,t.trigger(_.ERROR,{type:et.MEDIA_ERROR,details:de.BUFFER_NUDGE_ON_STALL,error:h,fatal:!1})}else{const l=new Error(`Playhead still not moving while enough data buffered @${a} after ${e.nudgeMaxRetry} nudges`);q.error(l.message),t.trigger(_.ERROR,{type:et.MEDIA_ERROR,details:de.BUFFER_STALLED_ERROR,error:l,fatal:!0})}}}const bA=100;class TA extends Nc{constructor(e,t,i){super(e,t,i,"[stream-controller]",tt.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:e}=this;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(_.ERROR,this.onError,this),e.on(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(_.BUFFER_CREATED,this.onBufferCreated,this),e.on(_.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(_.ERROR,this.onError,this),e.off(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(_.BUFFER_CREATED,this.onBufferCreated,this),e.off(_.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:i}=this;if(this.stopLoad(),this.setInterval(bA),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}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=Se.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=Se.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Se.WAITING_LEVEL:{var e;const{levels:i,level:n}=this,a=i==null||(e=i[n])==null?void 0:e.details;if(a&&(!a.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(a))break;this.state=Se.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=Se.IDLE;break}break}case Se.FRAG_LOADING_WAITING_RETRY:{var t;const i=self.performance.now(),n=this.retryDate;(!n||i>=n||(t=this.media)!=null&&t.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Se.IDLE)}break}this.state===Se.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:n}=this,{config:a,nextLoadLevel:l}=e;if(t===null||!n&&(this.startFragRequested||!a.startFragPrefetch)||this.altAudio&&this.audioOnly||!(i!=null&&i[l]))return;const h=i[l],d=this.getMainFwdBufferInfo();if(d===null)return;const p=this.getLevelDetails();if(p&&this._streamEnded(d,p)){const w={};this.altAudio&&(w.type="video"),this.hls.trigger(_.BUFFER_EOS,w),this.state=Se.ENDED;return}e.loadLevel!==l&&e.manualLevel===-1&&this.log(`Adapting to level ${l} from level ${this.level}`),this.level=e.nextLoadLevel=l;const m=h.details;if(!m||this.state===Se.WAITING_LEVEL||m.live&&this.levelLastLoaded!==l){this.level=l,this.state=Se.WAITING_LEVEL;return}const g=d.len,A=this.getMaxBufferLength(h.maxBitrate);if(g>=A)return;this.backtrackFragment&&this.backtrackFragment.start>d.end&&(this.backtrackFragment=null);const x=this.backtrackFragment?this.backtrackFragment.start:d.end;let b=this.getNextFragment(x,m);if(this.couldBacktrack&&!this.fragPrevious&&b&&b.sn!=="initSegment"&&this.fragmentTracker.getState(b)!==di.OK){var S;const P=((S=this.backtrackFragment)!=null?S:b).sn-m.startSN,$=m.fragments[P-1];$&&b.cc===$.cc&&(b=$,this.fragmentTracker.removeFragment($))}else this.backtrackFragment&&d.len&&(this.backtrackFragment=null);if(b&&this.isLoopLoading(b,x)){if(!b.gap){const P=this.audioOnly&&!this.altAudio?Ct.AUDIO:Ct.VIDEO,$=(P===Ct.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;$&&this.afterBufferFlushed($,P,tt.MAIN)}b=this.getNextFragmentLoopLoading(b,m,d,tt.MAIN,A)}b&&(b.initSegment&&!b.initSegment.data&&!this.bitrateTest&&(b=b.initSegment),this.loadFragment(b,h,x))}loadFragment(e,t,i){const n=this.fragmentTracker.getState(e);this.fragCurrent=e,n===di.NOT_LOADED||n===di.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,i)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,tt.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let i;const n=this.getAppendedFrag(t.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);const a=this.getLevelDetails();if(a!=null&&a.live){const h=this.getMainFwdBufferInfo();if(!h||h.len<a.targetduration*2)return}if(!t.paused&&e){const h=this.hls.nextLoadLevel,d=e[h],p=this.fragLastKbps;p&&this.fragCurrent?i=this.fragCurrent.duration*d.maxBitrate/(1e3*p)+1:i=0}else i=0;const l=this.getBufferedFrag(t.currentTime+i);if(l){const h=this.followingBufferedFrag(l);if(h){this.abortCurrentFrag();const d=h.maxStartPTS?h.maxStartPTS:h.start,p=h.duration,m=Math.max(l.end,d+Math.min(Math.max(p-this.config.maxFragLookUpTolerance,p*.5),p*.75));this.flushMainBuffer(m,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case Se.KEY_LOADING:case Se.FRAG_LOADING:case Se.FRAG_LOADING_WAITING_RETRY:case Se.PARSING:case Se.PARSED:this.state=Se.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new xA(this.config,i,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;ze(t)&&this.log(`Media seeked to ${t.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(_.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(e,t){let i=!1,n=!1,a;t.levels.forEach(l=>{a=l.audioCodec,a&&(a.indexOf("mp4a.40.2")!==-1&&(i=!0),a.indexOf("mp4a.40.5")!==-1&&(n=!0))}),this.audioCodecSwitch=i&&n&&!Fy(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:i}=this;if(!i||this.state!==Se.IDLE)return;const n=i[t.level];(!n.details||n.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(n.details))&&(this.state=Se.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:n}=this,a=t.level,l=t.details,h=l.totalduration;if(!n){this.warn(`Levels were reset while loading level ${a}`);return}this.log(`Level ${a} loaded [${l.startSN},${l.endSN}]${l.lastPartSn?`[part-${l.lastPartSn}-${l.lastPartIndex}]`:""}, cc [${l.startCC}, ${l.endCC}] duration:${h}`);const d=n[a],p=this.fragCurrent;p&&(this.state===Se.FRAG_LOADING||this.state===Se.FRAG_LOADING_WAITING_RETRY)&&(p.level!==t.level||p.urlId!==d.urlId)&&p.loader&&this.abortCurrentFrag();let m=0;if(l.live||(i=d.details)!=null&&i.live){if(this.checkLiveUpdate(l),l.deltaUpdateFailed)return;m=this.alignPlaylists(l,d.details)}if(d.details=l,this.levelLastLoaded=a,this.hls.trigger(_.LEVEL_UPDATED,{details:l,level:a}),this.state===Se.WAITING_LEVEL){if(this.waitForCdnTuneIn(l))return;this.state=Se.IDLE}this.startFragRequested?l.live&&this.synchronizeToLiveEdge(l):this.setStartPosition(l,m),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:i,part:n,payload:a}=e,{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 h=l[i.level],d=h.details;if(!d){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const p=h.videoCodec,m=d.PTSKnown||!d.live,g=(t=i.initSegment)==null?void 0:t.data,A=this._getAudioCodec(h),x=this.transmuxer=this.transmuxer||new gd(this.hls,tt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),b=n?n.index:-1,S=b!==-1,w=new $c(i.level,i.sn,i.stats.chunkCount,a.byteLength,b,S),P=this.initPTS[i.cc];x.push(a,g,A,p,i,n,d.totalduration,m,w,P)}onAudioTrackSwitching(e,t){const i=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const l=this.fragCurrent;l&&(this.log("Switching to main audio track, cancel main fragment load"),l.abortRequests(),this.fragmentTracker.removeFragment(l)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const a=this.hls;i&&(a.trigger(_.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),a.trigger(_.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=t.id,n=!!this.hls.audioTracks[i].url;if(n){const a=this.videoBuffer;a&&this.mediaBuffer!==a&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=a)}this.altAudio=n,this.tick()}onBufferCreated(e,t){const i=t.tracks;let n,a,l=!1;for(const h in i){const d=i[h];if(d.id==="main"){if(a=h,n=d,h==="video"){const p=i[h];p&&(this.videoBuffer=p.buffer)}}else l=!0}l&&n?(this.log(`Alternate track found, use ${a}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:n}=t;if(i&&i.type!==tt.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===Se.PARSED&&(this.state=Se.IDLE);return}const a=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}onError(e,t){var i;if(t.fatal){this.state=Se.ERROR;return}switch(t.details){case de.FRAG_GAP:case de.FRAG_PARSING_ERROR:case de.FRAG_DECRYPT_ERROR:case de.FRAG_LOAD_ERROR:case de.FRAG_LOAD_TIMEOUT:case de.KEY_LOAD_ERROR:case de.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(tt.MAIN,t);break;case de.LEVEL_LOAD_ERROR:case de.LEVEL_LOAD_TIMEOUT:case de.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===Se.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===Tt.LEVEL&&(this.state=Se.IDLE);break;case de.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case de.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Nt.getBuffered(e).length){const i=this.state!==Se.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,i)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=Se.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Ct.AUDIO||this.audioOnly&&!this.altAudio){const i=(t===Ct.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,t,tt.MAIN)}}onLevelsUpdated(e,t){this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}const n=Nt.getBuffered(e),l=(n.length?n.start(0):0)-i;l>0&&(l<this.config.maxBufferHole||l<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${l} to match buffer start`),i+=l,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${t}`),e.currentTime=i}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(i=>{const{hls:n}=this;if(!i||this.fragContextChanged(e))return;t.fragmentError=0,this.state=Se.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const a=e.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),n.trigger(_.FRAG_LOADED,i),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const i="main",{hls:n}=this,{remuxResult:a,chunkMeta:l}=e,h=this.getCurrentContext(l);if(!h){this.resetWhenMissingContext(l);return}const{frag:d,part:p,level:m}=h,{video:g,text:A,id3:x,initSegment:b}=a,{details:S}=m,w=this.altAudio?void 0:a.audio;if(this.fragContextChanged(d)){this.fragmentTracker.removeFragment(d);return}if(this.state=Se.PARSING,b){if(b!=null&&b.tracks){const N=d.initSegment||d;this._bufferInitSegment(m,b.tracks,N,l),n.trigger(_.FRAG_PARSING_INIT_SEGMENT,{frag:N,id:i,tracks:b.tracks})}const P=b.initPTS,$=b.timescale;ze(P)&&(this.initPTS[d.cc]={baseTime:P,timescale:$},n.trigger(_.INIT_PTS_FOUND,{frag:d,id:i,initPTS:P,timescale:$}))}if(g&&S&&d.sn!=="initSegment"){const P=S.fragments[d.sn-1-S.startSN],$=d.sn===S.startSN,N=!P||d.cc>P.cc;if(a.independent!==!1){const{startPTS:I,endPTS:O,startDTS:K,endDTS:U}=g;if(p)p.elementaryStreams[g.type]={startPTS:I,endPTS:O,startDTS:K,endDTS:U};else if(g.firstKeyFrame&&g.independent&&l.id===1&&!N&&(this.couldBacktrack=!0),g.dropped&&g.independent){const re=this.getMainFwdBufferInfo(),ne=(re?re.end:this.getLoadPosition())+this.config.maxBufferHole,Y=g.firstKeyFramePTS?g.firstKeyFramePTS:I;if(!$&&ne<Y-this.config.maxBufferHole&&!N){this.backtrack(d);return}else N&&(d.gap=!0);d.setElementaryStreamInfo(g.type,d.start,O,d.start,U,!0)}d.setElementaryStreamInfo(g.type,I,O,K,U),this.backtrackFragment&&(this.backtrackFragment=d),this.bufferFragmentData(g,d,p,l,$||N)}else if($||N)d.gap=!0;else{this.backtrack(d);return}}if(w){const{startPTS:P,endPTS:$,startDTS:N,endDTS:I}=w;p&&(p.elementaryStreams[Ct.AUDIO]={startPTS:P,endPTS:$,startDTS:N,endDTS:I}),d.setElementaryStreamInfo(Ct.AUDIO,P,$,N,I),this.bufferFragmentData(w,d,p,l)}if(S&&x!=null&&(t=x.samples)!=null&&t.length){const P={id:i,frag:d,details:S,samples:x.samples};n.trigger(_.FRAG_PARSING_METADATA,P)}if(S&&A){const P={id:i,frag:d,details:S,samples:A.samples};n.trigger(_.FRAG_PARSING_USERDATA,P)}}_bufferInitSegment(e,t,i,n){if(this.state!==Se.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:a,video:l,audiovideo:h}=t;if(a){let d=e.audioCodec;const p=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(d&&(d.indexOf("mp4a.40.5")!==-1?d="mp4a.40.2":d="mp4a.40.5"),a.metadata.channelCount!==1&&p.indexOf("firefox")===-1&&(d="mp4a.40.5")),p.indexOf("android")!==-1&&a.container!=="audio/mpeg"&&(d="mp4a.40.2",this.log(`Android: force audio codec to ${d}`)),e.audioCodec&&e.audioCodec!==d&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${d}"`),a.levelCodec=d,a.id="main",this.log(`Init audio buffer, container:${a.container}, codecs[selected/level/parsed]=[${d||""}/${e.audioCodec||""}/${a.codec}]`)}l&&(l.levelCodec=e.videoCodec,l.id="main",this.log(`Init video buffer, container:${l.container}, codecs[level/parsed]=[${e.videoCodec||""}/${l.codec}]`)),h&&this.log(`Init audiovideo buffer, container:${h.container}, codecs[level/parsed]=[${e.attrs.CODECS||""}/${h.codec}]`),this.hls.trigger(_.BUFFER_CODECS,t),Object.keys(t).forEach(d=>{const m=t[d].initSegment;m!=null&&m.byteLength&&this.hls.trigger(_.BUFFER_APPENDING,{type:d,data:m,frag:i,part:null,chunkMeta:n,parent:i.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,tt.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=Se.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(Nt.isBuffered(e,i)?t=this.getAppendedFrag(i):Nt.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;const n=this.fragPlaying,a=t.level;(!n||t.sn!==n.sn||n.level!==a||t.urlId!==n.urlId)&&(this.fragPlaying=t,this.hls.trigger(_.FRAG_CHANGED,{frag:t}),(!n||n.level!==a)&&this.hls.trigger(_.LEVEL_SWITCHED,{level:a}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,i=this.currentFrag;if(i&&ze(t)&&ze(i.programDateTime)){const n=i.programDateTime+(t-i.start)*1e3;return new Date(n)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class _n{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class SA{constructor(e,t,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 _n(e),this.fast_=new _n(t),this.defaultTTFB_=n,this.ttfb_=new _n(e)}update(e,t){const{slow_:i,fast_:n,ttfb_:a}=this;i.halfLife!==e&&(this.slow_=new _n(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.fast_=new _n(t,n.getEstimate(),n.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new _n(e,a.getEstimate(),a.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const i=8*t,n=e/1e3,a=i/n;this.fast_.sample(n,a),this.slow_.sample(n,a)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}class kA{constructor(e){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=e;const t=e.config;this.bwEstimator=new SA(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(_.FRAG_LOADING,this.onFragLoading,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:e}=this;e.off(_.FRAG_LOADING,this.onFragLoading,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,t){var i;const n=t.frag;this.ignoreFragment(n)||(this.fragCurrent=n,this.partCurrent=(i=t.part)!=null?i:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,t){this.clearTimer()}getTimeToLoadFrag(e,t,i,n){const a=e+i/t,l=n?this.lastLevelLoadSec:0;return a+l}onLevelLoaded(e,t){const i=this.hls.config,{total:n,bwEstimate:a}=t.stats;ze(n)&&ze(a)&&(this.lastLevelLoadSec=8*n/a),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:e,partCurrent:t,hls:i}=this,{autoLevelEnabled:n,media:a}=i;if(!e||!a)return;const l=performance.now(),h=t?t.stats:e.stats,d=t?t.duration:e.duration,p=l-h.loading.start;if(h.aborted||h.loaded&&h.loaded===h.total||e.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||a.paused||!a.playbackRate||!a.readyState)return;const m=i.mainForwardBufferInfo;if(m===null)return;const g=this.bwEstimator.getEstimateTTFB(),A=Math.abs(a.playbackRate);if(p<=Math.max(g,1e3*(d/(A*2))))return;const x=m.len/A;if(x>=2*d/A)return;const b=h.loading.first?h.loading.first-h.loading.start:-1,S=h.loaded&&b>-1,w=this.bwEstimator.getEstimate(),{levels:P,minAutoLevel:$}=i,N=P[e.level],I=h.total||Math.max(h.loaded,Math.round(d*N.maxBitrate/8));let O=p-b;O<1&&S&&(O=Math.min(p,h.loaded*8/w));const K=S?h.loaded*1e3/O:0,U=K?(I-h.loaded)/K:I*8/w+g/1e3;if(U<=x)return;const re=K?K*8:w;let ne=Number.POSITIVE_INFINITY,Y;for(Y=e.level-1;Y>$;Y--){const Ee=P[Y].maxBitrate;if(ne=this.getTimeToLoadFrag(g/1e3,re,d*Ee,!P[Y].details),ne<x)break}ne>=U||ne>d*10||(i.nextLoadLevel=Y,S?this.bwEstimator.sample(p-Math.min(g,b),h.loaded):this.bwEstimator.sampleTTFB(p),this.clearTimer(),q.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;
|
186
|
+
Time to underbuffer: ${x.toFixed(3)} s
|
187
|
+
Estimated load time for current fragment: ${U.toFixed(3)} s
|
188
|
+
Estimated load time for down switch fragment: ${ne.toFixed(3)} s
|
189
|
+
TTFB estimate: ${b}
|
190
|
+
Current BW estimate: ${ze(w)?(w/1024).toFixed(3):"Unknown"} Kb/s
|
191
|
+
New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
|
192
|
+
Aborting and switching to level ${Y}`),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),i.trigger(_.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:h}))}onFragLoaded(e,{frag:t,part:i}){const n=i?i.stats:t.stats;if(t.type===tt.MAIN&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const a=i?i.duration:t.duration,l=this.hls.levels[t.level],h=(l.loaded?l.loaded.bytes:0)+n.loaded,d=(l.loaded?l.loaded.duration:0)+a;l.loaded={bytes:h,duration:d},l.realBitrate=Math.round(8*h/d)}if(t.bitrateTest){const a={stats:n,frag:t,part:i,id:t.type};this.onFragBuffered(_.FRAG_BUFFERED,a),t.bitrateTest=!1}}}onFragBuffered(e,t){const{frag:i,part:n}=t,a=n!=null&&n.stats.loaded?n.stats:i.stats;if(a.aborted||this.ignoreFragment(i))return;const l=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(l,a.loaded),a.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==tt.MAIN||e.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const e=this._nextAutoLevel,t=this.bwEstimator;if(e!==-1&&!t.canEstimate())return e;let i=this.getNextABRAutoLevel();if(e!==-1){const n=this.hls.levels;if(n.length>Math.max(e,i)&&n[e].loadError<=n[i].loadError)return e}return e!==-1&&(i=Math.min(e,i)),i}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:i}=this,{maxAutoLevel:n,config:a,minAutoLevel:l,media:h}=i,d=t?t.duration:e?e.duration:0,p=h&&h.playbackRate!==0?Math.abs(h.playbackRate):1,m=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,g=i.mainForwardBufferInfo,A=(g?g.len:0)/p;let x=this.findBestLevel(m,l,n,A,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(x>=0)return x;q.trace(`[abr] ${A?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let b=d?Math.min(d,a.maxStarvationDelay):a.maxStarvationDelay,S=a.abrBandWidthFactor,w=a.abrBandWidthUpFactor;if(!A){const P=this.bitrateTestDelay;P&&(b=(d?Math.min(d,a.maxLoadingDelay):a.maxLoadingDelay)-P,q.trace(`[abr] bitrate test took ${Math.round(1e3*P)}ms, set first fragment max fetchDuration to ${Math.round(1e3*b)} ms`),S=w=1)}return x=this.findBestLevel(m,l,n,A+b,S,w),Math.max(x,0)}findBestLevel(e,t,i,n,a,l){var h;const{fragCurrent:d,partCurrent:p,lastLoadedFragLevel:m}=this,{levels:g}=this.hls,A=g[m],x=!!(A!=null&&(h=A.details)!=null&&h.live),b=A==null?void 0:A.codecSet,S=p?p.duration:d?d.duration:0,w=this.bwEstimator.getEstimateTTFB()/1e3;let P=t,$=-1;for(let N=i;N>=t;N--){const I=g[N];if(!I||b&&I.codecSet!==b){I&&(P=Math.min(N,P),$=Math.max(N,$));continue}$!==-1&&q.trace(`[abr] Skipped level(s) ${P}-${$} with CODECS:"${g[$].attrs.CODECS}"; not compatible with "${A.attrs.CODECS}"`);const O=I.details,K=(p?O==null?void 0:O.partTarget:O==null?void 0:O.averagetargetduration)||S;let U;N<=m?U=a*e:U=l*e;const re=g[N].maxBitrate,ne=this.getTimeToLoadFrag(w,U,re*K,O===void 0);if(q.trace(`[abr] level:${N} adjustedbw-bitrate:${Math.round(U-re)} avgDuration:${K.toFixed(1)} maxFetchDuration:${n.toFixed(1)} fetchDuration:${ne.toFixed(1)}`),U>re&&(ne===0||!ze(ne)||x&&!this.bitrateTestDelay||ne<n))return N}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}}class vd{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let i;if(e.length)e.length===1?i=e[0]:i=wA(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function wA(s,e){const t=new Uint8Array(e);let i=0;for(let n=0;n<s.length;n++){const a=s[n];t.set(a,i),i+=a.length}return t}const yd=100;class _A extends Nc{constructor(e,t,i){super(e,t,i,"[audio-stream-controller]",tt.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:e}=this;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(_.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(_.ERROR,this.onError,this),e.on(_.BUFFER_RESET,this.onBufferReset,this),e.on(_.BUFFER_CREATED,this.onBufferCreated,this),e.on(_.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(_.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(_.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(_.ERROR,this.onError,this),e.off(_.BUFFER_RESET,this.onBufferReset,this),e.off(_.BUFFER_CREATED,this.onBufferCreated,this),e.off(_.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(_.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:i,initPTS:n,timescale:a}){if(i==="main"){const l=t.cc;this.initPTS[t.cc]={baseTime:n,timescale:a},this.log(`InitPTS for cc: ${l} found from main: ${n}`),this.videoTrackCC=l,this.state===Se.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=Se.STOPPED;return}const t=this.lastCurrentTime;this.stopLoad(),this.setInterval(yd),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=Se.IDLE):(this.loadedmetadata=!1,this.state=Se.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case Se.IDLE:this.doTickIdle();break;case Se.WAITING_TRACK:{var e;const{levels:i,trackId:n}=this,a=i==null||(e=i[n])==null?void 0:e.details;if(a){if(this.waitForCdnTuneIn(a))break;this.state=Se.WAITING_INIT_PTS}break}case Se.FRAG_LOADING_WAITING_RETRY:{var t;const i=performance.now(),n=this.retryDate;(!n||i>=n||(t=this.media)!=null&&t.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Se.IDLE);break}case Se.WAITING_INIT_PTS:{const i=this.waitingData;if(i){const{frag:n,part:a,cache:l,complete:h}=i;if(this.initPTS[n.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=Se.FRAG_LOADING;const d=l.flush(),p={frag:n,part:a,payload:d,networkDetails:null};this._handleFragmentLoadProgress(p),h&&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 d=this.getLoadPosition(),p=Nt.bufferInfo(this.mediaBuffer,d,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=Se.IDLE}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Se.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:t,media:i,trackId:n}=this,a=e.config;if(!(t!=null&&t[n])||!i&&(this.startFragRequested||!a.startFragPrefetch))return;const l=t[n],h=l.details;if(!h||h.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(h)){this.state=Se.WAITING_TRACK;return}const d=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&d&&(this.bufferFlushed=!1,this.afterBufferFlushed(d,Ct.AUDIO,tt.AUDIO));const p=this.getFwdBufferInfo(d,tt.AUDIO);if(p===null)return;const{bufferedTrack:m,switchingTrack:g}=this;if(!g&&this._streamEnded(p,h)){e.trigger(_.BUFFER_EOS,{type:"audio"}),this.state=Se.ENDED;return}const A=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,tt.MAIN),x=p.len,b=this.getMaxBufferLength(A==null?void 0:A.len);if(x>=b&&!g)return;const w=h.fragments[0].start;let P=p.end;if(g&&i){const O=this.getLoadPosition();m&&g.attrs!==m.attrs&&(P=O),h.PTSKnown&&O<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 $=this.getNextFragment(P,h),N=!1;if($&&this.isLoopLoading($,P)&&(N=!!$.gap,$=this.getNextFragmentLoopLoading($,h,p,tt.MAIN,b)),!$){this.bufferFlushed=!0;return}const I=A&&$.start>A.end+h.targetduration;if(I||!(A!=null&&A.len)&&p.len){const O=this.getAppendedFrag($.start,tt.MAIN);if(O===null||(N||(N=!!O.gap||!!I&&A.len===0),I&&!N||N&&p.nextStart&&p.nextStart<O.end))return}this.loadFragment($,l,P)}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new wo(i))}onAudioTrackSwitching(e,t){const i=!!t.url;this.trackId=t.id;const{fragCurrent:n}=this;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?this.setInterval(yd):this.resetTransmuxer(),i?(this.switchingTrack=t,this.state=Se.IDLE):(this.switchingTrack=null,this.bufferedTrack=t,this.state=Se.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(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(_.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var i;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}const{levels:n}=this,{details:a,id:l}=t;if(!n){this.warn(`Audio tracks were reset while loading level ${l}`);return}this.log(`Track ${l} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`);const h=n[l];let d=0;if(a.live||(i=h.details)!=null&&i.live){this.checkLiveUpdate(a);const p=this.mainDetails;if(a.deltaUpdateFailed||!p)return;!h.details&&a.hasProgramDateTime&&p.hasProgramDateTime?(Xf(a,p),d=a.fragments[0].start):d=this.alignPlaylists(a,h.details)}h.details=a,this.levelLastLoaded=l,!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(h.details,d),this.state===Se.WAITING_TRACK&&!this.waitForCdnTuneIn(a)&&(this.state=Se.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:i,part:n,payload:a}=e,{config:l,trackId:h,levels:d}=this;if(!d){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const p=d[h];if(!p){this.warn("Audio track is undefined on fragment load progress");return}const m=p.details;if(!m){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const g=l.defaultAudioCodec||p.audioCodec||"mp4a.40.2";let A=this.transmuxer;A||(A=this.transmuxer=new gd(this.hls,tt.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const x=this.initPTS[i.cc],b=(t=i.initSegment)==null?void 0:t.data;if(x!==void 0){const w=n?n.index:-1,P=w!==-1,$=new $c(i.level,i.sn,i.stats.chunkCount,a.byteLength,w,P);A.push(a,b,g,"",i,n,m.totalduration,!1,$,x)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${m.startSN} ,${m.endSN}],track ${h}`);const{cache:S}=this.waitingData=this.waitingData||{frag:i,part:n,cache:new vd,complete:!1};S.push(new Uint8Array(a)),this.waitingVideoCC=this.videoTrackCC,this.state=Se.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){const i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){const{frag:i,part:n}=t;if(i.type!==tt.AUDIO){if(!this.loadedmetadata&&i.type===tt.MAIN){const a=this.videoBuffer||this.media;a&&Nt.getBuffered(a).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 a=this.switchingTrack;a&&(this.bufferedTrack=a,this.switchingTrack=null,this.hls.trigger(_.AUDIO_TRACK_SWITCHED,Ki({},a)))}this.fragBufferedComplete(i,n)}onError(e,t){var i;if(t.fatal){this.state=Se.ERROR;return}switch(t.details){case de.FRAG_GAP:case de.FRAG_PARSING_ERROR:case de.FRAG_DECRYPT_ERROR:case de.FRAG_LOAD_ERROR:case de.FRAG_LOAD_TIMEOUT:case de.KEY_LOAD_ERROR:case de.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(tt.AUDIO,t);break;case de.AUDIO_TRACK_LOAD_ERROR:case de.AUDIO_TRACK_LOAD_TIMEOUT:case de.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===Se.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===Tt.AUDIO_TRACK&&(this.state=Se.IDLE);break;case de.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case de.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushed(e,{type:t}){t===Ct.AUDIO&&(this.bufferFlushed=!0,this.state===Se.ENDED&&(this.state=Se.IDLE))}_handleTransmuxComplete(e){var t;const i="audio",{hls:n}=this,{remuxResult:a,chunkMeta:l}=e,h=this.getCurrentContext(l);if(!h){this.resetWhenMissingContext(l);return}const{frag:d,part:p,level:m}=h,{details:g}=m,{audio:A,text:x,id3:b,initSegment:S}=a;if(this.fragContextChanged(d)||!g){this.fragmentTracker.removeFragment(d);return}if(this.state=Se.PARSING,this.switchingTrack&&A&&this.completeAudioSwitch(this.switchingTrack),S!=null&&S.tracks){const w=d.initSegment||d;this._bufferInitSegment(S.tracks,w,l),n.trigger(_.FRAG_PARSING_INIT_SEGMENT,{frag:w,id:i,tracks:S.tracks})}if(A){const{startPTS:w,endPTS:P,startDTS:$,endDTS:N}=A;p&&(p.elementaryStreams[Ct.AUDIO]={startPTS:w,endPTS:P,startDTS:$,endDTS:N}),d.setElementaryStreamInfo(Ct.AUDIO,w,P,$,N),this.bufferFragmentData(A,d,p,l)}if(b!=null&&(t=b.samples)!=null&&t.length){const w=ai({id:i,frag:d,details:g},b);n.trigger(_.FRAG_PARSING_METADATA,w)}if(x){const w=ai({id:i,frag:d,details:g},x);n.trigger(_.FRAG_PARSING_USERDATA,w)}}_bufferInitSegment(e,t,i){if(this.state!==Se.PARSING)return;e.video&&delete e.video;const n=e.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(_.BUFFER_CODECS,e);const a=n.initSegment;if(a!=null&&a.byteLength){const l={type:"audio",frag:t,part:null,chunkMeta:i,parent:t.type,data:a};this.hls.trigger(_.BUFFER_APPENDING,l)}this.tick()}loadFragment(e,t,i){const n=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||n===di.NOT_LOADED||n===di.PARTIAL){var a;e.sn==="initSegment"?this._loadInitSegment(e,t):(a=t.details)!=null&&a.live&&!this.initPTS[e.cc]?(this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=Se.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(e,t,i))}else this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){const{hls:t,media:i,bufferedTrack:n}=this,a=n==null?void 0:n.attrs,l=e.attrs;i&&a&&(a.CHANNELS!==l.CHANNELS||a.NAME!==l.NAME||a.LANGUAGE!==l.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(_.AUDIO_TRACK_SWITCHED,Ki({},e))}}class RA extends Oc{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(_.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(_.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.LEVEL_LOADING,this.onLevelLoading,this),e.off(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(_.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(_.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(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:i,groupId:n,details:a}=t,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 h=l.details;l.details=t.details,this.log(`audio-track ${i} "${l.name}" lang:${l.lang} group:${n} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,h)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!(t!=null&&t.audioGroupIds))return;const i=t.audioGroupIds[t.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 a={audioTracks:n};this.log(`Updating audio tracks, ${n.length} track(s) found in group:${i}`),this.hls.trigger(_.AUDIO_TRACKS_UPDATED,a),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===Tt.AUDIO_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(t))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();const i=this.currentTrack;t[this.trackId];const n=t[e],{groupId:a,name:l}=n;if(this.log(`Switching to audio-track ${e} "${l}" lang:${n.lang} group:${a}`),this.trackId=e,this.currentTrack=n,this.selectDefaultTrack=!1,this.hls.trigger(_.AUDIO_TRACK_SWITCHING,Ki({},n)),n.details&&!n.details.live)return;const h=this.switchParams(n.url,i==null?void 0:i.details);this.loadPlaylist(h)}selectInitialTrack(){const e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(t!==-1)this.setAudioTrack(t);else{const i=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${e.length}`);this.warn(i.message),this.hls.trigger(_.ERROR,{type:et.MEDIA_ERROR,details:de.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const n=t[i];if((!this.selectDefaultTrack||n.default)&&(!e||e.attrs["STABLE-RENDITION-ID"]!==void 0&&e.attrs["STABLE-RENDITION-ID"]===n.attrs["STABLE-RENDITION-ID"]||e.name===n.name&&e.lang===n.lang))return n.id}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){const i=t.id,n=t.groupId;let a=t.url;if(e)try{a=e.addDirectives(a)}catch(l){this.warn(`Could not construct new URL with HLS Delivery Directives: ${l}`)}this.log(`loading audio-track playlist ${i} "${t.name}" lang:${t.lang} group:${n}`),this.clearTimer(),this.hls.trigger(_.AUDIO_TRACK_LOADING,{url:a,id:i,groupId:n,deliveryDirectives:e||null})}}}function Ad(s,e){if(s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(!LA(s[t].attrs,e[t].attrs))return!1;return!0}function LA(s,e){const t=s["STABLE-RENDITION-ID"];return t?t===e["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>s[i]!==e[i])}const Ed=500;class CA extends Nc{constructor(e,t,i){super(e,t,i,"[subtitle-stream-controller]",tt.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.ERROR,this.onError,this),e.on(_.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(_.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(_.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(_.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.ERROR,this.onError,this),e.off(_.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(_.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(_.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(_.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=Se.IDLE,this.setInterval(Ed),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:i,success:n}=t;if(this.fragPrevious=i,this.state=Se.IDLE,!n)return;const a=this.tracksBuffered[this.currentTrackId];if(!a)return;let l;const h=i.start;for(let p=0;p<a.length;p++)if(h>=a[p].start&&h<=a[p].end){l=a[p];break}const d=i.start+i.duration;l?l.end=d:(l={start:h,end:d},a.push(l)),this.fragmentTracker.fragBuffered(i)}onBufferFlushing(e,t){const{startOffset:i,endOffset:n}=t;if(i===0&&n!==Number.POSITIVE_INFINITY){const a=n-1;if(a<=0)return;t.endOffsetSubtitles=Math.max(0,a),this.tracksBuffered.forEach(l=>{for(let h=0;h<l.length;){if(l[h].end<=a){l.shift();continue}else if(l[h].start<a)l[h].start=a;else break;h++}}),this.fragmentTracker.removeFragmentsInRange(i,a,tt.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===tt.MAIN){var i;(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){const i=t.frag;(i==null?void 0:i.type)===tt.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Se.STOPPED&&(this.state=Se.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(Ad(this.levels,t)){this.levels=t.map(i=>new wo(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{const n=new wo(i);return this.tracksBuffered[n.id]=[],n}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,tt.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){if(this.currentTrackId=t.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(Ed)}onSubtitleTrackLoaded(e,t){var i;const{details:n,id:a}=t,{currentTrackId:l,levels:h}=this;if(!h.length)return;const d=h[l];if(a>=h.length||a!==l||!d)return;this.mediaBuffer=this.mediaBufferTimeRanges;let p=0;if(n.live||(i=d.details)!=null&&i.live){const m=this.mainDetails;if(n.deltaUpdateFailed||!m)return;const g=m.fragments[0];d.details?(p=this.alignPlaylists(n,d.details),p===0&&g&&(p=g.start,Cc(n,p))):n.hasProgramDateTime&&m.hasProgramDateTime?(Xf(n,m),p=n.fragments[0].start):g&&(p=g.start,Cc(n,p))}d.details=n,this.levelLastLoaded=a,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(d.details,p),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===Se.IDLE&&(_o(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),d.details=void 0))}_handleFragmentLoadComplete(e){const{frag:t,payload:i}=e,n=t.decryptdata,a=this.hls;if(!this.fragContextChanged(t)&&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(h=>{throw a.trigger(_.ERROR,{type:et.MEDIA_ERROR,details:de.FRAG_DECRYPT_ERROR,fatal:!1,error:h,reason:h.message,frag:t}),h}).then(h=>{const d=performance.now();a.trigger(_.FRAG_DECRYPTED,{frag:t,payload:h,stats:{tstart:l,tdecrypt:d}})}).catch(h=>{this.warn(`${h.name}: ${h.message}`),this.state=Se.IDLE})}}doTick(){if(!this.media){this.state=Se.IDLE;return}if(this.state===Se.IDLE){const{currentTrackId:e,levels:t}=this,i=t[e];if(!t.length||!i||!i.details)return;const{config:n}=this,a=this.getLoadPosition(),l=Nt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a,n.maxBufferHole),{end:h,len:d}=l,p=this.getFwdBufferInfo(this.media,tt.MAIN),m=i.details,g=this.getMaxBufferLength(p==null?void 0:p.len)+m.levelTargetDuration;if(d>g)return;const A=m.fragments,x=A.length,b=m.edge;let S=null;const w=this.fragPrevious;if(h<b){const P=n.maxFragLookUpTolerance,$=h>b-P?0:P;S=_o(w,A,Math.max(A[0].start,h),$),!S&&w&&w.start<A[0].start&&(S=A[0])}else S=A[x-1];if(!S)return;if(S=this.mapToInitFragWhenRequired(S),S.sn!=="initSegment"){const P=S.sn-m.startSN,$=A[P-1];$&&$.cc===S.cc&&this.fragmentTracker.getState($)===di.NOT_LOADED&&(S=$)}this.fragmentTracker.getState(S)===di.NOT_LOADED&&this.loadFragment(S,i,h)}}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,i){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,i))}get mediaBufferTimeRanges(){return new IA(this.tracksBuffered[this.currentTrackId]||[])}}class IA{constructor(e){this.buffered=void 0;const t=(i,n,a)=>{if(n=n>>>0,n>a-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${a})`);return e[n][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}}}}class DA extends Oc{constructor(e){super(e,"[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(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:e}=this;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(_.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(_.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.LEVEL_LOADING,this.onLevelLoading,this),e.off(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(_.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(_.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Zc(this.media.textTracks).forEach(t=>{Sn(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:i,details:n}=t,{trackId:a}=this,l=this.tracksInGroup[a];if(!l){this.warn(`Invalid subtitle track id ${i}`);return}const h=l.details;l.details=t.details,this.log(`subtitle track ${i} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,h)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!(t!=null&&t.textGroupIds))return;const i=t.textGroupIds[t.urlId],n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){const a=this.tracks.filter(d=>!i||d.groupId===i);this.tracksInGroup=a;const l=this.findTrackId(n==null?void 0:n.name)||this.findTrackId();this.groupId=i||null;const h={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${i}" group-id`),this.hls.trigger(_.SUBTITLE_TRACKS_UPDATED,h),l!==-1&&this.setSubtitleTrack(l,n)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId,n)}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const n=t[i];if((!this.selectDefaultTrack||n.default)&&(!e||e===n.name))return n.id}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Tt.SUBTITLE_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.checkRetry(t)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1;const t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}loadPlaylist(e){super.loadPlaylist();const t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){const i=t.id,n=t.groupId;let a=t.url;if(e)try{a=e.addDirectives(a)}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(_.SUBTITLE_TRACK_LOADING,{url:a,id:i,groupId:n,deliveryDirectives:e||null})}}toggleTrackModes(e){const{media:t,trackId:i}=this;if(!t)return;const n=Zc(t.textTracks),a=n.filter(h=>h.groupId===this.groupId);if(e===-1)[].slice.call(n).forEach(h=>{h.mode="disabled"});else{const h=a[i];h&&(h.mode="disabled")}const l=a[e];l&&(l.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,t){var i;const n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(e===-1||(i=n[e])!=null&&i.details)||e<-1||e>=n.length)return;this.clearTimer();const a=n[e];if(this.log(`Switching to subtitle-track ${e}`+(a?` "${a.name}" lang:${a.lang} group:${a.groupId}`:"")),this.trackId=e,a){const{id:l,groupId:h="",name:d,type:p,url:m}=a;this.hls.trigger(_.SUBTITLE_TRACK_SWITCH,{id:l,groupId:h,name:d,type:p,url:m});const g=this.switchParams(a.url,t==null?void 0:t.details);this.loadPlaylist(g)}else this.hls.trigger(_.SUBTITLE_TRACK_SWITCH,{id:e})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=-1;const t=Zc(this.media.textTracks);for(let i=0;i<t.length;i++)if(t[i].mode==="hidden")e=i;else if(t[i].mode==="showing"){e=i;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}}function Zc(s){const e=[];for(let t=0;t<s.length;t++){const i=s[t];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&e.push(s[t])}return e}class OA{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t){const i=this.queues[t];i.push(e),i.length===1&&this.buffers[t]&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t;const i=new Promise(a=>{t=a}),n={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(n,e),i}executeNext(e){const{buffers:t,queues:i}=this,n=t[e],a=i[e];if(a.length){const l=a[0];try{l.execute()}catch(h){q.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),l.onError(h),n!=null&&n.updating||(a.shift(),this.executeNext(e))}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const xd=Fa(),bd=/([ha]vc.)(?:\.[^.,]+)+/;class PA{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{const{media:t,mediaSource:i}=this;q.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(_.MEDIA_ATTACHED,{media:t})),i&&i.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{q.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{q.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:t,_objectUrl:i}=this;t&&t.src!==i&&q.error(`Media element src was set while attaching MediaSource (${i} > ${t.src})`)},this.hls=e,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:e}=this;e.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.BUFFER_RESET,this.onBufferReset,this),e.on(_.BUFFER_APPENDING,this.onBufferAppending,this),e.on(_.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.BUFFER_EOS,this.onBufferEos,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(_.FRAG_PARSED,this.onFragParsed,this),e.on(_.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.BUFFER_RESET,this.onBufferReset,this),e.off(_.BUFFER_APPENDING,this.onBufferAppending,this),e.off(_.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.BUFFER_EOS,this.onBufferEos,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(_.FRAG_PARSED,this.onFragParsed,this),e.off(_.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new OA(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,q.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){const i=this.media=t.media;if(i&&xd){const n=this.mediaSource=new xd;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:e,mediaSource:t,_objectUrl:i}=this;if(t){if(q.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(n){q.warn(`[buffer-controller]: onMediaDetaching: ${n.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),i&&self.URL.revokeObjectURL(i),e.src===i?(e.removeAttribute("src"),e.load()):q.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(_.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{const t=this.sourceBuffer[e];try{t&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(t),this.sourceBuffer[e]=void 0)}catch(i){q.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,i)}}),this._initSourceBuffer()}onBufferCodecs(e,t){const i=this.getSourceBufferTypes().length;Object.keys(t).forEach(n=>{if(i){const a=this.tracks[n];if(a&&typeof a.buffer.changeType=="function"){const{id:l,codec:h,levelCodec:d,container:p,metadata:m}=t[n],g=(a.levelCodec||a.codec).replace(bd,"$1"),A=(d||h).replace(bd,"$1");if(g!==A){const x=`${p};codecs=${d||h}`;this.appendChangeType(n,x),q.log(`[buffer-controller]: switching codec ${g} to ${A}`),this.tracks[n]={buffer:a.buffer,codec:h,container:p,levelCodec:d,metadata:m,id:l}}}}else this.pendingTracks[n]=t[n]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(e,t){const{operationQueue:i}=this,n={execute:()=>{const a=this.sourceBuffer[e];a&&(q.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${t}`),a.changeType(t)),i.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:a=>{q.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,a)}};i.append(n,e)}onBufferAppending(e,t){const{hls:i,operationQueue:n,tracks:a}=this,{data:l,type:h,frag:d,part:p,chunkMeta:m}=t,g=m.buffering[h],A=self.performance.now();g.start=A;const x=d.stats.buffering,b=p?p.stats.buffering:null;x.start===0&&(x.start=A),b&&b.start===0&&(b.start=A);const S=a.audio;let w=!1;h==="audio"&&(S==null?void 0:S.container)==="audio/mpeg"&&(w=!this.lastMpegAudioChunk||m.id===1||this.lastMpegAudioChunk.sn!==m.sn,this.lastMpegAudioChunk=m);const P=d.start,$={execute:()=>{if(g.executeStart=self.performance.now(),w){const N=this.sourceBuffer[h];if(N){const I=P-N.timestampOffset;Math.abs(I)>=.1&&(q.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${P} (delta: ${I}) sn: ${d.sn})`),N.timestampOffset=P)}}this.appendExecutor(l,h)},onStart:()=>{},onComplete:()=>{const N=self.performance.now();g.executeEnd=g.end=N,x.first===0&&(x.first=N),b&&b.first===0&&(b.first=N);const{sourceBuffer:I}=this,O={};for(const K in I)O[K]=Nt.getBuffered(I[K]);this.appendError=0,this.hls.trigger(_.BUFFER_APPENDED,{type:h,frag:d,part:p,chunkMeta:m,parent:d.type,timeRanges:O})},onError:N=>{q.error(`[buffer-controller]: Error encountered while trying to append to the ${h} SourceBuffer`,N);const I={type:et.MEDIA_ERROR,parent:d.type,details:de.BUFFER_APPEND_ERROR,frag:d,part:p,chunkMeta:m,error:N,err:N,fatal:!1};N.code===DOMException.QUOTA_EXCEEDED_ERR?I.details=de.BUFFER_FULL_ERROR:(this.appendError++,I.details=de.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(q.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),I.fatal=!0)),i.trigger(_.ERROR,I)}};n.append($,h)}onBufferFlushing(e,t){const{operationQueue:i}=this,n=a=>({execute:this.removeExecutor.bind(this,a,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(_.BUFFER_FLUSHED,{type:a})},onError:l=>{q.warn(`[buffer-controller]: Failed to remove from ${a} SourceBuffer`,l)}});t.type?i.append(n(t.type),t.type):this.getSourceBufferTypes().forEach(a=>{i.append(n(a),a)})}onFragParsed(e,t){const{frag:i,part:n}=t,a=[],l=n?n.elementaryStreams:i.elementaryStreams;l[Ct.AUDIOVIDEO]?a.push("audiovideo"):(l[Ct.AUDIO]&&a.push("audio"),l[Ct.VIDEO]&&a.push("video"));const h=()=>{const d=self.performance.now();i.stats.buffering.end=d,n&&(n.stats.buffering.end=d);const p=n?n.stats:i.stats;this.hls.trigger(_.FRAG_BUFFERED,{frag:i,part:n,stats:p,id:i.type})};a.length===0&&q.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(h,a)}onFragChanged(e,t){this.flushBackBuffer()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((n,a)=>{const l=this.sourceBuffer[a];return l&&(!t.type||t.type===a)&&(l.ending=!0,l.ended||(l.ended=!0,q.log(`[buffer-controller]: ${a} sourceBuffer now EOS`))),n&&!!(!l||l.ended)},!0)&&(q.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(a=>{const l=this.sourceBuffer[a];l&&(l.ending=!1)});const{mediaSource:n}=this;if(!n||n.readyState!=="open"){n&&q.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${n.readyState}`);return}q.log("[buffer-controller]: Calling mediaSource.endOfStream()"),n.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:e,details:t,media:i,sourceBuffer:n}=this;if(!i||t===null)return;const a=this.getSourceBufferTypes();if(!a.length)return;const l=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!ze(l)||l<0)return;const h=i.currentTime,d=t.levelTargetDuration,p=Math.max(l,d),m=Math.floor(h/d)*d-p;a.forEach(g=>{const A=n[g];if(A){const x=Nt.getBuffered(A);if(x.length>0&&m>x.start(0)){if(e.trigger(_.BACK_BUFFER_REACHED,{bufferEnd:m}),t.live)e.trigger(_.LIVE_BACK_BUFFER_REACHED,{bufferEnd:m});else if(A.ended&&x.end(x.length-1)-h<d*2){q.info(`[buffer-controller]: Cannot flush ${g} back buffer while SourceBuffer is in ended state`);return}e.trigger(_.BUFFER_FLUSHING,{startOffset:0,endOffset:m,type:g})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:e,hls:t,media:i,mediaSource:n}=this,a=e.fragments[0].start+e.totalduration,l=i.duration,h=ze(n.duration)?n.duration:0;e.live&&t.config.liveDurationInfinity?(q.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(a>h&&a>l||!ze(l))&&(q.log(`[buffer-controller]: Updating Media Source duration to ${a.toFixed(3)}`),n.duration=a)}updateSeekableRange(e){const t=this.mediaSource,i=e.fragments;if(i.length&&e.live&&t!=null&&t.setLiveSeekableRange){const a=Math.max(0,i[0].start),l=Math.max(a,a+e.totalduration);t.setLiveSeekableRange(a,l)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:i}=this,n=Object.keys(i).length;if(n&&!e||n===2){this.createSourceBuffers(i),this.pendingTracks={};const a=this.getSourceBufferTypes();if(a.length)this.hls.trigger(_.BUFFER_CREATED,{tracks:this.tracks}),a.forEach(l=>{t.executeNext(l)});else{const l=new Error("could not create source buffer for media codec(s)");this.hls.trigger(_.ERROR,{type:et.MEDIA_ERROR,details:de.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:l,reason:l.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const n in e)if(!t[n]){const a=e[n];if(!a)throw Error(`source buffer exists for track ${n}, however track does not`);const l=a.levelCodec||a.codec,h=`${a.container};codecs=${l}`;q.log(`[buffer-controller]: creating sourceBuffer(${h})`);try{const d=t[n]=i.addSourceBuffer(h),p=n;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[n]={buffer:d,codec:l,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(d){q.error(`[buffer-controller]: error while trying to add sourceBuffer: ${d.message}`),this.hls.trigger(_.ERROR,{type:et.MEDIA_ERROR,details:de.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,mimeType:h})}}}_onSBUpdateStart(e){const{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){const{operationQueue:t}=this;t.current(e).onComplete(),t.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){const i=new Error(`${e} SourceBuffer error`);q.error(`[buffer-controller]: ${i}`,t),this.hls.trigger(_.ERROR,{type:et.MEDIA_ERROR,details:de.BUFFER_APPENDING_ERROR,error:i,fatal:!1});const n=this.operationQueue.current(e);n&&n.onError(t)}removeExecutor(e,t,i){const{media:n,mediaSource:a,operationQueue:l,sourceBuffer:h}=this,d=h[e];if(!n||!a||!d){q.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),l.shiftAndExecuteNext(e);return}const p=ze(n.duration)?n.duration:1/0,m=ze(a.duration)?a.duration:1/0,g=Math.max(0,t),A=Math.min(i,p,m);A>g&&!d.ending?(d.ended=!1,q.log(`[buffer-controller]: Removing [${g},${A}] from the ${e} SourceBuffer`),d.remove(g,A)):l.shiftAndExecuteNext(e)}appendExecutor(e,t){const{operationQueue:i,sourceBuffer:n}=this,a=n[t];if(!a){q.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),i.shiftAndExecuteNext(t);return}a.ended=!1,a.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){q.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}const{operationQueue:i}=this,n=t.map(a=>i.appendBlocker(a));Promise.all(n).then(()=>{e(),t.forEach(a=>{const l=this.sourceBuffer[a];l!=null&&l.updating||i.shiftAndExecuteNext(a)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,i){const n=this.sourceBuffer[e];if(!n)return;const a=i.bind(this,e);this.listeners[e].push({event:t,listener:a}),n.addEventListener(t,a)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(i=>{t.removeEventListener(i.event,i.listener)})}}const Td={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},Sd=function(e){let t=e;return Td.hasOwnProperty(e)&&(t=Td[e]),String.fromCharCode(t)},br=15,ts=100,$A={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},MA={17:2,18:4,21:6,22:8,23:10,19:13,20:15},FA={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},NA={25:2,26:4,29:6,30:8,31:10,27:13,28:15},UA=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class BA{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const i=typeof t=="function"?t():t;q.log(`${this.time} [${e}] ${i}`)}}}const an=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class kd{constructor(e,t,i,n,a){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=i||!1,this.background=n||"black",this.flash=a||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let i=0;i<t.length;i++){const n=t[i];e.hasOwnProperty(n)&&(this[n]=e[n])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class GA{constructor(e,t,i,n,a,l){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new kd(t,i,n,a,l)}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class VA{constructor(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let t=0;t<ts;t++)this.chars.push(new GA);this.logger=e,this.pos=0,this.currPenState=new kd}equals(e){let t=!0;for(let i=0;i<ts;i++)if(!this.chars[i].equals(e.chars[i])){t=!1;break}return t}copy(e){for(let t=0;t<ts;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<ts;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>ts&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ts)}moveCursor(e){const t=this.pos+e;if(e>1)for(let i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=Sd(e);if(this.pos>=ts){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<ts;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let i=0;i<ts;i++){const n=this.chars[i].uchar;n!==" "&&(t=!1),e.push(n)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class qc{constructor(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let t=0;t<br;t++)this.rows.push(new VA(e));this.logger=e,this.currRow=br-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let e=0;e<br;e++)this.rows[e].clear();this.currRow=br-1}equals(e){let t=!0;for(let i=0;i<br;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<br;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<br;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let h=0;h<br;h++)this.rows[h].clear();const a=this.currRow+1-this.nrRollUpRows,l=this.lastOutputScreen;if(l){const h=l.rows[a].cueStartTime,d=this.logger.time;if(h&&d!==null&&h<d)for(let p=0;p<this.nrRollUpRows;p++)this.rows[t-this.nrRollUpRows+p+1].copy(l.rows[a+p])}}this.currRow=t;const i=this.rows[this.currRow];if(e.indent!==null){const a=e.indent,l=Math.max(a-1,0);i.setCursor(e.indent),e.color=i.chars[l].penState.foreground}const n={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(n)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let i="",n=-1;for(let a=0;a<br;a++){const l=this.rows[a].getTextString();l&&(n=a+1,e?t.push("Row "+n+": '"+l+"'"):t.push(l.trim()))}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(`
|
193
|
+
`)),i}getTextAndFormat(){return this.rows}}class wd{constructor(e,t,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new qc(i),this.nonDisplayedMemory=new qc(i),this.lastOutputScreen=new qc(i),this.currRollUpRow=this.displayedMemory.rows[br-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[br-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+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(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!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 e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const i=Math.floor(e/2)-16,n=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=n[i]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class _d{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const n=new BA;this.channels=[null,new wd(e,t,n),new wd(e+1,i,n)],this.cmdHistory=Ld(),this.logger=n}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let i,n,a,l=!1;this.logger.time=e;for(let h=0;h<t.length;h+=2)if(n=t[h]&127,a=t[h+1]&127,!(n===0&&a===0)){if(this.logger.log(3,"["+an([t[h],t[h+1]])+"] -> ("+an([n,a])+")"),i=this.parseCmd(n,a),i||(i=this.parseMidrow(n,a)),i||(i=this.parsePAC(n,a)),i||(i=this.parseBackgroundAttributes(n,a)),!i&&(l=this.parseChars(n,a),l)){const d=this.currentChannel;d&&d>0?this.channels[d].insertChars(l):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!i&&!l&&this.logger.log(2,"Couldn't parse cleaned data "+an([n,a])+" orig: "+an([t[h],t[h+1]]))}}parseCmd(e,t){const{cmdHistory:i}=this,n=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,a=(e===23||e===31)&&t>=33&&t<=35;if(!(n||a))return!1;if(Rd(e,t,i))return Rn(null,null,i),this.logger.log(3,"Repeated command ("+an([e,t])+") is dropped"),!0;const l=e===20||e===21||e===23?1:2,h=this.channels[l];return e===20||e===21||e===28||e===29?t===32?h.ccRCL():t===33?h.ccBS():t===34?h.ccAOF():t===35?h.ccAON():t===36?h.ccDER():t===37?h.ccRU(2):t===38?h.ccRU(3):t===39?h.ccRU(4):t===40?h.ccFON():t===41?h.ccRDC():t===42?h.ccTR():t===43?h.ccRTD():t===44?h.ccEDM():t===45?h.ccCR():t===46?h.ccENM():t===47&&h.ccEOC():h.ccTO(t-32),Rn(e,t,i),this.currentChannel=l,!0}parseMidrow(e,t){let i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const n=this.channels[i];return n?(n.ccMIDROW(t),this.logger.log(3,"MIDROW ("+an([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let i;const n=this.cmdHistory,a=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,l=(e===16||e===24)&&t>=64&&t<=95;if(!(a||l))return!1;if(Rd(e,t,n))return Rn(null,null,n),!0;const h=e<=23?1:2;t>=64&&t<=95?i=h===1?$A[e]:FA[e]:i=h===1?MA[e]:NA[e];const d=this.channels[h];return d?(d.setPAC(this.interpretPAC(i,t)),Rn(e,t,n),this.currentChannel=h,!0):!1}interpretPAC(e,t){let i;const n={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?i=t-96:i=t-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(e,t){let i,n=null,a=null;if(e>=25?(i=2,a=e-8):(i=1,a=e),a>=17&&a<=19){let l;a===17?l=t+80:a===18?l=t+112:l=t+144,this.logger.log(2,"Special char '"+Sd(l)+"' in channel "+i),n=[l]}else e>=32&&e<=127&&(n=t===0?[e]:[e,t]);if(n){const l=an(n);this.logger.log(3,"Char codes = "+l.join(",")),Rn(e,t,this.cmdHistory)}return n}parseBackgroundAttributes(e,t){const i=(e===16||e===24)&&t>=32&&t<=47,n=(e===23||e===31)&&t>=45&&t<=47;if(!(i||n))return!1;let a;const l={};e===16||e===24?(a=Math.floor((t-32)/2),l.background=UA[a],t%2===1&&(l.background=l.background+"_semi")):t===45?l.background="transparent":(l.foreground="black",t===47&&(l.underline=!0));const h=e<=23?1:2;return this.channels[h].setBkgData(l),Rn(e,t,this.cmdHistory),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}this.cmdHistory=Ld()}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const i=this.channels[t];i&&i.cueSplitAtTime(e)}}}function Rn(s,e,t){t.a=s,t.b=e}function Rd(s,e,t){return t.a===s&&t.b===e}function Ld(){return{a:null,b:null}}class Xa{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Qc=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const s=["","lr","rl"],e=["start","middle","end","left","right"];function t(h,d){if(typeof d!="string"||!Array.isArray(h))return!1;const p=d.toLowerCase();return~h.indexOf(p)?p:!1}function i(h){return t(s,h)}function n(h){return t(e,h)}function a(h,...d){let p=1;for(;p<arguments.length;p++){const m=arguments[p];for(const g in m)h[g]=m[g]}return h}function l(h,d,p){const m=this,g={enumerable:!0};m.hasBeenReset=!1;let A="",x=!1,b=h,S=d,w=p,P=null,$="",N=!0,I="auto",O="start",K=50,U="middle",re=50,ne="middle";Object.defineProperty(m,"id",a({},g,{get:function(){return A},set:function(Y){A=""+Y}})),Object.defineProperty(m,"pauseOnExit",a({},g,{get:function(){return x},set:function(Y){x=!!Y}})),Object.defineProperty(m,"startTime",a({},g,{get:function(){return b},set:function(Y){if(typeof Y!="number")throw new TypeError("Start time must be set to a number.");b=Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"endTime",a({},g,{get:function(){return S},set:function(Y){if(typeof Y!="number")throw new TypeError("End time must be set to a number.");S=Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"text",a({},g,{get:function(){return w},set:function(Y){w=""+Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"region",a({},g,{get:function(){return P},set:function(Y){P=Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"vertical",a({},g,{get:function(){return $},set:function(Y){const Ee=i(Y);if(Ee===!1)throw new SyntaxError("An invalid or illegal string was specified.");$=Ee,this.hasBeenReset=!0}})),Object.defineProperty(m,"snapToLines",a({},g,{get:function(){return N},set:function(Y){N=!!Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"line",a({},g,{get:function(){return I},set:function(Y){if(typeof Y!="number"&&Y!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");I=Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"lineAlign",a({},g,{get:function(){return O},set:function(Y){const Ee=n(Y);if(!Ee)throw new SyntaxError("An invalid or illegal string was specified.");O=Ee,this.hasBeenReset=!0}})),Object.defineProperty(m,"position",a({},g,{get:function(){return K},set:function(Y){if(Y<0||Y>100)throw new Error("Position must be between 0 and 100.");K=Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"positionAlign",a({},g,{get:function(){return U},set:function(Y){const Ee=n(Y);if(!Ee)throw new SyntaxError("An invalid or illegal string was specified.");U=Ee,this.hasBeenReset=!0}})),Object.defineProperty(m,"size",a({},g,{get:function(){return re},set:function(Y){if(Y<0||Y>100)throw new Error("Size must be between 0 and 100.");re=Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"align",a({},g,{get:function(){return ne},set:function(Y){const Ee=n(Y);if(!Ee)throw new SyntaxError("An invalid or illegal string was specified.");ne=Ee,this.hasBeenReset=!0}})),m.displayState=void 0}return l.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},l}();class HA{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function Cd(s){function e(i,n,a,l){return(i|0)*3600+(n|0)*60+(a|0)+parseFloat(l||0)}const t=s.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}class WA{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let n=0;n<i.length;++n)if(t===i[n]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function Id(s,e,t,i){const n=i?s.split(i):[s];for(const a in n){if(typeof n[a]!="string")continue;const l=n[a].split(t);if(l.length!==2)continue;const h=l[0],d=l[1];e(h,d)}}const Jc=new Qc(0,0,""),Za=Jc.align==="middle"?"middle":"center";function jA(s,e,t){const i=s;function n(){const h=Cd(s);if(h===null)throw new Error("Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),h}function a(h,d){const p=new WA;Id(h,function(A,x){let b;switch(A){case"region":for(let S=t.length-1;S>=0;S--)if(t[S].id===x){p.set(A,t[S].region);break}break;case"vertical":p.alt(A,x,["rl","lr"]);break;case"line":b=x.split(","),p.integer(A,b[0]),p.percent(A,b[0])&&p.set("snapToLines",!1),p.alt(A,b[0],["auto"]),b.length===2&&p.alt("lineAlign",b[1],["start",Za,"end"]);break;case"position":b=x.split(","),p.percent(A,b[0]),b.length===2&&p.alt("positionAlign",b[1],["start",Za,"end","line-left","line-right","auto"]);break;case"size":p.percent(A,x);break;case"align":p.alt(A,x,["start",Za,"end","left","right"]);break}},/:/,/\s/),d.region=p.get("region",null),d.vertical=p.get("vertical","");let m=p.get("line","auto");m==="auto"&&Jc.line===-1&&(m=-1),d.line=m,d.lineAlign=p.get("lineAlign","start"),d.snapToLines=p.get("snapToLines",!0),d.size=p.get("size",100),d.align=p.get("align",Za);let g=p.get("position","auto");g==="auto"&&Jc.position===50&&(g=d.align==="start"||d.align==="left"?0:d.align==="end"||d.align==="right"?100:50),d.position=g}function l(){s=s.replace(/^\s+/,"")}if(l(),e.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(),e.endTime=n(),l(),a(s,e)}function Dd(s){return s.replace(/<br(?: \/)?>/gi,`
|
194
|
+
`)}class KA{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new HA,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function i(){let a=t.buffer,l=0;for(a=Dd(a);l<a.length&&a[l]!=="\r"&&a[l]!==`
|
195
|
+
`;)++l;const h=a.slice(0,l);return a[l]==="\r"&&++l,a[l]===`
|
196
|
+
`&&++l,t.buffer=a.slice(l),h}function n(a){Id(a,function(l,h){},/:/)}try{let a="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;a=i();const h=a.match(/^()?WEBVTT([ \t].*)?$/);if(!(h!=null&&h[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let l=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(l?l=!1:a=i(),t.state){case"HEADER":/:/.test(a)?n(a):a||(t.state="ID");continue;case"NOTE":a||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){t.state="NOTE";break}if(!a)continue;if(t.cue=new Qc(0,0,""),t.state="CUE",a.indexOf("-->")===-1){t.cue.id=a;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{jA(a,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const h=a.indexOf("-->")!==-1;if(!a||h&&(l=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
|
197
|
+
`),t.cue.text+=a}continue;case"BADCUE":a||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
|
198
|
+
|
199
|
+
`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const zA=/\r\n|\n\r|\n|\r/g,eu=function(e,t,i=0){return e.slice(i,i+t.length)===t},YA=function(e){let t=parseInt(e.slice(-3));const i=parseInt(e.slice(-6,-4)),n=parseInt(e.slice(-9,-7)),a=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!ze(t)||!ze(i)||!ze(n)||!ze(a))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*n,t+=60*60*1e3*a,t},tu=function(e){let t=5381,i=e.length;for(;i;)t=t*33^e.charCodeAt(--i);return(t>>>0).toString()};function iu(s,e,t){return tu(s.toString())+tu(e.toString())+tu(t)}const XA=function(e,t,i){let n=e[t],a=e[n.prevCC];if(!a||!a.new&&n.new){e.ccOffset=e.presentationOffset=n.start,n.new=!1;return}for(;(l=a)!=null&&l.new;){var l;e.ccOffset+=n.start-a.start,n.new=!1,n=a,a=e[n.prevCC]}e.presentationOffset=i};function ZA(s,e,t,i,n,a,l){const h=new KA,d=Ir(new Uint8Array(s)).trim().replace(zA,`
|
200
|
+
`).split(`
|
201
|
+
`),p=[],m=e?aA(e.baseTime,e.timescale):0;let g="00:00.000",A=0,x=0,b,S=!0;h.oncue=function(w){const P=t[i];let $=t.ccOffset;const N=(A-m)/9e4;if(P!=null&&P.new&&(x!==void 0?$=t.ccOffset=P.start:XA(t,i,N)),N){if(!e){b=new Error("Missing initPTS for VTT MPEGTS");return}$=N-t.presentationOffset}const I=w.endTime-w.startTime,O=cr((w.startTime+$-x)*9e4,n*9e4)/9e4;w.startTime=Math.max(O,0),w.endTime=Math.max(O+I,0);const K=w.text.trim();w.text=decodeURIComponent(encodeURIComponent(K)),w.id||(w.id=iu(w.startTime,w.endTime,K)),w.endTime>0&&p.push(w)},h.onparsingerror=function(w){b=w},h.onflush=function(){if(b){l(b);return}a(p)},d.forEach(w=>{if(S)if(eu(w,"X-TIMESTAMP-MAP=")){S=!1,w.slice(16).split(",").forEach(P=>{eu(P,"LOCAL:")?g=P.slice(6):eu(P,"MPEGTS:")&&(A=parseInt(P.slice(7)))});try{x=YA(g)/1e3}catch(P){b=P}return}else w===""&&(S=!1);h.parse(w+`
|
202
|
+
`)}),h.flush()}const ru="stpp.ttml.im1t",Od=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Pd=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,qA={left:"start",center:"center",right:"end",start:"start",end:"end"};function $d(s,e,t,i){const n=xt(new Uint8Array(s),["mdat"]);if(n.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const a=n.map(h=>Ir(h)),l=oA(e.baseTime,1,e.timescale);try{a.forEach(h=>t(QA(h,l)))}catch(h){i(h)}}function QA(s,e){const n=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");const a={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},l=Object.keys(a).reduce((g,A)=>(g[A]=n.getAttribute(`ttp:${A}`)||a[A],g),{}),h=n.getAttribute("xml:space")!=="preserve",d=Md(su(n,"styling","style")),p=Md(su(n,"layout","region")),m=su(n,"body","[begin]");return[].map.call(m,g=>{const A=Fd(g,h);if(!A||!g.hasAttribute("begin"))return null;const x=ou(g.getAttribute("begin"),l),b=ou(g.getAttribute("dur"),l);let S=ou(g.getAttribute("end"),l);if(x===null)throw Nd(g);if(S===null){if(b===null)throw Nd(g);S=x+b}const w=new Qc(x-e,S-e,A);w.id=iu(w.startTime,w.endTime,w.text);const P=p[g.getAttribute("region")],$=d[g.getAttribute("style")],N=JA(P,$,d),{textAlign:I}=N;if(I){const O=qA[I];O&&(w.lineAlign=O),w.align=I}return ai(w,N),w}).filter(g=>g!==null)}function su(s,e,t){const i=s.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function Md(s){return s.reduce((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function Fd(s,e){return[].slice.call(s.childNodes).reduce((t,i,n)=>{var a;return i.nodeName==="br"&&n?t+`
|
203
|
+
`:(a=i.childNodes)!=null&&a.length?Fd(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function JA(s,e,t){const i="http://www.w3.org/ns/ttml#styling";let n=null;const a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],l=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return l&&t.hasOwnProperty(l)&&(n=t[l]),a.reduce((h,d)=>{const p=nu(e,i,d)||nu(s,i,d)||nu(n,i,d);return p&&(h[d]=p),h},{})}function nu(s,e,t){return s&&s.hasAttributeNS(e,t)?s.getAttributeNS(e,t):null}function Nd(s){return new Error(`Could not parse ttml timestamp ${s}`)}function ou(s,e){if(!s)return null;let t=Cd(s);return t===null&&(Od.test(s)?t=eE(s,e):Pd.test(s)&&(t=tE(s,e))),t}function eE(s,e){const t=Od.exec(s),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function tE(s,e){const t=Pd.exec(s),i=Number(t[1]);switch(t[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}class iE{constructor(e){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=Ud(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){const t=new Xa(this,"textTrack1"),i=new Xa(this,"textTrack2"),n=new Xa(this,"textTrack3"),a=new Xa(this,"textTrack4");this.cea608Parser1=new _d(1,t,i),this.cea608Parser2=new _d(3,n,a)}e.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(_.FRAG_LOADING,this.onFragLoading,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this),e.on(_.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(_.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(_.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(_.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(_.FRAG_LOADING,this.onFragLoading,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this),e.off(_.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(_.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(_.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(_.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,t,i,n,a){let l=!1;for(let h=a.length;h--;){const d=a[h],p=sE(d[0],d[1],t,i);if(p>=0&&(d[0]=Math.min(d[0],t),d[1]=Math.max(d[1],i),l=!0,p/(i-t)>.5))return}if(l||a.push([t,i]),this.config.renderTextTracksNatively){const h=this.captionsTracks[e];this.Cues.newCue(h,t,i,n)}else{const h=this.Cues.newCue(null,t,i,n);this.hls.trigger(_.CUES_PARSED,{type:"captions",cues:h,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:n,timescale:a}){const{unparsedVttFrags:l}=this;i==="main"&&(this.initPTS[t.cc]={baseTime:n,timescale:a}),l.length&&(this.unparsedVttFrags=[],l.forEach(h=>{this.onFragLoaded(_.FRAG_LOADED,h)}))}getExistingTrack(e){const{media:t}=this;if(t)for(let i=0;i<t.textTracks.length;i++){const n=t.textTracks[i];if(n[e])return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:i,media:n}=this,{label:a,languageCode:l}=t[e],h=this.getExistingTrack(e);if(h)i[e]=h,Sn(i[e]),Of(i[e],n);else{const d=this.createTextTrack("captions",a,l);d&&(d[e]=!0,i[e]=d)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const i=t.label,n={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=n,this.hls.trigger(_.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}createTextTrack(e,t,i){const n=this.media;if(n)return n.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach(t=>{Sn(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Ud(),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:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let i=0;i<t.length;i++)Sn(t[i])}onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[],n=i.some(a=>a.textCodec===ru);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(Ad(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const l=this.media?this.media.textTracks:null;this.tracks.forEach((h,d)=>{let p;if(l&&d<l.length){let m=null;for(let g=0;g<l.length;g++)if(rE(l[g],h)){m=l[g];break}m&&(p=m)}if(p)Sn(p);else{const m=this._captionsOrSubtitlesFromCharacteristics(h);p=this.createTextTrack(m,h.name,h.lang),p&&(p.mode="disabled")}p&&(p.groupId=h.groupId,this.textTracks.push(p))})}else if(this.tracks.length){const l=this.tracks.map(h=>({label:h.name,kind:h.type.toLowerCase(),default:h.default,subtitleTrack:h}));this.hls.trigger(_.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){const t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&i)return"captions"}return"subtitles"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{const n=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!n)return;const a=`textTrack${n[1]}`,l=this.captionsProperties[a];l&&(l.label=i.name,i.lang&&(l.languageCode=i.lang),l.media=i)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){const{cea608Parser1:i,cea608Parser2:n,lastSn:a,lastPartIndex:l}=this;if(!(!this.enabled||!(i&&n))&&t.frag.type===tt.MAIN){var h,d;const p=t.frag.sn,m=(h=t==null||(d=t.part)==null?void 0:d.index)!=null?h:-1;p===a+1||p===a&&m===l+1||(i.reset(),n.reset()),this.lastSn=p,this.lastPartIndex=m}}onFragLoaded(e,t){const{frag:i,payload:n}=t;if(i.type===tt.SUBTITLE)if(n.byteLength){const a=i.decryptdata,l="stats"in t;if(a==null||!a.encrypted||l){const h=this.tracks[i.level],d=this.vttCCs;d[i.cc]||(d[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),h&&h.textCodec===ru?this._parseIMSC1(i,n):this._parseVTTs(t)}}else this.hls.trigger(_.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const i=this.hls;$d(t,this.initPTS[e.cc],n=>{this._appendCues(n,e.level),i.trigger(_.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},n=>{q.log(`Failed to parse IMSC1: ${n}`),i.trigger(_.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:n})})}_parseVTTs(e){var t;const{frag:i,payload:n}=e,{initPTS:a,unparsedVttFrags:l}=this,h=a.length-1;if(!a[i.cc]&&h===-1){l.push(e);return}const d=this.hls,p=(t=i.initSegment)!=null&&t.data?on(i.initSegment.data,new Uint8Array(n)):n;ZA(p,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,m=>{this._appendCues(m,i.level),d.trigger(_.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},m=>{const g=m.message==="Missing initPTS for VTT MPEGTS";g?l.push(e):this._fallbackToIMSC1(i,n),q.log(`Failed to parse VTT cue: ${m}`),!(g&&h>i.cc)&&d.trigger(_.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:m})})}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||$d(t,this.initPTS[e.cc],()=>{i.textCodec=ru,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){const i=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[t];if(!n||n.mode==="disabled")return;e.forEach(a=>Pf(n,a))}else{const n=this.tracks[t];if(!n)return;const a=n.default?"default":"subtitles"+t;i.trigger(_.CUES_PARSED,{type:"subtitles",cues:e,track:a})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===tt.SUBTITLE&&this.onFragLoaded(_.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){const{cea608Parser1:i,cea608Parser2:n}=this;if(!this.enabled||!(i&&n))return;const{frag:a,samples:l}=t;if(!(a.type===tt.MAIN&&this.closedCaptionsForLevel(a)==="NONE"))for(let h=0;h<l.length;h++){const d=l[h].bytes;if(d){const p=this.extractCea608Data(d);i.addData(l[h].pts,p[0]),n.addData(l[h].pts,p[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:n,type:a}){const{media:l}=this;if(!(!l||l.currentTime<i)){if(!a||a==="video"){const{captionsTracks:h}=this;Object.keys(h).forEach(d=>kc(h[d],t,i))}if(this.config.renderTextTracksNatively&&t===0&&n!==void 0){const{textTracks:h}=this;Object.keys(h).forEach(d=>kc(h[d],t,n))}}}extractCea608Data(e){const t=[[],[]],i=e[0]&31;let n=2;for(let a=0;a<i;a++){const l=e[n++],h=127&e[n++],d=127&e[n++];if(h===0&&d===0)continue;if((4&l)!==0){const m=3&l;(m===0||m===1)&&(t[m].push(h),t[m].push(d))}}return t}}function rE(s,e){return!!s&&s.label===e.name&&!(s.textTrack1||s.textTrack2)}function sE(s,e,t,i){return Math.min(e,i)-Math.max(s,t)}function Ud(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class au{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(_.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(_.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null}onManifestParsed(e,t){const i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const e=this.hls.levels;if(e.length){const t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const i=t.filter((n,a)=>this.isLevelAllowed(n)&&a<=e);return this.clientRect=null,au.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 e=this.media,t={width:0,height:0};if(e){const i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return-1;const n=(l,h)=>h?l.width!==h.width||l.height!==h.height:!0;let a=e.length-1;for(let l=0;l<e.length;l+=1){const h=e[l];if((h.width>=t||h.height>=i)&&n(h,e[l+1])){a=l;break}}return a}}class nE{constructor(e){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=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const i=this.hls.config;if(i.capLevelOnFPSDrop){const n=t.media instanceof self.HTMLVideoElement?t.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(e,t,i){const n=performance.now();if(t){if(this.lastTime){const a=n-this.lastTime,l=i-this.lastDroppedFrames,h=t-this.lastDecodedFrames,d=1e3*l/a,p=this.hls;if(p.trigger(_.FPS_DROP,{currentDropped:l,currentDecoded:h,totalDroppedFrames:i}),d>0&&l>p.config.fpsDroppedMonitoringThreshold*h){let m=p.currentLevel;q.warn("drop FPS ratio greater than max allowed value for currentLevel: "+m),m>0&&(p.autoLevelCapping===-1||p.autoLevelCapping>=m)&&(m=m-1,p.trigger(_.FPS_DROP_LEVEL_CAPPING,{level:m,droppedLevel:p.currentLevel}),p.autoLevelCapping=m,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}const qa="[eme]";class Ln{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=Ln.CDMCleanupPromise?[Ln.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=q.debug.bind(q,qa),this.log=q.log.bind(q,qa),this.warn=q.warn.bind(q,qa),this.error=q.error.bind(q,qa),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(_.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(_.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(_.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(_.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:i}=this.config,n=t[e];if(n)return n.licenseUrl;if(e===ei.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:t}=this.config,i=t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,i=(l,h,d)=>!!l&&d.indexOf(l)===h,n=t.map(l=>l.audioCodec).filter(i),a=t.map(l=>l.videoCodec).filter(i);return n.length+a.length===0&&a.push("avc1.42e01e"),new Promise((l,h)=>{const d=p=>{const m=p.shift();this.getMediaKeysPromise(m,n,a).then(g=>l({keySystem:m,mediaKeys:g})).catch(g=>{p.length?d(p):g instanceof ur?h(g):h(new ur({type:et.KEY_SYSTEM_ERROR,details:de.KEY_SYSTEM_NO_ACCESS,error:g,fatal:!0},g.message))})};d(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let n=`Configured requestMediaKeySystemAccess is not a function ${i}`;return af===null&&self.location.protocol==="http:"&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return i(e,t)}getMediaKeysPromise(e,t,i){const n=Av(e,t,i,this.config.drmSystemOptions),a=this.keySystemAccessPromises[e];let l=a==null?void 0:a.keySystemAccess;if(!l){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(n)}`),l=this.requestMediaKeySystemAccess(e,n);const h=this.keySystemAccessPromises[e]={keySystemAccess:l};return l.catch(d=>{this.log(`Failed to obtain access to key-system "${e}": ${d}`)}),l.then(d=>{this.log(`Access for key-system "${d.keySystem}" obtained`);const p=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),h.mediaKeys=d.createMediaKeys().then(m=>(this.log(`Media-keys created for "${e}"`),p.then(g=>g?this.setMediaKeysServerCertificate(m,e,g):m))),h.mediaKeys.catch(m=>{this.error(`Failed to create media-keys for "${e}"}: ${m}`)}),h.mediaKeys})}return l.then(()=>a.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${Dr.hexDump(e.keyId||[])}`);const n=i.createSession(),a={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(a),a}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const i=this.createMediaKeySessionContext(e),n=this.getKeyIdString(t),a="cenc";this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,a,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Dr.hexDump(e.keyId)}updateKeySession(e,t){var i;const n=e.mediaKeysSession;return this.log(`Updating key-session "${n.sessionId}" for keyID ${Dr.hexDump(((i=e.decryptdata)==null?void 0:i.keyId)||[])}
|
204
|
+
} (data length: ${t&&t.byteLength})`),n.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,i)=>{const n=yc(this.config),a=e.map(sf).filter(l=>!!l&&n.indexOf(l)!==-1);return this.getKeySystemSelectionPromise(a).then(({keySystem:l})=>{const h=of(l);h?t(h):i(new Error(`Unable to find format for key-system "${l}"`))}).catch(i)})}loadKey(e){const t=e.keyInfo.decryptdata,i=this.getKeyIdString(t),n=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${n}`);let a=this.keyIdToKeySessionPromise[i];return a||(a=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(t).then(({keySystem:l,mediaKeys:h})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${n}`),this.attemptSetMediaKeys(l,h).then(()=>{this.throwIfDestroyed();const d=this.createMediaKeySessionContext({keySystem:l,mediaKeys:h,decryptdata:t}),p="cenc";return this.generateRequestWithPreferredKeySession(d,p,t.pssh,"playlist-key")}))),a.catch(l=>this.handleError(l))),a}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof ur?this.hls.trigger(_.ERROR,e.data):this.hls.trigger(_.ERROR,{type:et.KEY_SYSTEM_ERROR,details:de.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){const n=sf(e.keyFormat),a=n?[n]:yc(this.config);return this.attemptKeySystemAccess(a)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=yc(this.config)),e.length===0)throw new ur({type:et.KEY_SYSTEM_ERROR,details:de.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:i}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),i===null)return;let n,a;if(t==="sinf"&&this.config.drmSystems[ei.FAIRPLAY]){const m=Ti(new Uint8Array(i));try{const g=vc(JSON.parse(m).sinf),A=mf(new Uint8Array(g));if(!A)return;n=A.subarray(8,24),a=ei.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const m=Hv(i);if(m===null)return;m.version===0&&m.systemId===nf.WIDEVINE&&m.data&&(n=m.data.subarray(8,24)),a=yv(m.systemId)}if(!a||!n)return;const l=Dr.hexDump(n),{keyIdToKeySessionPromise:h,mediaKeySessions:d}=this;let p=h[l];for(let m=0;m<d.length;m++){const g=d[m],A=g.decryptdata;if(A.pssh||!A.keyId)continue;const x=Dr.hexDump(A.keyId);if(l===x||A.uri.replace(/-/g,"").indexOf(l)!==-1){p=h[x],delete h[x],A.pssh=new Uint8Array(i),A.keyId=n,p=h[l]=p.then(()=>this.generateRequestWithPreferredKeySession(g,t,i,"encrypted-event-key-match"));break}}p||(p=h[l]=this.getKeySystemSelectionPromise([a]).then(({keySystem:m,mediaKeys:g})=>{var A;this.throwIfDestroyed();const x=new So("ISO-23001-7",l,(A=of(m))!=null?A:"");return x.pssh=new Uint8Array(i),x.keyId=n,this.attemptSetMediaKeys(m,g).then(()=>{this.throwIfDestroyed();const b=this.createMediaKeySessionContext({decryptdata:x,keySystem:m,mediaKeys:g});return this.generateRequestWithPreferredKeySession(b,t,i,"encrypted-event-no-match")})})),p.catch(m=>this.handleError(m))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const n=Promise.all(i).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(n),n.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(a=>i.indexOf(a)===-1)})}generateRequestWithPreferredKeySession(e,t,i,n){var a,l;const h=(a=this.config.drmSystems)==null||(l=a[e.keySystem])==null?void 0:l.generateRequest;if(h)try{const A=h.call(this.hls,t,i,e);if(!A)throw new Error("Invalid response from configured generateRequest filter");t=A.initDataType,i=e.decryptdata.pssh=A.initData?new Uint8Array(A.initData):null}catch(A){var d;if(this.warn(A.message),(d=this.hls)!=null&&d.config.debug)throw A}if(i===null)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(e);const p=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${n}": ${p} (init data type: ${t} length: ${i?i.byteLength:null})`);const m=new zc;e.mediaKeysSession.onmessage=A=>{const x=e.mediaKeysSession;if(!x){m.emit("error",new Error("invalid state"));return}const{messageType:b,message:S}=A;this.log(`"${b}" message event for session "${x.sessionId}" message size: ${S.byteLength}`),b==="license-request"||b==="license-renewal"?this.renewLicense(e,S).catch(w=>{this.handleError(w),m.emit("error",w)}):b==="license-release"?e.keySystem===ei.FAIRPLAY&&(this.updateKeySession(e,rf("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${b}"`)},e.mediaKeysSession.onkeystatuseschange=A=>{if(!e.mediaKeysSession){m.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const b=e.keyStatus;m.emit("keyStatus",b),b==="expired"&&(this.warn(`${e.keySystem} expired for key ${p}`),this.renewKeySession(e))};const g=new Promise((A,x)=>{m.on("error",x),m.on("keyStatus",b=>{b.startsWith("usable")?A():b==="output-restricted"?x(new ur({type:et.KEY_SYSTEM_ERROR,details:de.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):b==="internal-error"?x(new ur({type:et.KEY_SYSTEM_ERROR,details:de.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${b}"`)):b==="expired"?x(new Error("key expired while generating request")):this.warn(`unhandled key status change "${b}"`)})});return e.mediaKeysSession.generateRequest(t,i).then(()=>{var A;this.log(`Request generated for key-session "${(A=e.mediaKeysSession)==null?void 0:A.sessionId}" keyId: ${p}`)}).catch(A=>{throw new ur({type:et.KEY_SYSTEM_ERROR,details:de.KEY_SYSTEM_NO_SESSION,error:A,fatal:!1},`Error generating key-session request: ${A}`)}).then(()=>g).catch(A=>{throw m.removeAllListeners(),this.removeSession(e),A}).then(()=>(m.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,i)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Dr.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Dr.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,i=t.loader,n=new i(t),a=this.getServerCertificateUrl(e);return a?(this.log(`Fetching serverCertificate for "${e}"`),new Promise((l,h)=>{const d={responseType:"arraybuffer",url:a},p=t.certLoadPolicy.default,m={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},g={onSuccess:(A,x,b,S)=>{l(A.data)},onError:(A,x,b,S)=>{h(new ur({type:et.KEY_SYSTEM_ERROR,details:de.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:b,response:Ki({url:d.url,data:void 0},A)},`"${e}" certificate request failed (${a}). Status: ${A.code} (${A.text})`))},onTimeout:(A,x,b)=>{h(new ur({type:et.KEY_SYSTEM_ERROR,details:de.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:b,response:{url:d.url,data:void 0}},`"${e}" certificate request timed out (${a})`))},onAbort:(A,x,b)=>{h(new Error("aborted"))}};n.load(d,m,g)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((n,a)=>{e.setServerCertificate(i).then(l=>{this.log(`setServerCertificate ${l?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${t}"`),n(e)}).catch(l=>{a(new ur({type:et.KEY_SYSTEM_ERROR,details:de.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:l,fatal:!0},l.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(n=>{throw new ur({type:et.KEY_SYSTEM_ERROR,details:de.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:n,fatal:!0},n.message)}))}setupLicenseXHR(e,t,i,n){const a=this.config.licenseXhrSetup;return a?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return a.call(this.hls,e,t,i,n)}).catch(l=>{if(!i.decryptdata)throw l;return e.open("POST",t,!0),a.call(this.hls,e,t,i,n)}).then(l=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:l||n})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:n}))}requestLicense(e,t){const i=this.config.keyLoadPolicy.default;return new Promise((n,a)=>{const l=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${l}`);const h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(h.readyState===4)if(h.status===200){this._requestLicenseFailureCount=0;let d=h.response;this.log(`License received ${d instanceof ArrayBuffer?d.byteLength:d}`);const p=this.config.licenseResponseCallback;if(p)try{d=p.call(this.hls,h,l,e)}catch(m){this.error(m)}n(d)}else{const d=i.errorRetry,p=d?d.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>p||h.status>=400&&h.status<500)a(new ur({type:et.KEY_SYSTEM_ERROR,details:de.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:h,response:{url:l,data:void 0,code:h.status,text:h.statusText}},`License Request XHR failed (${l}). Status: ${h.status} (${h.statusText})`));else{const m=p-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${m} attempts left`),this.requestLicense(e,t).then(n,a)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=h,this.setupLicenseXHR(h,l,e,t).then(({xhr:d,licenseChallenge:p})=>{d.send(p)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},So.clearKeyUriToKeyIdMap();const i=t.length;Ln.CDMCleanupPromise=Promise.all(t.map(n=>this.removeSession(n)).concat(e==null?void 0:e.setMediaKeys(null).catch(n=>{this.log(`Could not clear media keys: ${n}. media.src: ${e==null?void 0:e.src}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(n=>{this.log(`Could not close sessions and clear media keys: ${n}. media.src: ${e==null?void 0:e.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=t.reduce((n,a)=>(n.indexOf(a.keyFormat)===-1&&n.push(a.keyFormat),n),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:i}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),t.onmessage=null,t.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const n=this.mediaKeySessions.indexOf(e);return n>-1&&this.mediaKeySessions.splice(n,1),t.remove().catch(a=>{this.log(`Could not remove session: ${a}`)}).then(()=>t.close()).catch(a=>{this.log(`Could not close session: ${a}`)})}}}Ln.CDMCleanupPromise=void 0;class ur extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}const oE=1;var Xi={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const aE="h";class Ss{constructor(e){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:Xi.MANIFEST,su:!this.initialized})}catch(a){q.warn("Could not generate manifest CMCD data.",a)}},this.applyFragmentData=n=>{try{const a=n.frag,l=this.hls.levels[a.level],h=this.getObjectType(a),d={d:a.duration*1e3,ot:h};(h===Xi.VIDEO||h===Xi.AUDIO||h==Xi.MUXED)&&(d.br=l.bitrate/1e3,d.tb=this.getTopBandwidth(h)/1e3,d.bl=this.getBufferLength(h)),this.apply(n,d)}catch(a){q.warn("Could not generate segment CMCD data.",a)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||Ss.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}registerListeners(){const e=this.hls;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHED,this.onMediaDetached,this),e.on(_.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHED,this.onMediaDetached,this),e.off(_.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var i,n;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(n=t.tracks.video)==null?void 0:n.buffer}createData(){var e;return{v:oE,sf:aE,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){ai(t,this.createData());const i=t.ot===Xi.INIT||t.ot===Xi.VIDEO||t.ot===Xi.MUXED;if(this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){const n=Ss.toHeaders(t);if(!Object.keys(n).length)return;e.headers||(e.headers={}),ai(e.headers,n)}else{const n=Ss.toQuery(t);if(!n)return;e.url=Ss.appendQueryToUri(e.url,n)}}getObjectType(e){const{type:t}=e;if(t==="subtitle")return Xi.TIMED_TEXT;if(e.sn==="initSegment")return Xi.INIT;if(t==="audio")return Xi.AUDIO;if(t==="main")return this.hls.audioTracks.length?Xi.VIDEO:Xi.MUXED}getTopBandwidth(e){let t=0,i;const n=this.hls;if(e===Xi.AUDIO)i=n.audioTracks;else{const a=n.maxAutoLevel,l=a>-1?a+1:n.levels.length;i=n.levels.slice(0,l)}for(const a of i)a.bitrate>t&&(t=a.bitrate);return t>0?t:NaN}getBufferLength(e){const t=this.hls.media,i=e===Xi.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:Nt.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(a){this.loader=void 0,this.loader=new i(a)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(a,l,h){t(a),this.loader.load(a,l,h)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(a){this.loader=void 0,this.loader=new i(a)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(a,l,h){t(a),this.loader.load(a,l,h)}}}static uuid(){const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}static serialize(e){const t=[],i=p=>!Number.isNaN(p)&&p!=null&&p!==""&&p!==!1,n=p=>Math.round(p),a=p=>n(p/100)*100,h={br:n,d:n,bl:a,dl:a,mtp:a,nor:p=>encodeURIComponent(p),rtp:a,tb:n},d=Object.keys(e||{}).sort();for(const p of d){let m=e[p];if(!i(m)||p==="v"&&m===1||p=="pr"&&m===1)continue;const g=h[p];g&&(m=g(m));const A=typeof m;let x;p==="ot"||p==="sf"||p==="st"?x=`${p}=${m}`:A==="boolean"?x=p:A==="number"?x=`${p}=${m}`:x=`${p}=${JSON.stringify(m)}`,t.push(x)}return t.join(",")}static toHeaders(e){const t=Object.keys(e),i={},n=["Object","Request","Session","Status"],a=[{},{},{},{}],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 h of t){const d=l[h]!=null?l[h]:1;a[d][h]=e[h]}for(let h=0;h<a.length;h++){const d=Ss.serialize(a[h]);d&&(i[`CMCD-${n[h]}`]=d)}return i}static toQuery(e){return`CMCD=${encodeURIComponent(Ss.serialize(e))}`}static appendQueryToUri(e,t){if(!t)return e;const i=e.includes("?")?"&":"?";return`${e}${i}${t}`}}const lE=3e5;class cE{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=q.log.bind(q,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const e=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}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(e){const t=this.levels;t&&(this.levels=t.filter(i=>i!==e))}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(e,t){const{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if((i==null?void 0:i.action)===Li.SendAlternateToPenaltyBox&&i.flags===lr.MoveAllAlternatesMatchingHost){let n=this.pathwayPriority;const a=this.pathwayId;this.penalizedPathways[a]||(this.penalizedPathways[a]=performance.now()),!n&&this.levels&&(n=this.levels.reduce((l,h)=>(l.indexOf(h.pathwayId)===-1&&l.push(h.pathwayId),l),[])),n&&n.length>1&&(this.updatePathwayPriority(n),i.resolved=this.pathwayId!==a)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t;const i=this.penalizedPathways,n=performance.now();Object.keys(i).forEach(a=>{n-i[a]>lE&&delete i[a]});for(let a=0;a<e.length;a++){const l=e[a];if(i[l])continue;if(l===this.pathwayId)return;const h=this.hls.nextLoadLevel,d=this.hls.levels[h];if(t=this.getLevelsForPathway(l),t.length>0){this.log(`Setting Pathway to "${l}"`),this.pathwayId=l,this.hls.trigger(_.LEVELS_UPDATED,{levels:t});const p=this.hls.levels[h];d&&p&&this.levels&&(p.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&p.bitrate!==d.bitrate&&this.log(`Unstable Pathways change from bitrate ${d.bitrate} to ${p.bitrate}`),this.hls.nextLoadLevel=h);break}}}clonePathways(e){const t=this.levels;if(!t)return;const i={},n={};e.forEach(a=>{const{ID:l,"BASE-ID":h,"URI-REPLACEMENT":d}=a;if(t.some(m=>m.pathwayId===l))return;const p=this.getLevelsForPathway(h).map(m=>{const g=ai({},m);g.details=void 0,g.url=Gd(m.uri,m.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",d);const A=new Jt(m.attrs);A["PATHWAY-ID"]=l;const x=A.AUDIO&&`${A.AUDIO}_clone_${l}`,b=A.SUBTITLES&&`${A.SUBTITLES}_clone_${l}`;x&&(i[A.AUDIO]=x,A.AUDIO=x),b&&(n[A.SUBTITLES]=b,A.SUBTITLES=b),g.attrs=A;const S=new wo(g);return Ga(S,"audio",x),Ga(S,"text",b),S});t.push(...p),Bd(this.audioTracks,i,d,l),Bd(this.subtitleTracks,n,d,l)})}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let n;try{n=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(n.protocol!=="data:"){const m=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+m)}const a={responseType:"json",url:n.href},l=t.steeringManifestLoadPolicy.default,h=l.errorRetry||l.timeoutRetry||{},d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:h.maxNumRetry||0,retryDelay:h.retryDelayMs||0,maxRetryDelay:h.maxRetryDelayMs||0},p={onSuccess:(m,g,A,x)=>{this.log(`Loaded steering manifest: "${n}"`);const b=m.data;if(b.VERSION!==1){this.log(`Steering VERSION ${b.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=b.TTL;const{"RELOAD-URI":S,"PATHWAY-CLONES":w,"PATHWAY-PRIORITY":P}=b;if(S)try{this.uri=new self.URL(S,n).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${S}`);return}this.scheduleRefresh(this.uri||A.url),w&&this.clonePathways(w),P&&this.updatePathwayPriority(P)},onError:(m,g,A,x)=>{if(this.log(`Error loading steering manifest: ${m.code} ${m.text} (${g.url})`),this.stopLoad(),m.code===410){this.enabled=!1,this.log(`Steering manifest ${g.url} no longer available`);return}let b=this.timeToLoad*1e3;if(m.code===429){const S=this.loader;if(typeof(S==null?void 0:S.getResponseHeader)=="function"){const w=S.getResponseHeader("Retry-After");w&&(b=parseFloat(w)*1e3)}this.log(`Steering manifest ${g.url} rate limited`);return}this.scheduleRefresh(this.uri||g.url,b)},onTimeout:(m,g,A)=>{this.log(`Timeout loading steering manifest (${g.url})`),this.scheduleRefresh(this.uri||g.url)}};this.log(`Requesting steering manifest: ${n}`),this.loader.load(a,d,p)}scheduleRefresh(e,t=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(e)},t)}}function Bd(s,e,t,i){s&&Object.keys(e).forEach(n=>{const a=s.filter(l=>l.groupId===n).map(l=>{const h=ai({},l);return h.details=void 0,h.attrs=new Jt(h.attrs),h.url=h.attrs.URI=Gd(l.url,l.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),h.groupId=h.attrs["GROUP-ID"]=e[n],h.attrs["PATHWAY-ID"]=i,h});s.push(...a)})}function Gd(s,e,t,i){const{HOST:n,PARAMS:a,[t]:l}=i;let h;e&&(h=l==null?void 0:l[e],h&&(s=h));const d=new self.URL(s);return n&&!h&&(d.host=n),a&&Object.keys(a).sort().forEach(p=>{p&&d.searchParams.set(p,a[p])}),d.href}const uE=/^age:\s*[\d.]+\s*$/im;class Vd{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Da,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e)return;const i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;const a=this.xhrSetup;a?Promise.resolve().then(()=>{if(!this.stats.aborted)return a(i,t.url)}).catch(l=>(i.open("GET",t.url,!0),a(i,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(l=>{this.callbacks.onError({code:i.status,text:l.message},t,i,n)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const n=this.context.headers,{maxTimeToFirstByteMs:a,maxLoadTimeMs:l}=i.loadPolicy;if(n)for(const h in n)e.setRequestHeader(h,n[h]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=a&&ze(a)?a:l,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const n=t.readyState,a=this.config;if(!i.aborted&&n>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),n===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const l=t.status,h=t.responseType!=="text";if(l>=200&&l<300&&(h&&t.response||t.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const d=h?t.response:t.responseText,p=t.responseType==="arraybuffer"?d.byteLength:d.length;if(i.loaded=i.total=p,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;const m=this.callbacks.onProgress;if(m&&m(i,e,d,t),!this.callbacks)return;const g={url:t.responseURL,data:d,code:l};this.callbacks.onSuccess(g,i,e,t)}else{const d=a.loadPolicy.errorRetry,p=i.retry;Ba(d,p,!1,l)?this.retry(d):(q.error(`${l} while loading ${e.url}`),this.callbacks.onError({code:l,text:t.statusText},e,t,i))}}}loadtimeout(){var e;const t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,i=this.stats.retry;if(Ba(t,i,!0))this.retry(t);else{q.warn(`timeout while loading ${this.context.url}`);const n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:i}=this;this.retryDelay=Ic(e,i.retry),i.retry++,q.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&uE.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}function hE(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const fE=/(\d+)-(\d+)\/(\d+)/;class Hd{constructor(e){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=e.fetchSetup||gE,this.controller=new self.AbortController,this.stats=new Da}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const e=this.response;e!=null&&e.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,i){const n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();const a=dE(e,this.controller.signal),l=i.onProgress,h=e.responseType==="arraybuffer",d=h?"byteLength":"length",{maxTimeToFirstByteMs:p,maxLoadTimeMs:m}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=p&&ze(p)?p:m,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(n,e,this.response)},t.timeout),self.fetch(this.request).then(g=>{this.response=this.loader=g;const A=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=m,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(n,e,this.response)},m-(A-n.loading.start)),!g.ok){const{status:x,statusText:b}=g;throw new vE(b||"fetch, bad network response",x,g)}return n.loading.first=A,n.total=mE(g.headers)||n.total,l&&ze(t.highWaterMark)?this.loadProgressively(g,n,e,t.highWaterMark,l):h?g.arrayBuffer():e.responseType==="json"?g.json():g.text()}).then(g=>{const{response:A}=this;self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const x=g[d];x&&(n.loaded=n.total=x);const b={url:A.url,data:g,code:A.status};l&&!ze(t.highWaterMark)&&l(n,e,g,A),i.onSuccess(b,n,e,A)}).catch(g=>{if(self.clearTimeout(this.requestTimeout),n.aborted)return;const A=g&&g.code||0,x=g?g.message:null;i.onError({code:A,text:x},e,g?g.details:null,n)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,n=0,a){const l=new vd,h=e.body.getReader(),d=()=>h.read().then(p=>{if(p.done)return l.dataLength&&a(t,i,l.flush(),e),Promise.resolve(new ArrayBuffer(0));const m=p.value,g=m.length;return t.loaded+=g,g<n||l.dataLength?(l.push(m),l.dataLength>=n&&a(t,i,l.flush(),e)):a(t,i,m,e),d()}).catch(()=>Promise.reject());return d()}}function dE(s,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(ai({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function pE(s){const e=fE.exec(s);if(e)return parseInt(e[2])-parseInt(e[1])+1}function mE(s){const e=s.get("Content-Range");if(e){const i=pE(e);if(ze(i))return i}const t=s.get("Content-Length");if(t)return parseInt(t)}function gE(s,e){return new self.Request(s.url,e)}class vE extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const yE=/\s/,AE={newCue(s,e,t,i){const n=[];let a,l,h,d,p;const m=self.VTTCue||self.TextTrackCue;for(let A=0;A<i.rows.length;A++)if(a=i.rows[A],h=!0,d=0,p="",!a.isEmpty()){var g;for(let S=0;S<a.chars.length;S++)yE.test(a.chars[S].uchar)&&h?d++:(p+=a.chars[S].uchar,h=!1);a.cueStartTime=e,e===t&&(t+=1e-4),d>=16?d--:d++;const x=Dd(p.trim()),b=iu(e,t,x);s!=null&&(g=s.cues)!=null&&g.getCueById(b)||(l=new m(e,t,x),l.id=b,l.line=A+1,l.align="left",l.position=10+Math.min(80,Math.floor(d*8/32)*10),n.push(l))}return s&&n.length&&(n.sort((A,x)=>A.line==="auto"||x.line==="auto"?0:A.line>8&&x.line>8?x.line-A.line:A.line-x.line),n.forEach(A=>Pf(s,A))),n}},EE={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},xE=Ki(Ki({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:Vd,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:kA,bufferController:PA,capLevelController:au,errorController:vy,fpsController:nE,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:af,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:EE},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},bE()),{},{subtitleStreamController:CA,subtitleTrackController:DA,timelineController:iE,audioStreamController:_A,audioTrackController:RA,emeController:Ln,cmcdController:Ss,contentSteeringController:cE});function bE(){return{cueHandler:AE,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 TE(s,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const t=lu(s),i=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(a=>{const l=`${a==="level"?"playlist":a}LoadPolicy`,h=e[l]===void 0,d=[];n.forEach(p=>{const m=`${a}Loading${p}`,g=e[m];if(g!==void 0&&h){d.push(m);const A=t[l].default;switch(e[l]={default:A},p){case"TimeOut":A.maxLoadTimeMs=g,A.maxTimeToFirstByteMs=g;break;case"MaxRetry":A.errorRetry.maxNumRetry=g,A.timeoutRetry.maxNumRetry=g;break;case"RetryDelay":A.errorRetry.retryDelayMs=g,A.timeoutRetry.retryDelayMs=g;break;case"MaxRetryTimeout":A.errorRetry.maxRetryDelayMs=g,A.timeoutRetry.maxRetryDelayMs=g;break}}}),d.length&&q.warn(`hls.js config: "${d.join('", "')}" setting(s) are deprecated, use "${l}": ${JSON.stringify(e[l])}`)}),Ki(Ki({},t),e)}function lu(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(lu):Object.keys(s).reduce((e,t)=>(e[t]=lu(s[t]),e),{}):s}function SE(s){const e=s.loader;e!==Hd&&e!==Vd?(q.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):hE()&&(s.loader=Hd,s.progressive=!0,s.enableSoftwareAES=!0,q.log("[config]: Progressive streaming enabled, using FetchLoader"))}class is{static get version(){return"1.4.12"}static isSupported(){return My()}static get Events(){return _}static get ErrorTypes(){return et}static get ErrorDetails(){return de}static get DefaultConfig(){return is.defaultConfig?is.defaultConfig:xE}static set DefaultConfig(e){is.defaultConfig=e}constructor(e={}){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,lv(e.debug||!1,"Hls instance");const t=this.config=TE(is.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&SE(t);const{abrController:i,bufferController:n,capLevelController:a,errorController:l,fpsController:h}=t,d=new l(this),p=this.abrController=new i(this),m=this.bufferController=new n(this),g=this.capLevelController=new a(this),A=new h(this),x=new Qv(this),b=new ry(this),S=t.contentSteeringController,w=S?new S(this):null,P=this.levelController=new Ay(this,w),$=new Ey(this),N=new by(this.config),I=this.streamController=new TA(this,$,N);g.setStreamController(I),A.setStreamController(I);const O=[x,P,I];w&&O.splice(1,0,w),this.networkControllers=O;const K=[p,m,g,A,b,$];this.audioTrackController=this.createController(t.audioTrackController,O);const U=t.audioStreamController;U&&O.push(new U(this,$,N)),this.subtitleTrackController=this.createController(t.subtitleTrackController,O);const re=t.subtitleStreamController;re&&O.push(new re(this,$,N)),this.createController(t.timelineController,K),N.emeController=this.emeController=this.createController(t.emeController,K),this.cmcdController=this.createController(t.cmcdController,K),this.latencyController=this.createController(sy,K),this.coreComponents=K,O.push(d);const ne=d.onErrorOut;typeof ne=="function"&&this.on(_.ERROR,ne,d)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,n){this._emitter.off(e,t,i,n)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){q.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(_.ERROR,{type:et.OTHER_ERROR,details:de.INTERNAL_EXCEPTION,fatal:!1,event:e,error:i})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){q.log("destroy"),this.trigger(_.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){q.log("attachMedia"),this._media=e,this.trigger(_.MEDIA_ATTACHING,{media:e})}detachMedia(){q.log("detachMedia"),this.trigger(_.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,i=this.url,n=this.url=pc.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});q.log(`loadSource:${n}`),t&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(_.MANIFEST_LOADING,{url:e})}startLoad(e=-1){q.log(`startLoad(${e})`),this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){q.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){q.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){q.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){q.log(`set currentLevel:${e}`),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){q.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){q.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){q.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){q.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(q.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){Rc.indexOf(e)>-1&&(this._maxHdcpLevel=e)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let n=0;n<i;n++)if(e[n].maxBitrate>=t)return n;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let n;if(t===-1&&e&&e.length?n=e.length-1:n=t,i)for(let a=n;a--;){const l=e[a].attrs["HDCP-LEVEL"];if(l&&l<=i)return a}return n}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}is.defaultConfig=void 0;var kE=Co;Co.flatten=Co,Co.unflatten=Kd;function Wd(s){return s&&s.constructor&&typeof s.constructor.isBuffer=="function"&&s.constructor.isBuffer(s)}function jd(s){return s}function Co(s,e){e=e||{};const t=e.delimiter||".",i=e.maxDepth,n=e.transformKey||jd,a={};function l(h,d,p){p=p||1,Object.keys(h).forEach(function(m){const g=h[m],A=e.safe&&Array.isArray(g),x=Object.prototype.toString.call(g),b=Wd(g),S=x==="[object Object]"||x==="[object Array]",w=d?d+t+n(m):n(m);if(!A&&!b&&S&&Object.keys(g).length&&(!e.maxDepth||p<i))return l(g,w,p+1);a[w]=g})}return l(s),a}function Kd(s,e){e=e||{};const t=e.delimiter||".",i=e.overwrite||!1,n=e.transformKey||jd,a={};if(Wd(s)||Object.prototype.toString.call(s)!=="[object Object]")return s;function h(m){const g=Number(m);return isNaN(g)||m.indexOf(".")!==-1||e.object?m:g}function d(m,g,A){return Object.keys(A).reduce(function(x,b){return x[m+t+b]=A[b],x},g)}function p(m){const g=Object.prototype.toString.call(m),A=g==="[object Array]",x=g==="[object Object]";if(m){if(A)return!m.length;if(x)return!Object.keys(m).length}else return!0}return s=Object.keys(s).reduce(function(m,g){const A=Object.prototype.toString.call(s[g]);return!(A==="[object Object]"||A==="[object Array]")||p(s[g])?(m[g]=s[g],m):d(g,m,Co(s[g],e))},{}),Object.keys(s).forEach(function(m){const g=m.split(t).map(n);let A=h(g.shift()),x=h(g[0]),b=a;for(;x!==void 0;){if(A==="__proto__")return;const S=Object.prototype.toString.call(b[A]),w=S==="[object Object]"||S==="[object Array]";if(!i&&!w&&typeof b[A]<"u")return;(i&&!w||!i&&b[A]==null)&&(b[A]=typeof x=="number"&&!e.object?[]:{}),b=b[A],g.length>0&&(A=h(g.shift()),x=h(g[0]))}b[A]=Kd(s[m],e)}),a}const wE=ua(kE);var zd=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function _E(s,e){return!!(s===e||zd(s)&&zd(e))}function RE(s,e){if(s.length!==e.length)return!1;for(var t=0;t<s.length;t++)if(!_E(s[t],e[t]))return!1;return!0}function LE(s,e){e===void 0&&(e=RE);var t=null;function i(){for(var n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];if(t&&t.lastThis===this&&e(n,t.lastArgs))return t.lastResult;var l=s.apply(this,n);return t={lastResult:l,lastArgs:n,lastThis:this},l}return i.clear=function(){t=null},i}/**
|
205
|
+
* @license
|
206
|
+
* Copyright 2017 Google LLC
|
207
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
208
|
+
*/const Yd=(s,e,t)=>{const i=new Map;for(let n=e;n<=t;n++)i.set(s[n],n);return i},Xd=bn(class extends co{constructor(s){if(super(s),s.type!==xn.CHILD)throw Error("repeat() can only be used in text expressions")}ht(s,e,t){let i;t===void 0?t=e:e!==void 0&&(i=e);const n=[],a=[];let l=0;for(const h of s)n[l]=i?i(h,l):l,a[l]=t(h,l),l++;return{values:a,keys:n}}render(s,e,t){return this.ht(s,e,t).values}update(s,[e,t,i]){const n=Zg(s),{values:a,keys:l}=this.ht(e,t,i);if(!Array.isArray(n))return this.dt=l,a;const h=this.dt??(this.dt=[]),d=[];let p,m,g=0,A=n.length-1,x=0,b=a.length-1;for(;g<=A&&x<=b;)if(n[g]===null)g++;else if(n[A]===null)A--;else if(h[g]===l[x])d[x]=Qs(n[g],a[x]),g++,x++;else if(h[A]===l[b])d[b]=Qs(n[A],a[b]),A--,b--;else if(h[g]===l[b])d[b]=Qs(n[g],a[b]),lo(s,d[b+1],n[g]),g++,b--;else if(h[A]===l[x])d[x]=Qs(n[A],a[x]),lo(s,n[g],n[A]),A--,x++;else if(p===void 0&&(p=Yd(l,x,b),m=Yd(h,g,A)),p.has(h[g]))if(p.has(h[A])){const S=m.get(l[x]),w=S!==void 0?n[S]:null;if(w===null){const P=lo(s,n[g]);Qs(P,a[x]),d[x]=P}else d[x]=Qs(w,a[x]),lo(s,n[g],w),n[S]=null;x++}else Bl(n[A]),A--;else Bl(n[g]),g++;for(;x<=b;){const S=lo(s,d[b+1]);Qs(S,a[x]),d[x++]=S}for(;g<=A;){const S=n[g++];S!==null&&Bl(S)}return this.dt=l,Xg(s,d),ps}});var Zi="top",hr="bottom",fr="right",qi="left",cu="auto",Io=[Zi,hr,fr,qi],Cn="start",Do="end",CE="clippingParents",Zd="viewport",Oo="popper",IE="reference",qd=Io.reduce(function(s,e){return s.concat([e+"-"+Cn,e+"-"+Do])},[]),Qd=[].concat(Io,[cu]).reduce(function(s,e){return s.concat([e,e+"-"+Cn,e+"-"+Do])},[]),DE="beforeRead",OE="read",PE="afterRead",$E="beforeMain",ME="main",FE="afterMain",NE="beforeWrite",UE="write",BE="afterWrite",GE=[DE,OE,PE,$E,ME,FE,NE,UE,BE];function Pr(s){return s?(s.nodeName||"").toLowerCase():null}function rr(s){if(s==null)return window;if(s.toString()!=="[object Window]"){var e=s.ownerDocument;return e&&e.defaultView||window}return s}function ln(s){var e=rr(s).Element;return s instanceof e||s instanceof Element}function dr(s){var e=rr(s).HTMLElement;return s instanceof e||s instanceof HTMLElement}function uu(s){if(typeof ShadowRoot>"u")return!1;var e=rr(s).ShadowRoot;return s instanceof e||s instanceof ShadowRoot}function VE(s){var e=s.state;Object.keys(e.elements).forEach(function(t){var i=e.styles[t]||{},n=e.attributes[t]||{},a=e.elements[t];!dr(a)||!Pr(a)||(Object.assign(a.style,i),Object.keys(n).forEach(function(l){var h=n[l];h===!1?a.removeAttribute(l):a.setAttribute(l,h===!0?"":h)}))})}function HE(s){var e=s.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(i){var n=e.elements[i],a=e.attributes[i]||{},l=Object.keys(e.styles.hasOwnProperty(i)?e.styles[i]:t[i]),h=l.reduce(function(d,p){return d[p]="",d},{});!dr(n)||!Pr(n)||(Object.assign(n.style,h),Object.keys(a).forEach(function(d){n.removeAttribute(d)}))})}}const Jd={name:"applyStyles",enabled:!0,phase:"write",fn:VE,effect:HE,requires:["computeStyles"]};function $r(s){return s.split("-")[0]}var cn=Math.max,Qa=Math.min,In=Math.round;function hu(){var s=navigator.userAgentData;return s!=null&&s.brands&&Array.isArray(s.brands)?s.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function ep(){return!/^((?!chrome|android).)*safari/i.test(hu())}function Dn(s,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var i=s.getBoundingClientRect(),n=1,a=1;e&&dr(s)&&(n=s.offsetWidth>0&&In(i.width)/s.offsetWidth||1,a=s.offsetHeight>0&&In(i.height)/s.offsetHeight||1);var l=ln(s)?rr(s):window,h=l.visualViewport,d=!ep()&&t,p=(i.left+(d&&h?h.offsetLeft:0))/n,m=(i.top+(d&&h?h.offsetTop:0))/a,g=i.width/n,A=i.height/a;return{width:g,height:A,top:m,right:p+g,bottom:m+A,left:p,x:p,y:m}}function fu(s){var e=Dn(s),t=s.offsetWidth,i=s.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-i)<=1&&(i=e.height),{x:s.offsetLeft,y:s.offsetTop,width:t,height:i}}function tp(s,e){var t=e.getRootNode&&e.getRootNode();if(s.contains(e))return!0;if(t&&uu(t)){var i=e;do{if(i&&s.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function rs(s){return rr(s).getComputedStyle(s)}function WE(s){return["table","td","th"].indexOf(Pr(s))>=0}function ks(s){return((ln(s)?s.ownerDocument:s.document)||window.document).documentElement}function Ja(s){return Pr(s)==="html"?s:s.assignedSlot||s.parentNode||(uu(s)?s.host:null)||ks(s)}function ip(s){return!dr(s)||rs(s).position==="fixed"?null:s.offsetParent}function jE(s){var e=/firefox/i.test(hu()),t=/Trident/i.test(hu());if(t&&dr(s)){var i=rs(s);if(i.position==="fixed")return null}var n=Ja(s);for(uu(n)&&(n=n.host);dr(n)&&["html","body"].indexOf(Pr(n))<0;){var a=rs(n);if(a.transform!=="none"||a.perspective!=="none"||a.contain==="paint"||["transform","perspective"].indexOf(a.willChange)!==-1||e&&a.willChange==="filter"||e&&a.filter&&a.filter!=="none")return n;n=n.parentNode}return null}function Po(s){for(var e=rr(s),t=ip(s);t&&WE(t)&&rs(t).position==="static";)t=ip(t);return t&&(Pr(t)==="html"||Pr(t)==="body"&&rs(t).position==="static")?e:t||jE(s)||e}function du(s){return["top","bottom"].indexOf(s)>=0?"x":"y"}function $o(s,e,t){return cn(s,Qa(e,t))}function KE(s,e,t){var i=$o(s,e,t);return i>t?t:i}function rp(){return{top:0,right:0,bottom:0,left:0}}function sp(s){return Object.assign({},rp(),s)}function np(s,e){return e.reduce(function(t,i){return t[i]=s,t},{})}var zE=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,sp(typeof e!="number"?e:np(e,Io))};function YE(s){var e,t=s.state,i=s.name,n=s.options,a=t.elements.arrow,l=t.modifiersData.popperOffsets,h=$r(t.placement),d=du(h),p=[qi,fr].indexOf(h)>=0,m=p?"height":"width";if(!(!a||!l)){var g=zE(n.padding,t),A=fu(a),x=d==="y"?Zi:qi,b=d==="y"?hr:fr,S=t.rects.reference[m]+t.rects.reference[d]-l[d]-t.rects.popper[m],w=l[d]-t.rects.reference[d],P=Po(a),$=P?d==="y"?P.clientHeight||0:P.clientWidth||0:0,N=S/2-w/2,I=g[x],O=$-A[m]-g[b],K=$/2-A[m]/2+N,U=$o(I,K,O),re=d;t.modifiersData[i]=(e={},e[re]=U,e.centerOffset=U-K,e)}}function XE(s){var e=s.state,t=s.options,i=t.element,n=i===void 0?"[data-popper-arrow]":i;n!=null&&(typeof n=="string"&&(n=e.elements.popper.querySelector(n),!n)||tp(e.elements.popper,n)&&(e.elements.arrow=n))}const ZE={name:"arrow",enabled:!0,phase:"main",fn:YE,effect:XE,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function On(s){return s.split("-")[1]}var qE={top:"auto",right:"auto",bottom:"auto",left:"auto"};function QE(s,e){var t=s.x,i=s.y,n=e.devicePixelRatio||1;return{x:In(t*n)/n||0,y:In(i*n)/n||0}}function op(s){var e,t=s.popper,i=s.popperRect,n=s.placement,a=s.variation,l=s.offsets,h=s.position,d=s.gpuAcceleration,p=s.adaptive,m=s.roundOffsets,g=s.isFixed,A=l.x,x=A===void 0?0:A,b=l.y,S=b===void 0?0:b,w=typeof m=="function"?m({x,y:S}):{x,y:S};x=w.x,S=w.y;var P=l.hasOwnProperty("x"),$=l.hasOwnProperty("y"),N=qi,I=Zi,O=window;if(p){var K=Po(t),U="clientHeight",re="clientWidth";if(K===rr(t)&&(K=ks(t),rs(K).position!=="static"&&h==="absolute"&&(U="scrollHeight",re="scrollWidth")),K=K,n===Zi||(n===qi||n===fr)&&a===Do){I=hr;var ne=g&&K===O&&O.visualViewport?O.visualViewport.height:K[U];S-=ne-i.height,S*=d?1:-1}if(n===qi||(n===Zi||n===hr)&&a===Do){N=fr;var Y=g&&K===O&&O.visualViewport?O.visualViewport.width:K[re];x-=Y-i.width,x*=d?1:-1}}var Ee=Object.assign({position:h},p&&qE),ce=m===!0?QE({x,y:S},rr(t)):{x,y:S};if(x=ce.x,S=ce.y,d){var we;return Object.assign({},Ee,(we={},we[I]=$?"0":"",we[N]=P?"0":"",we.transform=(O.devicePixelRatio||1)<=1?"translate("+x+"px, "+S+"px)":"translate3d("+x+"px, "+S+"px, 0)",we))}return Object.assign({},Ee,(e={},e[I]=$?S+"px":"",e[N]=P?x+"px":"",e.transform="",e))}function JE(s){var e=s.state,t=s.options,i=t.gpuAcceleration,n=i===void 0?!0:i,a=t.adaptive,l=a===void 0?!0:a,h=t.roundOffsets,d=h===void 0?!0:h,p={placement:$r(e.placement),variation:On(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:n,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,op(Object.assign({},p,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:l,roundOffsets:d})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,op(Object.assign({},p,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:d})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const e4={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:JE,data:{}};var el={passive:!0};function t4(s){var e=s.state,t=s.instance,i=s.options,n=i.scroll,a=n===void 0?!0:n,l=i.resize,h=l===void 0?!0:l,d=rr(e.elements.popper),p=[].concat(e.scrollParents.reference,e.scrollParents.popper);return a&&p.forEach(function(m){m.addEventListener("scroll",t.update,el)}),h&&d.addEventListener("resize",t.update,el),function(){a&&p.forEach(function(m){m.removeEventListener("scroll",t.update,el)}),h&&d.removeEventListener("resize",t.update,el)}}const i4={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:t4,data:{}};var r4={left:"right",right:"left",bottom:"top",top:"bottom"};function tl(s){return s.replace(/left|right|bottom|top/g,function(e){return r4[e]})}var s4={start:"end",end:"start"};function ap(s){return s.replace(/start|end/g,function(e){return s4[e]})}function pu(s){var e=rr(s),t=e.pageXOffset,i=e.pageYOffset;return{scrollLeft:t,scrollTop:i}}function mu(s){return Dn(ks(s)).left+pu(s).scrollLeft}function n4(s,e){var t=rr(s),i=ks(s),n=t.visualViewport,a=i.clientWidth,l=i.clientHeight,h=0,d=0;if(n){a=n.width,l=n.height;var p=ep();(p||!p&&e==="fixed")&&(h=n.offsetLeft,d=n.offsetTop)}return{width:a,height:l,x:h+mu(s),y:d}}function o4(s){var e,t=ks(s),i=pu(s),n=(e=s.ownerDocument)==null?void 0:e.body,a=cn(t.scrollWidth,t.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),l=cn(t.scrollHeight,t.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),h=-i.scrollLeft+mu(s),d=-i.scrollTop;return rs(n||t).direction==="rtl"&&(h+=cn(t.clientWidth,n?n.clientWidth:0)-a),{width:a,height:l,x:h,y:d}}function gu(s){var e=rs(s),t=e.overflow,i=e.overflowX,n=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+n+i)}function lp(s){return["html","body","#document"].indexOf(Pr(s))>=0?s.ownerDocument.body:dr(s)&&gu(s)?s:lp(Ja(s))}function Mo(s,e){var t;e===void 0&&(e=[]);var i=lp(s),n=i===((t=s.ownerDocument)==null?void 0:t.body),a=rr(i),l=n?[a].concat(a.visualViewport||[],gu(i)?i:[]):i,h=e.concat(l);return n?h:h.concat(Mo(Ja(l)))}function vu(s){return Object.assign({},s,{left:s.x,top:s.y,right:s.x+s.width,bottom:s.y+s.height})}function a4(s,e){var t=Dn(s,!1,e==="fixed");return t.top=t.top+s.clientTop,t.left=t.left+s.clientLeft,t.bottom=t.top+s.clientHeight,t.right=t.left+s.clientWidth,t.width=s.clientWidth,t.height=s.clientHeight,t.x=t.left,t.y=t.top,t}function cp(s,e,t){return e===Zd?vu(n4(s,t)):ln(e)?a4(e,t):vu(o4(ks(s)))}function l4(s){var e=Mo(Ja(s)),t=["absolute","fixed"].indexOf(rs(s).position)>=0,i=t&&dr(s)?Po(s):s;return ln(i)?e.filter(function(n){return ln(n)&&tp(n,i)&&Pr(n)!=="body"}):[]}function c4(s,e,t,i){var n=e==="clippingParents"?l4(s):[].concat(e),a=[].concat(n,[t]),l=a[0],h=a.reduce(function(d,p){var m=cp(s,p,i);return d.top=cn(m.top,d.top),d.right=Qa(m.right,d.right),d.bottom=Qa(m.bottom,d.bottom),d.left=cn(m.left,d.left),d},cp(s,l,i));return h.width=h.right-h.left,h.height=h.bottom-h.top,h.x=h.left,h.y=h.top,h}function up(s){var e=s.reference,t=s.element,i=s.placement,n=i?$r(i):null,a=i?On(i):null,l=e.x+e.width/2-t.width/2,h=e.y+e.height/2-t.height/2,d;switch(n){case Zi:d={x:l,y:e.y-t.height};break;case hr:d={x:l,y:e.y+e.height};break;case fr:d={x:e.x+e.width,y:h};break;case qi:d={x:e.x-t.width,y:h};break;default:d={x:e.x,y:e.y}}var p=n?du(n):null;if(p!=null){var m=p==="y"?"height":"width";switch(a){case Cn:d[p]=d[p]-(e[m]/2-t[m]/2);break;case Do:d[p]=d[p]+(e[m]/2-t[m]/2);break}}return d}function Fo(s,e){e===void 0&&(e={});var t=e,i=t.placement,n=i===void 0?s.placement:i,a=t.strategy,l=a===void 0?s.strategy:a,h=t.boundary,d=h===void 0?CE:h,p=t.rootBoundary,m=p===void 0?Zd:p,g=t.elementContext,A=g===void 0?Oo:g,x=t.altBoundary,b=x===void 0?!1:x,S=t.padding,w=S===void 0?0:S,P=sp(typeof w!="number"?w:np(w,Io)),$=A===Oo?IE:Oo,N=s.rects.popper,I=s.elements[b?$:A],O=c4(ln(I)?I:I.contextElement||ks(s.elements.popper),d,m,l),K=Dn(s.elements.reference),U=up({reference:K,element:N,strategy:"absolute",placement:n}),re=vu(Object.assign({},N,U)),ne=A===Oo?re:K,Y={top:O.top-ne.top+P.top,bottom:ne.bottom-O.bottom+P.bottom,left:O.left-ne.left+P.left,right:ne.right-O.right+P.right},Ee=s.modifiersData.offset;if(A===Oo&&Ee){var ce=Ee[n];Object.keys(Y).forEach(function(we){var Oe=[fr,hr].indexOf(we)>=0?1:-1,B=[Zi,hr].indexOf(we)>=0?"y":"x";Y[we]+=ce[B]*Oe})}return Y}function u4(s,e){e===void 0&&(e={});var t=e,i=t.placement,n=t.boundary,a=t.rootBoundary,l=t.padding,h=t.flipVariations,d=t.allowedAutoPlacements,p=d===void 0?Qd:d,m=On(i),g=m?h?qd:qd.filter(function(b){return On(b)===m}):Io,A=g.filter(function(b){return p.indexOf(b)>=0});A.length===0&&(A=g);var x=A.reduce(function(b,S){return b[S]=Fo(s,{placement:S,boundary:n,rootBoundary:a,padding:l})[$r(S)],b},{});return Object.keys(x).sort(function(b,S){return x[b]-x[S]})}function h4(s){if($r(s)===cu)return[];var e=tl(s);return[ap(s),e,ap(e)]}function f4(s){var e=s.state,t=s.options,i=s.name;if(!e.modifiersData[i]._skip){for(var n=t.mainAxis,a=n===void 0?!0:n,l=t.altAxis,h=l===void 0?!0:l,d=t.fallbackPlacements,p=t.padding,m=t.boundary,g=t.rootBoundary,A=t.altBoundary,x=t.flipVariations,b=x===void 0?!0:x,S=t.allowedAutoPlacements,w=e.options.placement,P=$r(w),$=P===w,N=d||($||!b?[tl(w)]:h4(w)),I=[w].concat(N).reduce(function(Ue,Ke){return Ue.concat($r(Ke)===cu?u4(e,{placement:Ke,boundary:m,rootBoundary:g,padding:p,flipVariations:b,allowedAutoPlacements:S}):Ke)},[]),O=e.rects.reference,K=e.rects.popper,U=new Map,re=!0,ne=I[0],Y=0;Y<I.length;Y++){var Ee=I[Y],ce=$r(Ee),we=On(Ee)===Cn,Oe=[Zi,hr].indexOf(ce)>=0,B=Oe?"width":"height",W=Fo(e,{placement:Ee,boundary:m,rootBoundary:g,altBoundary:A,padding:p}),ke=Oe?we?fr:qi:we?hr:Zi;O[B]>K[B]&&(ke=tl(ke));var F=tl(ke),G=[];if(a&&G.push(W[ce]<=0),h&&G.push(W[ke]<=0,W[F]<=0),G.every(function(Ue){return Ue})){ne=Ee,re=!1;break}U.set(Ee,G)}if(re)for(var Q=b?3:1,me=function(Ke){var Ze=I.find(function(pt){var ft=U.get(pt);if(ft)return ft.slice(0,Ke).every(function(Kt){return Kt})});if(Ze)return ne=Ze,"break"},pe=Q;pe>0;pe--){var Re=me(pe);if(Re==="break")break}e.placement!==ne&&(e.modifiersData[i]._skip=!0,e.placement=ne,e.reset=!0)}}const d4={name:"flip",enabled:!0,phase:"main",fn:f4,requiresIfExists:["offset"],data:{_skip:!1}};function hp(s,e,t){return t===void 0&&(t={x:0,y:0}),{top:s.top-e.height-t.y,right:s.right-e.width+t.x,bottom:s.bottom-e.height+t.y,left:s.left-e.width-t.x}}function fp(s){return[Zi,fr,hr,qi].some(function(e){return s[e]>=0})}function p4(s){var e=s.state,t=s.name,i=e.rects.reference,n=e.rects.popper,a=e.modifiersData.preventOverflow,l=Fo(e,{elementContext:"reference"}),h=Fo(e,{altBoundary:!0}),d=hp(l,i),p=hp(h,n,a),m=fp(d),g=fp(p);e.modifiersData[t]={referenceClippingOffsets:d,popperEscapeOffsets:p,isReferenceHidden:m,hasPopperEscaped:g},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":m,"data-popper-escaped":g})}const m4={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:p4};function g4(s,e,t){var i=$r(s),n=[qi,Zi].indexOf(i)>=0?-1:1,a=typeof t=="function"?t(Object.assign({},e,{placement:s})):t,l=a[0],h=a[1];return l=l||0,h=(h||0)*n,[qi,fr].indexOf(i)>=0?{x:h,y:l}:{x:l,y:h}}function v4(s){var e=s.state,t=s.options,i=s.name,n=t.offset,a=n===void 0?[0,0]:n,l=Qd.reduce(function(m,g){return m[g]=g4(g,e.rects,a),m},{}),h=l[e.placement],d=h.x,p=h.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=d,e.modifiersData.popperOffsets.y+=p),e.modifiersData[i]=l}const y4={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:v4};function A4(s){var e=s.state,t=s.name;e.modifiersData[t]=up({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const E4={name:"popperOffsets",enabled:!0,phase:"read",fn:A4,data:{}};function x4(s){return s==="x"?"y":"x"}function b4(s){var e=s.state,t=s.options,i=s.name,n=t.mainAxis,a=n===void 0?!0:n,l=t.altAxis,h=l===void 0?!1:l,d=t.boundary,p=t.rootBoundary,m=t.altBoundary,g=t.padding,A=t.tether,x=A===void 0?!0:A,b=t.tetherOffset,S=b===void 0?0:b,w=Fo(e,{boundary:d,rootBoundary:p,padding:g,altBoundary:m}),P=$r(e.placement),$=On(e.placement),N=!$,I=du(P),O=x4(I),K=e.modifiersData.popperOffsets,U=e.rects.reference,re=e.rects.popper,ne=typeof S=="function"?S(Object.assign({},e.rects,{placement:e.placement})):S,Y=typeof ne=="number"?{mainAxis:ne,altAxis:ne}:Object.assign({mainAxis:0,altAxis:0},ne),Ee=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,ce={x:0,y:0};if(K){if(a){var we,Oe=I==="y"?Zi:qi,B=I==="y"?hr:fr,W=I==="y"?"height":"width",ke=K[I],F=ke+w[Oe],G=ke-w[B],Q=x?-re[W]/2:0,me=$===Cn?U[W]:re[W],pe=$===Cn?-re[W]:-U[W],Re=e.elements.arrow,Ue=x&&Re?fu(Re):{width:0,height:0},Ke=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:rp(),Ze=Ke[Oe],pt=Ke[B],ft=$o(0,U[W],Ue[W]),Kt=N?U[W]/2-Q-ft-Ze-Y.mainAxis:me-ft-Ze-Y.mainAxis,_t=N?-U[W]/2+Q+ft+pt+Y.mainAxis:pe+ft+pt+Y.mainAxis,je=e.elements.arrow&&Po(e.elements.arrow),qe=je?I==="y"?je.clientTop||0:je.clientLeft||0:0,Be=(we=Ee==null?void 0:Ee[I])!=null?we:0,ot=ke+Kt-Be-qe,Fe=ke+_t-Be,It=$o(x?Qa(F,ot):F,ke,x?cn(G,Fe):G);K[I]=It,ce[I]=It-ke}if(h){var At,Ut=I==="x"?Zi:qi,ci=I==="x"?hr:fr,st=K[O],Bt=O==="y"?"height":"width",at=st+w[Ut],$t=st-w[ci],Gt=[Zi,qi].indexOf(P)!==-1,Ji=(At=Ee==null?void 0:Ee[O])!=null?At:0,Vt=Gt?at:st-U[Bt]-re[Bt]-Ji+Y.altAxis,Di=Gt?st+U[Bt]+re[Bt]-Ji-Y.altAxis:$t,ns=x&&Gt?KE(Vt,st,Di):$o(x?Vt:at,st,x?Di:$t);K[O]=ns,ce[O]=ns-st}e.modifiersData[i]=ce}}const T4={name:"preventOverflow",enabled:!0,phase:"main",fn:b4,requiresIfExists:["offset"]};function S4(s){return{scrollLeft:s.scrollLeft,scrollTop:s.scrollTop}}function k4(s){return s===rr(s)||!dr(s)?pu(s):S4(s)}function w4(s){var e=s.getBoundingClientRect(),t=In(e.width)/s.offsetWidth||1,i=In(e.height)/s.offsetHeight||1;return t!==1||i!==1}function _4(s,e,t){t===void 0&&(t=!1);var i=dr(e),n=dr(e)&&w4(e),a=ks(e),l=Dn(s,n,t),h={scrollLeft:0,scrollTop:0},d={x:0,y:0};return(i||!i&&!t)&&((Pr(e)!=="body"||gu(a))&&(h=k4(e)),dr(e)?(d=Dn(e,!0),d.x+=e.clientLeft,d.y+=e.clientTop):a&&(d.x=mu(a))),{x:l.left+h.scrollLeft-d.x,y:l.top+h.scrollTop-d.y,width:l.width,height:l.height}}function R4(s){var e=new Map,t=new Set,i=[];s.forEach(function(a){e.set(a.name,a)});function n(a){t.add(a.name);var l=[].concat(a.requires||[],a.requiresIfExists||[]);l.forEach(function(h){if(!t.has(h)){var d=e.get(h);d&&n(d)}}),i.push(a)}return s.forEach(function(a){t.has(a.name)||n(a)}),i}function L4(s){var e=R4(s);return GE.reduce(function(t,i){return t.concat(e.filter(function(n){return n.phase===i}))},[])}function C4(s){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(s())})})),e}}function I4(s){var e=s.reduce(function(t,i){var n=t[i.name];return t[i.name]=n?Object.assign({},n,i,{options:Object.assign({},n.options,i.options),data:Object.assign({},n.data,i.data)}):i,t},{});return Object.keys(e).map(function(t){return e[t]})}var dp={placement:"bottom",modifiers:[],strategy:"absolute"};function pp(){for(var s=arguments.length,e=new Array(s),t=0;t<s;t++)e[t]=arguments[t];return!e.some(function(i){return!(i&&typeof i.getBoundingClientRect=="function")})}function D4(s){s===void 0&&(s={});var e=s,t=e.defaultModifiers,i=t===void 0?[]:t,n=e.defaultOptions,a=n===void 0?dp:n;return function(h,d,p){p===void 0&&(p=a);var m={placement:"bottom",orderedModifiers:[],options:Object.assign({},dp,a),modifiersData:{},elements:{reference:h,popper:d},attributes:{},styles:{}},g=[],A=!1,x={state:m,setOptions:function(P){var $=typeof P=="function"?P(m.options):P;S(),m.options=Object.assign({},a,m.options,$),m.scrollParents={reference:ln(h)?Mo(h):h.contextElement?Mo(h.contextElement):[],popper:Mo(d)};var N=L4(I4([].concat(i,m.options.modifiers)));return m.orderedModifiers=N.filter(function(I){return I.enabled}),b(),x.update()},forceUpdate:function(){if(!A){var P=m.elements,$=P.reference,N=P.popper;if(pp($,N)){m.rects={reference:_4($,Po(N),m.options.strategy==="fixed"),popper:fu(N)},m.reset=!1,m.placement=m.options.placement,m.orderedModifiers.forEach(function(Y){return m.modifiersData[Y.name]=Object.assign({},Y.data)});for(var I=0;I<m.orderedModifiers.length;I++){if(m.reset===!0){m.reset=!1,I=-1;continue}var O=m.orderedModifiers[I],K=O.fn,U=O.options,re=U===void 0?{}:U,ne=O.name;typeof K=="function"&&(m=K({state:m,options:re,name:ne,instance:x})||m)}}}},update:C4(function(){return new Promise(function(w){x.forceUpdate(),w(m)})}),destroy:function(){S(),A=!0}};if(!pp(h,d))return x;x.setOptions(p).then(function(w){!A&&p.onFirstUpdate&&p.onFirstUpdate(w)});function b(){m.orderedModifiers.forEach(function(w){var P=w.name,$=w.options,N=$===void 0?{}:$,I=w.effect;if(typeof I=="function"){var O=I({state:m,name:P,instance:x,options:N}),K=function(){};g.push(O||K)}})}function S(){g.forEach(function(w){return w()}),g=[]}return x}}var O4=[i4,E4,e4,Jd,y4,d4,T4,ZE,m4],P4=D4({defaultModifiers:O4}),$4="tippy-box",mp="tippy-content",M4="tippy-backdrop",gp="tippy-arrow",vp="tippy-svg-arrow",un={passive:!0,capture:!0},yp=function(){return document.body};function yu(s,e,t){if(Array.isArray(s)){var i=s[e];return i??(Array.isArray(t)?t[e]:t)}return s}function Au(s,e){var t={}.toString.call(s);return t.indexOf("[object")===0&&t.indexOf(e+"]")>-1}function Ap(s,e){return typeof s=="function"?s.apply(void 0,e):s}function Ep(s,e){if(e===0)return s;var t;return function(i){clearTimeout(t),t=setTimeout(function(){s(i)},e)}}function F4(s){return s.split(/\s+/).filter(Boolean)}function Pn(s){return[].concat(s)}function xp(s,e){s.indexOf(e)===-1&&s.push(e)}function N4(s){return s.filter(function(e,t){return s.indexOf(e)===t})}function U4(s){return s.split("-")[0]}function il(s){return[].slice.call(s)}function bp(s){return Object.keys(s).reduce(function(e,t){return s[t]!==void 0&&(e[t]=s[t]),e},{})}function No(){return document.createElement("div")}function rl(s){return["Element","Fragment"].some(function(e){return Au(s,e)})}function B4(s){return Au(s,"NodeList")}function G4(s){return Au(s,"MouseEvent")}function V4(s){return!!(s&&s._tippy&&s._tippy.reference===s)}function H4(s){return rl(s)?[s]:B4(s)?il(s):Array.isArray(s)?s:il(document.querySelectorAll(s))}function Eu(s,e){s.forEach(function(t){t&&(t.style.transitionDuration=e+"ms")})}function Tp(s,e){s.forEach(function(t){t&&t.setAttribute("data-state",e)})}function W4(s){var e,t=Pn(s),i=t[0];return i!=null&&(e=i.ownerDocument)!=null&&e.body?i.ownerDocument:document}function j4(s,e){var t=e.clientX,i=e.clientY;return s.every(function(n){var a=n.popperRect,l=n.popperState,h=n.props,d=h.interactiveBorder,p=U4(l.placement),m=l.modifiersData.offset;if(!m)return!0;var g=p==="bottom"?m.top.y:0,A=p==="top"?m.bottom.y:0,x=p==="right"?m.left.x:0,b=p==="left"?m.right.x:0,S=a.top-i+g>d,w=i-a.bottom-A>d,P=a.left-t+x>d,$=t-a.right-b>d;return S||w||P||$})}function xu(s,e,t){var i=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){s[i](n,t)})}function Sp(s,e){for(var t=e;t;){var i;if(s.contains(t))return!0;t=t.getRootNode==null||(i=t.getRootNode())==null?void 0:i.host}return!1}var Mr={isTouch:!1},kp=0;function K4(){Mr.isTouch||(Mr.isTouch=!0,window.performance&&document.addEventListener("mousemove",wp))}function wp(){var s=performance.now();s-kp<20&&(Mr.isTouch=!1,document.removeEventListener("mousemove",wp)),kp=s}function z4(){var s=document.activeElement;if(V4(s)){var e=s._tippy;s.blur&&!e.state.isVisible&&s.blur()}}function Y4(){document.addEventListener("touchstart",K4,un),window.addEventListener("blur",z4)}var X4=typeof window<"u"&&typeof document<"u",Z4=X4?!!window.msCrypto:!1,q4={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},Q4={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Tr=Object.assign({appendTo:yp,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},q4,Q4),J4=Object.keys(Tr),ex=function(e){var t=Object.keys(e);t.forEach(function(i){Tr[i]=e[i]})};function _p(s){var e=s.plugins||[],t=e.reduce(function(i,n){var a=n.name,l=n.defaultValue;if(a){var h;i[a]=s[a]!==void 0?s[a]:(h=Tr[a])!=null?h:l}return i},{});return Object.assign({},s,t)}function tx(s,e){var t=e?Object.keys(_p(Object.assign({},Tr,{plugins:e}))):J4,i=t.reduce(function(n,a){var l=(s.getAttribute("data-tippy-"+a)||"").trim();if(!l)return n;if(a==="content")n[a]=l;else try{n[a]=JSON.parse(l)}catch{n[a]=l}return n},{});return i}function Rp(s,e){var t=Object.assign({},e,{content:Ap(e.content,[s])},e.ignoreAttributes?{}:tx(s,e.plugins));return t.aria=Object.assign({},Tr.aria,t.aria),t.aria={expanded:t.aria.expanded==="auto"?e.interactive:t.aria.expanded,content:t.aria.content==="auto"?e.interactive?null:"describedby":t.aria.content},t}var ix=function(){return"innerHTML"};function bu(s,e){s[ix()]=e}function Lp(s){var e=No();return s===!0?e.className=gp:(e.className=vp,rl(s)?e.appendChild(s):bu(e,s)),e}function Cp(s,e){rl(e.content)?(bu(s,""),s.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?bu(s,e.content):s.textContent=e.content)}function Tu(s){var e=s.firstElementChild,t=il(e.children);return{box:e,content:t.find(function(i){return i.classList.contains(mp)}),arrow:t.find(function(i){return i.classList.contains(gp)||i.classList.contains(vp)}),backdrop:t.find(function(i){return i.classList.contains(M4)})}}function Ip(s){var e=No(),t=No();t.className=$4,t.setAttribute("data-state","hidden"),t.setAttribute("tabindex","-1");var i=No();i.className=mp,i.setAttribute("data-state","hidden"),Cp(i,s.props),e.appendChild(t),t.appendChild(i),n(s.props,s.props);function n(a,l){var h=Tu(e),d=h.box,p=h.content,m=h.arrow;l.theme?d.setAttribute("data-theme",l.theme):d.removeAttribute("data-theme"),typeof l.animation=="string"?d.setAttribute("data-animation",l.animation):d.removeAttribute("data-animation"),l.inertia?d.setAttribute("data-inertia",""):d.removeAttribute("data-inertia"),d.style.maxWidth=typeof l.maxWidth=="number"?l.maxWidth+"px":l.maxWidth,l.role?d.setAttribute("role",l.role):d.removeAttribute("role"),(a.content!==l.content||a.allowHTML!==l.allowHTML)&&Cp(p,s.props),l.arrow?m?a.arrow!==l.arrow&&(d.removeChild(m),d.appendChild(Lp(l.arrow))):d.appendChild(Lp(l.arrow)):m&&d.removeChild(m)}return{popper:e,onUpdate:n}}Ip.$$tippy=!0;var rx=1,sl=[],Su=[];function sx(s,e){var t=Rp(s,Object.assign({},Tr,_p(bp(e)))),i,n,a,l=!1,h=!1,d=!1,p=!1,m,g,A,x=[],b=Ep(ot,t.interactiveDebounce),S,w=rx++,P=null,$=N4(t.plugins),N={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},I={id:w,reference:s,popper:No(),popperInstance:P,props:t,state:N,plugins:$,clearDelayTimeouts:Vt,setProps:Di,setContent:ns,show:ui,hide:Sr,hideWithInteractivity:Ls,enable:Gt,disable:Ji,unmount:Cs,destroy:sr};if(!t.render)return I;var O=t.render(I),K=O.popper,U=O.onUpdate;K.setAttribute("data-tippy-root",""),K.id="tippy-"+I.id,I.popper=K,s._tippy=I,K._tippy=I;var re=$.map(function(ue){return ue.fn(I)}),ne=s.hasAttribute("aria-expanded");return je(),Q(),ke(),F("onCreate",[I]),t.showOnCreate&&at(),K.addEventListener("mouseenter",function(){I.props.interactive&&I.state.isVisible&&I.clearDelayTimeouts()}),K.addEventListener("mouseleave",function(){I.props.interactive&&I.props.trigger.indexOf("mouseenter")>=0&&Oe().addEventListener("mousemove",b)}),I;function Y(){var ue=I.props.touch;return Array.isArray(ue)?ue:[ue,0]}function Ee(){return Y()[0]==="hold"}function ce(){var ue;return!!((ue=I.props.render)!=null&&ue.$$tippy)}function we(){return S||s}function Oe(){var ue=we().parentNode;return ue?W4(ue):document}function B(){return Tu(K)}function W(ue){return I.state.isMounted&&!I.state.isVisible||Mr.isTouch||m&&m.type==="focus"?0:yu(I.props.delay,ue?0:1,Tr.delay)}function ke(ue){ue===void 0&&(ue=!1),K.style.pointerEvents=I.props.interactive&&!ue?"":"none",K.style.zIndex=""+I.props.zIndex}function F(ue,Ve,Qe){if(Qe===void 0&&(Qe=!0),re.forEach(function(ct){ct[ue]&&ct[ue].apply(ct,Ve)}),Qe){var Et;(Et=I.props)[ue].apply(Et,Ve)}}function G(){var ue=I.props.aria;if(ue.content){var Ve="aria-"+ue.content,Qe=K.id,Et=Pn(I.props.triggerTarget||s);Et.forEach(function(ct){var oi=ct.getAttribute(Ve);if(I.state.isVisible)ct.setAttribute(Ve,oi?oi+" "+Qe:Qe);else{var Oi=oi&&oi.replace(Qe,"").trim();Oi?ct.setAttribute(Ve,Oi):ct.removeAttribute(Ve)}})}}function Q(){if(!(ne||!I.props.aria.expanded)){var ue=Pn(I.props.triggerTarget||s);ue.forEach(function(Ve){I.props.interactive?Ve.setAttribute("aria-expanded",I.state.isVisible&&Ve===we()?"true":"false"):Ve.removeAttribute("aria-expanded")})}}function me(){Oe().removeEventListener("mousemove",b),sl=sl.filter(function(ue){return ue!==b})}function pe(ue){if(!(Mr.isTouch&&(d||ue.type==="mousedown"))){var Ve=ue.composedPath&&ue.composedPath()[0]||ue.target;if(!(I.props.interactive&&Sp(K,Ve))){if(Pn(I.props.triggerTarget||s).some(function(Qe){return Sp(Qe,Ve)})){if(Mr.isTouch||I.state.isVisible&&I.props.trigger.indexOf("click")>=0)return}else F("onClickOutside",[I,ue]);I.props.hideOnClick===!0&&(I.clearDelayTimeouts(),I.hide(),h=!0,setTimeout(function(){h=!1}),I.state.isMounted||Ze())}}}function Re(){d=!0}function Ue(){d=!1}function Ke(){var ue=Oe();ue.addEventListener("mousedown",pe,!0),ue.addEventListener("touchend",pe,un),ue.addEventListener("touchstart",Ue,un),ue.addEventListener("touchmove",Re,un)}function Ze(){var ue=Oe();ue.removeEventListener("mousedown",pe,!0),ue.removeEventListener("touchend",pe,un),ue.removeEventListener("touchstart",Ue,un),ue.removeEventListener("touchmove",Re,un)}function pt(ue,Ve){Kt(ue,function(){!I.state.isVisible&&K.parentNode&&K.parentNode.contains(K)&&Ve()})}function ft(ue,Ve){Kt(ue,Ve)}function Kt(ue,Ve){var Qe=B().box;function Et(ct){ct.target===Qe&&(xu(Qe,"remove",Et),Ve())}if(ue===0)return Ve();xu(Qe,"remove",g),xu(Qe,"add",Et),g=Et}function _t(ue,Ve,Qe){Qe===void 0&&(Qe=!1);var Et=Pn(I.props.triggerTarget||s);Et.forEach(function(ct){ct.addEventListener(ue,Ve,Qe),x.push({node:ct,eventType:ue,handler:Ve,options:Qe})})}function je(){Ee()&&(_t("touchstart",Be,{passive:!0}),_t("touchend",Fe,{passive:!0})),F4(I.props.trigger).forEach(function(ue){if(ue!=="manual")switch(_t(ue,Be),ue){case"mouseenter":_t("mouseleave",Fe);break;case"focus":_t(Z4?"focusout":"blur",It);break;case"focusin":_t("focusout",It);break}})}function qe(){x.forEach(function(ue){var Ve=ue.node,Qe=ue.eventType,Et=ue.handler,ct=ue.options;Ve.removeEventListener(Qe,Et,ct)}),x=[]}function Be(ue){var Ve,Qe=!1;if(!(!I.state.isEnabled||At(ue)||h)){var Et=((Ve=m)==null?void 0:Ve.type)==="focus";m=ue,S=ue.currentTarget,Q(),!I.state.isVisible&&G4(ue)&&sl.forEach(function(ct){return ct(ue)}),ue.type==="click"&&(I.props.trigger.indexOf("mouseenter")<0||l)&&I.props.hideOnClick!==!1&&I.state.isVisible?Qe=!0:at(ue),ue.type==="click"&&(l=!Qe),Qe&&!Et&&$t(ue)}}function ot(ue){var Ve=ue.target,Qe=we().contains(Ve)||K.contains(Ve);if(!(ue.type==="mousemove"&&Qe)){var Et=Bt().concat(K).map(function(ct){var oi,Oi=ct._tippy,pr=(oi=Oi.popperInstance)==null?void 0:oi.state;return pr?{popperRect:ct.getBoundingClientRect(),popperState:pr,props:t}:null}).filter(Boolean);j4(Et,ue)&&(me(),$t(ue))}}function Fe(ue){var Ve=At(ue)||I.props.trigger.indexOf("click")>=0&&l;if(!Ve){if(I.props.interactive){I.hideWithInteractivity(ue);return}$t(ue)}}function It(ue){I.props.trigger.indexOf("focusin")<0&&ue.target!==we()||I.props.interactive&&ue.relatedTarget&&K.contains(ue.relatedTarget)||$t(ue)}function At(ue){return Mr.isTouch?Ee()!==ue.type.indexOf("touch")>=0:!1}function Ut(){ci();var ue=I.props,Ve=ue.popperOptions,Qe=ue.placement,Et=ue.offset,ct=ue.getReferenceClientRect,oi=ue.moveTransition,Oi=ce()?Tu(K).arrow:null,pr=ct?{getBoundingClientRect:ct,contextElement:ct.contextElement||we()}:s,os={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Is){var Pi=Is.state;if(ce()){var Ho=B(),vr=Ho.box;["placement","reference-hidden","escaped"].forEach(function(Ds){Ds==="placement"?vr.setAttribute("data-placement",Pi.placement):Pi.attributes.popper["data-popper-"+Ds]?vr.setAttribute("data-"+Ds,""):vr.removeAttribute("data-"+Ds)}),Pi.attributes.popper={}}}},mr=[{name:"offset",options:{offset:Et}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!oi}},os];ce()&&Oi&&mr.push({name:"arrow",options:{element:Oi,padding:3}}),mr.push.apply(mr,(Ve==null?void 0:Ve.modifiers)||[]),I.popperInstance=P4(pr,K,Object.assign({},Ve,{placement:Qe,onFirstUpdate:A,modifiers:mr}))}function ci(){I.popperInstance&&(I.popperInstance.destroy(),I.popperInstance=null)}function st(){var ue=I.props.appendTo,Ve,Qe=we();I.props.interactive&&ue===yp||ue==="parent"?Ve=Qe.parentNode:Ve=Ap(ue,[Qe]),Ve.contains(K)||Ve.appendChild(K),I.state.isMounted=!0,Ut()}function Bt(){return il(K.querySelectorAll("[data-tippy-root]"))}function at(ue){I.clearDelayTimeouts(),ue&&F("onTrigger",[I,ue]),Ke();var Ve=W(!0),Qe=Y(),Et=Qe[0],ct=Qe[1];Mr.isTouch&&Et==="hold"&&ct&&(Ve=ct),Ve?i=setTimeout(function(){I.show()},Ve):I.show()}function $t(ue){if(I.clearDelayTimeouts(),F("onUntrigger",[I,ue]),!I.state.isVisible){Ze();return}if(!(I.props.trigger.indexOf("mouseenter")>=0&&I.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(ue.type)>=0&&l)){var Ve=W(!1);Ve?n=setTimeout(function(){I.state.isVisible&&I.hide()},Ve):a=requestAnimationFrame(function(){I.hide()})}}function Gt(){I.state.isEnabled=!0}function Ji(){I.hide(),I.state.isEnabled=!1}function Vt(){clearTimeout(i),clearTimeout(n),cancelAnimationFrame(a)}function Di(ue){if(!I.state.isDestroyed){F("onBeforeUpdate",[I,ue]),qe();var Ve=I.props,Qe=Rp(s,Object.assign({},Ve,bp(ue),{ignoreAttributes:!0}));I.props=Qe,je(),Ve.interactiveDebounce!==Qe.interactiveDebounce&&(me(),b=Ep(ot,Qe.interactiveDebounce)),Ve.triggerTarget&&!Qe.triggerTarget?Pn(Ve.triggerTarget).forEach(function(Et){Et.removeAttribute("aria-expanded")}):Qe.triggerTarget&&s.removeAttribute("aria-expanded"),Q(),ke(),U&&U(Ve,Qe),I.popperInstance&&(Ut(),Bt().forEach(function(Et){requestAnimationFrame(Et._tippy.popperInstance.forceUpdate)})),F("onAfterUpdate",[I,ue])}}function ns(ue){I.setProps({content:ue})}function ui(){var ue=I.state.isVisible,Ve=I.state.isDestroyed,Qe=!I.state.isEnabled,Et=Mr.isTouch&&!I.props.touch,ct=yu(I.props.duration,0,Tr.duration);if(!(ue||Ve||Qe||Et)&&!we().hasAttribute("disabled")&&(F("onShow",[I],!1),I.props.onShow(I)!==!1)){if(I.state.isVisible=!0,ce()&&(K.style.visibility="visible"),ke(),Ke(),I.state.isMounted||(K.style.transition="none"),ce()){var oi=B(),Oi=oi.box,pr=oi.content;Eu([Oi,pr],0)}A=function(){var mr;if(!(!I.state.isVisible||p)){if(p=!0,K.offsetHeight,K.style.transition=I.props.moveTransition,ce()&&I.props.animation){var gr=B(),Is=gr.box,Pi=gr.content;Eu([Is,Pi],ct),Tp([Is,Pi],"visible")}G(),Q(),xp(Su,I),(mr=I.popperInstance)==null||mr.forceUpdate(),F("onMount",[I]),I.props.animation&&ce()&&ft(ct,function(){I.state.isShown=!0,F("onShown",[I])})}},st()}}function Sr(){var ue=!I.state.isVisible,Ve=I.state.isDestroyed,Qe=!I.state.isEnabled,Et=yu(I.props.duration,1,Tr.duration);if(!(ue||Ve||Qe)&&(F("onHide",[I],!1),I.props.onHide(I)!==!1)){if(I.state.isVisible=!1,I.state.isShown=!1,p=!1,l=!1,ce()&&(K.style.visibility="hidden"),me(),Ze(),ke(!0),ce()){var ct=B(),oi=ct.box,Oi=ct.content;I.props.animation&&(Eu([oi,Oi],Et),Tp([oi,Oi],"hidden"))}G(),Q(),I.props.animation?ce()&&pt(Et,I.unmount):I.unmount()}}function Ls(ue){Oe().addEventListener("mousemove",b),xp(sl,b),b(ue)}function Cs(){I.state.isVisible&&I.hide(),I.state.isMounted&&(ci(),Bt().forEach(function(ue){ue._tippy.unmount()}),K.parentNode&&K.parentNode.removeChild(K),Su=Su.filter(function(ue){return ue!==I}),I.state.isMounted=!1,F("onHidden",[I]))}function sr(){I.state.isDestroyed||(I.clearDelayTimeouts(),I.unmount(),qe(),delete s._tippy,I.state.isDestroyed=!0,F("onDestroy",[I]))}}function hn(s,e){e===void 0&&(e={});var t=Tr.plugins.concat(e.plugins||[]);Y4();var i=Object.assign({},e,{plugins:t}),n=H4(s),a=n.reduce(function(l,h){var d=h&&sx(h,i);return d&&l.push(d),l},[]);return rl(s)?a[0]:a}hn.defaultProps=Tr,hn.setDefaultProps=ex,hn.currentInput=Mr,Object.assign({},Jd,{effect:function(e){var t=e.state,i={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,i.popper),t.styles=i,t.elements.arrow&&Object.assign(t.elements.arrow.style,i.arrow)}}),hn.setDefaultProps({render:Ip});class Fr extends Error{constructor(e,t=new Error,i=!1){super(),this.fatal=!1,this.fatal=i,this.stack=t.stack,this.message=[e,t.message].filter(Boolean).join(" - ")}}const nx=5;class ox{constructor(e){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._canvas=_i(),this._controls=_i(),this.host=e}set activeScenes(e){if(e!==this._activeScenes){const t=e[0],i=this._activeScenes[0];this._activeScenes=e,t!==i&&(this.host.dispatchEvent(new CustomEvent("scenechange",{detail:e[0]})),this.host.requestUpdate())}}get activeScenes(){return this._activeScenes}set currentTime(e){var t,i,n,a,l;const h=Math.min(this.host.duration,Math.max(0,e));this._currentTime=h,this.activeScenes=((t=this.host.scenes)==null?void 0:t.filter(({start:m,duration:g})=>h>=m&&h<m+g))??[],this._upcomingScenes=((i=this.host.scenes)==null?void 0:i.filter(({start:m})=>h>=m-nx&&h<m))??[],this.loadScenes(),this.syncVideoState(),(n=this._controls.value)==null||n.setAttribute("currentTime",h.toString());const d=this.activeScenes[0],p=z0((a=d==null?void 0:d.videoMeta)==null?void 0:a.captions);this.caption=((l=p.find(({start:m,end:g})=>{var A;const x=h-d.start+(((A=d.videoMeta)==null?void 0:A.start)??0);return m&&g&&x>=La(m)&&x<=La(g)}))==null?void 0:l.text)??"",this.draw(h),!this.host.paused&&!this.host.loading&&!this.host.processing&&!this.host.waiting&&this.host.dispatchEvent(new CustomEvent("timeupdate",{detail:h}))}get currentTime(){return this._currentTime}set caption(e){e!==this._caption&&(this._caption=e,this.host.requestUpdate())}get caption(){return this._caption}canvas(){return Ri(this._canvas)}controls(){return Ri(this._controls)}loadScenes(){[...this.activeScenes,...this._upcomingScenes].forEach(e=>{var t,i,n;const{start:a,duration:l,video:h,videoMeta:d}=e,p=this.host.currentTime>0||this.host.preload==="auto"||!this.host.paused;if(h&&d){const{key:m,hls:g,node:A}=h,{start:x,duration:b}=d,S=this.host.videoState[m];A&&S&&(A.currentTime>=x+b||A.ended||p&&(g?(t=g.startLoadOnce)==null||t.call(g,A.currentTime):S.initialised||(i=A.startLoadOnce)==null||i.call(A)))}else if(p){const m=`${a}-${l}`,g=this.host._sceneController.videoState[m];this.host.duration&&!((n=g==null?void 0:g.buffered)!=null&&n.length)&&(this.host._sceneController.videoState={...this.host._sceneController.videoState,[m]:{...g,buffered:[{start:Math.max(0,a/this.host.duration*100),end:Math.min((a+l)/this.host.duration*100,100)}]}})}})}syncVideoState(){var e;(e=this.host.scenes)==null||e.forEach(t=>{if(t.video){const{key:i,node:n}=t.video,a=this.host.videoState[i],l=this.activeScenes.includes(t);if(n&&a)if(l&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(n.paused&&a.initialised)try{return n.play()}catch(h){throw new Fr("Video play error",h,!0)}}else n.paused||n.pause()}})}draw(e=this.currentTime){var t,i;this.host.sceneConfig&&this._canvas.value&&((i=(t=this.host).compilation)==null||i.call(t,{currentTime:e,scenes:this.host.sceneConfig,canvas:this._canvas.value}))}clear(){var e;const t=this._canvas.value;(e=t==null?void 0:t.getContext("2d"))==null||e.clearRect(0,0,t.width,t.height)}}function ax(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function lx(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function ku(s){const{id:e,key:t,src:i,playlist:n,duration:a}=s;return new Promise(l=>{let h=null;const d=document.createElement("video");if(d.playsInline=!0,d.muted=!0,d.loop=!1,n&&!ax()&&is.isSupported()){let p=!1;h=new is({autoStartLoad:!0,xhrSetup:m=>{const{open:g}=m,A=n.split("?")[1];m.open=function(x,b,S){b.toString().includes("?")||(b+="?"+A),g.apply(this,[x,b,S])}}}),h.loadSource(n),h.attachMedia(d),h.startLoadOnce=(m=-1,g)=>{if(h&&!p){const A=h==null?void 0:h.levels.findIndex(x=>Math.min(x.height,x.width)===g);h.startLevel=h.firstLevel,h.startLoad(m),p=!0,h.currentLevel=A!==-1?A:h.firstLevel}},h.on(is.Events.LEVEL_LOADED,async()=>{p||h==null||h.stopLoad(),l({id:e,key:t,hls:h,config:s,node:d})})}else{d.src=i;let p=!1;if(d.startLoadOnce=()=>{p||(d.preload="auto",d.load(),p=!0)},a)d.preload="none",l({id:e,key:t,hls:h,config:s,node:d});else{d.preload="metadata";const m=async()=>{l({id:e,key:t,hls:h,config:s,node:d}),d.removeEventListener("loadedmetadata",m)};d.addEventListener("loadedmetadata",m)}}})}async function Dp(s){return s.duration===1/0?new Promise(e=>{s.currentTime=Number.MAX_SAFE_INTEGER,s.ontimeupdate=()=>{s.ontimeupdate=null,e(s.duration),s.currentTime=0}}):s.duration}const cx=xs(async function(e){return new FontFace(e.name,`url(${e.woff2??e.url})`,{style:e.style,weight:e.weight}).load()},{cacheKey:([s])=>JSON.stringify(s)});let ux=class{constructor(e){this._hasPlayed=!1,this._memoKey=null,this._lastDeps=null,this._duration=0,this._scenes=null,this._videos={},this._videoMeta={},this._videoState={},this._resolveVideo=xs(async t=>{const{id:i,key:n}=t,a=await ku(t);a.node.volume=this.host.volume,a.node.playbackRate=this.host.playbackRate;const l={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},h=Object.keys(l).reduce((d,p)=>{const m=p,g=l[m]({id:i,key:n,node:a.node});return d[m]=g,a.node.addEventListener(p,g),d},{});return{...a,listeners:h}},{cacheKey:([{id:t,key:i,src:n,playlist:a}])=>JSON.stringify({id:t,key:i,src:n==null?void 0:n.split("?")[0],playlist:a==null?void 0:a.split("?")[0]})}),this._resolveVideoMeta=xs(async(t,i)=>{const{id:n,captions:a,duration:l,startOffset:h,endOffset:d}=t,p=l??await Dp(i),m=(h??0)*p,g=(1-(d??0))*p;return{id:n,captions:a,start:m,duration:g-m}},{cacheKey:([{id:t,key:i,captions:n,duration:a,startOffset:l,endOffset:h}])=>JSON.stringify({id:t,key:i,captions:n,duration:a,startOffset:l,endOffset:h})}),this._handleLoadedData=({id:t,key:i,node:n})=>()=>{var a,l;const h=this.videoState[i];if(!(h!=null&&h.initialised)){this.videoState={...this.videoState,[i]:{...h,initialised:!0,waiting:!1,buffered:(h==null?void 0:h.buffered)??[]}};const d=(l=(a=this.scenes)==null?void 0:a.scenes)==null?void 0:l.find(({video:p})=>{p==null||p.key});d&&this._setVideoCurrentTime({scene:d,time:this.host.currentTime}),this.host.dispatchEvent(new CustomEvent("video:loadeddata",{detail:{id:t,key:i,node:n}}))}},this._handleWaiting=({key:t})=>()=>{const i=this.videoState[t];i!=null&&i.initialised&&!(i!=null&&i.waiting)&&(this.videoState={...this.videoState,[t]:{...i,waiting:!0}})},this._handleCanPlay=({key:t})=>()=>{const i=this.videoState[t];i!=null&&i.initialised&&(i!=null&&i.waiting)&&(this.videoState={...this.videoState,[t]:{...i,waiting:!1}}),this.host.paused&&this.host.draw()},this._handleProgress=({key:t,node:i})=>()=>{const n=this.videoState[t],a=this._getBufferSegments({key:t,node:i,duration:this.host.duration});this.videoState={...this.videoState,[t]:{...n,buffered:a}}},this._handleSeeking=({id:t,key:i,node:n})=>()=>{this.host.dispatchEvent(new CustomEvent("video:seeking",{detail:{id:t,key:i,node:n}}))},this._handleSeeked=({id:t,key:i,node:n})=>()=>{const a=this.videoState[i];a!=null&&a.initialised&&(this.host.draw(),this.host.dispatchEvent(new CustomEvent("video:seeked",{detail:{id:t,key:i,node:n}})))},this._handlePlay=({id:t,key:i,node:n})=>()=>{this.hasPlayed=!0,this.host.dispatchEvent(new CustomEvent("video:play",{detail:{id:t,key:i,node:n}}))},this._handlePlaying=({id:t,key:i,node:n})=>()=>{this.host.dispatchEvent(new CustomEvent("video:playing",{detail:{id:t,key:i,node:n}}))},this._handlePause=({id:t,key:i,node:n})=>()=>{this.host.dispatchEvent(new CustomEvent("video:pause",{detail:{id:t,key:i,node:n}}))},this._handleStalled=({id:t,key:i,node:n})=>()=>{this.host.dispatchEvent(new CustomEvent("video:stalled",{detail:{id:t,key:i,node:n}}))},this._handleTimeUpdate=({id:t,key:i,node:n})=>()=>{this.host.dispatchEvent(new CustomEvent("video:timeupdate",{detail:{id:t,key:i,node:n}}))},this._handleEnded=({id:t,key:i,node:n})=>()=>{this.host.dispatchEvent(new CustomEvent("video:ended",{detail:{id:t,key:i,node:n}}))},this._handleError=({id:t,key:i,node:n})=>()=>{const a=new Fr(`Video error - answer ${t} failed to load`);this.host.dispatchEvent(new ErrorEvent("error",{bubbles:!0,composed:!0,error:a,message:a.message})),this.host.dispatchEvent(new CustomEvent("video:error",{detail:{id:t,key:i,node:n}}))},this._cleanupVideo=t=>{var i;const n=this.videos[t];n&&(n.node.pause(),n.node.src="",(i=n.hls)==null||i.destroy(),Object.keys(n.listeners??{}).forEach(a=>{var l,h;if((l=this.videos)!=null&&l[t]){const d=(h=n.listeners)==null?void 0:h[a];d&&n.node.removeEventListener(a,d)}}),delete this.videos[t])},this.host=e,this.host.addController(this)}set hasPlayed(e){e!==this._hasPlayed&&(this._hasPlayed=e,this.host.requestUpdate())}get hasPlayed(){return this._hasPlayed}set duration(e){!isNaN(e)&&e!==this._duration&&(this._duration=e,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(e){e!==this._scenes&&(this._scenes=e,this.host.requestUpdate())}get scenes(){return this._scenes}set videos(e){e!==this._videos&&(this._videos=e,this.host.requestUpdate())}get videos(){return this._videos}set videoMeta(e){e!==this._videoMeta&&(this._videoMeta=e,this.host.requestUpdate())}get videoMeta(){return this._videoMeta}set videoState(e){e!==this._videoState&&(this._videoState=e,this.host.requestUpdate())}get videoState(){return this._videoState}_getBufferSegments({key:e,node:t,duration:i}){var n;const a=t==null?void 0:t.buffered,l=[],{start:h,video:d,videoMeta:p}=((n=this.scenes)==null?void 0:n.scenes.find(({video:m})=>e===(m==null?void 0:m.key)))??{};if(t&&a&&d&&p&&typeof h<"u")for(let m=0;m<a.length;m++){const g=a.start(m),A=a.end(m);Math.max(g,p.start)<=Math.min(A,p.start+p.duration)&&l.push({start:Math.max(0,(Math.max(g-p.start,0)+h)/i*100),end:Math.min((Math.min(A-p.start,p.duration)+h)/i*100,100)})}return l}_setupTask(){new oa(this.host,async([e,t,i,n,a,l])=>{try{let h=null;if(this.host._errors=[],i||e){if(this.host._processing=!0,i){let m=null;if(n)try{m=await(await fetch(n,{method:"GET"})).text()}catch(x){const b=new Fr("Track failed to fetch",x);this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:b,message:b.message}))}const A={questions:{items:[{answer:{id:"source",media:{[i.includes(".m3u8")?"playlist":"video"]:i},captions:{current:m}}}]}};try{this.scenes=await Tn({data:A,template:t,burnCaptions:a,debug:l},this._resolveVideo,this._resolveVideoMeta)}catch(x){try{this.scenes=await Tn({data:A,burnCaptions:a,debug:l},this._resolveVideo,this._resolveVideoMeta)}catch(b){throw new Fr("Fatal source template error",b,!0)}h=new Fr("Source template error",x)}}else try{this.scenes=await Tn({data:e,template:t,burnCaptions:a,debug:l},this._resolveVideo,this._resolveVideoMeta)}catch(m){try{this.scenes=await Tn({data:e,burnCaptions:a,debug:l},this._resolveVideo,this._resolveVideoMeta)}catch(g){throw new Fr("Fatal data template error",g,!0)}h=new Fr("Data template error",m)}Object.keys(this.videos).forEach(m=>{this.scenes.scenes.find(({video:g})=>m===(g==null?void 0:g.key))||this._videos[m].node.pause()});const d=this.scenes.scenes.reduce((m,{video:g})=>(g&&(m[g.key]=g),m),{});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((m,{video:g,start:A,duration:x})=>{var b;const S=(g==null?void 0:g.key)??`${A}-${x}`,w=this._getBufferSegments({key:S,node:g==null?void 0:g.node,duration:this.scenes.duration});return m[S]={initialised:!g,waiting:!!g,...this.videoState[S],buffered:g?w:(b=this.videoState[S])==null?void 0:b.buffered},m},{})},this.videoMeta=this.scenes.scenes.reduce((m,{video:g,videoMeta:A})=>(g&&A&&(m[g.key]=A),m),{}),(await Promise.all(this.scenes.fonts.map(m=>cx(m)))).forEach(m=>{document.fonts.add(m)}),this.duration=this.scenes.duration,this.host.paused&&this.host.reset(this.host.currentTime,!this.host.paused)}h&&this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:h,message:h.message}))}catch(h){this.scenes=null,this.duration=0,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:h,message:h.message}))}finally{this.host._processing=!1}},()=>{const e=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===e)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=e,this._lastDeps=t,t})}_setVideoCurrentTime({time:e,scene:t}){const{start:i,video:n,videoMeta:a}=t;if(n&&n.node&&a&&typeof i<"u"){const l=e-i;n.node.currentTime=Math.max(a.start,Math.min(a.start+a.duration,l+a.start))}}setVideosCurrentTime(e){var t;(t=this.scenes)==null||t.scenes.forEach(i=>{this._setVideoCurrentTime({time:e,scene:i})})}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(e=>{this._cleanupVideo(e)}),this.videos={}}};function hx(s){s.requestFullscreen?s.requestFullscreen():s.mozRequestFullScreen?s.mozRequestFullScreen():s.webkitRequestFullscreen?s.webkitRequestFullscreen():s.msRequestFullscreen&&s.msRequestFullscreen()}function fx(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const wu=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen","preview"],dx={id:"captions",event:"captions:click",label:"Closed Captions"},px={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},Op={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}]},mx={id:"playbackRate",label:"Playback playbackRate",subItems:Op};class gx extends Jh{constructor(e){if(super(e),this.element=null,this.observer=void 0,e.type!==xn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}disconnected(){var e;(e=this.observer)==null||e.disconnect(),this.observer=void 0}reconnected(){var e;this.element&&((e=this.observer)==null||e.observe(this.element))}update(e,[t]){return this.isConnected&&!this.observer&&(this.observer=new ResizeObserver(t),this.element=e.element,this.observer.observe(this.element)),vs}}const _u=bn(gx),vx=LE(()=>{const s=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),e=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-SemiBold.woff2)",{style:"normal",weight:"600"}),t=new FontFace("Roobert Captions","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),i=W0.map(n=>({load:!1,font:new FontFace(n.family,`url(${n.url})`,{style:n.style})}));return[{load:!0,font:s},{load:!0,font:e},{load:!0,font:t},...i]}),Nr={"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"},yx={colors:Nr,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 ${Nr["dark-100"]}`,medium:`0 .125rem .625rem ${Nr["dark-100"]}`,large:`0 .25rem 1rem ${Nr["dark-50"]}`,xl:`.25rem .25rem 1rem ${Nr["dark-250"]}`,xxl:`0 .25rem 2rem ${Nr["dark-100"]}`,xxxl:`.25rem .25rem 3rem ${Nr["dark-250"]}`,toolbar:`0 -.625rem .625rem ${Nr["dark-50"]}`,text:`0 0 .25rem ${Nr["dark-250"]}`},timings:{fast:".1s",normal:".2s",slow:".3s"},easings:{linear:"linear"},focusOutline:{width:".2rem",color:Nr["dark-400"]},iconSizes:{small:"0.75rem",medium:"1rem",large:"1.5rem"}},Pp=wE.flatten(yx,{delimiter:"-"}),Ax=Object.keys(Pp).map(s=>eo(`:host { --${s}: ${Pp[s]}; }`)),Rt=(s=>{class e extends s{firstUpdated(){vx().forEach(({load:n,font:a})=>{document.fonts.add(a),n&&a.load()})}}return e.styles=[(s==null?void 0:s.styles)??[],Ax,Ei`
|
209
|
+
:host {
|
210
|
+
font-family: var(--fontFamilies-sans);
|
211
|
+
font-size: var(--fontSizes-medium);
|
212
|
+
line-height: var(--lineHeights-medium);
|
213
|
+
font-weight: var(--fontWeights-regular);
|
214
|
+
}
|
215
|
+
`,Ei`
|
216
|
+
*,
|
217
|
+
*::before,
|
218
|
+
*::after,
|
219
|
+
::slotted(*) {
|
220
|
+
box-sizing: border-box;
|
221
|
+
}
|
222
|
+
|
223
|
+
body,
|
224
|
+
h1,
|
225
|
+
h2,
|
226
|
+
h3,
|
227
|
+
h4,
|
228
|
+
p,
|
229
|
+
figure,
|
230
|
+
blockquote,
|
231
|
+
dl,
|
232
|
+
dd,
|
233
|
+
::slotted(h1),
|
234
|
+
::slotted(h2),
|
235
|
+
::slotted(h3),
|
236
|
+
::slotted(h4),
|
237
|
+
::slotted(p),
|
238
|
+
::slotted(figure),
|
239
|
+
::slotted(blockquote),
|
240
|
+
::slotted(dl),
|
241
|
+
::slotted(dd) {
|
242
|
+
margin: 0;
|
243
|
+
}
|
244
|
+
|
245
|
+
ul[role='list'],
|
246
|
+
ol[role='list'],
|
247
|
+
::slotted(ul[role='list']),
|
248
|
+
::slotted(ol[role='list']) {
|
249
|
+
list-style: none;
|
250
|
+
}
|
251
|
+
|
252
|
+
a:not([class]),
|
253
|
+
::slotted(a:not([class])) {
|
254
|
+
text-decoration-skip-ink: auto;
|
255
|
+
}
|
256
|
+
|
257
|
+
img,
|
258
|
+
picture,
|
259
|
+
::slotted(img),
|
260
|
+
::slotted(picture) {
|
261
|
+
max-width: 100%;
|
262
|
+
display: block;
|
263
|
+
}
|
264
|
+
|
265
|
+
input,
|
266
|
+
button,
|
267
|
+
textarea,
|
268
|
+
select,
|
269
|
+
::slotted(input),
|
270
|
+
::slotted(button),
|
271
|
+
::slotted(textarea),
|
272
|
+
::slotted(select) {
|
273
|
+
font: inherit;
|
274
|
+
}
|
275
|
+
|
276
|
+
@media (prefers-reduced-motion) {
|
277
|
+
*,
|
278
|
+
*::before,
|
279
|
+
*::after,
|
280
|
+
::slotted(*),
|
281
|
+
::slotted(*::before),
|
282
|
+
::slotted(*::after) {
|
283
|
+
animation-duration: 0.01ms !important;
|
284
|
+
animation-iteration-count: 1 !important;
|
285
|
+
transition-duration: 0.01ms !important;
|
286
|
+
scroll-behavior: auto !important;
|
287
|
+
}
|
288
|
+
}
|
289
|
+
`],e})(En),Ex=(s,e)=>(typeof window<"u"&&(window.customElements.get(s)??window.customElements.define(s,e)),e),xx=(s,e)=>{const{kind:t,elements:i}=e;return{kind:t,elements:i,finisher(n){typeof window<"u"&&(window.customElements.get(s)??window.customElements.define(s,n))}}},Ui=s=>e=>typeof e=="function"?Ex(s,e):xx(s,e);class bx{constructor(e){this._memoKey=null,this._lastDeps=null,this._scenes=null,this._video=null,this._handleSeeked=()=>{this.host._draw()},this._resolveVideo=xs(async t=>{const i=await ku(t);return i.node.play=async()=>{},i.node.addEventListener("seeked",this._handleSeeked),i},{cacheKey:([{id:t,src:i,playlist:n}])=>JSON.stringify({id:t,src:i==null?void 0:i.split("?")[0],playlist:n==null?void 0:n.split("?")[0]})}),this._resolveAnswer=xs(async t=>{const{id:i,key:n,poster:a}=t,{node:l}=await ku(t),h=new Image;return{id:i,key:n,config:t,node:l,getSource:()=>(a&&h.src!==a&&(h.onload=()=>{this.host._draw()},h.src=a),h)}},{cacheKey:([{id:t,src:i,playlist:n,poster:a}])=>JSON.stringify({id:t,src:i==null?void 0:i.split("?")[0],playlist:n==null?void 0:n.split("?")[0],poster:a==null?void 0:a.split("?")[0]})}),this._resolveVideoMeta=xs(async(t,i)=>{const{id:n,duration:a,startOffset:l,endOffset:h}=t,d=a??await Dp(i),p=(l??0)*d,m=(1-(h??0))*d;return{id:n,start:p,duration:m-p}},{cacheKey:([{id:t,duration:i,startOffset:n,endOffset:a}])=>JSON.stringify({id:t,duration:i,startOffset:n,endOffset:a})}),this.host=e,this.host.addController(this)}set scenes(e){e!==this._scenes&&(this._scenes=e,this.host.requestUpdate())}get scenes(){return this._scenes}_setupTask(){new oa(this.host,async([e,t,i])=>{var n,a;try{if(e){const l=e.includes(".m3u8")?"playlist":"video";try{this.scenes=await Tn({data:{questions:{items:[{answer:{id:"source",media:{[l]:e}}}]}},template:i},this._resolveVideo,this._resolveVideoMeta)}catch(h){throw new Fr("Video preview source template error",h)}this._video=((a=(n=this.scenes.scenes[0])==null?void 0:n.video)==null?void 0:a.node)??null}else if(t)try{this.scenes=await Tn({data:t,template:i},this._resolveAnswer,this._resolveVideoMeta)}catch(l){throw new Fr("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 e=JSON.stringify({data:this.host.data,template:this.host.template});if(this._lastDeps&&this._memoKey===e)return this._lastDeps;const t=[this.host.src,this.host.data,this.host.template];return this._memoKey=e,this._lastDeps=t,t})}hostConnected(){this._setupTask()}hostDisconnected(){this._video&&(this._video.pause(),this._video.removeEventListener("seeked",this._handleSeeked),this._video.src="",this._video=null)}}function $p(s,e,t){return Math.min(Math.max(e,s),t)}function Ru(s,e={}){const t=Math.max(0,s||0),i=Math.floor(t/3600),n=Math.floor(t%3600/60),a=Math.floor(t%3600%60),l=Math.floor(t%1*1e3);let h=i?`${i}:${`${n}`.padStart(2,"0")}:${`${a}`.padStart(2,"0")}`:`${n}:${`${a}`.padStart(2,"0")}`;return e.includeMs&&(h+=`:${`${l}`.padStart(3,"0")}`),h}var Tx=Object.defineProperty,Sx=Object.getOwnPropertyDescriptor,$n=(s,e,t,i)=>{for(var n=i>1?void 0:i?Sx(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&Tx(e,t,n),n};let ws=class extends Rt{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return it`<button
|
290
|
+
class=${Qt({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
|
+
>
|
292
|
+
<slot></slot>
|
293
|
+
${this.icon&&it`<vmp-icon icon=${this.icon}></vmp-icon>`}
|
294
|
+
</button>`}};ws.styles=[Rt.styles??[],Ei`
|
295
|
+
:host {
|
296
|
+
--button-padding: var(--vu-button-padding, var(--space-s));
|
297
|
+
--button-color: var(--vu-button-color, var(--colors-dark-640));
|
298
|
+
--button-background: var(--vu-button-background, var(--colors-light-1000));
|
299
|
+
--button-background-hover: var(--vu-button-background-hover, var(--colors-light-1000));
|
300
|
+
|
301
|
+
display: block;
|
302
|
+
}
|
303
|
+
|
304
|
+
button {
|
305
|
+
position: relative;
|
306
|
+
display: flex;
|
307
|
+
align-items: center;
|
308
|
+
justify-content: center;
|
309
|
+
gap: var(--space-xxs);
|
310
|
+
border: none;
|
311
|
+
cursor: pointer;
|
312
|
+
font-weight: var(--fontWeights-semibold);
|
313
|
+
pointer-events: all;
|
314
|
+
transition: background 150ms ease;
|
315
|
+
|
316
|
+
padding: var(--button-padding);
|
317
|
+
color: var(--button-color);
|
318
|
+
background: var(--button-background);
|
319
|
+
padding: var(--button-padding);
|
320
|
+
}
|
321
|
+
|
322
|
+
button:focus {
|
323
|
+
outline: var(--borderWidths-thin) solid var(--colors-dark-1000);
|
324
|
+
}
|
325
|
+
|
326
|
+
.size-tiny {
|
327
|
+
--button-padding: var(--vu-button-padding, var(--space-xxs));
|
328
|
+
min-width: 20px;
|
329
|
+
}
|
330
|
+
|
331
|
+
.size-small {
|
332
|
+
--button-padding: var(--vu-button-padding, 6px);
|
333
|
+
min-width: 32px;
|
334
|
+
}
|
335
|
+
|
336
|
+
.size-large {
|
337
|
+
--button-padding: var(--vu-button-padding, var(--space-small));
|
338
|
+
min-width: 48px;
|
339
|
+
}
|
340
|
+
|
341
|
+
.radius-medium {
|
342
|
+
border-radius: var(--radii-small);
|
343
|
+
}
|
344
|
+
|
345
|
+
.radius-full {
|
346
|
+
border-radius: 100rem;
|
347
|
+
}
|
348
|
+
|
349
|
+
.weight-light {
|
350
|
+
--button-color: var(--vu-button-color, var(--colors-light-1000));
|
351
|
+
--button-background: var(--vu-button-background, transparent);
|
352
|
+
}
|
353
|
+
|
354
|
+
.weight-heavy {
|
355
|
+
--button-color: var(--vu-button-color, var(--colors-dark-640));
|
356
|
+
--button-background: var(--vu-button-background, var(--colors-light-1000));
|
357
|
+
}
|
358
|
+
|
359
|
+
.weight-heavy.active,
|
360
|
+
.weight-heavy:hover,
|
361
|
+
.weight-heavy:focus {
|
362
|
+
--button-background: var(--vu-button-background-hover, #cccccc);
|
363
|
+
}
|
364
|
+
|
365
|
+
.weight-light.active,
|
366
|
+
.weight-light:hover,
|
367
|
+
.weight-light:focus {
|
368
|
+
--button-background: var(--vu-button-background-hover, #9d9d9d);
|
369
|
+
}
|
370
|
+
`],$n([De({type:Boolean})],ws.prototype,"active",2),$n([De({type:String})],ws.prototype,"size",2),$n([De({type:String})],ws.prototype,"rounded",2),$n([De({type:String})],ws.prototype,"weight",2),$n([De({type:String})],ws.prototype,"icon",2),ws=$n([Ui("vmp-button")],ws);const Mp={"arrow-left":()=>it`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
|
371
|
+
<path
|
372
|
+
d="M16.6666 9.21875H6.52492L11.1833 4.85156L9.99992 3.75L3.33325 10L9.99992 16.25L11.1749 15.1484L6.52492 10.7812H16.6666V9.21875Z"
|
373
|
+
fill="currentColor"
|
374
|
+
/>
|
375
|
+
</svg>`,"arrow-right":()=>it`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
|
376
|
+
<path
|
377
|
+
d="M3.75 9.21875H13.2578L8.89062 4.85156L10 3.75L16.25 10L10 16.25L8.89844 15.1484L13.2578 10.7812H3.75V9.21875Z"
|
378
|
+
fill="currentColor"
|
379
|
+
/>
|
380
|
+
</svg>`,"captions-cross":()=>it`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
|
381
|
+
<path
|
382
|
+
d="M17.0625 19.4167L14.3125 16.6667H3.33333C2.875 16.6667 2.4825 16.5036 2.15583 16.1775C1.82972 15.8509 1.66667 15.4584 1.66667 15V4.16669C1.66667 4.13891 1.66667 4.11446 1.66667 4.09335C1.66667 4.0728 1.66667 4.04863 1.66667 4.02085L0.5625 2.91669L1.75 1.72919L18.25 18.2292L17.0625 19.4167ZM18.3333 15.9375L14.7083 12.3125C14.8056 12.2431 14.8786 12.1495 14.9275 12.0317C14.9758 11.9134 15 11.7917 15 11.6667V10.8334H13.75V11.25H13.6458L12.0833 9.68752V8.75002H13.75V9.16669H15V8.33335C15 8.09724 14.92 7.89919 14.76 7.73919C14.6006 7.57974 14.4028 7.50002 14.1667 7.50002H11.6667C11.4306 7.50002 11.2328 7.57974 11.0733 7.73919C10.9133 7.89919 10.8333 8.09724 10.8333 8.33335V8.43752L5.72917 3.33335H16.6667C17.125 3.33335 17.5175 3.49669 17.8442 3.82335C18.1703 4.14946 18.3333 4.54169 18.3333 5.00002V15.9375ZM5.83333 12.5H8.33333C8.56944 12.5 8.7675 12.42 8.9275 12.26C9.08694 12.1006 9.16667 11.9028 9.16667 11.6667V11.5209L8.47917 10.8334H7.91667V11.25H6.25V8.60419L5.3125 7.66669C5.21528 7.73613 5.13889 7.82974 5.08333 7.94752C5.02778 8.06585 5 8.19446 5 8.33335V11.6667C5 11.9028 5.07972 12.1006 5.23917 12.26C5.39917 12.42 5.59722 12.5 5.83333 12.5Z"
|
383
|
+
fill="currentColor"
|
384
|
+
/>
|
385
|
+
</svg>`,captions:()=>it`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
|
386
|
+
<path
|
387
|
+
d="M5.83342 12.5H8.33342C8.56953 12.5 8.76758 12.42 8.92758 12.26C9.08703 12.1005 9.16675 11.9028 9.16675 11.6666V10.8333H7.91675V11.25H6.25008V8.74998H7.91675V9.16665H9.16675V8.33331C9.16675 8.0972 9.08703 7.89915 8.92758 7.73915C8.76758 7.5797 8.56953 7.49998 8.33342 7.49998H5.83342C5.5973 7.49998 5.39925 7.5797 5.23925 7.73915C5.0798 7.89915 5.00008 8.0972 5.00008 8.33331V11.6666C5.00008 11.9028 5.0798 12.1005 5.23925 12.26C5.39925 12.42 5.5973 12.5 5.83342 12.5ZM11.6667 12.5H14.1667C14.4029 12.5 14.6006 12.42 14.7601 12.26C14.9201 12.1005 15.0001 11.9028 15.0001 11.6666V10.8333H13.7501V11.25H12.0834V8.74998H13.7501V9.16665H15.0001V8.33331C15.0001 8.0972 14.9201 7.89915 14.7601 7.73915C14.6006 7.5797 14.4029 7.49998 14.1667 7.49998H11.6667C11.4306 7.49998 11.2329 7.5797 11.0734 7.73915C10.9134 7.89915 10.8334 8.0972 10.8334 8.33331V11.6666C10.8334 11.9028 10.9134 12.1005 11.0734 12.26C11.2329 12.42 11.4306 12.5 11.6667 12.5ZM3.33341 16.6666C2.87508 16.6666 2.48258 16.5036 2.15591 16.1775C1.8298 15.8508 1.66675 15.4583 1.66675 15V4.99998C1.66675 4.54165 1.8298 4.14942 2.15591 3.82331C2.48258 3.49665 2.87508 3.33331 3.33341 3.33331H16.6667C17.1251 3.33331 17.5176 3.49665 17.8442 3.82331C18.1704 4.14942 18.3334 4.54165 18.3334 4.99998V15C18.3334 15.4583 18.1704 15.8508 17.8442 16.1775C17.5176 16.5036 17.1251 16.6666 16.6667 16.6666H3.33341Z"
|
388
|
+
fill="currentColor"
|
389
|
+
/>
|
390
|
+
</svg>`,"chevron-down":()=>it`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" part="svg">
|
391
|
+
<path
|
392
|
+
d="M11.8032 7.13666L10.8632 6.19666L7.80322 9.24999L4.74322 6.19666L3.80322 7.13666L7.80322 11.1367L11.8032 7.13666Z"
|
393
|
+
fill="currentColor"
|
394
|
+
/>
|
395
|
+
</svg>`,close:()=>it`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" part="svg">
|
396
|
+
<path
|
397
|
+
d="M15.8334 5.34163L14.6584 4.16663L10 8.82496L5.34169 4.16663L4.16669 5.34163L8.82502 9.99996L4.16669 14.6583L5.34169 15.8333L10 11.175L14.6584 15.8333L15.8334 14.6583L11.175 9.99996L15.8334 5.34163Z"
|
398
|
+
fill="currentColor"
|
399
|
+
/>
|
400
|
+
</svg>`,error:()=>it`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" part="svg">
|
401
|
+
<path
|
402
|
+
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm1 15h-2v-2h2v2Zm0-4h-2V7h2v6Z"
|
403
|
+
fill="currentColor"
|
404
|
+
/>
|
405
|
+
</svg>`,loading:()=>it`<svg class="spinner" width="50" height="50" viewBox="0 0 50 50" part="svg">
|
406
|
+
<style>
|
407
|
+
/* SVG spinner icon animation */
|
408
|
+
.spinner {
|
409
|
+
-webkit-animation: rotate 2s linear infinite;
|
410
|
+
animation: rotate 2s linear infinite;
|
411
|
+
}
|
412
|
+
|
413
|
+
.spinner .path {
|
414
|
+
stroke: currentColor;
|
415
|
+
stroke-linecap: round;
|
416
|
+
-webkit-animation: dash 1.5s ease-in-out infinite;
|
417
|
+
animation: dash 1.5s ease-in-out infinite;
|
418
|
+
}
|
419
|
+
|
420
|
+
@-webkit-keyframes rotate {
|
421
|
+
100% {
|
422
|
+
-webkit-transform: rotate(360deg);
|
423
|
+
transform: rotate(360deg);
|
424
|
+
}
|
425
|
+
}
|
426
|
+
|
427
|
+
@keyframes rotate {
|
428
|
+
100% {
|
429
|
+
-webkit-transform: rotate(360deg);
|
430
|
+
transform: rotate(360deg);
|
431
|
+
}
|
432
|
+
}
|
433
|
+
|
434
|
+
@-webkit-keyframes dash {
|
435
|
+
0% {
|
436
|
+
stroke-dasharray: 1, 150;
|
437
|
+
stroke-dashoffset: 0;
|
438
|
+
}
|
439
|
+
50% {
|
440
|
+
stroke-dasharray: 90, 150;
|
441
|
+
stroke-dashoffset: -35;
|
442
|
+
}
|
443
|
+
100% {
|
444
|
+
stroke-dasharray: 90, 150;
|
445
|
+
stroke-dashoffset: -124;
|
446
|
+
}
|
447
|
+
}
|
448
|
+
|
449
|
+
@keyframes dash {
|
450
|
+
0% {
|
451
|
+
stroke-dasharray: 1, 150;
|
452
|
+
stroke-dashoffset: 0;
|
453
|
+
}
|
454
|
+
50% {
|
455
|
+
stroke-dasharray: 90, 150;
|
456
|
+
stroke-dashoffset: -35;
|
457
|
+
}
|
458
|
+
100% {
|
459
|
+
stroke-dasharray: 90, 150;
|
460
|
+
stroke-dashoffset: -124;
|
461
|
+
}
|
462
|
+
}
|
463
|
+
</style>
|
464
|
+
<circle class="path" cx="25" cy="25" r="20" fill="none" stroke-width="5" />
|
465
|
+
</svg>`,maximize:()=>it`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
|
466
|
+
<path
|
467
|
+
fill-rule="evenodd"
|
468
|
+
clip-rule="evenodd"
|
469
|
+
d="M6.66675 3.33331H3.33341H1.66675V4.99998V8.33331H3.33341V4.99998H6.66675V3.33331ZM6.66675 15H3.33341V11.6666H1.66675V15V16.6666H3.33341H6.66675V15ZM13.3334 3.33331H16.6667H18.3334V4.99998V8.33331H16.6667V4.99998H13.3334V3.33331ZM16.6667 15H13.3334V16.6666H16.6667H18.3334V15V11.6666H16.6667V15Z"
|
470
|
+
fill="currentColor"
|
471
|
+
/>
|
472
|
+
</svg>`,minimize:()=>it`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
|
473
|
+
<path
|
474
|
+
fill-rule="evenodd"
|
475
|
+
clip-rule="evenodd"
|
476
|
+
d="M5.00008 3.33331H6.66675V6.66665V8.33331H5.00008H1.66675V6.66665H5.00008V3.33331ZM5.00008 11.6666H1.66675V13.3333H5.00008V16.6666H6.66675V13.3333V11.6666H5.00008ZM15.0001 6.66665H18.3334V8.33331H15.0001H13.3334V6.66665V3.33331H15.0001V6.66665ZM18.3334 11.6666H15.0001H13.3334V13.3333V16.6666H15.0001V13.3333H18.3334V11.6666Z"
|
477
|
+
fill="currentColor"
|
478
|
+
/>
|
479
|
+
</svg>`,muted:()=>it`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
|
480
|
+
<path
|
481
|
+
d="M13.75 10C13.75 8.525 12.9 7.25833 11.6667 6.64167V8.48333L13.7083 10.525C13.7333 10.3583 13.75 10.1833 13.75 10ZM15.8333 10C15.8333 10.7833 15.6667 11.5167 15.3833 12.2L16.6417 13.4583C17.1917 12.425 17.5 11.25 17.5 10C17.5 6.43333 15.0083 3.45 11.6667 2.69167V4.40833C14.075 5.125 15.8333 7.35833 15.8333 10ZM3.55833 2.5L2.5 3.55833L6.44167 7.5H2.5V12.5H5.83333L10 16.6667V11.0583L13.5417 14.6C12.9833 15.0333 12.3583 15.375 11.6667 15.5833V17.3C12.8167 17.0417 13.8583 16.5083 14.7417 15.7917L16.4417 17.5L17.5 16.4417L10 8.94167L3.55833 2.5ZM10 3.33333L8.25833 5.075L10 6.81667V3.33333Z"
|
482
|
+
fill="currentColor"
|
483
|
+
/>
|
484
|
+
</svg>`,pause:()=>it`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
|
485
|
+
<path
|
486
|
+
fill-rule="evenodd"
|
487
|
+
clip-rule="evenodd"
|
488
|
+
d="M8.33333 2.5H5V17.5H8.33333V2.5ZM15 2.5H11.6667V17.5H15V2.5Z"
|
489
|
+
fill="currentColor"
|
490
|
+
/>
|
491
|
+
</svg>`,"play-large":()=>it`<svg width="45" height="53" viewBox="0 0 45 53" fill="none" part="svg">
|
492
|
+
<path
|
493
|
+
d="M43.5 23.8319C45.5 25.0083 45.5 27.9492 43.5 29.1256L4.5 52.0647C2.5 53.2411 0 51.7706 0 49.4179V3.53961C0 1.18687 2.5 -0.283582 4.5 0.892785L43.5 23.8319Z"
|
494
|
+
fill="currentColor"
|
495
|
+
/>
|
496
|
+
</svg>`,play:()=>it`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
|
497
|
+
<path d="M17.3803 9.99998L5.83325 16.6666V3.33331L17.3803 9.99998Z" fill="currentColor" />
|
498
|
+
</svg>`,settings:()=>it`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
|
499
|
+
<path
|
500
|
+
d="M7.70833 18.3334L7.375 15.6667C7.19445 15.5972 7.02444 15.5139 6.865 15.4167C6.705 15.3195 6.54861 15.2153 6.39583 15.1042L3.91667 16.1459L1.625 12.1875L3.77083 10.5625C3.75694 10.4653 3.75 10.3714 3.75 10.2809C3.75 10.1909 3.75 10.0972 3.75 10C3.75 9.9028 3.75 9.80891 3.75 9.71835C3.75 9.62835 3.75694 9.53474 3.77083 9.43752L1.625 7.81252L3.91667 3.85419L6.39583 4.89585C6.54861 4.78474 6.70833 4.68058 6.875 4.58335C7.04167 4.48613 7.20833 4.4028 7.375 4.33335L7.70833 1.66669H12.2917L12.625 4.33335C12.8056 4.4028 12.9758 4.48613 13.1358 4.58335C13.2953 4.68058 13.4514 4.78474 13.6042 4.89585L16.0833 3.85419L18.375 7.81252L16.2292 9.43752C16.2431 9.53474 16.25 9.62835 16.25 9.71835C16.25 9.80891 16.25 9.9028 16.25 10C16.25 10.0972 16.25 10.1909 16.25 10.2809C16.25 10.3714 16.2361 10.4653 16.2083 10.5625L18.3542 12.1875L16.0625 16.1459L13.6042 15.1042C13.4514 15.2153 13.2917 15.3195 13.125 15.4167C12.9583 15.5139 12.7917 15.5972 12.625 15.6667L12.2917 18.3334H7.70833ZM10.0417 12.9167C10.8472 12.9167 11.5347 12.632 12.1042 12.0625C12.6736 11.4931 12.9583 10.8056 12.9583 10C12.9583 9.19447 12.6736 8.50696 12.1042 7.93752C11.5347 7.36808 10.8472 7.08335 10.0417 7.08335C9.22222 7.08335 8.53111 7.36808 7.96833 7.93752C7.40611 8.50696 7.125 9.19447 7.125 10C7.125 10.8056 7.40611 11.4931 7.96833 12.0625C8.53111 12.632 9.22222 12.9167 10.0417 12.9167ZM10.0417 11.25C9.69445 11.25 9.39945 11.1284 9.15667 10.885C8.91333 10.6422 8.79167 10.3472 8.79167 10C8.79167 9.6528 8.91333 9.3578 9.15667 9.11502C9.39945 8.87169 9.69445 8.75002 10.0417 8.75002C10.3889 8.75002 10.6842 8.87169 10.9275 9.11502C11.1703 9.3578 11.2917 9.6528 11.2917 10C11.2917 10.3472 11.1703 10.6422 10.9275 10.885C10.6842 11.1284 10.3889 11.25 10.0417 11.25ZM9.16667 16.6667H10.8125L11.1042 14.4584C11.5347 14.3472 11.9342 14.1839 12.3025 13.9684C12.6703 13.7534 13.0069 13.4931 13.3125 13.1875L15.375 14.0417L16.1875 12.625L14.3958 11.2709C14.4653 11.0764 14.5139 10.8714 14.5417 10.6559C14.5694 10.4409 14.5833 10.2222 14.5833 10C14.5833 9.7778 14.5694 9.55891 14.5417 9.34335C14.5139 9.12835 14.4653 8.92363 14.3958 8.72919L16.1875 7.37502L15.375 5.95835L13.3125 6.83335C13.0069 6.51391 12.6703 6.24641 12.3025 6.03085C11.9342 5.81585 11.5347 5.6528 11.1042 5.54169L10.8333 3.33335H9.1875L8.89583 5.54169C8.46528 5.6528 8.06611 5.81585 7.69833 6.03085C7.33 6.24641 6.99306 6.50697 6.6875 6.81252L4.625 5.95835L3.8125 7.37502L5.60417 8.70835C5.53472 8.91669 5.48611 9.12502 5.45833 9.33335C5.43056 9.54169 5.41667 9.76391 5.41667 10C5.41667 10.2222 5.43056 10.4375 5.45833 10.6459C5.48611 10.8542 5.53472 11.0625 5.60417 11.2709L3.8125 12.625L4.625 14.0417L6.6875 13.1667C6.99306 13.4861 7.33 13.7534 7.69833 13.9684C8.06611 14.1839 8.46528 14.3472 8.89583 14.4584L9.16667 16.6667Z"
|
501
|
+
fill="currentColor"
|
502
|
+
/>
|
503
|
+
</svg>`,tick:()=>it`<svg width="20" height="21" viewBox="0 0 20 21" fill="none" part="svg">
|
504
|
+
<path
|
505
|
+
d="M7.50016 14.0001L4.00016 10.5001L2.8335 11.6667L7.50016 16.3334L17.5002 6.33341L16.3335 5.16675L7.50016 14.0001Z"
|
506
|
+
fill="currentColor"
|
507
|
+
/>
|
508
|
+
</svg>`,"volume-high":()=>it`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
|
509
|
+
<path
|
510
|
+
d="M2.5 7.49998V12.5H5.83333L10 16.6667V3.33332L5.83333 7.49998H2.5ZM13.75 9.99998C13.75 8.52498 12.9 7.25832 11.6667 6.64165V13.35C12.9 12.7417 13.75 11.475 13.75 9.99998ZM11.6667 2.69165V4.40832C14.075 5.12498 15.8333 7.35832 15.8333 9.99998C15.8333 12.6417 14.075 14.875 11.6667 15.5917V17.3083C15.0083 16.55 17.5 13.5667 17.5 9.99998C17.5 6.43332 15.0083 3.44998 11.6667 2.69165Z"
|
511
|
+
fill="currentColor"
|
512
|
+
/>
|
513
|
+
</svg>`,"volume-low":()=>it`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
|
514
|
+
<path d="M5.83325 7.49998V12.5H9.16658L13.3333 16.6666V3.33331L9.16658 7.49998H5.83325Z" fill="currentColor" />
|
515
|
+
</svg>`,"volume-medium":()=>it`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
|
516
|
+
<path
|
517
|
+
d="M15.4167 9.99998C15.4167 8.52498 14.5667 7.25831 13.3334 6.64165V13.35C14.5667 12.7416 15.4167 11.475 15.4167 9.99998ZM4.16675 7.49998V12.5H7.50008L11.6667 16.6666V3.33331L7.50008 7.49998H4.16675Z"
|
518
|
+
fill="currentColor"
|
519
|
+
/>
|
520
|
+
</svg>`,vouch:()=>it`<svg
|
521
|
+
xmlns="http://www.w3.org/2000/svg"
|
522
|
+
height="28"
|
523
|
+
width="105"
|
524
|
+
viewBox="0 0 105 28"
|
525
|
+
fill="currentColor"
|
526
|
+
part="svg"
|
527
|
+
>
|
528
|
+
<path
|
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
|
+
/>
|
531
|
+
</svg>`};var kx=Object.defineProperty,wx=Object.getOwnPropertyDescriptor,Fp=(s,e,t,i)=>{for(var n=i>1?void 0:i?wx(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&kx(e,t,n),n};let nl=class extends Rt{render(){return!this.icon||!Object.keys(Mp).includes(this.icon)?null:Mp[this.icon]()}};nl.styles=[Rt.styles??[],Ei`
|
532
|
+
:host {
|
533
|
+
display: flex;
|
534
|
+
align-items: center;
|
535
|
+
justify-content: center;
|
536
|
+
flex-shrink: 0;
|
537
|
+
}
|
538
|
+
`],Fp([De({type:String})],nl.prototype,"icon",2),nl=Fp([Ui("vmp-icon")],nl);var _x=Object.defineProperty,Rx=Object.getOwnPropertyDescriptor,Mn=(s,e,t,i)=>{for(var n=i>1?void 0:i?Rx(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&_x(e,t,n),n};let _s=class extends Rt{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return it`
|
539
|
+
<vmp-button
|
540
|
+
?active=${this.active}
|
541
|
+
size=${qs(this.size)}
|
542
|
+
rounded=${qs(this.rounded)}
|
543
|
+
weight=${qs(this.weight)}
|
544
|
+
>
|
545
|
+
<vmp-icon
|
546
|
+
class=${Qt({tiny:this.size==="tiny",small:this.size==="small",large:this.size==="large"})}
|
547
|
+
icon=${qs(this.icon)}
|
548
|
+
></vmp-icon>
|
549
|
+
</vmp-button>
|
550
|
+
`}};_s.styles=[Rt.styles??[],Ei`
|
551
|
+
.tiny::part(svg) {
|
552
|
+
height: 12px;
|
553
|
+
width: 12px;
|
554
|
+
}
|
555
|
+
|
556
|
+
.small::part(svg) {
|
557
|
+
height: 20px;
|
558
|
+
width: 20px;
|
559
|
+
}
|
560
|
+
|
561
|
+
.large::part(svg) {
|
562
|
+
height: 32px;
|
563
|
+
width: 32px;
|
564
|
+
}
|
565
|
+
`],Mn([De({type:Boolean})],_s.prototype,"active",2),Mn([De({type:String})],_s.prototype,"size",2),Mn([De({type:String})],_s.prototype,"rounded",2),Mn([De({type:String})],_s.prototype,"weight",2),Mn([De({type:String})],_s.prototype,"icon",2),_s=Mn([Ui("vmp-icon-button")],_s);var Lx=Object.defineProperty,Cx=Object.getOwnPropertyDescriptor,Qi=(s,e,t,i)=>{for(var n=i>1?void 0:i?Cx(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&Lx(e,t,n),n};let ss=class extends Rt{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=lc,this._currentTime=0,this._sceneController=new bx(this),this._canvasRef=_i(),this._previewRef=_i(),this._previewTimeRef=_i(),this._handleScrubberMouseEnter=({detail:{x:s,y:e,elementLeft:t,elementRight:i}})=>{var n,a;if((n=this._previewRef)!=null&&n.value){const l=this._previewRef.value.getBoundingClientRect(),h=(a=this._previewRef.value.getRootNode().host)==null?void 0:a.getBoundingClientRect();l&&h&&(this._previewRef.value.style.opacity="1",this._previewRef.value.style.transform=`translate3d(${$p(t-h.left,s-h.left-l.width/2,i-h.left-l.width)}px, ${e-h.top-l.height-28}px, 0)`)}},this._handleScrubberMouseMove=({detail:{time:s,x:e,elementLeft:t,elementRight:i}})=>{var n,a,l,h,d,p,m,g;if(this._currentTime=s,(n=this._sceneController.scenes)!=null&&n.scenes.length){const A=(d=(h=(l=(a=this._sceneController.scenes)==null?void 0:a.scenes)==null?void 0:l.find(({start:x,duration:b,video:S})=>S&&s>=x&&s<=x+b))==null?void 0:h.video)==null?void 0:d.node;if(A&&(A.currentTime=s),this._draw(),(p=this._previewRef)!=null&&p.value){const x=this._previewRef.value.getBoundingClientRect(),b=(m=this._previewRef.value.getRootNode().host)==null?void 0:m.getBoundingClientRect();if(x&&b){const S=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[,w]=Array.from(S.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${$p(t-b.left,e-b.left-x.width/2,i-b.left-x.width)}px, ${w[1]}px, 0)`}}this._previewTimeRef.value&&this._previewTimeRef.value.setAttribute("content",Ru(Math.max(0,Math.min(this._currentTime,(g=this._sceneController.scenes)==null?void 0:g.duration))))}},this._handleScrubberMouseLeave=()=>{var s;(s=this._previewRef)!=null&&s.value&&(this._previewRef.value.style.opacity="0")},this._handleScrubberResize=({detail:{y:s}})=>{var e,t;if((e=this._previewRef)!=null&&e.value){const i=this._previewRef.value.getBoundingClientRect(),n=(t=this._previewRef.value.getRootNode().host)==null?void 0:t.getBoundingClientRect();if(i&&n){const a=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[l]=Array.from(a.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 e,t;this._sceneController.scenes&&this._canvasRef.value&&((t=this.compilation)==null||t.call(this,{currentTime:Math.max(0,Math.min(s,(e=this._sceneController.scenes)==null?void 0:e.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:e,width:t}=cc({resolution:180,aspectRatio:this.aspectRatio}),i=((s=this._sceneController.scenes)==null?void 0:s.scenes.length)??0;return!this.disabled&&(this.src||i>1)?it`
|
566
|
+
<div
|
567
|
+
${Ri(this._previewRef)}
|
568
|
+
class="preview"
|
569
|
+
style=${dc({width:this.aspectRatio>1?"140px":void 0,height:this.aspectRatio<=1?"140px":void 0,aspectRatio:this.aspectRatio})}
|
570
|
+
>
|
571
|
+
<canvas ${Ri(this._canvasRef)} class="preview-canvas" width=${t} height=${e}></canvas>
|
572
|
+
<vmp-text ${Ri(this._previewTimeRef)} class="preview-text" size="small"></vmp-text>
|
573
|
+
</div>
|
574
|
+
`:null}};ss.styles=[Rt.styles??[],Ei`
|
575
|
+
.preview {
|
576
|
+
position: absolute;
|
577
|
+
display: flex;
|
578
|
+
top: 0;
|
579
|
+
left: 0;
|
580
|
+
align-items: center;
|
581
|
+
flex-direction: column;
|
582
|
+
opacity: 0;
|
583
|
+
// Always on top
|
584
|
+
z-index: 2147483647;
|
585
|
+
pointer-events: none;
|
586
|
+
border: 3px solid var(--colors-light-1000);
|
587
|
+
background: var(--colors-dark-1000);
|
588
|
+
border-radius: var(--radii-medium);
|
589
|
+
transition: opacity 150ms ease-out;
|
590
|
+
}
|
591
|
+
|
592
|
+
.preview-canvas {
|
593
|
+
width: 100%;
|
594
|
+
height: 100%;
|
595
|
+
border-radius: var(--radii-small);
|
596
|
+
}
|
597
|
+
|
598
|
+
.preview-text {
|
599
|
+
position: absolute;
|
600
|
+
bottom: 0;
|
601
|
+
transform: translate3d(0, calc(100% + 9px), 0);
|
602
|
+
color: var(--colors-light-1000);
|
603
|
+
font-variant-numeric: tabular-nums;
|
604
|
+
}
|
605
|
+
`],Qi([De({type:String})],ss.prototype,"src",2),Qi([De({type:Object})],ss.prototype,"data",2),Qi([De({type:Object})],ss.prototype,"template",2),Qi([De({type:Boolean})],ss.prototype,"disabled",2),Qi([De({type:Number})],ss.prototype,"aspectRatio",2),Qi([De({attribute:!1})],ss.prototype,"compilation",2),ss=Qi([Ui("vmp-video-preview-content")],ss);let Rs=class extends Rt{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=lc}render(){return it`
|
606
|
+
<vmp-video-preview-content
|
607
|
+
?disabled=${this.disabled}
|
608
|
+
.src=${this.src}
|
609
|
+
.data=${this.data}
|
610
|
+
.template=${this.template}
|
611
|
+
.aspectRatio=${this.aspectRatio}
|
612
|
+
.compilation=${this.compilation}
|
613
|
+
></vmp-video-preview-content>
|
614
|
+
`}};Qi([De({type:String})],Rs.prototype,"src",2),Qi([De({type:Object})],Rs.prototype,"data",2),Qi([De({type:Object})],Rs.prototype,"template",2),Qi([De({type:Boolean})],Rs.prototype,"disabled",2),Qi([De({type:Number})],Rs.prototype,"aspectRatio",2),Qi([De({attribute:!1})],Rs.prototype,"compilation",2),Rs=Qi([Ui("vmp-video-preview")],Rs);class Ix extends co{constructor(e){if(super(e),e.type!==xn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}update(e,[t]){return t==null||t(e.element),vs}}const Np=bn(Ix);class Dx{constructor(e){this.hiddenControls=[],this._measureRef=_i(),this._prevControlsWidth=0,this._hideables={},this._showables={},this._onResize=t=>{var i,n,a;const l=this._measureRef.value,h=(a=(n=(i=t==null?void 0:t[0])==null?void 0:i.borderBoxSize)==null?void 0:n[0])==null?void 0:a.inlineSize;if(l&&h&&h!==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 d=[];for(;l.scrollWidth>l.offsetWidth;){const p=Object.keys(this._hideables).find(g=>this._hideables[g].hideIndex===d.length);if(!p)break;const m=this._hideables[p].element;m&&(m.style.display="none"),d.push(p),Object.keys(this._showables).forEach(g=>{this._showables[g].showOn.some(A=>d.includes(A))&&(this._showables[g].element.style.display="flex")})}this.hiddenControls=d,this._prevControlsWidth=h,this.host.requestUpdate()}},this.host=e}measure(){return Ri(this._measureRef)}contain(){return _u(this._onResize)}hide(e,t){return Np(i=>{this._hideables[e]={element:i,hideIndex:t}})}show(e,t){return Np(i=>{this._showables[e]={element:i,showOn:t}})}}const Lu=".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:translateX(5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=right]{transform:translateX(-5px)}";var Ox=Object.defineProperty,Px=Object.getOwnPropertyDescriptor,Uo=(s,e,t,i)=>{for(var n=i>1?void 0:i?Px(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&Ox(e,t,n),n};let fn=class extends Rt{constructor(){super(...arguments),this.semibold=!1,this.truncate=!1,this.size="medium",this.content=""}render(){return it`
|
615
|
+
<div
|
616
|
+
part="content"
|
617
|
+
class=${Qt({semibold:this.semibold,truncate:this.truncate,[this.size]:!0})}
|
618
|
+
style=${dc({fontFamily:wa({text:this.content,font:"var(--fontFamilies-sans)"})})}
|
619
|
+
>
|
620
|
+
${this.content}
|
621
|
+
</div>
|
622
|
+
`}};fn.styles=[Rt.styles??[],Ei`
|
623
|
+
:host {
|
624
|
+
--text-size: var(--fontSizes-medium);
|
625
|
+
--text-line-height: var(--lineHeights-medium);
|
626
|
+
--text-weight: var(--fontWeights-regular);
|
627
|
+
}
|
628
|
+
|
629
|
+
div {
|
630
|
+
font-size: var(--text-size);
|
631
|
+
line-height: var(--text-line-height);
|
632
|
+
font-weight: var(--text-weight);
|
633
|
+
}
|
634
|
+
|
635
|
+
.small {
|
636
|
+
--text-size: var(--fontSizes-small);
|
637
|
+
--text-line-height: var(--lineHeights-small);
|
638
|
+
}
|
639
|
+
|
640
|
+
.medium {
|
641
|
+
--text-size: var(--fontSizes-medium);
|
642
|
+
--text-line-height: var(--lineHeights-medium);
|
643
|
+
}
|
644
|
+
|
645
|
+
.large {
|
646
|
+
--text-size: var(--fontSizes-large);
|
647
|
+
--text-line-height: var(--lineHeights-large);
|
648
|
+
}
|
649
|
+
|
650
|
+
.semibold {
|
651
|
+
--text-weight: var(--fontWeights-semibold);
|
652
|
+
}
|
653
|
+
|
654
|
+
.truncate {
|
655
|
+
white-space: nowrap;
|
656
|
+
text-overflow: ellipsis;
|
657
|
+
overflow: hidden;
|
658
|
+
}
|
659
|
+
`],Uo([De({type:Boolean})],fn.prototype,"semibold",2),Uo([De({type:Boolean})],fn.prototype,"truncate",2),Uo([De({type:String})],fn.prototype,"size",2),Uo([De({type:String})],fn.prototype,"content",2),fn=Uo([Ui("vmp-text")],fn);var $x=Object.defineProperty,Mx=Object.getOwnPropertyDescriptor,Bo=(s,e,t,i)=>{for(var n=i>1?void 0:i?Mx(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&$x(e,t,n),n};let dn=class extends Rt{constructor(){super(...arguments),this.activeItems=[],this.visibleItems=null,this.subItemsActive=null,this.tippy=null,this._contentRef=_i()}_handleBackClick(){this.subItemsActive=null,this.visibleItems=this.items??null}willUpdate(){this.visibleItems=this.visibleItems??this.items??null}updated(){var s,e;const t=(e=(s=this.items)==null?void 0:s.items.find(({id:i})=>this.subItemsActive===i))==null?void 0:e.subItems;this.visibleItems=t??this.items??null,t||(this.subItemsActive=null)}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var s;const e=(s=this.shadowRoot)==null?void 0:s.querySelector("slot"),t=e==null?void 0:e.assignedElements()[0];t&&this._contentRef.value&&(this.tippy=hn(t,{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,e;return it`
|
660
|
+
<slot></slot>
|
661
|
+
<div ${Ri(this._contentRef)} class="content">
|
662
|
+
<div class="title">
|
663
|
+
${this.subItemsActive?it`
|
664
|
+
<button class="back" @click=${this._handleBackClick}>
|
665
|
+
<vmp-icon icon="chevron-down"></vmp-icon>
|
666
|
+
</button>
|
667
|
+
`:null}
|
668
|
+
<vmp-text
|
669
|
+
?bold=${!0}
|
670
|
+
?truncate=${!0}
|
671
|
+
size="small"
|
672
|
+
.content=${((s=this.visibleItems)==null?void 0:s.title)??"Sub Menu"}
|
673
|
+
></vmp-text>
|
674
|
+
</div>
|
675
|
+
${Xd(((e=this.visibleItems)==null?void 0:e.items)??[],({id:t})=>t,t=>it`
|
676
|
+
<button
|
677
|
+
class="item"
|
678
|
+
@click=${()=>{t.subItems&&(this.subItemsActive=t.id,this.visibleItems=t.subItems),t.event&&this.dispatchEvent(new CustomEvent(t.event,{detail:t,bubbles:!0,composed:!0}))}}
|
679
|
+
>
|
680
|
+
<vmp-text ?semibold=${!0} size="small" content=${t.label}></vmp-text>
|
681
|
+
${t.subItems?it`<vmp-icon class="forward" icon="chevron-down"></vmp-icon>`:this.activeItems.includes(t.id)?it`<vmp-icon icon="tick"></vmp-icon>`:null}
|
682
|
+
</button>
|
683
|
+
`)}
|
684
|
+
</div>
|
685
|
+
`}};dn.styles=[Rt.styles??[],eo(Lu),Ei`
|
686
|
+
:host {
|
687
|
+
display: flex;
|
688
|
+
}
|
689
|
+
|
690
|
+
.content {
|
691
|
+
display: flex;
|
692
|
+
min-width: 140px;
|
693
|
+
overflow: hidden;
|
694
|
+
flex-direction: column;
|
695
|
+
color: var(--colors-dark-1000);
|
696
|
+
background: var(--colors-light-1000);
|
697
|
+
border-radius: var(--radii-medium);
|
698
|
+
transition: height 150ms ease-out;
|
699
|
+
}
|
700
|
+
|
701
|
+
.back {
|
702
|
+
padding: 0;
|
703
|
+
margin: 0;
|
704
|
+
border: 0;
|
705
|
+
cursor: pointer;
|
706
|
+
background: transparent;
|
707
|
+
color: var(--colors-dark-400);
|
708
|
+
/* TODO: Kinda eyeballing this one */
|
709
|
+
margin-left: calc(var(--space-xxs) * -1);
|
710
|
+
transform: rotate(90deg);
|
711
|
+
}
|
712
|
+
|
713
|
+
.forward {
|
714
|
+
transform: rotate(-90deg);
|
715
|
+
}
|
716
|
+
|
717
|
+
.title {
|
718
|
+
display: flex;
|
719
|
+
align-items: center;
|
720
|
+
gap: var(--space-xxs);
|
721
|
+
color: var(--colors-dark-400);
|
722
|
+
text-transform: uppercase;
|
723
|
+
height: 36px;
|
724
|
+
padding: var(--space-small) var(--space-small) var(--space-xxs) var(--space-small);
|
725
|
+
}
|
726
|
+
|
727
|
+
.item {
|
728
|
+
display: flex;
|
729
|
+
align-items: center;
|
730
|
+
justify-content: space-between;
|
731
|
+
height: 42px;
|
732
|
+
border: none;
|
733
|
+
cursor: pointer;
|
734
|
+
color: var(--colors-dark-1000);
|
735
|
+
background: transparent;
|
736
|
+
padding: 0 var(--space-small);
|
737
|
+
}
|
738
|
+
|
739
|
+
.item:hover {
|
740
|
+
background: var(--colors-dark-100);
|
741
|
+
}
|
742
|
+
|
743
|
+
vmp-icon::part(svg) {
|
744
|
+
height: 20px;
|
745
|
+
width: 20px;
|
746
|
+
}
|
747
|
+
`],Bo([De({type:Object})],dn.prototype,"items",2),Bo([De({type:Array})],dn.prototype,"activeItems",2),Bo([xi()],dn.prototype,"visibleItems",2),Bo([xi()],dn.prototype,"subItemsActive",2),dn=Bo([Ui("vmp-menu")],dn);var Fx=Object.defineProperty,Nx=Object.getOwnPropertyDescriptor,Cu=(s,e,t,i)=>{for(var n=i>1?void 0:i?Nx(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&Fx(e,t,n),n};let Go=class extends Rt{constructor(){super(...arguments),this.content="",this.disabled=!1,this.tippy=null,this._contentRef=_i()}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var s;const e=(s=this.shadowRoot)==null?void 0:s.querySelector("slot"),t=e==null?void 0:e.assignedElements()[0];t&&this._contentRef.value&&(this.tippy=hn(t,{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,e;this.disabled?(s=this.tippy)==null||s.disable():(e=this.tippy)==null||e.enable()}render(){return it`
|
748
|
+
<slot></slot>
|
749
|
+
<div ${Ri(this._contentRef)} class="content">
|
750
|
+
<vmp-text content=${this.content}></vmp-text>
|
751
|
+
</div>
|
752
|
+
`}};Go.styles=[Rt.styles??[],eo(Lu),Ei`
|
753
|
+
:host {
|
754
|
+
display: flex;
|
755
|
+
}
|
756
|
+
|
757
|
+
.content {
|
758
|
+
display: flex;
|
759
|
+
align-items: center;
|
760
|
+
justify-content: center;
|
761
|
+
padding: var(--space-small);
|
762
|
+
color: var(--colors-light-1000);
|
763
|
+
background: var(--colors-dark-800);
|
764
|
+
border-radius: var(--radii-medium);
|
765
|
+
}
|
766
|
+
`],Cu([De({type:String})],Go.prototype,"content",2),Cu([De({type:Boolean})],Go.prototype,"disabled",2),Go=Cu([Ui("vmp-tooltip")],Go);var Ux=Object.defineProperty,Bx=Object.getOwnPropertyDescriptor,Iu=(s,e,t,i)=>{for(var n=i>1?void 0:i?Bx(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&Ux(e,t,n),n};let Vo=class extends Rt{constructor(){super(...arguments),this.volume=1,this.muted=!1,this.tippy=null,this._contentRef=_i(),this._anchorRef=_i(),this._menuOpen=!1}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{this._anchorRef.value&&this._contentRef.value&&(this.tippy=hn(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 it`
|
767
|
+
<vmp-icon-button
|
768
|
+
${Ri(this._anchorRef)}
|
769
|
+
icon=${this.muted||this.volume===0?"muted":this.volume<1/3?"volume-low":this.volume<2/3?"volume-medium":"volume-high"}
|
770
|
+
weight="heavy"
|
771
|
+
rounded="full"
|
772
|
+
@pointerdown=${s=>{this._menuOpen&&s.preventDefault()}}
|
773
|
+
@click=${()=>{this._menuOpen&&this.dispatchEvent(new CustomEvent("volume:click",{bubbles:!0,composed:!0,detail:this.muted}))}}
|
774
|
+
></vmp-icon-button>
|
775
|
+
<div ${Ri(this._contentRef)} class="content">
|
776
|
+
<input
|
777
|
+
key="volume"
|
778
|
+
type="range"
|
779
|
+
min="0"
|
780
|
+
max="1"
|
781
|
+
step="0.01"
|
782
|
+
.value=${this.volume.toString()}
|
783
|
+
@blur=${()=>{var s;return(s=this.tippy)==null?void 0:s.hide()}}
|
784
|
+
/>
|
785
|
+
</div>
|
786
|
+
`}};Vo.styles=[Rt.styles??[],eo(Lu),Ei`
|
787
|
+
.content {
|
788
|
+
--volume-slider-height: 4px;
|
789
|
+
--volume-slider-width: 78px;
|
790
|
+
|
791
|
+
display: flex;
|
792
|
+
height: var(--volume-slider-width);
|
793
|
+
width: var(--volume-slider-height);
|
794
|
+
}
|
795
|
+
|
796
|
+
.spacer {
|
797
|
+
display: flex;
|
798
|
+
height: var(--volume-slider-width);
|
799
|
+
width: var(--volume-slider-height);
|
800
|
+
}
|
801
|
+
|
802
|
+
input {
|
803
|
+
position: absolute;
|
804
|
+
appearance: none !important;
|
805
|
+
height: var(--volume-slider-height);
|
806
|
+
width: var(--volume-slider-width);
|
807
|
+
overflow: hidden;
|
808
|
+
border-radius: 1000rem;
|
809
|
+
cursor: pointer;
|
810
|
+
background: var(--colors-light-200);
|
811
|
+
rotate: -90deg;
|
812
|
+
/* Minus the input margin */
|
813
|
+
translate: 0 calc(var(--volume-slider-width) - 4px);
|
814
|
+
transform-origin: left;
|
815
|
+
transition: height 100ms ease-out, transform 100ms ease-out;
|
816
|
+
}
|
817
|
+
|
818
|
+
input:hover {
|
819
|
+
height: calc(var(--volume-slider-height) * 2);
|
820
|
+
}
|
821
|
+
|
822
|
+
input::-webkit-slider-runnable-track {
|
823
|
+
appearance: none !important;
|
824
|
+
height: var(--volume-slider-height);
|
825
|
+
color: var(--colors-light-1000);
|
826
|
+
transition: height 100ms ease-out;
|
827
|
+
}
|
828
|
+
|
829
|
+
input::-moz-range-track {
|
830
|
+
appearance: none !important;
|
831
|
+
height: var(--volume-slider-height);
|
832
|
+
color: var(--colors-light-1000);
|
833
|
+
transition: height 100ms ease-out;
|
834
|
+
}
|
835
|
+
|
836
|
+
input::-ms-track {
|
837
|
+
appearance: none !important;
|
838
|
+
height: var(--volume-slider-height);
|
839
|
+
color: var(--colors-light-1000);
|
840
|
+
transition: height 100ms ease-out;
|
841
|
+
}
|
842
|
+
|
843
|
+
input:hover::-webkit-slider-runnable-track {
|
844
|
+
height: calc(var(--volume-slider-height) * 2);
|
845
|
+
}
|
846
|
+
|
847
|
+
input:hover::-moz-range-track {
|
848
|
+
height: calc(var(--volume-slider-height) * 2);
|
849
|
+
}
|
850
|
+
|
851
|
+
input:hover::-ms-track {
|
852
|
+
height: calc(var(--volume-slider-height) * 2);
|
853
|
+
}
|
854
|
+
|
855
|
+
input::-webkit-slider-thumb {
|
856
|
+
appearance: none !important;
|
857
|
+
height: var(--volume-slider-height) !important;
|
858
|
+
width: var(--volume-slider-height) !important;
|
859
|
+
color: var(--colors-light-1000);
|
860
|
+
border-radius: 50%;
|
861
|
+
border: none;
|
862
|
+
background: var(--colors-light-1000);
|
863
|
+
box-shadow: calc((var(--volume-slider-width) + var(--volume-slider-height) / 2) * -1) 0 0
|
864
|
+
var(--volume-slider-width),
|
865
|
+
calc((var(--volume-slider-width) + var(--volume-slider-height) / 2)) 0 0 var(--volume-slider-width)
|
866
|
+
var(--colors-dark-640);
|
867
|
+
transition: height 100ms ease-out, width 100ms ease-out, box-shadow 100ms ease-out, color 200ms ease-out;
|
868
|
+
}
|
869
|
+
|
870
|
+
input::-moz-range-thumb {
|
871
|
+
appearance: none !important;
|
872
|
+
height: var(--volume-slider-height) !important;
|
873
|
+
width: var(--volume-slider-height) !important;
|
874
|
+
color: var(--colors-light-1000);
|
875
|
+
border-radius: 50%;
|
876
|
+
border: none;
|
877
|
+
background: var(--colors-light-1000);
|
878
|
+
box-shadow: calc((var(--volume-slider-width) + var(--volume-slider-height) / 2) * -1) 0 0
|
879
|
+
var(--volume-slider-width),
|
880
|
+
calc((var(--volume-slider-width) + var(--volume-slider-height) / 2)) 0 0 var(--volume-slider-width)
|
881
|
+
var(--colors-dark-640);
|
882
|
+
transition: height 100ms ease-out, width 100ms ease-out, box-shadow 100ms ease-out, color 200ms ease-out;
|
883
|
+
}
|
884
|
+
|
885
|
+
input::-ms-thumb {
|
886
|
+
appearance: none !important;
|
887
|
+
height: var(--volume-slider-height) !important;
|
888
|
+
width: var(--volume-slider-height) !important;
|
889
|
+
color: var(--colors-light-1000);
|
890
|
+
border-radius: 50%;
|
891
|
+
border: none;
|
892
|
+
background: var(--colors-light-1000);
|
893
|
+
box-shadow: calc((var(--volume-slider-width) + var(--volume-slider-height) / 2) * -1) 0 0
|
894
|
+
var(--volume-slider-width),
|
895
|
+
calc((var(--volume-slider-width) + var(--volume-slider-height) / 2)) 0 0 var(--volume-slider-width)
|
896
|
+
var(--colors-dark-640);
|
897
|
+
transition: height 100ms ease-out, width 100ms ease-out, box-shadow 100ms ease-out, color 200ms ease-out;
|
898
|
+
}
|
899
|
+
|
900
|
+
input:hover::-webkit-slider-thumb {
|
901
|
+
--volume-slider-height: 8px;
|
902
|
+
color: var(--colors-light-800);
|
903
|
+
}
|
904
|
+
|
905
|
+
input:hover::-moz-range-thumb {
|
906
|
+
--volume-slider-height: 8px;
|
907
|
+
color: var(--colors-light-800);
|
908
|
+
}
|
909
|
+
|
910
|
+
input:hover::-ms-thumb {
|
911
|
+
--volume-slider-height: 8px;
|
912
|
+
color: var(--colors-light-800);
|
913
|
+
}
|
914
|
+
`],Iu([De({type:Number})],Vo.prototype,"volume",2),Iu([De({type:Boolean})],Vo.prototype,"muted",2),Vo=Iu([Ui("vmp-volume-button")],Vo);var Gx=Object.defineProperty,Vx=Object.getOwnPropertyDescriptor,ol=(s,e,t,i)=>{for(var n=i>1?void 0:i?Vx(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&Gx(e,t,n),n};let Fn=class extends Rt{constructor(){super(...arguments),this.duration=0,this.currentTime=0,this.buffer=[],this._containerRef=_i(),this._handleContainerResize=()=>{var s;const e=(s=this._containerRef.value)==null?void 0:s.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:resize",{detail:e,bubbles:!0,composed:!0}))},this._handleMouseEnter=s=>{var e;const t=(e=this._containerRef.value)==null?void 0:e.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:mouseenter",{detail:{x:s.clientX,y:s.clientY,elementLeft:(t==null?void 0:t.left)??0,elementRight:(t==null?void 0:t.right)??document.body.offsetWidth},bubbles:!0,composed:!0}))},this._handleMouseMove=s=>{var e;const t=(e=this._containerRef.value)==null?void 0:e.getBoundingClientRect(),n=(s.clientX-((t==null?void 0:t.left)??0))/((t==null?void 0:t.width)??1);this.dispatchEvent(new CustomEvent("scrubber:mousemove",{detail:{x:s.clientX,y:s.clientY,time:n*this.duration,elementLeft:(t==null?void 0:t.left)??0,elementRight:(t==null?void 0:t.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 e=((s=this.buffer)==null?void 0:s.sort((t,i)=>t.start<i.start?-1:i.start<t.start?1:0).reduce((t,{start:i,end:n},a)=>{const l=t[a-1],h=Math.floor(i),d=Math.ceil(n);return t.push({id:i,start:Math.max(0,h),end:Math.min(d,100)}),l&&l.end>=i-1&&(t[a].start=l.end),t},[]))??[];return it`
|
915
|
+
<div
|
916
|
+
class="container"
|
917
|
+
${Ri(this._containerRef)}
|
918
|
+
${_u(this._handleContainerResize)}
|
919
|
+
@mouseenter=${this._handleMouseEnter}
|
920
|
+
@mousemove=${this._handleMouseMove}
|
921
|
+
@mouseleave=${this._handleMouseLeave}
|
922
|
+
>
|
923
|
+
<input
|
924
|
+
key="scrubber"
|
925
|
+
aria-label="Progress scrubber"
|
926
|
+
type="range"
|
927
|
+
min="0"
|
928
|
+
max=${this.duration}
|
929
|
+
step="0.01"
|
930
|
+
.value=${this.currentTime.toString()}
|
931
|
+
data-testid="scrubber"
|
932
|
+
/>
|
933
|
+
${Xd(e,({id:t})=>t,t=>it`
|
934
|
+
<div class="buffer" style=${`left: ${t.start}%; width: ${t.end-t.start}%`}></div>
|
935
|
+
`)}
|
936
|
+
</div>
|
937
|
+
`}};Fn.styles=[Rt.styles??[],Ei`
|
938
|
+
:host {
|
939
|
+
--player-scrubber-height: 8px;
|
940
|
+
--player-scrubber-shadow-width: 4000px;
|
941
|
+
|
942
|
+
display: flex;
|
943
|
+
}
|
944
|
+
|
945
|
+
.container {
|
946
|
+
position: relative;
|
947
|
+
display: flex;
|
948
|
+
width: 100%;
|
949
|
+
opacity: 1;
|
950
|
+
border-radius: 1000rem;
|
951
|
+
overflow: hidden;
|
952
|
+
transition: opacity 150ms ease-out;
|
953
|
+
}
|
954
|
+
|
955
|
+
input {
|
956
|
+
appearance: none !important;
|
957
|
+
height: var(--player-scrubber-height);
|
958
|
+
width: 100%;
|
959
|
+
margin: 0;
|
960
|
+
overflow: hidden;
|
961
|
+
cursor: pointer;
|
962
|
+
background: var(--colors-light-200);
|
963
|
+
transition: height 100ms ease-out, transform 100ms ease-out;
|
964
|
+
}
|
965
|
+
|
966
|
+
.buffer {
|
967
|
+
position: absolute;
|
968
|
+
height: var(--player-scrubber-height);
|
969
|
+
width: var(--player-buffered-percentage);
|
970
|
+
background: var(--colors-light-400);
|
971
|
+
pointer-events: none;
|
972
|
+
transition: height 100ms ease-out, width 250ms ease-out, left 250ms ease-out;
|
973
|
+
}
|
974
|
+
|
975
|
+
.container:hover .buffer {
|
976
|
+
height: calc(var(--player-scrubber-height) * 2);
|
977
|
+
}
|
978
|
+
|
979
|
+
.container:hover input {
|
980
|
+
height: calc(var(--player-scrubber-height) * 2);
|
981
|
+
}
|
982
|
+
|
983
|
+
input::-webkit-slider-runnable-track {
|
984
|
+
appearance: none !important;
|
985
|
+
height: var(--player-scrubber-height);
|
986
|
+
color: var(--colors-light-1000);
|
987
|
+
z-index: 2;
|
988
|
+
transition: height 100ms ease-out;
|
989
|
+
}
|
990
|
+
|
991
|
+
input::-moz-range-track {
|
992
|
+
appearance: none !important;
|
993
|
+
height: var(--player-scrubber-height);
|
994
|
+
color: var(--colors-light-1000);
|
995
|
+
transition: height 100ms ease-out;
|
996
|
+
}
|
997
|
+
|
998
|
+
input::-ms-track {
|
999
|
+
appearance: none !important;
|
1000
|
+
height: var(--player-scrubber-height);
|
1001
|
+
color: var(--colors-light-1000);
|
1002
|
+
transition: height 100ms ease-out;
|
1003
|
+
}
|
1004
|
+
|
1005
|
+
.container:hover input::-webkit-slider-runnable-track {
|
1006
|
+
height: calc(var(--player-scrubber-height) * 2);
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
.container:hover input::-moz-range-track {
|
1010
|
+
height: calc(var(--player-scrubber-height) * 2);
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
.container:hover input::-ms-track {
|
1014
|
+
height: calc(var(--player-scrubber-height) * 2);
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
input::-webkit-slider-thumb {
|
1018
|
+
appearance: none !important;
|
1019
|
+
height: var(--player-scrubber-height) !important;
|
1020
|
+
width: var(--player-scrubber-height) !important;
|
1021
|
+
color: var(--colors-light-1000);
|
1022
|
+
border-radius: 50%;
|
1023
|
+
border: none;
|
1024
|
+
background: var(--colors-light-1000);
|
1025
|
+
box-shadow: calc((var(--player-scrubber-shadow-width) + var(--player-scrubber-height) / 2) * -1) 0 0
|
1026
|
+
var(--player-scrubber-shadow-width);
|
1027
|
+
transition: height 100ms ease-out, width 100ms ease-out, box-shadow 100ms ease-out, color 200ms ease-out;
|
1028
|
+
}
|
1029
|
+
|
1030
|
+
input::-moz-range-thumb {
|
1031
|
+
appearance: none !important;
|
1032
|
+
height: var(--player-scrubber-height) !important;
|
1033
|
+
width: var(--player-scrubber-height) !important;
|
1034
|
+
color: var(--colors-light-1000);
|
1035
|
+
border-radius: 50%;
|
1036
|
+
border: none;
|
1037
|
+
background: var(--colors-light-1000);
|
1038
|
+
box-shadow: calc((var(--player-scrubber-shadow-width) + var(--player-scrubber-height) / 2) * -1) 0 0
|
1039
|
+
var(--player-scrubber-shadow-width);
|
1040
|
+
transition: height 100ms ease-out, width 100ms ease-out, box-shadow 100ms ease-out, color 200ms ease-out;
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
input::-ms-thumb {
|
1044
|
+
appearance: none !important;
|
1045
|
+
height: var(--player-scrubber-height) !important;
|
1046
|
+
width: var(--player-scrubber-height) !important;
|
1047
|
+
color: var(--colors-light-1000);
|
1048
|
+
border-radius: 50%;
|
1049
|
+
border: none;
|
1050
|
+
background: var(--colors-light-1000);
|
1051
|
+
box-shadow: calc((var(--player-scrubber-shadow-width) + var(--player-scrubber-height) / 2) * -1) 0 0
|
1052
|
+
var(--player-scrubber-shadow-width);
|
1053
|
+
transition: height 100ms ease-out, width 100ms ease-out, box-shadow 100ms ease-out, color 200ms ease-out;
|
1054
|
+
}
|
1055
|
+
|
1056
|
+
.container:hover input::-webkit-slider-thumb {
|
1057
|
+
--player-scrubber-height: 16px;
|
1058
|
+
color: var(--colors-light-800);
|
1059
|
+
}
|
1060
|
+
|
1061
|
+
.container:hover input::-moz-range-thumb {
|
1062
|
+
--player-scrubber-height: 16px;
|
1063
|
+
color: var(--colors-light-800);
|
1064
|
+
}
|
1065
|
+
|
1066
|
+
.container:hover input::-ms-thumb {
|
1067
|
+
--player-scrubber-height: 16px;
|
1068
|
+
color: var(--colors-light-800);
|
1069
|
+
}
|
1070
|
+
`],ol([De({type:Number})],Fn.prototype,"duration",2),ol([De({type:Number})],Fn.prototype,"currentTime",2),ol([De({type:Array})],Fn.prototype,"buffer",2),Fn=ol([Ui("vmp-progress-scrubber")],Fn);var Hx=Object.defineProperty,Wx=Object.getOwnPropertyDescriptor,Si=(s,e,t,i)=>{for(var n=i>1?void 0:i?Wx(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&Hx(e,t,n),n};let li=class extends Rt{constructor(){super(...arguments),this.resizeHider=new Dx(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=wu,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,e;(e=Array.from((s=this.shadowRoot)==null?void 0:s.querySelectorAll("vmp-menu, vmp-tooltip, vmp-volume-button")))==null||e.forEach(t=>{var i;(i=t.tippy)==null||i.hide()})}render(){var s,e,t,i,n,a,l,h,d,p,m,g,A;const x=((s=this.levels)==null?void 0:s.map((B,W)=>{const ke=Math.min(B.width,B.height);return{id:`level-${W.toString()}`,event:"level:click",label:`${ke}p`,value:{resolution:ke,level:W}}}))??[],b={title:"Quality",items:[...x.reverse(),{id:"level--1",event:"level:click",label:"Auto",value:{level:-1,resolution:"auto"}}]},S={id:"levels",label:"Quality",subItems:b},w=(e=b.items)==null?void 0:e.find(({value:B})=>B.level===this.level),P=["levels","playback-rate","captions","fullscreen"].filter(B=>{var W;return(W=this.controls)==null?void 0:W.includes(B)}),$={title:"Settings",items:[dx,px,S,mx].filter(({id:B})=>P.includes(B)&&this.resizeHider.hiddenControls.includes(B))},N=(t=this.controls)==null?void 0:t.includes("progress"),I=(i=this.controls)==null?void 0:i.includes("navigation"),O=(n=this.controls)==null?void 0:n.includes("play"),K=(a=this.controls)==null?void 0:a.includes("volume"),U=(l=this.controls)==null?void 0:l.includes("current-time"),re=(h=this.controls)==null?void 0:h.includes("duration"),ne=(d=this.controls)==null?void 0:d.includes("levels"),Y=(p=this.controls)==null?void 0:p.includes("speed"),Ee=(m=this.controls)==null?void 0:m.includes("captions"),ce=(g=this.controls)==null?void 0:g.includes("fullscreen"),we=O||K||U||re||ne||Y||Ee||ce,Oe=[`level-${(A=this.level)==null?void 0:A.toString()}`,`playback-rate-${this.playbackRate.toString()}`,this.captions&&"captions",this.fullscreen&&"fullscreen"].filter(Boolean);return it`
|
1071
|
+
<div
|
1072
|
+
${this.resizeHider.measure()}
|
1073
|
+
${this.resizeHider.contain()}
|
1074
|
+
class=${Qt({container:!0,hidden:!N&&!we})}
|
1075
|
+
>
|
1076
|
+
<div
|
1077
|
+
class=${Qt({"scrubber-container":!0,hidden:!N})}
|
1078
|
+
>
|
1079
|
+
<vmp-progress-scrubber
|
1080
|
+
class=${Qt({scrubber:!0,invisible:this.volumeMenuOpen||this.levelsMenuOpen||this.playbackRateMenuOpen||this.settingsMenuOpen})}
|
1081
|
+
duration=${this.duration}
|
1082
|
+
currentTime=${this.currentTime}
|
1083
|
+
.buffer=${this.buffer}
|
1084
|
+
></vmp-progress-scrubber>
|
1085
|
+
</div>
|
1086
|
+
<div
|
1087
|
+
${this.resizeHider.contain()}
|
1088
|
+
class=${Qt({buttons:!0,hidden:!we})}
|
1089
|
+
>
|
1090
|
+
<div class="section">
|
1091
|
+
<div
|
1092
|
+
${this.resizeHider.hide("navigation",6)}
|
1093
|
+
class=${Qt({navigation:!0,hidden:!I})}
|
1094
|
+
>
|
1095
|
+
<vmp-icon-button
|
1096
|
+
icon="arrow-left"
|
1097
|
+
weight="heavy"
|
1098
|
+
rounded="full"
|
1099
|
+
@click=${this._handleNavigateBackClick}
|
1100
|
+
></vmp-icon-button>
|
1101
|
+
<vmp-icon-button
|
1102
|
+
icon="arrow-right"
|
1103
|
+
weight="heavy"
|
1104
|
+
rounded="full"
|
1105
|
+
@click=${this._handleNavigateForwardClick}
|
1106
|
+
></vmp-icon-button>
|
1107
|
+
</div>
|
1108
|
+
<vmp-icon-button
|
1109
|
+
class=${Qt({hidden:!O})}
|
1110
|
+
icon=${this.playing?"pause":"play"}
|
1111
|
+
weight="heavy"
|
1112
|
+
rounded="full"
|
1113
|
+
data-testid="play"
|
1114
|
+
@click=${this._handlePlayClick}
|
1115
|
+
></vmp-icon-button>
|
1116
|
+
<vmp-volume-button
|
1117
|
+
class=${Qt({hidden:!K})}
|
1118
|
+
?muted=${this.muted}
|
1119
|
+
volume=${this.volume}
|
1120
|
+
@menu:toggle=${this._handleVolumeMenuToggle}
|
1121
|
+
></vmp-volume-button>
|
1122
|
+
<div class="time">
|
1123
|
+
<vmp-text
|
1124
|
+
${this.resizeHider.hide("current-time",1)}
|
1125
|
+
class=${Qt({hidden:!U})}
|
1126
|
+
?semibold=${!0}
|
1127
|
+
content="${Ru(this.currentTime)}${re?"/":null}"
|
1128
|
+
></vmp-text>
|
1129
|
+
<vmp-text
|
1130
|
+
${this.resizeHider.hide("duration",5)}
|
1131
|
+
class=${Qt({hidden:!re})}
|
1132
|
+
?semibold=${!0}
|
1133
|
+
content=${Ru(this.duration)}
|
1134
|
+
></vmp-text>
|
1135
|
+
</div>
|
1136
|
+
</div>
|
1137
|
+
<div class="section">
|
1138
|
+
<vmp-menu
|
1139
|
+
${this.resizeHider.hide("levels",0)}
|
1140
|
+
class=${Qt({hidden:!ne||x.length<=0})}
|
1141
|
+
.items=${b}
|
1142
|
+
.activeItems=${Oe}
|
1143
|
+
@menu:toggle=${this._handleLevelsMenuOpen}
|
1144
|
+
>
|
1145
|
+
<vmp-tooltip content="Quality" ?disabled=${this.levelsMenuOpen}>
|
1146
|
+
<vmp-button ?active=${this.levelsMenuOpen} icon="chevron-down">${w==null?void 0:w.label}</vmp-button>
|
1147
|
+
</vmp-tooltip>
|
1148
|
+
</vmp-menu>
|
1149
|
+
<vmp-menu
|
1150
|
+
${this.resizeHider.hide("playback-rate",4)}
|
1151
|
+
class=${Qt({hidden:!Y})}
|
1152
|
+
.items=${Op}
|
1153
|
+
.activeItems=${Oe}
|
1154
|
+
@menu:toggle=${this._handlePlaybackMenuToggle}
|
1155
|
+
>
|
1156
|
+
<vmp-tooltip content="Playback speed" ?disabled=${this.playbackRateMenuOpen}>
|
1157
|
+
<vmp-button ?active=${this.playbackRateMenuOpen} icon="chevron-down"
|
1158
|
+
>${this.playbackRate.toFixed(1)}x</vmp-button
|
1159
|
+
>
|
1160
|
+
</vmp-tooltip>
|
1161
|
+
</vmp-menu>
|
1162
|
+
<vmp-tooltip
|
1163
|
+
${this.resizeHider.hide("captions",3)}
|
1164
|
+
class=${Qt({hidden:!Ee})}
|
1165
|
+
content="Captions"
|
1166
|
+
>
|
1167
|
+
<vmp-icon-button
|
1168
|
+
?active=${this.captions}
|
1169
|
+
icon=${this.captions?"captions":"captions-cross"}
|
1170
|
+
rounded="full"
|
1171
|
+
@click=${this._handleCaptionsClick}
|
1172
|
+
></vmp-icon-button>
|
1173
|
+
</vmp-tooltip>
|
1174
|
+
<vmp-tooltip
|
1175
|
+
${this.resizeHider.hide("fullscreen",2)}
|
1176
|
+
content="Fullscreen"
|
1177
|
+
class=${Qt({hidden:!ce})}
|
1178
|
+
>
|
1179
|
+
<vmp-icon-button
|
1180
|
+
?active=${this.fullscreen}
|
1181
|
+
icon=${this.fullscreen?"minimize":"maximize"}
|
1182
|
+
rounded="full"
|
1183
|
+
data-testid="fullscreen"
|
1184
|
+
@click=${this._handleFullscreenClick}
|
1185
|
+
></vmp-icon-button>
|
1186
|
+
</vmp-tooltip>
|
1187
|
+
<vmp-menu
|
1188
|
+
${this.resizeHider.show("settings",["levels","playback-rate","captions","fullscreen"])}
|
1189
|
+
.items=${$}
|
1190
|
+
.activeItems=${Oe}
|
1191
|
+
@menu:toggle=${this._handleSettingsMenuToggle}
|
1192
|
+
>
|
1193
|
+
<vmp-tooltip content="Settings" ?disabled=${this.settingsMenuOpen}>
|
1194
|
+
<vmp-icon-button ?active=${this.settingsMenuOpen} icon="settings" rounded="full"></vmp-icon-button>
|
1195
|
+
</vmp-tooltip>
|
1196
|
+
</vmp-menu>
|
1197
|
+
</div>
|
1198
|
+
</div>
|
1199
|
+
</div>
|
1200
|
+
`}};li.styles=[Rt.styles??[],Ei`
|
1201
|
+
:host {
|
1202
|
+
--controls-border-radius: var(--player-border-radius, 0px);
|
1203
|
+
|
1204
|
+
display: flex;
|
1205
|
+
width: 100%;
|
1206
|
+
isolation: isolate;
|
1207
|
+
}
|
1208
|
+
|
1209
|
+
.container {
|
1210
|
+
display: flex;
|
1211
|
+
flex-direction: column;
|
1212
|
+
gap: var(--space-small);
|
1213
|
+
flex: 1;
|
1214
|
+
min-width: 0;
|
1215
|
+
overflow: auto;
|
1216
|
+
padding: var(--space-xl) var(--space-xs) var(--space-xs) var(--space-xs);
|
1217
|
+
background: linear-gradient(to bottom, transparent 20%, var(--colors-dark-800) 100%);
|
1218
|
+
border-radius: var(--controls-border-radius);
|
1219
|
+
border-top-left-radius: 0;
|
1220
|
+
border-top-right-radius: 0;
|
1221
|
+
}
|
1222
|
+
|
1223
|
+
.buttons {
|
1224
|
+
display: flex;
|
1225
|
+
justify-content: space-between;
|
1226
|
+
gap: var(--space-xs);
|
1227
|
+
width: max-content;
|
1228
|
+
min-width: 100%;
|
1229
|
+
}
|
1230
|
+
|
1231
|
+
.section {
|
1232
|
+
display: flex;
|
1233
|
+
gap: var(--space-xs);
|
1234
|
+
}
|
1235
|
+
|
1236
|
+
.scrubber-container {
|
1237
|
+
position: relative;
|
1238
|
+
display: flex;
|
1239
|
+
height: 8px;
|
1240
|
+
}
|
1241
|
+
|
1242
|
+
.scrubber {
|
1243
|
+
position: absolute;
|
1244
|
+
width: 100%;
|
1245
|
+
bottom: 0;
|
1246
|
+
transition: opacity 150ms ease-out;
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
.invisible {
|
1250
|
+
opacity: 0;
|
1251
|
+
pointer-events: none;
|
1252
|
+
}
|
1253
|
+
|
1254
|
+
.navigation {
|
1255
|
+
display: flex;
|
1256
|
+
background: var(--colors-light-1000);
|
1257
|
+
border-radius: 1000rem;
|
1258
|
+
}
|
1259
|
+
|
1260
|
+
.time {
|
1261
|
+
display: flex;
|
1262
|
+
align-items: center;
|
1263
|
+
color: var(--colors-light-1000);
|
1264
|
+
white-space: nowrap;
|
1265
|
+
font-variant-numeric: tabular-nums;
|
1266
|
+
}
|
1267
|
+
|
1268
|
+
.hidden {
|
1269
|
+
display: none;
|
1270
|
+
}
|
1271
|
+
`],Si([De({type:Boolean})],li.prototype,"playing",2),Si([De({type:Number})],li.prototype,"volume",2),Si([De({type:Boolean})],li.prototype,"muted",2),Si([De({type:Number})],li.prototype,"currentTime",2),Si([De({type:Number})],li.prototype,"duration",2),Si([De({type:Number})],li.prototype,"level",2),Si([De({type:Number})],li.prototype,"playbackRate",2),Si([De({type:Array})],li.prototype,"buffer",2),Si([De({type:Array,attribute:!1})],li.prototype,"levels",2),Si([De({type:Boolean})],li.prototype,"captions",2),Si([De({type:Boolean})],li.prototype,"fullscreen",2),Si([De({type:Array})],li.prototype,"controls",2),Si([xi()],li.prototype,"volumeMenuOpen",2),Si([xi()],li.prototype,"levelsMenuOpen",2),Si([xi()],li.prototype,"playbackRateMenuOpen",2),Si([xi()],li.prototype,"settingsMenuOpen",2),li=Si([Ui("vmp-player-controls")],li);var jx=Object.defineProperty,Kx=Object.getOwnPropertyDescriptor,zx=(s,e,t,i)=>{for(var n=i>1?void 0:i?Kx(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&jx(e,t,n),n};let Du=class extends Rt{render(){return it`<vmp-icon icon="loading"></vmp-icon>`}};Du.styles=[Rt.styles??[],Ei`
|
1272
|
+
:host {
|
1273
|
+
display: flex;
|
1274
|
+
align-items: center;
|
1275
|
+
justify-content: center;
|
1276
|
+
}
|
1277
|
+
`],Du=zx([Ui("vmp-loading-spinner")],Du);var Yx=Object.defineProperty,Xx=Object.getOwnPropertyDescriptor,Up=(s,e,t,i)=>{for(var n=i>1?void 0:i?Xx(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&Yx(e,t,n),n};let al=class extends Rt{constructor(){super(...arguments),this.caption=""}render(){return it`
|
1278
|
+
<div class="container">
|
1279
|
+
<vmp-text content=${this.caption} size="large"></vmp-text>
|
1280
|
+
</div>
|
1281
|
+
`}};al.styles=[Rt.styles??[],Ei`
|
1282
|
+
.container {
|
1283
|
+
display: block;
|
1284
|
+
margin: 0 var(--space-small);
|
1285
|
+
text-align: center;
|
1286
|
+
}
|
1287
|
+
|
1288
|
+
vmp-text::part(content) {
|
1289
|
+
display: inline;
|
1290
|
+
padding: var(--space-xxs) var(--space-xs);
|
1291
|
+
text-align: center;
|
1292
|
+
border-radius: var(--radii-small);
|
1293
|
+
box-decoration-break: clone;
|
1294
|
+
-webkit-box-decoration-break: clone;
|
1295
|
+
color: var(--colors-light-1000);
|
1296
|
+
background: var(--colors-dark-800);
|
1297
|
+
/* Line height controls the spacing between the cloned boxes so has to override the default */
|
1298
|
+
line-height: 2.2;
|
1299
|
+
}
|
1300
|
+
`],Up([De({type:String})],al.prototype,"caption",2),al=Up([Ui("vmp-captions")],al);var Zx=Object.defineProperty,qx=Object.getOwnPropertyDescriptor,Ii=(s,e,t,i)=>{for(var n=i>1?void 0:i?qx(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&Zx(e,t,n),n};const Qx=3e3;let pi=class extends Rt{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=wu,this.showControls=!0,this._hasTouched=!1,this._playerControlsRef=_i()}_startHideControls(){clearTimeout(this._controlHideTimeout),this._controlHideTimeout=setTimeout(()=>{this.showControls=!1,this._hasTouched=!1},Qx)}_immediateShowControls(){this.showControls=!0,clearTimeout(this._controlHideTimeout)}_immediateHideControls(){this.showControls=!1,this._hasTouched=!1,clearTimeout(this._controlHideTimeout)}willUpdate(s){var e;s.has("playing")&&this.playing&&this._startHideControls(),s.has("showControls")&&this.playing&&!this.showControls&&((e=this._playerControlsRef.value)==null||e.hideMenus())}render(){var s;const e=(s=this.controls)==null?void 0:s.includes("play-large"),t=this.playing&&!this.showControls,i=!!(e&&!this.playing);return it`
|
1301
|
+
<div
|
1302
|
+
class=${Qt({container:!0,hide:t})}
|
1303
|
+
@mousemove=${()=>{this._immediateShowControls(),this._startHideControls()}}
|
1304
|
+
@mouseleave=${this._immediateHideControls}
|
1305
|
+
@touchstart=${n=>{this.playing&&!this.showControls&&!this._hasTouched&&(n.preventDefault(),this._hasTouched=!0,this._immediateShowControls(),this._startHideControls())}}
|
1306
|
+
>
|
1307
|
+
<div
|
1308
|
+
class=${Qt({fixtures:!0,invisible:!this.loading&&!i})}
|
1309
|
+
@click=${()=>{this.showControls&&this.dispatchEvent(new CustomEvent("play:click",{bubbles:!0,composed:!0,detail:this.playing}))}}
|
1310
|
+
>
|
1311
|
+
<vmp-icon
|
1312
|
+
class=${Qt({hidden:!i})}
|
1313
|
+
icon="play-large"
|
1314
|
+
></vmp-icon>
|
1315
|
+
<vmp-loading-spinner
|
1316
|
+
class=${Qt({hidden:!this.loading||i})}
|
1317
|
+
></vmp-loading-spinner>
|
1318
|
+
</div>
|
1319
|
+
<div
|
1320
|
+
class=${Qt({controls:!0,hide:t})}
|
1321
|
+
@focusin=${this._immediateShowControls}
|
1322
|
+
@mousemove=${n=>{n.stopPropagation(),this._immediateShowControls()}}
|
1323
|
+
@click=${this._immediateShowControls}
|
1324
|
+
>
|
1325
|
+
${this.captions?it`<vmp-captions
|
1326
|
+
class=${Qt({hidden:!this.caption,hiddenControls:t})}
|
1327
|
+
caption=${this.caption}
|
1328
|
+
></vmp-captions>`:null}
|
1329
|
+
<vmp-player-controls
|
1330
|
+
${Ri(this._playerControlsRef)}
|
1331
|
+
?playing=${this.playing}
|
1332
|
+
?muted=${this.muted}
|
1333
|
+
volume=${this.volume}
|
1334
|
+
currentTime=${this.currentTime}
|
1335
|
+
duration=${this.duration}
|
1336
|
+
.levels=${this.levels}
|
1337
|
+
.level=${this.level}
|
1338
|
+
playbackRate=${this.playbackRate}
|
1339
|
+
.buffer=${this.buffer}
|
1340
|
+
.controls=${this.controls}
|
1341
|
+
?captions=${this.captions}
|
1342
|
+
?fullscreen=${this.fullscreen}
|
1343
|
+
></vmp-player-controls>
|
1344
|
+
</div>
|
1345
|
+
</div>
|
1346
|
+
`}};pi.styles=[Rt.styles??[],Ei`
|
1347
|
+
:host {
|
1348
|
+
--overlay-border-radius: var(--player-border-radius, 0px);
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
.container {
|
1352
|
+
position: relative;
|
1353
|
+
display: flex;
|
1354
|
+
justify-content: space-between;
|
1355
|
+
height: 100%;
|
1356
|
+
width: 100%;
|
1357
|
+
overflow: hidden;
|
1358
|
+
border-radius: var(--overlay-border-radius);
|
1359
|
+
}
|
1360
|
+
|
1361
|
+
.container.hide {
|
1362
|
+
cursor: none;
|
1363
|
+
}
|
1364
|
+
|
1365
|
+
.fixtures {
|
1366
|
+
position: absolute;
|
1367
|
+
top: 0;
|
1368
|
+
left: 0;
|
1369
|
+
right: 0;
|
1370
|
+
bottom: 0;
|
1371
|
+
display: flex;
|
1372
|
+
align-items: center;
|
1373
|
+
justify-content: center;
|
1374
|
+
opacity: 1;
|
1375
|
+
color: var(--colors-light-1000);
|
1376
|
+
background: var(--colors-dark-200);
|
1377
|
+
border-radius: var(--overlay-border-radius);
|
1378
|
+
transition: opacity 150ms ease-out;
|
1379
|
+
}
|
1380
|
+
|
1381
|
+
.hidden {
|
1382
|
+
display: none;
|
1383
|
+
}
|
1384
|
+
|
1385
|
+
.invisible {
|
1386
|
+
opacity: 0;
|
1387
|
+
}
|
1388
|
+
|
1389
|
+
.controls {
|
1390
|
+
position: relative;
|
1391
|
+
display: flex;
|
1392
|
+
flex-direction: column;
|
1393
|
+
align-self: flex-end;
|
1394
|
+
flex: 1;
|
1395
|
+
min-width: 0;
|
1396
|
+
opacity: 1;
|
1397
|
+
isolation: isolate;
|
1398
|
+
transform: translateY(0%);
|
1399
|
+
transition: transform 200ms ease-out;
|
1400
|
+
}
|
1401
|
+
|
1402
|
+
.controls.hide {
|
1403
|
+
pointer-events: none;
|
1404
|
+
transform: translateY(100%);
|
1405
|
+
}
|
1406
|
+
|
1407
|
+
vmp-captions {
|
1408
|
+
position: absolute;
|
1409
|
+
bottom: calc(100%);
|
1410
|
+
width: 100%;
|
1411
|
+
transform: translateY(var(--space-medium));
|
1412
|
+
transition: transform 200ms ease-out;
|
1413
|
+
}
|
1414
|
+
|
1415
|
+
vmp-captions.hiddenControls {
|
1416
|
+
transform: translateY(calc(var(--space-small) * -1));
|
1417
|
+
}
|
1418
|
+
`],Ii([De({type:Boolean})],pi.prototype,"loading",2),Ii([De({type:Boolean})],pi.prototype,"playing",2),Ii([De({type:Number})],pi.prototype,"volume",2),Ii([De({type:Boolean})],pi.prototype,"muted",2),Ii([De({type:Number})],pi.prototype,"currentTime",2),Ii([De({type:Number})],pi.prototype,"duration",2),Ii([De({type:Array,attribute:!1})],pi.prototype,"levels",2),Ii([De({type:Number})],pi.prototype,"level",2),Ii([De({type:Number})],pi.prototype,"playbackRate",2),Ii([De({type:String})],pi.prototype,"caption",2),Ii([De({type:Array})],pi.prototype,"buffer",2),Ii([De({type:Boolean})],pi.prototype,"captions",2),Ii([De({type:Boolean})],pi.prototype,"fullscreen",2),Ii([De({type:Array})],pi.prototype,"controls",2),Ii([xi()],pi.prototype,"showControls",2),pi=Ii([Ui("vmp-player-overlay")],pi);var Jx=Object.defineProperty,eb=Object.getOwnPropertyDescriptor,ri=(s,e,t,i)=>{for(var n=i>1?void 0:i?eb(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&Jx(e,t,n),n};const tb=1e3/60;let ti=class extends Rt{constructor(){super(...arguments),this.burnCaptions=!1,this.debug=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=lc,this._sceneController=new ux(this),this._drawController=new ox(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=_i(),this._canvasRef=_i(),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,tb):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:e})=>{if(e){const{key:t}=e,i=this.videoState[t];return!i||!i.initialised||i.waiting||e.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 e=setInterval(()=>{!!this.errors.find(i=>i.fatal)&&s(!1),!this.loading&&!this.processing&&this.scenes.length>0&&s(!0)},500);setTimeout(()=>{clearInterval(e),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:e,start:t,duration:i})=>{const n=(e==null?void 0:e.key)??`${t}-${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:e})=>{e&&(e.node.playbackRate=s)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:s})))}get playbackRate(){return this._playbackRate}set volume(s){const e=Math.min(1,Math.max(0,s));e!==this._volume&&(this.scenes.forEach(({video:t})=>{t&&(t.node.volume=e)}),localStorage.setItem("vmp-player-volume",e.toString()),this._volume=e,e>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:e})=>{e&&(e.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:e})=>{if(e!=null&&e.hls){const t=e.hls.levels.findIndex(i=>Math.min(i.height,i.width)===s);e.hls.currentLevel=t??-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,e=!1){this._lastTimestamp=null,this._drawController.currentTime=s,this._sceneController.setVideosCurrentTime(s),e?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 e,t;if((e=this._sceneController)!=null&&e.scenes){const i=(t=this.scenes)==null?void 0:t[s];if(!i){const n=new Fr(`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?fx():this._playerRef.value&&hx(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"?it`
|
1419
|
+
<style>
|
1420
|
+
:host {
|
1421
|
+
aspect-ratio: ${this.propAspectRatio};
|
1422
|
+
}
|
1423
|
+
</style>
|
1424
|
+
`:null:it`
|
1425
|
+
<style>
|
1426
|
+
:host {
|
1427
|
+
width: 100%;
|
1428
|
+
height: 100%;
|
1429
|
+
}
|
1430
|
+
</style>
|
1431
|
+
`}_renderError(){return it`<div class="error">
|
1432
|
+
<div class="error-icon">
|
1433
|
+
<vmp-icon icon="error"></vmp-icon>
|
1434
|
+
</div>
|
1435
|
+
<div class="error-text">
|
1436
|
+
<vmp-text semibold content="An error has occurred when attempting to play this video."></vmp-text>
|
1437
|
+
<vmp-text semibold content="Please try again later."></vmp-text>
|
1438
|
+
</div>
|
1439
|
+
</div>`}render(){var s,e,t,i,n,a;const l=this.loading||this.processing||!this.scenes||this.duration<=0,{height:h,width:d}=cc({resolution:((s=this.sceneConfig)==null?void 0:s.resolution)??720,aspectRatio:this.aspectRatio}),p=Object.keys(this.sceneVideoState).reduce(($,N)=>$.concat(this.sceneVideoState[N].buffered??[]),[]),m=l?[]:(e=this.controls??wu)==null?void 0:e.filter($=>!($==="fullscreen"&&lx()||$==="navigation"&&(!this.scenes||this.scenes.length<=1))),g=!(m!=null&&m.includes("preview")),A=(((t=this.scenes)==null?void 0:t.length)??0)-1,x=((i=this.scenes)==null?void 0:i.findIndex($=>$===this._drawController.activeScenes[0]))??0,b=(a=(n=this._drawController.activeScenes[0])==null?void 0:n.video)==null?void 0:a.hls,S=this.loading||this.waiting||this.processing,w=!this.src&&!this.data,P=!!this.errors.find($=>$.fatal);return it`
|
1440
|
+
${this._renderStyles()}
|
1441
|
+
<div
|
1442
|
+
${Ri(this._playerRef)}
|
1443
|
+
class=${Qt({player:!0,responsive:!this.propAspectRatio})}
|
1444
|
+
style=${dc({aspectRatio:this.aspectRatio})}
|
1445
|
+
>
|
1446
|
+
${!S&&(w||P)?this._renderError():it`<canvas
|
1447
|
+
${Ri(this._canvasRef)}
|
1448
|
+
${this._drawController.canvas()}
|
1449
|
+
${_u(this._handleCanvasResize)}
|
1450
|
+
height=${h}
|
1451
|
+
width=${d}
|
1452
|
+
></canvas>
|
1453
|
+
<vmp-player-overlay
|
1454
|
+
${this._drawController.controls()}
|
1455
|
+
.data=${this.data}
|
1456
|
+
.template=${this.template}
|
1457
|
+
?disabled=${l}
|
1458
|
+
?playing=${!this.paused}
|
1459
|
+
?loading=${S}
|
1460
|
+
?muted=${this.muted}
|
1461
|
+
volume=${this.volume}
|
1462
|
+
duration=${this.duration}
|
1463
|
+
.levels=${(b==null?void 0:b.levels)??[]}
|
1464
|
+
level=${qs(b!=null&&b.autoLevelEnabled?-1:b==null?void 0:b.currentLevel)}
|
1465
|
+
playbackRate=${this.playbackRate}
|
1466
|
+
caption=${this._drawController.caption}
|
1467
|
+
.buffer=${p}
|
1468
|
+
.controls=${m}
|
1469
|
+
?captions=${this.captions}
|
1470
|
+
?fullscreen=${this.fullscreen}
|
1471
|
+
@navigate:back=${$=>{$.defaultPrevented||this.setScene(x<=0?A:x-1)}}
|
1472
|
+
@navigate:forward=${$=>{$.defaultPrevented||this.setScene(x>=A?0:x+1)}}
|
1473
|
+
@play:click=${({detail:$})=>{l||($?this.pause():(this.muted=this._manualMute,this.play()))}}
|
1474
|
+
@volume:click=${({detail:$})=>{this.muted=!$,this._manualMute=!$}}
|
1475
|
+
@level:click=${({detail:$})=>{this.videoResolution=$.value.resolution}}
|
1476
|
+
@playbackRate:click=${({detail:$})=>{this.playbackRate=$.value??1}}
|
1477
|
+
@captions:click=${()=>{this._captions=!this._captions}}
|
1478
|
+
@fullscreen:click=${()=>{this.toggleFullscreen()}}
|
1479
|
+
@input=${$=>{const N=$.composedPath()[0],I=N.getAttribute("key");if(I==="scrubber"){const O=parseFloat(N.value);this._drawController.currentTime=O,this._sceneController.setVideosCurrentTime(O),this.dispatchEvent(new CustomEvent("seeking",{detail:O}))}I==="volume"&&(this.volume=parseFloat(N.value))}}
|
1480
|
+
@pointerdown=${$=>{$.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!0,this._wasPlaying=!this.paused,this.paused||this.pause())}}
|
1481
|
+
@pointerup=${$=>{$.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!1,this._wasPlaying&&(this.play(),this._wasPlaying=!1),this.dispatchEvent(new CustomEvent("seeked",{detail:this._drawController.currentTime})))}}
|
1482
|
+
></vmp-player-overlay>
|
1483
|
+
<vmp-video-preview
|
1484
|
+
?disabled=${g}
|
1485
|
+
.src=${this.src}
|
1486
|
+
.data=${this.data}
|
1487
|
+
.template=${this.template}
|
1488
|
+
.aspectRatio=${this.aspectRatio}
|
1489
|
+
.compilation=${this.compilation}
|
1490
|
+
></vmp-video-preview>`}
|
1491
|
+
</div>
|
1492
|
+
`}};ti.styles=[Rt.styles??[],Ei`
|
1493
|
+
:host {
|
1494
|
+
--player-border-radius: var(--vouch-media-player-border-radius, 0px);
|
1495
|
+
|
1496
|
+
display: flex;
|
1497
|
+
}
|
1498
|
+
|
1499
|
+
.player {
|
1500
|
+
position: relative;
|
1501
|
+
display: flex;
|
1502
|
+
align-items: center;
|
1503
|
+
justify-content: center;
|
1504
|
+
background: var(--colors-dark-1000);
|
1505
|
+
border-radius: var(--player-border-radius);
|
1506
|
+
}
|
1507
|
+
|
1508
|
+
.responsive {
|
1509
|
+
width: 100%;
|
1510
|
+
height: 100%;
|
1511
|
+
}
|
1512
|
+
|
1513
|
+
.error {
|
1514
|
+
display: flex;
|
1515
|
+
align-items: center;
|
1516
|
+
justify-content: center;
|
1517
|
+
gap: var(--space-xxs);
|
1518
|
+
padding: var(--space-medium);
|
1519
|
+
width: 100%;
|
1520
|
+
height: 100%;
|
1521
|
+
color: white;
|
1522
|
+
}
|
1523
|
+
|
1524
|
+
.error-icon {
|
1525
|
+
color: var(--colors-red-500);
|
1526
|
+
}
|
1527
|
+
|
1528
|
+
.error-text {
|
1529
|
+
display: flex;
|
1530
|
+
flex-direction: column;
|
1531
|
+
}
|
1532
|
+
|
1533
|
+
canvas {
|
1534
|
+
width: 100%;
|
1535
|
+
max-height: 100%;
|
1536
|
+
object-fit: contain;
|
1537
|
+
border-radius: var(--player-border-radius);
|
1538
|
+
}
|
1539
|
+
|
1540
|
+
vmp-player-overlay {
|
1541
|
+
position: absolute;
|
1542
|
+
top: 0;
|
1543
|
+
left: 0;
|
1544
|
+
right: 0;
|
1545
|
+
bottom: 0;
|
1546
|
+
}
|
1547
|
+
|
1548
|
+
vmp-video-preview {
|
1549
|
+
position: absolute;
|
1550
|
+
top: 0;
|
1551
|
+
left: 0;
|
1552
|
+
}
|
1553
|
+
`],ri([De({type:Object})],ti.prototype,"data",2),ri([De({type:Object})],ti.prototype,"template",2),ri([De({type:Boolean})],ti.prototype,"burnCaptions",2),ri([De({type:Boolean})],ti.prototype,"debug",2),ri([De({type:String})],ti.prototype,"src",2),ri([De({type:String})],ti.prototype,"track",2),ri([De({type:Number,attribute:"aspectratio"})],ti.prototype,"propAspectRatio",2),ri([De({type:String})],ti.prototype,"preload",2),ri([De({type:Boolean})],ti.prototype,"autoplay",2),ri([De({type:Boolean})],ti.prototype,"loading",2),ri([De({type:Array})],ti.prototype,"controls",2),ri([De({attribute:!1})],ti.prototype,"compilation",2),ri([xi()],ti.prototype,"_pageHidden",2),ri([xi()],ti.prototype,"_aspectRatio",2),ri([xi()],ti.prototype,"_processing",2),ri([xi()],ti.prototype,"_waiting",2),ri([xi()],ti.prototype,"_errors",2),ri([xi()],ti.prototype,"_seeking",2),ri([xi()],ti.prototype,"_captions",2),ri([xi()],ti.prototype,"_fullscreen",2),ti=ri([Ui("vmp-media-player")],ti);var ib=Object.defineProperty,rb=Object.getOwnPropertyDescriptor,Bi=(s,e,t,i)=>{for(var n=i>1?void 0:i?rb(e,t):e,a=s.length-1,l;a>=0;a--)(l=s[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&ib(e,t,n),n};Ft.PlayerEmbed=class extends En{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 i2(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 w2(this),this._trackingController=new ev(this),this._mediaPlayerRef=_i()}get fetching(){return this._fetcherController.fetching}get waiting(){var e;return(e=this._mediaPlayerRef.value)==null?void 0:e.waiting}get initialised(){var e;return(e=this._mediaPlayerRef.value)==null?void 0:e.initialised}get seeking(){var e;return(e=this._mediaPlayerRef.value)==null?void 0:e.seeking}get paused(){var e;return(e=this._mediaPlayerRef.value)==null?void 0:e.paused}get captions(){var e;return(e=this._mediaPlayerRef.value)==null?void 0:e.captions}get fullscreen(){var e;return(e=this._mediaPlayerRef.value)==null?void 0:e.fullscreen}get duration(){var e;return(e=this._mediaPlayerRef.value)==null?void 0:e.duration}set currentTime(e){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.currentTime=e)}get currentTime(){var e;return((e=this._mediaPlayerRef.value)==null?void 0:e.currentTime)??0}set playbackRate(e){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.playbackRate=e)}get playbackRate(){var e;return((e=this._mediaPlayerRef.value)==null?void 0:e.playbackRate)??1}set volume(e){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.volume=e)}get volume(){var e;return((e=this._mediaPlayerRef.value)==null?void 0:e.volume)??1}set muted(e){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.muted=e)}get muted(){var e;return((e=this._mediaPlayerRef.value)==null?void 0:e.muted)??!1}get scene(){var e;return((e=this._mediaPlayerRef.value)==null?void 0:e.scene)??null}get scenes(){var e;return((e=this._mediaPlayerRef.value)==null?void 0:e.scenes)??[]}get sceneConfig(){var e;return((e=this._mediaPlayerRef.value)==null?void 0:e.sceneConfig)??null}get videoState(){var e;return(e=this._mediaPlayerRef.value)==null?void 0:e.videoState}get mediaPlayer(){return this._mediaPlayerRef.value}play(){var e;(e=this._mediaPlayerRef.value)==null||e.play()}pause(){var e;(e=this._mediaPlayerRef.value)==null||e.pause()}reset(e=0,t=!1){var i;(i=this._mediaPlayerRef.value)==null||i.reset(e,t)}setScene(e){var t;(t=this._mediaPlayerRef.value)==null||t.setScene(e)}_renderStyles(){return this.aspectRatio?typeof this.aspectRatio=="number"?it`
|
1554
|
+
<style>
|
1555
|
+
:host {
|
1556
|
+
aspect-ratio: ${this.aspectRatio};
|
1557
|
+
}
|
1558
|
+
</style>
|
1559
|
+
`:null:it`
|
1560
|
+
<style>
|
1561
|
+
:host {
|
1562
|
+
width: 100%;
|
1563
|
+
height: 100%;
|
1564
|
+
}
|
1565
|
+
</style>
|
1566
|
+
`}render(){return it`
|
1567
|
+
${this._renderStyles()}
|
1568
|
+
<vmp-media-player
|
1569
|
+
${Ri(this._mediaPlayerRef)}
|
1570
|
+
${this.eventController.register()}
|
1571
|
+
?autoplay=${this.autoplay}
|
1572
|
+
?loading=${this.fetching}
|
1573
|
+
.data=${this.vouch}
|
1574
|
+
.template=${this.template}
|
1575
|
+
aspectRatio=${qs(this.aspectRatio)}
|
1576
|
+
preload=${qs(this.preload)}
|
1577
|
+
.controls=${this.controls}
|
1578
|
+
></vmp-media-player>
|
1579
|
+
`}},Ft.PlayerEmbed.styles=[Ei`
|
1580
|
+
:host {
|
1581
|
+
display: flex;
|
1582
|
+
}
|
1583
|
+
`],Bi([De({type:Object})],Ft.PlayerEmbed.prototype,"data",2),Bi([De({type:String})],Ft.PlayerEmbed.prototype,"vouchId",2),Bi([De({type:String})],Ft.PlayerEmbed.prototype,"templateId",2),Bi([De({type:Array})],Ft.PlayerEmbed.prototype,"questions",2),Bi([De({type:String})],Ft.PlayerEmbed.prototype,"env",2),Bi([De({type:String})],Ft.PlayerEmbed.prototype,"apiKey",2),Bi([De({type:Boolean})],Ft.PlayerEmbed.prototype,"disableTracking",2),Bi([De({type:String})],Ft.PlayerEmbed.prototype,"trackingSource",2),Bi([De({type:Array})],Ft.PlayerEmbed.prototype,"controls",2),Bi([De({type:String})],Ft.PlayerEmbed.prototype,"preload",2),Bi([De({type:Boolean})],Ft.PlayerEmbed.prototype,"autoplay",2),Bi([De({type:Number})],Ft.PlayerEmbed.prototype,"aspectRatio",2),Bi([xi()],Ft.PlayerEmbed.prototype,"vouch",2),Bi([xi()],Ft.PlayerEmbed.prototype,"template",2),Ft.PlayerEmbed=Bi([Hg("vouch-embed-player")],Ft.PlayerEmbed);function Ur(s){if(typeof s!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(s))}function Bp(s,e){for(var t="",i=0,n=-1,a=0,l,h=0;h<=s.length;++h){if(h<s.length)l=s.charCodeAt(h);else{if(l===47)break;l=47}if(l===47){if(!(n===h-1||a===1))if(n!==h-1&&a===2){if(t.length<2||i!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var d=t.lastIndexOf("/");if(d!==t.length-1){d===-1?(t="",i=0):(t=t.slice(0,d),i=t.length-1-t.lastIndexOf("/")),n=h,a=0;continue}}else if(t.length===2||t.length===1){t="",i=0,n=h,a=0;continue}}e&&(t.length>0?t+="/..":t="..",i=2)}else t.length>0?t+="/"+s.slice(n+1,h):t=s.slice(n+1,h),i=h-n-1;n=h,a=0}else l===46&&a!==-1?++a:a=-1}return t}function sb(s,e){var t=e.dir||e.root,i=e.base||(e.name||"")+(e.ext||"");return t?t===e.root?t+i:t+s+i:i}var Nn={resolve:function(){for(var e="",t=!1,i,n=arguments.length-1;n>=-1&&!t;n--){var a;n>=0?a=arguments[n]:(i===void 0&&(i=process.cwd()),a=i),Ur(a),a.length!==0&&(e=a+"/"+e,t=a.charCodeAt(0)===47)}return e=Bp(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(Ur(e),e.length===0)return".";var t=e.charCodeAt(0)===47,i=e.charCodeAt(e.length-1)===47;return e=Bp(e,!t),e.length===0&&!t&&(e="."),e.length>0&&i&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return Ur(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var i=arguments[t];Ur(i),i.length>0&&(e===void 0?e=i:e+="/"+i)}return e===void 0?".":Nn.normalize(e)},relative:function(e,t){if(Ur(e),Ur(t),e===t||(e=Nn.resolve(e),t=Nn.resolve(t),e===t))return"";for(var i=1;i<e.length&&e.charCodeAt(i)===47;++i);for(var n=e.length,a=n-i,l=1;l<t.length&&t.charCodeAt(l)===47;++l);for(var h=t.length,d=h-l,p=a<d?a:d,m=-1,g=0;g<=p;++g){if(g===p){if(d>p){if(t.charCodeAt(l+g)===47)return t.slice(l+g+1);if(g===0)return t.slice(l+g)}else a>p&&(e.charCodeAt(i+g)===47?m=g:g===0&&(m=0));break}var A=e.charCodeAt(i+g),x=t.charCodeAt(l+g);if(A!==x)break;A===47&&(m=g)}var b="";for(g=i+m+1;g<=n;++g)(g===n||e.charCodeAt(g)===47)&&(b.length===0?b+="..":b+="/..");return b.length>0?b+t.slice(l+m):(l+=m,t.charCodeAt(l)===47&&++l,t.slice(l))},_makeLong:function(e){return e},dirname:function(e){if(Ur(e),e.length===0)return".";for(var t=e.charCodeAt(0),i=t===47,n=-1,a=!0,l=e.length-1;l>=1;--l)if(t=e.charCodeAt(l),t===47){if(!a){n=l;break}}else a=!1;return n===-1?i?"/":".":i&&n===1?"//":e.slice(0,n)},basename:function(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ur(e);var i=0,n=-1,a=!0,l;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var h=t.length-1,d=-1;for(l=e.length-1;l>=0;--l){var p=e.charCodeAt(l);if(p===47){if(!a){i=l+1;break}}else d===-1&&(a=!1,d=l+1),h>=0&&(p===t.charCodeAt(h)?--h===-1&&(n=l):(h=-1,n=d))}return i===n?n=d:n===-1&&(n=e.length),e.slice(i,n)}else{for(l=e.length-1;l>=0;--l)if(e.charCodeAt(l)===47){if(!a){i=l+1;break}}else n===-1&&(a=!1,n=l+1);return n===-1?"":e.slice(i,n)}},extname:function(e){Ur(e);for(var t=-1,i=0,n=-1,a=!0,l=0,h=e.length-1;h>=0;--h){var d=e.charCodeAt(h);if(d===47){if(!a){i=h+1;break}continue}n===-1&&(a=!1,n=h+1),d===46?t===-1?t=h:l!==1&&(l=1):t!==-1&&(l=-1)}return t===-1||n===-1||l===0||l===1&&t===n-1&&t===i+1?"":e.slice(t,n)},format:function(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return sb("/",e)},parse:function(e){Ur(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var i=e.charCodeAt(0),n=i===47,a;n?(t.root="/",a=1):a=0;for(var l=-1,h=0,d=-1,p=!0,m=e.length-1,g=0;m>=a;--m){if(i=e.charCodeAt(m),i===47){if(!p){h=m+1;break}continue}d===-1&&(p=!1,d=m+1),i===46?l===-1?l=m:g!==1&&(g=1):l!==-1&&(g=-1)}return l===-1||d===-1||g===0||g===1&&l===d-1&&l===h+1?d!==-1&&(h===0&&n?t.base=t.name=e.slice(1,d):t.base=t.name=e.slice(h,d)):(h===0&&n?(t.name=e.slice(1,l),t.base=e.slice(1,d)):(t.name=e.slice(h,l),t.base=e.slice(h,d)),t.ext=e.slice(l,d)),h>0?t.dir=e.slice(0,h-1):n&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};Nn.posix=Nn;var nb=Nn;const{basename:Gp,extname:ob}=nb;class ab{constructor(){let e=(()=>typeof ca>"u")(),t="image/png",i="image/jpeg",n="image/jpeg",a="image/webp",l="application/pdf",h="image/svg+xml";Object.assign(this,{toMime:this.toMime.bind(this),fromMime:this.fromMime.bind(this),expected:e?'"png", "jpg", or "webp"':'"png", "jpg", "pdf", or "svg"',formats:e?{png:t,jpg:i,jpeg:n,webp:a}:{png:t,jpg:i,jpeg:n,pdf:l,svg:h},mimes:e?{[t]:"png",[i]:"jpg",[a]:"webp"}:{[t]:"png",[i]:"jpg",[l]:"pdf",[h]:"svg"}})}toMime(e){return this.formats[(e||"").replace(/^\./,"").toLowerCase()]}fromMime(e){return this.mimes[e]}}function lb(s,{filename:e="",extension:t="",format:S,page:n,quality:a,matte:l,density:h,outline:d,archive:x}={}){var{fromMime:m,toMime:g,expected:A}=new ab,x=x||"canvas",b=S||t.replace(/@\d+x$/i,"")||ob(e),S=m(g(b)||b),w=g(S),P=s.length;if(!b)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!S)throw new Error(`Unsupported file format "${b}" (expected ${A})`);if(!P)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let $,N,I=e.replace(/{(\d*)}/g,(K,U)=>(N=!0,U=parseInt(U,10),$=isFinite(U)?U:isFinite($)?$:-1,"{}")),O=n>0?n-1:n<0?P+n:void 0;if(isFinite(O)&&O<0||O>=P)throw new RangeError(P==1?`Canvas only has a ‘page 1’ (${O} is out of bounds)`:`Canvas has pages 1–${P} (${O} is out of bounds)`);if(s=isFinite(O)?[s[O]]:N||S=="pdf"?s:s.slice(-1),a===void 0)a=.92;else if(typeof a!="number"||!isFinite(a)||a<0||a>1)throw new TypeError("The quality option must be an number in the 0.0–1.0 range");if(h===void 0){let K=(t||Gp(e,b)).match(/@(\d+)x$/i);h=K?parseInt(K[1],10):1}else if(typeof h!="number"||!Number.isInteger(h)||h<1)throw new TypeError("The density option must be a non-negative integer");return d===void 0?d=!0:S=="svg"&&(d=!!d),{filename:e,pattern:I,format:S,mime:w,pages:s,padding:$,quality:a,matte:l,density:h,outline:d,archive:x}}class ll{static for(e){return new ll().append(e).get()}constructor(){this.crc=-1}get(){return~this.crc}append(e){for(var t=this.crc|0,i=this.table,n=0,a=e.length|0;n<a;n++)t=t>>>8^i[(t^e[n])&255];return this.crc=t,this}}ll.prototype.table=(()=>{var s,e,t,i=[];for(s=0;s<256;s++){for(t=s,e=0;e<8;e++)t=t&1?t>>>1^3988292384:t>>>1;i[s]=t}return i})();function Ou(s){let e=new Uint8Array(s),t=new DataView(e.buffer),i={array:e,view:t,size:s,set8(n,a){return t.setUint8(n,a),i},set16(n,a){return t.setUint16(n,a,!0),i},set32(n,a){return t.setUint32(n,a,!0),i},bytes(n,a){return e.set(a,n),i}};return i}const cl=class cl{constructor(e){let t=new Date;Object.assign(this,{directory:e,offset:0,files:[],time:(t.getHours()<<6|t.getMinutes())<<5|t.getSeconds()/2,date:(t.getFullYear()-1980<<4|t.getMonth()+1)<<5|t.getDate()}),this.add(e)}async add(e,t){let i=!t,n=cl.encoder.encode(`${this.directory}/${i?"":e}`),a=new Uint8Array(i?0:await t.arrayBuffer()),l=30+n.length,h=l+a.length,d=16,{offset:p}=this,m=Ou(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,ll.for(a)).set32(14,a.length).set32(18,a.length).set16(22,n.length);p+=l;let g=Ou(l+a.length+d).set32(0,67324752).bytes(4,m.array).bytes(30,n).bytes(l,a);p+=a.length,g.set32(h,134695760).bytes(h+4,m.array.slice(10,22)),p+=d,this.files.push({offset:p,folder:i,name:n,header:m,payload:g}),this.offset=p}toBuffer(){let e=this.files.reduce((g,{name:A})=>46+A.length+g,0),t=Ou(e+22),i=0;for(var{offset:n,name:a,header:l,folder:h}of this.files)t.set32(i,33639248).set16(i+4,20).bytes(i+6,l.array).set8(i+38,h?16:0).set32(i+42,n).bytes(i+46,a),i+=46+a.length;t.set32(i,101010256).set16(i+8,this.files.length).set16(i+10,this.files.length).set32(i+12,e).set32(i+16,this.offset);let d=new Uint8Array(this.offset+t.size),p=0;for(var{payload:m}of this.files)d.set(m.array,p),p+=m.size;return d.set(t.array,p),d}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}};ug(cl,"encoder",new TextEncoder);let Pu=cl;const $u=(s,e,t,i)=>{if(i){let{width:n,height:a}=s,l=Object.assign(document.createElement("canvas"),{width:n,height:a}),h=l.getContext("2d");h.fillStyle=i,h.fillRect(0,0,n,a),h.drawImage(s,0,0),s=l}return new Promise((n,a)=>s.toBlob(n,e,t))},cb=(...s)=>$u(...s).then(e=>e.arrayBuffer()),ub=async(s,e,t,i,n)=>{Vp(n,await $u(s,e,t,i))},hb=async(s,e,t,i,n,a,l)=>{let h=m=>a.replace("{}",String(m+1).padStart(l,"0")),d=Gp(n,".zip")||"archive",p=new Pu(d);await Promise.all(s.map(async(m,g)=>{let A=h(g);await p.add(A,await $u(m,e,t,i))})),Vp(`${d}.zip`,p.blob)},Vp=(s,e)=>{const t=window.URL.createObjectURL(e),i=document.createElement("a");i.style.display="none",i.href=t,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(t),100)};var fb={asBuffer:cb,asDownload:ub,asZipDownload:hb,atScale:(s,e,t)=>s.map(i=>{if(e==1&&!t)return i.canvas;let n=document.createElement("canvas"),a=n.getContext("2d"),l=i.canvas?i.canvas:i;return n.width=l.width*e,n.height=l.height*e,t&&(a.fillStyle=t,a.fillRect(0,0,n.width,n.height)),a.scale(e,e),a.drawImage(l,0,0),n}),options:lb};const{asBuffer:Mu,asDownload:db,asZipDownload:pb,atScale:Fu,options:Nu}=fb,Hp=Symbol.for("toDataURL"),mb=s=>{let e=Object.assign(new Wp,{crossOrigin:"Anonymous",src:s});return e.decode().then(()=>e)};class gb{constructor(e,t){let i=document.createElement("canvas"),n=[];Object.defineProperty(i,"async",{value:!0,writable:!1,enumerable:!0});for(var[a,l]of Object.entries({png:()=>Mu(i,"image/png"),jpg:()=>Mu(i,"image/jpeg"),pages:()=>n.concat(i).map(h=>h.getContext("2d"))}))Object.defineProperty(i,a,{get:l});return Object.assign(i,{width:e,height:t,newPage(...h){var{width:p,height:m}=i,d=Object.assign(document.createElement("canvas"),{width:p,height:m});d.getContext("2d").drawImage(i,0,0),n.push(d);var[p,m]=h.length?h:[p,m];return Object.assign(i,{width:p,height:m}).getContext("2d")},saveAs(h,d){d=typeof d=="number"?{quality:d}:d;let p=Nu(this.pages,{filename:h,...d}),{pattern:m,padding:g,mime:A,quality:x,matte:b,density:S,archive:w}=p,P=Fu(p.pages,S);return g==null?db(P[0],A,x,b,h):pb(P,A,x,b,w,m,g)},toBuffer(h="png",d={}){d=typeof d=="number"?{quality:d}:d;let p=Nu(this.pages,{extension:h,...d}),{mime:m,quality:g,matte:A,pages:x,density:b}=p,S=Fu(x,b,A)[0];return Mu(S,m,g,A)},[Hp]:i.toDataURL.bind(i),toDataURL(h="png",d={}){d=typeof d=="number"?{quality:d}:d;let p=Nu(this.pages,{extension:h,...d}),{mime:m,quality:g,matte:A,pages:x,density:b}=p,S=Fu(x,b,A)[0],w=S[S===i?Hp:"toDataURL"](m,g);return Promise.resolve(w)}})}}const{CanvasRenderingContext2D:vb,CanvasGradient:yb,CanvasPattern:Ab,Image:Wp,ImageData:Eb,Path2D:xb,DOMMatrix:bb,DOMRect:Tb,DOMPoint:Sb}=window;var jp={Canvas:gb,loadImage:mb,CanvasRenderingContext2D:vb,CanvasGradient:yb,CanvasPattern:Ab,Image:Wp,ImageData:Eb,Path2D:xb,DOMMatrix:bb,DOMRect:Tb,DOMPoint:Sb};const Kp=Xr({__proto__:null,default:ua(jp)},[jp]);return Object.defineProperty(Ft,Symbol.toStringTag,{value:"Module"}),Ft}({});
|
1584
|
+
//# sourceMappingURL=embed.iife.js.map
|